@mrakomor/core 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockChrome.mjs +1 -1
- package/dist/blockInsertMenu.mjs +1 -1
- package/dist/chunk-4WTPDNPA.mjs +1 -0
- package/dist/chunk-5AD5MQXI.mjs +1 -0
- package/dist/{chunk-JVQ2YGII.mjs → chunk-B2UFH244.mjs} +1 -1
- package/dist/{chunk-5HWTMPF4.mjs → chunk-BWK2S4UI.mjs} +2 -2
- package/dist/{chunk-FAXIFXQK.mjs → chunk-D6K2L5O3.mjs} +1 -1
- package/dist/{chunk-6CG6EGQM.mjs → chunk-DHFIX7FW.mjs} +1 -1
- package/dist/{chunk-TL5BHWDU.mjs → chunk-J4TTWQ6J.mjs} +1 -1
- package/dist/{chunk-GDDVUIEH.mjs → chunk-SG5PCGIV.mjs} +1 -1
- package/dist/clipboard.mjs +1 -1
- package/dist/footer.cjs +1 -1
- package/dist/footer.mjs +2 -2
- package/dist/headline.mjs +1 -1
- package/dist/help.cjs +1 -1
- package/dist/help.mjs +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.mjs +1 -1
- package/dist/link.mjs +1 -1
- package/dist/list.cjs +2 -2
- package/dist/list.mjs +1 -1
- package/dist/paragraph.cjs +2 -2
- package/dist/paragraph.mjs +1 -1
- package/dist/slashCommand.cjs +2 -2
- package/dist/slashCommand.mjs +1 -1
- package/dist/tooltip.mjs +1 -1
- package/dist/tts.cjs +5 -5
- package/dist/tts.mjs +1 -1
- package/dist/types/dom.d.mts +8 -0
- package/package.json +10 -9
- package/dist/chunk-P7TUN2KD.mjs +0 -1
- package/dist/chunk-S2W6LYHT.mjs +0 -1
package/dist/list.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/list/List.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=`.molecule-list-list{margin:0 0 1em;padding-inline-start:1.5em}.molecule-list-list li{margin:.25em 0;outline:none}.molecule-list-list li:focus{outline:none}.molecule-list-list li[data-depth="1"]{margin-inline-start:1.5em}.molecule-list-list li[data-depth="2"]{margin-inline-start:3em}.molecule-list-list li[data-depth="3"]{margin-inline-start:4.5em}
|
|
2
|
-
`,document.head.appendChild(n);}}})();var dt=class{next(...e){}error(...e){}complete(...e){}},ve=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 ue=Symbol("@esmj/signals:type"),J=Symbol("@esmj/signals:name");var R=null,Te=false,Oe=[];function v(e){let t=R;R=null;let n=e();return R=t,n}function Tn(){Te=false;let e=St();for(let n of e)n.get();let t=Oe;Oe=[];for(let n of t)n();}function ht(){Te||(Te=true,queueMicrotask(Tn));}function Me(e){Oe.push(e),ht();}var Et=Symbol("@esmj/signals:internal observable"),L=Symbol("@esmj/signals:original function"),On=class extends ve{#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[L]=void 0),e instanceof bt&&e.next[L]===void 0){let t=e.next.bind(e);e.next=()=>v(()=>{this.#e.add(e),t(),this.#r();}),e.next[L]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[L]){let n=t.get,r=n.bind(t);t.get=()=>v(()=>(this.#e.delete(t),r())),t.get[L]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[L]?e.next[L]:e.next,e.get=e.get[L]?e.get[L]:e.get,this.#e.delete(e),this.unsubscribe(e)}},fe=null;function yt(e){fe=new On(e);}yt(()=>{ht();});function St(){return fe.getPending()}function xt(e){return fe.watch(e)}function Ct(e){return fe.unwatch(e)}var A=Symbol("@esmj/signals:no error"),bt=class Rt extends dt{#e=true;#r=false;#t=null;#o=this.#p();#a=null;#l=null;#i=0;#s=new Map;#n=A;constructor(t,n){super(),this.#a=t,this.#l=n,this.debug=n?.debug,this[ue]="computed",this[J]=n?.debug??null,this.get=this.get.bind(this);}#u(){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[J],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Rt&&v(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[Et].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=$(this.#c(),this.#l)),(this.#e||this.#n!==A)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),R&&R.sourceRevisions.set(this,this.#i),this.#n!==A)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=$(this.#c(),this.#l)),(this.#e||this.#n!==A)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),this.#n!==A)throw this.#n;return this.#t.peek()}#c(){this.#r=true,this.#e=false,this.#n=A,this.#u(),this.#o.sourceRevisions.clear();let t=R;R=this.#o;let n;try{n=this.#a();}catch(r){this.#n=r;}return R=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=A,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===A&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#n=A;}};function F(e,t){return new bt(e,t)}function I(e,t){let n,{debug:r,...o}={},s=F(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),xt(s);let i=()=>{n?.(),s.destroy(),Ct(s);};return i[Symbol.dispose]=i,i[ue]="effect",i[J]=r??null,i.__RX_COMPUTED__=s,i}function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new ve;function s(){return R&&(R.dependencies.set(o,o.subscribe(R.observer)),R.sourceRevisions.set(a,r)),e}function i(){return e}function c(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let a={get:s,set:c,peek:i,getRevision:l,[Et]:o,[ue]:"signal",[J]:t?.debug??null};return a}function pe(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Tt=Symbol("node-component"),me=Symbol("node-internal"),Mn=Symbol("keep-literal"),Ee=Symbol("raw-props");function $e(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function Fe(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var wn=new Set(["template","script"]);function Dn(e,t){let n=(e==null?"span":String(e)).trim(),r=n;wn.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${e}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),r="span");let o=document.createElement(r);return r==="span"&&(o.style.display="contents"),o.setAttribute(t,pe()),o}function He(e,t,n){let r=Dn(e,t);return n?.id&&r.setAttribute("id",n.id),r}var Ot=null;function H(){return Ot}function ge(e){Ot=e;}function ye(e){return e?.[Tt]||null}function kt(e,t){e[Tt]=t;}function de(e,t={disposers:[],id:pe()}){return e?.[me]?e[me]:(e&&(e[me]=t),t)}function Pn(e){return e[me]}function M(e,t){let n=Pn(e);n||(n=de(e)),n.disposers.push(t);}function De(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function w(e,t){let n=H();ge(e);try{return t()}finally{ge(n);}}var Pe=new Map,he=new Map,_t=new Map;function Mt(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let s=e[o];o==="children"||n(o)?r[o]=s:s?.[Mn]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=F(s):r[o]=$(s);}return r}function Se(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?false:n.every(o=>{let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(t,o);if(!s||!i)return false;let c="value"in s?s.value:s.get?.call(e),l="value"in i?i.value:i.get?.call(t);return Se(c,l)})}function Ke(e){return {id:Symbol("context-id"),defaultValue:e}}function Ue(e){let t=H();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function N(e){Me(()=>{setTimeout(e,0);});}function ee(e){let t=e.componentId,n=Pe.get(t);if(n){Pe.delete(t);for(let r of n){let o=r();typeof o=="function"&&De(he,t,o);}}}function jn(e){let t=he.get(e);if(t){he.delete(e);for(let n of t)n();}}function $n(e){let t=_t.get(e);if(t){_t.delete(e);for(let n of t)n();}}function xe(e){if(!e)return;let t=de(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=ye(e);if(n&&(jn(n.componentId),$n(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;xe(r),r=o;}}}function K(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function It(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function Fn(e,t,n){let r=pe(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=It(e)?void 0:e[Ee],i={...Mt(t??{},s),children:n},c=H(),l={disposers:[],id:r,contexts:new Map(c?.contexts)};ge(l);let a;if(It(e)){o.ClassConstructor=e;let f=new e(i);o.classInstance=f,typeof f.onMount=="function"&&De(Pe,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&De(he,r,()=>{f.onUnmount?.();}),a=f.render();}else a=e(i);ge(c);let u=Hn(a);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)de(f,l),kt(f,o);else de(u,l),u instanceof Node&&kt(u,o);return u}};return o}function qe(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{ee(t);});}function Hn(e){return e instanceof Node?e:K(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Nt={className:"class",htmlFor:"for"},Bt=new Set(["value","defaultValue","checked","selected","indeterminate"]),Kn=new Set(["srcdoc"]),Un=new Set(["href","src","action","formaction","xlink:href"]),qn=new Set(["securitypolicyviolation"]),Gn=new Set(["contenteditable","draggable","spellcheck"]);function Z(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var wt=Symbol("Fragment");function V(e,t,n){if(e===wt){let o=document.createDocumentFragment();return je(o,At(n)),o}if(typeof e=="function")return Fn(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),Ce(r,t),je(r,At(n)),r}function we(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Vn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Yn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Kn.has(n)?true:Un.has(n)&&t!==null&&t!==void 0&&Vn(String(t))}function Dt(e){return typeof e!="string"?e:Nt[e]?Nt[e]:e}function zn(e,t){let n=Dt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Gn.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Lt(e,t,n){let r=zn(t,n);if(r===null){e.removeAttribute(t);return}if(Yn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function Ce(e,t){let n=H();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=Dt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(Z(o)){let s=I(()=>{w(n,()=>{we(e,o.get());});});M(e,s);}else if(typeof o=="function"){let s=I(()=>{w(n,()=>{we(e,o());});});M(e,s);}else we(e,o);continue}if(r==="style"){if(Z(o)){let s=I(()=>{w(n,()=>{Object.assign(e.style,o.get());});});M(e,s);}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 s=r.slice(2).toLowerCase();if(qn.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(Z(o)||typeof o=="function"){let s=r,i=I(()=>{w(n,()=>{let c=typeof o=="function"?o():o.get();Bt.has(s)?e[s]=c??"":Lt(e,s,c);});});M(e,i);continue}Bt.has(r)||typeof r=="symbol"?e[r]=o??"":Lt(e,r,o);}}function At(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function je(e,t){for(let n of t)Pt(e,n);}function Pt(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"){vt(e,t);return}if(K(t)){qe(e,t);return}if(Z(t)){vt(e,()=>t.get());return}if(Array.isArray(t)){je(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function Y(e){let t=null,n=e;return K(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 be(e,t=true){for(let n of e)t&&xe(n),n.remove();}function vt(e,t){let n=H(),r=document.createComment("");e.appendChild(r);let o=[],s=I(()=>{w(n,()=>{let i=t(),{nodes:c,instance:l}=Y(i);be(o),c.length&&r.after(...c),l&&queueMicrotask(()=>ee(l)),o=c;});});M(e,s);}var Ft=class{constructor(e){this.props=e;}};function jt(e,t,n,r){let{equals:o=Se,tagName:s="span",...i}=r??{},c=He(s,"data-for",i);Ce(c,i);let l=H(),a=[],u=new Map,f=F(()=>e()),p=I(()=>{let m=f.get(),h=Array.isArray(m)?m:[],S=[],y=[],P=new Set;for(let d=0;d<h.length;d++){let b=h[d],_=t(b,d);if(P.has(_)){console.error(`For: duplicate key "${String(_)}" detected; ignoring later item at index ${d}`);continue}P.add(_),S.push(b),y.push(_);}let G=new Map(a.map(d=>[d.key,d])),O=[];for(let d=0;d<S.length;d++){let b=y[d],_=S[d],j=G.get(b);if(j)u.get(b).set(_),O.push(j),G.delete(b);else {let pt=$(_,{equals:o});u.set(b,pt);let Nn={...pt,set(){}},mt={key:b,nodes:[]};w(l,()=>{let Bn=n(Nn,d),{nodes:Ln,instance:gt}=Y(Bn);mt.nodes=Ln,gt&&queueMicrotask(()=>ee(gt));}),O.push(mt);}}for(let[d,b]of G)be(b.nodes),u.delete(d);let B=null;for(let d=O.length-1;d>=0;d--){let b=O[d].nodes;for(let _=b.length-1;_>=0;_--){let j=b[_];(j.parentNode!==c||j.nextSibling!==B)&&c.insertBefore(j,B),B=j;}}a=O;});return M(c,p),c}function Ge(e,t,n,r){if(typeof e=="function")return jt(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:c,children:l,...a}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=$e(o),f=Fe(e??{},t);return jt(u,s,f,{...a,equals:i,tagName:c})}Ge[Ee]=e=>e!=="each";function Ht(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(xe(e),e.innerHTML=""),K(t)?qe(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Xn={abortEarly:true};function Xe(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 Jn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Xe(e.errors[r],n));}function qt(e,t,n,r){if(n!==false){let o=Xe(e.error,t);return {success:false,error:o,errors:[o]}}Jn(e,r,t);}function Re(e){return e?.abortEarly!==void 0?e:Xn}function Ve(e,t){x(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var te=e=>typeof e=="string"||e instanceof String,Ye=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),ze=e=>e===true||e===false,Qn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Zn=e=>typeof e=="function",er=e=>Array.isArray(e),We=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Gt(e,t){let n=k(We,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,s])=>`${o}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:s="always"}={}){return x(this,"_parse",(i,c,l)=>{let a=i(c,l);if(!a.success)return a;let u=o(a.data,{context:l?.context});if(!We(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={...a.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...a.data,...u}}}),this},x(n,"_parse",(o,s,i)=>{let c=o(s,i),{abortEarly:l}=Re(i);if(c.success===false)return c;let a={},u=[];for(let f in e){let p=e[f]._parse(c.data[f],i);if(p.success)a[f]=p.data;else {let m=qt(p,f,l,u);if(m)return m}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:a}}),r}function Je(e){return k(te,{...e,type:"string"})}function Qe(e){return k(Ye,{...e,type:"number"})}function Ze(e){return k(ze,{...e,type:"boolean"})}function et(e){return k(Qn,{...e,type:"date"})}function Vt(e){return k(Zn,{...e,type:"function"})}function Yt(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${i}".`,o="enum",s=k(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function zt(e,t){let n=k(er,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,x(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:c}=Re(s);if(i.success===false)return i;let l=[],a=[],u=s;for(let f=0;f<i.data.length;f++){let p={...u,context:{...u?.context,index:f}},m=e._parse(i.data[f],p);if(m.success)l.push(m.data);else {let h=qt(m,f,c,a);if(h)return h}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:l}}),n}function Wt(){return k(()=>true)}function z(e,t){return x(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Xt(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof o}" with value: ${We(o)?JSON.stringify(o):`"${o}"`}`,r=k(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,x(r,"_parse",(o,s,i)=>{let c=i,l=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(s,c);if(m.success)return m;l.push(m);}let{abortEarly:a}=Re(c),u={message:typeof n=="function"?n(s):n};if(a!==false)return {success:false,error:u,errors:[u]};let f=[];for(let p=0;p<l.length;p++){let m=l[p].errors;if(m?.length)for(let h=0;h<m.length;h++)m[h].cause?.key&&f.push(Xe(m[h],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function Jt(e,t){let n=k(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 Qt(e){let t=k(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,x(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Zt(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 en={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return z(n=>{let r;return te(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},Ze({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return z(n=>{if(ze(n))return Number(n);if(te(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},Qe({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return z(n=>ze(n)||Ye(n)&&Number.isFinite(n)?String(n):n,Je({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return z(n=>{let r;return te(n)&&(r=n.trim()),Ye(n)&&Number.isFinite(n)||r?new Date(r??n):n},et({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return x(e,"_parse",(r,o,s)=>{if(te(o))try{o=JSON.parse(o);}catch{let i={message:typeof n=="function"?n(o):n};return {success:false,error:i,errors:[i]}}return r(o,s)}),e}},tn={},g={object:Gt,string:Je,number:Qe,boolean:Ze,date:et,function:Vt,enum:Yt,array:zt,any:Wt,preprocess:z,union:Xt,literal:Jt,contextRef:Qt,withContext:Zt,coerce:tn,cast:en};function Kt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function x(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function k(e,{type:t="any",name:n,message:r}={}){r=r||Kt(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,c){let l=e(i);if(l===true)return {success:true,data:i};if(typeof l=="object"&&l?.success===true)return l;let a={message:typeof r=="function"?r(i):r};return {success:false,error:a,errors:[a]}},parse(i,c){let l=this._parse(i,c);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(i,c){return this._parse(i,c)},transform(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success&&(u.data=i(u.data)),u}),this},optional(){return Ve(this,i=>i===void 0),this},nullable(){return Ve(this,i=>i===null),this},nullish(){return Ve(this,i=>i==null),this},default(i){return x(this,"_parse",(c,l,a)=>(l===void 0&&(l=typeof i=="function"?i({context:a?.context}):i),c(l,a))),this},catch(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success?u:{success:true,data:typeof i=="function"?i({input:l,error:u.error}):i}}),this},pipe(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success?i._parse(u.data,a):u}),this},refine(i,{message:c,type:l,jsonSchema:a}={}){if(l&&(c=c||Kt(l),t=l),a){let u=[...this._getJsonSchemaHints?.()??[],a];this._getJsonSchemaHints=()=>u;}return x(this,"_parse",(u,f,p)=>{let m=u(f,p),{abortEarly:h}=Re(p);if(!m.success)return m;let S=i(m.data);if(S===true||typeof S=="object"&&S?.success===true)return m;let y={message:typeof c=="function"?c(f):c};return {success:false,error:y,errors:[y]}}),this},clone(){return {...this}}};return Ut.length>0?Ut.reduce((i,c)=>c(i,e,o)??i,s):s}var Ut=[];var tt=rt(),nt=rt(),nn=rt(),tr=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function rt(){return Math.floor(Math.random()*16777215)}function nr(){return nt=(nt+1)%16777215,nt}function C(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=nr(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,tt>>16&255,tt>>8&255,tt&255,nn>>8&255,nn&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=tr[n.charCodeAt(o)];return r}var ot=Symbol("block-element"),rr=Symbol("block-element-body"),ne=Symbol("selectable-element");function st(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 it(e){return e?st(e.startContainer,ot):null}function ke(e){return st(e,ot)}function rn(e){return e?st(e.startContainer,ne):null}function or(e){return e?e[ne]!==void 0?[e]:[...e.children].filter(t=>t[ne]!==void 0):[]}function sr(e,t){return t?or(e).indexOf(t):-1}function re(e,t){let n=rn(t);return !n||!e?.contains(n)?null:{element:n,index:sr(e,n)}}function on(){return window.getSelection()}function U(){let e=on();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function ct(){let e=U();if(!e)return 0;e.collapse(true);let t=rn(e),n=it(e),r=t??W(n);return _e(r,e.startContainer,e.startOffset)}function _e(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,c=e.childNodes,l=Math.min(n,c.length);for(let a=0;a<l;a++)i+=c[a].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=o.nextNode();for(;s;){if(s===t)return r+n;r+=s.textContent.length,s=o.nextNode();}return r}function ir(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 s=o.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(r+i>=t)return n.setEnd(s,t-r),n.setStart(s,t-r),n;r+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)o.push(s.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function D(e,t){let n=ir(e,t),r=on();r.removeAllRanges(),r.addRange(n);}function W(e){if(!e)return null;let t=cr(e);return t?.firstElementChild??t?.firstChild}function oe(e){if(!e?.[ot])return null;let t=W(e);return t?ye(t)?.classInstance:null}function cr(e){if(!e)return null;for(let t of e.children)if(t[rr])return t;return null}var se={KEYDOWN:"mrakomor:keydown",INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var sn=Ke();var Ie=class extends Ft{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Ue(sn),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return g.object({component:g.string().default(this.NAMESPACE),properties:g.object().default({}),settings:g.object().default({})}).default({})}static getPropsSchema(){return g.object({state:this.getStateSchema(),observeDOMChanges:g.boolean().default(true)}).default({})}parseFromHTML(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(se.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var X="molecule.paragraph.Paragraph",ie="molecule.list.List";var cn="molecule.headline.";function E(e){return e===`
|
|
2
|
+
`,document.head.appendChild(n);}}})();var dt=class{next(...e){}error(...e){}complete(...e){}},Te=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var ue=Symbol("@esmj/signals:type"),J=Symbol("@esmj/signals:name");var R=null,ve=false,Oe=[];function T(e){let t=R;R=null;let n=e();return R=t,n}function vn(){ve=false;let e=St();for(let n of e)n.get();let t=Oe;Oe=[];for(let n of t)n();}function ht(){ve||(ve=true,queueMicrotask(vn));}function Me(e){Oe.push(e),ht();}var Et=Symbol("@esmj/signals:internal observable"),A=Symbol("@esmj/signals:original function"),On=class extends Te{#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=()=>T(()=>{this.#e.add(e),this.#r();}),e.next[A]=void 0),e instanceof bt&&e.next[A]===void 0){let t=e.next.bind(e);e.next=()=>T(()=>{this.#e.add(e),t(),this.#r();}),e.next[A]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[A]){let n=t.get,r=n.bind(t);t.get=()=>T(()=>(this.#e.delete(t),r())),t.get[A]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[A]?e.next[A]:e.next,e.get=e.get[A]?e.get[A]:e.get,this.#e.delete(e),this.unsubscribe(e)}},fe=null;function yt(e){fe=new On(e);}yt(()=>{ht();});function St(){return fe.getPending()}function xt(e){return fe.watch(e)}function Ct(e){return fe.unwatch(e)}var L=Symbol("@esmj/signals:no error"),bt=class Rt extends dt{#e=true;#r=false;#t=null;#o=this.#p();#a=null;#l=null;#i=0;#s=new Map;#n=L;constructor(t,n){super(),this.#a=t,this.#l=n,this.debug=n?.debug,this[ue]="computed",this[J]=n?.debug??null,this.get=this.get.bind(this);}#u(){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[J],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof Rt&&T(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[Et].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=$(this.#c(),this.#l)),(this.#e||this.#n!==L)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),R&&R.sourceRevisions.set(this,this.#i),this.#n!==L)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=$(this.#c(),this.#l)),(this.#e||this.#n!==L)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),this.#n!==L)throw this.#n;return this.#t.peek()}#c(){this.#r=true,this.#e=false,this.#n=L,this.#u(),this.#o.sourceRevisions.clear();let t=R;R=this.#o;let n;try{n=this.#a();}catch(r){this.#n=r;}return R=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=L,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===L&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#n=L;}};function F(e,t){return new bt(e,t)}function _(e,t){let n,{debug:r,...o}={},s=F(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),xt(s);let i=()=>{n?.(),s.destroy(),Ct(s);};return i[Symbol.dispose]=i,i[ue]="effect",i[J]=r??null,i.__RX_COMPUTED__=s,i}function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new Te;function s(){return R&&(R.dependencies.set(o,o.subscribe(R.observer)),R.sourceRevisions.set(a,r)),e}function i(){return e}function c(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let a={get:s,set:c,peek:i,getRevision:l,[Et]:o,[ue]:"signal",[J]:t?.debug??null};return a}function pe(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var vt=Symbol("node-component"),me=Symbol("node-internal"),Mn=Symbol("keep-literal"),Ee=Symbol("raw-props");function $e(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function Fe(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var wn=new Set(["template","script"]);function Dn(e,t){let n=(e==null?"span":String(e)).trim(),r=n;wn.has(n.toLowerCase())&&(console.warn(`[esmj-dom] tagName "${e}" cannot render children in normal flow and is not supported as a reconciliation wrapper; falling back to "span".`),r="span");let o=document.createElement(r);return r==="span"&&(o.style.display="contents"),o.setAttribute(t,pe()),o}function He(e,t,n){let r=Dn(e,t);return n?.id&&r.setAttribute("id",n.id),r}var Ot=null;function H(){return Ot}function ge(e){Ot=e;}function ye(e){return e?.[vt]||null}function kt(e,t){e[vt]=t;}function de(e,t={disposers:[],id:pe()}){return e?.[me]?e[me]:(e&&(e[me]=t),t)}function Pn(e){return e[me]}function M(e,t){let n=Pn(e);n||(n=de(e)),n.disposers.push(t);}function De(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function w(e,t){let n=H();ge(e);try{return t()}finally{ge(n);}}var Pe=new Map,he=new Map,It=new Map;function Mt(e,t){let n=typeof t=="function"?t:o=>!!t?.includes(o),r=Object.create(null);for(let o of Object.keys(e)){let s=e[o];o==="children"||n(o)?r[o]=s:s?.[Mn]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=F(s):r[o]=$(s);}return r}function Se(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?false:n.every(o=>{let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(t,o);if(!s||!i)return false;let c="value"in s?s.value:s.get?.call(e),l="value"in i?i.value:i.get?.call(t);return Se(c,l)})}function Ke(e){return {id:Symbol("context-id"),defaultValue:e}}function Ue(e){let t=H();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function N(e){Me(()=>{setTimeout(e,0);});}function ee(e){let t=e.componentId,n=Pe.get(t);if(n){Pe.delete(t);for(let r of n){let o=r();typeof o=="function"&&De(he,t,o);}}}function jn(e){let t=he.get(e);if(t){he.delete(e);for(let n of t)n();}}function $n(e){let t=It.get(e);if(t){It.delete(e);for(let n of t)n();}}function xe(e){if(!e)return;let t=de(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=ye(e);if(n&&(jn(n.componentId),$n(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;xe(r),r=o;}}}function K(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function _t(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function Fn(e,t,n){let r=pe(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=_t(e)?void 0:e[Ee],i={...Mt(t??{},s),children:n},c=H(),l={disposers:[],id:r,contexts:new Map(c?.contexts)};ge(l);let a;if(_t(e)){o.ClassConstructor=e;let f=new e(i);o.classInstance=f,typeof f.onMount=="function"&&De(Pe,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&De(he,r,()=>{f.onUnmount?.();}),a=f.render();}else a=e(i);ge(c);let u=Hn(a);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)de(f,l),kt(f,o);else de(u,l),u instanceof Node&&kt(u,o);return u}};return o}function qe(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{ee(t);});}function Hn(e){return e instanceof Node?e:K(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Nt={className:"class",htmlFor:"for"},Bt=new Set(["value","defaultValue","checked","selected","indeterminate"]),Kn=new Set(["srcdoc"]),Un=new Set(["href","src","action","formaction","xlink:href"]),qn=new Set(["securitypolicyviolation"]),Gn=new Set(["contenteditable","draggable","spellcheck"]);function Z(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var wt=Symbol("Fragment");function V(e,t,n){if(e===wt){let o=document.createDocumentFragment();return je(o,Lt(n)),o}if(typeof e=="function")return Fn(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),Ce(r,t),je(r,Lt(n)),r}function we(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Vn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Yn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Kn.has(n)?true:Un.has(n)&&t!==null&&t!==void 0&&Vn(String(t))}function Dt(e){return typeof e!="string"?e:Nt[e]?Nt[e]:e}function zn(e,t){let n=Dt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Gn.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function At(e,t,n){let r=zn(t,n);if(r===null){e.removeAttribute(t);return}if(Yn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function Ce(e,t){let n=H();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=Dt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(Z(o)){let s=_(()=>{w(n,()=>{we(e,o.get());});});M(e,s);}else if(typeof o=="function"){let s=_(()=>{w(n,()=>{we(e,o());});});M(e,s);}else we(e,o);continue}if(r==="style"){if(Z(o)){let s=_(()=>{w(n,()=>{Object.assign(e.style,o.get());});});M(e,s);}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 s=r.slice(2).toLowerCase();if(qn.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(Z(o)||typeof o=="function"){let s=r,i=_(()=>{w(n,()=>{let c=typeof o=="function"?o():o.get();Bt.has(s)?e[s]=c??"":At(e,s,c);});});M(e,i);continue}Bt.has(r)||typeof r=="symbol"?e[r]=o??"":At(e,r,o);}}function Lt(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function je(e,t){for(let n of t)Pt(e,n);}function Pt(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"){Tt(e,t);return}if(K(t)){qe(e,t);return}if(Z(t)){Tt(e,()=>t.get());return}if(Array.isArray(t)){je(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function Y(e){let t=null,n=e;return K(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 be(e,t=true){for(let n of e)t&&xe(n),n.remove();}function Tt(e,t){let n=H(),r=document.createComment("");e.appendChild(r);let o=[],s=_(()=>{w(n,()=>{let i=t(),{nodes:c,instance:l}=Y(i);be(o),c.length&&r.after(...c),l&&queueMicrotask(()=>ee(l)),o=c;});});M(e,s);}var Ft=class{constructor(e){this.props=e;}};function jt(e,t,n,r){let{equals:o=Se,tagName:s="span",...i}=r??{},c=He(s,"data-for",i);Ce(c,i);let l=H(),a=[],u=new Map,f=F(()=>e()),p=_(()=>{let m=f.get(),h=Array.isArray(m)?m:[],S=[],y=[],P=new Set;for(let d=0;d<h.length;d++){let b=h[d],I=t(b,d);if(P.has(I)){console.error(`For: duplicate key "${String(I)}" detected; ignoring later item at index ${d}`);continue}P.add(I),S.push(b),y.push(I);}let G=new Map(a.map(d=>[d.key,d])),O=[];for(let d=0;d<S.length;d++){let b=y[d],I=S[d],j=G.get(b);if(j)u.get(b).set(I),O.push(j),G.delete(b);else {let pt=$(I,{equals:o});u.set(b,pt);let Nn={...pt,set(){}},mt={key:b,nodes:[]};w(l,()=>{let Bn=n(Nn,d),{nodes:An,instance:gt}=Y(Bn);mt.nodes=An,gt&&queueMicrotask(()=>ee(gt));}),O.push(mt);}}for(let[d,b]of G)be(b.nodes),u.delete(d);let B=null;for(let d=O.length-1;d>=0;d--){let b=O[d].nodes;for(let I=b.length-1;I>=0;I--){let j=b[I];(j.parentNode!==c||j.nextSibling!==B)&&c.insertBefore(j,B),B=j;}}a=O;});return M(c,p),c}function Ge(e,t,n,r){if(typeof e=="function")return jt(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:c,children:l,...a}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=$e(o),f=Fe(e??{},t);return jt(u,s,f,{...a,equals:i,tagName:c})}Ge[Ee]=e=>e!=="each";function Ht(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(xe(e),e.innerHTML=""),K(t)?qe(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Xn={abortEarly:true};function Xe(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 Jn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Xe(e.errors[r],n));}function qt(e,t,n,r){if(n!==false){let o=Xe(e.error,t);return {success:false,error:o,errors:[o]}}Jn(e,r,t);}function Re(e){return e?.abortEarly!==void 0?e:Xn}function Ve(e,t){x(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var te=e=>typeof e=="string"||e instanceof String,Ye=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),ze=e=>e===true||e===false,Qn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Zn=e=>typeof e=="function",er=e=>Array.isArray(e),We=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Gt(e,t){let n=k(We,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([o,s])=>`${o}: ${s._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(o,{when:s="always"}={}){return x(this,"_parse",(i,c,l)=>{let a=i(c,l);if(!a.success)return a;let u=o(a.data,{context:l?.context});if(!We(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={...a.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...a.data,...u}}}),this},x(n,"_parse",(o,s,i)=>{let c=o(s,i),{abortEarly:l}=Re(i);if(c.success===false)return c;let a={},u=[];for(let f in e){let p=e[f]._parse(c.data[f],i);if(p.success)a[f]=p.data;else {let m=qt(p,f,l,u);if(m)return m}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:a}}),r}function Je(e){return k(te,{...e,type:"string"})}function Qe(e){return k(Ye,{...e,type:"number"})}function Ze(e){return k(ze,{...e,type:"boolean"})}function et(e){return k(Qn,{...e,type:"date"})}function Vt(e){return k(Zn,{...e,type:"function"})}function Yt(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${i}".`,o="enum",s=k(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function zt(e,t){let n=k(er,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,x(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:c}=Re(s);if(i.success===false)return i;let l=[],a=[],u=s;for(let f=0;f<i.data.length;f++){let p={...u,context:{...u?.context,index:f}},m=e._parse(i.data[f],p);if(m.success)l.push(m.data);else {let h=qt(m,f,c,a);if(h)return h}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:l}}),n}function Wt(){return k(()=>true)}function z(e,t){return x(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Xt(e,t){let n=o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((s,i)=>` ${i+1}. ${s._getDescription()}`).join(",")} but received "${typeof o}" with value: ${We(o)?JSON.stringify(o):`"${o}"`}`,r=k(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,x(r,"_parse",(o,s,i)=>{let c=i,l=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(s,c);if(m.success)return m;l.push(m);}let{abortEarly:a}=Re(c),u={message:typeof n=="function"?n(s):n};if(a!==false)return {success:false,error:u,errors:[u]};let f=[];for(let p=0;p<l.length;p++){let m=l[p].errors;if(m?.length)for(let h=0;h<m.length;h++)m[h].cause?.key&&f.push(Xe(m[h],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function Jt(e,t){let n=k(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 Qt(e){let t=k(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,x(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Zt(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 en={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return z(n=>{let r;return te(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},Ze({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return z(n=>{if(ze(n))return Number(n);if(te(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},Qe({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return z(n=>ze(n)||Ye(n)&&Number.isFinite(n)?String(n):n,Je({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return z(n=>{let r;return te(n)&&(r=n.trim()),Ye(n)&&Number.isFinite(n)||r?new Date(r??n):n},et({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return x(e,"_parse",(r,o,s)=>{if(te(o))try{o=JSON.parse(o);}catch{let i={message:typeof n=="function"?n(o):n};return {success:false,error:i,errors:[i]}}return r(o,s)}),e}},tn={},g={object:Gt,string:Je,number:Qe,boolean:Ze,date:et,function:Vt,enum:Yt,array:zt,any:Wt,preprocess:z,union:Xt,literal:Jt,contextRef:Qt,withContext:Zt,coerce:tn,cast:en};function Kt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function x(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function k(e,{type:t="any",name:n,message:r}={}){r=r||Kt(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,c){let l=e(i);if(l===true)return {success:true,data:i};if(typeof l=="object"&&l?.success===true)return l;let a={message:typeof r=="function"?r(i):r};return {success:false,error:a,errors:[a]}},parse(i,c){let l=this._parse(i,c);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(i,c){return this._parse(i,c)},transform(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success&&(u.data=i(u.data)),u}),this},optional(){return Ve(this,i=>i===void 0),this},nullable(){return Ve(this,i=>i===null),this},nullish(){return Ve(this,i=>i==null),this},default(i){return x(this,"_parse",(c,l,a)=>(l===void 0&&(l=typeof i=="function"?i({context:a?.context}):i),c(l,a))),this},catch(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success?u:{success:true,data:typeof i=="function"?i({input:l,error:u.error}):i}}),this},pipe(i){return x(this,"_parse",(c,l,a)=>{let u=c(l,a);return u.success?i._parse(u.data,a):u}),this},refine(i,{message:c,type:l,jsonSchema:a}={}){if(l&&(c=c||Kt(l),t=l),a){let u=[...this._getJsonSchemaHints?.()??[],a];this._getJsonSchemaHints=()=>u;}return x(this,"_parse",(u,f,p)=>{let m=u(f,p),{abortEarly:h}=Re(p);if(!m.success)return m;let S=i(m.data);if(S===true||typeof S=="object"&&S?.success===true)return m;let y={message:typeof c=="function"?c(f):c};return {success:false,error:y,errors:[y]}}),this},clone(){return {...this}}};return Ut.length>0?Ut.reduce((i,c)=>c(i,e,o)??i,s):s}var Ut=[];var tt=rt(),nt=rt(),nn=rt(),tr=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function rt(){return Math.floor(Math.random()*16777215)}function nr(){return nt=(nt+1)%16777215,nt}function C(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=nr(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,tt>>16&255,tt>>8&255,tt&255,nn>>8&255,nn&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=tr[n.charCodeAt(o)];return r}var ot=Symbol("block-element"),rr=Symbol("block-element-body"),ne=Symbol("selectable-element");function st(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 it(e){return e?st(e.startContainer,ot):null}function ke(e){return st(e,ot)}function rn(e){return e?st(e.startContainer,ne):null}function or(e){return e?e[ne]!==void 0?[e]:[...e.children].filter(t=>t[ne]!==void 0):[]}function sr(e,t){return t?or(e).indexOf(t):-1}function re(e,t){let n=rn(t);return !n||!e?.contains(n)?null:{element:n,index:sr(e,n)}}function on(){return window.getSelection()}function U(){let e=on();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function ct(){let e=U();if(!e)return 0;e.collapse(true);let t=rn(e),n=it(e),r=t??W(n);return Ie(r,e.startContainer,e.startOffset)}function Ie(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,c=e.childNodes,l=Math.min(n,c.length);for(let a=0;a<l;a++)i+=c[a].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),s=o.nextNode();for(;s;){if(s===t)return r+n;r+=s.textContent.length,s=o.nextNode();}return r}function ir(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 s=o.pop();if(s.nodeType===Node.TEXT_NODE){let i=s.textContent.length;if(r+i>=t)return n.setEnd(s,t-r),n.setStart(s,t-r),n;r+=i;}else if(s.childNodes&&s.childNodes.length>0)for(let i=s.childNodes.length-1;i>=0;i--)o.push(s.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function D(e,t){let n=ir(e,t),r=on();r.removeAllRanges(),r.addRange(n);}function W(e){if(!e)return null;let t=cr(e);return t?.firstElementChild??t?.firstChild}function oe(e){if(!e?.[ot])return null;let t=W(e);return t?ye(t)?.classInstance:null}function cr(e){if(!e)return null;for(let t of e.children)if(t[rr])return t;return null}var se={KEYDOWN:"mrakomor:keydown",INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var sn=Ke();var _e=class extends Ft{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Ue(sn),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return g.object({component:g.string().default(this.NAMESPACE),properties:g.object().default({}),settings:g.object().default({})}).default({})}static getPropsSchema(){return g.object({state:this.getStateSchema(),observeDOMChanges:g.boolean().default(true)}).default({})}parseFromHTML(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(se.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var X="molecule.paragraph.Paragraph",ie="molecule.list.List";var cn="molecule.headline.";function E(e){return e===`
|
|
3
3
|
`||e===`\r
|
|
4
4
|
`?"":e??""}function q({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},s=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:s},...r?{settings:r}:{}}}function fn(e){let t="",n=[],r=[];return (e??[]).forEach((o,s)=>{s>0&&(t+=`
|
|
5
|
-
`);let i=t.length;t+=E(o?.text);for(let c of o?.inlineStyleRanges??[])n.push({...c,offset:c.offset+i});for(let c of o?.entityRanges??[])r.push({...c,offset:c.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function T(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function pn({mrakomor:e,resultIndex:t,cursor:n,fallbackBlockElement:r,itemIndex:o}){let s=()=>{if(typeof n!="number")return;let i=e._getBlockElements()[t]??r,c=oe(i);if(c?.setCursor){c.setCursor({cursor:n,itemIndex:o});return}let l=W(i);l?.isConnected&&D(l,n);};s(),N(s);}function lt(e){let t=e?.component??"";return t===X||t.startsWith(cn)}function Ne(e){return Array.isArray(e?.properties?.items)}function lr(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function ln(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function ar(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let c=r.find(l=>l.match(i));c&&(s=V(c,{},s));}for(let i of n){let c=o.find(l=>l.match(i));c&&(s=V(c,i,s));}return s}function mn(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=E(e.properties.text),s=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!o)return r;let c=lr([...s,...i],o.length);for(let l=0;l<c.length-1;l+=1){let a=c[l],u=c[l+1];if(a>=u)continue;let f=o.slice(a,u),p=ar(f,ln(s,a,u),ln(i,a,u),{inlineStyleComponents:t,entityRangeComponents:n});Ht(r,p);}return r}function ce(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let c=r.find(a=>a.match(i));if(c){let a=i.textContent.length;t.properties.inlineStyleRanges.push({style:c.style,offset:s,length:a}),s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let l=o.find(a=>a.match(i));if(l){let a=i.textContent.length;t.properties.entityRanges.push({...l.getStateSchema(i).parse(),offset:s,length:a}),s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function le(e,t){let n=E(e.properties.text),r=E(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 an(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function un(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 gn(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=an(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=un(e.properties.inlineStyleRanges,t),n.properties.entityRanges=an(e.properties.entityRanges,t),r.properties.entityRanges=un(e.properties.entityRanges,t),r.componentId=C(),{originalLineState:n,newLineState:r}}var Be=class extends Ie{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:t}={}){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:E(this.getState()?.properties?.text).length;D(this.element,r);};n(),N(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:E(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),q({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=fn(n?.properties?.items);return le(t,T(r))}};function dn(e,t,n){let r=e._getBlockElementIndex(t);if(r===-1)return false;let o=e.getContent();return o.splice(r,1,e.normalizeComponentState(n)),e._setContentState(o),true}function hn(){return g.object({length:g.number(),offset:g.number(),style:g.string()})}function En({type:e,data:t=g.any(),length:n,offset:r}={}){let o=e!=null,s=g.object({type:o?g.string().default(e):g.string(),data:t}),i=n??(o?0:void 0),c=r??(o?0:void 0);return g.object({entity:o?s.default({}):s,length:i==null?g.number():g.number().default(i),offset:c==null?g.number():g.number().default(c)})}function Sn(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function Le(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=C();return t.add(r),{...n,componentId:r}})}function xn(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function at(e,t){return !e||!t?0:_e(e,t.startContainer,t.startOffset)}function Cn(e,t){let n=T(e),{originalLineState:r,newLineState:o}=gn(n,t);return {before:{componentId:e.componentId,depth:e.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]},after:{componentId:C(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function bn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:o?.componentId??C(),depth:o?.depth??0,text:E(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:C(),depth:0,text:E(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:ie,componentId:C(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function ut(e,t,{namespace:n=X,Constructor:r}={}){let o=e.properties?.items??[],s=o[t];if(!s)return {blocks:[e],paragraphIndex:0};let i=o.slice(0,t),c=o.slice(t+1),l=q({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),a={component:n,componentId:C(),settings:{},...r?.fromExchangeState(l)??T(s)},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(a),c.length&&u.push({...e,componentId:i.length?C():e.componentId,properties:{...e.properties,items:c}}),{blocks:u,paragraphIndex:i.length?1:0}}function yn(e){return Ne(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function ft(e,t){let n=yn(e),r=yn(t);return n!=null&&n===r}function Rn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!ft(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let p=[...e];p.splice(n,1);let m=s.length-1,h=m>=0?E(s[m]?.text).length:0;return {content:p,listIndex:t,cursor:h}}let[c,...l]=i,a=0;if(s.length===0)s.push(c,...l),a=0;else {let p=s.length-1,m=s[p],h=T(m),S=T(c),{state:y,cursor:P}=le(h,S);s[p]={...m,text:y.properties.text,inlineStyleRanges:y.properties.inlineStyleRanges,entityRanges:y.properties.entityRanges},l.length&&s.push(...l),a=P;}let u={...r,properties:{...r.properties,items:Le(s)}},f=[...e];return f[t]=u,f.splice(n,1),{content:f,listIndex:t,cursor:a}}function kn(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=q({properties:t?.properties}).properties.items,[s,...i]=o,c=n[r],l=T(c),a=T(s),{state:u,cursor:f}=le(l,a),p=n.map((m,h)=>h===r?{...m,text:u.properties.text,inlineStyleRanges:u.properties.inlineStyleRanges,entityRanges:u.properties.entityRanges}:m);return i.length&&p.push(...i.map(m=>({componentId:m?.componentId??C(),depth:m?.depth??0,text:E(m?.text??""),inlineStyleRanges:m?.inlineStyleRanges??[],entityRanges:m?.entityRanges??[]}))),{state:{...e,properties:{...e.properties,items:Le(p)}},cursor:f,itemIndex:r}}function _n(e,t){return mn({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function In(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:E(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return ce(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:E(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var Ae=e=>g.object({componentId:g.string().default(()=>e?.getAttribute?.("data-componentid")||C()),depth:g.number().default(0),text:g.string().default(""),inlineStyleRanges:g.array(hn()).default([]),entityRanges:g.array(En()).default([])}).default({}),ae=class e extends Be{static get NAMESPACE(){return ie}static get LABEL(){return "List"}static get GROUP(){return "lists"}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){let n=Sn(t);return g.object({component:g.string().default(e.NAMESPACE),componentId:g.string().default(t?.getAttribute("data-componentid")||C()),properties:g.object({items:g.array(Ae()).default([Ae().parse()]).transform(Le)}).default({}),settings:g.object({style:g.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(o=>{let s={componentId:o?.componentId,text:E(o?.text),depth:o?.depth??0};return o?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=o.inlineStyleRanges),o?.entityRanges!==void 0&&(s.entityRanges=o.entityRanges),s});return q({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return bn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return kn(t,n)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},o=xn(t);if(o.length)n.properties.items=o.map(s=>Ae(s).parse(In(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[Ae().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}_commitState(t){let n=ke(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId);dn(this.mrakomor,n,t);}_buildItemContent(t){return _n(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),n=this.state.peek(),r=n.settings?.style==="ORDERED"?"ol":"ul",o=Ge(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>V("li",{contentEditable:true,[ne]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let c=s.get()?.componentId,a=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===c);return String(a>=0?a:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let c=s.get(),l=c?.text??"";return E(l)?v(()=>this._buildItemContent(c)):"<br>"}}),{tagName:r});return o.className=t,n.componentId&&o.setAttribute("data-componentid",n.componentId),this.element=o,o}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor({cursor:t,itemIndex:n}={}){let r=this.getState()?.properties?.items??[],o=r.length-1;if(o<0)return;let s=typeof n=="number"&&n>=0&&n<=o?n:o,i=typeof t=="number"?t:E(r[s]?.text).length,c=()=>{let l=this.element?.querySelector(`li[data-item-index="${s}"]`);l?.isConnected&&D(l,i);};c(),N(c);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],o=r[t];if(!o)return;if((o.depth??0)>0){r[t]={...o,depth:o.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let f=()=>{let p=this.element?.querySelector(`li[data-item-index="${t}"]`);p?.isConnected&&D(p,0);};f(),N(f);return}let s=ke(this.element),i=this.mrakomor._getBlockElementIndex(s),c=s?.previousElementSibling??null,l=c?this.mrakomor._getBlockElementIndex(c):-1;if(t===0&&l>=0&&i===l+1){let f=this.mrakomor.getContent(),p=Rn(f,l,i);if(p){let m=p.content.map((h,S)=>S===p.listIndex?this.mrakomor.normalizeComponentState(h):h);this.mrakomor._setContentState(m),oe(c)?.setCursor?.({cursor:p.cursor});return}}let{blocks:a,paragraphIndex:u}=ut(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(X)});this.mrakomor.command.replaceBlockElement({blockElement:ke(this.element),blocks:a,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=U(),r=re(this.element,n);if(!r)return;let{element:o,index:s}=r,i=at(o,n),c=this.getState(),l=[...c.properties.items??[]],a=l[s];if(!a)return;if(!E(a.text)){this.#e(s);return}let{before:u,after:f}=Cn(a,i);l.splice(s,1,u,f),this._commitState({...c,properties:{...c.properties,items:l}}),N(()=>{let p=this.element?.querySelector(`li[data-item-index="${s+1}"]`);p&&D(p,0);});}#t(t){let n=U();if(!n?.collapsed)return;let r=re(this.element,n);if(!r){let c=n.startContainer;if(!(c===this.element||this.element?.contains?.(c)))return;t.preventDefault(),this.#e(0);return}let{element:o,index:s}=r;at(o,n)===0&&(t.preventDefault(),this.#e(s));}};function ur(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!lt({component:r})||!Ne(o))return;e.preventDefault();let i=oe(n)?.element,c=e.range??U(),l=re(i,c);if(!l)return;let{index:a}=l,{blocks:u,paragraphIndex:f}=ut(o,a,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:f});}function fr(e){if(e.key!=="Backspace")return;let t=U();if(!t?.collapsed)return;let n=it(t);if(!n)return;let r=W(n),o=!E(r?.textContent),s=t.startOffset===0||ct()===0||o;if(!o||!s)return;let i=n.previousSibling;if(!i)return;let{mrakomor:c}=e,l=c._getBlockElementIndex(n),a=c._getBlockElementIndex(i);if(l<0||a<0)return;let u=c._getBlockElementState(n),f=c._getBlockElementState(i);if(!u||!lt(u)||!f||f.component!==ie)return;let p=c.getContent(),m=p[l+1];if(!ft(f,m))return;let S=c.register.blocks.getByNamespace(m.component)?.toExchangeState?.(m),y=S&&ae.appendExchangeState(f,S);y&&(e.preventDefault(),p.splice(l,1),p.splice(a,2,c.normalizeComponentState(y.state)),c._setContentState(p),pn({mrakomor:c,resultIndex:a,cursor:y.cursor,fallbackBlockElement:i,itemIndex:y.itemIndex}));}function pr(e){return {resolveConfig:t=>(t.blockComponents.push({component:e,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:e,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===e.NAMESPACE)return e},registerCommands(t){t.emitter.on(se.TRANSFORM_BLOCK_ELEMENT,ur),t.emitter.on(se.KEYDOWN,fr);}}}function mr(){return pr(ae)}exports.List=ae;exports.listPlugin=mr;
|
|
5
|
+
`);let i=t.length;t+=E(o?.text);for(let c of o?.inlineStyleRanges??[])n.push({...c,offset:c.offset+i});for(let c of o?.entityRanges??[])r.push({...c,offset:c.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function v(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function pn({mrakomor:e,resultIndex:t,cursor:n,fallbackBlockElement:r,itemIndex:o}){let s=()=>{if(typeof n!="number")return;let i=e._getBlockElements()[t]??r,c=oe(i);if(c?.setCursor){c.setCursor({cursor:n,itemIndex:o});return}let l=W(i);l?.isConnected&&D(l,n);};s(),N(s);}function lt(e){let t=e?.component??"";return t===X||t.startsWith(cn)}function Ne(e){return Array.isArray(e?.properties?.items)}function lr(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function ln(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function ar(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let c=r.find(l=>l.match(i));c&&(s=V(c,{},s));}for(let i of n){let c=o.find(l=>l.match(i));c&&(s=V(c,i,s));}return s}function mn(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=E(e.properties.text),s=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!o)return r;let c=lr([...s,...i],o.length);for(let l=0;l<c.length-1;l+=1){let a=c[l],u=c[l+1];if(a>=u)continue;let f=o.slice(a,u),p=ar(f,ln(s,a,u),ln(i,a,u),{inlineStyleComponents:t,entityRangeComponents:n});Ht(r,p);}return r}function ce(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let c=r.find(a=>a.match(i));if(c){let a=i.textContent.length;t.properties.inlineStyleRanges.push({style:c.style,offset:s,length:a}),s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let l=o.find(a=>a.match(i));if(l){let a=i.textContent.length;t.properties.entityRanges.push({...l.getStateSchema(i).parse(),offset:s,length:a}),s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=ce(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function le(e,t){let n=E(e.properties.text),r=E(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 an(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function un(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 gn(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=an(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=un(e.properties.inlineStyleRanges,t),n.properties.entityRanges=an(e.properties.entityRanges,t),r.properties.entityRanges=un(e.properties.entityRanges,t),r.componentId=C(),{originalLineState:n,newLineState:r}}var Be=class extends _e{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:t}={}){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:E(this.getState()?.properties?.text).length;D(this.element,r);};n(),N(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:E(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),q({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=fn(n?.properties?.items);return le(t,v(r))}};function dn(e,t,n){let r=e._getBlockElementIndex(t);if(r===-1)return false;let o=e.getContent();return o.splice(r,1,e.normalizeComponentState(n)),e._setContentState(o),true}function hn(){return g.object({length:g.number(),offset:g.number(),style:g.string()})}function En({type:e,data:t=g.any(),length:n,offset:r}={}){let o=e!=null,s=g.object({type:o?g.string().default(e):g.string(),data:t}),i=n??(o?0:void 0),c=r??(o?0:void 0);return g.object({entity:o?s.default({}):s,length:i==null?g.number():g.number().default(i),offset:c==null?g.number():g.number().default(c)})}function Sn(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function Ae(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=C();return t.add(r),{...n,componentId:r}})}function xn(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function at(e,t){return !e||!t?0:Ie(e,t.startContainer,t.startOffset)}function Cn(e,t){let n=v(e),{originalLineState:r,newLineState:o}=gn(n,t);return {before:{componentId:e.componentId,depth:e.depth??0,text:r.properties.text,inlineStyleRanges:r.properties.inlineStyleRanges??[],entityRanges:r.properties.entityRanges??[]},after:{componentId:C(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function bn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:o?.componentId??C(),depth:o?.depth??0,text:E(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:C(),depth:0,text:E(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:ie,componentId:C(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function ut(e,t,{namespace:n=X,Constructor:r}={}){let o=e.properties?.items??[],s=o[t];if(!s)return {blocks:[e],paragraphIndex:0};let i=o.slice(0,t),c=o.slice(t+1),l=q({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),a={component:n,componentId:C(),settings:{},...r?.fromExchangeState(l)??v(s)},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(a),c.length&&u.push({...e,componentId:i.length?C():e.componentId,properties:{...e.properties,items:c}}),{blocks:u,paragraphIndex:i.length?1:0}}function yn(e){return Ne(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function ft(e,t){let n=yn(e),r=yn(t);return n!=null&&n===r}function Rn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!ft(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let p=[...e];p.splice(n,1);let m=s.length-1,h=m>=0?E(s[m]?.text).length:0;return {content:p,listIndex:t,cursor:h}}let[c,...l]=i,a=0;if(s.length===0)s.push(c,...l),a=0;else {let p=s.length-1,m=s[p],h=v(m),S=v(c),{state:y,cursor:P}=le(h,S);s[p]={...m,text:y.properties.text,inlineStyleRanges:y.properties.inlineStyleRanges,entityRanges:y.properties.entityRanges},l.length&&s.push(...l),a=P;}let u={...r,properties:{...r.properties,items:Ae(s)}},f=[...e];return f[t]=u,f.splice(n,1),{content:f,listIndex:t,cursor:a}}function kn(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=q({properties:t?.properties}).properties.items,[s,...i]=o,c=n[r],l=v(c),a=v(s),{state:u,cursor:f}=le(l,a),p=n.map((m,h)=>h===r?{...m,text:u.properties.text,inlineStyleRanges:u.properties.inlineStyleRanges,entityRanges:u.properties.entityRanges}:m);return i.length&&p.push(...i.map(m=>({componentId:m?.componentId??C(),depth:m?.depth??0,text:E(m?.text??""),inlineStyleRanges:m?.inlineStyleRanges??[],entityRanges:m?.entityRanges??[]}))),{state:{...e,properties:{...e.properties,items:Ae(p)}},cursor:f,itemIndex:r}}function In(e,t){return mn({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function _n(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:E(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return ce(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:E(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var Le=e=>g.object({componentId:g.string().default(()=>e?.getAttribute?.("data-componentid")||C()),depth:g.number().default(0),text:g.string().default(""),inlineStyleRanges:g.array(hn()).default([]),entityRanges:g.array(En()).default([])}).default({}),ae=class e extends Be{static get NAMESPACE(){return ie}static get LABEL(){return "List"}static get GROUP(){return "lists"}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){let n=Sn(t);return g.object({component:g.string().default(e.NAMESPACE),componentId:g.string().default(t?.getAttribute("data-componentid")||C()),properties:g.object({items:g.array(Le()).default([Le().parse()]).transform(Ae)}).default({}),settings:g.object({style:g.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(o=>{let s={componentId:o?.componentId,text:E(o?.text),depth:o?.depth??0};return o?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=o.inlineStyleRanges),o?.entityRanges!==void 0&&(s.entityRanges=o.entityRanges),s});return q({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return bn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return kn(t,n)}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse()),r={inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()},o=xn(t);if(o.length)n.properties.items=o.map(s=>Le(s).parse(_n(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[Le().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}_commitState(t){let n=ke(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId);dn(this.mrakomor,n,t);}_buildItemContent(t){return In(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-"),n=this.state.peek(),r=n.settings?.style==="ORDERED"?"ol":"ul",o=Ge(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>V("li",{contentEditable:true,[ne]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let c=s.get()?.componentId,a=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===c);return String(a>=0?a:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let c=s.get(),l=c?.text??"";return E(l)?T(()=>this._buildItemContent(c)):"<br>"}}),{tagName:r});return o.className=t,n.componentId&&o.setAttribute("data-componentid",n.componentId),this.element=o,o}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor({cursor:t,itemIndex:n}={}){let r=this.getState()?.properties?.items??[],o=r.length-1;if(o<0)return;let s=typeof n=="number"&&n>=0&&n<=o?n:o,i=typeof t=="number"?t:E(r[s]?.text).length,c=()=>{let l=this.element?.querySelector(`li[data-item-index="${s}"]`);l?.isConnected&&D(l,i);};c(),N(c);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],o=r[t];if(!o)return;if((o.depth??0)>0){r[t]={...o,depth:o.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let f=()=>{let p=this.element?.querySelector(`li[data-item-index="${t}"]`);p?.isConnected&&D(p,0);};f(),N(f);return}let s=ke(this.element),i=this.mrakomor._getBlockElementIndex(s),c=s?.previousElementSibling??null,l=c?this.mrakomor._getBlockElementIndex(c):-1;if(t===0&&l>=0&&i===l+1){let f=this.mrakomor.getContent(),p=Rn(f,l,i);if(p){let m=p.content.map((h,S)=>S===p.listIndex?this.mrakomor.normalizeComponentState(h):h);this.mrakomor._setContentState(m),oe(c)?.setCursor?.({cursor:p.cursor});return}}let{blocks:a,paragraphIndex:u}=ut(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(X)});this.mrakomor.command.replaceBlockElement({blockElement:ke(this.element),blocks:a,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=U(),r=re(this.element,n);if(!r)return;let{element:o,index:s}=r,i=at(o,n),c=this.getState(),l=[...c.properties.items??[]],a=l[s];if(!a)return;if(!E(a.text)){this.#e(s);return}let{before:u,after:f}=Cn(a,i);l.splice(s,1,u,f),this._commitState({...c,properties:{...c.properties,items:l}}),N(()=>{let p=this.element?.querySelector(`li[data-item-index="${s+1}"]`);p&&D(p,0);});}#t(t){let n=U();if(!n?.collapsed)return;let r=re(this.element,n);if(!r){let c=n.startContainer;if(!(c===this.element||this.element?.contains?.(c)))return;t.preventDefault(),this.#e(0);return}let{element:o,index:s}=r;at(o,n)===0&&(t.preventDefault(),this.#e(s));}};function ur(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!lt({component:r})||!Ne(o))return;e.preventDefault();let i=oe(n)?.element,c=e.range??U(),l=re(i,c);if(!l)return;let{index:a}=l,{blocks:u,paragraphIndex:f}=ut(o,a,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:f});}function fr(e){if(e.key!=="Backspace"&&e.key!=="Delete")return;let t=U();if(!t?.collapsed)return;let n=it(t);if(!n)return;let r=W(n),o=!E(r?.textContent),s=t.startOffset===0||ct()===0||o;if(!o||!s)return;let i=n.previousSibling;if(!i)return;let{mrakomor:c}=e,l=c._getBlockElementIndex(n),a=c._getBlockElementIndex(i);if(l<0||a<0)return;let u=c._getBlockElementState(n),f=c._getBlockElementState(i);if(!u||!lt(u)||!f||f.component!==ie)return;let p=c.getContent(),m=p[l+1];if(!ft(f,m))return;let S=c.register.blocks.getByNamespace(m.component)?.toExchangeState?.(m),y=S&&ae.appendExchangeState(f,S);y&&(e.preventDefault(),p.splice(l,1),p.splice(a,2,c.normalizeComponentState(y.state)),c._setContentState(p),pn({mrakomor:c,resultIndex:a,cursor:y.cursor,fallbackBlockElement:i,itemIndex:y.itemIndex}));}function pr(e){return {resolveConfig:t=>(t.blockComponents.push({component:e,label:"UL",keywords:["ul","unordered","bullet"],order:100,settings:{style:"UNORDERED"}},{component:e,label:"OL",keywords:["ol","ordered","number"],order:101,settings:{style:"ORDERED"}}),t),resolveComponent:t=>{if(t===e.NAMESPACE)return e},registerCommands(t){t.emitter.on(se.TRANSFORM_BLOCK_ELEMENT,ur),t.emitter.on(se.KEYDOWN,fr);}}}function mr(){return pr(ae)}exports.List=ae;exports.listPlugin=mr;
|
package/dist/list.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as List,e as listPlugin}from'./chunk-
|
|
1
|
+
export{c as List,e as listPlugin}from'./chunk-BWK2S4UI.mjs';import'./chunk-5AD5MQXI.mjs';import'./chunk-SG5PCGIV.mjs';import'./chunk-B2UFH244.mjs';import'./chunk-ZHOZPQZH.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-D6K2L5O3.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-4WTPDNPA.mjs';import'./chunk-7CJLTNHZ.mjs';
|
package/dist/paragraph.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/paragraph/Paragraph.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 p{margin-top:0}
|
|
2
|
-
`,document.head.appendChild(n);}}})();var Ue=class{next(...e){}error(...e){}complete(...e){}},me=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 X=Symbol("@esmj/signals:type"),V=Symbol("@esmj/signals:name");var S=null,he=false,de=[];function w(e){let t=S;S=null;let n=e();return S=t,n}function an(){he=false;let e=ze();for(let n of e)n.get();let t=de;de=[];for(let n of t)n();}function Ye(){he||(he=true,queueMicrotask(an));}function ge(e){de.push(e),Ye();}var We=Symbol("@esmj/signals:internal observable"),A=Symbol("@esmj/signals:original function"),ln=class extends me{#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=()=>w(()=>{this.#e.add(e),this.#r();}),e.next[A]=void 0),e instanceof Ze&&e.next[A]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{this.#e.add(e),t(),this.#r();}),e.next[A]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[A]){let n=t.get,r=n.bind(t);t.get=()=>w(()=>(this.#e.delete(t),r())),t.get[A]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[A]?e.next[A]:e.next,e.get=e.get[A]?e.get[A]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function Xe(e){z=new ln(e);}Xe(()=>{Ye();});function ze(){return z.getPending()}function Je(e){return z.watch(e)}function Qe(e){return z.unwatch(e)}var v=Symbol("@esmj/signals:no error"),Ze=class et extends Ue{#e=true;#r=false;#n=null;#o=this.#p();#c=null;#l=null;#i=0;#s=new Map;#t=v;constructor(t,n){super(),this.#c=t,this.#l=n,this.debug=n?.debug,this[X]="computed",this[V]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[V],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof et&&w(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[We].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=I(this.#a(),this.#l)),(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=I(this.#a(),this.#l)),(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.#u(),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=v,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===v&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#t=v;}};function P(e,t){return new Ze(e,t)}function _(e,t){let n,{debug:r,...o}={},i=P(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),Je(i);let s=()=>{n?.(),i.destroy(),Qe(i);};return s[Symbol.dispose]=s,s[X]="effect",s[V]=r??null,s.__RX_COMPUTED__=i,s}function I(e,t={}){let n=t?.equals??Object.is,r=0,o=new me;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(c,r)),e}function s(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let c={get:i,set:a,peek:s,getRevision:l,[We]:o,[X]:"signal",[V]:t?.debug??null};return c}function J(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var ct=Symbol("node-component"),Q=Symbol("node-internal"),cn=Symbol("keep-literal"),ne=Symbol("raw-props");var ut=null;function B(){return ut}function Z(e){ut=e;}function Ne(e){return e?.[ct]||null}function tt(e,t){e[ct]=t;}function ee(e,t={disposers:[],id:J()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function pn(e){return e[Q]}function M(e,t){let n=pn(e);n||(n=ee(e)),n.disposers.push(t);}function Ee(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function L(e,t){let n=B();Z(e);try{return t()}finally{Z(n);}}var Se=new Map,te=new Map,nt=new Map;function ft(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?.[cn]?r[o]=i():i!=null&&typeof i.get=="function"?r[o]=i:typeof i=="function"?r[o]=P(i):r[o]=I(i);}return r}function Re(e){return {id:Symbol("context-id"),defaultValue:e}}function ke(e){let t=B();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function oe(e){ge(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Se.get(t);if(n){Se.delete(t);for(let r of n){let o=r();typeof o=="function"&&Ee(te,t,o);}}}function mn(e){let t=te.get(e);if(t){te.delete(e);for(let n of t)n();}}function hn(e){let t=nt.get(e);if(t){nt.delete(e);for(let n of t)n();}}function se(e){if(!e)return;let t=ee(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=Ne(e);if(n&&(mn(n.componentId),hn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;se(r),r=o;}}}function j(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function rt(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function dn(e,t,n){let r=J(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=rt(e)?void 0:e[ne],s={...ft(t??{},i),children:n},a=B(),l={disposers:[],id:r,contexts:new Map(a?.contexts)};Z(l);let c;if(rt(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&Ee(Se,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&Ee(te,r,()=>{f.onUnmount?.();}),c=f.render();}else c=e(s);Z(a);let u=gn(c);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ee(f,l),tt(f,o);else ee(u,l),u instanceof Node&&tt(u,o);return u}};return o}function Ae(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function gn(e){return e instanceof Node?e:j(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var ot={className:"class",htmlFor:"for"},st=new Set(["value","defaultValue","checked","selected","indeterminate"]),yn=new Set(["srcdoc"]),En=new Set(["href","src","action","formaction","xlink:href"]),Sn=new Set(["securitypolicyviolation"]),bn=new Set(["contenteditable","draggable","spellcheck"]);function U(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var pt=Symbol("Fragment");function D(e,t,n){if(e===pt){let o=document.createDocumentFragment();return be(o,at(n)),o}if(typeof e=="function")return dn(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),ie(r,t),be(r,at(n)),r}function ye(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function xn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Cn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return yn.has(n)?true:En.has(n)&&t!==null&&t!==void 0&&xn(String(t))}function mt(e){return typeof e!="string"?e:ot[e]?ot[e]:e}function _n(e,t){let n=mt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return bn.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function it(e,t,n){let r=_n(t,n);if(r===null){e.removeAttribute(t);return}if(Cn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function ie(e,t){let n=B();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=mt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(U(o)){let i=_(()=>{L(n,()=>{ye(e,o.get());});});M(e,i);}else if(typeof o=="function"){let i=_(()=>{L(n,()=>{ye(e,o());});});M(e,i);}else ye(e,o);continue}if(r==="style"){if(U(o)){let i=_(()=>{L(n,()=>{Object.assign(e.style,o.get());});});M(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(Sn.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(U(o)||typeof o=="function"){let i=r,s=_(()=>{L(n,()=>{let a=typeof o=="function"?o():o.get();st.has(i)?e[i]=a??"":it(e,i,a);});});M(e,s);continue}st.has(r)||typeof r=="symbol"?e[r]=o??"":it(e,r,o);}}function at(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function be(e,t){for(let n of t)ht(e,n);}function ht(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"){lt(e,t);return}if(j(t)){Ae(e,t);return}if(U(t)){lt(e,()=>t.get());return}if(Array.isArray(t)){be(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function F(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 ae(e,t=true){for(let n of e)t&&se(n),n.remove();}function lt(e,t){let n=B(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{L(n,()=>{let s=t(),{nodes:a,instance:l}=F(s);ae(o),a.length&&r.after(...a),l&&queueMicrotask(()=>Y(l)),o=a;});});M(e,i);}var yt=class{constructor(e){this.props=e;}};function Et(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(se(e),e.innerHTML=""),j(t)?Ae(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var kn={abortEarly:true};function Le(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 An(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Le(e.errors[r],n));}function xt(e,t,n,r){if(n!==false){let o=Le(e.error,t);return {success:false,error:o,errors:[o]}}An(e,r,t);}function le(e){return e?.abortEarly!==void 0?e:kn}function ve(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,we=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Te=e=>e===true||e===false,vn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),wn=e=>typeof e=="function",Tn=e=>Array.isArray(e),Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Ct(e,t){let n=b(Me,{...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,l)=>{let c=s(a,l);if(!c.success)return c;let u=o(c.data,{context:l?.context});if(!Me(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={...c.data};for(let m in u)f[m]===void 0&&(f[m]=u[m]);return {success:true,data:f}}return {success:true,data:{...c.data,...u}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:l}=le(s);if(a.success===false)return a;let c={},u=[];for(let f in e){let m=e[f]._parse(a.data[f],s);if(m.success)c[f]=m.data;else {let h=xt(m,f,l,u);if(h)return h}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),r}function Oe(e){return b(W,{...e,type:"string"})}function Ie(e){return b(we,{...e,type:"number"})}function Pe(e){return b(Te,{...e,type:"boolean"})}function Be(e){return b(vn,{...e,type:"date"})}function _t(e){return b(wn,{...e,type:"function"})}function Nt(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 Rt(e,t){let n=b(Tn,{...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}=le(i);if(s.success===false)return s;let l=[],c=[],u=i;for(let f=0;f<s.data.length;f++){let m={...u,context:{...u?.context,index:f}},h=e._parse(s.data[f],m);if(h.success)l.push(h.data);else {let y=xt(h,f,a,c);if(y)return y}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),n}function kt(){return b(()=>true)}function H(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function At(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: ${Me(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,l=[];for(let m=0;m<e.length;m++){let h=e[m]._parse(i,a);if(h.success)return h;l.push(h);}let{abortEarly:c}=le(a),u={message:typeof n=="function"?n(i):n};if(c!==false)return {success:false,error:u,errors:[u]};let f=[];for(let m=0;m<l.length;m++){let h=l[m].errors;if(h?.length)for(let y=0;y<h.length;y++)h[y].cause?.key&&f.push(Le(h[y],`branch ${m}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function vt(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 wt(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 Tt(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 Mt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return H(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},Pe({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return H(n=>{if(Te(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},Ie({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return H(n=>Te(n)||we(n)&&Number.isFinite(n)?String(n):n,Oe({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return H(n=>{let r;return W(n)&&(r=n.trim()),we(n)&&Number.isFinite(n)||r?new Date(r??n):n},Be({...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}},Lt={},p={object:Ct,string:Oe,number:Ie,boolean:Pe,date:Be,function:_t,enum:Nt,array:Rt,any:kt,preprocess:H,union:At,literal:vt,contextRef:wt,withContext:Tt,coerce:Lt,cast:Mt};function St(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||St(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 l=e(s);if(l===true)return {success:true,data:s};if(typeof l=="object"&&l?.success===true)return l;let c={message:typeof r=="function"?r(s):r};return {success:false,error:c,errors:[c]}},parse(s,a){let l=this._parse(s,a);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success&&(u.data=s(u.data)),u}),this},optional(){return ve(this,s=>s===void 0),this},nullable(){return ve(this,s=>s===null),this},nullish(){return ve(this,s=>s==null),this},default(s){return g(this,"_parse",(a,l,c)=>(l===void 0&&(l=typeof s=="function"?s({context:c?.context}):s),a(l,c))),this},catch(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?u:{success:true,data:typeof s=="function"?s({input:l,error:u.error}):s}}),this},pipe(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?s._parse(u.data,c):u}),this},refine(s,{message:a,type:l,jsonSchema:c}={}){if(l&&(a=a||St(l),t=l),c){let u=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>u;}return g(this,"_parse",(u,f,m)=>{let h=u(f,m),{abortEarly:y}=le(m);if(!h.success)return h;let R=s(h.data);if(R===true||typeof R=="object"&&R?.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 bt.length>0?bt.reduce((s,a)=>a(s,e,o)??s,i):i}var bt=[];var je=De(),$e=De(),Ot=De(),Mn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function De(){return Math.floor(Math.random()*16777215)}function Ln(){return $e=($e+1)%16777215,$e}function ce(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Ln(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,je>>16&255,je>>8&255,je&255,Ot>>8&255,Ot&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Mn[n.charCodeAt(o)];return r}var On=Symbol("block-element"),In=Symbol("block-element-body"),Fe=Symbol("selectable-element");function It(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 Pn(e){return e?It(e.startContainer,On):null}function Bn(e){return e?It(e.startContainer,Fe):null}function Pt(){return window.getSelection()}function He(){let e=Pt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Bt(){let e=He();if(!e)return 0;e.collapse(true);let t=Bn(e),n=Pn(e),r=t??$t(n);return jt(r,e.startContainer,e.startOffset)}function jt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,l=Math.min(n,a.length);for(let c=0;c<l;c++)s+=a[c].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 Ke(e,t){let n=jn(e,t),r=Pt();r.removeAllRanges(),r.addRange(n);}function $t(e){if(!e)return null;let t=$n(e);return t?.firstElementChild??t?.firstChild}function $n(e){if(!e)return null;for(let t of e.children)if(t[In])return t;return null}var Dt={INPUT:"mrakomor:input"};var Ft=Re();var ue=class extends yt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=ke(Ft),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}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(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(Dt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var Ht="molecule.paragraph.Paragraph";function N(e){return e===`
|
|
2
|
+
`,document.head.appendChild(n);}}})();var Ue=class{next(...e){}error(...e){}complete(...e){}},me=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 X=Symbol("@esmj/signals:type"),V=Symbol("@esmj/signals:name");var S=null,he=false,de=[];function w(e){let t=S;S=null;let n=e();return S=t,n}function an(){he=false;let e=ze();for(let n of e)n.get();let t=de;de=[];for(let n of t)n();}function Ye(){he||(he=true,queueMicrotask(an));}function ge(e){de.push(e),Ye();}var We=Symbol("@esmj/signals:internal observable"),A=Symbol("@esmj/signals:original function"),ln=class extends me{#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=()=>w(()=>{this.#e.add(e),this.#r();}),e.next[A]=void 0),e instanceof Ze&&e.next[A]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{this.#e.add(e),t(),this.#r();}),e.next[A]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[A]){let n=t.get,r=n.bind(t);t.get=()=>w(()=>(this.#e.delete(t),r())),t.get[A]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[A]?e.next[A]:e.next,e.get=e.get[A]?e.get[A]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function Xe(e){z=new ln(e);}Xe(()=>{Ye();});function ze(){return z.getPending()}function Je(e){return z.watch(e)}function Qe(e){return z.unwatch(e)}var v=Symbol("@esmj/signals:no error"),Ze=class et extends Ue{#e=true;#r=false;#n=null;#o=this.#p();#c=null;#l=null;#i=0;#s=new Map;#t=v;constructor(t,n){super(),this.#c=t,this.#l=n,this.debug=n?.debug,this[X]="computed",this[V]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#o.dependencies.values())t();this.#o.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[V],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof et&&w(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[We].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=I(this.#a(),this.#l)),(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=I(this.#a(),this.#l)),(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.#u(),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=v,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===v&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#t=v;}};function B(e,t){return new Ze(e,t)}function _(e,t){let n,{debug:r,...o}={},i=B(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),Je(i);let s=()=>{n?.(),i.destroy(),Qe(i);};return s[Symbol.dispose]=s,s[X]="effect",s[V]=r??null,s.__RX_COMPUTED__=i,s}function I(e,t={}){let n=t?.equals??Object.is,r=0,o=new me;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(c,r)),e}function s(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function l(){return r}let c={get:i,set:a,peek:s,getRevision:l,[We]:o,[X]:"signal",[V]:t?.debug??null};return c}function J(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var ct=Symbol("node-component"),Q=Symbol("node-internal"),cn=Symbol("keep-literal"),ne=Symbol("raw-props");var ut=null;function P(){return ut}function Z(e){ut=e;}function Ne(e){return e?.[ct]||null}function tt(e,t){e[ct]=t;}function ee(e,t={disposers:[],id:J()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function pn(e){return e[Q]}function M(e,t){let n=pn(e);n||(n=ee(e)),n.disposers.push(t);}function Ee(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function L(e,t){let n=P();Z(e);try{return t()}finally{Z(n);}}var Se=new Map,te=new Map,nt=new Map;function ft(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?.[cn]?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 Re(e){return {id:Symbol("context-id"),defaultValue:e}}function ke(e){let t=P();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function oe(e){ge(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Se.get(t);if(n){Se.delete(t);for(let r of n){let o=r();typeof o=="function"&&Ee(te,t,o);}}}function mn(e){let t=te.get(e);if(t){te.delete(e);for(let n of t)n();}}function hn(e){let t=nt.get(e);if(t){nt.delete(e);for(let n of t)n();}}function se(e){if(!e)return;let t=ee(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=Ne(e);if(n&&(mn(n.componentId),hn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;se(r),r=o;}}}function j(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function rt(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function dn(e,t,n){let r=J(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=rt(e)?void 0:e[ne],s={...ft(t??{},i),children:n},a=P(),l={disposers:[],id:r,contexts:new Map(a?.contexts)};Z(l);let c;if(rt(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&Ee(Se,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&Ee(te,r,()=>{f.onUnmount?.();}),c=f.render();}else c=e(s);Z(a);let u=gn(c);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ee(f,l),tt(f,o);else ee(u,l),u instanceof Node&&tt(u,o);return u}};return o}function Ae(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function gn(e){return e instanceof Node?e:j(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var ot={className:"class",htmlFor:"for"},st=new Set(["value","defaultValue","checked","selected","indeterminate"]),yn=new Set(["srcdoc"]),En=new Set(["href","src","action","formaction","xlink:href"]),Sn=new Set(["securitypolicyviolation"]),bn=new Set(["contenteditable","draggable","spellcheck"]);function U(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var pt=Symbol("Fragment");function D(e,t,n){if(e===pt){let o=document.createDocumentFragment();return be(o,at(n)),o}if(typeof e=="function")return dn(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),ie(r,t),be(r,at(n)),r}function ye(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function xn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Cn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return yn.has(n)?true:En.has(n)&&t!==null&&t!==void 0&&xn(String(t))}function mt(e){return typeof e!="string"?e:ot[e]?ot[e]:e}function _n(e,t){let n=mt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return bn.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function it(e,t,n){let r=_n(t,n);if(r===null){e.removeAttribute(t);return}if(Cn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function ie(e,t){let n=P();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=mt(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(U(o)){let i=_(()=>{L(n,()=>{ye(e,o.get());});});M(e,i);}else if(typeof o=="function"){let i=_(()=>{L(n,()=>{ye(e,o());});});M(e,i);}else ye(e,o);continue}if(r==="style"){if(U(o)){let i=_(()=>{L(n,()=>{Object.assign(e.style,o.get());});});M(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(Sn.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,o);continue}if(U(o)||typeof o=="function"){let i=r,s=_(()=>{L(n,()=>{let a=typeof o=="function"?o():o.get();st.has(i)?e[i]=a??"":it(e,i,a);});});M(e,s);continue}st.has(r)||typeof r=="symbol"?e[r]=o??"":it(e,r,o);}}function at(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function be(e,t){for(let n of t)ht(e,n);}function ht(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"){lt(e,t);return}if(j(t)){Ae(e,t);return}if(U(t)){lt(e,()=>t.get());return}if(Array.isArray(t)){be(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function F(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 ae(e,t=true){for(let n of e)t&&se(n),n.remove();}function lt(e,t){let n=P(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{L(n,()=>{let s=t(),{nodes:a,instance:l}=F(s);ae(o),a.length&&r.after(...a),l&&queueMicrotask(()=>Y(l)),o=a;});});M(e,i);}var yt=class{constructor(e){this.props=e;}};function Et(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(se(e),e.innerHTML=""),j(t)?Ae(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var kn={abortEarly:true};function Le(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 An(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Le(e.errors[r],n));}function xt(e,t,n,r){if(n!==false){let o=Le(e.error,t);return {success:false,error:o,errors:[o]}}An(e,r,t);}function le(e){return e?.abortEarly!==void 0?e:kn}function ve(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,we=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Te=e=>e===true||e===false,vn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),wn=e=>typeof e=="function",Tn=e=>Array.isArray(e),Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Ct(e,t){let n=b(Me,{...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,l)=>{let c=s(a,l);if(!c.success)return c;let u=o(c.data,{context:l?.context});if(!Me(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={...c.data};for(let m in u)f[m]===void 0&&(f[m]=u[m]);return {success:true,data:f}}return {success:true,data:{...c.data,...u}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:l}=le(s);if(a.success===false)return a;let c={},u=[];for(let f in e){let m=e[f]._parse(a.data[f],s);if(m.success)c[f]=m.data;else {let h=xt(m,f,l,u);if(h)return h}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),r}function Oe(e){return b(W,{...e,type:"string"})}function Ie(e){return b(we,{...e,type:"number"})}function Be(e){return b(Te,{...e,type:"boolean"})}function Pe(e){return b(vn,{...e,type:"date"})}function _t(e){return b(wn,{...e,type:"function"})}function Nt(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 Rt(e,t){let n=b(Tn,{...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}=le(i);if(s.success===false)return s;let l=[],c=[],u=i;for(let f=0;f<s.data.length;f++){let m={...u,context:{...u?.context,index:f}},h=e._parse(s.data[f],m);if(h.success)l.push(h.data);else {let y=xt(h,f,a,c);if(y)return y}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),n}function kt(){return b(()=>true)}function H(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function At(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: ${Me(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,l=[];for(let m=0;m<e.length;m++){let h=e[m]._parse(i,a);if(h.success)return h;l.push(h);}let{abortEarly:c}=le(a),u={message:typeof n=="function"?n(i):n};if(c!==false)return {success:false,error:u,errors:[u]};let f=[];for(let m=0;m<l.length;m++){let h=l[m].errors;if(h?.length)for(let y=0;y<h.length;y++)h[y].cause?.key&&f.push(Le(h[y],`branch ${m}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function vt(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 wt(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 Tt(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 Mt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return H(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},Be({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return H(n=>{if(Te(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},Ie({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return H(n=>Te(n)||we(n)&&Number.isFinite(n)?String(n):n,Oe({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return H(n=>{let r;return W(n)&&(r=n.trim()),we(n)&&Number.isFinite(n)||r?new Date(r??n):n},Pe({...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}},Lt={},p={object:Ct,string:Oe,number:Ie,boolean:Be,date:Pe,function:_t,enum:Nt,array:Rt,any:kt,preprocess:H,union:At,literal:vt,contextRef:wt,withContext:Tt,coerce:Lt,cast:Mt};function St(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||St(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 l=e(s);if(l===true)return {success:true,data:s};if(typeof l=="object"&&l?.success===true)return l;let c={message:typeof r=="function"?r(s):r};return {success:false,error:c,errors:[c]}},parse(s,a){let l=this._parse(s,a);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success&&(u.data=s(u.data)),u}),this},optional(){return ve(this,s=>s===void 0),this},nullable(){return ve(this,s=>s===null),this},nullish(){return ve(this,s=>s==null),this},default(s){return g(this,"_parse",(a,l,c)=>(l===void 0&&(l=typeof s=="function"?s({context:c?.context}):s),a(l,c))),this},catch(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?u:{success:true,data:typeof s=="function"?s({input:l,error:u.error}):s}}),this},pipe(s){return g(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?s._parse(u.data,c):u}),this},refine(s,{message:a,type:l,jsonSchema:c}={}){if(l&&(a=a||St(l),t=l),c){let u=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>u;}return g(this,"_parse",(u,f,m)=>{let h=u(f,m),{abortEarly:y}=le(m);if(!h.success)return h;let R=s(h.data);if(R===true||typeof R=="object"&&R?.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 bt.length>0?bt.reduce((s,a)=>a(s,e,o)??s,i):i}var bt=[];var je=De(),$e=De(),Ot=De(),Mn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function De(){return Math.floor(Math.random()*16777215)}function Ln(){return $e=($e+1)%16777215,$e}function ce(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Ln(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,je>>16&255,je>>8&255,je&255,Ot>>8&255,Ot&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Mn[n.charCodeAt(o)];return r}var On=Symbol("block-element"),In=Symbol("block-element-body"),Fe=Symbol("selectable-element");function It(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 Bn(e){return e?It(e.startContainer,On):null}function Pn(e){return e?It(e.startContainer,Fe):null}function Bt(){return window.getSelection()}function He(){let e=Bt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Pt(){let e=He();if(!e)return 0;e.collapse(true);let t=Pn(e),n=Bn(e),r=t??$t(n);return jt(r,e.startContainer,e.startOffset)}function jt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,l=Math.min(n,a.length);for(let c=0;c<l;c++)s+=a[c].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 Ke(e,t){let n=jn(e,t),r=Bt();r.removeAllRanges(),r.addRange(n);}function $t(e){if(!e)return null;let t=$n(e);return t?.firstElementChild??t?.firstChild}function $n(e){if(!e)return null;for(let t of e.children)if(t[In])return t;return null}var Dt={INPUT:"mrakomor:input"};var Ft=Re();var ue=class extends yt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=ke(Ft),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}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(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(Dt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var Ht="molecule.paragraph.Paragraph";function N(e){return e===`
|
|
3
3
|
`||e===`\r
|
|
4
4
|
`?"":e??""}function Gt({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 Ut(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 Yt(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function Dn(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function Kt(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function Fn(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let i=e;for(let s of t){let a=r.find(l=>l.match(s));a&&(i=D(a,{},i));}for(let s of n){let a=o.find(l=>l.match(s));a&&(i=D(a,s,i));}return i}function Wt(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=N(e.properties.text),i=e.properties.inlineStyleRanges??[],s=e.properties.entityRanges??[];if(!o)return r;let a=Dn([...i,...s],o.length);for(let l=0;l<a.length-1;l+=1){let c=a[l],u=a[l+1];if(c>=u)continue;let f=o.slice(c,u),m=Fn(f,Kt(i,c,u),Kt(s,c,u),{inlineStyleComponents:t,entityRangeComponents:n});Et(r,m);}return r}function fe(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let i=n;for(let s of e){if(s.nodeType===Node.TEXT_NODE){i+=s.textContent.length;continue}if(s.nodeType!==Node.ELEMENT_NODE||s.nodeName==="BR")continue;let a=r.find(c=>c.match(s));if(a){let c=s.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:i,length:c}),i=fe(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}let l=o.find(c=>c.match(s));if(l){let c=s.textContent.length;t.properties.entityRanges.push({...l.getStateSchema(s).parse(),offset:i,length:c}),i=fe(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}i=fe(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});}return i}function Xt(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 Vt(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 Hn(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=Vt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=qt(e.properties.entityRanges,t),r.properties.entityRanges=Vt(e.properties.entityRanges,t),r.componentId=ce(),{originalLineState:n,newLineState:r}}function zt(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Hn(e.getState(),
|
|
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 Yt(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function Dn(e,t){let n=new Set([0,t]);for(let r of e)n.add(r.offset),n.add(r.offset+r.length);return [...n].sort((r,o)=>r-o)}function Kt(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function Fn(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let i=e;for(let s of t){let a=r.find(l=>l.match(s));a&&(i=D(a,{},i));}for(let s of n){let a=o.find(l=>l.match(s));a&&(i=D(a,s,i));}return i}function Wt(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=N(e.properties.text),i=e.properties.inlineStyleRanges??[],s=e.properties.entityRanges??[];if(!o)return r;let a=Dn([...i,...s],o.length);for(let l=0;l<a.length-1;l+=1){let c=a[l],u=a[l+1];if(c>=u)continue;let f=o.slice(c,u),m=Fn(f,Kt(i,c,u),Kt(s,c,u),{inlineStyleComponents:t,entityRangeComponents:n});Et(r,m);}return r}function fe(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let i=n;for(let s of e){if(s.nodeType===Node.TEXT_NODE){i+=s.textContent.length;continue}if(s.nodeType!==Node.ELEMENT_NODE||s.nodeName==="BR")continue;let a=r.find(c=>c.match(s));if(a){let c=s.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:i,length:c}),i=fe(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}let l=o.find(c=>c.match(s));if(l){let c=s.textContent.length;t.properties.entityRanges.push({...l.getStateSchema(s).parse(),offset:i,length:c}),i=fe(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}i=fe(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});}return i}function Xt(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 Vt(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 Hn(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=Vt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=qt(e.properties.entityRanges,t),r.properties.entityRanges=Vt(e.properties.entityRanges,t),r.componentId=ce(),{originalLineState:n,newLineState:r}}function zt(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Hn(e.getState(),Pt(e.element));return e.mrakomor.command.insertBlockElement({range:He(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}function Jt(e,t){let n=e.constructor;if(!t)return n.getStateSchema(t).parse();let r=structuredClone(n.getStateSchema(t).parse());return fe(t.childNodes,r,0,{inlineStyleComponents:e.getInlineStyleComponents(),entityRangeComponents:e.getEntityRangeComponents()}),r.properties.text=N(r.properties.text),r}var pe=class extends ue{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:t}={}){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:N(this.getState()?.properties?.text).length;Ke(this.element,r);};n(),oe(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),Gt({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=Ut(n?.properties?.items);return Xt(t,Yt(r))}};function Qt(){return p.object({length:p.number(),offset:p.number(),style:p.string()})}function Zt({type:e,data:t=p.any(),length:n,offset:r}={}){let o=e!=null,i=p.object({type:o?p.string().default(e):p.string(),data:t}),s=n??(o?0:void 0),a=r??(o?0:void 0);return p.object({entity:o?i.default({}):i,length:s==null?p.number():p.number().default(s),offset:a==null?p.number():p.number().default(a)})}function en(e,{component:t,properties:n,settings:r=p.object({}).default({})}){return p.object({component:p.string().default(t),componentId:p.string().default(e?.getAttribute("data-componentid")||ce()),properties:p.object(n).default({}),settings:r}).default({})}var K=class e extends pe{static get NAMESPACE(){return Ht}static get LABEL(){return "P"}static get KEYWORDS(){return ["p","paragraph","text"]}getInlineStyleComponents(){return this.props?.inlineStyles?.get()??this.mrakomor.getConfig()?.inlineStyles??[]}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}static getStateSchema(t){return en(t,{component:e.NAMESPACE,properties:{entityRanges:p.array(Zt()).default([]),inlineStyleRanges:p.array(Qt()).default([]),text:p.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return Jt(this,t)}_buildContent(t){return Wt(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return D("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[Fe]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return N(r)?w(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){zt(this,t);}};function Kn(){return {resolveConfig:e=>(e.blockComponents.push(K),e),resolveComponent:e=>{if(e===K.NAMESPACE)return K}}}exports.Paragraph=K;exports.paragraphPlugin=Kn;
|
package/dist/paragraph.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as Paragraph,b as paragraphPlugin}from'./chunk-
|
|
1
|
+
export{a as Paragraph,b as paragraphPlugin}from'./chunk-DHFIX7FW.mjs';import'./chunk-SG5PCGIV.mjs';import'./chunk-B2UFH244.mjs';import'./chunk-ZHOZPQZH.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-D6K2L5O3.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-4WTPDNPA.mjs';import'./chunk-7CJLTNHZ.mjs';
|
package/dist/slashCommand.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var Ie=class{next(...e){}error(...e){}complete(...e){}},H=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 V=Symbol("@esmj/signals:type"),q=Symbol("@esmj/signals:name");var
|
|
1
|
+
'use strict';var Ie=class{next(...e){}error(...e){}complete(...e){}},H=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 V=Symbol("@esmj/signals:type"),q=Symbol("@esmj/signals:name");var R=null,re=false,Pe=[];function B(e){let t=R;R=null;let n=e();return R=t,n}function Ut(){re=false;let e=je();for(let n of e)n.get();let t=Pe;Pe=[];for(let n of t)n();}function Vt(){re||(re=true,queueMicrotask(Ut));}var $e=Symbol("@esmj/signals:internal observable"),T=Symbol("@esmj/signals:original function"),zt=class extends H{#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=()=>B(()=>{this.#e.add(e),this.#r();}),e.next[T]=void 0),e instanceof qe&&e.next[T]===void 0){let t=e.next.bind(e);e.next=()=>B(()=>{this.#e.add(e),t(),this.#r();}),e.next[T]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[T]){let n=t.get,r=n.bind(t);t.get=()=>B(()=>(this.#e.delete(t),r())),t.get[T]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[T]?e.next[T]:e.next,e.get=e.get[T]?e.get[T]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function De(e){z=new zt(e);}De(()=>{Vt();});function je(){return z.getPending()}var w=Symbol("@esmj/signals:no error"),qe=class Ke extends Ie{#e=true;#r=false;#t=null;#o=this.#p();#s=null;#i=null;#c=0;#l=new Map;#n=w;constructor(t,n){super(),this.#s=t,this.#i=n,this.debug=n?.debug,this[V]="computed",this[q]=n?.debug??null,this.get=this.get.bind(this);}#u(){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.#c}getDebugInfo(){return {name:this[q],dirty:this.#e,revision:this.#c,sourceDependencies:[...this.#l.keys()]}}#f(){for(let[t,n]of this.#l)if(t instanceof Ke&&B(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[$e].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=$(this.#a(),this.#i)),(this.#e||this.#n!==w)&&(this.#l.size===0||this.#f()?this.#a():this.#e=false),R&&R.sourceRevisions.set(this,this.#c),this.#n!==w)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=$(this.#a(),this.#i)),(this.#e||this.#n!==w)&&(this.#l.size===0||this.#f()?this.#a():this.#e=false),this.#n!==w)throw this.#n;return this.#t.peek()}#a(){this.#r=true,this.#e=false,this.#n=w,this.#u(),this.#o.sourceRevisions.clear();let t=R;R=this.#o;let n;try{n=this.#s();}catch(r){this.#n=r;}return R=t,this.#l=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=w,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===w&&this.#t&&this.#t.set(n),this.#c++,n}destroy(){this.#u(),this.#l.clear(),this.#e=true,this.#n=w;}};function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new H;function i(){return R&&(R.dependencies.set(o,o.subscribe(R.observer)),R.sourceRevisions.set(u,r)),e}function s(){return e}function l(f){if(!n(e,f)){e=f,r++,o.next();}return e}function c(){return r}let u={get:i,set:l,peek:s,getRevision:c,[$e]:o,[V]:"signal",[q]:t?.debug??null};return u}var ge=Ee(),ye=Ee(),tt=Ee(),hn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Ee(){return Math.floor(Math.random()*16777215)}function mn(){return ye=(ye+1)%16777215,ye}function Z(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=mn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,ge>>16&255,ge>>8&255,ge&255,tt>>8&255,tt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=hn[n.charCodeAt(o)];return r}var gn=Symbol("block-element");var yn=Symbol("selectable-element");function nt(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 rt(e){return e?nt(e.startContainer,gn):null}function ot(e){return e?nt(e.startContainer,yn):null}function En(){return window.getSelection()}function j(){let e=En();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Se(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,l=e.childNodes,c=Math.min(n,l.length);for(let u=0;u<c;u++)s+=l[u].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}var st="molecule.paragraph.Paragraph";var it="molecule.headline.";function I(e){return e===`
|
|
2
2
|
`||e===`\r
|
|
3
|
-
`?"":e??""}function at({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 P(e){let t=e?.component??"";return t===st||t.startsWith(it)}function ut(e,t){let n=I(e.properties.text),r=I(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 lt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function ct(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 xe(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=lt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=ct(e.properties.inlineStyleRanges,t),n.properties.entityRanges=lt(e.properties.entityRanges,t),r.properties.entityRanges=ct(e.properties.entityRanges,t),r.componentId=Z(),{originalLineState:n,newLineState:r}}var be={INPUT:"mrakomor:input"};function ft(e){return e.map((t,n)=>({entry:t,index:n})).sort((t,n)=>{let r=t.entry.order??t.index,o=n.entry.order??n.index;return r!==o?r-o:t.index-n.index}).map(({entry:t})=>t)}var ee=class extends H{mrakomor;#e=new Map;#r=null;#t=0;#o;constructor(t,n={}){super(),this.mrakomor=t,this.#o=n.sort??ft;}normalize(t,n){throw new Error("Register subclass must implement normalize")}#s(){this.#r=null,this.next(this.list());}#i(t,n=this.#t++){let r=this.normalize(t,n);return r?(this.#e.set(r.id,r),r):null}add(t){if(Array.isArray(t)){let r=[];for(let o of t){let i=this.#i(o,this.#t++);i&&r.push(i);}return r.length&&this.#s(),r}let n=this.#i(t);return n&&this.#s(),n}get(t){return this.#e.get(t)}has(t){return this.#e.has(t)}remove(t){let n=this.#e.delete(t);return n&&this.#s(),n}list(){return this.#r??=this.#o([...this.#e.values()]),this.#r}};var Sn={abortEarly:true};function ke(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 xn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(ke(e.errors[r],n));}function ht(e,t,n,r){if(n!==false){let o=ke(e.error,t);return {success:false,error:o,errors:[o]}}xn(e,r,t);}function te(e){return e?.abortEarly!==void 0?e:Sn}function Ce(e,t){C(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var U=e=>typeof e=="string"||e instanceof String,Re=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Ne=e=>e===true||e===false,bn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Cn=e=>typeof e=="function",Rn=e=>Array.isArray(e),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function mt(e,t){let n=_(_e,{...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 C(this,"_parse",(s,l,c)=>{let u=s(l,c);if(!u.success)return u;let f=o(u.data,{context:c?.context});if(!_e(f)){let p={message:`derive() callback must return a plain object of overrides, got ${f===null?"null":typeof f}`};return {success:false,error:p,errors:[p]}}if(i==="missing"){let p={...u.data};for(let h in f)p[h]===void 0&&(p[h]=f[h]);return {success:true,data:p}}return {success:true,data:{...u.data,...f}}}),this},C(n,"_parse",(o,i,s)=>{let l=o(i,s),{abortEarly:c}=te(s);if(l.success===false)return l;let u={},f=[];for(let p in e){let h=e[p]._parse(l.data[p],s);if(h.success)u[p]=h.data;else {let m=ht(h,p,c,f);if(m)return m}}return f.length>0?{success:false,error:f[0],errors:f}:{success:true,data:u}}),r}function Ae(e){return _(U,{...e,type:"string"})}function Te(e){return _(Re,{...e,type:"number"})}function we(e){return _(Ne,{...e,type:"boolean"})}function Le(e){return _(bn,{...e,type:"date"})}function gt(e){return _(Cn,{...e,type:"function"})}function yt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(l=>`"${l}"`).join(" | ")}, received "${s}".`,o="enum",i=_(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function Et(e,t){let n=_(Rn,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,C(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:l}=te(i);if(s.success===false)return s;let c=[],u=[],f=i;for(let p=0;p<s.data.length;p++){let h={...f,context:{...f?.context,index:p}},m=e._parse(s.data[p],h);if(m.success)c.push(m.data);else {let S=ht(m,p,l,u);if(S)return S}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),n}function St(){return _(()=>true)}function F(e,t){return C(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function xt(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: ${_e(o)?JSON.stringify(o):`"${o}"`}`,r=_(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,C(r,"_parse",(o,i,s)=>{let l=s,c=[];for(let h=0;h<e.length;h++){let m=e[h]._parse(i,l);if(m.success)return m;c.push(m);}let{abortEarly:u}=te(l),f={message:typeof n=="function"?n(i):n};if(u!==false)return {success:false,error:f,errors:[f]};let p=[];for(let h=0;h<c.length;h++){let m=c[h].errors;if(m?.length)for(let S=0;S<m.length;S++)m[S].cause?.key&&p.push(ke(m[S],`branch ${h}`));}return p.length===0&&p.push(f),{success:false,error:p[0],errors:p}}),r}function bt(e,t){let n=_(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 Ct(e){let t=_(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,C(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Rt(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 Nt={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 U(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},we({...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(Ne(n))return Number(n);if(U(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},Te({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Ne(n)||Re(n)&&Number.isFinite(n)?String(n):n,Ae({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return U(n)&&(r=n.trim()),Re(n)&&Number.isFinite(n)||r?new Date(r??n):n},Le({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return C(e,"_parse",(r,o,i)=>{if(U(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={},E={object:mt,string:Ae,number:Te,boolean:we,date:Le,function:gt,enum:yt,array:Et,any:St,preprocess:F,union:xt,literal:bt,contextRef:Ct,withContext:Rt,coerce:_t,cast:Nt};function pt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function C(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function _(e,{type:t="any",name:n,message:r}={}){r=r||pt(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,l){let c=e(s);if(c===true)return {success:true,data:s};if(typeof c=="object"&&c?.success===true)return c;let u={message:typeof r=="function"?r(s):r};return {success:false,error:u,errors:[u]}},parse(s,l){let c=this._parse(s,l);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(s,l){return this._parse(s,l)},transform(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success&&(f.data=s(f.data)),f}),this},optional(){return Ce(this,s=>s===void 0),this},nullable(){return Ce(this,s=>s===null),this},nullish(){return Ce(this,s=>s==null),this},default(s){return C(this,"_parse",(l,c,u)=>(c===void 0&&(c=typeof s=="function"?s({context:u?.context}):s),l(c,u))),this},catch(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success?f:{success:true,data:typeof s=="function"?s({input:c,error:f.error}):s}}),this},pipe(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success?s._parse(f.data,u):f}),this},refine(s,{message:l,type:c,jsonSchema:u}={}){if(c&&(l=l||pt(c),t=c),u){let f=[...this._getJsonSchemaHints?.()??[],u];this._getJsonSchemaHints=()=>f;}return C(this,"_parse",(f,p,h)=>{let m=f(p,h),{abortEarly:S}=te(h);if(!m.success)return m;let k=s(m.data);if(k===true||typeof k=="object"&&k?.success===true)return m;let R={message:typeof l=="function"?l(p):l};return {success:false,error:R,errors:[R]}}),this},clone(){return {...this}}};return dt.length>0?dt.reduce((s,l)=>l(s,e,o)??s,i):i}var dt=[];function Nn(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function _n({id:e,label:t,fallback:n=0}){return e??Nn(t,n)}var kt=E.object({id:E.string().optional(),label:E.string().optional(),keywords:E.array(E.string()).optional(),group:E.string().optional(),order:E.number().default(({context:e})=>e?.index??0),description:E.string().optional(),handler:E.function()}).derive(e=>{let t=_n({id:e.id,label:e.label,fallback:e.order}),n=String(e.label??e.id??`Action ${e.order}`),r=e.keywords?.length?e.keywords.map(String):[n,t];return {id:t,label:n,keywords:r,group:e.group??"actions",...e.description!=null&&e.description!==""?{description:String(e.description)}:{}}});var ne=class extends ee{normalize(t,n){if(!t||typeof t.handler!="function")return null;try{return kt.parse(t,{context:{index:n}})}catch{return null}}};function At(e,t){let n=e._getBlockElementState(t);return n?structuredClone(n):null}function kn(e,t){let n=e._getBlockElementByComponentId(t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function Tt(e){return e==null||e===""||/\s/.test(e)}function wt(e,t){if(typeof e!="string"||t<1)return null;let n=e.slice(0,t),r=-1;for(let o=n.length-1;o>=0;o--){let i=n[o];if(i==="/"){let s=o===0?null:n[o-1];if(s===null||/\s/.test(s)){r=o;break}return null}if(!/[\w]/.test(i))return null}return r<0?null:{slashStart:r,slashEnd:t,query:n.slice(r+1)}}function Lt(e,t){if(!e)return null;let n=t.inputType??"",r=t.data??null;return n==="insertText"||n==="insertCompositionText"||n==="insertReplacementText"?r==null||r===""?e:/\s/.test(r)||!/^[\w]+$/.test(r)?null:{...e,query:e.query+r,slashEnd:e.slashEnd+r.length}:n==="deleteContentBackward"||n==="deleteContentForward"||n==="deleteByCut"||n==="deleteByDrag"?e.slashEnd<=e.slashStart+1?null:{...e,query:e.query.slice(0,-1),slashEnd:e.slashEnd-1}:n==="insertFromPaste"||n==="insertFromDrop"?null:e}function ve(e){return typeof e?.handler=="function"}function vt(e,t){let n=String(t??"").trim().toLowerCase();return n?e.filter(r=>String(r.label??"").toLowerCase().includes(n)?true:(r.keywords??[]).some(i=>String(i).toLowerCase().includes(n))):e.slice()}function Bt(e,t,n,r){let{originalLineState:o}=xe(e,t),i=r&&P(r)?r:e,{newLineState:s}=xe(i,n);return {beforeState:o,afterState:s}}function Mt(e,t){let n=e._getBlockElementState(t);return n&&P(n)?n:null}function An(e,t=null){let n=e?.component,r=n?.NAMESPACE;if(!n||!r)return null;let o=I(t?.properties?.text??""),i=t?.properties?.inlineStyleRanges??[],s=t?.properties?.entityRanges??[],l={componentId:Z(),component:r,...e.settings?{settings:e.settings}:{}},c=at({properties:{text:o,inlineStyleRanges:i,entityRanges:s},settings:e.settings});return n.getStateSchema().parse({...n.fromExchangeState(c),...l})}function Ot(e,t){if(!ve(t))return;let{mrakomor:n,blockElement:r,slashStart:o,slashEnd:i,baselineState:s}=e;if(!s||!P(s)){t.handler(e);return}let l=Mt(n,r),{beforeState:c,afterState:u}=Bt(s,o,i,l),{state:f}=ut(c,u),p=I(c.properties?.text).length;n.command.replaceBlockElement({blockElement:r,blocks:[n.normalizeComponentState(f)],cursor:p}),t.handler(e);}function It(e,t){let{mrakomor:n,blockElement:r,slashStart:o,slashEnd:i,baselineState:s}=e,l=t?.component?.NAMESPACE;if(!l||!s||!P(s))return;let c=Mt(n,r),{beforeState:u,afterState:f}=Bt(s,o,i,c),p=I(u.properties?.text),h=I(f.properties?.text),m=!p&&!h,S=An(t,m?null:f);if(S){if(m){n.command.replaceBlockElement({blockElement:r,blocks:[S],cursor:0});return}n.command.insertBlockElement({blockElement:r,namespace:l,originalLineState:u,newLineState:S,cursor:0});}}function Pt(e,t){return {mrakomor:e,blockElement:kn(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:j()}}function $t(){return E.object({id:E.string(),group:E.string().default("general"),description:E.string().default(""),commands:E.array(E.string()).default([]),shortcuts:E.array(E.string()).default([])}).default({})}function Tn(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function Dt(e){return $t().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[Tn(e)],shortcuts:[]})}var wn={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function jt(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(Dt(n));}function Ln({mrakomor:e}){e.register.slashActions=new ne(e);let t=null,n=null,r=[],o=0,i=false;function s(a){return vt([...e.register.blocks.list(),...e.register.slashActions.list()],a)}function l(){i=false,t=null,n=null,r=[],o=0,e.command.closeMenu?.();}function c(a){if(!t||!a)return;let d=Pt(e,t);ve(a)?Ot(d,a):It(d,a),l();}function u(a){if(!t)return;a&&(n=a),r=s(t.query),o=0;let d=i;i=true;let g={entries:r,anchorRect:n??void 0,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c};d?e.command.updateMenu?.(g):e.command.openMenu?.(g);}function f(a,d,g,b,y){t={blockElement:a,slashStart:d,slashEnd:g,query:b,baselineState:At(e,a)},u(y);}function p(){let a=j();if(!a?.collapsed)return null;let d=rt(a),g=ot(a);if(!d||!g)return null;let b=g.textContent??"",y=Se(g,a.startContainer,a.startOffset);return {blockElement:d,selectable:g,text:b,cursor:y}}function h(a){let g=j()?.getBoundingClientRect?.();return (!g||g.width===0&&g.height===0)&&(g=a.getBoundingClientRect()),g}function m(a){return P(e._getBlockElementState(a))}function S(a){let d=wt(a.text,a.cursor);if(!d){i&&l();return}f(a.blockElement,d.slashStart,d.slashEnd,d.query,h(a.selectable));}function k(){let a=p();if(!a||!m(a.blockElement)||a.cursor<1||a.text[a.cursor-1]!=="/")return false;let d=a.cursor-1,g=d===0?null:a.text[d-1];return Tt(g)?(f(a.blockElement,d,d+1,"",h(a.selectable)),true):false}function R(a){let d=a.data??null,g=a.inputType??"";if(!t){if(d!=="/")return;k();return}if(g==="insertCompositionText"||g==="insertFromPaste"||g==="insertFromDrop"){let x=p();if(!x||x.blockElement!==t.blockElement){l();return}S(x);return}let b=g===""&&d!=null?{inputType:"insertText",data:d}:a,y=Lt(t,b);if(!y){l();return}t=y,u();}return {resolveConfig(a){return e.register.slashActions.add(a.slashActions??[]),jt(e),a},registerCommands(){e.register.help.add(wn),jt(e);},onKeyDown(a){if(i){if(a.key==="ArrowDown"){if(a.preventDefault(),!r.length)return;o=(o+1)%r.length,e.command.updateMenu?.({entries:r,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c});return}if(a.key==="ArrowUp"){if(a.preventDefault(),!r.length)return;o=(o-1+r.length)%r.length,e.command.updateMenu?.({entries:r,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c});return}if(a.key==="Enter"){a.preventDefault(),a.stopPropagation?.();let d=r[o];d&&c(d);return}a.key==="Escape"&&(a.preventDefault(),l());}},registerHandlers(){e.emitter.on(be.INPUT,R),e.emitter.on(be.CLOSE_MENU,()=>{i=false,t=null,n=null,r=[],o=0;});}}}exports.slashCommandPlugin=Ln;
|
|
3
|
+
`?"":e??""}function at({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 P(e){let t=e?.component??"";return t===st||t.startsWith(it)}function ut(e,t){let n=I(e.properties.text),r=I(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 lt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function ct(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 xe(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=lt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=ct(e.properties.inlineStyleRanges,t),n.properties.entityRanges=lt(e.properties.entityRanges,t),r.properties.entityRanges=ct(e.properties.entityRanges,t),r.componentId=Z(),{originalLineState:n,newLineState:r}}var be={INPUT:"mrakomor:input"};function ft(e){return e.map((t,n)=>({entry:t,index:n})).sort((t,n)=>{let r=t.entry.order??t.index,o=n.entry.order??n.index;return r!==o?r-o:t.index-n.index}).map(({entry:t})=>t)}var ee=class extends H{mrakomor;#e=new Map;#r=null;#t=0;#o;constructor(t,n={}){super(),this.mrakomor=t,this.#o=n.sort??ft;}normalize(t,n){throw new Error("Register subclass must implement normalize")}#s(){this.#r=null,this.next(this.list());}#i(t,n=this.#t++){let r=this.normalize(t,n);return r?(this.#e.set(r.id,r),r):null}add(t){if(Array.isArray(t)){let r=[];for(let o of t){let i=this.#i(o,this.#t++);i&&r.push(i);}return r.length&&this.#s(),r}let n=this.#i(t);return n&&this.#s(),n}get(t){return this.#e.get(t)}has(t){return this.#e.has(t)}remove(t){let n=this.#e.delete(t);return n&&this.#s(),n}list(){return this.#r??=this.#o([...this.#e.values()]),this.#r}};var Sn={abortEarly:true};function ke(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 xn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(ke(e.errors[r],n));}function ht(e,t,n,r){if(n!==false){let o=ke(e.error,t);return {success:false,error:o,errors:[o]}}xn(e,r,t);}function te(e){return e?.abortEarly!==void 0?e:Sn}function Ce(e,t){C(e,"_parse",(n,r,o)=>{let i=n(r,o);return !i.success&&t(r)?{success:true,data:r}:i});}var U=e=>typeof e=="string"||e instanceof String,Ne=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Re=e=>e===true||e===false,bn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Cn=e=>typeof e=="function",Nn=e=>Array.isArray(e),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function mt(e,t){let n=_(_e,{...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 C(this,"_parse",(s,l,c)=>{let u=s(l,c);if(!u.success)return u;let f=o(u.data,{context:c?.context});if(!_e(f)){let p={message:`derive() callback must return a plain object of overrides, got ${f===null?"null":typeof f}`};return {success:false,error:p,errors:[p]}}if(i==="missing"){let p={...u.data};for(let h in f)p[h]===void 0&&(p[h]=f[h]);return {success:true,data:p}}return {success:true,data:{...u.data,...f}}}),this},C(n,"_parse",(o,i,s)=>{let l=o(i,s),{abortEarly:c}=te(s);if(l.success===false)return l;let u={},f=[];for(let p in e){let h=e[p]._parse(l.data[p],s);if(h.success)u[p]=h.data;else {let m=ht(h,p,c,f);if(m)return m}}return f.length>0?{success:false,error:f[0],errors:f}:{success:true,data:u}}),r}function Ae(e){return _(U,{...e,type:"string"})}function Te(e){return _(Ne,{...e,type:"number"})}function we(e){return _(Re,{...e,type:"boolean"})}function Le(e){return _(bn,{...e,type:"date"})}function gt(e){return _(Cn,{...e,type:"function"})}function yt(e,t){let n=s=>e.includes(s),r=s=>`Invalid ${o} value. Expected ${e.map(l=>`"${l}"`).join(" | ")}, received "${s}".`,o="enum",i=_(n,{message:r,...t,type:o});return i._getDescription=()=>`enum(${e.map(s=>`"${s}"`).join(" | ")})`,i._getDefinition=()=>e,i}function Et(e,t){let n=_(Nn,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,C(n,"_parse",(r,o,i)=>{let s=r(o,i),{abortEarly:l}=te(i);if(s.success===false)return s;let c=[],u=[],f=i;for(let p=0;p<s.data.length;p++){let h={...f,context:{...f?.context,index:p}},m=e._parse(s.data[p],h);if(m.success)c.push(m.data);else {let S=ht(m,p,l,u);if(S)return S}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),n}function St(){return _(()=>true)}function F(e,t){return C(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function xt(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: ${_e(o)?JSON.stringify(o):`"${o}"`}`,r=_(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,C(r,"_parse",(o,i,s)=>{let l=s,c=[];for(let h=0;h<e.length;h++){let m=e[h]._parse(i,l);if(m.success)return m;c.push(m);}let{abortEarly:u}=te(l),f={message:typeof n=="function"?n(i):n};if(u!==false)return {success:false,error:f,errors:[f]};let p=[];for(let h=0;h<c.length;h++){let m=c[h].errors;if(m?.length)for(let S=0;S<m.length;S++)m[S].cause?.key&&p.push(ke(m[S],`branch ${h}`));}return p.length===0&&p.push(f),{success:false,error:p[0],errors:p}}),r}function bt(e,t){let n=_(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 Ct(e){let t=_(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,C(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function Nt(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 Rt={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 U(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},we({...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(Re(n))return Number(n);if(U(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},Te({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return F(n=>Re(n)||Ne(n)&&Number.isFinite(n)?String(n):n,Ae({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return F(n=>{let r;return U(n)&&(r=n.trim()),Ne(n)&&Number.isFinite(n)||r?new Date(r??n):n},Le({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return C(e,"_parse",(r,o,i)=>{if(U(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={},E={object:mt,string:Ae,number:Te,boolean:we,date:Le,function:gt,enum:yt,array:Et,any:St,preprocess:F,union:xt,literal:bt,contextRef:Ct,withContext:Nt,coerce:_t,cast:Rt};function pt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function C(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function _(e,{type:t="any",name:n,message:r}={}){r=r||pt(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,l){let c=e(s);if(c===true)return {success:true,data:s};if(typeof c=="object"&&c?.success===true)return c;let u={message:typeof r=="function"?r(s):r};return {success:false,error:u,errors:[u]}},parse(s,l){let c=this._parse(s,l);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(s,l){return this._parse(s,l)},transform(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success&&(f.data=s(f.data)),f}),this},optional(){return Ce(this,s=>s===void 0),this},nullable(){return Ce(this,s=>s===null),this},nullish(){return Ce(this,s=>s==null),this},default(s){return C(this,"_parse",(l,c,u)=>(c===void 0&&(c=typeof s=="function"?s({context:u?.context}):s),l(c,u))),this},catch(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success?f:{success:true,data:typeof s=="function"?s({input:c,error:f.error}):s}}),this},pipe(s){return C(this,"_parse",(l,c,u)=>{let f=l(c,u);return f.success?s._parse(f.data,u):f}),this},refine(s,{message:l,type:c,jsonSchema:u}={}){if(c&&(l=l||pt(c),t=c),u){let f=[...this._getJsonSchemaHints?.()??[],u];this._getJsonSchemaHints=()=>f;}return C(this,"_parse",(f,p,h)=>{let m=f(p,h),{abortEarly:S}=te(h);if(!m.success)return m;let k=s(m.data);if(k===true||typeof k=="object"&&k?.success===true)return m;let N={message:typeof l=="function"?l(p):l};return {success:false,error:N,errors:[N]}}),this},clone(){return {...this}}};return dt.length>0?dt.reduce((s,l)=>l(s,e,o)??s,i):i}var dt=[];function Rn(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function _n({id:e,label:t,fallback:n=0}){return e??Rn(t,n)}var kt=E.object({id:E.string().optional(),label:E.string().optional(),keywords:E.array(E.string()).optional(),group:E.string().optional(),order:E.number().default(({context:e})=>e?.index??0),description:E.string().optional(),handler:E.function()}).derive(e=>{let t=_n({id:e.id,label:e.label,fallback:e.order}),n=String(e.label??e.id??`Action ${e.order}`),r=e.keywords?.length?e.keywords.map(String):[n,t];return {id:t,label:n,keywords:r,group:e.group??"actions",...e.description!=null&&e.description!==""?{description:String(e.description)}:{}}});var ne=class extends ee{normalize(t,n){if(!t||typeof t.handler!="function")return null;try{return kt.parse(t,{context:{index:n}})}catch{return null}}};function At(e,t){let n=e._getBlockElementState(t);return n?structuredClone(n):null}function kn(e,t){let n=e._getBlockElementByComponentId(t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function Tt(e){return e==null||e===""||/\s/.test(e)}function wt(e,t){if(typeof e!="string"||t<1)return null;let n=e.slice(0,t),r=-1;for(let o=n.length-1;o>=0;o--){let i=n[o];if(i==="/"){let s=o===0?null:n[o-1];if(s===null||/\s/.test(s)){r=o;break}return null}if(!/[\w]/.test(i))return null}return r<0?null:{slashStart:r,slashEnd:t,query:n.slice(r+1)}}function Lt(e,t){if(!e)return null;let n=t.inputType??"",r=t.data??null;return n==="insertText"||n==="insertCompositionText"||n==="insertReplacementText"?r==null||r===""?e:/\s/.test(r)||!/^[\w]+$/.test(r)?null:{...e,query:e.query+r,slashEnd:e.slashEnd+r.length}:n==="deleteContentBackward"||n==="deleteContentForward"||n==="deleteByCut"||n==="deleteByDrag"?e.slashEnd<=e.slashStart+1?null:{...e,query:e.query.slice(0,-1),slashEnd:e.slashEnd-1}:n==="insertFromPaste"||n==="insertFromDrop"?null:e}function ve(e){return typeof e?.handler=="function"}function vt(e,t){let n=String(t??"").trim().toLowerCase();return n?e.filter(r=>String(r.label??"").toLowerCase().includes(n)?true:(r.keywords??[]).some(i=>String(i).toLowerCase().includes(n))):e.slice()}function Bt(e,t,n,r){let{originalLineState:o}=xe(e,t),i=r&&P(r)?r:e,{newLineState:s}=xe(i,n);return {beforeState:o,afterState:s}}function Mt(e,t){let n=e._getBlockElementState(t);return n&&P(n)?n:null}function An(e,t=null){let n=e?.component,r=n?.NAMESPACE;if(!n||!r)return null;let o=I(t?.properties?.text??""),i=t?.properties?.inlineStyleRanges??[],s=t?.properties?.entityRanges??[],l={componentId:Z(),component:r,...e.settings?{settings:e.settings}:{}},c=at({properties:{text:o,inlineStyleRanges:i,entityRanges:s},settings:e.settings});return n.getStateSchema().parse({...n.fromExchangeState(c),...l})}function Ot(e,t){if(!ve(t))return;let{mrakomor:n,blockElement:r,slashStart:o,slashEnd:i,baselineState:s}=e;if(!s||!P(s)){t.handler(e);return}let l=Mt(n,r),{beforeState:c,afterState:u}=Bt(s,o,i,l),{state:f}=ut(c,u),p=I(c.properties?.text).length;n.command.replaceBlockElement({blockElement:r,blocks:[n.normalizeComponentState(f)],cursor:p}),t.handler(e);}function It(e,t){let{mrakomor:n,blockElement:r,slashStart:o,slashEnd:i,baselineState:s}=e,l=t?.component?.NAMESPACE;if(!l||!s||!P(s))return;let c=Mt(n,r),{beforeState:u,afterState:f}=Bt(s,o,i,c),p=I(u.properties?.text),h=I(f.properties?.text),m=!p&&!h,S=An(t,m?null:f);if(S){if(m){n.command.replaceBlockElement({blockElement:r,blocks:[S],cursor:0});return}n.command.insertBlockElement({blockElement:r,namespace:l,originalLineState:u,newLineState:S,cursor:0});}}function Pt(e,t){return {mrakomor:e,blockElement:kn(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:j()}}function $t(){return E.object({id:E.string(),group:E.string().default("general"),description:E.string().default(""),commands:E.array(E.string()).default([]),shortcuts:E.array(E.string()).default([])}).default({})}function Tn(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function Dt(e){return $t().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[Tn(e)],shortcuts:[]})}var wn={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function jt(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(Dt(n));}function Ln({mrakomor:e}){e.register.slashActions=new ne(e);let t=null,n=null,r=[],o=0,i=false;function s(a){return vt([...e.register.blocks.list(),...e.register.slashActions.list()],a)}function l(){i=false,t=null,n=null,r=[],o=0,e.command.closeMenu?.();}function c(a){if(!t||!a)return;let d=Pt(e,t);ve(a)?Ot(d,a):It(d,a),l();}function u(a){if(!t)return;a&&(n=a),r=s(t.query),o=0;let d=i;i=true;let g={entries:r,anchorRect:n??void 0,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c};d?e.command.updateMenu?.(g):e.command.openMenu?.(g);}function f(a,d,g,b,y){t={blockElement:a,slashStart:d,slashEnd:g,query:b,baselineState:At(e,a)},u(y);}function p(){let a=j();if(!a?.collapsed)return null;let d=rt(a),g=ot(a);if(!d||!g)return null;let b=g.textContent??"",y=Se(g,a.startContainer,a.startOffset);return {blockElement:d,selectable:g,text:b,cursor:y}}function h(a){let g=j()?.getBoundingClientRect?.();return (!g||g.width===0&&g.height===0)&&(g=a.getBoundingClientRect()),g}function m(a){return P(e._getBlockElementState(a))}function S(a){let d=wt(a.text,a.cursor);if(!d){i&&l();return}f(a.blockElement,d.slashStart,d.slashEnd,d.query,h(a.selectable));}function k(){let a=p();if(!a||!m(a.blockElement)||a.cursor<1||a.text[a.cursor-1]!=="/")return false;let d=a.cursor-1,g=d===0?null:a.text[d-1];return Tt(g)?(f(a.blockElement,d,d+1,"",h(a.selectable)),true):false}function N(a){let d=a.data??null,g=a.inputType??"";if(!t){if(d!=="/")return;k();return}if(g==="insertCompositionText"||g==="insertFromPaste"||g==="insertFromDrop"){let x=p();if(!x||x.blockElement!==t.blockElement){l();return}S(x);return}let b=g===""&&d!=null?{inputType:"insertText",data:d}:a,y=Lt(t,b);if(!y){l();return}t=y,u();}return {resolveConfig(a){return e.register.slashActions.add(a.slashActions??[]),jt(e),a},registerCommands(){e.register.help.add(wn),jt(e);},onKeyDown(a){if(i){if(a.key==="ArrowDown"){if(a.preventDefault(),!r.length)return;o=(o+1)%r.length,e.command.updateMenu?.({entries:r,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c});return}if(a.key==="ArrowUp"){if(a.preventDefault(),!r.length)return;o=(o-1+r.length)%r.length,e.command.updateMenu?.({entries:r,highlightIndex:o,ariaLabel:"Slash commands",onSelect:c});return}if(a.key==="Enter"){a.preventDefault(),a.stopPropagation?.();let d=r[o];d&&c(d);return}a.key==="Escape"&&(a.preventDefault(),l());}},registerHandlers(){e.emitter.on(be.INPUT,N),e.emitter.on(be.CLOSE_MENU,()=>{i=false,t=null,n=null,r=[],o=0;});}}}exports.slashCommandPlugin=Ln;
|
package/dist/slashCommand.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a as a$2,b}from'./chunk-EXDY5TZH.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {q,v as v$1,j as j$1,x,k as k$1}from'./chunk-
|
|
1
|
+
import {a as a$2,b}from'./chunk-EXDY5TZH.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {q,v as v$1,j as j$1,x,k as k$1}from'./chunk-D6K2L5O3.mjs';import {a as a$1}from'./chunk-B6JJAATK.mjs';import {k,e,g,p,a as a$3}from'./chunk-4WTPDNPA.mjs';import'./chunk-7CJLTNHZ.mjs';function X(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function Z({id:e,label:t,fallback:n=0}){return e??X(t,n)}var O=a.object({id:a.string().optional(),label:a.string().optional(),keywords:a.array(a.string()).optional(),group:a.string().optional(),order:a.number().default(({context:e})=>e?.index??0),description:a.string().optional(),handler:a.function()}).derive(e=>{let t=Z({id:e.id,label:e.label,fallback:e.order}),n=String(e.label??e.id??`Action ${e.order}`),l=e.keywords?.length?e.keywords.map(String):[n,t];return {id:t,label:n,keywords:l,group:e.group??"actions",...e.description!=null&&e.description!==""?{description:String(e.description)}:{}}});var A=class extends a$2{normalize(t,n){if(!t||typeof t.handler!="function")return null;try{return O.parse(t,{context:{index:n}})}catch{return null}}};function N(e,t){let n=e._getBlockElementState(t);return n?structuredClone(n):null}function ee(e,t){let n=e._getBlockElementByComponentId(t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function H(e){return e==null||e===""||/\s/.test(e)}function z(e,t){if(typeof e!="string"||t<1)return null;let n=e.slice(0,t),l=-1;for(let o=n.length-1;o>=0;o--){let a=n[o];if(a==="/"){let c=o===0?null:n[o-1];if(c===null||/\s/.test(c)){l=o;break}return null}if(!/[\w]/.test(a))return null}return l<0?null:{slashStart:l,slashEnd:t,query:n.slice(l+1)}}function U(e,t){if(!e)return null;let n=t.inputType??"",l=t.data??null;return n==="insertText"||n==="insertCompositionText"||n==="insertReplacementText"?l==null||l===""?e:/\s/.test(l)||!/^[\w]+$/.test(l)?null:{...e,query:e.query+l,slashEnd:e.slashEnd+l.length}:n==="deleteContentBackward"||n==="deleteContentForward"||n==="deleteByCut"||n==="deleteByDrag"?e.slashEnd<=e.slashStart+1?null:{...e,query:e.query.slice(0,-1),slashEnd:e.slashEnd-1}:n==="insertFromPaste"||n==="insertFromDrop"?null:e}function L(e){return typeof e?.handler=="function"}function $(e,t){let n=String(t??"").trim().toLowerCase();return n?e.filter(l=>String(l.label??"").toLowerCase().includes(n)?true:(l.keywords??[]).some(a=>String(a).toLowerCase().includes(n))):e.slice()}function j(e,t,n,l){let{originalLineState:o}=x(e,t),a=l&&q(l)?l:e,{newLineState:c}=x(a,n);return {beforeState:o,afterState:c}}function K(e,t){let n=e._getBlockElementState(t);return n&&q(n)?n:null}function te(e,t=null){let n=e?.component,l=n?.NAMESPACE;if(!n||!l)return null;let o=j$1(t?.properties?.text??""),a=t?.properties?.inlineStyleRanges??[],c=t?.properties?.entityRanges??[],u={componentId:a$3(),component:l,...e.settings?{settings:e.settings}:{}},p=k$1({properties:{text:o,inlineStyleRanges:a,entityRanges:c},settings:e.settings});return n.getStateSchema().parse({...n.fromExchangeState(p),...u})}function V(e,t){if(!L(t))return;let{mrakomor:n,blockElement:l,slashStart:o,slashEnd:a,baselineState:c}=e;if(!c||!q(c)){t.handler(e);return}let u=K(n,l),{beforeState:p,afterState:d}=j(c,o,a,u),{state:h}=v$1(p,d),S=j$1(p.properties?.text).length;n.command.replaceBlockElement({blockElement:l,blocks:[n.normalizeComponentState(h)],cursor:S}),t.handler(e);}function Y(e,t){let{mrakomor:n,blockElement:l,slashStart:o,slashEnd:a,baselineState:c}=e,u=t?.component?.NAMESPACE;if(!u||!c||!q(c))return;let p=K(n,l),{beforeState:d,afterState:h}=j(c,o,a,p),S=j$1(d.properties?.text),C=j$1(h.properties?.text),k=!S&&!C,E=te(t,k?null:h);if(E){if(k){n.command.replaceBlockElement({blockElement:l,blocks:[E],cursor:0});return}n.command.insertBlockElement({blockElement:l,namespace:u,originalLineState:d,newLineState:E,cursor:0});}}function v(e,t){return {mrakomor:e,blockElement:ee(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:k()}}function ne(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function G(e){return b().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[ne(e)],shortcuts:[]})}var re={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function J(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(G(n));}function le({mrakomor:e$1}){e$1.register.slashActions=new A(e$1);let t=null,n=null,l=[],o=0,a=false;function c(r){return $([...e$1.register.blocks.list(),...e$1.register.slashActions.list()],r)}function u(){a=false,t=null,n=null,l=[],o=0,e$1.command.closeMenu?.();}function p$1(r){if(!t||!r)return;let s=v(e$1,t);L(r)?V(s,r):Y(s,r),u();}function d(r){if(!t)return;r&&(n=r),l=c(t.query),o=0;let s=a;a=true;let i={entries:l,anchorRect:n??void 0,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p$1};s?e$1.command.updateMenu?.(i):e$1.command.openMenu?.(i);}function h(r,s,i,y,g){t={blockElement:r,slashStart:s,slashEnd:i,query:y,baselineState:N(e$1,r)},d(g);}function S(){let r=k();if(!r?.collapsed)return null;let s=e(r),i=g(r);if(!s||!i)return null;let y=i.textContent??"",g$1=p(i,r.startContainer,r.startOffset);return {blockElement:s,selectable:i,text:y,cursor:g$1}}function C(r){let i=k()?.getBoundingClientRect?.();return (!i||i.width===0&&i.height===0)&&(i=r.getBoundingClientRect()),i}function k$1(r){return q(e$1._getBlockElementState(r))}function E(r){let s=z(r.text,r.cursor);if(!s){a&&u();return}h(r.blockElement,s.slashStart,s.slashEnd,s.query,C(r.selectable));}function Q(){let r=S();if(!r||!k$1(r.blockElement)||r.cursor<1||r.text[r.cursor-1]!=="/")return false;let s=r.cursor-1,i=s===0?null:r.text[s-1];return H(i)?(h(r.blockElement,s,s+1,"",C(r.selectable)),true):false}function W(r){let s=r.data??null,i=r.inputType??"";if(!t){if(s!=="/")return;Q();return}if(i==="insertCompositionText"||i==="insertFromPaste"||i==="insertFromDrop"){let B=S();if(!B||B.blockElement!==t.blockElement){u();return}E(B);return}let y=i===""&&s!=null?{inputType:"insertText",data:s}:r,g=U(t,y);if(!g){u();return}t=g,d();}return {resolveConfig(r){return e$1.register.slashActions.add(r.slashActions??[]),J(e$1),r},registerCommands(){e$1.register.help.add(re),J(e$1);},onKeyDown(r){if(a){if(r.key==="ArrowDown"){if(r.preventDefault(),!l.length)return;o=(o+1)%l.length,e$1.command.updateMenu?.({entries:l,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p$1});return}if(r.key==="ArrowUp"){if(r.preventDefault(),!l.length)return;o=(o-1+l.length)%l.length,e$1.command.updateMenu?.({entries:l,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p$1});return}if(r.key==="Enter"){r.preventDefault(),r.stopPropagation?.();let s=l[o];s&&p$1(s);return}r.key==="Escape"&&(r.preventDefault(),u());}},registerHandlers(){e$1.emitter.on(a$1.INPUT,W),e$1.emitter.on(a$1.CLOSE_MENU,()=>{a=false,t=null,n=null,l=[],o=0;});}}}export{le as slashCommandPlugin};
|
package/dist/tooltip.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-ERNLRJPB.mjs';import {o as o$1,B}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-ERNLRJPB.mjs';import {o as o$1,B}from'./chunk-D6K2L5O3.mjs';import {a}from'./chunk-B6JJAATK.mjs';import {q,x,s,k,e as e$1,v,h,m as m$1,n}from'./chunk-4WTPDNPA.mjs';import {e,m,o,c,u,p,g,f}from'./chunk-7CJLTNHZ.mjs';(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/tooltip/Tooltip.css",m=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(u){return u.getAttribute("data-mrakomor-css-path")===t});if(!m){var i=document.createElement("style");i.setAttribute("data-mrakomor-css",""),i.setAttribute("data-mrakomor-css-path",t),i.textContent=`.mrakomor-tooltip{position:absolute;z-index:9100;display:flex;flex-direction:row;align-items:center;gap:2px;background:#1a1a1a;border-radius:6px;padding:4px 6px;box-shadow:0 3px 10px #00000040;pointer-events:all;white-space:nowrap}.mrakomor-tooltip__btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;border-radius:4px;color:#fff;cursor:pointer;font-size:13px;font-weight:600;min-width:28px;min-height:28px;padding:0 6px;transition:background .1s}.mrakomor-tooltip__btn:hover{background:#ffffff26}.mrakomor-tooltip__btn--active{background:#ffffff40;color:#7dd3fc}.mrakomor-tooltip__separator{width:1px;height:18px;background:#fff3;margin:0 4px;flex-shrink:0}
|
|
2
2
|
`,document.head.appendChild(i);}}})();function V({mrakomor:t,open:m$1,tooltipElement:i}){let u$1=e(0),y=e(0),f=e([]),p$1=null,C=null;function E(){m$1.set(false),p$1=null,C=null;}m(()=>{let v=t.emitter.on(a.OPEN_TOOLTIP,({element:n,actions:o$1})=>{p$1=n,C=q(),f.set(o$1??[]),m$1.set(true),o(()=>{let{x:s,y:S}=x(t.getRoot(),n,i);u$1.set(s),y.set(S);});}),R=t.emitter.on(a.CLOSE_TOOLTIP,E),e=t.emitter.on(a.KEYDOWN,()=>{m$1.peek()===true&&E();}),r=t.emitter.on(a.CLICK,n=>{if(m$1.peek()!==true||!i.current||!p$1)return;let o=n.target;if(!(o instanceof Node)){E();return}i.current.contains(o)||p$1.contains(o)||o instanceof Element&&o.contains(i.current)||E();});return ()=>{v(),R(),e(),r();}});let _=c(()=>({left:`${u$1.get()}px`,top:`${y.get()}px`}));return u(()=>m$1.get(),p("div",{className:"mrakomor-tooltip",contenteditable:false,style:_,$ref:i},()=>J(f.get(),t,C)))}function J(t,m,i){if(!t.length)return null;let u=null,y=[];for(let f of t){u!==null&&f.group!==u&&y.push(p("span",{className:"mrakomor-tooltip__separator"})),u=f.group;let p$1=f.label,C=typeof p$1=="string"?p$1:typeof p$1=="function"?p(p$1,{}):p$1;y.push(p("button",{type:"button",className:["mrakomor-tooltip__btn",f.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:f.title??"",onClick:E=>{E.preventDefault(),s(i),f.onAction(m);}},C));}return p("span",{style:"display: contents"},y)}function Q({mrakomor:t}){let i=false,u=null,y=e(false),f$1=g(null);function p$1(){let e=t.getConfig();return {inlineStyles:e.inlineStyles,entityRanges:e.entityRanges,blockTransforms:t.register.blocks.list()}}function C(e,r){let n=o$1(t,e,r);if(!n)return null;let{element:o,item:s}=n;return s.inlineStyleRanges===void 0&&s.entityRanges===void 0?null:[{element:o,inlineStyleRanges:s.inlineStyleRanges??[],entityRanges:s.entityRanges??[]}]}function E(e,r,n$1,o$1){let s=[],S=t.getConfig()?.inlineStyles??[],b=t.getConfig()?.entityRanges??[],A=(r?.length?r:[{element:n$1,inlineStyleRanges:[],entityRanges:[]}]).map(l=>{let{offset:d,length:a}=B(l.element??n$1,o$1);return {item:l,selStart:d,selEnd:d+a}});for(let l of e.inlineStyles){let d=typeof l=="string"?l:l.style,a=S.find(T=>T.style===d);if(!a)continue;let L=A.some(({item:T,selStart:W,selEnd:X})=>(T.inlineStyleRanges??[]).some(x=>x.style===d&&x.offset<X&&x.offset+x.length>W));s.push({label:a.LABEL??d,title:d.charAt(0)+d.slice(1).toLowerCase(),group:"inline",active:()=>L,onAction:T=>{m$1(),T.command.insertInlineStyleRange({style:a.style}),o(()=>{n();});}});}for(let l of e.entityRanges){let d=typeof l=="string"?l:l.NAMESPACE,a=b.find(L=>L.NAMESPACE===d);a&&s.push({label:a.LABEL??"\u{1F517}",title:a.NAMESPACE,group:"inline",active:()=>false,onAction:L=>{m$1(),L.command.insertEntityRange({namespace:a.NAMESPACE,blockElement:n$1});}});}return s}function _(e){return {label:e.LABEL??e.NAMESPACE,title:e.LABEL??e.NAMESPACE,group:"transform",active:()=>true,onAction:()=>{}}}function v$1(e,r,n,o){let s=[],S=new Set;for(let b of e.blockTransforms){let g=typeof b=="string"?b:b?.component?.NAMESPACE??b?.NAMESPACE;if(!g||S.has(g)||(S.add(g),g===n.NAMESPACE))continue;let A=t.resolveComponentConstructor(g);A&&s.push({label:A.LABEL??g,title:`Convert to ${A.LABEL??g}`,group:"transform",active:()=>false,onAction:l=>{l.command.transformBlockElement({blockElement:r,namespace:g,range:o});}});}return s}function R(){if(i)return;let e=window.getSelection(),r=t.getRoot();if(!e||e.rangeCount===0){t.command.closeTooltip();return}let n=k();if(!r.contains(n.commonAncestorContainer)){t.command.closeTooltip();return}if(n.startContainer===f$1.current&&y.peek()===true)return;let o=e$1(n);if(!o){t.command.closeTooltip();return}let s=v(o),S=t._getBlockElementState(o);if(!s||!S){t.command.closeTooltip();return}let b=s.constructor;if(n.collapsed){t.command.closeTooltip();return}let g=h(n.startContainer),A=h(n.endContainer);if(!g||!A||g!==A){t.command.closeTooltip();return}let l=p$1(),d=C(o,n),a=[_(b),...v$1(l,o,b,n),...E(l,d,o,n)];if(a.length===0){t.command.closeTooltip();return}t.command.openTooltip({element:o,actions:a});}return {registerEvents(){a.OPEN_TOOLTIP="mrakomor:open-tooltip",a.CLOSE_TOOLTIP="mrakomor:close-tooltip";},registerCommands(e){e.command.openTooltip=(r,n)=>{e.emit(a.OPEN_TOOLTIP,{...r,options:n});},e.command.closeTooltip=r=>{e.emit(a.CLOSE_TOOLTIP,{options:r});};},registerListeners(){t.emitter.on(a.SELECTION_CHANGE,R),a.OPEN_DIALOG&&t.emitter.on(a.OPEN_DIALOG,()=>{i=true,y.peek()===true&&t.command.closeTooltip();}),a.CLOSE_DIALOG&&t.emitter.on(a.CLOSE_DIALOG,()=>{i=false;});},onMount(){let{dispose:e}=a$1(t,"mrakomor-tooltip-plugin-container",p(V,{mrakomor:f(t),tooltipElement:f$1,open:y}));u=e;},onUnmount(){u?.(),u=null;}}}export{V as Tooltip,Q as tooltipPlugin};
|