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