@mrakomor/core 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tts.cjs CHANGED
@@ -1,9 +1,9 @@
1
- 'use strict';var nr={abortEarly:true};function it(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 rr(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(it(e.errors[r],n));}function zt(e,t,n,r){if(n!==false){let o=it(e.error,t);return {success:false,error:o,errors:[o]}}rr(e,r,t);}function Ae(e){return e?.abortEarly!==void 0?e:nr}function nt(e,t){b(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var ue=e=>typeof e=="string"||e instanceof String,rt=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),ot=e=>e===true||e===false,or=e=>e instanceof Date&&!Number.isNaN(e.getTime()),sr=e=>typeof e=="function",ir=e=>Array.isArray(e),st=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Wt(e,t){let n=A(st,{...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,c,a)=>{let l=i(c,a);if(!l.success)return l;let u=o(l.data,{context:a?.context});if(!st(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 c=o(s,i),{abortEarly:a}=Ae(i);if(c.success===false)return c;let l={},u=[];for(let p in e){let m=e[p]._parse(c.data[p],i);if(m.success)l[p]=m.data;else {let d=zt(m,p,a,u);if(d)return d}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),r}function ct(e){return A(ue,{...e,type:"string"})}function at(e){return A(rt,{...e,type:"number"})}function lt(e){return A(ot,{...e,type:"boolean"})}function ut(e){return A(or,{...e,type:"date"})}function Xt(e){return A(sr,{...e,type:"function"})}function Jt(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${i}".`,o="enum",s=A(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function Qt(e,t){let n=A(ir,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,b(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:c}=Ae(s);if(i.success===false)return i;let a=[],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)a.push(d.data);else {let E=zt(d,p,c,l);if(E)return E}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:a}}),n}function Zt(){return A(()=>true)}function te(e,t){return b(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function en(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: ${st(o)?JSON.stringify(o):`"${o}"`}`,r=A(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,b(r,"_parse",(o,s,i)=>{let c=i,a=[];for(let m=0;m<e.length;m++){let d=e[m]._parse(s,c);if(d.success)return d;a.push(d);}let{abortEarly:l}=Ae(c),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<a.length;m++){let d=a[m].errors;if(d?.length)for(let E=0;E<d.length;E++)d[E].cause?.key&&p.push(it(d[E],`branch ${m}`));}return p.length===0&&p.push(u),{success:false,error:p[0],errors:p}}),r}function tn(e,t){let n=A(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 nn(e){let t=A(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,b(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function rn(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 on={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return te(n=>{let r;return ue(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},lt({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return te(n=>{if(ot(n))return Number(n);if(ue(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 te(n=>ot(n)||rt(n)&&Number.isFinite(n)?String(n):n,ct({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return te(n=>{let r;return ue(n)&&(r=n.trim()),rt(n)&&Number.isFinite(n)||r?new Date(r??n):n},ut({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return b(e,"_parse",(r,o,s)=>{if(ue(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}},sn={},f={object:Wt,string:ct,number:at,boolean:lt,date:ut,function:Xt,enum:Jt,array:Qt,any:Zt,preprocess:te,union:en,literal:tn,contextRef:nn,withContext:rn,coerce:sn,cast:on};function Gt(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 A(e,{type:t="any",name:n,message:r}={}){r=r||Gt(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,c){let a=e(i);if(a===true)return {success:true,data:i};if(typeof a=="object"&&a?.success===true)return a;let l={message:typeof r=="function"?r(i):r};return {success:false,error:l,errors:[l]}},parse(i,c){let a=this._parse(i,c);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(i,c){return this._parse(i,c)},transform(i){return b(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return nt(this,i=>i===void 0),this},nullable(){return nt(this,i=>i===null),this},nullish(){return nt(this,i=>i==null),this},default(i){return b(this,"_parse",(c,a,l)=>(a===void 0&&(a=typeof i=="function"?i({context:l?.context}):i),c(a,l))),this},catch(i){return b(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:a,error:u.error}):i}}),this},pipe(i){return b(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:c,type:a,jsonSchema:l}={}){if(a&&(c=c||Gt(a),t=a),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return b(this,"_parse",(u,p,m)=>{let d=u(p,m),{abortEarly:E}=Ae(m);if(!d.success)return d;let C=i(d.data);if(C===true||typeof C=="object"&&C?.success===true)return d;let y={message:typeof c=="function"?c(p):c};return {success:false,error:y,errors:[y]}}),this},clone(){return {...this}}};return Yt.length>0?Yt.reduce((i,c)=>c(i,e,o)??i,s):s}var Yt=[];var cn=class{next(...e){}error(...e){}complete(...e){}},ft=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 _e=Symbol("@esmj/signals:type"),fe=Symbol("@esmj/signals:name");var _=null,pt=false,mt=[];function R(e){let t=_;_=null;let n=e();return _=t,n}function lr(){pt=false;let e=fn();for(let n of e)n.get();let t=mt;mt=[];for(let n of t)n();}function an(){pt||(pt=true,queueMicrotask(lr));}function dt(e){mt.push(e),an();}var ln=Symbol("@esmj/signals:internal observable"),w=Symbol("@esmj/signals:original function"),ur=class extends ft{#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=()=>R(()=>{this.#e.add(e),this.#r();}),e.next[w]=void 0),e instanceof dn&&e.next[w]===void 0){let t=e.next.bind(e);e.next=()=>R(()=>{this.#e.add(e),t(),this.#r();}),e.next[w]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[w]){let n=t.get,r=n.bind(t);t.get=()=>R(()=>(this.#e.delete(t),r())),t.get[w]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[w]?e.next[w]:e.next,e.get=e.get[w]?e.get[w]:e.get,this.#e.delete(e),this.unsubscribe(e)}},Ne=null;function un(e){Ne=new ur(e);}un(()=>{an();});function fn(){return Ne.getPending()}function pn(e){return Ne.watch(e)}function mn(e){return Ne.unwatch(e)}var P=Symbol("@esmj/signals:no error"),dn=class gn extends cn{#e=true;#r=false;#t=null;#o=this.#p();#l=null;#a=null;#i=0;#s=new Map;#n=P;constructor(t,n){super(),this.#l=t,this.#a=n,this.debug=n?.debug,this[_e]="computed",this[fe]=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[fe],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof gn&&R(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[ln].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=z(this.#c(),this.#a)),(this.#e||this.#n!==P)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),_&&_.sourceRevisions.set(this,this.#i),this.#n!==P)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=z(this.#c(),this.#a)),(this.#e||this.#n!==P)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),this.#n!==P)throw this.#n;return this.#t.peek()}#c(){this.#r=true,this.#e=false,this.#n=P,this.#u(),this.#o.sourceRevisions.clear();let t=_;_=this.#o;let n;try{n=this.#l();}catch(r){this.#n=r;}return _=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 W(e,t){return new dn(e,t)}function N(e,t){let n,{debug:r,...o}={},s=W(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),pn(s);let i=()=>{n?.(),s.destroy(),mn(s);};return i[Symbol.dispose]=i,i[_e]="effect",i[fe]=r??null,i.__RX_COMPUTED__=s,i}function z(e,t={}){let n=t?.equals??Object.is,r=0,o=new ft;function s(){return _&&(_.dependencies.set(o,o.subscribe(_.observer)),_.sourceRevisions.set(l,r)),e}function i(){return e}function c(u){if(!n(e,u)){e=u,r++,o.next();}return e}function a(){return r}let l={get:s,set:c,peek:i,getRevision:a,[ln]:o,[_e]:"signal",[fe]:t?.debug??null};return l}function ve(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Rn=Symbol("node-component"),Ie=Symbol("node-internal"),fr=Symbol("keep-literal"),Te=Symbol("raw-props");function St(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function xt(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var pr=new Set(["template","script"]);function mr(e,t){let n=(e==null?"span":String(e)).trim(),r=n;pr.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,ve()),o}function Ct(e,t,n){let r=mr(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,c){if(Reflect.has(s,i))return Reflect.get(s,i,c);if(!t)return;let a=t[i];return typeof a=="function"?a.bind(t):a},set(s,i,c,a){return Reflect.has(s,i)||!t?Reflect.set(s,i,c,a):(t[i]=c,true)},has(s,i){return Reflect.has(s,i)||!!t&&i in t}})}var An=null;function X(){return An}function Le(e){An=e;}function we(e){return e?.[Rn]||null}function hn(e,t){e[Rn]=t;}function Be(e,t={disposers:[],id:ve()}){return e?.[Ie]?e[Ie]:(e&&(e[Ie]=t),t)}function dr(e){return e[Ie]}function H(e,t){let n=dr(e);n||(n=Be(e)),n.disposers.push(t);}function ht(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function $(e,t){let n=X();Le(e);try{return t()}finally{Le(n);}}var Et=new Map,Me=new Map,En=new Map;function _n(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?.[fr]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=W(s):r[o]=z(s);}return r}function Pe(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?false:n.every(o=>{let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(t,o);if(!s||!i)return false;let c="value"in s?s.value:s.get?.call(e),a="value"in i?i.value:i.get?.call(t);return Pe(c,a)})}function kt(e){return {id:Symbol("context-id"),defaultValue:e}}function de(e){let t=X();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function v(e){dt(()=>{setTimeout(e,0);});}function ge(e){let t=e.componentId,n=Et.get(t);if(n){Et.delete(t);for(let r of n){let o=r();typeof o=="function"&&ht(Me,t,o);}}}function gr(e){let t=Me.get(e);if(t){Me.delete(e);for(let n of t)n();}}function hr(e){let t=En.get(e);if(t){En.delete(e);for(let n of t)n();}}function Oe(e){if(!e)return;let t=Be(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=we(e);if(n&&(gr(n.componentId),hr(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Oe(r),r=o;}}}function J(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function yn(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function Er(e,t,n){let r=ve(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=yn(e)?void 0:e[Te],i={..._n(t??{},s),children:n},c=X(),a={disposers:[],id:r,contexts:new Map(c?.contexts)};Le(a);let l;if(yn(e)){o.ClassConstructor=e;let p=new e(i);o.classInstance=p,typeof p.onMount=="function"&&ht(Et,r,()=>{p.onMount?.();}),typeof p.onUnmount=="function"&&ht(Me,r,()=>{p.onUnmount?.();}),l=p.render();}else l=e(i);Le(c);let u=yr(l);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let p of u.childNodes)Be(p,a),hn(p,o);else Be(u,a),u instanceof Node&&hn(u,o);return u}};return o}function Rt(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{ge(t);});}function yr(e){return e instanceof Node?e:J(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Sn={className:"class",htmlFor:"for"},xn=new Set(["value","defaultValue","checked","selected","indeterminate"]),Sr=new Set(["srcdoc"]),xr=new Set(["href","src","action","formaction","xlink:href"]),Cr=new Set(["securitypolicyviolation"]),br=new Set(["contenteditable","draggable","spellcheck"]);function me(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Nn=Symbol("Fragment");function S(e,t,n){if(e===Nn){let o=document.createDocumentFragment();return yt(o,bn(n)),o}if(typeof e=="function")return Er(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),De(r,t),yt(r,bn(n)),r}function gt(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function kr(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Rr(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Sr.has(n)?true:xr.has(n)&&t!==null&&t!==void 0&&kr(String(t))}function vn(e){return typeof e!="string"?e:Sn[e]?Sn[e]:e}function Ar(e,t){let n=vn(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return br.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Cn(e,t,n){let r=Ar(t,n);if(r===null){e.removeAttribute(t);return}if(Rr(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function De(e,t){let n=X();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=vn(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(me(o)){let s=N(()=>{$(n,()=>{gt(e,o.get());});});H(e,s);}else if(typeof o=="function"){let s=N(()=>{$(n,()=>{gt(e,o());});});H(e,s);}else gt(e,o);continue}if(r==="style"){if(me(o)){let s=N(()=>{$(n,()=>{Object.assign(e.style,o.get());});});H(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(Cr.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(me(o)||typeof o=="function"){let s=r,i=N(()=>{$(n,()=>{let c=typeof o=="function"?o():o.get();xn.has(s)?e[s]=c??"":Cn(e,s,c);});});H(e,i);continue}xn.has(r)||typeof r=="symbol"?e[r]=o??"":Cn(e,r,o);}}function bn(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function yt(e,t){for(let n of t)In(e,n);}function In(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"){kn(e,t);return}if(J(t)){Rt(e,t);return}if(me(t)){kn(e,()=>t.get());return}if(Array.isArray(t)){yt(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function ne(e){let t=null,n=e;return J(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function je(e,t=true){for(let n of e)t&&Oe(n),n.remove();}function kn(e,t){let n=X(),r=document.createComment("");e.appendChild(r);let o=[],s=N(()=>{$(n,()=>{let i=t(),{nodes:c,instance:a}=ne(i);je(o),c.length&&r.after(...c),a&&queueMicrotask(()=>ge(a)),o=c;});});H(e,s);}var He=class{constructor(e){this.props=e;}};function Ln(e,t,n,r){let{equals:o=Pe,tagName:s="span",...i}=r??{},c=Ct(s,"data-for",i);De(c,i);let a=X(),l=[],u=new Map,p=W(()=>e()),m=N(()=>{let d=p.get(),E=Array.isArray(d)?d:[],C=[],y=[],G=new Set;for(let h=0;h<E.length;h++){let k=E[h],I=t(k,h);if(G.has(I)){console.error(`For: duplicate key "${String(I)}" detected; ignoring later item at index ${h}`);continue}G.add(I),C.push(k),y.push(I);}let ee=new Map(l.map(h=>[h.key,h])),j=[];for(let h=0;h<C.length;h++){let k=y[h],I=C[h],Y=ee.get(k);if(Y)u.get(k).set(I),j.push(Y),ee.delete(k);else {let Vt=z(I,{equals:o});u.set(k,Vt);let Zn={...Vt,set(){}},Ut={key:k,nodes:[]};$(a,()=>{let er=n(Zn,h),{nodes:tr,instance:qt}=ne(er);Ut.nodes=tr,qt&&queueMicrotask(()=>ge(qt));}),j.push(Ut);}}for(let[h,k]of ee)je(k.nodes),u.delete(h);let T=null;for(let h=j.length-1;h>=0;h--){let k=j[h].nodes;for(let I=k.length-1;I>=0;I--){let Y=k[I];(Y.parentNode!==c||Y.nextSibling!==T)&&c.insertBefore(Y,T),T=Y;}}l=j;});return H(c,m),c}function At(e,t,n,r){if(typeof e=="function")return Ln(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:c,children:a,...l}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=St(o),p=xt(e??{},t);return Ln(u,s,p,{...l,equals:i,tagName:c})}At[Te]=e=>e!=="each";function Mn(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=""),J(t)?Rt(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var _t=vt(),Nt=vt(),Tn=vt(),Nr=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function vt(){return Math.floor(Math.random()*16777215)}function vr(){return Nt=(Nt+1)%16777215,Nt}function x(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=vr(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,_t>>16&255,_t>>8&255,_t&255,Tn>>8&255,Tn&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Nr[n.charCodeAt(o)];return r}var It=Symbol("block-element"),Ir=Symbol("block-element-body"),O=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 Bt(e){return e?Lt(e.startContainer,It):null}function F(e){return Lt(e,It)}function wn(e){return e?Lt(e.startContainer,O):null}function Lr(e){return e?e[O]!==void 0?[e]:[...e.children].filter(t=>t[O]!==void 0):[]}function Br(e,t){return t?Lr(e).indexOf(t):-1}function he(e,t){let n=wn(t);return !n||!e?.contains(n)?null:{element:n,index:Br(e,n)}}function Pn(){return window.getSelection()}function B(){let e=Pn();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function $e(){let e=B();if(!e)return 0;e.collapse(true);let t=wn(e),n=Bt(e),r=t??K(n);return Fe(r,e.startContainer,e.startOffset)}function Fe(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,c=e.childNodes,a=Math.min(n,c.length);for(let l=0;l<a;l++)i+=c[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 Mr(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 M(e,t){let n=Mr(e,t),r=Pn();r.removeAllRanges(),r.addRange(n);}function K(e){if(!e)return null;let t=Tr(e);return t?.firstElementChild??t?.firstChild}function Ee(e){if(!e?.[It])return null;let t=K(e);return t?we(t)?.classInstance:null}function Tr(e){if(!e)return null;for(let t of e.children)if(t[Ir])return t;return null}var L="molecule.paragraph.Paragraph",ye="molecule.list.List";var Mt="molecule.headline.H1",Tt="molecule.headline.H2",wt="molecule.headline.H3",Pt="molecule.headline.H4",Ot="molecule.headline.H5",On="molecule.headline.";function g(e){return e===`
1
+ 'use strict';var nr={abortEarly:true};function it(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 rr(e,t,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)t.push(it(e.errors[r],n));}function zt(e,t,n,r){if(n!==false){let o=it(e.error,t);return {success:false,error:o,errors:[o]}}rr(e,r,t);}function Ae(e){return e?.abortEarly!==void 0?e:nr}function nt(e,t){b(e,"_parse",(n,r,o)=>{let s=n(r,o);return !s.success&&t(r)?{success:true,data:r}:s});}var ue=e=>typeof e=="string"||e instanceof String,rt=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),ot=e=>e===true||e===false,or=e=>e instanceof Date&&!Number.isNaN(e.getTime()),sr=e=>typeof e=="function",ir=e=>Array.isArray(e),st=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Wt(e,t){let n=A(st,{...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,c,a)=>{let l=i(c,a);if(!l.success)return l;let u=o(l.data,{context:a?.context});if(!st(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 c=o(s,i),{abortEarly:a}=Ae(i);if(c.success===false)return c;let l={},u=[];for(let p in e){let m=e[p]._parse(c.data[p],i);if(m.success)l[p]=m.data;else {let g=zt(m,p,a,u);if(g)return g}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:l}}),r}function ct(e){return A(ue,{...e,type:"string"})}function at(e){return A(rt,{...e,type:"number"})}function lt(e){return A(ot,{...e,type:"boolean"})}function ut(e){return A(or,{...e,type:"date"})}function Xt(e){return A(sr,{...e,type:"function"})}function Jt(e,t){let n=i=>e.includes(i),r=i=>`Invalid ${o} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${i}".`,o="enum",s=A(n,{message:r,...t,type:o});return s._getDescription=()=>`enum(${e.map(i=>`"${i}"`).join(" | ")})`,s._getDefinition=()=>e,s}function Qt(e,t){let n=A(ir,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,n._getDefinition=()=>e,b(n,"_parse",(r,o,s)=>{let i=r(o,s),{abortEarly:c}=Ae(s);if(i.success===false)return i;let a=[],l=[],u=s;for(let p=0;p<i.data.length;p++){let m={...u,context:{...u?.context,index:p}},g=e._parse(i.data[p],m);if(g.success)a.push(g.data);else {let E=zt(g,p,c,l);if(E)return E}}return l.length>0?{success:false,error:l[0],errors:l}:{success:true,data:a}}),n}function Zt(){return A(()=>true)}function te(e,t){return b(t,"_parse",(n,r,o)=>(r=e(r),n(r,o))),t}function en(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: ${st(o)?JSON.stringify(o):`"${o}"`}`,r=A(()=>false,{message:n,...t,type:"union"});return r._getDefinition=()=>e,b(r,"_parse",(o,s,i)=>{let c=i,a=[];for(let m=0;m<e.length;m++){let g=e[m]._parse(s,c);if(g.success)return g;a.push(g);}let{abortEarly:l}=Ae(c),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<a.length;m++){let g=a[m].errors;if(g?.length)for(let E=0;E<g.length;E++)g[E].cause?.key&&p.push(it(g[E],`branch ${m}`));}return p.length===0&&p.push(u),{success:false,error:p[0],errors:p}}),r}function tn(e,t){let n=A(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 nn(e){let t=A(()=>true,{type:"contextRef"});return t._getDescription=()=>`contextRef("${e}")`,b(t,"_parse",(n,r,o)=>({success:true,data:o?.context?.[e]})),t}function rn(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 on={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return te(n=>{let r;return ue(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},lt({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return te(n=>{if(ot(n))return Number(n);if(ue(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 te(n=>ot(n)||rt(n)&&Number.isFinite(n)?String(n):n,ct({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return te(n=>{let r;return ue(n)&&(r=n.trim()),rt(n)&&Number.isFinite(n)||r?new Date(r??n):n},ut({...e,message:t}))},json(e,t){let n=t?.message??(r=>`Cannot parse "${r}" as JSON.`);return b(e,"_parse",(r,o,s)=>{if(ue(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}},sn={},f={object:Wt,string:ct,number:at,boolean:lt,date:ut,function:Xt,enum:Jt,array:Qt,any:Zt,preprocess:te,union:en,literal:tn,contextRef:nn,withContext:rn,coerce:sn,cast:on};function Gt(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 A(e,{type:t="any",name:n,message:r}={}){r=r||Gt(t);let o={name:n,message:r,type:t},s={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(i,c){let a=e(i);if(a===true)return {success:true,data:i};if(typeof a=="object"&&a?.success===true)return a;let l={message:typeof r=="function"?r(i):r};return {success:false,error:l,errors:[l]}},parse(i,c){let a=this._parse(i,c);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(i,c){return this._parse(i,c)},transform(i){return b(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success&&(u.data=i(u.data)),u}),this},optional(){return nt(this,i=>i===void 0),this},nullable(){return nt(this,i=>i===null),this},nullish(){return nt(this,i=>i==null),this},default(i){return b(this,"_parse",(c,a,l)=>(a===void 0&&(a=typeof i=="function"?i({context:l?.context}):i),c(a,l))),this},catch(i){return b(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success?u:{success:true,data:typeof i=="function"?i({input:a,error:u.error}):i}}),this},pipe(i){return b(this,"_parse",(c,a,l)=>{let u=c(a,l);return u.success?i._parse(u.data,l):u}),this},refine(i,{message:c,type:a,jsonSchema:l}={}){if(a&&(c=c||Gt(a),t=a),l){let u=[...this._getJsonSchemaHints?.()??[],l];this._getJsonSchemaHints=()=>u;}return b(this,"_parse",(u,p,m)=>{let g=u(p,m),{abortEarly:E}=Ae(m);if(!g.success)return g;let C=i(g.data);if(C===true||typeof C=="object"&&C?.success===true)return g;let y={message:typeof c=="function"?c(p):c};return {success:false,error:y,errors:[y]}}),this},clone(){return {...this}}};return Yt.length>0?Yt.reduce((i,c)=>c(i,e,o)??i,s):s}var Yt=[];var cn=class{next(...e){}error(...e){}complete(...e){}},ft=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 _e=Symbol("@esmj/signals:type"),fe=Symbol("@esmj/signals:name");var _=null,pt=false,mt=[];function R(e){let t=_;_=null;let n=e();return _=t,n}function lr(){pt=false;let e=fn();for(let n of e)n.get();let t=mt;mt=[];for(let n of t)n();}function an(){pt||(pt=true,queueMicrotask(lr));}function gt(e){mt.push(e),an();}var ln=Symbol("@esmj/signals:internal observable"),w=Symbol("@esmj/signals:original function"),ur=class extends ft{#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=()=>R(()=>{this.#e.add(e),this.#r();}),e.next[w]=void 0),e instanceof gn&&e.next[w]===void 0){let t=e.next.bind(e);e.next=()=>R(()=>{this.#e.add(e),t(),this.#r();}),e.next[w]=t;}return this.subscribe(e)}getPending(){let e=[];for(let t of this.#e){if(!t.get[w]){let n=t.get,r=n.bind(t);t.get=()=>R(()=>(this.#e.delete(t),r())),t.get[w]=n;}e.push(t);}return e}unwatch(e){return e.next=e.next[w]?e.next[w]:e.next,e.get=e.get[w]?e.get[w]:e.get,this.#e.delete(e),this.unsubscribe(e)}},Ne=null;function un(e){Ne=new ur(e);}un(()=>{an();});function fn(){return Ne.getPending()}function pn(e){return Ne.watch(e)}function mn(e){return Ne.unwatch(e)}var P=Symbol("@esmj/signals:no error"),gn=class dn extends cn{#e=true;#r=false;#t=null;#o=this.#p();#l=null;#a=null;#i=0;#s=new Map;#n=P;constructor(t,n){super(),this.#l=t,this.#a=n,this.debug=n?.debug,this[_e]="computed",this[fe]=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[fe],dirty:this.#e,revision:this.#i,sourceDependencies:[...this.#s.keys()]}}#f(){for(let[t,n]of this.#s)if(t instanceof dn&&R(()=>t.get()),t.getRevision()!==n)return true;return false}next(){this.#e=true,this.#t[ln].next();}get(){if(this.#r)throw new Error("Cycle detected in computed signal");if(this.#t||(this.#t=z(this.#c(),this.#a)),(this.#e||this.#n!==P)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),_&&_.sourceRevisions.set(this,this.#i),this.#n!==P)throw this.#n;return this.#t.get()}peek(){if(this.#t||(this.#t=z(this.#c(),this.#a)),(this.#e||this.#n!==P)&&(this.#s.size===0||this.#f()?this.#c():this.#e=false),this.#n!==P)throw this.#n;return this.#t.peek()}#c(){this.#r=true,this.#e=false,this.#n=P,this.#u(),this.#o.sourceRevisions.clear();let t=_;_=this.#o;let n;try{n=this.#l();}catch(r){this.#n=r;}return _=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 W(e,t){return new gn(e,t)}function N(e,t){let n,{debug:r,...o}={},s=W(()=>{n?.(),n=e();},{equals:()=>false,...o});s.get(),pn(s);let i=()=>{n?.(),s.destroy(),mn(s);};return i[Symbol.dispose]=i,i[_e]="effect",i[fe]=r??null,i.__RX_COMPUTED__=s,i}function z(e,t={}){let n=t?.equals??Object.is,r=0,o=new ft;function s(){return _&&(_.dependencies.set(o,o.subscribe(_.observer)),_.sourceRevisions.set(l,r)),e}function i(){return e}function c(u){if(!n(e,u)){e=u,r++,o.next();}return e}function a(){return r}let l={get:s,set:c,peek:i,getRevision:a,[ln]:o,[_e]:"signal",[fe]:t?.debug??null};return l}function Ie(){return Date.now().toString(32).substring(5)+Math.random().toString(32).substring(2)}var Rn=Symbol("node-component"),ve=Symbol("node-internal"),fr=Symbol("keep-literal"),Te=Symbol("raw-props");function St(e){return typeof e=="function"?e:e!=null&&typeof e.get=="function"?()=>e.get():()=>e}function xt(e,t){let n=e.children!==void 0?e.children:t;return Array.isArray(n)?n[0]:n}var pr=new Set(["template","script"]);function mr(e,t){let n=(e==null?"span":String(e)).trim(),r=n;pr.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,Ie()),o}function Ct(e,t,n){let r=mr(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,c){if(Reflect.has(s,i))return Reflect.get(s,i,c);if(!t)return;let a=t[i];return typeof a=="function"?a.bind(t):a},set(s,i,c,a){return Reflect.has(s,i)||!t?Reflect.set(s,i,c,a):(t[i]=c,true)},has(s,i){return Reflect.has(s,i)||!!t&&i in t}})}var An=null;function X(){return An}function Be(e){An=e;}function we(e){return e?.[Rn]||null}function hn(e,t){e[Rn]=t;}function Le(e,t={disposers:[],id:Ie()}){return e?.[ve]?e[ve]:(e&&(e[ve]=t),t)}function gr(e){return e[ve]}function H(e,t){let n=gr(e);n||(n=Le(e)),n.disposers.push(t);}function ht(e,t,n){e.has(t)||e.set(t,[]),e.get(t).push(n);}function $(e,t){let n=X();Be(e);try{return t()}finally{Be(n);}}var Et=new Map,Me=new Map,En=new Map;function _n(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?.[fr]?r[o]=s():s!=null&&typeof s.get=="function"?r[o]=s:typeof s=="function"?r[o]=W(s):r[o]=z(s);}return r}function Pe(e,t){if(e===t)return true;if(e==null||t==null||typeof e!="object"||typeof t!="object")return false;let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?false:n.every(o=>{let s=Object.getOwnPropertyDescriptor(e,o),i=Object.getOwnPropertyDescriptor(t,o);if(!s||!i)return false;let c="value"in s?s.value:s.get?.call(e),a="value"in i?i.value:i.get?.call(t);return Pe(c,a)})}function kt(e){return {id:Symbol("context-id"),defaultValue:e}}function ge(e){let t=X();return t?.contexts?.has(e.id)?t.contexts.get(e.id):e.defaultValue}function I(e){gt(()=>{setTimeout(e,0);});}function de(e){let t=e.componentId,n=Et.get(t);if(n){Et.delete(t);for(let r of n){let o=r();typeof o=="function"&&ht(Me,t,o);}}}function dr(e){let t=Me.get(e);if(t){Me.delete(e);for(let n of t)n();}}function hr(e){let t=En.get(e);if(t){En.delete(e);for(let n of t)n();}}function Oe(e){if(!e)return;let t=Le(e);if(t?.disposers?.length){for(let r of t.disposers)try{r();}catch(o){console.error("[esmj-dom] cleanupTree: disposer threw, cleanup continues",o);}t.disposers=[];}let n=we(e);if(n&&(dr(n.componentId),hr(n.componentId)),e.childNodes){let r=e.firstChild;for(;r;){let o=r.nextSibling;Oe(r),r=o;}}}function J(e){return e!=null&&typeof e=="object"&&typeof e.$constructor=="function"}function yn(e){return typeof e=="function"&&typeof e.prototype?.render=="function"}function Er(e,t,n){let r=Ie(),o={componentId:r,$children:n,element:null,classInstance:null,$constructor(){let s=yn(e)?void 0:e[Te],i={..._n(t??{},s),children:n},c=X(),a={disposers:[],id:r,contexts:new Map(c?.contexts)};Be(a);let l;if(yn(e)){o.ClassConstructor=e;let p=new e(i);o.classInstance=p,typeof p.onMount=="function"&&ht(Et,r,()=>{p.onMount?.();}),typeof p.onUnmount=="function"&&ht(Me,r,()=>{p.onUnmount?.();}),l=p.render();}else l=e(i);Be(c);let u=yr(l);if(o.element=u,u instanceof DocumentFragment&&u.childNodes.length)for(let p of u.childNodes)Le(p,a),hn(p,o);else Le(u,a),u instanceof Node&&hn(u,o);return u}};return o}function Rt(e,t){let n=t.$constructor();n instanceof Node&&e.appendChild(n),queueMicrotask(()=>{de(t);});}function yr(e){return e instanceof Node?e:J(e)?e.$constructor():typeof e=="string"||typeof e=="number"?document.createTextNode(String(e)):document.createTextNode("")}var Sn={className:"class",htmlFor:"for"},xn=new Set(["value","defaultValue","checked","selected","indeterminate"]),Sr=new Set(["srcdoc"]),xr=new Set(["href","src","action","formaction","xlink:href"]),Cr=new Set(["securitypolicyviolation"]),br=new Set(["contenteditable","draggable","spellcheck"]);function me(e){return e!=null&&typeof e=="object"&&typeof e.get=="function"&&!(e instanceof Node)}var Nn=Symbol("Fragment");function S(e,t,n){if(e===Nn){let o=document.createDocumentFragment();return yt(o,bn(n)),o}if(typeof e=="function")return Er(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),De(r,t),yt(r,bn(n)),r}function dt(e,t){t instanceof DocumentFragment?e.replaceChildren(t):e.innerHTML=t??"";}function kr(e){return typeof e!="string"?false:e.replace(/[\p{White_Space}\p{Cc}]+/gu,"").toLowerCase().startsWith("javascript:")}function Rr(e,t){if(typeof e!="string")return false;let n=e.toLowerCase();return Sr.has(n)?true:xr.has(n)&&t!==null&&t!==void 0&&kr(String(t))}function In(e){return typeof e!="string"?e:Sn[e]?Sn[e]:e}function Ar(e,t){let n=In(e),r=typeof n=="string"?n.toLowerCase():String(n).toLowerCase();return br.has(r)&&(t===true||t===false||t==="true"||t==="false")?String(t):t==null||t===false?null:t}function Cn(e,t,n){let r=Ar(t,n);if(r===null){e.removeAttribute(t);return}if(Rr(t,r)){e.removeAttribute(t),console.warn(`[esmj-dom] Blocked unsafe attribute "${String(t)}" on <${e.tagName.toLowerCase()}>`);return}e.setAttribute(t,r);}function De(e,t){let n=X();for(let[r,o]of Reflect.ownKeys(t).map(s=>[s,t[s]]))if(r!=="id"){if(r=In(r),r==="$ref"){typeof o=="function"?o(e):typeof o=="object"&&o!==null&&(o.current=e);continue}if(r==="$dangerouslySetInnerHTML"){if(me(o)){let s=N(()=>{$(n,()=>{dt(e,o.get());});});H(e,s);}else if(typeof o=="function"){let s=N(()=>{$(n,()=>{dt(e,o());});});H(e,s);}else dt(e,o);continue}if(r==="style"){if(me(o)){let s=N(()=>{$(n,()=>{Object.assign(e.style,o.get());});});H(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(Cr.has(s)){console.warn(`[esmj-dom] Blocked unsafe event binding "${r}" on <${e.tagName.toLowerCase()}>`);continue}e.addEventListener(s,o);continue}if(me(o)||typeof o=="function"){let s=r,i=N(()=>{$(n,()=>{let c=typeof o=="function"?o():o.get();xn.has(s)?e[s]=c??"":Cn(e,s,c);});});H(e,i);continue}xn.has(r)||typeof r=="symbol"?e[r]=o??"":Cn(e,r,o);}}function bn(e){return e==null?[]:Array.isArray(e)?e.flat(Number.POSITIVE_INFINITY):[e]}function yt(e,t){for(let n of t)vn(e,n);}function vn(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"){kn(e,t);return}if(J(t)){Rt(e,t);return}if(me(t)){kn(e,()=>t.get());return}if(Array.isArray(t)){yt(e,t);return}e.appendChild(document.createTextNode(String(t)));}}function ne(e){let t=null,n=e;return J(e)&&(t=e,n=e.$constructor()),n instanceof DocumentFragment?{nodes:Array.from(n.childNodes),instance:t}:n instanceof Node?{nodes:[n],instance:t}:n==null||n===false||n===true?{nodes:[],instance:t}:{nodes:[document.createTextNode(String(n))],instance:t}}function je(e,t=true){for(let n of e)t&&Oe(n),n.remove();}function kn(e,t){let n=X(),r=document.createComment("");e.appendChild(r);let o=[],s=N(()=>{$(n,()=>{let i=t(),{nodes:c,instance:a}=ne(i);je(o),c.length&&r.after(...c),a&&queueMicrotask(()=>de(a)),o=c;});});H(e,s);}var He=class{constructor(e){this.props=e;}};function Bn(e,t,n,r){let{equals:o=Pe,tagName:s="span",...i}=r??{},c=Ct(s,"data-for",i);De(c,i);let a=X(),l=[],u=new Map,p=W(()=>e()),m=N(()=>{let g=p.get(),E=Array.isArray(g)?g:[],C=[],y=[],G=new Set;for(let h=0;h<E.length;h++){let k=E[h],v=t(k,h);if(G.has(v)){console.error(`For: duplicate key "${String(v)}" detected; ignoring later item at index ${h}`);continue}G.add(v),C.push(k),y.push(v);}let ee=new Map(l.map(h=>[h.key,h])),j=[];for(let h=0;h<C.length;h++){let k=y[h],v=C[h],Y=ee.get(k);if(Y)u.get(k).set(v),j.push(Y),ee.delete(k);else {let Vt=z(v,{equals:o});u.set(k,Vt);let Zn={...Vt,set(){}},Ut={key:k,nodes:[]};$(a,()=>{let er=n(Zn,h),{nodes:tr,instance:qt}=ne(er);Ut.nodes=tr,qt&&queueMicrotask(()=>de(qt));}),j.push(Ut);}}for(let[h,k]of ee)je(k.nodes),u.delete(h);let T=null;for(let h=j.length-1;h>=0;h--){let k=j[h].nodes;for(let v=k.length-1;v>=0;v--){let Y=k[v];(Y.parentNode!==c||Y.nextSibling!==T)&&c.insertBefore(Y,T),T=Y;}}l=j;});return H(c,m),c}function At(e,t,n,r){if(typeof e=="function")return Bn(e,t,n,r);let{each:o,keyFn:s,equals:i,tagName:c,children:a,...l}=e??{};if(typeof s!="function")throw new Error('For: "keyFn" prop is required and must be a function');let u=St(o),p=xt(e??{},t);return Bn(u,s,p,{...l,equals:i,tagName:c})}At[Te]=e=>e!=="each";function Mn(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=""),J(t)?Rt(e,t):t instanceof Node?e.appendChild(t):e.appendChild(document.createTextNode(String(t)));}var _t=It(),Nt=It(),Tn=It(),Nr=Array.from({length:256},(e,t)=>(t<=15?"0":"")+t.toString(16));function It(){return Math.floor(Math.random()*16777215)}function Ir(){return Nt=(Nt+1)%16777215,Nt}function x(){let e=Math.floor(Date.now()/1e3);e=parseInt(e,10)%4294967295;let t=Ir(),n=String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,e&255,_t>>16&255,_t>>8&255,_t&255,Tn>>8&255,Tn&255,t>>16&255,t>>8&255,t&255),r="";for(let o=0;o<n.length;o++)r+=Nr[n.charCodeAt(o)];return r}var vt=Symbol("block-element"),vr=Symbol("block-element-body"),O=Symbol("selectable-element");function Bt(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 Lt(e){return e?Bt(e.startContainer,vt):null}function F(e){return Bt(e,vt)}function wn(e){return e?Bt(e.startContainer,O):null}function Br(e){return e?e[O]!==void 0?[e]:[...e.children].filter(t=>t[O]!==void 0):[]}function Lr(e,t){return t?Br(e).indexOf(t):-1}function he(e,t){let n=wn(t);return !n||!e?.contains(n)?null:{element:n,index:Lr(e,n)}}function Pn(){return window.getSelection()}function L(){let e=Pn();return e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function $e(){let e=L();if(!e)return 0;e.collapse(true);let t=wn(e),n=Lt(e),r=t??K(n);return Fe(r,e.startContainer,e.startOffset)}function Fe(e,t,n){if(!e)return 0;if(t===e){if(t.nodeType===Node.TEXT_NODE)return n;let i=0,c=e.childNodes,a=Math.min(n,c.length);for(let l=0;l<a;l++)i+=c[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 Mr(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 M(e,t){let n=Mr(e,t),r=Pn();r.removeAllRanges(),r.addRange(n);}function K(e){if(!e)return null;let t=Tr(e);return t?.firstElementChild??t?.firstChild}function Ee(e){if(!e?.[vt])return null;let t=K(e);return t?we(t)?.classInstance:null}function Tr(e){if(!e)return null;for(let t of e.children)if(t[vr])return t;return null}var B="molecule.paragraph.Paragraph",ye="molecule.list.List";var Mt="molecule.headline.H1",Tt="molecule.headline.H2",wt="molecule.headline.H3",Pt="molecule.headline.H4",Ot="molecule.headline.H5",On="molecule.headline.";function d(e){return e===`
2
2
  `||e===`\r
3
3
  `?"":e??""}function Q({component:e,originComponent:t,properties:n,settings:r}={}){let o=n??{},s=Array.isArray(o.items)?o.items:[{text:o.text??"",inlineStyleRanges:o.inlineStyleRanges??[],entityRanges:o.entityRanges??[]}];return {...e?{component:e}:{},...t?{originComponent:t}:{},properties:{items:s},...r?{settings:r}:{}}}function $n(e){let t="",n=[],r=[];return (e??[]).forEach((o,s)=>{s>0&&(t+=`
4
- `);let i=t.length;t+=g(o?.text);for(let c of o?.inlineStyleRanges??[])n.push({...c,offset:c.offset+i});for(let c of o?.entityRanges??[])r.push({...c,offset:c.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function D(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function Fn({mrakomor:e,resultIndex:t,cursor:n,fallbackBlockElement:r,itemIndex:o}){let s=()=>{if(typeof n!="number")return;let i=e._getBlockElements()[t]??r,c=Ee(i);if(c?.setCursor){c.setCursor({cursor:n,itemIndex:o});return}let a=K(i);a?.isConnected&&M(a,n);};s(),v(s);}function Dt(e){let t=e?.component??"";return t===L||t.startsWith(On)}function Ke(e){return Array.isArray(e?.properties?.items)}function wr(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 Dn(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function Pr(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let c=r.find(a=>a.match(i));c&&(s=S(c,{},s));}for(let i of n){let c=o.find(a=>a.match(i));c&&(s=S(c,i,s));}return s}function oe(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 c=wr([...s,...i],o.length);for(let a=0;a<c.length-1;a+=1){let l=c[a],u=c[a+1];if(l>=u)continue;let p=o.slice(l,u),m=Pr(p,Dn(s,l,u),Dn(i,l,u),{inlineStyleComponents:t,entityRangeComponents:n});Mn(r,m);}return r}function re(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let c=r.find(l=>l.match(i));if(c){let l=i.textContent.length;t.properties.inlineStyleRanges.push({style:c.style,offset:s,length:l}),s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let a=o.find(l=>l.match(i));if(a){let l=i.textContent.length;t.properties.entityRanges.push({...a.getStateSchema(i).parse(),offset:s,length:l}),s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function Se(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 jn(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Hn(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 jt(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=jn(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Hn(e.properties.inlineStyleRanges,t),n.properties.entityRanges=jn(e.properties.entityRanges,t),r.properties.entityRanges=Hn(e.properties.entityRanges,t),r.componentId=x(),{originalLineState:n,newLineState:r}}function Ve(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=jt(e.getState(),$e(e.element));return e.mrakomor.command.insertBlockElement({range:B(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}function Ue(e,t){let n=e.constructor;if(!t)return n.getStateSchema(t).parse();let r=structuredClone(n.getStateSchema(t).parse());return re(t.childNodes,r,0,{inlineStyleComponents:e.getInlineStyleComponents(),entityRangeComponents:e.getEntityRangeComponents()}),r.properties.text=g(r.properties.text),r}(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}
5
- `,document.head.appendChild(n);}}})();var xe={KEYDOWN:"mrakomor:keydown",INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var qe=kt();var Ge=class extends He{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=de(qe),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(xe.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var V=class extends Ge{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:t}={}){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:g(this.getState()?.properties?.text).length;M(this.element,r);};n(),v(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:g(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),Q({originComponent:this.NAMESPACE,properties:{items:[r]},settings:t?.settings})}static fromExchangeState(t){let n=t?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:t?.settings}}static appendExchangeState(t,n){let r=$n(n?.properties?.items);return Se(t,D(r))}};function Ye(){return f.object({length:f.number(),offset:f.number(),style:f.string()})}function Z({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),c=r??(o?0:void 0);return f.object({entity:o?s.default({}):s,length:i==null?f.number():f.number().default(i),offset:c==null?f.number():f.number().default(c)})}function se(){return f.array(Z()).transform(e=>e.filter(t=>t.entity.type==="atom.tts.Voice")).default([])}function U(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")||x()),properties:f.object(n).default({}),settings:r}).default({})}var ze=class extends V{constructor(t){super(t),this._level=1;}static getStateSchema(t){return U(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 S(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[O]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return g(r)?R(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}Ve(this,t,{namespace:L});}#e(t){if(!B()?.collapsed)return;let r=F(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=K(s);i?.isConnected&&M(i,0);};o(),v(o);}};var q=class extends ze{static getStateSchema(t){return U(t,{component:this.NAMESPACE,properties:{text:f.string().default(t?.textContent??t?.innerText??""),entityRanges:se()}})}getInlineStyleComponents(){return []}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}parseFromHTML(t){return Ue(this,t)}_buildContent(t){return oe(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}},We=class extends q{static get NAMESPACE(){return Mt}static get LABEL(){return "H1"}constructor(t){super(t),this._level=1;}},Ce=class extends q{static get NAMESPACE(){return Tt}static get LABEL(){return "H2"}constructor(t){super(t),this._level=2;}},be=class extends q{static get NAMESPACE(){return wt}static get LABEL(){return "H3"}constructor(t){super(t),this._level=3;}},ke=class extends q{static get NAMESPACE(){return Pt}static get LABEL(){return "H4"}constructor(t){super(t),this._level=4;}},Xe=class extends q{static get NAMESPACE(){return Ot}static get LABEL(){return "H5"}constructor(t){super(t),this._level=5;}};function Or(){return {resolveConfig:e=>(e.blockComponents.push(Ce,be,ke),e),resolveComponent:e=>{if(e===We.NAMESPACE)return We;if(e===Ce.NAMESPACE)return Ce;if(e===be.NAMESPACE)return be;if(e===ke.NAMESPACE)return ke;if(e===Xe.NAMESPACE)return Xe}}}(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}
6
- `,document.head.appendChild(n);}}})();function Kn(e,t,n){let r=e._getBlockElementIndex(t);if(r===-1)return false;let o=e.getContent();return o.splice(r,1,e.normalizeComponentState(n)),e._setContentState(o),true}function Je(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function ie(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=x();return t.add(r),{...n,componentId:r}})}function Un(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function Ht(e,t){return !e||!t?0:Fe(e,t.startContainer,t.startOffset)}function qn(e,t){let n=D(e),{originalLineState:r,newLineState:o}=jt(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:x(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function Gn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:o?.componentId??x(),depth:o?.depth??0,text:g(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:x(),depth:0,text:g(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:ye,componentId:x(),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),c=o.slice(t+1),a=Q({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),l={component:n,componentId:x(),settings:{},...r?.fromExchangeState(a)??D(s)},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(l),c.length&&u.push({...e,componentId:i.length?x():e.componentId,properties:{...e.properties,items:c}}),{blocks:u,paragraphIndex:i.length?1:0}}function Vn(e){return Ke(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function Ft(e,t){let n=Vn(e),r=Vn(t);return n!=null&&n===r}function Yn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!Ft(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let m=[...e];m.splice(n,1);let d=s.length-1,E=d>=0?g(s[d]?.text).length:0;return {content:m,listIndex:t,cursor:E}}let[c,...a]=i,l=0;if(s.length===0)s.push(c,...a),l=0;else {let m=s.length-1,d=s[m],E=D(d),C=D(c),{state:y,cursor:G}=Se(E,C);s[m]={...d,text:y.properties.text,inlineStyleRanges:y.properties.inlineStyleRanges,entityRanges:y.properties.entityRanges},a.length&&s.push(...a),l=G;}let u={...r,properties:{...r.properties,items:ie(s)}},p=[...e];return p[t]=u,p.splice(n,1),{content:p,listIndex:t,cursor:l}}function zn(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=Q({properties:t?.properties}).properties.items,[s,...i]=o,c=n[r],a=D(c),l=D(s),{state:u,cursor:p}=Se(a,l),m=n.map((d,E)=>E===r?{...d,text:u.properties.text,inlineStyleRanges:u.properties.inlineStyleRanges,entityRanges:u.properties.entityRanges}:d);return i.length&&m.push(...i.map(d=>({componentId:d?.componentId??x(),depth:d?.depth??0,text:g(d?.text??""),inlineStyleRanges:d?.inlineStyleRanges??[],entityRanges:d?.entityRanges??[]}))),{state:{...e,properties:{...e.properties,items:ie(m)}},cursor:p,itemIndex:r}}function Wn(e,t){return oe({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function Xn(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:g(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return re(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 Qe=e=>f.object({componentId:f.string().default(()=>e?.getAttribute?.("data-componentid")||x()),depth:f.number().default(0),text:f.string().default(""),inlineStyleRanges:f.array(Ye()).default([]),entityRanges:f.array(Z()).default([])}).default({}),Re=class e extends V{static get NAMESPACE(){return ye}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=Je(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||x()),properties:f.object({items:f.array(Qe()).default([Qe().parse()]).transform(ie)}).default({}),settings:f.object({style:f.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(o=>{let s={componentId:o?.componentId,text:g(o?.text),depth:o?.depth??0};return o?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=o.inlineStyleRanges),o?.entityRanges!==void 0&&(s.entityRanges=o.entityRanges),s});return Q({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return Gn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return zn(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=Un(t);if(o.length)n.properties.items=o.map(s=>Qe(s).parse(Xn(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[Qe().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}_commitState(t){let n=F(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId);Kn(this.mrakomor,n,t);}_buildItemContent(t){return Wn(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=At(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>S("li",{contentEditable:true,[O]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let c=s.get()?.componentId,l=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===c);return String(l>=0?l:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let c=s.get(),a=c?.text??"";return g(a)?R(()=>this._buildItemContent(c)):"<br>"}}),{tagName:r});return o.className=t,n.componentId&&o.setAttribute("data-componentid",n.componentId),this.element=o,o}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor({cursor:t,itemIndex:n}={}){let r=this.getState()?.properties?.items??[],o=r.length-1;if(o<0)return;let s=typeof n=="number"&&n>=0&&n<=o?n:o,i=typeof t=="number"?t:g(r[s]?.text).length,c=()=>{let a=this.element?.querySelector(`li[data-item-index="${s}"]`);a?.isConnected&&M(a,i);};c(),v(c);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],o=r[t];if(!o)return;if((o.depth??0)>0){r[t]={...o,depth:o.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let p=()=>{let m=this.element?.querySelector(`li[data-item-index="${t}"]`);m?.isConnected&&M(m,0);};p(),v(p);return}let s=F(this.element),i=this.mrakomor._getBlockElementIndex(s),c=s?.previousElementSibling??null,a=c?this.mrakomor._getBlockElementIndex(c):-1;if(t===0&&a>=0&&i===a+1){let p=this.mrakomor.getContent(),m=Yn(p,a,i);if(m){let d=m.content.map((E,C)=>C===m.listIndex?this.mrakomor.normalizeComponentState(E):E);this.mrakomor._setContentState(d),Ee(c)?.setCursor?.({cursor:m.cursor});return}}let{blocks:l,paragraphIndex:u}=$t(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(L)});this.mrakomor.command.replaceBlockElement({blockElement:F(this.element),blocks:l,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=B(),r=he(this.element,n);if(!r)return;let{element:o,index:s}=r,i=Ht(o,n),c=this.getState(),a=[...c.properties.items??[]],l=a[s];if(!l)return;if(!g(l.text)){this.#e(s);return}let{before:u,after:p}=qn(l,i);a.splice(s,1,u,p),this._commitState({...c,properties:{...c.properties,items:a}}),v(()=>{let m=this.element?.querySelector(`li[data-item-index="${s+1}"]`);m&&M(m,0);});}#t(t){let n=B();if(!n?.collapsed)return;let r=he(this.element,n);if(!r){let c=n.startContainer;if(!(c===this.element||this.element?.contains?.(c)))return;t.preventDefault(),this.#e(0);return}let{element:o,index:s}=r;Ht(o,n)===0&&(t.preventDefault(),this.#e(s));}};function Dr(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!Dt({component:r})||!Ke(o))return;e.preventDefault();let i=Ee(n)?.element,c=e.range??B(),a=he(i,c);if(!a)return;let{index:l}=a,{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 jr(e){if(e.key!=="Backspace")return;let t=B();if(!t?.collapsed)return;let n=Bt(t);if(!n)return;let r=K(n),o=!g(r?.textContent),s=t.startOffset===0||$e()===0||o;if(!o||!s)return;let i=n.previousSibling;if(!i)return;let{mrakomor:c}=e,a=c._getBlockElementIndex(n),l=c._getBlockElementIndex(i);if(a<0||l<0)return;let u=c._getBlockElementState(n),p=c._getBlockElementState(i);if(!u||!Dt(u)||!p||p.component!==ye)return;let m=c.getContent(),d=m[a+1];if(!Ft(p,d))return;let C=c.register.blocks.getByNamespace(d.component)?.toExchangeState?.(d),y=C&&Re.appendExchangeState(p,C);y&&(e.preventDefault(),m.splice(a,1),m.splice(l,2,c.normalizeComponentState(y.state)),c._setContentState(m),Fn({mrakomor:c,resultIndex:l,cursor:y.cursor,fallbackBlockElement:i,itemIndex:y.itemIndex}));}function Jn(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(xe.TRANSFORM_BLOCK_ELEMENT,Dr),t.emitter.on(xe.KEYDOWN,jr);}}}var Qn=e=>f.object({componentId:f.string().default(()=>x()),depth:f.number().default(0),text:f.string().default(""),entityRanges:se()}).default({}),Ze=class e extends Re{static getStateSchema(t){let n=Je(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||x()),properties:f.object({items:f.array(Qn()).default([Qn().parse()]).transform(ie)}).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 Hr(){return Jn(Ze)}(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 et=class e extends V{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 U(t,{component:e.NAMESPACE,properties:{entityRanges:f.array(Z()).default([]),inlineStyleRanges:f.array(Ye()).default([]),text:f.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return Ue(this,t)}_buildContent(t){return oe(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return S("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[O]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return g(r)?R(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){Ve(this,t);}};var ce=class e extends et{static getStateSchema(t){return U(t,{component:e.NAMESPACE,properties:{entityRanges:se(),text:f.string().default(t?.innerText??t?.textContent??"")}})}getInlineStyleComponents(){return []}};function $r(){return {resolveConfig:e=>(e.blockComponents.push(ce),e),resolveComponent:e=>{if(e===ce.NAMESPACE)return ce}}}var tt=class extends He{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=de(qe),this.element=bt();}render(){return S(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}
4
+ `);let i=t.length;t+=d(o?.text);for(let c of o?.inlineStyleRanges??[])n.push({...c,offset:c.offset+i});for(let c of o?.entityRanges??[])r.push({...c,offset:c.offset+i});}),{text:t,inlineStyleRanges:n,entityRanges:r}}function D(e){return {properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}}}function Fn({mrakomor:e,resultIndex:t,cursor:n,fallbackBlockElement:r,itemIndex:o}){let s=()=>{if(typeof n!="number")return;let i=e._getBlockElements()[t]??r,c=Ee(i);if(c?.setCursor){c.setCursor({cursor:n,itemIndex:o});return}let a=K(i);a?.isConnected&&M(a,n);};s(),I(s);}function Dt(e){let t=e?.component??"";return t===B||t.startsWith(On)}function Ke(e){return Array.isArray(e?.properties?.items)}function wr(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 Dn(e,t,n){return e.filter(r=>r.offset<=t&&r.offset+r.length>=n)}function Pr(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=e;for(let i of t){let c=r.find(a=>a.match(i));c&&(s=S(c,{},s));}for(let i of n){let c=o.find(a=>a.match(i));c&&(s=S(c,i,s));}return s}function oe(e,{inlineStyleComponents:t,entityRangeComponents:n}){let r=document.createDocumentFragment(),o=d(e.properties.text),s=e.properties.inlineStyleRanges??[],i=e.properties.entityRanges??[];if(!o)return r;let c=wr([...s,...i],o.length);for(let a=0;a<c.length-1;a+=1){let l=c[a],u=c[a+1];if(l>=u)continue;let p=o.slice(l,u),m=Pr(p,Dn(s,l,u),Dn(i,l,u),{inlineStyleComponents:t,entityRangeComponents:n});Mn(r,m);}return r}function re(e,t,n,{inlineStyleComponents:r,entityRangeComponents:o}){let s=n;for(let i of e){if(i.nodeType===Node.TEXT_NODE){s+=i.textContent.length;continue}if(i.nodeType!==Node.ELEMENT_NODE||i.nodeName==="BR")continue;let c=r.find(l=>l.match(i));if(c){let l=i.textContent.length;t.properties.inlineStyleRanges.push({style:c.style,offset:s,length:l}),s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}let a=o.find(l=>l.match(i));if(a){let l=i.textContent.length;t.properties.entityRanges.push({...a.getStateSchema(i).parse(),offset:s,length:l}),s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});continue}s=re(i.childNodes,t,s,{inlineStyleComponents:r,entityRangeComponents:o});}return s}function Se(e,t){let n=d(e.properties.text),r=d(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 jn(e,t){return (e??[]).filter(n=>n.offset<t).map(n=>({...n,length:Math.min(n.length,t-n.offset)}))}function Hn(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 jt(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=jn(e.properties.inlineStyleRanges,t),r.properties.inlineStyleRanges=Hn(e.properties.inlineStyleRanges,t),n.properties.entityRanges=jn(e.properties.entityRanges,t),r.properties.entityRanges=Hn(e.properties.entityRanges,t),r.componentId=x(),{originalLineState:n,newLineState:r}}function Ve(e,t,{namespace:n=e.constructor.NAMESPACE}={}){if(t.key!=="Enter")return false;t.preventDefault();let{originalLineState:r,newLineState:o}=jt(e.getState(),$e(e.element));return e.mrakomor.command.insertBlockElement({range:L(),cursor:0,newLineState:o,originalLineState:r,namespace:n}),true}function Ue(e,t){let n=e.constructor;if(!t)return n.getStateSchema(t).parse();let r=structuredClone(n.getStateSchema(t).parse());return re(t.childNodes,r,0,{inlineStyleComponents:e.getInlineStyleComponents(),entityRangeComponents:e.getEntityRangeComponents()}),r.properties.text=d(r.properties.text),r}(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}
5
+ `,document.head.appendChild(n);}}})();var xe={KEYDOWN:"mrakomor:keydown",INPUT:"mrakomor:input",TRANSFORM_BLOCK_ELEMENT:"mrakomor:transform-block-element"};var qe=kt();var Ge=class extends He{state;element;mrakomor;constructor(t){super(t);let{state:n,observeDOMChanges:r=true}=t??{};this.state=n,this.element=null,this.mrakomor=ge(qe),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(xe.INPUT,this._onInputMarkStale)));}onUnmount(){this._observer&&(this._observer.disconnect(),this._observer=null),this._offInputStale?.(),this._offInputStale=null,this._onInputMarkStale=null,this._stale=false;}};var V=class extends Ge{static get NAMESPACE(){return "namespace.block.BlockComponent"}static get LABEL(){return ""}static get KEYWORDS(){return []}static get GROUP(){return "blocks"}isAtomic(){return false}setCursor({cursor:t}={}){let n=()=>{if(!this.element?.isConnected)return;let r=typeof t=="number"?t:d(this.getState()?.properties?.text).length;M(this.element,r);};n(),I(n);}onKeydown(t){}static toExchangeState(t){let n=t?.properties,r={text:d(n?.text)};return n?.inlineStyleRanges!==void 0&&(r.inlineStyleRanges=n.inlineStyleRanges),n?.entityRanges!==void 0&&(r.entityRanges=n.entityRanges),Q({originComponent:this.NAMESPACE,properties:{items:[r]},settings:t?.settings})}static fromExchangeState(t){let n=t?.properties?.items?.[0];return {properties:{text:n?.text??"",inlineStyleRanges:n?.inlineStyleRanges??[],entityRanges:n?.entityRanges??[]},settings:t?.settings}}static appendExchangeState(t,n){let r=$n(n?.properties?.items);return Se(t,D(r))}};function Ye(){return f.object({length:f.number(),offset:f.number(),style:f.string()})}function Z({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),c=r??(o?0:void 0);return f.object({entity:o?s.default({}):s,length:i==null?f.number():f.number().default(i),offset:c==null?f.number():f.number().default(c)})}function se(){return f.array(Z()).transform(e=>e.filter(t=>t.entity.type==="atom.tts.Voice")).default([])}function U(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")||x()),properties:f.object(n).default({}),settings:r}).default({})}var ze=class extends V{constructor(t){super(t),this._level=1;}static getStateSchema(t){return U(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=d(n.properties.text),n}_buildContent(t){return t.properties?.text??""}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return S(`h${this._level}`,{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[O]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return d(r)?R(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){if(t.key==="Backspace"){this.#e(t);return}Ve(this,t,{namespace:B});}#e(t){if(!L()?.collapsed)return;let r=F(this.element);if(r?.previousElementSibling||d(this.getState()?.properties?.text))return;t.preventDefault(),this.mrakomor.command.transformBlockElement({blockElement:r,namespace:B});let o=()=>{let s=this.mrakomor.getRoot()?.querySelector(".mrakomor-content .mrakomor-block-element"),i=K(s);i?.isConnected&&M(i,0);};o(),I(o);}};var q=class extends ze{static getStateSchema(t){return U(t,{component:this.NAMESPACE,properties:{text:f.string().default(t?.textContent??t?.innerText??""),entityRanges:se()}})}getInlineStyleComponents(){return []}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}parseFromHTML(t){return Ue(this,t)}_buildContent(t){return oe(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}},We=class extends q{static get NAMESPACE(){return Mt}static get LABEL(){return "H1"}constructor(t){super(t),this._level=1;}},Ce=class extends q{static get NAMESPACE(){return Tt}static get LABEL(){return "H2"}constructor(t){super(t),this._level=2;}},be=class extends q{static get NAMESPACE(){return wt}static get LABEL(){return "H3"}constructor(t){super(t),this._level=3;}},ke=class extends q{static get NAMESPACE(){return Pt}static get LABEL(){return "H4"}constructor(t){super(t),this._level=4;}},Xe=class extends q{static get NAMESPACE(){return Ot}static get LABEL(){return "H5"}constructor(t){super(t),this._level=5;}};function Or(){return {resolveConfig:e=>(e.blockComponents.push(Ce,be,ke),e),resolveComponent:e=>{if(e===We.NAMESPACE)return We;if(e===Ce.NAMESPACE)return Ce;if(e===be.NAMESPACE)return be;if(e===ke.NAMESPACE)return ke;if(e===Xe.NAMESPACE)return Xe}}}(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}
6
+ `,document.head.appendChild(n);}}})();function Kn(e,t,n){let r=e._getBlockElementIndex(t);if(r===-1)return false;let o=e.getContent();return o.splice(r,1,e.normalizeComponentState(n)),e._setContentState(o),true}function Je(e){if(e?.nodeName==="OL")return "ORDERED";if(e?.nodeName==="UL")return "UNORDERED"}function ie(e=[]){let t=new Set;return e.map(n=>{if(n?.componentId&&!t.has(n.componentId))return t.add(n.componentId),n;let r=x();return t.add(r),{...n,componentId:r}})}function Un(e){return e?[...e.children].filter(t=>t.nodeName==="LI"):[]}function Ht(e,t){return !e||!t?0:Fe(e,t.startContainer,t.startOffset)}function qn(e,t){let n=D(e),{originalLineState:r,newLineState:o}=jt(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:x(),depth:e.depth??0,text:o.properties.text,inlineStyleRanges:o.properties.inlineStyleRanges??[],entityRanges:o.properties.entityRanges??[]}}}function Gn(e,{style:t="UNORDERED"}={}){let n=e?.properties?.items,r=Array.isArray(n)&&n.length?n.map(o=>({componentId:o?.componentId??x(),depth:o?.depth??0,text:d(o?.text??""),inlineStyleRanges:[...o?.inlineStyleRanges??[]],entityRanges:[...o?.entityRanges??[]]})):[{componentId:x(),depth:0,text:d(e?.properties?.text??""),inlineStyleRanges:[...e?.properties?.inlineStyleRanges??[]],entityRanges:[...e?.properties?.entityRanges??[]]}];return {component:ye,componentId:x(),properties:{items:r},settings:{style:t==="ORDERED"?"ORDERED":"UNORDERED"}}}function $t(e,t,{namespace:n=B,Constructor:r}={}){let o=e.properties?.items??[],s=o[t];if(!s)return {blocks:[e],paragraphIndex:0};let i=o.slice(0,t),c=o.slice(t+1),a=Q({properties:{text:s.text,inlineStyleRanges:s.inlineStyleRanges,entityRanges:s.entityRanges}}),l={component:n,componentId:x(),settings:{},...r?.fromExchangeState(a)??D(s)},u=[];return i.length&&u.push({...e,properties:{...e.properties,items:i}}),u.push(l),c.length&&u.push({...e,componentId:i.length?x():e.componentId,properties:{...e.properties,items:c}}),{blocks:u,paragraphIndex:i.length?1:0}}function Vn(e){return Ke(e)?e.settings?.style==="ORDERED"?"ORDERED":"UNORDERED":null}function Ft(e,t){let n=Vn(e),r=Vn(t);return n!=null&&n===r}function Yn(e,t,n){if(t<0||n!==t+1||n>=e.length)return null;let r=e[t],o=e[n];if(!Ft(r,o))return null;let s=[...r.properties?.items??[]],i=[...o.properties?.items??[]];if(i.length===0){let m=[...e];m.splice(n,1);let g=s.length-1,E=g>=0?d(s[g]?.text).length:0;return {content:m,listIndex:t,cursor:E}}let[c,...a]=i,l=0;if(s.length===0)s.push(c,...a),l=0;else {let m=s.length-1,g=s[m],E=D(g),C=D(c),{state:y,cursor:G}=Se(E,C);s[m]={...g,text:y.properties.text,inlineStyleRanges:y.properties.inlineStyleRanges,entityRanges:y.properties.entityRanges},a.length&&s.push(...a),l=G;}let u={...r,properties:{...r.properties,items:ie(s)}},p=[...e];return p[t]=u,p.splice(n,1),{content:p,listIndex:t,cursor:l}}function zn(e,t){let n=e.properties?.items??[],r=n.length-1;if(r<0)return null;let o=Q({properties:t?.properties}).properties.items,[s,...i]=o,c=n[r],a=D(c),l=D(s),{state:u,cursor:p}=Se(a,l),m=n.map((g,E)=>E===r?{...g,text:u.properties.text,inlineStyleRanges:u.properties.inlineStyleRanges,entityRanges:u.properties.entityRanges}:g);return i.length&&m.push(...i.map(g=>({componentId:g?.componentId??x(),depth:g?.depth??0,text:d(g?.text??""),inlineStyleRanges:g?.inlineStyleRanges??[],entityRanges:g?.entityRanges??[]}))),{state:{...e,properties:{...e.properties,items:ie(m)}},cursor:p,itemIndex:r}}function Wn(e,t){return oe({properties:{text:e?.text??"",inlineStyleRanges:e?.inlineStyleRanges??[],entityRanges:e?.entityRanges??[]}},t)}function Xn(e,t){let n=Number(e.getAttribute("data-depth")??0)||0,r={properties:{text:d(e.innerText??e.textContent??""),inlineStyleRanges:[],entityRanges:[]}};return re(e.childNodes,r,0,t),{componentId:e.getAttribute("data-componentid")||void 0,depth:n,text:d(r.properties.text),inlineStyleRanges:r.properties.inlineStyleRanges,entityRanges:r.properties.entityRanges}}var Qe=e=>f.object({componentId:f.string().default(()=>e?.getAttribute?.("data-componentid")||x()),depth:f.number().default(0),text:f.string().default(""),inlineStyleRanges:f.array(Ye()).default([]),entityRanges:f.array(Z()).default([])}).default({}),Re=class e extends V{static get NAMESPACE(){return ye}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=Je(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||x()),properties:f.object({items:f.array(Qe()).default([Qe().parse()]).transform(ie)}).default({}),settings:f.object({style:f.enum(["ORDERED","UNORDERED"]).default(n??"UNORDERED")}).default({})}).default({})}static toExchangeState(t){let r=(t?.properties?.items??[]).map(o=>{let s={componentId:o?.componentId,text:d(o?.text),depth:o?.depth??0};return o?.inlineStyleRanges!==void 0&&(s.inlineStyleRanges=o.inlineStyleRanges),o?.entityRanges!==void 0&&(s.entityRanges=o.entityRanges),s});return Q({originComponent:this.NAMESPACE,properties:{items:r},settings:t?.settings})}static fromExchangeState(t){return Gn(t,{style:t?.settings?.style})}static appendExchangeState(t,n){return zn(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=Un(t);if(o.length)n.properties.items=o.map(s=>Qe(s).parse(Xn(s,r)));else {let s=this.state?.peek?.()?.properties?.items;n.properties.items=s?.length?structuredClone(s):[Qe().parse()];}return n.settings={...n.settings,style:t.nodeName==="OL"?"ORDERED":t.nodeName==="UL"?"UNORDERED":this.state?.peek()?.settings?.style??n.settings?.style??"UNORDERED"},n}_commitState(t){let n=F(this.element)??this.mrakomor._getBlockElementByComponentId(t.componentId);Kn(this.mrakomor,n,t);}_buildItemContent(t){return Wn(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=At(()=>this.state.get().properties?.items??[],(s,i)=>s.componentId??String(i),(s,i)=>S("li",{contentEditable:true,[O]:true,"data-componentid":()=>s.get().componentId,"data-item-index":()=>{let c=s.get()?.componentId,l=(this.state.get().properties?.items??[]).findIndex(u=>u.componentId===c);return String(l>=0?l:i)},"data-depth":()=>String(s.get()?.depth??0),$dangerouslySetInnerHTML:()=>{let c=s.get(),a=c?.text??"";return d(a)?R(()=>this._buildItemContent(c)):"<br>"}}),{tagName:r});return o.className=t,n.componentId&&o.setAttribute("data-componentid",n.componentId),this.element=o,o}onKeydown(t){if(t.key==="Enter"){this.#r(t);return}t.key==="Backspace"&&this.#t(t);}setCursor({cursor:t,itemIndex:n}={}){let r=this.getState()?.properties?.items??[],o=r.length-1;if(o<0)return;let s=typeof n=="number"&&n>=0&&n<=o?n:o,i=typeof t=="number"?t:d(r[s]?.text).length,c=()=>{let a=this.element?.querySelector(`li[data-item-index="${s}"]`);a?.isConnected&&M(a,i);};c(),I(c);}#e(t){let n=this.getState(),r=[...n.properties.items??[]],o=r[t];if(!o)return;if((o.depth??0)>0){r[t]={...o,depth:o.depth-1},this._commitState({...n,properties:{...n.properties,items:r}});let p=()=>{let m=this.element?.querySelector(`li[data-item-index="${t}"]`);m?.isConnected&&M(m,0);};p(),I(p);return}let s=F(this.element),i=this.mrakomor._getBlockElementIndex(s),c=s?.previousElementSibling??null,a=c?this.mrakomor._getBlockElementIndex(c):-1;if(t===0&&a>=0&&i===a+1){let p=this.mrakomor.getContent(),m=Yn(p,a,i);if(m){let g=m.content.map((E,C)=>C===m.listIndex?this.mrakomor.normalizeComponentState(E):E);this.mrakomor._setContentState(g),Ee(c)?.setCursor?.({cursor:m.cursor});return}}let{blocks:l,paragraphIndex:u}=$t(n,t,{Constructor:this.mrakomor.register.blocks.getByNamespace(B)});this.mrakomor.command.replaceBlockElement({blockElement:F(this.element),blocks:l,cursor:0,cursorBlockIndex:u});}#r(t){t.preventDefault();let n=L(),r=he(this.element,n);if(!r)return;let{element:o,index:s}=r,i=Ht(o,n),c=this.getState(),a=[...c.properties.items??[]],l=a[s];if(!l)return;if(!d(l.text)){this.#e(s);return}let{before:u,after:p}=qn(l,i);a.splice(s,1,u,p),this._commitState({...c,properties:{...c.properties,items:a}}),I(()=>{let m=this.element?.querySelector(`li[data-item-index="${s+1}"]`);m&&M(m,0);});}#t(t){let n=L();if(!n?.collapsed)return;let r=he(this.element,n);if(!r){let c=n.startContainer;if(!(c===this.element||this.element?.contains?.(c)))return;t.preventDefault(),this.#e(0);return}let{element:o,index:s}=r;Ht(o,n)===0&&(t.preventDefault(),this.#e(s));}};function Dr(e){let{mrakomor:t,blockElement:n,namespace:r}=e;if(!t||!n||!r)return;let o=t._getBlockElementState(n);if(!o||!Dt({component:r})||!Ke(o))return;e.preventDefault();let i=Ee(n)?.element,c=e.range??L(),a=he(i,c);if(!a)return;let{index:l}=a,{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 jr(e){if(e.key!=="Backspace"&&e.key!=="Delete")return;let t=L();if(!t?.collapsed)return;let n=Lt(t);if(!n)return;let r=K(n),o=!d(r?.textContent),s=t.startOffset===0||$e()===0||o;if(!o||!s)return;let i=n.previousSibling;if(!i)return;let{mrakomor:c}=e,a=c._getBlockElementIndex(n),l=c._getBlockElementIndex(i);if(a<0||l<0)return;let u=c._getBlockElementState(n),p=c._getBlockElementState(i);if(!u||!Dt(u)||!p||p.component!==ye)return;let m=c.getContent(),g=m[a+1];if(!Ft(p,g))return;let C=c.register.blocks.getByNamespace(g.component)?.toExchangeState?.(g),y=C&&Re.appendExchangeState(p,C);y&&(e.preventDefault(),m.splice(a,1),m.splice(l,2,c.normalizeComponentState(y.state)),c._setContentState(m),Fn({mrakomor:c,resultIndex:l,cursor:y.cursor,fallbackBlockElement:i,itemIndex:y.itemIndex}));}function Jn(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(xe.TRANSFORM_BLOCK_ELEMENT,Dr),t.emitter.on(xe.KEYDOWN,jr);}}}var Qn=e=>f.object({componentId:f.string().default(()=>x()),depth:f.number().default(0),text:f.string().default(""),entityRanges:se()}).default({}),Ze=class e extends Re{static getStateSchema(t){let n=Je(t);return f.object({component:f.string().default(e.NAMESPACE),componentId:f.string().default(t?.getAttribute("data-componentid")||x()),properties:f.object({items:f.array(Qn()).default([Qn().parse()]).transform(ie)}).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 Hr(){return Jn(Ze)}(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 et=class e extends V{static get NAMESPACE(){return B}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 U(t,{component:e.NAMESPACE,properties:{entityRanges:f.array(Z()).default([]),inlineStyleRanges:f.array(Ye()).default([]),text:f.string().default(t?.innerText??t?.textContent??"")}})}parseFromHTML(t){return Ue(this,t)}_buildContent(t){return oe(t,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return S("p",{className:t,"data-componentid":this.state.peek().componentId,contentEditable:true,[O]:true,$ref:n=>{this.element=n;},$dangerouslySetInnerHTML:()=>{let n=this.state.get(),r=n.properties?.text??"";return d(r)?R(()=>this._buildContent(n)):"<br>"}})}onKeydown(t){Ve(this,t);}};var ce=class e extends et{static getStateSchema(t){return U(t,{component:e.NAMESPACE,properties:{entityRanges:se(),text:f.string().default(t?.innerText??t?.textContent??"")}})}getInlineStyleComponents(){return []}};function $r(){return {resolveConfig:e=>(e.blockComponents.push(ce),e),resolveComponent:e=>{if(e===ce.NAMESPACE)return ce}}}var tt=class extends He{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=ge(qe),this.element=bt();}render(){return S(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
8
  `,document.head.appendChild(n);}}})();var le=[{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"}],Fr='<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 Kt(e){return le.find(t=>t.id===e)??le[0]}function Kr(e){let t=le.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 ae=class e extends tt{#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 Z({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 S("div",{className:"tts-voice-toolbar"},[S("div",{className:"tts-voice-toolbar__row"},[...le.map(s=>S("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)),S("span",{className:"tts-voice-toolbar__sep"}),S("button",{type:"button",className:"tts-voice-toolbar__btn tts-voice-toolbar__btn--danger",title:"Remove TTS voice",$dangerouslySetInnerHTML:Fr,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:t.peek(),length:n.peek(),offset:r.peek()},blockElement:F(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||(t.set({...t.peek(),data:{voice:le[0].id}}),this.#t(this.props)),this.#e=N(()=>{let n=t.get()?.data?.voice??"";this.element.current?.style.setProperty("--tts-voice-color",Kr(n));});}onUnmount(){this.#e?.();}render(){let{entity:t,length:n,offset:r,children:o}=this.props;return S("span",{className:()=>{let s=t.get()?.data?.voice??"";return `atom-tts-voice tts-voice--${Kt(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?Kt(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 Vr(){return {resolveConfig:e=>(e.entityRanges.push(ae),e),resolveComponent:e=>{if(e===ae.NAMESPACE)return ae}}}
9
9
  exports.TtsHeadlineComponent=q;exports.TtsList=Ze;exports.TtsParagraph=ce;exports.TtsVoice=ae;exports.VOICES=le;exports.getVoice=Kt;exports.ttsHeadlinePlugin=Or;exports.ttsListPlugin=Hr;exports.ttsParagraphPlugin=$r;exports.ttsVoicePlugin=Vr;
package/dist/tts.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import {a as a$4}from'./chunk-6CG6EGQM.mjs';import {a}from'./chunk-TL5BHWDU.mjs';import {c as c$1,a as a$2,b as b$1,d as d$2}from'./chunk-5HWTMPF4.mjs';import'./chunk-S2W6LYHT.mjs';import'./chunk-GDDVUIEH.mjs';import {a as a$5}from'./chunk-2C6UDFD4.mjs';import {d as d$1,c,b as b$2}from'./chunk-JVQ2YGII.mjs';import'./chunk-ZHOZPQZH.mjs';import {a as a$1}from'./chunk-P7IKAZYZ.mjs';import {A,t,e,f as f$2,g as g$1,h as h$1,i}from'./chunk-FAXIFXQK.mjs';import'./chunk-B6JJAATK.mjs';import {a as a$3,f as f$1}from'./chunk-P7TUN2KD.mjs';import {p as p$1,d as d$3}from'./chunk-7CJLTNHZ.mjs';var s=class extends a{static getStateSchema(t){return d$1(t,{component:this.NAMESPACE,properties:{text:a$1.string().default(t?.textContent??t?.innerText??""),entityRanges:c()}})}getInlineStyleComponents(){return []}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}parseFromHTML(t){return A(this,t)}_buildContent(t$1){return t(t$1,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}},h=class extends s{static get NAMESPACE(){return e}static get LABEL(){return "H1"}constructor(t){super(t),this._level=1;}},d=class extends s{static get NAMESPACE(){return f$2}static get LABEL(){return "H2"}constructor(t){super(t),this._level=2;}},g=class extends s{static get NAMESPACE(){return g$1}static get LABEL(){return "H3"}constructor(t){super(t),this._level=3;}},f=class extends s{static get NAMESPACE(){return h$1}static get LABEL(){return "H4"}constructor(t){super(t),this._level=4;}},b=class extends s{static get NAMESPACE(){return i}static get LABEL(){return "H5"}constructor(t){super(t),this._level=5;}};function $(){return {resolveConfig:e=>(e.blockComponents.push(d,g,f),e),resolveComponent:e=>{if(e===h.NAMESPACE)return h;if(e===d.NAMESPACE)return d;if(e===g.NAMESPACE)return g;if(e===f.NAMESPACE)return f;if(e===b.NAMESPACE)return b}}}var j=e=>a$1.object({componentId:a$1.string().default(()=>a$3()),depth:a$1.number().default(0),text:a$1.string().default(""),entityRanges:c()}).default({}),E=class e extends c$1{static getStateSchema(t){let o=a$2(t);return a$1.object({component:a$1.string().default(e.NAMESPACE),componentId:a$1.string().default(t?.getAttribute("data-componentid")||a$3()),properties:a$1.object({items:a$1.array(j()).default([j().parse()]).transform(b$1)}).default({}),settings:a$1.object({style:a$1.enum(["ORDERED","UNORDERED"]).default(o??"UNORDERED")}).default({})}).default({})}getInlineStyleComponents(){return []}parseFromHTML(t){return this.constructor.getStateSchema(t).parse(super.parseFromHTML(t))}};function F(){return d$2(E)}var p=class e extends a$4{static getStateSchema(t){return d$1(t,{component:e.NAMESPACE,properties:{entityRanges:c(),text:a$1.string().default(t?.innerText??t?.textContent??"")}})}getInlineStyleComponents(){return []}};function J(){return {resolveConfig:e=>(e.blockComponents.push(p),e),resolveComponent:e=>{if(e===p.NAMESPACE)return p}}}(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(i){return i.getAttribute("data-mrakomor-css-path")===e});if(!t){var o=document.createElement("style");o.setAttribute("data-mrakomor-css",""),o.setAttribute("data-mrakomor-css-path",e),o.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}
1
+ import {a as a$4}from'./chunk-DHFIX7FW.mjs';import {a}from'./chunk-J4TTWQ6J.mjs';import {c as c$1,a as a$2,b as b$1,d as d$2}from'./chunk-BWK2S4UI.mjs';import'./chunk-5AD5MQXI.mjs';import'./chunk-SG5PCGIV.mjs';import {a as a$5}from'./chunk-2C6UDFD4.mjs';import {d as d$1,c,b as b$2}from'./chunk-B2UFH244.mjs';import'./chunk-ZHOZPQZH.mjs';import {a as a$1}from'./chunk-P7IKAZYZ.mjs';import {A,t,e,f as f$2,g as g$1,h as h$1,i}from'./chunk-D6K2L5O3.mjs';import'./chunk-B6JJAATK.mjs';import {a as a$3,f as f$1}from'./chunk-4WTPDNPA.mjs';import {p as p$1,d as d$3}from'./chunk-7CJLTNHZ.mjs';var s=class extends a{static getStateSchema(t){return d$1(t,{component:this.NAMESPACE,properties:{text:a$1.string().default(t?.textContent??t?.innerText??""),entityRanges:c()}})}getInlineStyleComponents(){return []}getEntityRangeComponents(){return this.props?.entityRanges?.get()??this.mrakomor.getConfig()?.entityRanges??[]}parseFromHTML(t){return A(this,t)}_buildContent(t$1){return t(t$1,{inlineStyleComponents:this.getInlineStyleComponents(),entityRangeComponents:this.getEntityRangeComponents()})}},h=class extends s{static get NAMESPACE(){return e}static get LABEL(){return "H1"}constructor(t){super(t),this._level=1;}},d=class extends s{static get NAMESPACE(){return f$2}static get LABEL(){return "H2"}constructor(t){super(t),this._level=2;}},g=class extends s{static get NAMESPACE(){return g$1}static get LABEL(){return "H3"}constructor(t){super(t),this._level=3;}},f=class extends s{static get NAMESPACE(){return h$1}static get LABEL(){return "H4"}constructor(t){super(t),this._level=4;}},b=class extends s{static get NAMESPACE(){return i}static get LABEL(){return "H5"}constructor(t){super(t),this._level=5;}};function $(){return {resolveConfig:e=>(e.blockComponents.push(d,g,f),e),resolveComponent:e=>{if(e===h.NAMESPACE)return h;if(e===d.NAMESPACE)return d;if(e===g.NAMESPACE)return g;if(e===f.NAMESPACE)return f;if(e===b.NAMESPACE)return b}}}var j=e=>a$1.object({componentId:a$1.string().default(()=>a$3()),depth:a$1.number().default(0),text:a$1.string().default(""),entityRanges:c()}).default({}),E=class e extends c$1{static getStateSchema(t){let o=a$2(t);return a$1.object({component:a$1.string().default(e.NAMESPACE),componentId:a$1.string().default(t?.getAttribute("data-componentid")||a$3()),properties:a$1.object({items:a$1.array(j()).default([j().parse()]).transform(b$1)}).default({}),settings:a$1.object({style:a$1.enum(["ORDERED","UNORDERED"]).default(o??"UNORDERED")}).default({})}).default({})}getInlineStyleComponents(){return []}parseFromHTML(t){return this.constructor.getStateSchema(t).parse(super.parseFromHTML(t))}};function F(){return d$2(E)}var p=class e extends a$4{static getStateSchema(t){return d$1(t,{component:e.NAMESPACE,properties:{entityRanges:c(),text:a$1.string().default(t?.innerText??t?.textContent??"")}})}getInlineStyleComponents(){return []}};function J(){return {resolveConfig:e=>(e.blockComponents.push(p),e),resolveComponent:e=>{if(e===p.NAMESPACE)return p}}}(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(i){return i.getAttribute("data-mrakomor-css-path")===e});if(!t){var o=document.createElement("style");o.setAttribute("data-mrakomor-css",""),o.setAttribute("data-mrakomor-css-path",e),o.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}
2
2
  `,document.head.appendChild(o);}}})();var u=[{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"}],U='<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 x(e){return u.find(t=>t.id===e)??u[0]}function q(e){let t=u.find(a=>a.id===e);if(t)return t.color;let o=0;for(let a=0;a<e.length;a++)o=o*31+e.charCodeAt(a)|0;return `hsl(${Math.abs(o)%360}, 65%, 45%)`}var m=class e extends a$5{#t;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 o;if(t?.getAttribute?.("data-state"))try{o=JSON.parse(t.getAttribute("data-state"));}catch{}let i=o?.entity?.data?.voice??t?.getAttribute?.("data-voice")??"";return b$2({type:e.NAMESPACE,data:a$1.object({voice:a$1.string().default(i)}).default({}),length:o?.length??0,offset:o?.offset??0}).default({})}#o({entity:t,length:o,offset:i}){let a=t.peek()?.data?.voice??"";return p$1("div",{className:"tts-voice-toolbar"},[p$1("div",{className:"tts-voice-toolbar__row"},[...u.map(n=>p$1("button",{type:"button",className:`tts-voice-toolbar__voice tts-voice-toolbar__voice--${n.gender}${a===n.id?" tts-voice-toolbar__voice--active":""}`,$ref:S=>S?.style.setProperty("--tts-voice-color",n.color),title:n.label,onClick:()=>{t.set({...t.peek(),data:{voice:n.id}}),this.mrakomor.command.closeDialog();}},n.label)),p$1("span",{className:"tts-voice-toolbar__sep"}),p$1("button",{type:"button",className:"tts-voice-toolbar__btn tts-voice-toolbar__btn--danger",title:"Remove TTS voice",$dangerouslySetInnerHTML:U,onClick:()=>{this.mrakomor.command.removeEntityRange?.({state:{entity:t.peek(),length:o.peek(),offset:i.peek()},blockElement:f$1(this.element)});}})])])}#e(t){this.mrakomor.command.openDialog({element:this.element,children:this.#o(t)});}onMount(){let{entity:t}=this.props;t.peek()?.data?.voice||(t.set({...t.peek(),data:{voice:u[0].id}}),this.#e(this.props)),this.#t=d$3(()=>{let o=t.get()?.data?.voice??"";this.element.current?.style.setProperty("--tts-voice-color",q(o));});}onUnmount(){this.#t?.();}render(){let{entity:t,length:o,offset:i,children:a}=this.props;return p$1("span",{className:()=>{let n=t.get()?.data?.voice??"";return `atom-tts-voice tts-voice--${x(n||"man1").gender}`},"data-entity-type":this.constructor.NAMESPACE,"data-voice":()=>t.get()?.data?.voice??"","data-voice-label":()=>{let n=t.get()?.data?.voice??"";return n?x(n).label:""},$ref:this.element,onClick:n=>{n.preventDefault(),this.#e({entity:t,length:o,offset:i});},"data-state":()=>JSON.stringify({entity:t.get(),length:o.get(),offset:i.get()})},a)}};function z(){return {resolveConfig:e=>(e.entityRanges.push(m),e),resolveComponent:e=>{if(e===m.NAMESPACE)return m}}}
3
3
  export{s as TtsHeadlineComponent,E as TtsList,p as TtsParagraph,m as TtsVoice,u as VOICES,x as getVoice,$ as ttsHeadlinePlugin,F as ttsListPlugin,J as ttsParagraphPlugin,z as ttsVoicePlugin};
@@ -117,6 +117,14 @@ export function getSelectableItemForRange(root: Element | null | undefined, rang
117
117
  * @returns {import('#src/types.mjs').SelectionState | null}
118
118
  */
119
119
  export function getSelectionState(): import("#src/types.mjs").SelectionState | null;
120
+ /**
121
+ * Whether a block wrapper's rendered content root is itself contentEditable
122
+ * (e.g. Paragraph's `<p>`, Headline's `<h*>` — `true`; a non-editable atomic
123
+ * block like Figure, or a missing/unmounted block — `false`).
124
+ * @param {Element | null | undefined} blockElement
125
+ * @returns {boolean}
126
+ */
127
+ export function isBlockContentEditable(blockElement: Element | null | undefined): boolean;
120
128
  /**
121
129
  * Position an overlay above an anchor, coordinates relative to the editor root.
122
130
  * @param {Element} root
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrakomor/core",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "",
5
5
  "imports": {
6
6
  "#src/*.mjs": "./src/*.mjs",
@@ -82,19 +82,19 @@
82
82
  "sideEffects": [
83
83
  "**/*.css",
84
84
  "./dist/chunk-2C6UDFD4.mjs",
85
- "./dist/chunk-5HWTMPF4.mjs",
86
- "./dist/chunk-6CG6EGQM.mjs",
85
+ "./dist/chunk-4WTPDNPA.mjs",
86
+ "./dist/chunk-5AD5MQXI.mjs",
87
87
  "./dist/chunk-7CJLTNHZ.mjs",
88
+ "./dist/chunk-B2UFH244.mjs",
88
89
  "./dist/chunk-B6JJAATK.mjs",
90
+ "./dist/chunk-BWK2S4UI.mjs",
91
+ "./dist/chunk-D6K2L5O3.mjs",
92
+ "./dist/chunk-DHFIX7FW.mjs",
89
93
  "./dist/chunk-ERNLRJPB.mjs",
90
94
  "./dist/chunk-EXDY5TZH.mjs",
91
- "./dist/chunk-FAXIFXQK.mjs",
92
- "./dist/chunk-GDDVUIEH.mjs",
93
- "./dist/chunk-JVQ2YGII.mjs",
95
+ "./dist/chunk-J4TTWQ6J.mjs",
94
96
  "./dist/chunk-P7IKAZYZ.mjs",
95
- "./dist/chunk-P7TUN2KD.mjs",
96
- "./dist/chunk-S2W6LYHT.mjs",
97
- "./dist/chunk-TL5BHWDU.mjs",
97
+ "./dist/chunk-SG5PCGIV.mjs",
98
98
  "./dist/chunk-ZHOZPQZH.mjs"
99
99
  ],
100
100
  "scripts": {
@@ -106,6 +106,7 @@
106
106
  "test:size": "npm run build && node scripts/check-bundle-size.mjs && node scripts/check-esmj-size.mjs",
107
107
  "test:e2e": "playwright test",
108
108
  "test:performance": "playwright test --project=performance",
109
+ "test:bugfinder": "node --import ./bot/registerCssLoader.mjs bot/cli.mjs",
109
110
  "bot:bugfinder": "node --import ./bot/registerCssLoader.mjs bot/cli.mjs",
110
111
  "lint": "biome check --no-errors-on-unmatched",
111
112
  "lint:fix": "biome check --write --unsafe --no-errors-on-unmatched",
@@ -1 +0,0 @@
1
- import {h as h$1}from'./chunk-7CJLTNHZ.mjs';var C=E(),S=E(),B=E(),I=Array.from({length:256},(t,e)=>(e<=15?"0":"")+e.toString(16));function E(){return Math.floor(Math.random()*16777215)}function k(){return S=(S+1)%16777215,S}function v(){let t=Math.floor(Date.now()/1e3);t=parseInt(t,10)%4294967295;let e=k(),n=String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255,C>>16&255,C>>8&255,C&255,B>>8&255,B&255,e>>16&255,e>>8&255,e&255),o="";for(let l=0;l<n.length;l++)o+=I[n.charCodeAt(l)];return o}var x=Symbol("block-element"),M=Symbol("block-element-body"),g=Symbol("selectable-element");function h(t,e){let n=t;for(n?.nodeType===Node.TEXT_NODE&&(n=n.parentElement);n&&n[e]===void 0;)n=n.parentElement;return n??null}function y(t){return t?h(t.startContainer,x):null}function O(t){return h(t,x)}function N(t){return t?h(t.startContainer,g):null}function T(t){return h(t,g)}function _(t){return t?t[g]!==void 0?[t]:[...t.children].filter(e=>e[g]!==void 0):[]}function w(t,e){return e?_(t).indexOf(e):-1}function W(t,e){let n=N(e);return !n||!t?.contains(n)?null:{element:n,index:w(t,n)}}function b(){return window.getSelection()}function p(){let t=b();return t.rangeCount>0?t.getRangeAt(0).cloneRange():null}function j(){let t=p();if(!t)return 0;t.collapse(true);let e=N(t),n=y(t),o=e??s(n);return d(o,t.startContainer,t.startOffset)}var f=null;function F(){f=L();}function A(){f&&G(f);}function K(){f&&(f={start:f.end,end:f.end,element:f.element},A());}function D(t,e){let n=N(e);return n||(s(t)??t?.childNodes?.[0]??null)}function d(t,e,n){if(!t)return 0;if(e===t){if(e.nodeType===Node.TEXT_NODE)return n;let c=0,u=t.childNodes,a=Math.min(n,u.length);for(let i=0;i<a;i++)c+=u[i].textContent.length;return c}if(e.nodeType===Node.ELEMENT_NODE&&!t.contains(e))return 0;let o=0,l=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=l.nextNode();for(;r;){if(r===e)return o+n;o+=r.textContent.length,r=l.nextNode();}return o}function L(){let t=p();if(!t)return null;let e=y(t),n=D(e,t);return {start:d(n,t.startContainer,t.startOffset),end:d(n,t.endContainer,t.endOffset),element:e,selectableElement:n}}function Y(t=p()){if(!t||t.collapsed)return null;let e=O(t.startContainer),n=O(t.endContainer);if(!e||!n)return null;let o=T(t.startContainer)??s(e),l=T(t.endContainer)??s(n);return {startBlock:e,endBlock:n,startOffset:d(o,t.startContainer,t.startOffset),endOffset:d(l,t.endContainer,t.endOffset)}}function G(t){if(!t)return;let{start:e,end:n,element:o,selectableElement:l}=t,r=l?.isConnected&&l||s(o)||o?.childNodes?.[0];if(!r)return;let c=m(r,e),u=m(r,n),a=document.createRange();a.setStart(c.startContainer,c.startOffset),a.setEnd(u.endContainer,u.endOffset);let i=b();i.removeAllRanges(),i.addRange(a);}function m(t,e){let n=document.createRange();if(!t)return n;if(e<=0)return n.setStart(t,0),n.collapse(true),n;let o=0,l=[t];for(;l.length>0;){let r=l.pop();if(r.nodeType===Node.TEXT_NODE){let c=r.textContent.length;if(o+c>=e)return n.setEnd(r,e-o),n.setStart(r,e-o),n;o+=c;}else if(r.childNodes&&r.childNodes.length>0)for(let c=r.childNodes.length-1;c>=0;c--)l.push(r.childNodes[c]);}return n.setEnd(t,t.childNodes.length),n.setStart(t,t.childNodes.length),n}function q(t,e){let n=m(t,e),o=b();o.removeAllRanges(),o.addRange(n);}function s(t){if(!t)return null;let e=H(t);return e?.firstElementChild??e?.firstChild}function z(t){if(!t?.[x])return null;let e=s(t);return e?h$1(e)?.classInstance:null}function H(t){if(!t)return null;for(let e of t.children)if(e[M])return e;return null}function J(t,e,n,o=12){let l=t.getBoundingClientRect(),r=typeof e?.getBoundingClientRect=="function"?e.getBoundingClientRect():e??{left:0,top:0},c=n?.offsetHeight??40;return {x:r.left-l.left,y:r.top-l.top-c-o}}function P(t,e){let n=t.getBoundingClientRect(),o=e?.offsetWidth??420,l=e?.offsetHeight??320,r=16;return {x:Math.max(r,(n.width-o)/2),y:Math.max(r,(n.height-l)/2)}}export{v as a,x as b,M as c,g as d,y as e,O as f,N as g,T as h,_ as i,W as j,p as k,j as l,F as m,A as n,K as o,d as p,L as q,Y as r,G as s,q as t,s as u,z as v,H as w,J as x,P as y};
@@ -1 +0,0 @@
1
- import {a as a$1}from'./chunk-GDDVUIEH.mjs';import {a as a$2}from'./chunk-P7IKAZYZ.mjs';import {d,c,z,j,w as w$1,q,k as k$2,o as o$1,D,n,C,p as p$1}from'./chunk-FAXIFXQK.mjs';import {a,b}from'./chunk-B6JJAATK.mjs';import {a as a$3,d as d$1,k as k$1,e,w,u,l,r,t,v as v$1}from'./chunk-P7TUN2KD.mjs';import {p,s,b as b$1,o}from'./chunk-7CJLTNHZ.mjs';var k=class o extends a$1{static get NAMESPACE(){return c}static getStateSchema(t){return a$2.object({component:a$2.string().default(o.NAMESPACE),componentId:a$2.string().default(t?.getAttribute("data-componentid")||a$3()),properties:a$2.object({}).default({}),settings:a$2.object({}).default({})}).default({})}constructor(t){super(t),this.root=null;}getState(){return this.state.peek()}isAtomic(){return true}static appendExchangeState(){return null}onMount(){}onUnmount(){}render(){let t=this.constructor.NAMESPACE.toLowerCase().replaceAll(".","-");return p("div",{className:t,contentEditable:false,style:"position: relative;",$ref:n=>{this.element=n;},"data-state":()=>JSON.stringify(this.state.get()),"data-componentid":this.state.peek().componentId},[p("div",{$ref:n=>{this.root=n;},style:"display: block;",contentEditable:false}),p("span",{style:"position: absolute; bottom: 0; right: 0; width: 10px; height: 100%; outline: none;",contentEditable:true,[d$1]:true},document.createTextNode("\xA0"))])}onKeydown(t){t.key!=="Backspace"&&t.key!=="ArrowUp"&&t.key!=="ArrowDown"&&t.preventDefault(),z(this,t);}};var v=class extends k{static get NAMESPACE(){return d}onMount(){let t=p("div",{style:"user-select: none;",contentEditable:false},()=>`Unknown component: ${this.state.get().component}`);s(this.root,t);}onUnmount(){this.root.innerHTML="";}};function O(o,t,r){let n=o._getBlockElementIndex(t);if(n===-1)return false;let e=o.getContent();return e.splice(n,1,o.normalizeComponentState(r)),o._setContentState(e),true}function st(o$1){let{mrakomor:t}=o$1,{blockElement:r,range:n,newLineState:e$1,originalLineState:c,namespace:s,position:i,cursor:a}=o$1,l,m;if(i||(r?l=t._getBlockElementIndex(r):n&&(l=t._getBlockElementIndex(e(n))),l===void 0||l===-1))return;m=l+1;let E=t.getContent();c&&E.splice(l,1,t.normalizeComponentState(c)),e$1&&(e$1.component=s,E.splice(m,0,t.normalizeComponentState(e$1))),t._setContentState(E),o(()=>{typeof a=="number"&&v$1(t._getBlockElements()[m])?.setCursor?.({cursor:a});});}function it(o$1){let{mrakomor:t$1}=o$1,{blockElement:r,range:n,blocks:e$1,cursor:c,cursorBlockIndex:s=0}=o$1;if(!Array.isArray(e$1)||e$1.length===0)return;let i=r??(n?e(n):null),a=t$1._getBlockElementIndex(i);if(a===-1)return;let l=[...t$1._getContentState()];l.splice(a,1,...e$1.map(m=>t$1.normalizeComponentState(m))),t$1._setContentState(l),o(()=>{if(typeof c!="number")return;t$1._syncBlockElementsFromDom();let m=u(t$1._getBlockElements()[a+s]);m?.isConnected&&t(m,c);});}function lt(o){let{mrakomor:t,blockElement:r,namespace:n}=o,e=t._getBlockElementState(r);if(!e)return;let c=t.register.blocks.getByNamespace(e.component),s=t.register.blocks.getByNamespace(n),i=(o.exchangeState&&k$2(o.exchangeState))??c?.toExchangeState?.(e)??k$2({properties:e.properties,settings:e.settings}),a=s?.fromExchangeState?.(i)??i;O(t,r,{...a,component:n,componentId:a$3()});}function at(o){let{mrakomor:t,blockElement:r,targetIndex:n}=o,e=t._getBlockElementIndex(r);if(e===-1||typeof n!="number")return;let c=n>e?n-1:n;if(c===e)return;let s=[...t._getContentState()],[i]=s.splice(e,1);s.splice(c,0,i),t._setContentState(s);}function mt(o$1){let{mrakomor:t$1,blockElement:r,range:n}=o$1,e$1=t$1._getBlockElementIndex(r);if(e$1!==-1){let c=t$1.getContent();c.splice(e$1,1),t$1._setContentState(c);}o(()=>{let c=e(n);t(u(c),0);});}function ut(o){let{mrakomor:t,state:r,blockElement:n}=o,e=t._getBlockElementState(n);if(!e)return;let c=structuredClone(e),s=r?.offset,i=r?.length,a=r?.entity?.type;c.properties.entityRanges=(c.properties.entityRanges??[]).filter(l=>!(l?.offset===s&&l?.length===i&&l?.entity?.type===a)),O(t,n,c),t.command.closeDialog?.();}function Et(o){let{mrakomor:t,namespace:r,state:n$1}=o,e$1=o.range??k$1(),c=o.blockElement??e(e$1),s=o$1(t,c,e$1);if(!s||s.item.entityRanges===void 0)return;let{Constructor:i,current:a,element:l,itemIndex:m,item:E}=s,d=D(E.entityRanges,l,e$1,{namespace:r,entityData:n$1});if(d===null)return;let M=n(i,a,m,{entityRanges:d});O(t,c,M);}function gt(o){let{mrakomor:t,style:r}=o,n$1=o.range??k$1(),e$1=o.blockElement??e(n$1),c=o$1(t,e$1,n$1);if(!c||c.item.inlineStyleRanges===void 0)return;let{Constructor:s,current:i,element:a,itemIndex:l,item:m}=c,E=C(m.inlineStyleRanges,a,n$1,r);if(E===null)return;let d=n(s,i,l,{inlineStyleRanges:E});O(t,e$1,d);}function dt(o){let{mrakomor:t,blockElement:r,previousBlockElement:n}=o,e=t._getBlockElementIndex(n),c=t._getBlockElementIndex(r);if(e===-1||c===-1)return;let s=t.getContent(),i=s[c],a=s[e],l=t.register.blocks.getByNamespace(a.component),m=t.register.blocks.getByNamespace(i.component),E=(o.exchangeState&&k$2(o.exchangeState))??m?.toExchangeState?.(i)??k$2({properties:i.properties,settings:i.settings}),d=l?.appendExchangeState?.(a,E);d&&(s.splice(c,1),s.splice(e,1,t.normalizeComponentState(d.state)),t._setContentState(s),p$1({mrakomor:t,resultIndex:e,cursor:d.cursor,fallbackBlockElement:n,itemIndex:d.itemIndex}));}function pt(o){let{mrakomor:t}=o,r=t.getRoot(),n=o.relatedTarget instanceof Node&&r.contains(o.relatedTarget),e=r?.contains(document.activeElement)??false;if(n||e)return;let[s,i]=b$1(()=>[t.getContent(),t._getContentState()]);s.length===i.length&&s.every((l,m)=>l===i[m])||t.setContent(s);}function ft(o){let{mrakomor:t$1,clientX:r,clientY:n}=o;if(typeof n!="number")return;let e=t$1._getContentRoot(),c=t$1._getBlockElements(),s=c[0],i=c[c.length-1];if(!e||!s||!i)return;let a=n<s.getBoundingClientRect().top,l=n>i.getBoundingClientRect().bottom;if(!a&&!l)return;if(typeof r=="number"){let E=e.getBoundingClientRect();if(r<E.left||r>E.right)return}let m=u(a?s:i);m?.isConnected&&t(m,a?0:m.textContent.length);}function kt(o){let t=k$1();return e(t)?.getNodeComponent?.()?.classInstance?.onKeydown?.(o)}function Ct(o){v$1(o)?.setCursor?.();}function Bt(o$1){if(o$1.key!=="Backspace")return;let{mrakomor:t$1}=o$1,r$1=k$1();if(!r$1)return;let n=e(r$1);if(!n)return;let e$1=w(n),c=n?.previousSibling,i=w(c)?.childNodes?.[0]?.contentEditable==="true",a=e$1?.childNodes?.[0]?.contentEditable==="true",l$1=u(n),m=!j(l$1?.textContent),E=r$1.collapsed&&(r$1.startOffset===0||l()===0||m);if(!r$1.collapsed){let p=r(r$1);if(p&&p.startBlock!==p.endBlock){let x=t$1._getBlockElementIndex(p.startBlock),h=t$1._getBlockElementIndex(p.endBlock),K=t$1.getContent(),nt=x>=0?K[x]:void 0,ot=h>=0?K[h]:void 0;if(x>=0&&h>x&&typeof nt?.properties?.text=="string"&&typeof ot?.properties?.text=="string"){o$1.preventDefault();let{content:rt,cursor:z,resultIndex:ct}=w$1(K,{startIndex:x,endIndex:h,startOffset:p.startOffset,endOffset:p.endOffset});t$1._setContentState(rt.map(R=>t$1.normalizeComponentState(R))),o(()=>{let R=t$1._getBlockElements()[ct];R&&typeof z=="number"&&t(u(R),z);});}}return}if(!E)return;let d=t$1._getBlockElementIndex(n),M=c?t$1._getBlockElementIndex(c):-1,N=t$1._getBlockElementState(n),F=t$1._getBlockElementState(c),D=c?v$1(c):null;if(!c||M<0){o$1.preventDefault();return}if(F&&N&&q(N)&&D&&!D.isAtomic?.()){if(m&&!q(F)){o$1.preventDefault();let p=t$1.getContent();p.splice(d,1),t$1._setContentState(p),Ct(c);return}o$1.preventDefault(),t$1.command.mergeBlockElement({blockElement:n,previousBlockElement:c,range:r$1});return}D?.isAtomic?.()&&(!i&&r$1.startOffset===0||n?.textContent==="\xA0"&&!a)&&(o$1.preventDefault(),t$1.command.removeBlockElement({blockElement:c,range:r$1})),N&&!q(N)&&o$1.preventDefault();}function Ut(o){return {resolveComponent:t=>t===k.NAMESPACE?k:v,registerCommands(t){t.emitter.on(a.INSERT_BLOCK_ELEMENT,b(st)),t.emitter.on(a.REPLACE_BLOCK_ELEMENT,b(it)),t.emitter.on(a.TRANSFORM_BLOCK_ELEMENT,b(lt)),t.emitter.on(a.MOVE_BLOCK_ELEMENT,b(at)),t.emitter.on(a.REMOVE_BLOCK_ELEMENT,b(mt)),t.emitter.on(a.REMOVE_ENTITY_RANGE,b(ut)),t.emitter.on(a.INSERT_ENTITY_RANGE,b(Et)),t.emitter.on(a.INSERT_INLINE_STYLE_RANGE,b(gt)),t.emitter.on(a.MERGE_BLOCK_ELEMENT,b(dt));},registerHandlers(t){t.emitter.on(a.FOCUSOUT,pt),t.emitter.on(a.KEYDOWN,b(kt)),t.emitter.on(a.KEYDOWN,b(Bt)),t.emitter.on(a.CLICK,b(ft));},registerListeners(t){let r=t.getRoot(),{signal:n}=t.listenerAbortController;r.addEventListener("keydown",e=>t.emitDomEvent(a.KEYDOWN,e),{signal:n}),r.addEventListener("beforeinput",e=>t.emitDomEvent(a.BEFORE_INPUT,e),{signal:n}),r.addEventListener("input",e=>t.emitDomEvent(a.INPUT,e),{signal:n}),r.addEventListener("focusin",e=>t.emitDomEvent(a.FOCUSIN,e),{signal:n}),r.addEventListener("focusout",e=>t.emitDomEvent(a.FOCUSOUT,e),{signal:n}),r.addEventListener("click",e=>t.emitDomEvent(a.CLICK,e),{signal:n}),document.addEventListener("selectionchange",e=>t.emitDomEvent(a.SELECTION_CHANGE,e),{signal:n});}}}export{v as a,O as b,Ut as c};