@mrakomor/core 0.0.10 → 0.0.11

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