@mrakomor/core 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/blockChrome.cjs +3 -0
  2. package/dist/blockChrome.mjs +2 -2
  3. package/dist/blockInsertMenu.cjs +1 -0
  4. package/dist/blockInsertMenu.mjs +1 -1
  5. package/dist/chunk-5VPYPKGA.mjs +1 -0
  6. package/dist/chunk-G2QV4GOO.mjs +1 -0
  7. package/dist/{chunk-WX7ESURF.mjs → chunk-GDID5DFL.mjs} +1 -1
  8. package/dist/chunk-K2DMHAUD.mjs +1 -0
  9. package/dist/chunk-N4I2WZWF.mjs +1 -0
  10. package/dist/chunk-Q7RMVYZR.mjs +1 -0
  11. package/dist/chunk-T7OO472O.mjs +1 -0
  12. package/dist/chunk-TX4RCFPO.mjs +3 -0
  13. package/dist/chunk-U3MSKB3R.mjs +2 -0
  14. package/dist/chunk-UC7W4JIH.mjs +2 -0
  15. package/dist/chunk-WBTDWVEC.mjs +3 -0
  16. package/dist/{chunk-XQCH2FNS.mjs → chunk-YHWQV2DB.mjs} +1 -1
  17. package/dist/clipboard.cjs +5 -0
  18. package/dist/clipboard.mjs +3 -3
  19. package/dist/footer.cjs +2 -0
  20. package/dist/footer.mjs +2 -2
  21. package/dist/headline.cjs +4 -0
  22. package/dist/headline.mjs +1 -1
  23. package/dist/help.cjs +2 -0
  24. package/dist/help.mjs +2 -2
  25. package/dist/index.cjs +6 -0
  26. package/dist/index.mjs +4 -4
  27. package/dist/link.cjs +3 -0
  28. package/dist/link.mjs +2 -2
  29. package/dist/list.cjs +5 -0
  30. package/dist/list.mjs +1 -1
  31. package/dist/paragraph.cjs +4 -0
  32. package/dist/paragraph.mjs +1 -1
  33. package/dist/slashCommand.cjs +3 -0
  34. package/dist/slashCommand.mjs +1 -1
  35. package/dist/tooltip.cjs +2 -0
  36. package/dist/tooltip.mjs +2 -2
  37. package/dist/tts.cjs +9 -0
  38. package/dist/tts.mjs +3 -3
  39. package/package.json +68 -27
  40. package/dist/chunk-4NSVB4MI.mjs +0 -1
  41. package/dist/chunk-6XPPNCKR.mjs +0 -1
  42. package/dist/chunk-7UI6TZPX.mjs +0 -1
  43. package/dist/chunk-F67KYIDS.mjs +0 -2
  44. package/dist/chunk-JFLCNBDM.mjs +0 -3
  45. package/dist/chunk-P6HMUYFA.mjs +0 -1
  46. package/dist/chunk-PMR6XOZ6.mjs +0 -2
  47. package/dist/chunk-QWAQBTXR.mjs +0 -1
  48. package/dist/chunk-XVWRPXC2.mjs +0 -2
  49. package/dist/chunk-ZDZQ2RVJ.mjs +0 -1
package/dist/list.cjs ADDED
@@ -0,0 +1,5 @@
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 lt=class{next(...e){}error(...e){}complete(...e){}},ke=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 se=Symbol("@esmj/signals:type"),X=Symbol("@esmj/signals:name");var R=null,Ie=false,Ae=[];function w(e){let t=R;R=null;let n=e();return R=t,n}function Cn(){Ie=false;let e=pt();for(let n of e)n.get();let t=Ae;Ae=[];for(let n of t)n();}function ct(){Ie||(Ie=true,queueMicrotask(Cn));}function Le(e){Ae.push(e),ct();}var ut=Symbol("@esmj/signals:internal observable"),L=Symbol("@esmj/signals:original function"),Nn=class extends ke{#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=s=>{n(s),this.#e.add(s);},t.unsubscribe=s=>{r(s),this.#e.delete(s);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>w(()=>{this.#e.add(e),this.#r();}),e.next[L]=void 0),e instanceof gt&&e.next[L]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{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=()=>w(()=>(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)}},oe=null;function ft(e){oe=new Nn(e);}ft(()=>{ct();});function pt(){return oe.getPending()}function mt(e){return oe.watch(e)}function dt(e){return oe.unwatch(e)}var T=Symbol("@esmj/signals:no error"),gt=class ht extends lt{#e=true;#r=false;#t=null;#s=this.#p();#c=null;#l=null;#i=0;#o=new Map;#n=T;constructor(t,n){super(),this.#c=t,this.#l=n,this.debug=n?.debug,this[se]="computed",this[X]=n?.debug??null,this.get=this.get.bind(this);}#u(){for(let{unsubscribe:t}of this.#s.dependencies.values())t();this.#s.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#i}getDebugInfo(){return {name:this[X],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#o.keys()]}}#f(){for(let[t,n]of this.#o)if(t instanceof ht&&w(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[ut].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=P(this.#a(),this.#l)),(this.#e||this.#n!==T)&&(this.#o.size===0||this.#f()?this.#a():this.#e=false),R&&R.sourceRevisions.set(this,this.#i),this.#n!==T)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=P(this.#a(),this.#l)),(this.#e||this.#n!==T)&&(this.#o.size===0||this.#f()?this.#a():this.#e=false),this.#n!==T)throw this.#n;return this.#t.peek()}#a(){this.#r=true,this.#e=false,this.#n=T,this.#u(),this.#s.sourceRevisions.clear();let t=R;R=this.#s;let n;try{n=this.#c();}catch(r){this.#n=r;}return R=t,this.#o=this.#s.sourceRevisions,this.#s.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=T,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===T&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#o.clear(),this.#e=true,this.#n=T;}};function j(e,t){return new gt(e,t)}function I(e,t){let n,{debug:r,...s}={},o=j(()=>{n?.(),n=e();},{equals:()=>false,...s});o.get(),mt(o);let i=()=>{n?.(),o.destroy(),dt(o);};return i[Symbol.dispose]=i,i[se]="effect",i[X]=r??null,i.__RX_COMPUTED__=o,i}function P(e,t={}){let n=t?.equals??Object.is,r=0,s=new ke;function o(){return R&&(R.dependencies.set(s,s.subscribe(R.observer)),R.sourceRevisions.set(c,r)),e}function i(){return e}function a(u){if(!n(e,u)){e=u,r++,s.next();}return e}function l(){return r}let c={get:o,set:a,peek:i,getRevision:l,[ut]:s,[se]:"signal",[X]:t?.debug??null};return c}function ie(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var _t=Symbol("node-component"),ae=Symbol("node-internal"),_n=Symbol("keep-literal"),fe=Symbol("raw-props");function Oe(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function De(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var kn=new Set(["template","script"]);function In(e,t){let n=(e==null?"span":String(e)).trim(),r=n;kn.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 s=document.createElement(r);return r==="span"&&(s.style.display="contents"),s.setAttribute(t,ie()),s}function Be(e,t,n){let r=In(e,t);return n?.id&&r.setAttribute("id",n.id),r}var kt=null;function $(){return kt}function le(e){kt=e;}function pe(e){return e?.[_t]||null}function yt(e,t){e[_t]=t;}function ce(e,t={disposers:[],id:ie()}){return e?.[ae]?e[ae]:(e&&(e[ae]=t),t)}function An(e){return e[ae]}function v(e,t){let n=An(e);n||(n=ce(e)),n.disposers.push(t);}function we(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function O(e,t){let n=$();le(e);try{return t()}finally{le(n);}}var Me=new Map,ue=new Map,Et=new Map;function It(e,t){let n=typeof t=="function"?t:s=>!!t?.includes(s),r=Object.create(null);for(let s of Object.keys(e)){let o=e[s];s==="children"||n(s)?r[s]=o:o?.[_n]?r[s]=o():o!=null&&typeof o.get=="function"?r[s]=o:typeof o=="function"?r[s]=j(o):r[s]=P(o);}return r}function me(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(s=>{let o=Object.getOwnPropertyDescriptor(e,s),i=Object.getOwnPropertyDescriptor(t,s);if(!o||!i)return false;let a="value"in o?o.value:o.get?.call(e),l="value"in i?i.value:i.get?.call(t);return me(a,l)})}function Pe(e){return {id:Symbol("context-id"),defaultValue:e}}function je(e){let t=$();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function F(e){Le(()=>{setTimeout(e,0);});}function Q(e){let t=e.componentId,n=Me.get(t);if(n){Me.delete(t);for(let r of n){let s=r();typeof s=="function"&&we(ue,t,s);}}}function Ln(e){let t=ue.get(e);if(t){ue.delete(e);for(let n of t)n();}}function Tn(e){let t=Et.get(e);if(t){Et.delete(e);for(let n of t)n();}}function de(e){if(!e)return;let t=ce(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(s){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",s);}t.disposers=[];}let n=pe(e);if(n&&(Ln(n.componentId),Tn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let s=r.nextSibling;de(r),r=s;}}}function H(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function St(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function wn(e,t,n){let r=ie(),s={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let o=St(e)?void 0:e[fe],i={...It(t??{},o),children:n},a=$(),l={disposers:[],id:r,contexts:new Map(a?.contexts)};le(l);let c;if(St(e)){s.ClassConstructor=e;let f=new e(i);s.classInstance=f,typeof f.onMount=="function"&&we(Me,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&we(ue,r,()=>{f.onUnmount?.();}),c=f.render();}else c=e(i);le(a);let u=Mn(c);if(s.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let f of u.childNodes)ce(f,l),yt(f,s);else ce(u,l),u instanceof Node&&yt(u,s);return u}};return s}function $e(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Q(t);});}function Mn(e){return e instanceof Node?e:H(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var xt={className:"class",htmlFor:"for"},bt=new Set(["value","defaultValue","checked","selected","indeterminate"]),vn=new Set(["srcdoc"]),On=new Set(["href","src","action","formaction","xlink:href"]),Dn=new Set(["securitypolicyviolation"]),Bn=new Set(["contenteditable","draggable","spellcheck"]);function J(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var At=Symbol("Fragment");function q(e,t,n){if(e===At){let s=document.createDocumentFragment();return ve(s,Ct(n)),s}if(typeof e=="function")return wn(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),ge(r,t),ve(r,Ct(n)),r}function Te(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Pn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function jn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return vn.has(n)?true:On.has(n)&&t!==null&&t!==void 0&&Pn(String(t))}function Lt(e){return typeof e!="string"?e:xt[e]?xt[e]:e}function $n(e,t){let n=Lt(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 Rt(e,t,n){let r=$n(t,n);if(r===null){e.removeAttribute(t);return}if(jn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function ge(e,t){let n=$();for(let[r,s]of Reflect.ownKeys(t).map(o=>[o,t[o]]))if(r!=="id"){if(r=Lt(r),r==="$ref"){typeof s=="function"?s(e):typeof s=="object"&&s!==null&&(s.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(J(s)){let o=I(()=>{O(n,()=>{Te(e,s.get());});});v(e,o);}else if(typeof s=="function"){let o=I(()=>{O(n,()=>{Te(e,s());});});v(e,o);}else Te(e,s);continue}if(r==="style"){if(J(s)){let o=I(()=>{O(n,()=>{Object.assign(e.style,s.get());});});v(e,o);}else typeof s=="object"&&s!==null?Object.assign(e.style,s):e.setAttribute("style",s);continue}if(typeof r=="string"&&r.startsWith("on")&&typeof s=="function"){let o=r.slice(2).toLowerCase();if(Dn.has(o)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(o,s);continue}if(J(s)||typeof s=="function"){let o=r,i=I(()=>{O(n,()=>{let a=typeof s=="function"?s():s.get();bt.has(o)?e[o]=a??"":Rt(e,o,a);});});v(e,i);continue}bt.has(r)||typeof r=="symbol"?e[r]=s??"":Rt(e,r,s);}}function Ct(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function ve(e,t){for(let n of t)Tt(e,n);}function Tt(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"){Nt(e,t);return}if(H(t)){$e(e,t);return}if(J(t)){Nt(e,()=>t.get());return}if(Array.isArray(t)){ve(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function K(e){let t=null,n=e;return H(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function he(e,t=true){for(let n of e)t&&de(n),n.remove();}function Nt(e,t){let n=$(),r=document.createComment("");e.appendChild(r);let s=[],o=I(()=>{O(n,()=>{let i=t(),{nodes:a,instance:l}=K(i);he(s),a.length&&r.after(...a),l&&queueMicrotask(()=>Q(l)),s=a;});});v(e,o);}var vt=class{constructor(e){this.props=e;}};function wt(e,t,n,r){let{equals:s=me,tagName:o="span",...i}=r??{},a=Be(o,"data-for",i);ge(a,i);let l=$(),c=[],u=new Map,f=j(()=>e()),p=I(()=>{let m=f.get(),y=Array.isArray(m)?m:[],N=[],E=[],D=new Set;for(let g=0;g<y.length;g++){let x=y[g],_=t(x,g);if(D.has(_)){console.error(`For: duplicate key "${String(_)}" detected; ignoring later item at index ${g}`);continue}D.add(_),N.push(x),E.push(_);}let U=new Map(c.map(g=>[g.key,g])),M=[];for(let g=0;g<N.length;g++){let x=E[g],_=N[g],B=U.get(x);if(B)u.get(x).set(_),M.push(B),U.delete(x);else {let ot=P(_,{equals:s});u.set(x,ot);let En={...ot,set(){}},it={key:x,nodes:[]};O(l,()=>{let Sn=n(En,g),{nodes:xn,instance:at}=K(Sn);it.nodes=xn,at&&queueMicrotask(()=>Q(at));}),M.push(it);}}for(let[g,x]of U)he(x.nodes),u.delete(g);let A=null;for(let g=M.length-1;g>=0;g--){let x=M[g].nodes;for(let _=x.length-1;_>=0;_--){let B=x[_];(B.parentNode!==a||B.nextSibling!==A)&&a.insertBefore(B,A),A=B;}}c=M;});return v(a,p),a}function Fe(e,t,n,r){if(typeof e=="function")return wt(e,t,n,r);let{each:s,keyFn:o,equals:i,tagName:a,children:l,...c}=e??{};if(typeof o!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=Oe(s),f=De(e??{},t);return wt(u,o,f,{...c,equals:i,tagName:a})}Fe[fe]=e=>e!=="each";function Ot(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(de(e),e.innerHTML=""),H(t)?$e(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Hn={abortEarly:true};function Ge(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 Un(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Ge(e.errors[r],n));}function Pt(e,t,n,r){if(n!==false){let s=Ge(e.error,t);return {success:false,error:s,errors:[s]}}Un(e,r,t);}function ye(e){return e?.abortEarly!==void 0?e:Hn}function He(e,t){S(e,"_parse",(n,r,s)=>{let o=n(r,s);return !o.success&&t(r)?{success:true,data:r}:o});}var Z=e=>typeof e=="string"||e instanceof String,Ue=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),qe=e=>e===true||e===false,qn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),Kn=e=>typeof e=="function",Gn=e=>Array.isArray(e),Ke=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function jt(e,t){let n=C(Ke,{...t,type:"object"});n._getDescription=()=>`object({ ${Object.entries(e).map(([s,o])=>`${s}: ${o._getDescription()}`).join(", ")} })`,n._getDefinition=()=>e;let r=n;return r.derive=function(s,{when:o="always"}={}){return S(this,"_parse",(i,a,l)=>{let c=i(a,l);if(!c.success)return c;let u=s(c.data,{context:l?.context});if(!Ke(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(o==="missing"){let f={...c.data};for(let p in u)f[p]===void 0&&(f[p]=u[p]);return {success:true,data:f}}return {success:true,data:{...c.data,...u}}}),this},S(n,"_parse",(s,o,i)=>{let a=s(o,i),{abortEarly:l}=ye(i);if(a.success===false)return a;let c={},u=[];for(let f in e){let p=e[f]._parse(a.data[f],i);if(p.success)c[f]=p.data;else {let m=Pt(p,f,l,u);if(m)return m}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:c}}),r}function Ve(e){return C(Z,{...e,type:"string"})}function Ye(e){return C(Ue,{...e,type:"number"})}function We(e){return C(qe,{...e,type:"boolean"})}function Xe(e){return C(qn,{...e,type:"date"})}function $t(e){return C(Kn,{...e,type:"function"})}function Ft(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${s} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,s="enum",o=C(n,{message:r,...t,type:s});return o._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,o._getDefinition=()=>e,o}function Ht(e,t){let n=C(Gn,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,S(n,"_parse",(r,s,o)=>{let i=r(s,o),{abortEarly:a}=ye(o);if(i.success===false)return i;let l=[],c=[],u=o;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 y=Pt(m,f,a,c);if(y)return y}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),n}function Ut(){return C(()=>true)}function G(e,t){return S(t,"_parse",(n,r,s)=>(r=e(r),n(r,s))),t}function qt(e,t){let n=s=>`Invalid union value. Expected the value to match one of the schemas:${e.map((o,i)=>` ${i+1}. ${o._getDescription()}`).join(",")} but received "${typeof s}" with value: ${Ke(s)?JSON.stringify(s):`"${s}"`}`,r=C(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,S(r,"_parse",(s,o,i)=>{let a=i,l=[];for(let p=0;p<e.length;p++){let m=e[p]._parse(o,a);if(m.success)return m;l.push(m);}let{abortEarly:c}=ye(a),u={message:typeof n=="function"?n(o):n};if(c!==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 y=0;y<m.length;y++)m[y].cause?.key&&f.push(Ge(m[y],`branch ${p}`));}return f.length===0&&f.push(u),{success:false,error:f[0],errors:f}}),r}function Kt(e,t){let n=C(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 Gt(e){let t=C(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,S(t,"_parse",(n,r,s)=>({success:true,data:s?.context?.[e]})),t}function Vt(e,t){return {parse(n,r){let s=e.parse(r?.context??{},r);return t(s).parse(n,r)},safeParse(n,r){let s=e.safeParse(r?.context??{},r);return s.success?t(s.data).safeParse(n,r):s}}}var Yt={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return G(n=>{let r;return Z(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 G(n=>{if(qe(n))return Number(n);if(Z(n)){let r=n.trim();if(r==="")return n;let s=Number(r);if(Number.isFinite(s))return s}return n},Ye({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return G(n=>qe(n)||Ue(n)&&Number.isFinite(n)?String(n):n,Ve({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return G(n=>{let r;return Z(n)&&(r=n.trim()),Ue(n)&&Number.isFinite(n)||r?new Date(r??n):n},Xe({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return S(e,"_parse",(r,s,o)=>{if(Z(s))try{s=JSON.parse(s);}catch{let i={message:typeof n=="function"?n(s):n};return {success:false,error:i,errors:[i]}}return r(s,o)}),e}},Wt={},d={object:jt,string:Ve,number:Ye,boolean:We,date:Xe,function:$t,enum:Ft,array:Ht,any:Ut,preprocess:G,union:qt,literal:Kt,contextRef:Gt,withContext:Vt,coerce:Wt,cast:Yt};function Dt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function S(e,t,n){let r=e[t];e[t]=(...s)=>n(r,...s);}function C(e,{type:t="any",name:n,message:r}={}){r=r||Dt(t);let s={name:n,message:r,type:t},o={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let l=e(i);if(l===true)return {success:true,data:i};if(typeof l=="object"&&l?.success===true)return l;let c={message:typeof r=="function"?r(i):r};return {success:false,error:c,errors:[c]}},parse(i,a){let l=this._parse(i,a);if(!l.success)throw l=l,new Error(l.error.message,{cause:l.error.cause});return l.data},safeParse(i,a){return this._parse(i,a)},transform(i){return S(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success&&(u.data=i(u.data)),u}),this},optional(){return He(this,i=>i===void 0),this},nullable(){return He(this,i=>i===null),this},nullish(){return He(this,i=>i==null),this},default(i){return S(this,"_parse",(a,l,c)=>(l===void 0&&(l=typeof i=="function"?i({context:c?.context}):i),a(l,c))),this},catch(i){return S(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?u:{success:true,data:typeof i=="function"?i({input:l,error:u.error}):i}}),this},pipe(i){return S(this,"_parse",(a,l,c)=>{let u=a(l,c);return u.success?i._parse(u.data,c):u}),this},refine(i,{message:a,type:l,jsonSchema:c}={}){if(l&&(a=a||Dt(l),t=l),c){let u=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>u;}return S(this,"_parse",(u,f,p)=>{let m=u(f,p),{abortEarly:y}=ye(p);if(!m.success)return m;let N=i(m.data);if(N===true||typeof N=="object"&&N?.success===true)return m;let E={message:typeof a=="function"?a(f):a};return {success:false,error:E,errors:[E]}}),this},clone(){return {...this}}};return Bt.length>0?Bt.reduce((i,a)=>a(i,e,s)??i,o):o}var Bt=[];var ze=Qe(),Je=Qe(),Xt=Qe(),Vn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Qe(){return Math.floor(Math.random()*16777215)}function Yn(){return Je=(Je+1)%16777215,Je}function b(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Yn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,ze>>16&255,ze>>8&255,ze&255,Xt>>8&255,Xt&255,t>>16&255,t>>8&255,t&255),r="";for(let s=0;s<n.length;s++)r+=Vn[n.charCodeAt(s)];return r}var zt=Symbol("block-element"),Wn=Symbol("block-element-body"),Jt=Symbol("selectable-element");function Xn(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 Ee(e){return Xn(e,zt)}function Qt(){return window.getSelection()}function V(){let e=Qt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Ze(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,a=e.childNodes,l=Math.min(n,a.length);for(let c=0;c<l;c++)i+=a[c].textContent.length;return i}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),o=s.nextNode();for(;o;){if(o===t)return r+n;r+=o.textContent.length,o=s.nextNode();}return r}function zn(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,s=[e];for(;s.length>0;){let o=s.pop();if(o.nodeType===Node.TEXT_NODE){let i=o.textContent.length;if(r+i>=t)return n.setEnd(o,t-r),n.setStart(o,t-r),n;r+=i;}else if(o.childNodes&&o.childNodes.length>0)for(let i=o.childNodes.length-1;i>=0;i--)s.push(o.childNodes[i]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function Y(e,t){let n=zn(e,t),r=Qt();r.removeAllRanges(),r.addRange(n);}function Jn(e){if(!e)return null;let t=Qn(e);return t?.firstElementChild??t?.firstChild}function et(e){if(!e?.[zt])return null;let t=Jn(e);return t?pe(t)?.classInstance:null}function Qn(e){if(!e)return null;for(let t of e.children)if(t[Wn])return t;return null}var Se={INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var Zt=Pe();var xe=class extends vt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=je(Zt),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return d.object({component:d.string().default(this.NAMESPACE),properties:d.object().default({}),settings:d.object().default({})}).default({})}static getPropsSchema(){return d.object({state:this.getStateSchema(),observeDOMChanges:d.boolean().default(true)}).default({})}parseFromHTML(t){return this.constructor.getStateSchema(t).parse()}getState(){if(this._stale){let t=this.element;return this.parseFromHTML(t)}return this.state.peek()}isStale(){return this._stale}#e(){this._stale=true;}onMount(){!this.element||!this._observeDOMChanges||(this._observer=new MutationObserver(()=>{this.#e();}),this._observer.observe(this.element,{subtree:true,characterData:true,characterDataOldValue:true,childList:true,attributes:true,attributeOldValue:true}),this._onInputMarkStale=t=>{let n=t.target;n instanceof Node&&this.element?.contains(n)&&this.#e();},this.mrakomor?.emitter&&(this._offInputStale=this.mrakomor.emitter.on(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 W="molecule.paragraph.Paragraph",be="molecule.list.List";var en="molecule.headline.";function h(e){return e===`
3
+ `||e===`\r
4
+ `?"":e??""}function k({component:e,originComponent:t,properties:n,settings:r}={}){let s=n??{};return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{...s,text:s.text??"",inlineStyleRanges:s.inlineStyleRanges??[],entityRanges:s.entityRanges??[]},...r?{settings:r}:{}}}function sn(e){let t=e?.component??"";return t===W||t.startsWith(en)}function Re(e){return Array.isArray(e?.properties?.items)}function Zn(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,s)=>r-s)}function tn(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function er(e,t,n,{inlineStyleComponents:r,entityRangeComponents:s}){let o=e;for(let i of t){let a=r.find(l=>l.match(i));a&&(o=q(a,{},o));}for(let i of n){let a=s.find(l=>l.match(i));a&&(o=q(a,i,o));}return o}function on(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),s=h(e.properties.text),o=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!s)return r;let a=Zn([...o,...i],s.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=s.slice(c,u),p=er(f,tn(o,c,u),tn(i,c,u),{inlineStyleComponents:t,entityRangeComponents:n});Ot(r,p);}return r}function ee(e,t,n,{inlineStyleComponents:r,entityRangeComponents:s}){let o=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){o+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let a=r.find(c=>c.match(i));if(a){let c=i.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:o,length:c}),o=ee(i.childNodes,t,o,{inlineStyleComponents:r,entityRangeComponents:s});continue}let l=s.find(c=>c.match(i));if(l){let c=i.textContent.length;t.properties.entityRanges.push({...l.getStateSchema(i).parse(),offset:o,length:c}),o=ee(i.childNodes,t,o,{inlineStyleComponents:r,entityRangeComponents:s});continue}o=ee(i.childNodes,t,o,{inlineStyleComponents:r,entityRangeComponents:s});}return o}function te(e,t){let n=h(e.properties.text),r=h(t.properties.text);return {state:{...e,properties:{...t.properties,...e.properties,text:n+r,inlineStyleRanges:[...e.properties.inlineStyleRanges??[],...(t.properties.inlineStyleRanges??[]).map(s=>({...s,offset:s.offset+n.length}))],entityRanges:[...e.properties.entityRanges??[],...(t.properties.entityRanges??[]).map(s=>({...s,offset:s.offset+n.length}))]},settings:{...t.settings,...e.settings}},cursor:n.length}}function nn(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function rn(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 an(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=nn(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=rn(e.properties.inlineStyleRanges,t),n.properties.entityRanges=nn(e.properties.entityRanges,t),r.properties.entityRanges=rn(e.properties.entityRanges,t),r.componentId=b(),{originalLineState:n,newLineState:r}}var Ce=class extends xe{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:h(this.getState()?.properties?.text).length;Y(this.element,r);};n(),F(n);}onKeydown(t){}getFormattingTarget(t){return null}static toExchangeState(t){return k({originComponent:this.NAMESPACE,properties:{...t?.properties,text:h(t?.properties?.text)},settings:t?.settings})}static fromExchangeState(t){return {properties:t?.properties,settings:t?.settings}}static appendExchangeState(t,n){return te(t,n)}};function ln(){return d.object({length:d.number(),offset:d.number(),style:d.string()})}function cn({type:e,data:t=d.any(),length:n,offset:r}={}){let s=e!=null,o=d.object({type:s?d.string().default(e):d.string(),data:t}),i=n??(s?0:void 0),a=r??(s?0:void 0);return d.object({entity:s?o.default({}):o,length:i==null?d.number():d.number().default(i),offset:a==null?d.number():d.number().default(a)})}function fn(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function tt(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=b();return t.add(r),{...n,componentId:r}})}function nt(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function ne(e,t){if(!e||!t)return null;let n=t.startContainer;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n!==e;){if(n.nodeName==="LI"&&e.contains(n))return n;n=n.parentElement;}return null}function re(e,t){if(!t)return -1;let n=t.getAttribute?.("data-item-index");if(n!=null&&n!==""){let r=Number(n);if(!Number.isNaN(r))return r}return nt(e).indexOf(t)}function rt(e,t){return !e||!t?0:Ze(e,t.startContainer,t.startOffset)}function pn(e,t){let n=k({properties:{text:e.text,inlineStyleRanges:e.inlineStyleRanges,entityRanges:e.entityRanges}}),{originalLineState:r,newLineState:s}=an(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:b(),depth:e.depth??0,text:s.properties.text,inlineStyleRanges:s.properties.inlineStyleRanges??[],entityRanges:s.properties.entityRanges??[]}}}function mn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(s=>({componentId:b(),depth:s?.depth??0,text:h(s?.text??""),inlineStyleRanges:[...s?.inlineStyleRanges??[]],entityRanges:[...s?.entityRanges??[]]})):[{componentId:b(),depth:0,text:h(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:be,componentId:b(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function st(e,t,{namespace:n=W,Constructor:r}={}){let s=e.properties?.items??[],o=s[t];if(!o)return {blocks:[e],paragraphIndex:0};let i=s.slice(0,t),a=s.slice(t+1),l=k({properties:{text:o.text,inlineStyleRanges:o.inlineStyleRanges,entityRanges:o.entityRanges}}),c={component:n,componentId:b(),settings:{},...r?.fromExchangeState(l)??l},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(c),a.length&&u.push({...e,componentId:i.length?b():e.componentId,properties:{...e.properties,items:a}}),{blocks:u,paragraphIndex:i.length?1:0}}function un(e){return Re(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function tr(e,t){let n=un(e),r=un(t);return n!=null&&n===r}function dn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],s=e[n];if(!tr(r,s))return null;let o=[...r.properties?.items??[]],i=[...s.properties?.items??[]];if(i.length===0){let p=[...e];p.splice(n,1);let m=o.length-1,y=m>=0?h(o[m]?.text).length:0;return {content:p,listIndex:t,cursor:y}}let[a,...l]=i,c=0;if(o.length===0)o.push(a,...l),c=0;else {let p=o.length-1,m=o[p],y=k({properties:{text:m.text,inlineStyleRanges:m.inlineStyleRanges,entityRanges:m.entityRanges}}),N=k({properties:{text:a.text,inlineStyleRanges:a.inlineStyleRanges,entityRanges:a.entityRanges}}),{state:E,cursor:D}=te(y,N);o[p]={...m,text:E.properties.text,inlineStyleRanges:E.properties.inlineStyleRanges,entityRanges:E.properties.entityRanges},l.length&&o.push(...l),c=D;}let u={...r,properties:{...r.properties,items:tt(o)}},f=[...e];return f[t]=u,f.splice(n,1),{content:f,listIndex:t,cursor:c}}function gn(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let s=n[r],o=k({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),i=k({properties:t?.properties}),{state:a,cursor:l}=te(o,i);return {state:{...e,properties:{...e.properties,items:n.map((c,u)=>u===r?{...c,text:a.properties.text,inlineStyleRanges:a.properties.inlineStyleRanges,entityRanges:a.properties.entityRanges}:c)}},cursor:l}}function hn(e,t){return on({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function yn(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:h(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return ee(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:h(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var Ne=e=>d.object({componentId:d.string().default(()=>e?.getAttribute?.("data-componentid")||b()),depth:d.number().default(0),text:d.string().default(""),inlineStyleRanges:d.array(ln()).default([]),entityRanges:d.array(cn()).default([])}).default({}),_e=class e extends Ce{static get NAMESPACE(){return be}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=fn(t);return d.object({component:d.string().default(e.NAMESPACE),componentId:d.string().default(t?.getAttribute("data-componentid")||b()),properties:d.object({items:d.array(Ne()).default([Ne().parse()]).transform(tt)}).default({}),settings:d.object({style:d.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let n=t?.properties?.items??[],r=n.map(o=>h(o?.text)).join(`
5
+ `),s=n.map(o=>({text:h(o?.text),inlineStyleRanges:o?.inlineStyleRanges??[],entityRanges:o?.entityRanges??[],depth:o?.depth??0}));return k({originComponent:this.NAMESPACE,properties:{text:r,items:s},settings:t?.settings})}static fromExchangeState(t){return mn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return gn(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()},s=nt(t);if(s.length)n.properties.items=s.map(o=>Ne(o).parse(yn(o,r)));else {let o=this.state?.peek?.()?.properties?.items;n.properties.items=o?.length?structuredClone(o):[Ne().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}getFormattingTarget(t){let n=t??V(),r=ne(this.element,n);if(!r)return null;let s=re(this.element,r);return s<0?null:{element:r,read(o){let i=o.properties?.items?.[s];return {inlineStyleRanges:i?.inlineStyleRanges,entityRanges:i?.entityRanges}},write(o,{inlineStyleRanges:i,entityRanges:a}){let l=o.properties?.items?.[s];l&&(i!==void 0&&(l.inlineStyleRanges=i),a!==void 0&&(l.entityRanges=a));}}}_commitState(t){let n=Ee(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId),r=this.mrakomor._getBlockElementIndex(n);if(r===-1)return;let s=this.mrakomor.getContent();s.splice(r,1,t),this.mrakomor.setContent(s);}_buildItemContent(t){return hn(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",s=Fe(()=>this.state.get().properties?.items??[],(o,i)=>o.componentId??String(i),(o,i)=>q("li",{contentEditable:true,[Jt]:true,"data-componentid":()=>o.get().componentId,"data-item-index":()=>{let a=o.get()?.componentId,c=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===a);return String(c>=0?c:i)},"data-depth":()=>String(o.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let a=o.get(),l=a?.text??"";return h(l)?w(()=>this._buildItemContent(a)):"<br>"}}),{tagName:r});return s.className=t,n.componentId&&s.setAttribute("data-componentid",n.componentId),this.element=s,s}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor(t){let n=this.getState()?.properties?.items??[],r=n.length-1;if(r<0)return;let s=typeof t=="number"?t:h(n[r]?.text).length,o=()=>{let i=this.element?.querySelector(`li[data-item-index="${r}"]`);i?.isConnected&&Y(i,s);};o(),F(o);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],s=r[t];if(!s)return;if((s.depth??0)>0){r[t]={...s,depth:s.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let f=()=>{let p=this.element?.querySelector(`li[data-item-index="${t}"]`);p?.isConnected&&Y(p,0);};f(),F(f);return}let o=Ee(this.element),i=this.mrakomor._getBlockElementIndex(o),a=o?.previousElementSibling??null,l=a?this.mrakomor._getBlockElementIndex(a):-1;if(t===0&&l>=0&&i===l+1){let f=this.mrakomor.getContent(),p=dn(f,l,i);if(p){this.mrakomor._setContentState(p.content.map(m=>this.mrakomor.normalizeComponentState(m))),et(a)?.setCursor?.(p.cursor);return}}let{blocks:c,paragraphIndex:u}=st(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(W)});this.mrakomor.command.replaceBlockElement({blockElement:Ee(this.element),blocks:c,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=V(),r=ne(this.element,n);if(!r)return;let s=re(this.element,r),o=rt(r,n),i=this.getState(),a=[...i.properties.items??[]],l=a[s];if(!l)return;if(!h(l.text)){this.#e(s);return}let{before:c,after:u}=pn(l,o);a.splice(s,1,c,u),this._commitState({...i,properties:{...i.properties,items:a}}),F(()=>{let f=this.element?.querySelector(`li[data-item-index="${s+1}"]`);f&&Y(f,0);});}#t(t){let n=V();if(!n?.collapsed)return;let r=ne(this.element,n);if(!r){let i=n.startContainer;if(!(i===this.element||this.element?.contains?.(i)))return;t.preventDefault(),this.#e(0);return}let s=re(this.element,r);rt(r,n)===0&&(t.preventDefault(),this.#e(s));}};function nr(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let s=t._getBlockElementState(n);if(!s||!sn({component:r})||!Re(s))return;e.preventDefault();let i=et(n)?.element,a=e.range??V(),l=i?ne(i,a):null,c=re(i,l);if(c<0)return;let{blocks:u,paragraphIndex:f}=st(s,c,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:f});}function rr(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,nr);}}}function sr(){return rr(_e)}exports.List=_e;exports.listPlugin=sr;
package/dist/list.mjs CHANGED
@@ -1 +1 @@
1
- export{a as List,c as listPlugin}from'./chunk-F67KYIDS.mjs';import'./chunk-QWAQBTXR.mjs';import'./chunk-P6HMUYFA.mjs';import'./chunk-WX7ESURF.mjs';import'./chunk-7UI6TZPX.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-JFLCNBDM.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-XQCH2FNS.mjs';import'./chunk-ZDZQ2RVJ.mjs';
1
+ export{a as List,c as listPlugin}from'./chunk-WBTDWVEC.mjs';import'./chunk-Q7RMVYZR.mjs';import'./chunk-G2QV4GOO.mjs';import'./chunk-GDID5DFL.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-TX4RCFPO.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-YHWQV2DB.mjs';import'./chunk-K2DMHAUD.mjs';
@@ -0,0 +1,4 @@
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 Ge=class{next(...e){}error(...e){}complete(...e){}},pe=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,me=false,de=[];function w(e){let t=S;S=null;let n=e();return S=t,n}function on(){me=false;let e=Xe();for(let n of e)n.get();let t=de;de=[];for(let n of t)n();}function Ue(){me||(me=true,queueMicrotask(on));}function he(e){de.push(e),Ue();}var Ye=Symbol("@esmj/signals:internal observable"),k=Symbol("@esmj/signals:original function"),sn=class extends pe{#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[k]=void 0),e instanceof Qe&&e.next[k]===void 0){let t=e.next.bind(e);e.next=()=>w(()=>{this.#e.add(e),t(),this.#r();}),e.next[k]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[k]){let n=t.get,r=n.bind(t);t.get=()=>w(()=>(this.#e.delete(t),r())),t.get[k]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[k]?e.next[k]:e.next,e.get=e.get[k]?e.get[k]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function We(e){z=new sn(e);}We(()=>{Ue();});function Xe(){return z.getPending()}function ze(e){return z.watch(e)}function Je(e){return z.unwatch(e)}var A=Symbol("@esmj/signals:no error"),Qe=class Ze extends Ge{#e=true;#r=false;#n=null;#o=this.#p();#l=null;#u=null;#i=0;#s=new Map;#t=A;constructor(t,n){super(),this.#l=t,this.#u=n,this.debug=n?.debug,this[X]="computed",this[V]=n?.debug??null,this.get=this.get.bind(this);}#c(){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 Ze&&w(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[Ye].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==A)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),S&&S.sourceRevisions.set(this,this.#i),this.#t!==A)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=I(this.#a(),this.#u)),(this.#e||this.#t!==A)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#t!==A)throw this.#t;return this.#n.peek()}#a(){this.#r=true,this.#e=false,this.#t=A,this.#c(),this.#o.sourceRevisions.clear();let t=S;S=this.#o;let n;try{n=this.#l();}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=A,this.#n.set(r);}).catch(r=>{this.#t=r;})),this.#t===A&&this.#n&&this.#n.set(n),this.#i++,n}destroy(){this.#c(),this.#s.clear(),this.#e=true,this.#t=A;}};function P(e,t){return new Qe(e,t)}function _(e,t){let n,{debug:r,...o}={},i=P(()=>{n?.(),n=e();},{equals:()=>false,...o});i.get(),ze(i);let s=()=>{n?.(),i.destroy(),Je(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 pe;function i(){return S&&(S.dependencies.set(o,o.subscribe(S.observer)),S.sourceRevisions.set(l,r)),e}function s(){return e}function a(c){if(!n(e,c)){e=c,r++,o.next();}return e}function u(){return r}let l={get:i,set:a,peek:s,getRevision:u,[Ye]:o,[X]:"signal",[V]:t?.debug??null};return l}function J(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var ut=Symbol("node-component"),Q=Symbol("node-internal"),an=Symbol("keep-literal"),ne=Symbol("raw-props");var lt=null;function B(){return lt}function Z(e){lt=e;}function _e(e){return e?.[ut]||null}function et(e,t){e[ut]=t;}function ee(e,t={disposers:[],id:J()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function cn(e){return e[Q]}function M(e,t){let n=cn(e);n||(n=ee(e)),n.disposers.push(t);}function ye(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 Ee=new Map,te=new Map,tt=new Map;function ct(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?.[an]?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 Ne(e){return {id:Symbol("context-id"),defaultValue:e}}function Re(e){let t=B();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function ke(e){he(()=>{setTimeout(e,0);});}function Y(e){let t=e.componentId,n=Ee.get(t);if(n){Ee.delete(t);for(let r of n){let o=r();typeof o=="function"&&ye(te,t,o);}}}function fn(e){let t=te.get(e);if(t){te.delete(e);for(let n of t)n();}}function pn(e){let t=tt.get(e);if(t){tt.delete(e);for(let n of t)n();}}function oe(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=_e(e);if(n&&(fn(n.componentId),pn(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;oe(r),r=o;}}}function $(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function nt(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function mn(e,t,n){let r=J(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let i=nt(e)?void 0:e[ne],s={...ct(t??{},i),children:n},a=B(),u={disposers:[],id:r,contexts:new Map(a?.contexts)};Z(u);let l;if(nt(e)){o.ClassConstructor=e;let f=new e(s);o.classInstance=f,typeof f.onMount=="function"&&ye(Ee,r,()=>{f.onMount?.();}),typeof f.onUnmount=="function"&&ye(te,r,()=>{f.onUnmount?.();}),l=f.render();}else l=e(s);Z(a);let c=dn(l);if(o.element=c,c instanceof DocumentFragment&&c.childNodes.length)for(let f of c.childNodes)ee(f,u),et(f,o);else ee(c,u),c instanceof Node&&et(c,o);return c}};return o}function Ae(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{Y(t);});}function dn(e){return e instanceof Node?e:$(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var rt={className:"class",htmlFor:"for"},ot=new Set(["value","defaultValue","checked","selected","indeterminate"]),hn=new Set(["srcdoc"]),gn=new Set(["href","src","action","formaction","xlink:href"]),yn=new Set(["securitypolicyviolation"]),En=new Set(["contenteditable","draggable","spellcheck"]);function U(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var ft=Symbol("Fragment");function D(e,t,n){if(e===ft){let o=document.createDocumentFragment();return Se(o,it(n)),o}if(typeof e=="function")return mn(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),se(r,t),Se(r,it(n)),r}function ge(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function Sn(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function bn(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return hn.has(n)?true:gn.has(n)&&t!==null&&t!==void 0&&Sn(String(t))}function pt(e){return typeof e!="string"?e:rt[e]?rt[e]:e}function xn(e,t){let n=pt(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return En.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function st(e,t,n){let r=xn(t,n);if(r===null){e.removeAttribute(t);return}if(bn(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function se(e,t){let n=B();for(let[r,o]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(r!=="id"){if(r=pt(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,()=>{ge(e,o.get());});});M(e,i);}else if(typeof o=="function"){let i=_(()=>{L(n,()=>{ge(e,o());});});M(e,i);}else ge(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(yn.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();ot.has(i)?e[i]=a??"":st(e,i,a);});});M(e,s);continue}ot.has(r)||typeof r=="symbol"?e[r]=o??"":st(e,r,o);}}function it(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Se(e,t){for(let n of t)mt(e,n);}function mt(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"){at(e,t);return}if($(t)){Ae(e,t);return}if(U(t)){at(e,()=>t.get());return}if(Array.isArray(t)){Se(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function F(e){let t=null,n=e;return $(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function ie(e,t=true){for(let n of e)t&&oe(n),n.remove();}function at(e,t){let n=B(),r=document.createComment("");e.appendChild(r);let o=[],i=_(()=>{L(n,()=>{let s=t(),{nodes:a,instance:u}=F(s);ie(o),a.length&&r.after(...a),u&&queueMicrotask(()=>Y(u)),o=a;});});M(e,i);}var gt=class{constructor(e){this.props=e;}};function yt(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(oe(e),e.innerHTML=""),$(t)?Ae(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Nn={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 Rn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(Le(e.errors[r],n));}function bt(e,t,n,r){if(n!==false){let o=Le(e.error,t);return {success:false,error:o,errors:[o]}}Rn(e,r,t);}function ae(e){return e?.abortEarly!==void 0?e:Nn}function we(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,ve=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Te=e=>e===true||e===false,kn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),An=e=>typeof e=="function",wn=e=>Array.isArray(e),Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function xt(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,u)=>{let l=s(a,u);if(!l.success)return l;let c=o(l.data,{context:u?.context});if(!Me(c)){let f={message:`derive() callback must return a plain object of overrides, got ${c===null?"null":typeof c}`};return {success:false,error:f,errors:[f]}}if(i==="missing"){let f={...l.data};for(let m in c)f[m]===void 0&&(f[m]=c[m]);return {success:true,data:f}}return {success:true,data:{...l.data,...c}}}),this},g(n,"_parse",(o,i,s)=>{let a=o(i,s),{abortEarly:u}=ae(s);if(a.success===false)return a;let l={},c=[];for(let f in e){let m=e[f]._parse(a.data[f],s);if(m.success)l[f]=m.data;else {let d=bt(m,f,u,c);if(d)return d}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:l}}),r}function Oe(e){return b(W,{...e,type:"string"})}function Ie(e){return b(ve,{...e,type:"number"})}function Pe(e){return b(Te,{...e,type:"boolean"})}function Be(e){return b(kn,{...e,type:"date"})}function Ct(e){return b(An,{...e,type:"function"})}function _t(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 Nt(e,t){let n=b(wn,{...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}=ae(i);if(s.success===false)return s;let u=[],l=[],c=i;for(let f=0;f<s.data.length;f++){let m={...c,context:{...c?.context,index:f}},d=e._parse(s.data[f],m);if(d.success)u.push(d.data);else {let y=bt(d,f,a,l);if(y)return y}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:u}}),n}function Rt(){return b(()=>true)}function H(e,t){return g(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function kt(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,u=[];for(let m=0;m<e.length;m++){let d=e[m]._parse(i,a);if(d.success)return d;u.push(d);}let{abortEarly:l}=ae(a),c={message:typeof n=="function"?n(i):n};if(l!==false)return {success:false,error:c,errors:[c]};let f=[];for(let m=0;m<u.length;m++){let d=u[m].errors;if(d?.length)for(let y=0;y<d.length;y++)d[y].cause?.key&&f.push(Le(d[y],`branch ${m}`));}return f.length===0&&f.push(c),{success:false,error:f[0],errors:f}}),r}function At(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 vt(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 Tt={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)||ve(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()),ve(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}},Mt={},p={object:xt,string:Oe,number:Ie,boolean:Pe,date:Be,function:Ct,enum:_t,array:Nt,any:Rt,preprocess:H,union:kt,literal:At,contextRef:wt,withContext:vt,coerce:Mt,cast:Tt};function Et(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||Et(t);let o={name:n,message:r,type:t},i={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(s,a){let u=e(s);if(u===true)return {success:true,data:s};if(typeof u=="object"&&u?.success===true)return u;let l={message:typeof r=="function"?r(s):r};return {success:false,error:l,errors:[l]}},parse(s,a){let u=this._parse(s,a);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(s,a){return this._parse(s,a)},transform(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success&&(c.data=s(c.data)),c}),this},optional(){return we(this,s=>s===void 0),this},nullable(){return we(this,s=>s===null),this},nullish(){return we(this,s=>s==null),this},default(s){return g(this,"_parse",(a,u,l)=>(u===void 0&&(u=typeof s=="function"?s({context:l?.context}):s),a(u,l))),this},catch(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?c:{success:true,data:typeof s=="function"?s({input:u,error:c.error}):s}}),this},pipe(s){return g(this,"_parse",(a,u,l)=>{let c=a(u,l);return c.success?s._parse(c.data,l):c}),this},refine(s,{message:a,type:u,jsonSchema:l}={}){if(u&&(a=a||Et(u),t=u),l){let c=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>c;}return g(this,"_parse",(c,f,m)=>{let d=c(f,m),{abortEarly:y}=ae(m);if(!d.success)return d;let N=s(d.data);if(N===true||typeof N=="object"&&N?.success===true)return d;let C={message:typeof a=="function"?a(f):a};return {success:false,error:C,errors:[C]}}),this},clone(){return {...this}}};return St.length>0?St.reduce((s,a)=>a(s,e,o)??s,i):i}var St=[];var $e=De(),je=De(),Lt=De(),vn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function De(){return Math.floor(Math.random()*16777215)}function Tn(){return je=(je+1)%16777215,je}function ue(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Tn(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,$e>>16&255,$e>>8&255,$e&255,Lt>>8&255,Lt&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=vn[n.charCodeAt(o)];return r}var Mn=Symbol("block-element"),Ln=Symbol("block-element-body"),Fe=Symbol("selectable-element");function Ot(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 On(e){return e?Ot(e.startContainer,Mn):null}function In(e){return e?Ot(e.startContainer,Fe):null}function It(){return window.getSelection()}function He(){let e=It();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Pt(){let e=He();if(!e)return 0;e.collapse(true);let t=In(e),n=On(e),r=t??Bn(n);return Bt(r,e.startContainer,e.startOffset)}function Bt(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,a=e.childNodes,u=Math.min(n,a.length);for(let l=0;l<u;l++)s+=a[l].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let r=0,o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=o.nextNode();for(;i;){if(i===t)return r+n;r+=i.textContent.length,i=o.nextNode();}return r}function Pn(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 $t(e,t){let n=Pn(e,t),r=It();r.removeAllRanges(),r.addRange(n);}function Bn(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[Ln])return t;return null}var jt={INPUT:"mrakomor:input"};var Dt=Ne();var le=class extends gt{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=Re(Dt),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(jt.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var Ft="molecule.paragraph.Paragraph";function v(e){return e===`
3
+ `||e===`\r
4
+ `?"":e??""}function Vt({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{};return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{...o,text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]},...r?{settings:r}:{}}}function jn(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 Ht(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function Dn(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let i=e;for(let s of t){let a=r.find(u=>u.match(s));a&&(i=D(a,{},i));}for(let s of n){let a=o.find(u=>u.match(s));a&&(i=D(a,s,i));}return i}function Gt(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=v(e.properties.text),i=e.properties.inlineStyleRanges??[],s=e.properties.entityRanges??[];if(!o)return r;let a=jn([...i,...s],o.length);for(let u=0;u<a.length-1;u+=1){let l=a[u],c=a[u+1];if(l>=c)continue;let f=o.slice(l,c),m=Dn(f,Ht(i,l,c),Ht(s,l,c),{inlineStyleComponents:t,entityRangeComponents:n});yt(r,m);}return r}function ce(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(l=>l.match(s));if(a){let l=s.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:i,length:l}),i=ce(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}let u=o.find(l=>l.match(s));if(u){let l=s.textContent.length;t.properties.entityRanges.push({...u.getStateSchema(s).parse(),offset:i,length:l}),i=ce(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});continue}i=ce(s.childNodes,t,i,{inlineStyleComponents:r,entityRangeComponents:o});}return i}function Ut(e,t){let n=v(e.properties.text),r=v(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 Kt(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function qt(e,t){return (e??[]).filter(n=>n.offset+n.length>t).map(n=>({...n,offset:Math.max(0,n.offset-t),length:n.offset+n.length-Math.max(n.offset,t)}))}function Fn(e,t){let n=structuredClone(e),r=structuredClone(e);return n.properties.text=e.properties.text.slice(0,t),r.properties.text=e.properties.text.slice(t),n.properties.inlineStyleRanges=Kt(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=qt(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Kt(e.properties.entityRanges,t),r.properties.entityRanges=qt(e.properties.entityRanges,t),r.componentId=ue(),{originalLineState:n,newLineState:r}}function Yt(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Fn(e.getState(),Pt(e.element));return e.mrakomor.command.insertBlockElement({range:He(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}function Wt(e,t){let n=e.constructor;if(!t)return n.getStateSchema(t).parse();let r=structuredClone(n.getStateSchema(t).parse());return ce(t.childNodes,r,0,{inlineStyleComponents:e.getInlineStyleComponents(),entityRangeComponents:e.getEntityRangeComponents()}),r.properties.text=v(r.properties.text),r}function Xt(e){return e?{element:e,read(t){return {inlineStyleRanges:t.properties?.inlineStyleRanges,entityRanges:t.properties?.entityRanges}},write(t,{inlineStyleRanges:n,entityRanges:r}){n!==void 0&&(t.properties.inlineStyleRanges=n),r!==void 0&&(t.properties.entityRanges=r);}}:null}var fe=class extends le{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:v(this.getState()?.properties?.text).length;$t(this.element,r);};n(),ke(n);}onKeydown(t){}getFormattingTarget(t){return null}static toExchangeState(t){return Vt({originComponent:this.NAMESPACE,properties:{...t?.properties,text:v(t?.properties?.text)},settings:t?.settings})}static fromExchangeState(t){return {properties:t?.properties,settings:t?.settings}}static appendExchangeState(t,n){return Ut(t,n)}};function zt(){return p.object({length:p.number(),offset:p.number(),style:p.string()})}function Jt({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 Qt(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")||ue()),properties:p.object(n).default({}),settings:r}).default({})}var K=class e extends fe{static get NAMESPACE(){return Ft}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 Qt(t,{component:e.NAMESPACE,properties:{entityRanges:p.array(Jt()).default([]),inlineStyleRanges:p.array(zt()).default([]),text:p.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return Wt(this,t)}_buildContent(t){return Gt(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 v(r)?w(()=>this._buildContent(n)):"<br>"}})}getFormattingTarget(t){return Xt(this.element)}onKeydown(t){Yt(this,t);}};function Hn(){return {resolveConfig:e=>(e.blockComponents.push(K),e),resolveComponent:e=>{if(e===K.NAMESPACE)return K}}}exports.Paragraph=K;exports.paragraphPlugin=Hn;
@@ -1 +1 @@
1
- export{a as Paragraph,b as paragraphPlugin}from'./chunk-PMR6XOZ6.mjs';import'./chunk-P6HMUYFA.mjs';import'./chunk-WX7ESURF.mjs';import'./chunk-7UI6TZPX.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-JFLCNBDM.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-XQCH2FNS.mjs';import'./chunk-ZDZQ2RVJ.mjs';
1
+ export{a as Paragraph,b as paragraphPlugin}from'./chunk-U3MSKB3R.mjs';import'./chunk-G2QV4GOO.mjs';import'./chunk-GDID5DFL.mjs';import'./chunk-T7OO472O.mjs';import'./chunk-P7IKAZYZ.mjs';import'./chunk-TX4RCFPO.mjs';import'./chunk-B6JJAATK.mjs';import'./chunk-YHWQV2DB.mjs';import'./chunk-K2DMHAUD.mjs';
@@ -0,0 +1,3 @@
1
+ 'use strict';var Ie=class{next(...e){}error(...e){}complete(...e){}},ne=class{#e=new Set;pipe(...e){return e.reduce((t,n)=>n(t),this)}next(...e){Array.from(this.#e).forEach(t=>{typeof t=="function"?t(...e):t.next(...e);});}error(...e){Array.from(this.#e).forEach(t=>{t?.error?.(...e),this.unsubscribe(t);});}complete(...e){Array.from(this.#e).forEach(t=>{t?.complete?.(...e),this.unsubscribe(t);});}subscribe(e){return this.#e.add(e),{unsubscribe:()=>{this.unsubscribe(e);}}}unsubscribe(e){this.#e.delete(e);}};var U=Symbol("@esmj/signals:type"),H=Symbol("@esmj/signals:name");var R=null,re=false,Pe=[];function M(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 ne{#e=new Set;#r=null;constructor(e){super(),this.#r=e,this.pipe(t=>{let n=t.subscribe.bind(t),r=t.unsubscribe.bind(t);return t.subscribe=o=>{n(o),this.#e.add(o);},t.unsubscribe=o=>{r(o),this.#e.delete(o);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>M(()=>{this.#e.add(e),this.#r();}),e.next[T]=void 0),e instanceof qe&&e.next[T]===void 0){let t=e.next.bind(e);e.next=()=>M(()=>{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=()=>M(()=>(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)}},V=null;function De(e){V=new zt(e);}De(()=>{Vt();});function je(){return V.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;#u=0;#l=new Map;#n=w;constructor(t,n){super(),this.#s=t,this.#i=n,this.debug=n?.debug,this[U]="computed",this[H]=n?.debug??null,this.get=this.get.bind(this);}#c(){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.#u}getDebugInfo(){return {name:this[H],dirty:this.#e,revision:this.#u,sourceDependencies:[...this.#l.keys()]}}#f(){for(let[t,n]of this.#l)if(t instanceof Ke&&M(()=>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.#u),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.#c(),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.#u++,n}destroy(){this.#c(),this.#l.clear(),this.#e=true,this.#n=w;}};function $(e,t={}){let n=t?.equals??Object.is,r=0,o=new ne;function i(){return R&&(R.dependencies.set(o,o.subscribe(R.observer)),R.sourceRevisions.set(c,r)),e}function s(){return e}function l(f){if(!n(e,f)){e=f,r++,o.next();}return e}function u(){return r}let c={get:i,set:l,peek:s,getRevision:u,[$e]:o,[U]:"signal",[H]:t?.debug??null};return c}var ge=Ee(),ye=Ee(),tt=Ee(),dn=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function Ee(){return Math.floor(Math.random()*16777215)}function hn(){return ye=(ye+1)%16777215,ye}function Q(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=hn(),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+=dn[n.charCodeAt(o)];return r}var mn=Symbol("block-element");var gn=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,mn):null}function ot(e){return e?nt(e.startContainer,gn):null}function yn(){return window.getSelection()}function j(){let e=yn();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,u=Math.min(n,l.length);for(let c=0;c<u;c++)s+=l[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}var st="molecule.paragraph.Paragraph";var it="molecule.headline.";function I(e){return e===`
2
+ `||e===`\r
3
+ `?"":e??""}function P(e){let t=e?.component??"";return t===st||t.startsWith(it)}function at(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 ut(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 be(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=ut(e.properties.inlineStyleRanges,t),n.properties.entityRanges=lt(e.properties.entityRanges,t),r.properties.entityRanges=ut(e.properties.entityRanges,t),r.componentId=Q(),{originalLineState:n,newLineState:r}}var xe={INPUT:"mrakomor:input"};var ct=class{#e=new Set;pipe(...e){return En(...e)(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);}};function En(...e){return t=>Array.from(e).reduce((n,r)=>r(n),t)}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 Z=class extends ct{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 bn(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]}}bn(e,r,t);}function ee(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 G=e=>typeof e=="string"||e instanceof String,Ne=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),Re=e=>e===true||e===false,xn=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,u)=>{let c=s(l,u);if(!c.success)return c;let f=o(c.data,{context:u?.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={...c.data};for(let h in f)p[h]===void 0&&(p[h]=f[h]);return {success:true,data:p}}return {success:true,data:{...c.data,...f}}}),this},C(n,"_parse",(o,i,s)=>{let l=o(i,s),{abortEarly:u}=ee(s);if(l.success===false)return l;let c={},f=[];for(let p in e){let h=e[p]._parse(l.data[p],s);if(h.success)c[p]=h.data;else {let m=ht(h,p,u,f);if(m)return m}}return f.length>0?{success:false,error:f[0],errors:f}:{success:true,data:c}}),r}function Ae(e){return _(G,{...e,type:"string"})}function Te(e){return _(Ne,{...e,type:"number"})}function we(e){return _(Re,{...e,type:"boolean"})}function Le(e){return _(xn,{...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}=ee(i);if(s.success===false)return s;let u=[],c=[],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)u.push(m.data);else {let S=ht(m,p,l,c);if(S)return S}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),n}function St(){return _(()=>true)}function F(e,t){return C(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function bt(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,u=[];for(let h=0;h<e.length;h++){let m=e[h]._parse(i,l);if(m.success)return m;u.push(m);}let{abortEarly:c}=ee(l),f={message:typeof n=="function"?n(i):n};if(c!==false)return {success:false,error:f,errors:[f]};let p=[];for(let h=0;h<u.length;h++){let m=u[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 xt(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 G(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(G(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 G(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(G(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:bt,literal:xt,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 u=e(s);if(u===true)return {success:true,data:s};if(typeof u=="object"&&u?.success===true)return u;let c={message:typeof r=="function"?r(s):r};return {success:false,error:c,errors:[c]}},parse(s,l){let u=this._parse(s,l);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(s,l){return this._parse(s,l)},transform(s){return C(this,"_parse",(l,u,c)=>{let f=l(u,c);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,u,c)=>(u===void 0&&(u=typeof s=="function"?s({context:c?.context}):s),l(u,c))),this},catch(s){return C(this,"_parse",(l,u,c)=>{let f=l(u,c);return f.success?f:{success:true,data:typeof s=="function"?s({input:u,error:f.error}):s}}),this},pipe(s){return C(this,"_parse",(l,u,c)=>{let f=l(u,c);return f.success?s._parse(f.data,c):f}),this},refine(s,{message:l,type:u,jsonSchema:c}={}){if(u&&(l=l||pt(u),t=u),c){let f=[...this._getJsonSchemaHints?.()??[],c];this._getJsonSchemaHints=()=>f;}return C(this,"_parse",(f,p,h)=>{let m=f(p,h),{abortEarly:S}=ee(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 te=class extends Z{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 Mt(e,t,n,r){let{originalLineState:o}=be(e,t),i=r&&P(r)?r:e,{newLineState:s}=be(i,n);return {beforeState:o,afterState:s}}function Ot(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:Q(),component:r,...e.settings?{settings:e.settings}:{}},u={properties:{text:o,inlineStyleRanges:i,entityRanges:s},...e.settings?{settings:e.settings}:{}};return n.getStateSchema().parse({...n.fromExchangeState(u),...l})}function Bt(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=Ot(n,r),{beforeState:u,afterState:c}=Mt(s,o,i,l),{state:f}=at(u,c),p=I(u.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 u=Ot(n,r),{beforeState:c,afterState:f}=Mt(s,o,i,u),p=I(c.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:c,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 te(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 u(a){if(!t||!a)return;let d=Pt(e,t);ve(a)?Bt(d,a):It(d,a),l();}function c(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:u};d?e.command.updateMenu?.(g):e.command.openMenu?.(g);}function f(a,d,g,x,y){t={blockElement:a,slashStart:d,slashEnd:g,query:x,baselineState:At(e,a)},c(y);}function p(){let a=j();if(!a?.collapsed)return null;let d=rt(a),g=ot(a);if(!d||!g)return null;let x=g.textContent??"",y=Se(g,a.startContainer,a.startOffset);return {blockElement:d,selectable:g,text:x,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 b=p();if(!b||b.blockElement!==t.blockElement){l();return}S(b);return}let x=g===""&&d!=null?{inputType:"insertText",data:d}:a,y=Lt(t,x);if(!y){l();return}t=y,c();}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:u});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:u});return}if(a.key==="Enter"){a.preventDefault(),a.stopPropagation?.();let d=r[o];d&&u(d);return}a.key==="Escape"&&(a.preventDefault(),l());}},registerHandlers(){e.emitter.on(xe.INPUT,N),e.emitter.on(xe.CLOSE_MENU,()=>{i=false,t=null,n=null,r=[],o=0;});}}}exports.slashCommandPlugin=Ln;
@@ -1 +1 @@
1
- import {a as a$2,b}from'./chunk-WQWE5UCN.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {k,p,j as j$1,r,b as b$1}from'./chunk-JFLCNBDM.mjs';import {a as a$1}from'./chunk-B6JJAATK.mjs';import {i,e,g,n,t,a as a$3}from'./chunk-XQCH2FNS.mjs';import'./chunk-ZDZQ2RVJ.mjs';function Z(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function ee({id:e,label:t,fallback:n=0}){return e??Z(t,n)}var _=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=ee({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 B=class extends a$2{normalize(t,n){if(!t||typeof t.handler!="function")return null;try{return _.parse(t,{context:{index:n}})}catch{return null}}};function H(e,t){let n=e._getBlockElementIndex(t);if(n===-1)return null;let l=e.getContent()[n];return l?structuredClone(l):null}function te(e,t$1){if(!t$1)return null;for(let n of e._getBlockElements())if(t(n)?.state?.peek()?.componentId===t$1)return n;return null}function ne(e,t){let n=te(e,t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function z(e){return e==null||e===""||/\s/.test(e)}function U(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 c=n[o];if(c==="/"){let a=o===0?null:n[o-1];if(a===null||/\s/.test(a)){l=o;break}return null}if(!/[\w]/.test(c))return null}return l<0?null:{slashStart:l,slashEnd:t,query:n.slice(l+1)}}function $(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 I(e){return typeof e?.handler=="function"}function j(e,t){let n=String(t??"").trim().toLowerCase();return n?e.filter(l=>String(l.label??"").toLowerCase().includes(n)?true:(l.keywords??[]).some(c=>String(c).toLowerCase().includes(n))):e.slice()}function K(e,t,n,l){let{originalLineState:o}=r(e,t),c=l&&k(l)?l:e,{newLineState:a}=r(c,n);return {beforeState:o,afterState:a}}function V(e){let t$1=t(e)?.getState?.();return t$1&&k(t$1)?t$1:null}function re(e,t=null){let n=e?.component,l=n?.NAMESPACE;if(!n||!l)return null;let o=j$1(t?.properties?.text??""),c=t?.properties?.inlineStyleRanges??[],a=t?.properties?.entityRanges??[],u={componentId:a$3(),component:l,...e.settings?{settings:e.settings}:{}};return l===b$1?n.getStateSchema().parse({...u,properties:{items:[{text:o,inlineStyleRanges:c,entityRanges:a}]}}):n.getStateSchema().parse({...u,properties:{text:o,inlineStyleRanges:c,entityRanges:a}})}function Y(e,t){if(!I(t))return;let{mrakomor:n,blockElement:l,slashStart:o,slashEnd:c,baselineState:a}=e;if(!a||!k(a)){t.handler(e);return}let u=V(l),{beforeState:f,afterState:d}=K(a,o,c,u),{state:m}=p(f,d),S=j$1(f.properties?.text).length;n.command.replaceBlockElement({blockElement:l,blocks:[n.normalizeComponentState(m)],cursor:S}),t.handler(e);}function v(e,t){let{mrakomor:n,blockElement:l,slashStart:o,slashEnd:c,baselineState:a}=e,u=t?.component?.NAMESPACE;if(!u||!a||!k(a))return;let f=V(l),{beforeState:d,afterState:m}=K(a,o,c,f),S=j$1(d.properties?.text),C=j$1(m.properties?.text),A=!S&&!C,E=re(t,A?null:m);if(E){if(A){n.command.replaceBlockElement({blockElement:l,blocks:[E],cursor:0});return}n.command.insertBlockElement({blockElement:l,namespace:u,originalLineState:d,newLineState:E,cursor:0});}}function G(e,t){return {mrakomor:e,blockElement:ne(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:i()}}function le(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function J(e){return b().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[le(e)],shortcuts:[]})}var oe={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function Q(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(J(n));}function se({mrakomor:e$1}){e$1.register.slashActions=new B(e$1);let t$1=null,n$1=null,l=[],o=0,c=false;function a(r){return j([...e$1.register.blocks.list(),...e$1.register.slashActions.list()],r)}function u(){c=false,t$1=null,n$1=null,l=[],o=0,e$1.command.closeMenu?.();}function f(r){if(!t$1||!r)return;let s=G(e$1,t$1);I(r)?Y(s,r):v(s,r),u();}function d(r){if(!t$1)return;r&&(n$1=r),l=a(t$1.query),o=0;let s=c;c=true;let i={entries:l,anchorRect:n$1??void 0,highlightIndex:o,ariaLabel:"Slash commands",onSelect:f};s?e$1.command.updateMenu?.(i):e$1.command.openMenu?.(i);}function m(r,s,i,y,g){t$1={blockElement:r,slashStart:s,slashEnd:i,query:y,baselineState:H(e$1,r)},d(g);}function S(){let r=i();if(!r?.collapsed)return null;let s=e(r),i$1=g(r);if(!s||!i$1)return null;let y=i$1.textContent??"",g$1=n(i$1,r.startContainer,r.startOffset);return {blockElement:s,selectable:i$1,text:y,cursor:g$1}}function C(r){let i$1=i()?.getBoundingClientRect?.();return (!i$1||i$1.width===0&&i$1.height===0)&&(i$1=r.getBoundingClientRect()),i$1}function A(r){let i=t(r)?.state?.peek();return !!(i&&k(i))}function E(r){let s=U(r.text,r.cursor);if(!s){c&&u();return}m(r.blockElement,s.slashStart,s.slashEnd,s.query,C(r.selectable));}function W(){let r=S();if(!r||!A(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 z(i)?(m(r.blockElement,s,s+1,"",C(r.selectable)),true):false}function X(r){let s=r.data??null,i=r.inputType??"";if(!t$1){if(s!=="/")return;W();return}if(i==="insertCompositionText"||i==="insertFromPaste"||i==="insertFromDrop"){let T=S();if(!T||T.blockElement!==t$1.blockElement){u();return}E(T);return}let y=i===""&&s!=null?{inputType:"insertText",data:s}:r,g=$(t$1,y);if(!g){u();return}t$1=g,d();}return {resolveConfig(r){return e$1.register.slashActions.add(r.slashActions??[]),Q(e$1),r},registerCommands(){e$1.register.help.add(oe),Q(e$1);},onKeyDown(r){if(c){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:f});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:f});return}if(r.key==="Enter"){r.preventDefault(),r.stopPropagation?.();let s=l[o];s&&f(s);return}r.key==="Escape"&&(r.preventDefault(),u());}},registerHandlers(){e$1.emitter.on(a$1.INPUT,X),e$1.emitter.on(a$1.CLOSE_MENU,()=>{c=false,t$1=null,n$1=null,l=[],o=0;});}}}export{se as slashCommandPlugin};
1
+ import {a as a$2,b}from'./chunk-WQWE5UCN.mjs';import {a}from'./chunk-P7IKAZYZ.mjs';import {l,q,j as j$1,s}from'./chunk-TX4RCFPO.mjs';import {a as a$1}from'./chunk-B6JJAATK.mjs';import {i,e,g,n,a as a$3}from'./chunk-YHWQV2DB.mjs';import'./chunk-K2DMHAUD.mjs';function W(e,t){return String(e??t).trim().toLowerCase().replace(/\s+/g,"-")||String(t)}function X({id:e,label:t,fallback:n=0}){return e??W(t,n)}var _=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=X({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 _.parse(t,{context:{index:n}})}catch{return null}}};function O(e,t){let n=e._getBlockElementState(t);return n?structuredClone(n):null}function Z(e,t){let n=e._getBlockElementByComponentId(t.baselineState?.componentId);return n||(e._getBlockElementIndex(t.blockElement)!==-1&&t.blockElement?.isConnected,t.blockElement)}function N(e){return e==null||e===""||/\s/.test(e)}function H(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 z(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 U(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 $(e,t,n,l$1){let{originalLineState:o}=s(e,t),a=l$1&&l(l$1)?l$1:e,{newLineState:c}=s(a,n);return {beforeState:o,afterState:c}}function j(e,t){let n=e._getBlockElementState(t);return n&&l(n)?n:null}function ee(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={properties:{text:o,inlineStyleRanges:a,entityRanges:c},...e.settings?{settings:e.settings}:{}};return n.getStateSchema().parse({...n.fromExchangeState(p),...u})}function K(e,t){if(!L(t))return;let{mrakomor:n,blockElement:l$1,slashStart:o,slashEnd:a,baselineState:c}=e;if(!c||!l(c)){t.handler(e);return}let u=j(n,l$1),{beforeState:p,afterState:d}=$(c,o,a,u),{state:h}=q(p,d),S=j$1(p.properties?.text).length;n.command.replaceBlockElement({blockElement:l$1,blocks:[n.normalizeComponentState(h)],cursor:S}),t.handler(e);}function V(e,t){let{mrakomor:n,blockElement:l$1,slashStart:o,slashEnd:a,baselineState:c}=e,u=t?.component?.NAMESPACE;if(!u||!c||!l(c))return;let p=j(n,l$1),{beforeState:d,afterState:h}=$(c,o,a,p),S=j$1(d.properties?.text),C=j$1(h.properties?.text),k=!S&&!C,y=ee(t,k?null:h);if(y){if(k){n.command.replaceBlockElement({blockElement:l$1,blocks:[y],cursor:0});return}n.command.insertBlockElement({blockElement:l$1,namespace:u,originalLineState:d,newLineState:y,cursor:0});}}function Y(e,t){return {mrakomor:e,blockElement:Z(e,t),query:t.query,slashStart:t.slashStart,slashEnd:t.slashEnd,baselineState:t.baselineState,range:i()}}function te(e){return `/${(e.keywords?.[0]??e.label??e.id).toLowerCase()}`}function v(e){return b().parse({id:e.id,group:e.group,description:e.description??e.label,commands:[te(e)],shortcuts:[]})}var ne={id:"slash.open",group:"blocks",description:"Open the slash command menu",commands:["/"],shortcuts:[]};function G(e){let t=e.register.slashActions;if(t)for(let n of t.list())e.register.help.add(v(n));}function re({mrakomor:e$1}){e$1.register.slashActions=new A(e$1);let t=null,n$1=null,l$1=[],o=0,a=false;function c(r){return U([...e$1.register.blocks.list(),...e$1.register.slashActions.list()],r)}function u(){a=false,t=null,n$1=null,l$1=[],o=0,e$1.command.closeMenu?.();}function p(r){if(!t||!r)return;let s=Y(e$1,t);L(r)?K(s,r):V(s,r),u();}function d(r){if(!t)return;r&&(n$1=r),l$1=c(t.query),o=0;let s=a;a=true;let i={entries:l$1,anchorRect:n$1??void 0,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p};s?e$1.command.updateMenu?.(i):e$1.command.openMenu?.(i);}function h(r,s,i,E,g){t={blockElement:r,slashStart:s,slashEnd:i,query:E,baselineState:O(e$1,r)},d(g);}function S(){let r=i();if(!r?.collapsed)return null;let s=e(r),i$1=g(r);if(!s||!i$1)return null;let E=i$1.textContent??"",g$1=n(i$1,r.startContainer,r.startOffset);return {blockElement:s,selectable:i$1,text:E,cursor:g$1}}function C(r){let i$1=i()?.getBoundingClientRect?.();return (!i$1||i$1.width===0&&i$1.height===0)&&(i$1=r.getBoundingClientRect()),i$1}function k(r){return l(e$1._getBlockElementState(r))}function y(r){let s=H(r.text,r.cursor);if(!s){a&&u();return}h(r.blockElement,s.slashStart,s.slashEnd,s.query,C(r.selectable));}function J(){let r=S();if(!r||!k(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 N(i)?(h(r.blockElement,s,s+1,"",C(r.selectable)),true):false}function Q(r){let s=r.data??null,i=r.inputType??"";if(!t){if(s!=="/")return;J();return}if(i==="insertCompositionText"||i==="insertFromPaste"||i==="insertFromDrop"){let B=S();if(!B||B.blockElement!==t.blockElement){u();return}y(B);return}let E=i===""&&s!=null?{inputType:"insertText",data:s}:r,g=z(t,E);if(!g){u();return}t=g,d();}return {resolveConfig(r){return e$1.register.slashActions.add(r.slashActions??[]),G(e$1),r},registerCommands(){e$1.register.help.add(ne),G(e$1);},onKeyDown(r){if(a){if(r.key==="ArrowDown"){if(r.preventDefault(),!l$1.length)return;o=(o+1)%l$1.length,e$1.command.updateMenu?.({entries:l$1,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p});return}if(r.key==="ArrowUp"){if(r.preventDefault(),!l$1.length)return;o=(o-1+l$1.length)%l$1.length,e$1.command.updateMenu?.({entries:l$1,highlightIndex:o,ariaLabel:"Slash commands",onSelect:p});return}if(r.key==="Enter"){r.preventDefault(),r.stopPropagation?.();let s=l$1[o];s&&p(s);return}r.key==="Escape"&&(r.preventDefault(),u());}},registerHandlers(){e$1.emitter.on(a$1.INPUT,Q),e$1.emitter.on(a$1.CLOSE_MENU,()=>{a=false,t=null,n$1=null,l$1=[],o=0;});}}}export{re as slashCommandPlugin};
@@ -0,0 +1,2 @@
1
+ 'use strict';(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/tooltip/Tooltip.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(o){return o.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.mrakomor-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
+ `,document.head.appendChild(n);}}})();var Pe=class{next(...e){}error(...e){}complete(...e){}},pe=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"),H=Symbol("@esmj/signals:name");var T=null,de=false,ge=[];function K(e){let t=T;T=null;let n=e();return T=t,n}function xt(){de=false;let e=$e();for(let n of e)n.get();let t=ge;ge=[];for(let n of t)n();}function je(){de||(de=true,queueMicrotask(xt));}function me(e){ge.push(e),je();}var De=Symbol("@esmj/signals:internal observable"),I=Symbol("@esmj/signals:original function"),Ct=class extends pe{#e=new Set;#o=null;constructor(e){super(),this.#o=e,this.pipe(t=>{let n=t.subscribe.bind(t),o=t.unsubscribe.bind(t);return t.subscribe=r=>{n(r),this.#e.add(r);},t.unsubscribe=r=>{o(r),this.#e.delete(r);},t});}watch(e){if(typeof e.next!="function"&&(e.next=()=>K(()=>{this.#e.add(e),this.#o();}),e.next[I]=void 0),e instanceof qe&&e.next[I]===void 0){let t=e.next.bind(e);e.next=()=>K(()=>{this.#e.add(e),t(),this.#o();}),e.next[I]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[I]){let n=t.get,o=n.bind(t);t.get=()=>K(()=>(this.#e.delete(t),o())),t.get[I]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[I]?e.next[I]:e.next,e.get=e.get[I]?e.get[I]:e.get,this.#e.delete(e),this.unsubscribe(e)}},z=null;function Fe(e){z=new Ct(e);}Fe(()=>{je();});function $e(){return z.getPending()}function Ke(e){return z.watch(e)}function Ge(e){return z.unwatch(e)}var B=Symbol("@esmj/signals:no error"),qe=class Ve extends Pe{#e=true;#o=false;#n=null;#r=this.#p();#u=null;#c=null;#s=0;#i=new Map;#t=B;constructor(t,n){super(),this.#u=t,this.#c=n,this.debug=n?.debug,this[X]="computed",this[H]=n?.debug??null,this.get=this.get.bind(this);}#a(){for(let{unsubscribe:t}of this.#r.dependencies.values())t();this.#r.dependencies.clear();}#p(){return {dependencies:new Map,sourceRevisions:new Map,observer:this}}getRevision(){return this.#s}getDebugInfo(){return {name:this[H],dirty:this.#e,revision:this.#s,sourceDependencies:[...this.#i.keys()]}}#f(){for(let[t,n]of this.#i)if(t instanceof Ve&&K(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#n[De].next();}get(){if(this.#o)throw new Error("Cycle detected in computed signal");if(this.#n||(this.#n=_(this.#l(),this.#c)),(this.#e||this.#t!==B)&&(this.#i.size===0||this.#f()?this.#l():this.#e=false),T&&T.sourceRevisions.set(this,this.#s),this.#t!==B)throw this.#t;return this.#n.get()}peek(){if(this.#n||(this.#n=_(this.#l(),this.#c)),(this.#e||this.#t!==B)&&(this.#i.size===0||this.#f()?this.#l():this.#e=false),this.#t!==B)throw this.#t;return this.#n.peek()}#l(){this.#o=true,this.#e=false,this.#t=B,this.#a(),this.#r.sourceRevisions.clear();let t=T;T=this.#r;let n;try{n=this.#u();}catch(o){this.#t=o;}return T=t,this.#i=this.#r.sourceRevisions,this.#r.sourceRevisions=new Map,this.#o=false,n instanceof Promise&&(n=n.then(o=>{this.#t=B,this.#n.set(o);}).catch(o=>{this.#t=o;})),this.#t===B&&this.#n&&this.#n.set(n),this.#s++,n}destroy(){this.#a(),this.#i.clear(),this.#e=true,this.#t=B;}};function O(e,t){return new qe(e,t)}function w(e,t){let n,{debug:o,...r}={},i=O(()=>{n?.(),n=e();},{equals:()=>false,...r});i.get(),Ke(i);let s=()=>{n?.(),i.destroy(),Ge(i);};return s[Symbol.dispose]=s,s[X]="effect",s[H]=o??null,s.__RX_COMPUTED__=i,s}function _(e,t={}){let n=t?.equals??Object.is,o=0,r=new pe;function i(){return T&&(T.dependencies.set(r,r.subscribe(T.observer)),T.sourceRevisions.set(a,o)),e}function s(){return e}function l(p){if(!n(e,p)){e=p,o++,r.next();}return e}function u(){return o}let a={get:i,set:l,peek:s,getRevision:u,[De]:r,[X]:"signal",[H]:t?.debug??null};return a}function J(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Ze=Symbol("node-component"),Q=Symbol("node-internal"),et=Symbol("keep-literal"),re=Symbol("raw-props");function be(e){let t=()=>e;return t[et]=true,t}function Ce(e){let t=null,n=()=>t,o=i=>(t=i??null,t),r={get:n,set:o,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(r,"current",{get(){return t},set(i){o(i);},enumerable:true,configurable:false}),new Proxy(r,{get(i,s,l){if(Reflect.has(i,s))return Reflect.get(i,s,l);if(!t)return;let u=t[s];return typeof u=="function"?u.bind(t):u},set(i,s,l,u){return Reflect.has(i,s)||!t?Reflect.set(i,s,l,u):(t[s]=l,true)},has(i,s){return Reflect.has(i,s)||!!t&&s in t}})}var tt=null;function G(){return tt}function Z(e){tt=e;}function ie(e){return e?.[Ze]||null}function He(e,t){e[Ze]=t;}function ee(e,t={disposers:[],id:J()}){return e?.[Q]?e[Q]:(e&&(e[Q]=t),t)}function Tt(e){return e[Q]}function P(e,t){let n=Tt(e);n||(n=ee(e)),n.disposers.push(t);}function te(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function D(e,t){let n=G();Z(e);try{return t()}finally{Z(n);}}var ne=new Map,oe=new Map,Ue=new Map;function nt(e,t){let n=typeof t=="function"?t:r=>!!t?.includes(r),o=Object.create(null);for(let r of Object.keys(e)){let i=e[r];r==="children"||n(r)?o[r]=i:i?.[et]?o[r]=i():i!=null&&typeof i.get=="function"?o[r]=i:typeof i=="function"?o[r]=O(i):o[r]=_(i);}return o}function Re(e){let t=G();if(!t){console.warn("onMount called outside of a component context");return}te(ne,t.id,e);}function le(e){me(()=>{setTimeout(e,0);});}function q(e){let t=e.componentId,n=ne.get(t);if(n){ne.delete(t);for(let o of n){let r=o();typeof r=="function"&&te(oe,t,r);}}}function _t(e){let t=oe.get(e);if(t){oe.delete(e);for(let n of t)n();}}function Lt(e){let t=Ue.get(e);if(t){Ue.delete(e);for(let n of t)n();}}function ce(e){if(!e)return;let t=ee(e);if(t?.disposers?.length){for(let o of t.disposers)try{o();}catch(r){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",r);}t.disposers=[];}let n=ie(e);if(n&&(_t(n.componentId),Lt(n.componentId)),e.childNodes){let o=e.firstChild;for(;o;){let r=o.nextSibling;ce(o),o=r;}}}function F(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function Ye(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function wt(e,t,n){let o=J(),r={componentId:o,$children:n,element:null,classInstance:null,$constructor(){let i=Ye(e)?void 0:e[re],s={...nt(t??{},i),children:n},l=G(),u={disposers:[],id:o,contexts:new Map(l?.contexts)};Z(u);let a;if(Ye(e)){r.ClassConstructor=e;let c=new e(s);r.classInstance=c,typeof c.onMount=="function"&&te(ne,o,()=>{c.onMount?.();}),typeof c.onUnmount=="function"&&te(oe,o,()=>{c.onUnmount?.();}),a=c.render();}else a=e(s);Z(l);let p=kt(a);if(r.element=p,p instanceof DocumentFragment&&p.childNodes.length)for(let c of p.childNodes)ee(c,u),He(c,r);else ee(p,u),p instanceof Node&&He(p,r);return p}};return r}function Ne(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{q(t);});}function kt(e){return e instanceof Node?e:F(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var We={className:"class",htmlFor:"for"},Xe=new Set(["value","defaultValue","checked","selected","indeterminate"]),At=new Set(["srcdoc"]),Ot=new Set(["href","src","action","formaction","xlink:href"]),vt=new Set(["securitypolicyviolation"]),Mt=new Set(["contenteditable","draggable","spellcheck"]);function Y(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var ot=Symbol("Fragment");function j(e,t,n){if(e===ot){let r=document.createDocumentFragment();return ye(r,Je(n)),r}if(typeof e=="function")return wt(e,t||{},n);typeof e!="string"&&(n=t,t=e,e="div"),t=t||{};let o=document.createElement(e);return t.id&&o.setAttribute("id",t.id),ue(o,t),ye(o,Je(n)),o}function he(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function It(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Bt(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return At.has(n)?true:Ot.has(n)&&t!==null&&t!==void 0&&It(String(t))}function rt(e){return typeof e!="string"?e:We[e]?We[e]:e}function Pt(e,t){let n=rt(e),o=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Mt.has(o)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function ze(e,t,n){let o=Pt(t,n);if(o===null){e.removeAttribute(t);return}if(Bt(t,o)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,o);}function ue(e,t){let n=G();for(let[o,r]of Reflect.ownKeys(t).map(i=>[i,t[i]]))if(o!=="id"){if(o=rt(o),o==="$ref"){typeof r=="function"?r(e):typeof r=="object"&&r!==null&&(r.current=e);continue}if(o==="$dangerouslySetInnerHTML"){if(Y(r)){let i=w(()=>{D(n,()=>{he(e,r.get());});});P(e,i);}else if(typeof r=="function"){let i=w(()=>{D(n,()=>{he(e,r());});});P(e,i);}else he(e,r);continue}if(o==="style"){if(Y(r)){let i=w(()=>{D(n,()=>{Object.assign(e.style,r.get());});});P(e,i);}else typeof r=="object"&&r!==null?Object.assign(e.style,r):e.setAttribute("style",r);continue}if(typeof o=="string"&&o.startsWith("on")&&typeof r=="function"){let i=o.slice(2).toLowerCase();if(vt.has(i)){console.warn(`[esmj-dom] Blocked unsafe event binding "${o}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(i,r);continue}if(Y(r)||typeof r=="function"){let i=o,s=w(()=>{D(n,()=>{let l=typeof r=="function"?r():r.get();Xe.has(i)?e[i]=l??"":ze(e,i,l);});});P(e,s);continue}Xe.has(o)||typeof o=="symbol"?e[o]=r??"":ze(e,o,r);}}function Je(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function ye(e,t){for(let n of t)it(e,n);}function it(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"){Qe(e,t);return}if(F(t)){Ne(e,t);return}if(Y(t)){Qe(e,()=>t.get());return}if(Array.isArray(t)){ye(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function V(e){let t=null,n=e;return F(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&&ce(n),n.remove();}function Qe(e,t){let n=G(),o=document.createComment("");e.appendChild(o);let r=[],i=w(()=>{D(n,()=>{let s=t(),{nodes:l,instance:u}=V(s);ae(r),l.length&&o.after(...l),u&&queueMicrotask(()=>q(u)),r=l;});});P(e,i);}function Te(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(ce(e),e.innerHTML=""),F(t)?Ne(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}function ct(e,t){let n=null;if(F(t)?(n=t.$constructor(),queueMicrotask(()=>q(t))):t instanceof Node?n=t:n=document.createTextNode(String(t)),n instanceof HTMLElement){let o=O(()=>!!e()),r=w(()=>{n.style.display=o.get()?"":"none";});P(n,r);}return n}function Ft(e,t,n,o){let r=e.getRoot()?.querySelector(t);if(!r)return {container:null,dispose:null};let i=document.createElement("div");i.className=n,r.append(i);let s=Te(i,o);return {container:i,dispose:s??null}}function ut(e,t,n){return Ft(e,".mrakomor-tools-container",t,n)}Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));var ft=Symbol("block-element"),$t=Symbol("block-element-body"),pt=Symbol("selectable-element");function we(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 ke(e){return e?we(e.startContainer,ft):null}function Kt(e){return e?we(e.startContainer,pt):null}function Ae(e){return we(e,pt)}function dt(){return window.getSelection()}function fe(){let e=dt();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}var _e=null;function Oe(){_e=ve();}function gt(){_e&&Me(_e);}function Gt(e,t){let n=Kt(t);return n||(Ie(e)??e?.childNodes?.[0]??null)}function W(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let s=0,l=e.childNodes,u=Math.min(n,l.length);for(let a=0;a<u;a++)s+=l[a].textContent.length;return s}if(t.nodeType===Node.ELEMENT_NODE&&!e.contains(t))return 0;let o=0,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=r.nextNode();for(;i;){if(i===t)return o+n;o+=i.textContent.length,i=r.nextNode();}return o}function ve(){let e=fe();if(!e)return null;let t=ke(e),n=Gt(t,e);return {start:W(n,e.startContainer,e.startOffset),end:W(n,e.endContainer,e.endOffset),element:t,selectableElement:n}}function Me(e){if(!e)return;let{start:t,end:n,element:o,selectableElement:r}=e,i=r?.isConnected&&r||Ie(o)||o?.childNodes?.[0];if(!i)return;let s=at(i,t),l=at(i,n),u=document.createRange();u.setStart(s.startContainer,s.startOffset),u.setEnd(l.endContainer,l.endOffset);let a=dt();a.removeAllRanges(),a.addRange(u);}function at(e,t){let n=document.createRange();if(!e)return n;if(t<=0)return n.setStart(e,0),n.collapse(true),n;let o=0,r=[e];for(;r.length>0;){let i=r.pop();if(i.nodeType===Node.TEXT_NODE){let s=i.textContent.length;if(o+s>=t)return n.setEnd(i,t-o),n.setStart(i,t-o),n;o+=s;}else if(i.childNodes&&i.childNodes.length>0)for(let s=i.childNodes.length-1;s>=0;s--)r.push(i.childNodes[s]);}return n.setEnd(e,e.childNodes.length),n.setStart(e,e.childNodes.length),n}function Ie(e){if(!e)return null;let t=qt(e);return t?.firstElementChild??t?.firstChild}function mt(e){if(!e?.[ft])return null;let t=Ie(e);return t?ie(t)?.classInstance:null}function qt(e){if(!e)return null;for(let t of e.children)if(t[$t])return t;return null}function ht(e,t,n,o=12){let r=e.getBoundingClientRect(),i=typeof t?.getBoundingClientRect=="function"?t.getBoundingClientRect():t??{left:0,top:0},s=n?.offsetHeight??40;return {x:i.left-r.left,y:i.top-r.top-s-o}}function yt(e,t){let n=W(e,t.startContainer,t.startOffset),o=W(e,t.endContainer,t.endOffset);return {offset:n,length:Math.max(0,o-n)}}var R={KEYDOWN:"mrakomor:keydown",CLICK:"mrakomor:click",SELECTION_CHANGE:"mrakomor:selection-change"};function Et({mrakomor:e,open:t,tooltipElement:n}){let o=_(0),r=_(0),i=_([]),s=null,l=null;function u(){t.set(false),s=null,l=null;}Re(()=>{let p=e.emitter.on(R.OPEN_TOOLTIP,({element:h,actions:g})=>{s=h,l=ve(),i.set(g??[]),t.set(true),le(()=>{let{x:E,y:b}=ht(e.getRoot(),h,n);o.set(E),r.set(b);});}),c=e.emitter.on(R.CLOSE_TOOLTIP,u),m=e.emitter.on(R.KEYDOWN,()=>{t.peek()===true&&u();}),d=e.emitter.on(R.CLICK,h=>{if(t.peek()!==true||!n.current||!s)return;let g=h.target;if(!(g instanceof Node)){u();return}n.current.contains(g)||s.contains(g)||g instanceof Element&&g.contains(n.current)||u();});return ()=>{p(),c(),m(),d();}});let a=O(()=>({left:`${o.get()}px`,top:`${r.get()}px`}));return ct(()=>t.get(),j("div",{className:"mrakomor-tooltip",contenteditable:false,style:a,$ref:n},()=>Vt(i.get(),e,l)))}function Vt(e,t,n){if(!e.length)return null;let o=null,r=[];for(let i of e){o!==null&&i.group!==o&&r.push(j("span",{className:"mrakomor-tooltip__separator"})),o=i.group;let s=i.label,l=typeof s=="string"?s:typeof s=="function"?j(s,{}):s;r.push(j("button",{type:"button",className:["mrakomor-tooltip__btn",i.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:i.title??"",onClick:u=>{u.preventDefault(),Me(n),i.onAction(t);}},l));}return j("span",{style:"display: contents"},r)}function Ht({mrakomor:e}){let n=false,o=null,r=_(false),i=Ce();function s(){let c=e.getConfig();return {inlineStyles:c.inlineStyles,entityRanges:c.entityRanges,blockTransforms:e.register.blocks.list()}}function l(c,m,d,h,g){let E=[],b=e.getConfig()?.inlineStyles??[],y=e.getConfig()?.entityRanges??[],x=g?.read?.(m)??{inlineStyleRanges:m?.properties?.inlineStyleRanges,entityRanges:m?.properties?.entityRanges},C=g?.element??d,f=x?.inlineStyleRanges??[],{offset:S,length:N}=yt(C,h),v=S+N;for(let k of c.inlineStyles){let M=typeof k=="string"?k:k.style,L=b.find(A=>A.style===M);if(!L)continue;let $=f.some(A=>A.style===M&&A.offset<v&&A.offset+A.length>S);E.push({label:L.LABEL??M,title:M.charAt(0)+M.slice(1).toLowerCase(),group:"inline",active:()=>$,onAction:A=>{Oe(),A.command.insertInlineStyleRange({style:L.style}),le(()=>{gt();});}});}for(let k of c.entityRanges){let M=typeof k=="string"?k:k.NAMESPACE,L=y.find($=>$.NAMESPACE===M);L&&E.push({label:L.LABEL??"\u{1F517}",title:L.NAMESPACE,group:"inline",active:()=>false,onAction:$=>{Oe(),$.command.insertEntityRange({namespace:L.NAMESPACE,blockElement:d});}});}return E}function u(c){return {label:c.LABEL??c.NAMESPACE,title:c.LABEL??c.NAMESPACE,group:"transform",active:()=>true,onAction:()=>{}}}function a(c,m,d,h){let g=[],E=new Set;for(let b of c.blockTransforms){let y=typeof b=="string"?b:b?.component?.NAMESPACE??b?.NAMESPACE;if(!y||E.has(y)||(E.add(y),y===d.NAMESPACE))continue;let x=e.resolveComponentConstructor(y);x&&g.push({label:x.LABEL??y,title:`Convert to ${x.LABEL??y}`,group:"transform",active:()=>false,onAction:C=>{C.command.transformBlockElement({blockElement:m,namespace:y,range:h});}});}return g}function p(){if(n)return;let c=window.getSelection(),m=e.getRoot();if(!c||c.rangeCount===0){e.command.closeTooltip();return}let d=fe();if(!m.contains(d.commonAncestorContainer)){e.command.closeTooltip();return}if(d.startContainer===i.current&&r.peek()===true)return;let h=ke(d);if(!h){e.command.closeTooltip();return}let g=mt(h),E=e._getBlockElementState(h);if(!g||!E){e.command.closeTooltip();return}let b=g.constructor;if(d.collapsed){e.command.closeTooltip();return}let y=Ae(d.startContainer),x=Ae(d.endContainer);if(!y||!x||y!==x){e.command.closeTooltip();return}let C=s(),f=g.getFormattingTarget?.(d)??null,S=[u(b),...a(C,h,b,d),...l(C,E,h,d,f)];if(S.length===0){e.command.closeTooltip();return}e.command.openTooltip({element:h,actions:S});}return {registerEvents(){R.OPEN_TOOLTIP="mrakomor:open-tooltip",R.CLOSE_TOOLTIP="mrakomor:close-tooltip";},registerCommands(c){c.command.openTooltip=(m,d)=>{c.emit(R.OPEN_TOOLTIP,{...m,options:d});},c.command.closeTooltip=m=>{c.emit(R.CLOSE_TOOLTIP,{options:m});};},registerListeners(){e.emitter.on(R.SELECTION_CHANGE,p),R.OPEN_DIALOG&&e.emitter.on(R.OPEN_DIALOG,()=>{n=true,r.peek()===true&&e.command.closeTooltip();}),R.CLOSE_DIALOG&&e.emitter.on(R.CLOSE_DIALOG,()=>{n=false;});},onMount(){let{dispose:c}=ut(e,"mrakomor-tooltip-plugin-container",j(Et,{mrakomor:be(e),tooltipElement:i,open:r}));o=c;},onUnmount(){o?.(),o=null;}}}exports.Tooltip=Et;exports.tooltipPlugin=Ht;
package/dist/tooltip.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {a as a$1}from'./chunk-4NSVB4MI.mjs';import {w}from'./chunk-JFLCNBDM.mjs';import {a}from'./chunk-B6JJAATK.mjs';import {o,v,q,e as e$1,t,h,k as k$1,l}from'./chunk-XQCH2FNS.mjs';import {c,k,m,b,s,n,e,d}from'./chunk-ZDZQ2RVJ.mjs';(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/tooltip/Tooltip.css",g=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(a){return a.getAttribute("data-mrakomor-css-path")===t});if(!g){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
- `,document.head.appendChild(i);}}})();function U({mrakomor:t,open:g,tooltipElement:i}){let a$1=c(0),d=c(0),u=c([]),p=null,E=null;function A(){g.set(false),p=null,E=null;}k(()=>{let v$1=t.emitter.on(a.OPEN_TOOLTIP,({element:o$1,actions:f})=>{p=o$1,E=o(),u.set(f??[]),g.set(true),m(()=>{let{x:c,y:s}=v(t.getRoot(),o$1,i);a$1.set(c),d.set(s);});}),e=t.emitter.on(a.CLOSE_TOOLTIP,A),r=t.emitter.on(a.KEYDOWN,()=>{g.peek()===true&&A();}),n=t.emitter.on(a.CLICK,o=>{g.peek()===true&&i.current&&!i.current.contains(o.target)&&p&&!p.contains(o.target)&&A();});return ()=>{v$1(),e(),r(),n();}});let _=b(()=>({left:`${a$1.get()}px`,top:`${d.get()}px`}));return s(()=>g.get(),n("div",{className:"mrakomor-tooltip",contenteditable:false,style:_,$ref:i},()=>X(u.get(),t,E)))}function X(t,g,i){if(!t.length)return null;let a=null,d=[];for(let u of t){a!==null&&u.group!==a&&d.push(n("span",{className:"mrakomor-tooltip__separator"})),a=u.group;let p=u.label,E=typeof p=="string"?p:typeof p=="function"?n(p,{}):p;d.push(n("button",{type:"button",className:["mrakomor-tooltip__btn",u.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:u.title??"",onClick:A=>{A.preventDefault(),q(i),u.onAction(g);}},E));}return n("span",{style:"display: contents"},d)}function J({mrakomor:t$1}){let i=false,a$2=null,d$1=c(false),u=e(null);function p(){let e=t$1.getConfig();return {inlineStyles:e.inlineStyles,entityRanges:e.entityRanges,blockTransforms:t$1.register.blocks.list()}}function E(e,r,n,o,f){let c=[],s=t$1.getConfig()?.inlineStyles??[],m$1=t$1.getConfig()?.entityRanges??[],T=f?.read?.(r)??{inlineStyleRanges:r?.properties?.inlineStyleRanges,entityRanges:r?.properties?.entityRanges},N=f?.element??n,P=T?.inlineStyleRanges??[],{offset:L,length:V}=w(N,o),W=L+V;for(let S of e.inlineStyles){let C=typeof S=="string"?S:S.style,y=s.find(b=>b.style===C);if(!y)continue;let O=P.some(b=>b.style===C&&b.offset<W&&b.offset+b.length>L);c.push({label:y.LABEL??C,title:C.charAt(0)+C.slice(1).toLowerCase(),group:"inline",active:()=>O,onAction:b=>{k$1(),b.command.insertInlineStyleRange({style:y.style}),m(()=>{l();});}});}for(let S of e.entityRanges){let C=typeof S=="string"?S:S.NAMESPACE,y=m$1.find(O=>O.NAMESPACE===C);y&&c.push({label:y.LABEL??"\u{1F517}",title:y.NAMESPACE,group:"inline",active:()=>false,onAction:O=>{k$1(),O.command.insertEntityRange({namespace:y.NAMESPACE,blockElement:n});}});}return c}function A(e){return {label:e.LABEL??e.NAMESPACE,title:e.LABEL??e.NAMESPACE,group:"transform",active:()=>true,onAction:()=>{}}}function _(e,r,n){let o=[],f=new Set;for(let c of e.blockTransforms){let s=typeof c=="string"?c:c?.component?.NAMESPACE??c?.NAMESPACE;if(!s||f.has(s)||(f.add(s),s===n.NAMESPACE))continue;let m=t$1.resolveComponentConstructor(s);m&&o.push({label:m.LABEL??s,title:`Convert to ${m.LABEL??s}`,group:"transform",active:()=>false,onAction:T=>{T.command.transformBlockElement({blockElement:r,namespace:s});}});}return o}function v(){if(i)return;let e=window.getSelection(),r=t$1.getRoot();if(!e||e.rangeCount===0){t$1.command.closeTooltip();return}let n=e.getRangeAt(0);if(!r.contains(n.commonAncestorContainer)){t$1.command.closeTooltip();return}if(n.startContainer===u.current&&d$1.peek()===true)return;let o=e$1(n);if(!o){t$1.command.closeTooltip();return}let f=t(o);if(!f){t$1.command.closeTooltip();return}let c=f.constructor;if(n.collapsed){t$1.command.closeTooltip();return}let s=h(n.startContainer),m=h(n.endContainer);if(!s||!m||s!==m){t$1.command.closeTooltip();return}let T=p(),N=f.getState(),P=f.getFormattingTarget?.(n)??null,L=[A(c),..._(T,o,c),...E(T,N,o,n,P)];if(L.length===0){t$1.command.closeTooltip();return}t$1.command.openTooltip({element:o,actions:L});}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$1.emitter.on(a.SELECTION_CHANGE,v),a.OPEN_DIALOG&&t$1.emitter.on(a.OPEN_DIALOG,()=>{i=true,d$1.peek()===true&&t$1.command.closeTooltip();}),a.CLOSE_DIALOG&&t$1.emitter.on(a.CLOSE_DIALOG,()=>{i=false;});},onMount(){let{dispose:e}=a$1(t$1,"mrakomor-tooltip-plugin-container",n(U,{mrakomor:d(t$1),tooltipElement:u,open:d$1}));a$2=e;},onUnmount(){a$2?.(),a$2=null;}}}export{U as Tooltip,J as tooltipPlugin};
1
+ import {a as a$1}from'./chunk-5VPYPKGA.mjs';import {x}from'./chunk-TX4RCFPO.mjs';import {a}from'./chunk-B6JJAATK.mjs';import {o,v,q,i,e as e$1,t as t$1,h,k,l as l$1}from'./chunk-YHWQV2DB.mjs';import {d,l,n,b,t,o as o$1,f,e}from'./chunk-K2DMHAUD.mjs';(function(){if(!(typeof document>"u")){var t="mrakomor/core/plugin/tooltip/Tooltip.css",d=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(a){return a.getAttribute("data-mrakomor-css-path")===t});if(!d){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
+ `,document.head.appendChild(i);}}})();function V({mrakomor:t$1,open:d$1,tooltipElement:i}){let a$1=d(0),m=d(0),u=d([]),p=null,S=null;function y(){d$1.set(false),p=null,S=null;}l(()=>{let v$1=t$1.emitter.on(a.OPEN_TOOLTIP,({element:s,actions:o$1})=>{p=s,S=o(),u.set(o$1??[]),d$1.set(true),n(()=>{let{x:f,y:g}=v(t$1.getRoot(),s,i);a$1.set(f),m.set(g);});}),e=t$1.emitter.on(a.CLOSE_TOOLTIP,y),r=t$1.emitter.on(a.KEYDOWN,()=>{d$1.peek()===true&&y();}),n$1=t$1.emitter.on(a.CLICK,s=>{if(d$1.peek()!==true||!i.current||!p)return;let o=s.target;if(!(o instanceof Node)){y();return}i.current.contains(o)||p.contains(o)||o instanceof Element&&o.contains(i.current)||y();});return ()=>{v$1(),e(),r(),n$1();}});let N=b(()=>({left:`${a$1.get()}px`,top:`${m.get()}px`}));return t(()=>d$1.get(),o$1("div",{className:"mrakomor-tooltip",contenteditable:false,style:N,$ref:i},()=>J(u.get(),t$1,S)))}function J(t,d,i){if(!t.length)return null;let a=null,m=[];for(let u of t){a!==null&&u.group!==a&&m.push(o$1("span",{className:"mrakomor-tooltip__separator"})),a=u.group;let p=u.label,S=typeof p=="string"?p:typeof p=="function"?o$1(p,{}):p;m.push(o$1("button",{type:"button",className:["mrakomor-tooltip__btn",u.active?.()?"mrakomor-tooltip__btn--active":""].filter(Boolean).join(" "),title:u.title??"",onClick:y=>{y.preventDefault(),q(i),u.onAction(d);}},S));}return o$1("span",{style:"display: contents"},m)}function Q({mrakomor:t}){let i$1=false,a$2=null,m=d(false),u=f(null);function p(){let e=t.getConfig();return {inlineStyles:e.inlineStyles,entityRanges:e.entityRanges,blockTransforms:t.register.blocks.list()}}function S(e,r,n$1,s,o){let f=[],g=t.getConfig()?.inlineStyles??[],c=t.getConfig()?.entityRanges??[],E=o?.read?.(r)??{inlineStyleRanges:r?.properties?.inlineStyleRanges,entityRanges:r?.properties?.entityRanges},L=o?.element??n$1,P=E?.inlineStyleRanges??[],{offset:O,length:W}=x(L,s),X=O+W;for(let C of e.inlineStyles){let h=typeof C=="string"?C:C.style,b=g.find(A=>A.style===h);if(!b)continue;let x=P.some(A=>A.style===h&&A.offset<X&&A.offset+A.length>O);f.push({label:b.LABEL??h,title:h.charAt(0)+h.slice(1).toLowerCase(),group:"inline",active:()=>x,onAction:A=>{k(),A.command.insertInlineStyleRange({style:b.style}),n(()=>{l$1();});}});}for(let C of e.entityRanges){let h=typeof C=="string"?C:C.NAMESPACE,b=c.find(x=>x.NAMESPACE===h);b&&f.push({label:b.LABEL??"\u{1F517}",title:b.NAMESPACE,group:"inline",active:()=>false,onAction:x=>{k(),x.command.insertEntityRange({namespace:b.NAMESPACE,blockElement:n$1});}});}return f}function y(e){return {label:e.LABEL??e.NAMESPACE,title:e.LABEL??e.NAMESPACE,group:"transform",active:()=>true,onAction:()=>{}}}function N(e,r,n,s){let o=[],f=new Set;for(let g of e.blockTransforms){let c=typeof g=="string"?g:g?.component?.NAMESPACE??g?.NAMESPACE;if(!c||f.has(c)||(f.add(c),c===n.NAMESPACE))continue;let E=t.resolveComponentConstructor(c);E&&o.push({label:E.LABEL??c,title:`Convert to ${E.LABEL??c}`,group:"transform",active:()=>false,onAction:L=>{L.command.transformBlockElement({blockElement:r,namespace:c,range:s});}});}return o}function v(){if(i$1)return;let e=window.getSelection(),r=t.getRoot();if(!e||e.rangeCount===0){t.command.closeTooltip();return}let n=i();if(!r.contains(n.commonAncestorContainer)){t.command.closeTooltip();return}if(n.startContainer===u.current&&m.peek()===true)return;let s=e$1(n);if(!s){t.command.closeTooltip();return}let o=t$1(s),f=t._getBlockElementState(s);if(!o||!f){t.command.closeTooltip();return}let g=o.constructor;if(n.collapsed){t.command.closeTooltip();return}let c=h(n.startContainer),E=h(n.endContainer);if(!c||!E||c!==E){t.command.closeTooltip();return}let L=p(),P=o.getFormattingTarget?.(n)??null,O=[y(g),...N(L,s,g,n),...S(L,f,s,n,P)];if(O.length===0){t.command.closeTooltip();return}t.command.openTooltip({element:s,actions:O});}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,v),a.OPEN_DIALOG&&t.emitter.on(a.OPEN_DIALOG,()=>{i$1=true,m.peek()===true&&t.command.closeTooltip();}),a.CLOSE_DIALOG&&t.emitter.on(a.CLOSE_DIALOG,()=>{i$1=false;});},onMount(){let{dispose:e$1}=a$1(t,"mrakomor-tooltip-plugin-container",o$1(V,{mrakomor:e(t),tooltipElement:u,open:m}));a$2=e$1;},onUnmount(){a$2?.(),a$2=null;}}}export{V as Tooltip,Q as tooltipPlugin};
package/dist/tts.cjs ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict';var Jn={abortEarly:true};function st(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 Qn(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(st(e.errors[r],n));}function Gt(e,t,n,r){if(n!==false){let o=st(e.error,t);return {success:false,error:o,errors:[o]}}Qn(e,r,t);}function xe(e){return e?.abortEarly!==void 0?e:Jn}function tt(e,t){b(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var ie=e=>typeof e=="string"||e instanceof String,nt=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),rt=e=>e===true||e===false,Zn=e=>e instanceof Date&&!Number.isNaN(e.getTime()),er=e=>typeof e=="function",tr=e=>Array.isArray(e),ot=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Yt(e,t){let n=R(ot,{...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 b(this,"_parse",(i,a,c)=>{let l=i(a,c);if(!l.success)return l;let u=o(l.data,{context:c?.context});if(!ot(u)){let p={message:`derive() callback must return a plain object of overrides, got ${u===null?"null":typeof u}`};return {success:false,error:p,errors:[p]}}if(s==="missing"){let p={...l.data};for(let m in u)p[m]===void 0&&(p[m]=u[m]);return {success:true,data:p}}return {success:true,data:{...l.data,...u}}}),this},b(n,"_parse",(o,s,i)=>{let a=o(s,i),{abortEarly:c}=xe(i);if(a.success===false)return a;let l={},u=[];for(let p in e){let m=e[p]._parse(a.data[p],i);if(m.success)l[p]=m.data;else {let d=Gt(m,p,c,u);if(d)return d}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),r}function it(e){return R(ie,{...e,type:"string"})}function at(e){return R(nt,{...e,type:"number"})}function ct(e){return R(rt,{...e,type:"boolean"})}function lt(e){return R(Zn,{...e,type:"date"})}function Wt(e){return R(er,{...e,type:"function"})}function zt(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${i}".`,o="enum",s=R(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function Xt(e,t){let n=R(tr,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,b(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:a}=xe(s);if(i.success===false)return i;let c=[],l=[],u=s;for(let p=0;p<i.data.length;p++){let m={...u,context:{...u?.context,index:p}},d=e._parse(i.data[p],m);if(d.success)c.push(d.data);else {let S=Gt(d,p,a,l);if(S)return S}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:c}}),n}function Jt(){return R(()=>true)}function Z(e,t){return b(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function Qt(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: ${ot(o)?JSON.stringify(o):`"${o}"`}`,r=R(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,b(r,"_parse",(o,s,i)=>{let a=i,c=[];for(let m=0;m<e.length;m++){let d=e[m]._parse(s,a);if(d.success)return d;c.push(d);}let{abortEarly:l}=xe(a),u={message:typeof n=="function"?n(s):n};if(l!==false)return {success:false,error:u,errors:[u]};let p=[];for(let m=0;m<c.length;m++){let d=c[m].errors;if(d?.length)for(let S=0;S<d.length;S++)d[S].cause?.key&&p.push(st(d[S],`branch ${m}`));}return p.length===0&&p.push(u),{success:false,error:p[0],errors:p}}),r}function Zt(e,t){let n=R(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 en(e){let t=R(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,b(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function tn(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 nn={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 ie(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},ct({...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(rt(n))return Number(n);if(ie(n)){let r=n.trim();if(r==="")return n;let o=Number(r);if(Number.isFinite(o))return o}return n},at({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return Z(n=>rt(n)||nt(n)&&Number.isFinite(n)?String(n):n,it({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return Z(n=>{let r;return ie(n)&&(r=n.trim()),nt(n)&&Number.isFinite(n)||r?new Date(r??n):n},lt({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return b(e,"_parse",(r,o,s)=>{if(ie(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}},rn={},f={object:Yt,string:it,number:at,boolean:ct,date:lt,function:Wt,enum:zt,array:Xt,any:Jt,preprocess:Z,union:Qt,literal:Zt,contextRef:en,withContext:tn,coerce:rn,cast:nn};function qt(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function b(e,t,n){let r=e[t];e[t]=(...o)=>n(r,...o);}function R(e,{type:t="any",name:n,message:r}={}){r=r||qt(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,a){let c=e(i);if(c===true)return {success:true,data:i};if(typeof c=="object"&&c?.success===true)return c;let l={message:typeof r=="function"?r(i):r};return {success:false,error:l,errors:[l]}},parse(i,a){let c=this._parse(i,a);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(i,a){return this._parse(i,a)},transform(i){return b(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return tt(this,i=>i===void 0),this},nullable(){return tt(this,i=>i===null),this},nullish(){return tt(this,i=>i==null),this},default(i){return b(this,"_parse",(a,c,l)=>(c===void 0&&(c=typeof i=="function"?i({context:l?.context}):i),a(c,l))),this},catch(i){return b(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:c,error:u.error}):i}}),this},pipe(i){return b(this,"_parse",(a,c,l)=>{let u=a(c,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:a,type:c,jsonSchema:l}={}){if(c&&(a=a||qt(c),t=c),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return b(this,"_parse",(u,p,m)=>{let d=u(p,m),{abortEarly:S}=xe(m);if(!d.success)return d;let _=i(d.data);if(_===true||typeof _=="object"&&_?.success===true)return d;let x={message:typeof a=="function"?a(p):a};return {success:false,error:x,errors:[x]}}),this},clone(){return {...this}}};return Kt.length>0?Kt.reduce((i,a)=>a(i,e,o)??i,s):s}var Kt=[];var on=class{next(...e){}error(...e){}complete(...e){}},ut=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 be=Symbol("@esmj/signals:type"),ae=Symbol("@esmj/signals:name");var N=null,ft=false,pt=[];function A(e){let t=N;N=null;let n=e();return N=t,n}function or(){ft=false;let e=ln();for(let n of e)n.get();let t=pt;pt=[];for(let n of t)n();}function sn(){ft||(ft=true,queueMicrotask(or));}function mt(e){pt.push(e),sn();}var an=Symbol("@esmj/signals:internal observable"),T=Symbol("@esmj/signals:original function"),sr=class extends ut{#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=()=>A(()=>{this.#e.add(e),this.#r();}),e.next[T]=void 0),e instanceof pn&&e.next[T]===void 0){let t=e.next.bind(e);e.next=()=>A(()=>{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=()=>A(()=>(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)}},Ce=null;function cn(e){Ce=new sr(e);}cn(()=>{sn();});function ln(){return Ce.getPending()}function un(e){return Ce.watch(e)}function fn(e){return Ce.unwatch(e)}var P=Symbol("@esmj/signals:no error"),pn=class mn extends on{#e=true;#r=false;#t=null;#o=this.#p();#l=null;#c=null;#i=0;#s=new Map;#n=P;constructor(t,n){super(),this.#l=t,this.#c=n,this.debug=n?.debug,this[be]="computed",this[ae]=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[ae],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof mn&&A(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[an].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=G(this.#a(),this.#c)),(this.#e||this.#n!==P)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),N&&N.sourceRevisions.set(this,this.#i),this.#n!==P)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=G(this.#a(),this.#c)),(this.#e||this.#n!==P)&&(this.#s.size===0||this.#f()?this.#a():this.#e=false),this.#n!==P)throw this.#n;return this.#t.peek()}#a(){this.#r=true,this.#e=false,this.#n=P,this.#u(),this.#o.sourceRevisions.clear();let t=N;N=this.#o;let n;try{n=this.#l();}catch(r){this.#n=r;}return N=t,this.#s=this.#o.sourceRevisions,this.#o.sourceRevisions=new Map,this.#r=false,n instanceof Promise&&(n=n.then(r=>{this.#n=P,this.#t.set(r);}).catch(r=>{this.#n=r;})),this.#n===P&&this.#t&&this.#t.set(n),this.#i++,n}destroy(){this.#u(),this.#s.clear(),this.#e=true,this.#n=P;}};function Y(e,t){return new pn(e,t)}function k(e,t){let n,{debug:r,...o}={},s=Y(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),un(s);let i=()=>{n?.(),s.destroy(),fn(s);};return i[Symbol.dispose]=i,i[be]="effect",i[ae]=r??null,i.__RX_COMPUTED__=s,i}function G(e,t={}){let n=t?.equals??Object.is,r=0,o=new ut;function s(){return N&&(N.dependencies.set(o,o.subscribe(N.observer)),N.sourceRevisions.set(l,r)),e}function i(){return e}function a(u){if(!n(e,u)){e=u,r++,o.next();}return e}function c(){return r}let l={get:s,set:a,peek:i,getRevision:c,[an]:o,[be]:"signal",[ae]:t?.debug??null};return l}function Ae(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Cn=Symbol("node-component"),Re=Symbol("node-internal"),ir=Symbol("keep-literal"),ve=Symbol("raw-props");function yt(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function St(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var ar=new Set(["template","script"]);function cr(e,t){let n=(e==null?"span":String(e)).trim(),r=n;ar.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,Ae()),o}function xt(e,t,n){let r=cr(e,t);return n?.id&&r.setAttribute("id",n.id),r}function bt(e){let t=null,n=()=>t,r=s=>(t=s??null,t),o={get:n,set:r,[Symbol.toPrimitive](){return t?String(t):""}};return Object.defineProperty(o,"current",{get(){return t},set(s){r(s);},enumerable:true,configurable:false}),new Proxy(o,{get(s,i,a){if(Reflect.has(s,i))return Reflect.get(s,i,a);if(!t)return;let c=t[i];return typeof c=="function"?c.bind(t):c},set(s,i,a,c){return Reflect.has(s,i)||!t?Reflect.set(s,i,a,c):(t[i]=a,true)},has(s,i){return Reflect.has(s,i)||!!t&&i in t}})}var An=null;function W(){return An}function Ne(e){An=e;}function Le(e){return e?.[Cn]||null}function dn(e,t){e[Cn]=t;}function ke(e,t={disposers:[],id:Ae()}){return e?.[Re]?e[Re]:(e&&(e[Re]=t),t)}function lr(e){return e[Re]}function B(e,t){let n=lr(e);n||(n=ke(e)),n.disposers.push(t);}function gt(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function H(e,t){let n=W();Ne(e);try{return t()}finally{Ne(n);}}var ht=new Map,_e=new Map,gn=new Map;function Rn(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?.[ir]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=Y(s):r[o]=G(s);}return r}function Ie(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 a="value"in s?s.value:s.get?.call(e),c="value"in i?i.value:i.get?.call(t);return Ie(a,c)})}function Ct(e){return {id:Symbol("context-id"),defaultValue:e}}function ue(e){let t=W();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function O(e){mt(()=>{setTimeout(e,0);});}function fe(e){let t=e.componentId,n=ht.get(t);if(n){ht.delete(t);for(let r of n){let o=r();typeof o=="function"&&gt(_e,t,o);}}}function ur(e){let t=_e.get(e);if(t){_e.delete(e);for(let n of t)n();}}function fr(e){let t=gn.get(e);if(t){gn.delete(e);for(let n of t)n();}}function Me(e){if(!e)return;let t=ke(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=Le(e);if(n&&(ur(n.componentId),fr(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Me(r),r=o;}}}function z(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function hn(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function pr(e,t,n){let r=Ae(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=hn(e)?void 0:e[ve],i={...Rn(t??{},s),children:n},a=W(),c={disposers:[],id:r,contexts:new Map(a?.contexts)};Ne(c);let l;if(hn(e)){o.ClassConstructor=e;let p=new e(i);o.classInstance=p,typeof p.onMount=="function"&&gt(ht,r,()=>{p.onMount?.();}),typeof p.onUnmount=="function"&&gt(_e,r,()=>{p.onUnmount?.();}),l=p.render();}else l=e(i);Ne(a);let u=mr(l);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let p of u.childNodes)ke(p,c),dn(p,o);else ke(u,c),u instanceof Node&&dn(u,o);return u}};return o}function At(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{fe(t);});}function mr(e){return e instanceof Node?e:z(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var En={className:"class",htmlFor:"for"},yn=new Set(["value","defaultValue","checked","selected","indeterminate"]),dr=new Set(["srcdoc"]),gr=new Set(["href","src","action","formaction","xlink:href"]),hr=new Set(["securitypolicyviolation"]),Er=new Set(["contenteditable","draggable","spellcheck"]);function le(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Nn=Symbol("Fragment");function E(e,t,n){if(e===Nn){let o=document.createDocumentFragment();return Et(o,xn(n)),o}if(typeof e=="function")return pr(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),we(r,t),Et(r,xn(n)),r}function dt(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function yr(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Sr(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return dr.has(n)?true:gr.has(n)&&t!==null&&t!==void 0&&yr(String(t))}function kn(e){return typeof e!="string"?e:En[e]?En[e]:e}function xr(e,t){let n=kn(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return Er.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Sn(e,t,n){let r=xr(t,n);if(r===null){e.removeAttribute(t);return}if(Sr(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function we(e,t){let n=W();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=kn(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(le(o)){let s=k(()=>{H(n,()=>{dt(e,o.get());});});B(e,s);}else if(typeof o=="function"){let s=k(()=>{H(n,()=>{dt(e,o());});});B(e,s);}else dt(e,o);continue}if(r==="style"){if(le(o)){let s=k(()=>{H(n,()=>{Object.assign(e.style,o.get());});});B(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(hr.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(le(o)||typeof o=="function"){let s=r,i=k(()=>{H(n,()=>{let a=typeof o=="function"?o():o.get();yn.has(s)?e[s]=a??"":Sn(e,s,a);});});B(e,i);continue}yn.has(r)||typeof r=="symbol"?e[r]=o??"":Sn(e,r,o);}}function xn(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function Et(e,t){for(let n of t)_n(e,n);}function _n(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"){bn(e,t);return}if(z(t)){At(e,t);return}if(le(t)){bn(e,()=>t.get());return}if(Array.isArray(t)){Et(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function ee(e){let t=null,n=e;return z(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 Te(e,t=true){for(let n of e)t&&Me(n),n.remove();}function bn(e,t){let n=W(),r=document.createComment("");e.appendChild(r);let o=[],s=k(()=>{H(n,()=>{let i=t(),{nodes:a,instance:c}=ee(i);Te(o),a.length&&r.after(...a),c&&queueMicrotask(()=>fe(c)),o=a;});});B(e,s);}var Pe=class{constructor(e){this.props=e;}};function vn(e,t,n,r){let{equals:o=Ie,tagName:s="span",...i}=r??{},a=xt(s,"data-for",i);we(a,i);let c=W(),l=[],u=new Map,p=Y(()=>e()),m=k(()=>{let d=p.get(),S=Array.isArray(d)?d:[],_=[],x=[],q=new Set;for(let h=0;h<S.length;h++){let C=S[h],v=t(C,h);if(q.has(v)){console.error(`For: duplicate key "${String(v)}" detected; ignoring later item at index ${h}`);continue}q.add(v),_.push(C),x.push(v);}let Q=new Map(l.map(h=>[h.key,h])),D=[];for(let h=0;h<_.length;h++){let C=x[h],v=_[h],K=Q.get(C);if(K)u.get(C).set(v),D.push(K),Q.delete(C);else {let Ft=G(v,{equals:o});u.set(C,Ft);let Wn={...Ft,set(){}},Vt={key:C,nodes:[]};H(c,()=>{let zn=n(Wn,h),{nodes:Xn,instance:Ut}=ee(zn);Vt.nodes=Xn,Ut&&queueMicrotask(()=>fe(Ut));}),D.push(Vt);}}for(let[h,C]of Q)Te(C.nodes),u.delete(h);let w=null;for(let h=D.length-1;h>=0;h--){let C=D[h].nodes;for(let v=C.length-1;v>=0;v--){let K=C[v];(K.parentNode!==a||K.nextSibling!==w)&&a.insertBefore(K,w),w=K;}}l=D;});return B(a,m),a}function Rt(e,t,n,r){if(typeof e=="function")return vn(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:a,children:c,...l}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=yt(o),p=St(e??{},t);return vn(u,s,p,{...l,equals:i,tagName:a})}Rt[ve]=e=>e!=="each";function In(e,t){if(typeof e=="string"&&(e=document.querySelector(e)),!e)throw new Error("mount: container not found");e instanceof DocumentFragment||(Me(e),e.innerHTML=""),z(t)?At(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var Nt=_t(),kt=_t(),Mn=_t(),Cr=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function _t(){return Math.floor(Math.random()*16777215)}function Ar(){return kt=(kt+1)%16777215,kt}function y(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Ar(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,Nt>>16&255,Nt>>8&255,Nt&255,Mn>>8&255,Mn&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Cr[n.charCodeAt(o)];return r}var vt=Symbol("block-element"),Rr=Symbol("block-element-body"),X=Symbol("selectable-element");function Lt(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 Nr(e){return e?Lt(e.startContainer,vt):null}function $(e){return Lt(e,vt)}function kr(e){return e?Lt(e.startContainer,X):null}function wn(){return window.getSelection()}function M(){let e=wn();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function Tn(){let e=M();if(!e)return 0;e.collapse(true);let t=kr(e),n=Nr(e),r=t??De(n);return Oe(r,e.startContainer,e.startOffset)}function Oe(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,a=e.childNodes,c=Math.min(n,a.length);for(let l=0;l<c;l++)i+=a[l].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 _r(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 j(e,t){let n=_r(e,t),r=wn();r.removeAllRanges(),r.addRange(n);}function De(e){if(!e)return null;let t=vr(e);return t?.firstElementChild??t?.firstChild}function It(e){if(!e?.[vt])return null;let t=De(e);return t?Le(t)?.classInstance:null}function vr(e){if(!e)return null;for(let t of e.children)if(t[Rr])return t;return null}var L="molecule.paragraph.Paragraph",Be="molecule.list.List";var Mt="molecule.headline.H1",wt="molecule.headline.H2",Tt="molecule.headline.H3",Pt="molecule.headline.H4",Ot="molecule.headline.H5",Pn="molecule.headline.";function g(e){return e===`
2
+ `||e===`\r
3
+ `?"":e??""}function I({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{};return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{...o,text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]},...r?{settings:r}:{}}}function Hn(e){let t=e?.component??"";return t===L||t.startsWith(Pn)}function He(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 On(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function Ir(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let a=r.find(c=>c.match(i));a&&(s=E(a,{},s));}for(let i of n){let a=o.find(c=>c.match(i));a&&(s=E(a,i,s));}return s}function ne(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=g(e.properties.text),s=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!o)return r;let a=Lr([...s,...i],o.length);for(let c=0;c<a.length-1;c+=1){let l=a[c],u=a[c+1];if(l>=u)continue;let p=o.slice(l,u),m=Ir(p,On(s,l,u),On(i,l,u),{inlineStyleComponents:t,entityRangeComponents:n});In(r,m);}return r}function te(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 a=r.find(l=>l.match(i));if(a){let l=i.textContent.length;t.properties.inlineStyleRanges.push({style:a.style,offset:s,length:l}),s=te(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let c=o.find(l=>l.match(i));if(c){let l=i.textContent.length;t.properties.entityRanges.push({...c.getStateSchema(i).parse(),offset:s,length:l}),s=te(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=te(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function pe(e,t){let n=g(e.properties.text),r=g(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 Dn(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Bn(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 Dt(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=Dn(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Bn(e.properties.inlineStyleRanges,t),n.properties.entityRanges=Dn(e.properties.entityRanges,t),r.properties.entityRanges=Bn(e.properties.entityRanges,t),r.componentId=y(),{originalLineState:n,newLineState:r}}function $e(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=Dt(e.getState(),Tn(e.element));return e.mrakomor.command.insertBlockElement({range:M(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}function je(e,t){let n=e.constructor;if(!t)return n.getStateSchema(t).parse();let r=structuredClone(n.getStateSchema(t).parse());return te(t.childNodes,r,0,{inlineStyleComponents:e.getInlineStyleComponents(),entityRangeComponents:e.getEntityRangeComponents()}),r.properties.text=g(r.properties.text),r}function Fe(e){return e?{element:e,read(t){return {inlineStyleRanges:t.properties?.inlineStyleRanges,entityRanges:t.properties?.entityRanges}},write(t,{inlineStyleRanges:n,entityRanges:r}){n!==void 0&&(t.properties.inlineStyleRanges=n),r!==void 0&&(t.properties.entityRanges=r);}}:null}(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/headline/Headline.css",t=Array.prototype.some.call(document.head.querySelectorAll("style[data-mrakomor-css-path]"),function(r){return r.getAttribute("data-mrakomor-css-path")===e});if(!t){var n=document.createElement("style");n.setAttribute("data-mrakomor-css",""),n.setAttribute("data-mrakomor-css-path",e),n.textContent=`.mrakomor-content h1,.mrakomor-content h2,.mrakomor-content h3,.mrakomor-content h4,.mrakomor-content h5{margin-top:0}
4
+ `,document.head.appendChild(n);}}})();var Ve={INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var Ue=Ct();var qe=class extends Pe{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=ue(Ue),this._stale=false,this._observer=null,this._offInputStale=null,this._onInputMarkStale=null,this._observeDOMChanges=r;}static get NAMESPACE(){return "namespace.AbstractComponent"}static getStateSchema(){return f.object({component:f.string().default(this.NAMESPACE),properties:f.object().default({}),settings:f.object().default({})}).default({})}static getPropsSchema(){return f.object({state:this.getStateSchema(),observeDOMChanges:f.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(Ve.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var F=class extends qe{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor(t){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:g(this.getState()?.properties?.text).length;j(this.element,r);};n(),O(n);}onKeydown(t){}getFormattingTarget(t){return null}static toExchangeState(t){return I({originComponent:this.NAMESPACE,properties:{...t?.properties,text:g(t?.properties?.text)},settings:t?.settings})}static fromExchangeState(t){return {properties:t?.properties,settings:t?.settings}}static appendExchangeState(t,n){return pe(t,n)}};function Ke(){return f.object({length:f.number(),offset:f.number(),style:f.string()})}function J({type:e,data:t=f.any(),length:n,offset:r}={}){let o=e!=null,s=f.object({type:o?f.string().default(e):f.string(),data:t}),i=n??(o?0:void 0),a=r??(o?0:void 0);return f.object({entity:o?s.default({}):s,length:i==null?f.number():f.number().default(i),offset:a==null?f.number():f.number().default(a)})}function re(){return f.array(J()).transform(e=>e.filter(t=>t.entity.type==="atom.tts.Voice")).default([])}function V(e,{component:t,properties:n,settings:r=f.object({}).default({})}){return f.object({component:f.string().default(t),componentId:f.string().default(e?.getAttribute("data-componentid")||y()),properties:f.object(n).default({}),settings:r}).default({})}var Ge=class extends F{constructor(t){super(t),this._level=1;}static getStateSchema(t){return V(t,{component:this.NAMESPACE,properties:{text:f.string().default(t?.textContent??t?.innerText??"")}})}parseFromHTML(t){if(!t)return this.constructor.getStateSchema(t).parse();let n=structuredClone(this.constructor.getStateSchema(t).parse());return n.properties.text=g(n.properties.text),n}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return E(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[X]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return g(r)?A(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}$e(this,t,{namespace:L});}#e(t){if(!M()?.collapsed)return;let r=$(this.element);if(r?.previousElementSibling||g(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:r,namespace:L});let o=()=>{let s=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),i=De(s);i?.isConnected&&j(i,0);};o(),O(o);}};var U=class extends Ge{static getStateSchema(t){return V(t,{component:this.NAMESPACE,properties:{text:f.string().default(t?.textContent??t?.innerText??""),entityRanges:re()}})}getInlineStyleComponents(){return []}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}parseFromHTML(t){return je(this,t)}_buildContent(t){return ne(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}getFormattingTarget(t){return Fe(this.element)}},Ye=class extends U{static get NAMESPACE(){return Mt}static get LABEL(){return "H1"}constructor(t){super(t),this._level=1;}},me=class extends U{static get NAMESPACE(){return wt}static get LABEL(){return "H2"}constructor(t){super(t),this._level=2;}},de=class extends U{static get NAMESPACE(){return Tt}static get LABEL(){return "H3"}constructor(t){super(t),this._level=3;}},ge=class extends U{static get NAMESPACE(){return Pt}static get LABEL(){return "H4"}constructor(t){super(t),this._level=4;}},We=class extends U{static get NAMESPACE(){return Ot}static get LABEL(){return "H5"}constructor(t){super(t),this._level=5;}};function Mr(){return {resolveConfig:e=>(e.blockComponents.push(me,de,ge),e),resolveComponent:e=>{if(e===Ye.NAMESPACE)return Ye;if(e===me.NAMESPACE)return me;if(e===de.NAMESPACE)return de;if(e===ge.NAMESPACE)return ge;if(e===We.NAMESPACE)return We}}}(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}
5
+ `,document.head.appendChild(n);}}})();function ze(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function he(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=y();return t.add(r),{...n,componentId:r}})}function Bt(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function Ee(e,t){if(!e||!t)return null;let n=t.startContainer;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n!==e;){if(n.nodeName==="LI"&&e.contains(n))return n;n=n.parentElement;}return null}function ye(e,t){if(!t)return -1;let n=t.getAttribute?.("data-item-index");if(n!=null&&n!==""){let r=Number(n);if(!Number.isNaN(r))return r}return Bt(e).indexOf(t)}function Ht(e,t){return !e||!t?0:Oe(e,t.startContainer,t.startOffset)}function jn(e,t){let n=I({properties:{text:e.text,inlineStyleRanges:e.inlineStyleRanges,entityRanges:e.entityRanges}}),{originalLineState:r,newLineState:o}=Dt(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:y(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function Fn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:y(),depth:o?.depth??0,text:g(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:y(),depth:0,text:g(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:Be,componentId:y(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function $t(e,t,{namespace:n=L,Constructor:r}={}){let o=e.properties?.items??[],s=o[t];if(!s)return {blocks:[e],paragraphIndex:0};let i=o.slice(0,t),a=o.slice(t+1),c=I({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),l={component:n,componentId:y(),settings:{},...r?.fromExchangeState(c)??c},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(l),a.length&&u.push({...e,componentId:i.length?y():e.componentId,properties:{...e.properties,items:a}}),{blocks:u,paragraphIndex:i.length?1:0}}function $n(e){return He(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function wr(e,t){let n=$n(e),r=$n(t);return n!=null&&n===r}function Vn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!wr(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let m=[...e];m.splice(n,1);let d=s.length-1,S=d>=0?g(s[d]?.text).length:0;return {content:m,listIndex:t,cursor:S}}let[a,...c]=i,l=0;if(s.length===0)s.push(a,...c),l=0;else {let m=s.length-1,d=s[m],S=I({properties:{text:d.text,inlineStyleRanges:d.inlineStyleRanges,entityRanges:d.entityRanges}}),_=I({properties:{text:a.text,inlineStyleRanges:a.inlineStyleRanges,entityRanges:a.entityRanges}}),{state:x,cursor:q}=pe(S,_);s[m]={...d,text:x.properties.text,inlineStyleRanges:x.properties.inlineStyleRanges,entityRanges:x.properties.entityRanges},c.length&&s.push(...c),l=q;}let u={...r,properties:{...r.properties,items:he(s)}},p=[...e];return p[t]=u,p.splice(n,1),{content:p,listIndex:t,cursor:l}}function Un(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=n[r],s=I({properties:{text:o.text,inlineStyleRanges:o.inlineStyleRanges,entityRanges:o.entityRanges}}),i=I({properties:t?.properties}),{state:a,cursor:c}=pe(s,i);return {state:{...e,properties:{...e.properties,items:n.map((l,u)=>u===r?{...l,text:a.properties.text,inlineStyleRanges:a.properties.inlineStyleRanges,entityRanges:a.properties.entityRanges}:l)}},cursor:c}}function qn(e,t){return ne({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function Kn(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:g(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return te(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:g(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var Xe=e=>f.object({componentId:f.string().default(()=>e?.getAttribute?.("data-componentid")||y()),depth:f.number().default(0),text:f.string().default(""),inlineStyleRanges:f.array(Ke()).default([]),entityRanges:f.array(J()).default([])}).default({}),Je=class e extends F{static get NAMESPACE(){return Be}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=ze(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||y()),properties:f.object({items:f.array(Xe()).default([Xe().parse()]).transform(he)}).default({}),settings:f.object({style:f.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let n=t?.properties?.items??[],r=n.map(s=>g(s?.text)).join(`
6
+ `),o=n.map(s=>({text:g(s?.text),inlineStyleRanges:s?.inlineStyleRanges??[],entityRanges:s?.entityRanges??[],depth:s?.depth??0}));return I({originComponent:this.NAMESPACE,properties:{text:r,items:o},settings:t?.settings})}static fromExchangeState(t){return Fn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return Un(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=Bt(t);if(o.length)n.properties.items=o.map(s=>Xe(s).parse(Kn(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[Xe().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}getFormattingTarget(t){let n=t??M(),r=Ee(this.element,n);if(!r)return null;let o=ye(this.element,r);return o<0?null:{element:r,read(s){let i=s.properties?.items?.[o];return {inlineStyleRanges:i?.inlineStyleRanges,entityRanges:i?.entityRanges}},write(s,{inlineStyleRanges:i,entityRanges:a}){let c=s.properties?.items?.[o];c&&(i!==void 0&&(c.inlineStyleRanges=i),a!==void 0&&(c.entityRanges=a));}}}_commitState(t){let n=$(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId),r=this.mrakomor._getBlockElementIndex(n);if(r===-1)return;let o=this.mrakomor.getContent();o.splice(r,1,t),this.mrakomor.setContent(o);}_buildItemContent(t){return qn(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=Rt(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>E("li",{contentEditable:true,[X]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let a=s.get()?.componentId,l=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===a);return String(l>=0?l:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let a=s.get(),c=a?.text??"";return g(c)?A(()=>this._buildItemContent(a)):"<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(t){let n=this.getState()?.properties?.items??[],r=n.length-1;if(r<0)return;let o=typeof t=="number"?t:g(n[r]?.text).length,s=()=>{let i=this.element?.querySelector(`li[data-item-index="${r}"]`);i?.isConnected&&j(i,o);};s(),O(s);}#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 p=()=>{let m=this.element?.querySelector(`li[data-item-index="${t}"]`);m?.isConnected&&j(m,0);};p(),O(p);return}let s=$(this.element),i=this.mrakomor._getBlockElementIndex(s),a=s?.previousElementSibling??null,c=a?this.mrakomor._getBlockElementIndex(a):-1;if(t===0&&c>=0&&i===c+1){let p=this.mrakomor.getContent(),m=Vn(p,c,i);if(m){this.mrakomor._setContentState(m.content.map(d=>this.mrakomor.normalizeComponentState(d))),It(a)?.setCursor?.(m.cursor);return}}let{blocks:l,paragraphIndex:u}=$t(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(L)});this.mrakomor.command.replaceBlockElement({blockElement:$(this.element),blocks:l,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=M(),r=Ee(this.element,n);if(!r)return;let o=ye(this.element,r),s=Ht(r,n),i=this.getState(),a=[...i.properties.items??[]],c=a[o];if(!c)return;if(!g(c.text)){this.#e(o);return}let{before:l,after:u}=jn(c,s);a.splice(o,1,l,u),this._commitState({...i,properties:{...i.properties,items:a}}),O(()=>{let p=this.element?.querySelector(`li[data-item-index="${o+1}"]`);p&&j(p,0);});}#t(t){let n=M();if(!n?.collapsed)return;let r=Ee(this.element,n);if(!r){let i=n.startContainer;if(!(i===this.element||this.element?.contains?.(i)))return;t.preventDefault(),this.#e(0);return}let o=ye(this.element,r);Ht(r,n)===0&&(t.preventDefault(),this.#e(o));}};function Tr(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!Hn({component:r})||!He(o))return;e.preventDefault();let i=It(n)?.element,a=e.range??M(),c=i?Ee(i,a):null,l=ye(i,c);if(l<0)return;let{blocks:u,paragraphIndex:p}=$t(o,l,{namespace:r,Constructor:t.register.blocks.getByNamespace(r)});t.command.replaceBlockElement({blockElement:n,blocks:u,cursor:0,cursorBlockIndex:p});}function Gn(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(Ve.TRANSFORM_BLOCK_ELEMENT,Tr);}}}var Yn=e=>f.object({componentId:f.string().default(()=>y()),depth:f.number().default(0),text:f.string().default(""),entityRanges:re()}).default({}),Qe=class e extends Je{static getStateSchema(t){let n=ze(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||y()),properties:f.object({items:f.array(Yn()).default([Yn().parse()]).transform(he)}).default({}),settings:f.object({style:f.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}getInlineStyleComponents(){return []}parseFromHTML(t){return this.constructor.getStateSchema(t).parse(super.parseFromHTML(t))}};function Pr(){return Gn(Qe)}(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}
7
+ `,document.head.appendChild(n);}}})();var Ze=class e extends F{static get NAMESPACE(){return L}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 V(t,{component:e.NAMESPACE,properties:{entityRanges:f.array(J()).default([]),inlineStyleRanges:f.array(Ke()).default([]),text:f.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return je(this,t)}_buildContent(t){return ne(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return E("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[X]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return g(r)?A(()=>this._buildContent(n)):"<br>"}})}getFormattingTarget(t){return Fe(this.element)}onKeydown(t){$e(this,t);}};var oe=class e extends Ze{static getStateSchema(t){return V(t,{component:e.NAMESPACE,properties:{entityRanges:re(),text:f.string().default(t?.innerText??t?.textContent??"")}})}getInlineStyleComponents(){return []}};function Or(){return {resolveConfig:e=>(e.blockComponents.push(oe),e),resolveComponent:e=>{if(e===oe.NAMESPACE)return oe}}}var et=class extends Pe{static get nodeName(){return "span"}static get NAMESPACE(){return "namespace.EntityRangeElement"}static match(t){return t?.nodeName===this.nodeName.toUpperCase()||t?.entity?.type===this.NAMESPACE}static getStateSchema(t){return f.any()}constructor(t){super(t),this.mrakomor=ue(Ue),this.element=bt();}render(){return E(this.constructor.nodeName,{},this.props.children)}};(function(){if(!(typeof document>"u")){var e="mrakomor/core/plugin/tts/TtsVoice.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=`.atom-tts-voice{position:relative;border-radius:2px;display:inline-block}.atom-tts-voice:before{content:attr(data-voice-label);position:absolute;top:-1.1em;left:0;font-size:10px;line-height:1;white-space:nowrap;padding:1px 4px;border-radius:3px;pointer-events:none;font-weight:600}.tts-voice--man,.tts-voice--woman{background:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 14%,white);color:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 75%,black)}.tts-voice--man:before,.tts-voice--woman:before{background:var(--tts-voice-color, #1a73e8);color:#fff}.tts-voice-toolbar{display:flex;flex-direction:column;gap:6px}.tts-voice-toolbar__row{display:flex;align-items:center;flex-wrap:wrap;gap:4px;min-width:0}.tts-voice-toolbar__voice{flex-shrink:0;border:1px solid #dadce0;border-radius:4px;padding:4px 8px;font-size:12px;background:#fff;color:#333}.tts-voice-toolbar__voice--man,.tts-voice-toolbar__voice--woman{border-color:var(--tts-voice-color, #1a73e8);color:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 75%,black)}.tts-voice-toolbar__voice--active{font-weight:600}.tts-voice-toolbar__voice--man.tts-voice-toolbar__voice--active,.tts-voice-toolbar__voice--woman.tts-voice-toolbar__voice--active{background:color-mix(in srgb,var(--tts-voice-color, #1a73e8) 16%,white)}.tts-voice-toolbar__sep{width:1px;height:18px;background:#e0e0e0;flex-shrink:0;margin:0 2px}.tts-voice-toolbar__btn{display:flex;align-items:center;justify-content:center;flex-shrink:0;background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:#555}.tts-voice-toolbar__btn:hover{background:#f0f0f0;color:#222}.tts-voice-toolbar__btn--danger:hover{color:#d32f2f;background:#fdecea}
8
+ `,document.head.appendChild(n);}}})();var Se=[{id:"Jarda",label:"Voice Jarda",gender:"man",color:"#1a73e8"},{id:"Pavel",label:"Voice Pavel",gender:"man",color:"#1e8e3e"},{id:"Radek",label:"Voice Radek",gender:"man",color:"#00838f"},{id:"Magda",label:"Voice Magda",gender:"woman",color:"#7b1fa2"},{id:"Marketa",label:"Voice Marketa",gender:"woman",color:"#d81b60"},{id:"Silva",label:"Voice Silva",gender:"woman",color:"#c62828"}],Dr='<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>';function jt(e){return Se.find(t=>t.id===e)??Se[0]}function Br(e){let t=Se.find(o=>o.id===e);if(t)return t.color;let n=0;for(let o=0;o<e.length;o++)n=n*31+e.charCodeAt(o)|0;return `hsl(${Math.abs(n)%360}, 65%, 45%)`}var se=class e extends et{#e;static get NAMESPACE(){return "atom.tts.Voice"}static get LABEL(){return "VOICE"}static match(t){return t?.entity?.type===e.NAMESPACE||t?.nodeName==="SPAN"&&t?.getAttribute?.("data-entity-type")===e.NAMESPACE}static getStateSchema(t){let n;if(t?.getAttribute?.("data-state"))try{n=JSON.parse(t.getAttribute("data-state"));}catch{}let r=n?.entity?.data?.voice??t?.getAttribute?.("data-voice")??"";return J({type:e.NAMESPACE,data:f.object({voice:f.string().default(r)}).default({}),length:n?.length??0,offset:n?.offset??0}).default({})}#r({entity:t,length:n,offset:r}){let o=t.peek()?.data?.voice??"";return E("div",{className:"tts-voice-toolbar"},[E("div",{className:"tts-voice-toolbar__row"},[...Se.map(s=>E("button",{type:"button",className:`tts-voice-toolbar__voice tts-voice-toolbar__voice--${s.gender}${o===s.id?" tts-voice-toolbar__voice--active":""}`,$ref:i=>i?.style.setProperty("--tts-voice-color",s.color),title:s.label,onClick:()=>{t.set({...t.peek(),data:{voice:s.id}}),this.mrakomor.command.closeDialog();}},s.label)),E("span",{className:"tts-voice-toolbar__sep"}),E("button",{type:"button",className:"tts-voice-toolbar__btn tts-voice-toolbar__btn--danger",title:"Remove TTS voice",$dangerouslySetInnerHTML:Dr,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:t.peek(),length:n.peek(),offset:r.peek()},blockElement:$(this.element)});}})])])}#t(t){this.mrakomor.command.openDialog({element:this.element,children:this.#r(t)});}onMount(){let{entity:t}=this.props;t.peek()?.data?.voice||this.#t(this.props),this.#e=k(()=>{let n=t.get()?.data?.voice??"";this.element.current?.style.setProperty("--tts-voice-color",Br(n));});}onUnmount(){this.#e?.();}render(){let{entity:t,length:n,offset:r,children:o}=this.props;return E("span",{className:()=>{let s=t.get()?.data?.voice??"";return `atom-tts-voice tts-voice--${jt(s||"man1").gender}`},"data-entity-type":this.constructor.NAMESPACE,"data-voice":()=>t.get()?.data?.voice??"","data-voice-label":()=>{let s=t.get()?.data?.voice??"";return s?jt(s).label:""},$ref:this.element,onClick:s=>{s.preventDefault(),this.#t({entity:t,length:n,offset:r});},"data-state":()=>JSON.stringify({entity:t.get(),length:n.get(),offset:r.get()})},o)}};function Hr(){return {resolveConfig:e=>(e.entityRanges.push(se),e),resolveComponent:e=>{if(e===se.NAMESPACE)return se}}}
9
+ exports.TtsHeadlineComponent=U;exports.TtsList=Qe;exports.TtsParagraph=oe;exports.TtsVoice=se;exports.VOICES=Se;exports.getVoice=jt;exports.ttsHeadlinePlugin=Mr;exports.ttsListPlugin=Pr;exports.ttsParagraphPlugin=Or;exports.ttsVoicePlugin=Hr;