@tempots/beatui 1.1.1 → 1.1.3
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/beatui.css +0 -3
- package/dist/beatui.tailwind.css +0 -3
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +2150 -2146
- package/dist/lexical/index.cjs.js +2 -2
- package/dist/lexical/index.es.js +1408 -1410
- package/dist/menu-B60Q9j3-.cjs +1 -0
- package/dist/menu-BkqFGcXg.js +366 -0
- package/dist/types/components/navigation/breadcrumbs.d.ts +1 -1
- package/dist/types/components/navigation/flyout.d.ts +15 -5
- package/package.json +1 -1
- package/dist/menu-B8yoDMRS.js +0 -373
- package/dist/menu-B92oSDct.cjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("@lexical/rich-text"),F=require("@lexical/list"),
|
|
2
|
-
`}isInline(){return!1}decorate(){return null}}function Tt(){return{node:se()}}function se(){return n.$applyNodeReplacement(new oe)}function Ue(t){return t instanceof oe}function me(t){const o=[j.HeadingNode,j.QuoteNode,F.ListNode,F.ListItemNode,ee.LinkNode,ie.CodeNode,ie.CodeHighlightNode,oe];return t.table&&o.push(q.TableNode,q.TableCellNode,q.TableRowNode),t.autoLink&&o.push(ee.AutoLinkNode),t.hashtag&&o.push(Re.HashtagNode),t.mark&&o.push(ne.MarkNode),t.overflow&&o.push(dt.OverflowNode),[...new Set(o)]}function pe(t){switch(t){case"bare":return{richText:!0,history:!0,clipboard:!0};case"docked":return{richText:!0,history:!0,clipboard:!0,list:!0,link:!0,autoLink:!0,code:!0,table:!0};case"contextual":return{richText:!0,history:!0,clipboard:!0,list:!0,link:!0,autoLink:!0,code:!0,table:!0}}}async function ze(){return yt}async function he(t){return j.registerRichText(t)}async function be(t){return ft.registerPlainText(t)}async function Ce(t,o){const s=Fe.createEmptyHistoryState(),c=o?.delay??300;return Fe.registerHistory(t,s,c)}async function ye(t){return()=>{}}async function Ee(t){return typeof F.registerList=="function"?typeof F.registerCheckList=="function"?ge.mergeRegister(F.registerList(t),F.registerCheckList(t)):F.registerList(t):ge.mergeRegister(t.registerCommand(F.INSERT_ORDERED_LIST_COMMAND,()=>(F.insertList(t,"number"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.INSERT_UNORDERED_LIST_COMMAND,()=>(F.insertList(t,"bullet"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.INSERT_CHECK_LIST_COMMAND,()=>(F.insertList(t,"check"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.REMOVE_LIST_COMMAND,()=>(F.removeList(t),!0),n.COMMAND_PRIORITY_LOW))}async function Oe(t){return t.registerCommand(ee.TOGGLE_LINK_COMMAND,o=>(o===null||typeof o=="string"?ee.toggleLink(o):ee.toggleLink(o.url,o),!0),n.COMMAND_PRIORITY_LOW)}async function Mt(t,o,s){const c=o?.trigger||"/";let l=!1,u=null,p=0;const O=()=>t.getEditorState().read(()=>{const C=n.$getSelection();if(!n.$isRangeSelection(C)||!C.isCollapsed())return!1;const E=C.anchor,x=E.getNode();if(!n.$isTextNode(x))return!1;const R=x.getTextContent(),P=E.offset;if(P===0||R[P-1]!==c)return!1;if(P===1)return!0;const b=R[P-2];return!!/\s/.test(b)}),v=()=>u?t.getEditorState().read(()=>{if(!u)return"";const C=u.getTextContent(),E=C.indexOf(c,p);if(E===-1)return"";const x=n.$getSelection();if(!n.$isRangeSelection(x))return"";const R=x.anchor;if(R.getNode().getKey()!==u.getKey())return"";const N=R.offset;return N<=E?"":C.slice(E+1,N)}):"",A=()=>{t.getEditorState().read(()=>{const C=n.$getSelection();if(n.$isRangeSelection(C)){const E=C.anchor,x=E.getNode();if(n.$isTextNode(x)){u=x,p=E.offset-1,l=!0;const R={isActive:!0,filterText:"",anchorNode:u,anchorOffset:p};s?.onTrigger?.(R,k),s?.onUpdate?.(R,k)}}})},h=()=>{l&&(l=!1,u=null,p=0,s?.onClose?.())},k=()=>{u&&t.update(()=>{if(!u)return;const C=u.getTextContent(),E=C.indexOf(c,p);if(E===-1)return;const x=n.$getSelection();if(!n.$isRangeSelection(x))return;const R=x.anchor;if(R.getNode().getKey()!==u.getKey())return;const N=R.offset,b=C.slice(0,E),L=C.slice(N);u.setTextContent(b+L);const a=n.$getSelection();n.$isRangeSelection(a)&&(a.anchor.set(u.getKey(),E,"text"),a.focus.set(u.getKey(),E,"text"))})},y=()=>{if(!l)return;const E={isActive:!0,filterText:v(),anchorNode:u,anchorOffset:p};s?.onUpdate?.(E,k)},g=t.registerMutationListener(n.TextNode,C=>{if(!l&&O()){A();return}l&&(u&&!C.has(u.getKey())?y():h())}),M=ge.mergeRegister(t.registerUpdateListener(({editorState:C})=>{C.read(()=>{if(!l)return;const E=n.$getSelection();if(!n.$isRangeSelection(E)){h();return}const x=E.anchor,R=x.getNode();if(!u||R.getKey()!==u.getKey()){h();return}const N=u.getTextContent().indexOf(c,p);if(N===-1||x.offset<=N){h();return}})}),t.registerCommand(n.KEY_ARROW_DOWN_COMMAND,C=>l?(C.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ARROW_UP_COMMAND,C=>l?(C.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ENTER_COMMAND,C=>l?(C?.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ESCAPE_COMMAND,C=>l?(C?.preventDefault(),h(),!0):!1,n.COMMAND_PRIORITY_LOW));return()=>{h(),g(),M()}}function Nt(t,o,s){s(),o.handler(t),t.focus()}const St=n.createCommand("TOGGLE_SLASH_COMMAND_PALETTE"),ce=n.createCommand("INSERT_HORIZONTAL_RULE_COMMAND"),xt=n.createCommand("INSERT_IMAGE_COMMAND");function Te(t){return t.registerCommand(ce,()=>{const o=n.$getSelection();if(!n.$isRangeSelection(o))return!1;if(o.focus.getNode()!==null){const c=se();o.insertNodes([c]);const l=n.$createParagraphNode();c.insertAfter(l),l.selectStart()}return!0},n.COMMAND_PRIORITY_LOW)}const Ge={dependencies:[oe],export:t=>Ue(t)?"---":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,o,s,c)=>{const l=se();if(c)t.replace(l);else{t.replace(l);const u=n.$createParagraphNode();l.insertAfter(u),u.selectStart()}},type:"element"},De=[...Ae.TRANSFORMERS,Ge];async function K(t){let o="";return t.getEditorState().read(()=>{o=Ae.$convertToMarkdownString(De)}),o}async function V(t,o){t.update(()=>{Ae.$convertFromMarkdownString(o,De)})}async function kt(){return De}async function Y(t){let o="";return t.getEditorState().read(()=>{o=Be.$generateHtmlFromNodes(t)}),o}async function X(t,o){t.update(()=>{const c=new DOMParser().parseFromString(o,"text/html"),l=Be.$generateNodesFromDOM(t,c);n.$getRoot().clear(),n.$insertNodes(l)})}async function _t(t,o,s){let c,l,u;switch(o){case"markdown":c=await K(t),l="text/markdown",u="md";break;case"html":c=await Y(t),l="text/html",u="html";break;case"json":c=JSON.stringify(t.getEditorState().toJSON(),null,2),l="application/json",u="json";break}const p=new Blob([c],{type:l}),O=URL.createObjectURL(p),v=document.createElement("a");v.href=O,v.download=s??`document.${u}`,v.click(),URL.revokeObjectURL(O)}async function vt(t,o,s){const c=await new Promise((u,p)=>{const O=new FileReader;O.onload=()=>u(O.result),O.onerror=()=>p(O.error),O.readAsText(o)});switch(s??Rt(o.name)){case"markdown":{await V(t,c);break}case"html":{await X(t,c);break}case"json":{const u=t.parseEditorState(c);t.setEditorState(u);break}}}function Rt(t){return t.endsWith(".md")||t.endsWith(".markdown")?"markdown":t.endsWith(".html")||t.endsWith(".htm")?"html":"json"}async function Me(t,o){return"registerTablePlugin"in fe&&typeof fe.registerTablePlugin=="function"?fe.registerTablePlugin(t):()=>{}}async function At(t,o=3,s=3){t.dispatchCommand(fe.INSERT_TABLE_COMMAND,{rows:String(o),columns:String(s),includeHeaders:!0})}async function Lt(t,o){return"registerCodeHighlighting"in re&&typeof re.registerCodeHighlighting=="function"?re.registerCodeHighlighting(t):()=>{}}async function It(t,o){return"registerCodeHighlighting"in re&&typeof re.registerCodeHighlighting=="function"?re.registerCodeHighlighting(t):()=>{}}const Dt=/#[\w\u0590-\u05ff]+/;function wt(t){return new Re.HashtagNode(t)}async function $t(t,o){const s=[],c=gt.registerLexicalTextEntity(t,l=>{const u=Dt.exec(l);return u?{start:u.index,end:u.index+u[0].length}:null},Re.HashtagNode,wt);if(Array.isArray(c)?s.push(...c):typeof c=="function"&&s.push(c),o?.onHashtagClick){const l=t.registerCommand(n.CLICK_COMMAND,u=>{const p=u.target;if(p.classList.contains("bc-lexical-hashtag")){const O=p.textContent;if(O)return o.onHashtagClick(O.replace("#","")),!0}return!1},n.COMMAND_PRIORITY_LOW);s.push(l)}return()=>{s.forEach(l=>l())}}const Pt=/((https?:\/\/(www\.)?|www\.)[^\s<>]+)/g,Ht=/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/g,Ft=[{pattern:Pt,urlTransformer:t=>t.startsWith("http")?t:`https://${t}`},{pattern:Ht,urlTransformer:t=>`mailto:${t}`}];async function Bt(t,o){const s=o?.matchers??Ft;return t.registerMutationListener(n.TextNode,c=>{t.update(()=>{for(const[l,u]of c){if(u!=="created"&&u!=="updated")continue;const p=n.$getNodeByKey(l);if(!p||!n.$isTextNode(p))continue;const O=p.getTextContent();for(const v of s){const A=new RegExp(v.pattern.source,v.pattern.flags);let h;for(;(h=A.exec(O))!==null;)v.urlTransformer(h[0])}}})})}async function jt(t,o){const s=[];return o?.onMarkClick&&s.push(t.registerCommand(n.CLICK_COMMAND,c=>{const l=c.target;if(l.classList.contains("bc-lexical-mark")){const u=l.dataset.markId;if(u)return o.onMarkClick(u,{id:u,type:l.dataset.markType||"annotation",data:{}}),!0}return!1},n.COMMAND_PRIORITY_LOW)),()=>s.forEach(c=>c())}async function Ut(t,o,s){t.update(()=>{const c=n.$getSelection();n.$isRangeSelection(c)&&ne.$wrapSelectionInMarkNode(c,c.isBackward(),o)})}async function zt(t,o){t.update(()=>{const c=n.$getRoot().getAllTextNodes().filter(l=>{const u=l.getParent();return ne.$isMarkNode(u)?ne.$getMarkIDs(l,0)?.includes(o)??!1:!1});for(const l of c){const u=l.getParent();ne.$isMarkNode(u)&&ne.$unwrapMarkNode(u)}})}async function Gt(t,o){const{maxLength:s,onOverflow:c}=o;return t.registerUpdateListener(({editorState:l})=>{l.read(()=>{const O=n.$getRoot().getTextContent().length,v=O>s;c&&c(v,O)})})}async function Ne(t){return"registerDragonSupport"in ke&&typeof ke.registerDragonSupport=="function"?ke.registerDragonSupport(t):()=>{}}async function Se(t,o){const s=o.docMap??new Map,c=o.id??"lexical",l=o.doc.getText(c),u=ht.createBinding(t,o.provider,l,o.doc,s),p=t.registerUpdateListener(()=>{});return()=>{p(),u&&typeof u.destroy=="function"&&u.destroy()}}function qt(t){let o={hasSelection:!1,selectedText:"",anchorOffset:0,focusOffset:0};return t.getEditorState().read(()=>{const s=n.$getSelection();n.$isRangeSelection(s)&&(o={hasSelection:!s.isCollapsed(),selectedText:s.getTextContent(),anchorOffset:s.anchor.offset,focusOffset:s.focus.offset})}),o}function we(t){let o="";return t.getEditorState().read(()=>{o=n.$getRoot().getTextContent()}),o}function Wt(t){return we(t).length}function Kt(t){const o=we(t).trim();return o?o.split(/\s+/).length:0}function Yt(t,o){t.update(()=>{const s=n.$getSelection();n.$isRangeSelection(s)&&s.insertText(o)}),t.focus()}async function Jt(){return Et}function le(t,o,s){const c=new Map;if(t)for(const l of t.split(";")){const u=l.trim();if(!u)continue;const p=u.indexOf(":");if(p===-1)continue;const O=u.slice(0,p).trim(),v=u.slice(p+1).trim();c.set(O,v)}return s?c.set(o,s):c.delete(o),c.size===0?"":Array.from(c.entries()).map(([l,u])=>`${l}: ${u}`).join("; ")}function te(t,o){if(!t)return"";const s=new RegExp(`(?:^|;)\\s*${o.replace(/-/g,"\\-")}:\\s*([^;]+)`),c=t.match(s);return c?c[1].trim():""}function Vt(t,o){const s=t.getElementByKey(o);s&&t.getEditorState().read(()=>{const c=n.$getNodeByKey(o);if(!n.$isElementNode(c)||n.$isRootNode(c))return;const l=c.getStyle(),u=te(l,"background-color");s.style.backgroundColor=u||"";const p=te(l,"line-height");s.style.lineHeight=p||""})}function $e(t){const o=t.registerUpdateListener(({dirtyElements:s})=>{if(s.size!==0)for(const[c]of s)Vt(t,c)});return t.getEditorState().read(()=>{const s=n.$getRoot();for(const c of s.getChildren())if(n.$isElementNode(c)){const l=c.getStyle();if(l){const u=t.getElementByKey(c.getKey());if(u){const p=te(l,"background-color");p&&(u.style.backgroundColor=p);const O=te(l,"line-height");O&&(u.style.lineHeight=O)}}}}),o}function _e(t,o){const s=o.exportDOM(t);if(s.element&&ge.isHTMLElement(s.element)&&n.$isElementNode(o)){const c=o.getStyle(),l=te(c,"background-color");l&&(s.element.style.backgroundColor=l);const u=te(c,"line-height");u&&(s.element.style.lineHeight=u)}return s}function xe(){const t=new Map;return t.set(n.ParagraphNode,_e),t.set(j.HeadingNode,_e),t.set(j.QuoteNode,_e),t}function Xt(){const t=o=>()=>({conversion:s=>{const c=o(s);if(c&&n.$isElementNode(c)){s.style?.textAlign&&c.setFormat(s.style.textAlign);let l="";s.style?.backgroundColor&&(l=le(l,"background-color",s.style.backgroundColor)),s.style?.lineHeight&&(l=le(l,"line-height",s.style.lineHeight)),l&&c.setStyle(l)}return{node:c}},priority:1});return{p:t(()=>n.$createParagraphNode()),h1:t(()=>j.$createHeadingNode("h1")),h2:t(()=>j.$createHeadingNode("h2")),h3:t(()=>j.$createHeadingNode("h3")),h4:t(()=>j.$createHeadingNode("h4")),h5:t(()=>j.$createHeadingNode("h5")),h6:t(()=>j.$createHeadingNode("h6"))}}const qe=["color","font-size","font-family","background-color","line-height"],Zt=new Set(["font-weight","font-style","text-decoration","text-decoration-line","vertical-align"]),Qt={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},eo=["span","b","em","i","strong","u","s","sub","sup","code","mark"];function to(t,o,s){if(!n.$isTextNode(o))return;const c=t.fontWeight,l=t.textDecoration.split(" ");(c==="700"||c==="bold")&&!o.hasFormat("bold")&&o.toggleFormat("bold"),t.fontStyle==="italic"&&!o.hasFormat("italic")&&o.toggleFormat("italic"),l.includes("line-through")&&!o.hasFormat("strikethrough")&&o.toggleFormat("strikethrough"),l.includes("underline")&&!o.hasFormat("underline")&&o.toggleFormat("underline"),t.verticalAlign==="sub"&&!o.hasFormat("subscript")&&o.toggleFormat("subscript"),t.verticalAlign==="super"&&!o.hasFormat("superscript")&&o.toggleFormat("superscript"),s&&!o.hasFormat(s)&&o.toggleFormat(s)}function We(t=qe){const o={};for(const s of eo)o[s]=c=>{const l=c.style,u=Qt[s],p=s==="b"?l.fontWeight!=="normal"?"bold":void 0:u;return{conversion:()=>({node:null,forChild:O=>{if(!n.$isTextNode(O))return O;to(l,O,p);let v=O.getStyle();for(const A of t){if(Zt.has(A))continue;const h=l.getPropertyValue(A);h&&(v=le(v,A,h))}return v&&O.setStyle(v),O}}),priority:1}};return o}function ue(t){return{...Xt(),...We(t)}}async function de(t={}){const{nodes:o=[],plugins:s=[],onError:c}=t,u=(await ze()).createEditor({namespace:"BeatUIHeadless",nodes:o,onError:p=>{c?c(p,u):console.error("[BeatUI Headless]",p)},editable:!1,html:{export:xe(),import:ue()}});if(s.length>0)for(const p of s)p.register(u);return u}async function oo(t){const o=await de();return await V(o,t),o.getEditorState().toJSON()}async function no(t){const o=await de(),s=o.parseEditorState(JSON.stringify(t));return o.setEditorState(s),await K(o)}async function ro(t){const o=await de();return await X(o,t),o.getEditorState().toJSON()}async function io(t){const o=await de(),s=o.parseEditorState(JSON.stringify(t));return o.setEditorState(s),await Y(o)}const Ke=t=>{const{value:o,format:s,plugins:c,readOnly:l,placeholder:u,class:p,namespace:O="BeatUILexical",heightMode:v="auto",autoFocus:A=!1,onError:h,onInput:k,onChange:y,onBlur:g,onReady:M}=t;return e.Use(Ie.Theme,({appearance:C})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:E})=>Le.LinkPortal({id:"beatui-lexical-css",href:E})),e.attr.class("bc-lexical-editor-container"),v==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(p),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${v}`),e.attr.contenteditable(l!=null?e.Value.map(l,E=>!E):!0),l!=null?e.attr.class(e.Value.map(l,E=>E?"bc-lexical-editor--readonly":"")):null,e.WithElement(E=>{let x=null;const R=[];return(async()=>{try{const N=c??pe("bare"),b=me(N),L=e.Value.get(s??"markdown"),a=n.createEditor({namespace:O,nodes:b,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:T=>{h?h(T,a):console.error("[BeatUI Lexical]",T)},editable:l?!e.Value.get(l):!0,html:{export:xe(),import:ue()}});x=a,a.setRootElement(E);const I=[];if(N.richText?I.push(he(a)):N.plainText&&I.push(be(a)),N.history){const T=typeof N.history=="object"?N.history:void 0;I.push(Ce(a,T))}if(N.clipboard&&I.push(ye(a)),N.list&&I.push(Ee(a)),N.link&&I.push(Oe(a)),N.yjs&&I.push(Se(a,N.yjs)),N.dragon&&I.push(Ne(a)),N.table&&I.push(Me(a)),(await Promise.all(I)).forEach(T=>{T&&R.push(T)}),R.push(Te(a)),R.push($e(a)),o!=null){const T=e.Value.get(o);if(T!=null&&(T!==""||L==="json"&&typeof T=="object")){if(L==="markdown"&&typeof T=="string")await V(a,T);else if(L==="html"&&typeof T=="string")await X(a,T);else if(L==="json"&&typeof T=="object")try{const r=JSON.stringify(T),_=a.parseEditorState(r);a.setEditorState(_)}catch(r){console.error("[BeatUI] Failed to parse JSON editor state:",r),h&&h(r instanceof Error?r:new Error(String(r)),a)}}}if(R.push(a.registerUpdateListener(({editorState:T,dirtyElements:f,dirtyLeaves:r})=>{f.size===0&&r.size===0||k&&T.read(async()=>{if(L==="markdown"){const _=await K(a);k(_,a)}else if(L==="html"){const _=await Y(a);k(_,a)}else L==="json"&&k(T.toJSON(),a)})})),o!=null&&R.push(e.Value.on(o,async T=>{if(T!=null){if(L==="markdown"&&typeof T=="string"){const f=await K(a);T!==f&&await V(a,T)}else if(L==="html"&&typeof T=="string"){const f=await Y(a);T!==f&&await X(a,T)}else if(L==="json"&&typeof T=="object"){const f=JSON.stringify(a.getEditorState().toJSON()),r=JSON.stringify(T);if(f!==r){const _=a.parseEditorState(r);a.setEditorState(_)}}}})),l!=null&&R.push(e.Value.on(l,T=>{a.setEditable(!T)})),R.push(a.registerCommand(n.BLUR_COMMAND,()=>(g&&g(a),y&&a.getEditorState().read(async()=>{if(L==="markdown"){const T=await K(a);y(T,a)}else if(L==="html"){const T=await Y(a);y(T,a)}else L==="json"&&y(a.getEditorState().toJSON(),a)}),!1),n.COMMAND_PRIORITY_LOW)),R.push(C.on(T=>{const f=a.getRootElement();f&&(f.dataset.theme=T)})),A)a.focus();else{const T=a.getRootElement();T&&T===document.activeElement&&T.blur()}M&&M(a)}catch(N){console.error("[BeatUI] Failed to initialize Lexical editor:",N);const b=E;b.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{R.forEach(N=>N())}catch{}try{x?.setRootElement(null)}catch{}})}))))};function Ye(t,o,s){const c=(g,M)=>o.map(()=>{const C=t.value;return C?C.getEditorState().read(()=>{const E=n.$getSelection();return n.$isRangeSelection(E)?g(E):M}):M}),l=g=>{const M=g.anchor.getNode();return M.getKey()==="root"?M:M.getTopLevelElementOrThrow()};return{withSelection:c,getAnchorElement:l,textFormatActive:g=>c(M=>M.hasFormat(g),!1),blockTypeActive:g=>c(M=>l(M).getType()===g,!1),listTypeActive:g=>c(M=>{const C=l(M).getParent();return F.$isListNode(C)&&C.getListType()===g},!1),headingActive:g=>o.map(()=>{const M=t.value;return M?M.getEditorState().read(()=>{const C=n.$getSelection();if(n.$isRangeSelection(C)){const E=l(C);if(E.getType()==="heading")return M.getElementByKey(E.getKey())?.tagName===`H${g}`}return!1}):!1}),linkActive:()=>c(g=>{const M=g.anchor.getNode();return M.getParent()?.getType()==="link"||M.getType()==="link"},!1),dispatch:(g,M)=>()=>{const C=t.value;C&&(C.dispatchCommand(g,M),C.focus())},toggleBlock:(g,M)=>()=>{const C=t.value;C&&(C.update(()=>{const E=n.$getSelection();if(n.$isRangeSelection(E)){const x=l(E);B.$setBlocksType(E,()=>x.getType()===g?n.$createParagraphNode():M())}}),C.focus())},toggleLink:()=>{const g=t.value;g&&(g.getEditorState().read(()=>{const M=n.$getSelection();if(n.$isRangeSelection(M)){const C=M.anchor.getNode();if(C.getParent()?.getType()==="link"||C.getType()==="link")g.dispatchCommand(ee.TOGGLE_LINK_COMMAND,null);else{const R=prompt(s?.enterUrlMessage?.()??"Enter URL:");R&&g.dispatchCommand(ee.TOGGLE_LINK_COMMAND,R)}}}),g.focus())}}}function Je(t,o){return s=>c=>ve.EditorToolbarButton({...c,display:s,disabled:t,size:o})}const lo={font:["font-family","font-size","line-height"],color:["font-color","highlight-color","background-color"],"text-formatting":["bold","italic","underline","strikethrough","code"],"clear-formatting":["clear-formatting"],headings:["paragraph","heading-1","heading-2","heading-3","heading-4","heading-5","heading-6"],lists:["bullet-list","ordered-list","check-list"],indent:["indent","outdent"],blocks:["blockquote","code-block","horizontal-rule"],tables:["insert-table"],links:["link"],history:["undo","redo"],clipboard:["cut","copy","paste"]},ao=["font","color","text-formatting","clear-formatting","headings","lists","indent","blocks","tables","links","history","clipboard"];function so(){return ao.map(t=>({group:t}))}function co(t){if(t.layout)return t.layout;const{visibleGroups:o,hiddenGroups:s,customGroups:c}=t;let l=so();if((o||s)&&(l=l.filter(u=>{if("separator"in u||"customGroup"in u)return!0;const p=u.group;return!(s?.includes(p)||o&&!o.includes(p))})),c&&c.length>0)for(const u of c)l.push({customGroup:u.id});return l}const uo=[{value:"Arial",label:"Arial"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Trebuchet MS",label:"Trebuchet MS"},{value:"Verdana",label:"Verdana"}],fo=[{value:"10px",label:"10"},{value:"12px",label:"12"},{value:"14px",label:"14"},{value:"16px",label:"16"},{value:"18px",label:"18"},{value:"20px",label:"20"},{value:"24px",label:"24"},{value:"30px",label:"30"},{value:"36px",label:"36"}],go=[{value:"1",label:"1"},{value:"1.15",label:"1.15"},{value:"1.5",label:"1.5"},{value:"2",label:"2"},{value:"2.5",label:"2.5"},{value:"3",label:"3"}];function Ve({editor:t,stateUpdate:o,toolbar:s={},readOnly:c=e.signal(!1),size:l="sm"}){const{maxHeadingLevel:u=3}=s,p=co(s);return e.Use(W.BeatUII18n,O=>e.Ensure(t,v=>{const A=v,h=O.$.lexical,{getAnchorElement:k,textFormatActive:y,blockTypeActive:g,listTypeActive:M,headingActive:C,linkActive:E,dispatch:x,toggleBlock:R,toggleLink:P}=Ye(A,o,{enterUrlMessage:()=>O.value.lexical.enterUrl}),b=Je(c,l)(e.signal(!0)),L=()=>{const i=A.value;i&&(i.update(()=>{const m=n.$getSelection();n.$isRangeSelection(m)&&B.$setBlocksType(m,()=>n.$createParagraphNode())}),i.focus())},a=i=>{const m=A.value;m&&(m.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=`h${i}`,Q=m.getElementByKey(z.getKey());z.getType()==="heading"&&Q?.tagName===`H${i}`?B.$setBlocksType(w,()=>n.$createParagraphNode()):B.$setBlocksType(w,()=>j.$createHeadingNode(Z))}}),m.focus())},I=()=>{const i=A.value;if(!i)return;const m=i.getRootElement();m&&(m.focus(),document.execCommand("copy"))},S=()=>{const i=A.value;if(!i)return;const m=i.getRootElement();m&&(m.focus(),document.execCommand("cut"))},T=()=>{const i=A.value;i&&navigator.clipboard.readText().then(m=>{i.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&w.insertText(m)}),i.focus()}).catch(()=>{})},f=()=>{const i=A.value;i&&(i.update(()=>{const m=n.$getSelection();if(n.$isRangeSelection(m))for(const w of m.getNodes())n.$isTextNode(w)&&(w.setFormat(0),w.setStyle(""))}),i.focus())},r=()=>{const i=A.value;i&&(i.dispatchCommand(q.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0}),i.focus())},_={value:"",label:O.value.lexical.defaultOption},G=[_,...s.fontFamilies??uo],d=[_,...s.fontSizes??fo],D=[_,...s.lineHeights??go],H=o.map(()=>{const i=A.value;return i?i.getEditorState().read(()=>{const m=n.$getSelection();return n.$isRangeSelection(m)?B.$getSelectionStyleValueForProperty(m,"font-family",""):""}):""}),U=o.map(()=>{const i=A.value;return i?i.getEditorState().read(()=>{const m=n.$getSelection();return n.$isRangeSelection(m)?B.$getSelectionStyleValueForProperty(m,"font-size",""):""}):""}),tt=i=>{const m=A.value;m&&(m.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"font-family":i||null})}),m.focus())},ot=i=>{const m=A.value;m&&(m.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"font-size":i||null})}),m.focus())},nt=o.map(()=>{const i=A.value;return i?i.getEditorState().read(()=>{const m=n.$getSelection();return n.$isRangeSelection(m)&&B.$getSelectionStyleValueForProperty(m,"color","")||"#000000"}):"#000000"}),rt=o.map(()=>{const i=A.value;return i?i.getEditorState().read(()=>{const m=n.$getSelection();return n.$isRangeSelection(m)&&B.$getSelectionStyleValueForProperty(m,"background-color","")||"#ffffff"}):"#ffffff"}),it=o.map(()=>{const i=A.value;return i?i.getEditorState().read(()=>{const m=n.$getSelection();if(n.$isRangeSelection(m)){const z=k(m).getStyle();return te(z,"background-color")||"#ffffff"}return"#ffffff"}):"#ffffff"}),lt=o.map(()=>{const i=A.value;return i?i.getEditorState().read(()=>{const m=n.$getSelection();if(n.$isRangeSelection(m)){const z=k(m).getStyle();return te(z,"line-height")||""}return""}):""}),at=i=>{const m=A.value;m&&(m.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{color:i})}),m.focus())},st=i=>{const m=A.value;m&&(m.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"background-color":i})}),m.focus())},ct=i=>{const m=A.value;m&&(m.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=z.getStyle(),Q=le(Z,"background-color",i);z.setStyle(Q)}}),m.focus())},ut=i=>{const m=A.value;m&&(m.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=z.getStyle(),Q=le(Z,"line-height",i);z.setStyle(Q)}}),m.focus())},$=new Map;$.set("bold",()=>b({active:y("bold"),onClick:x(n.FORMAT_TEXT_COMMAND,"bold"),label:h.map(i=>i.bold),icon:"mdi:format-bold"})),$.set("italic",()=>b({active:y("italic"),onClick:x(n.FORMAT_TEXT_COMMAND,"italic"),label:h.map(i=>i.italic),icon:"mdi:format-italic"})),$.set("underline",()=>b({active:y("underline"),onClick:x(n.FORMAT_TEXT_COMMAND,"underline"),label:h.map(i=>i.underline),icon:"mdi:format-underline"})),$.set("strikethrough",()=>b({active:y("strikethrough"),onClick:x(n.FORMAT_TEXT_COMMAND,"strikethrough"),label:h.map(i=>i.strikethrough),icon:"mdi:format-strikethrough"})),$.set("code",()=>b({active:y("code"),onClick:x(n.FORMAT_TEXT_COMMAND,"code"),label:h.map(i=>i.code),icon:"mdi:code-tags"})),$.set("clear-formatting",()=>b({active:e.signal(!1),onClick:f,label:h.map(i=>i.clearFormatting),icon:"mdi:format-clear"})),$.set("paragraph",()=>b({active:g("paragraph"),onClick:L,label:h.map(i=>i.normal),icon:"mdi:format-paragraph"}));for(let i=1;i<=u;i++)$.set(`heading-${i}`,()=>b({active:C(i),onClick:()=>a(i),label:h.map(m=>m.heading(i)),icon:`mdi:format-header-${i}`}));$.set("bullet-list",()=>b({active:M("bullet"),onClick:x(F.INSERT_UNORDERED_LIST_COMMAND,void 0),label:h.map(i=>i.bulletList),icon:"mdi:format-list-bulleted"})),$.set("ordered-list",()=>b({active:M("number"),onClick:x(F.INSERT_ORDERED_LIST_COMMAND,void 0),label:h.map(i=>i.orderedList),icon:"mdi:format-list-numbered"})),$.set("check-list",()=>b({active:M("check"),onClick:x(F.INSERT_CHECK_LIST_COMMAND,void 0),label:h.map(i=>i.checkList),icon:"mdi:format-list-checks"})),$.set("indent",()=>b({active:e.signal(!1),onClick:x(n.INDENT_CONTENT_COMMAND,void 0),label:h.map(i=>i.indent),icon:"mdi:format-indent-increase"})),$.set("outdent",()=>b({active:e.signal(!1),onClick:x(n.OUTDENT_CONTENT_COMMAND,void 0),label:h.map(i=>i.outdent),icon:"mdi:format-indent-decrease"})),$.set("blockquote",()=>b({active:g("quote"),onClick:R("quote",j.$createQuoteNode),label:h.map(i=>i.blockquote),icon:"mdi:format-quote-close"})),$.set("code-block",()=>b({active:g("code"),onClick:R("code",ie.$createCodeNode),label:h.map(i=>i.codeBlock),icon:"mdi:code-braces"})),$.set("horizontal-rule",()=>b({active:e.signal(!1),onClick:x(ce,void 0),label:h.map(i=>i.horizontalRule),icon:"mdi:minus"})),$.set("insert-table",()=>b({active:e.signal(!1),onClick:r,label:h.map(i=>i.insertTable),icon:"mdi:table-plus"})),$.set("link",()=>b({active:E(),onClick:P,label:h.map(i=>i.link),icon:"mdi:link"})),$.set("undo",()=>b({active:e.signal(!1),onClick:x(n.UNDO_COMMAND,void 0),label:h.map(i=>i.undo),icon:"mdi:undo"})),$.set("redo",()=>b({active:e.signal(!1),onClick:x(n.REDO_COMMAND,void 0),label:h.map(i=>i.redo),icon:"mdi:redo"})),$.set("cut",()=>b({active:e.signal(!1),onClick:S,label:h.map(i=>i.cut),icon:"mdi:content-cut"})),$.set("copy",()=>b({active:e.signal(!1),onClick:I,label:h.map(i=>i.copy),icon:"mdi:content-copy"})),$.set("paste",()=>b({active:e.signal(!1),onClick:T,label:h.map(i=>i.paste),icon:"mdi:content-paste"})),$.set("font-family",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(h.map(i=>i.fontFamily)),e.attr.disabled(c),e.on.change(i=>tt(i.target.value)),...G.map(i=>e.html.option(e.attr.value(i.value),e.attr.selected(H.map(m=>m===i.value)),i.label)))),$.set("font-size",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(h.map(i=>i.fontSize)),e.attr.disabled(c),e.on.change(i=>ot(i.target.value)),...d.map(i=>e.html.option(e.attr.value(i.value),e.attr.selected(U.map(m=>m===i.value)),i.label)))),$.set("line-height",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(h.map(i=>i.lineHeight)),e.attr.disabled(c),e.on.change(i=>ut(i.target.value)),...D.map(i=>e.html.option(e.attr.value(i.value),e.attr.selected(lt.map(m=>m===i.value)),i.label)))),$.set("font-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(h.map(i=>i.fontColor)),e.html.input(e.attr.type("color"),e.attr.value(nt),e.attr.disabled(c),e.on.input(i=>at(i.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon"),"A"))),$.set("highlight-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(h.map(i=>i.highlightColor)),e.html.input(e.attr.type("color"),e.attr.value(rt),e.attr.disabled(c),e.on.input(i=>st(i.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--highlight"),"A"))),$.set("background-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(h.map(i=>i.backgroundColor)),e.html.input(e.attr.type("color"),e.attr.value(it),e.attr.disabled(c),e.on.input(i=>ct(i.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--bg"),"■")));const Pe={editor:A,stateUpdate:o,readOnly:c,size:l,button:i=>b({active:i.active??e.signal(!1),onClick:i.onClick,label:i.label,icon:i.icon})},He=i=>{if(i.type==="button"){const m=i;$.set(i.id,()=>b({active:m.active?.(Pe)??e.signal(!1),onClick:()=>m.onClick(A.value),label:m.label,icon:m.icon}))}else if(i.type==="select"){const m=i,w=m.resetOnSelect!==!1;$.set(i.id,()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(m.label),e.attr.disabled(c),e.on.change(z=>{const Z=z.target,Q=Z.value;Q!==""&&(m.onSelect(Q,A.value),w&&(Z.value=""))}),e.html.option(e.attr.value(""),e.attr.disabled(w),e.attr.selected(!0),m.label),...m.options.map(z=>e.html.option(e.attr.value(z.value),z.label))))}else if(i.type==="custom"){const m=i;$.set(i.id,()=>m.render(Pe))}};if(s.customItems)for(const i of s.customItems)He(i);if(s.customGroups)for(const i of s.customGroups)for(const m of i.items)He(m);return je.Toolbar({},e.attr.class("bc-lexical-toolbar"),...mo(p,$,u,s.customGroups))}))}function mo(t,o,s,c){const l=new Map;if(c)for(const p of c)l.set(p.id,p);const u=[];for(const p of t){if("separator"in p){u.push(je.ToolbarDivider());continue}if("customGroup"in p){const h=l.get(p.customGroup);if(!h)continue;const k=[];for(const g of h.items){const M=o.get(g.id);M&&k.push(M())}if(k.length===0)continue;const y=k.map(()=>e.signal(!0));u.push(ve.EditorToolbarGroup({display:y},...k));continue}let O=p.items??lo[p.group]??[];p.group==="headings"&&!p.items&&(O=O.filter(h=>h.startsWith("heading-")?parseInt(h.split("-")[1],10)<=s:!0));const v=[];for(const h of O){const k=o.get(h);k&&v.push(k())}if(v.length===0)continue;const A=v.map(()=>e.signal(!0));u.push(ve.EditorToolbarGroup({display:A},...v))}return u}function Xe({editor:t,stateUpdate:o,readOnly:s=e.signal(!1)}){const c=e.prop(!1),l=e.prop(0),u=e.prop(0);let p=null,O=null;const v=e.prop(!1),A=N=>{let b=null;return N.getEditorState().read(()=>{const L=n.$getSelection();if(!n.$isRangeSelection(L))return;let a=L.anchor.getNode();for(;a;){if(q.$isTableCellNode(a)){b=a;break}if(a=a.getParent(),!a||a.getKey()==="root")break}}),b},h=(N,b)=>{const L=N.getBoundingClientRect(),a=b.closest(".bc-lexical-editor-container"),I=a?a.getBoundingClientRect():b.getBoundingClientRect();return l.value=L.top-I.top+2,u.value=I.right-L.right+2,!0},k=()=>{const N=t.value;if(!N){c.value=!1;return}const b=A(N);if(!b){v.value||(c.value=!1);return}const L=N.getElementByKey(b.getKey()),a=N.getRootElement();L&&a?(h(L,a),c.value=!0):c.value=!1};o.onChange(k);const y=N=>()=>{const b=t.value;b&&(b.update(N),O?.(),b.focus())},g=y(()=>q.$insertTableRowAtSelection(!1)),M=y(()=>q.$insertTableRowAtSelection(!0)),C=y(()=>q.$insertTableColumnAtSelection(!1)),E=y(()=>q.$insertTableColumnAtSelection(!0)),x=y(()=>q.$deleteTableRowAtSelection()),R=y(()=>q.$deleteTableColumnAtSelection()),P=y(()=>{const N=n.$getSelection();if(!n.$isRangeSelection(N))return;const b=N.anchor.getNode(),L=q.$getTableCellNodeFromLexicalNode(b);if(!L)return;q.$getTableNodeFromLexicalNodeOrThrow(L).remove()});return e.Use(W.BeatUII18n,N=>e.Ensure(t,b=>{const L=b,a=N.$.lexical,I=r=>{const _=L.value;if(!_||s.value)return;const G=_.getRootElement();if(!G)return;const D=r.target.closest("td, th");D&&G.contains(D)&&(r.preventDefault(),h(D,G)&&(c.value=!0),bt.delayedAnimationFrame(()=>{p?.()}))},S=L.value?.getRootElement(),f=S?.closest(".bc-lexical-editor-container")??S??document;return f.addEventListener("contextmenu",I),[e.OnDispose(()=>{f.removeEventListener("contextmenu",I)}),e.When(c,()=>e.html.div(e.attr.class("bc-table-cell-marker"),e.style.position("absolute"),e.style.top(l.map(r=>`${r}px`)),e.style.right(u.map(r=>`${r}px`)),e.style.zIndex("10"),e.WithElement(r=>{r.addEventListener("mousedown",_=>{_.preventDefault()})}),e.html.button(e.attr.class("bc-table-cell-marker__button"),e.attr.type("button"),e.attr.title(a.map(r=>r.tableActions)),e.attr.disabled(s),W.Icon({icon:"lucide:chevron-down",size:"xs"}),e.WithElement(r=>{const _=new MutationObserver(()=>{const G=r.getAttribute("aria-expanded")==="true";v.value=G});return _.observe(r,{attributes:!0,attributeFilter:["aria-expanded"]}),e.OnDispose(()=>_.disconnect())}),J.Menu({items:()=>[J.MenuItem({key:"insert-row-above",content:a.map(r=>r.insertRowAbove),before:W.Icon({icon:"lucide:arrow-up",size:"sm"}),onClick:g,disabled:s}),J.MenuItem({key:"insert-row-below",content:a.map(r=>r.insertRowBelow),before:W.Icon({icon:"lucide:arrow-down",size:"sm"}),onClick:M,disabled:s}),J.MenuItem({key:"insert-column-left",content:a.map(r=>r.insertColumnLeft),before:W.Icon({icon:"lucide:arrow-left",size:"sm"}),onClick:C,disabled:s}),J.MenuItem({key:"insert-column-right",content:a.map(r=>r.insertColumnRight),before:W.Icon({icon:"lucide:arrow-right",size:"sm"}),onClick:E,disabled:s}),J.MenuSeparator(),J.MenuItem({key:"delete-row",content:a.map(r=>r.deleteRow),before:W.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:x,disabled:s}),J.MenuItem({key:"delete-column",content:a.map(r=>r.deleteColumn),before:W.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:R,disabled:s}),J.MenuItem({key:"delete-table",content:a.map(r=>r.deleteTable),before:W.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:P,disabled:s})],placement:"bottom-end",showOn:(r,_)=>(p=r,O=_,e.on.click(()=>{v.value?_():(r(),v.value=!0)})),showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const r=L.value;r&&r.focus()},ariaLabel:a.map(r=>r.tableActions)}))))]}))}const po=t=>{const{value:o,format:s,plugins:c,readOnly:l,placeholder:u,class:p,namespace:O="BeatUILexical",heightMode:v="fixed",toolbar:A,autoFocus:h=!1,onError:k,onInput:y,onChange:g,onBlur:M,onReady:C}=t,E=e.prop(null),x=e.prop(0),R=N=>typeof N=="object"&&N!==null&&"map"in N&&typeof N.map=="function",P=l!=null?R(l)?l:e.prop(e.Value.get(l)):e.prop(!1);return e.Use(Ie.Theme,({appearance:N})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:b})=>Le.LinkPortal({id:"beatui-lexical-css",href:b})),e.attr.class("bc-lexical-editor-container"),v==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(p),e.When(P.map(b=>!b),()=>Ve({editor:E,stateUpdate:x,toolbar:A,readOnly:P,size:"sm"})),Xe({editor:E,stateUpdate:x,readOnly:P}),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${v}`),e.attr.contenteditable(l!=null?e.Value.map(l,b=>!b):!0),l!=null?e.attr.class(e.Value.map(l,b=>b?"bc-lexical-editor--readonly":"")):null,e.WithElement(b=>{let L=null;const a=[];return(async()=>{try{const S=c??pe("docked"),T=me(S),f=e.Value.get(s??"markdown"),r=n.createEditor({namespace:O,nodes:T,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:d=>{k?k(d,r):console.error("[BeatUI Lexical]",d)},editable:l?!e.Value.get(l):!0,html:{export:xe(),import:ue()}});L=r,E.set(r),r.setRootElement(b);const _=[];if(S.richText?_.push(he(r)):S.plainText&&_.push(be(r)),S.history){const d=typeof S.history=="object"?S.history:void 0;_.push(Ce(r,d))}if(S.clipboard&&_.push(ye(r)),S.list&&_.push(Ee(r)),S.link&&_.push(Oe(r)),S.yjs&&_.push(Se(r,S.yjs)),S.dragon&&_.push(Ne(r)),S.table&&_.push(Me(r)),(await Promise.all(_)).forEach(d=>{d&&a.push(d)}),a.push(Te(r)),a.push($e(r)),a.push(r.registerCommand(n.SELECTION_CHANGE_COMMAND,()=>(x.set(x.value+1),!1),n.COMMAND_PRIORITY_LOW)),a.push(r.registerUpdateListener(({editorState:d,dirtyElements:D,dirtyLeaves:H})=>{(D.size>0||H.size>0)&&x.set(x.value+1),y&&(D.size>0||H.size>0)&&d.read(async()=>{if(f==="markdown"){const U=await K(r);y(U,r)}else if(f==="html"){const U=await Y(r);y(U,r)}else f==="json"&&y(d.toJSON(),r)})})),o!=null){const d=e.Value.get(o);if(d!=null&&(d!==""||f==="json"&&typeof d=="object")){if(f==="markdown"&&typeof d=="string")await V(r,d);else if(f==="html"&&typeof d=="string")await X(r,d);else if(f==="json"&&typeof d=="object")try{const H=JSON.stringify(d),U=r.parseEditorState(H);r.setEditorState(U)}catch(H){console.error("[BeatUI] Failed to parse JSON editor state:",H),k&&k(H instanceof Error?H:new Error(String(H)),r)}}}if(o!=null&&a.push(e.Value.on(o,async d=>{if(d!=null){if(f==="markdown"&&typeof d=="string"){const D=await K(r);d!==D&&await V(r,d)}else if(f==="html"&&typeof d=="string"){const D=await Y(r);d!==D&&await X(r,d)}else if(f==="json"&&typeof d=="object"){const D=JSON.stringify(r.getEditorState().toJSON()),H=JSON.stringify(d);if(D!==H){const U=r.parseEditorState(H);r.setEditorState(U)}}}})),l!=null&&a.push(e.Value.on(l,d=>{r.setEditable(!d)})),a.push(r.registerCommand(n.BLUR_COMMAND,()=>(M&&M(r),g&&r.getEditorState().read(async()=>{if(f==="markdown"){const d=await K(r);g(d,r)}else if(f==="html"){const d=await Y(r);g(d,r)}else f==="json"&&g(r.getEditorState().toJSON(),r)}),!1),n.COMMAND_PRIORITY_LOW)),a.push(N.on(d=>{const D=r.getRootElement();D&&(D.dataset.theme=d)})),h)r.focus();else{const d=r.getRootElement();d&&d===document.activeElement&&d.blur()}C&&C(r)}catch(S){console.error("[BeatUI] Failed to initialize Lexical editor:",S);const T=b;T.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{a.forEach(S=>S())}catch{}try{L?.setRootElement(null)}catch{}E.set(null)})}))))};function Ze({editor:t,stateUpdate:o,groups:s=["text-formatting"],readOnly:c=e.signal(!1),size:l="sm"}){const u=e.prop(!1),p=e.prop(0),O=e.prop(0);return e.Use(W.BeatUII18n,v=>e.Ensure(t,A=>{const h=A,k=v.$.lexical,y=a=>s.includes(a),{textFormatActive:g,linkActive:M,dispatch:C,toggleLink:E}=Ye(h,o,{enterUrlMessage:()=>v.value.lexical.enterUrl}),R=Je(c,l)(e.signal(!0)),P=()=>{const a=h.value;if(!a){u.value=!1;return}const I=a.getRootElement();if(!I){u.value=!1;return}const S=window.getSelection();if(!S||S.rangeCount===0||S.isCollapsed){u.value=!1;return}const T=S.anchorNode;if(T&&!I.contains(T)){u.value=!1;return}const r=S.getRangeAt(0).getBoundingClientRect();if(r.width===0&&r.height===0){u.value=!1;return}const _=40,G=8;let d=r.top-_-G;const D=r.left+r.width/2;d<0&&(d=r.bottom+G),p.value=d,O.value=D,u.value=!0},N=o.onChange(P),b=()=>{P()};document.addEventListener("selectionchange",b);const L=e.html.div(e.attr.class("bc-floating-toolbar"),e.style.position("fixed"),e.style.top(p.map(a=>`${a}px`)),e.style.left(O.map(a=>`${a}px`)),e.style.transform("translateX(-50%)"),e.WithElement(a=>{const I=T=>{if(T.key==="Escape"&&u.value){u.value=!1;const f=h.value;f&&f.focus()}},S=T=>{if(u.value&&!a.contains(T.target)){const f=h.value;if(f){const r=f.getRootElement();if(r&&r.contains(T.target))return}u.value=!1}};return document.addEventListener("keydown",I),document.addEventListener("mousedown",S),e.OnDispose(()=>{N(),document.removeEventListener("keydown",I),document.removeEventListener("mousedown",S),document.removeEventListener("selectionchange",b)})}),...y("text-formatting")?[R({active:g("bold"),onClick:C(n.FORMAT_TEXT_COMMAND,"bold"),label:k.map(a=>a.bold),icon:"mdi:format-bold"}),R({active:g("italic"),onClick:C(n.FORMAT_TEXT_COMMAND,"italic"),label:k.map(a=>a.italic),icon:"mdi:format-italic"}),R({active:g("underline"),onClick:C(n.FORMAT_TEXT_COMMAND,"underline"),label:k.map(a=>a.underline),icon:"mdi:format-underline"}),R({active:g("strikethrough"),onClick:C(n.FORMAT_TEXT_COMMAND,"strikethrough"),label:k.map(a=>a.strikethrough),icon:"mdi:format-strikethrough"}),R({active:g("code"),onClick:C(n.FORMAT_TEXT_COMMAND,"code"),label:k.map(a=>a.code),icon:"mdi:code-tags"})]:[],...y("links")?[R({active:M(),onClick:E,label:k.map(a=>a.link),icon:"mdi:link"})]:[],...y("clipboard")?[R({active:e.signal(!1),onClick:()=>{const a=h.value;if(!a)return;const I=a.getRootElement();I&&(I.focus(),document.execCommand("cut"))},label:k.map(a=>a.cut),icon:"mdi:content-cut"}),R({active:e.signal(!1),onClick:()=>{const a=h.value;if(!a)return;const I=a.getRootElement();I&&(I.focus(),document.execCommand("copy"))},label:k.map(a=>a.copy),icon:"mdi:content-copy"}),R({active:e.signal(!1),onClick:()=>{const a=h.value;a&&navigator.clipboard.readText().then(I=>{a.update(()=>{const S=n.$getSelection();n.$isRangeSelection(S)&&S.insertText(I)}),a.focus()}).catch(()=>{})},label:k.map(a=>a.paste),icon:"mdi:content-paste"})]:[]);return e.When(u,()=>L)}))}const ho=[{id:"heading1",label:"Heading 1",description:"Large section heading",icon:"mdi:format-header-1",keywords:["h1","heading","title"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h1"))})}},{id:"heading2",label:"Heading 2",description:"Medium section heading",icon:"mdi:format-header-2",keywords:["h2","heading"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h2"))})}},{id:"heading3",label:"Heading 3",description:"Small section heading",icon:"mdi:format-header-3",keywords:["h3","heading"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h3"))})}},{id:"bullet-list",label:"Bullet List",description:"Create a bulleted list",icon:"mdi:format-list-bulleted",keywords:["ul","unordered","bullets"],category:"Lists",handler:t=>{t.dispatchCommand(F.INSERT_UNORDERED_LIST_COMMAND,void 0)}},{id:"ordered-list",label:"Ordered List",description:"Create a numbered list",icon:"mdi:format-list-numbered",keywords:["ol","numbered","1","2","3"],category:"Lists",handler:t=>{t.dispatchCommand(F.INSERT_ORDERED_LIST_COMMAND,void 0)}},{id:"quote",label:"Quote",description:"Insert a blockquote",icon:"mdi:format-quote-close",keywords:["blockquote","citation"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createQuoteNode())})}},{id:"code-block",label:"Code Block",description:"Insert a code block",icon:"mdi:code-braces",keywords:["code","pre","programming"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>ie.$createCodeNode())})}},{id:"divider",label:"Divider",description:"Insert a horizontal rule",icon:"mdi:minus",keywords:["hr","horizontal","line","separator"],category:"Basic blocks",handler:t=>{t.dispatchCommand(ce,void 0)}},{id:"table",label:"Table",description:"Insert a table",icon:"mdi:table",keywords:["table","grid","cells","rows","columns"],category:"Advanced",handler:t=>{t.dispatchCommand(q.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0})}}];function bo({commands:t,isVisible:o,filterText:s,position:c,onSelect:l,onClose:u}){const p=e.prop(0),O=s.map(y=>{const g=y.toLowerCase().trim();return g?t.filter(M=>[M.label.toLowerCase(),M.description?.toLowerCase()||"",...M.keywords?.map(E=>E.toLowerCase())||[]].join(" ").includes(g)):t});O.onChange(()=>{p.value=0});const v=y=>{const g=O.value;if(y>=0&&y<g.length){const M=g[y];l(M)}},A=y=>{if(!o.value)return;const M=O.value.length-1;switch(y.key){case"ArrowDown":y.preventDefault(),p.value=Math.min(p.value+1,M);break;case"ArrowUp":y.preventDefault(),p.value=Math.max(p.value-1,0);break;case"Enter":y.preventDefault(),v(p.value);break;case"Escape":y.preventDefault(),u();break}},h=(y,g)=>{const M=p.map(E=>E===g),C=`slash-cmd-${y.id}`;return e.html.div(e.attr.class("bc-slash-command-palette__item"),e.attr.id(C),e.attr.role("option"),e.aria.selected(M),e.WithElement(E=>{const x=()=>{p.value=g},R=()=>{v(g)};return E.addEventListener("mouseenter",x),E.addEventListener("click",R),e.OnDispose(()=>{E.removeEventListener("mouseenter",x),E.removeEventListener("click",R)})}),typeof y.icon=="string"?e.html.div(e.attr.class("bc-slash-command-palette__icon"),W.Icon({icon:y.icon,size:"sm"})):y.icon,e.html.div(e.attr.class("bc-slash-command-palette__content"),e.html.div(e.attr.class("bc-slash-command-palette__label"),y.label),y.description?e.html.div(e.attr.class("bc-slash-command-palette__description"),y.description):void 0),y.category?e.html.div(e.attr.class("bc-slash-command-palette__category"),y.category):void 0)},k=e.Use(W.BeatUII18n,y=>e.html.div(e.attr.class("bc-slash-command-palette"),e.attr.role("listbox"),e.aria.label(y.$.lexical.map(g=>g.slashCommands)),e.style.position("absolute"),e.style.top(c.map(g=>`${g.top}px`)),e.style.left(c.map(g=>`${g.left}px`)),e.WithElement(()=>(document.addEventListener("keydown",A),e.OnDispose(()=>{document.removeEventListener("keydown",A)}))),e.When(O.map(g=>g.length===0),()=>e.html.div(e.attr.class("bc-slash-command-palette__empty"),y.$.lexical.map(g=>g.noCommandsFound))),e.ForEach(O,(g,M)=>{const C=g.value;return h(C,M.index)})));return e.When(o,()=>k)}const Qe=[{id:"paragraph",label:"Paragraph",icon:"mdi:format-paragraph",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>n.$createParagraphNode())})}},{id:"heading1",label:"Heading 1",icon:"mdi:format-header-1",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h1"))})}},{id:"heading2",label:"Heading 2",icon:"mdi:format-header-2",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h2"))})}},{id:"heading3",label:"Heading 3",icon:"mdi:format-header-3",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h3"))})}},{id:"bullet-list",label:"Bullet List",icon:"mdi:format-list-bulleted",handler:t=>{t.dispatchCommand(F.INSERT_UNORDERED_LIST_COMMAND,void 0)}},{id:"ordered-list",label:"Ordered List",icon:"mdi:format-list-numbered",handler:t=>{t.dispatchCommand(F.INSERT_ORDERED_LIST_COMMAND,void 0)}},{id:"quote",label:"Quote",icon:"mdi:format-quote-close",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createQuoteNode())})}},{id:"code-block",label:"Code Block",icon:"mdi:code-braces",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>ie.$createCodeNode())})}},{id:"divider",label:"Divider",icon:"mdi:minus",handler:t=>{t.dispatchCommand(ce,void 0)}},{id:"table",label:"Table",icon:"mdi:table",handler:t=>{t.dispatchCommand(q.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0})}}];function et({editor:t,stateUpdate:o,readOnly:s=e.signal(!1),commands:c=Qe}){const l=e.prop(!1),u=e.prop(!1),p=e.prop(0),O=e.prop(0);return e.Use(W.BeatUII18n,v=>e.Ensure(t,A=>{const h=A;let k=null,y=!1,g=null,M=null;const C=24,E=4,x=200,R=f=>{if(f===k&&l.value)return;k=f;const r=f.getBoundingClientRect();p.value=r.top,O.value=r.left-C-E,l.value=!0},P=()=>{g!=null&&(clearTimeout(g),g=null)},N=()=>{u.value||(P(),g=setTimeout(()=>{g=null,u.value||(l.value=!1,k=null)},x))},b=()=>{const f=h.value;if(!f)return;const r=f.getRootElement();r&&(I(r),f.getEditorState().read(()=>{const _=n.$getSelection();if(n.$isRangeSelection(_))try{const d=_.anchor.getNode().getTopLevelElementOrThrow(),D=f.getElementByKey(d.getKey());D&&R(D)}catch{}}))},L=f=>{if(u.value)return;const r=h.value;if(!r)return;const _=r.getRootElement();if(_)for(const G of Array.from(_.children)){const d=G.getBoundingClientRect();if(f.clientY>=d.top&&f.clientY<=d.bottom){P(),R(G);return}}},a=()=>{N()},I=f=>{y||(y=!0,f.addEventListener("mousemove",L),f.addEventListener("mouseleave",a))},S=o.onChange(b);return[e.OnDispose(()=>{S(),P();const f=h.value;if(f){const r=f.getRootElement();r&&y&&(r.removeEventListener("mousemove",L),r.removeEventListener("mouseleave",a))}}),e.When(l,()=>e.html.div(e.attr.class("bc-block-handle"),e.style.position("fixed"),e.style.top(p.map(f=>`${f}px`)),e.style.left(O.map(f=>`${f}px`)),e.on.mouseenter(P),e.on.mouseleave(()=>N()),e.WithElement(f=>{f.addEventListener("mousedown",r=>{r.preventDefault()})}),e.html.button(e.attr.class("bc-block-handle__button"),e.attr.type("button"),e.attr.title(v.$.lexical.map(f=>f.changeBlockType)),e.attr.disabled(s),W.Icon({icon:"mdi:drag-horizontal-variant",size:"sm"}),e.WithElement(f=>{const r=new MutationObserver(()=>{const _=f.getAttribute("aria-expanded")==="true";u.value=_});return r.observe(f,{attributes:!0,attributeFilter:["aria-expanded"]}),e.OnDispose(()=>r.disconnect())}),J.Menu({items:()=>c.map(f=>J.MenuItem({key:f.id,content:f.label,before:W.Icon({icon:f.icon,size:"sm"}),onClick:()=>{const r=h.value;r&&(f.handler(r),M?.(),r.focus())}})),placement:"bottom-start",showOn:(f,r)=>(M=r,e.on.click(()=>{u.value?r():(f(),u.value=!0)})),showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const f=h.value;f&&f.focus()},ariaLabel:v.value.lexical.blockTypes}))))]}))}const Co=t=>{const{value:o,format:s,plugins:c,readOnly:l,placeholder:u,class:p,namespace:O="BeatUILexical",heightMode:v="auto",floatingToolbarGroups:A,autoFocus:h=!1,onError:k,onInput:y,onChange:g,onBlur:M,onReady:C}=t,E=e.prop(null),x=e.prop(0),R=N=>typeof N=="object"&&N!==null&&"map"in N&&typeof N.map=="function",P=l!=null?R(l)?l:e.prop(e.Value.get(l)):e.prop(!1);return e.Use(Ie.Theme,({appearance:N})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:b})=>Le.LinkPortal({id:"beatui-lexical-css",href:b})),e.attr.class("bc-lexical-editor-container"),v==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(p),Ze({editor:E,stateUpdate:x,groups:A??["text-formatting","links"],readOnly:P}),et({editor:E,stateUpdate:x,readOnly:P}),Xe({editor:E,stateUpdate:x,readOnly:P}),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${v}`),e.attr.contenteditable(l!=null?e.Value.map(l,b=>!b):!0),l!=null?e.attr.class(e.Value.map(l,b=>b?"bc-lexical-editor--readonly":"")):null,e.WithElement(b=>{let L=null;const a=[];return(async()=>{try{const S=c??pe("contextual"),T=me(S),f=e.Value.get(s??"markdown"),r=n.createEditor({namespace:O,nodes:T,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:d=>{k?k(d,r):console.error("[BeatUI Lexical]",d)},editable:l?!e.Value.get(l):!0,html:{export:xe(),import:ue()}});L=r,E.set(r),r.setRootElement(b);const _=[];if(S.richText?_.push(he(r)):S.plainText&&_.push(be(r)),S.history){const d=typeof S.history=="object"?S.history:void 0;_.push(Ce(r,d))}if(S.clipboard&&_.push(ye(r)),S.list&&_.push(Ee(r)),S.link&&_.push(Oe(r)),S.yjs&&_.push(Se(r,S.yjs)),S.dragon&&_.push(Ne(r)),S.table&&_.push(Me(r)),(await Promise.all(_)).forEach(d=>{d&&a.push(d)}),a.push(Te(r)),a.push($e(r)),a.push(r.registerCommand(n.SELECTION_CHANGE_COMMAND,()=>(x.set(x.value+1),!1),n.COMMAND_PRIORITY_LOW)),a.push(r.registerUpdateListener(({editorState:d,dirtyElements:D,dirtyLeaves:H})=>{(D.size>0||H.size>0)&&x.set(x.value+1),y&&(D.size>0||H.size>0)&&d.read(async()=>{if(f==="markdown"){const U=await K(r);y(U,r)}else if(f==="html"){const U=await Y(r);y(U,r)}else f==="json"&&y(d.toJSON(),r)})})),o!=null){const d=e.Value.get(o);if(d!=null&&(d!==""||f==="json"&&typeof d=="object")){if(f==="markdown"&&typeof d=="string")await V(r,d);else if(f==="html"&&typeof d=="string")await X(r,d);else if(f==="json"&&typeof d=="object")try{const H=JSON.stringify(d),U=r.parseEditorState(H);r.setEditorState(U)}catch(H){console.error("[BeatUI] Failed to parse JSON editor state:",H),k&&k(H instanceof Error?H:new Error(String(H)),r)}}}if(o!=null&&a.push(e.Value.on(o,async d=>{if(d!=null){if(f==="markdown"&&typeof d=="string"){const D=await K(r);d!==D&&await V(r,d)}else if(f==="html"&&typeof d=="string"){const D=await Y(r);d!==D&&await X(r,d)}else if(f==="json"&&typeof d=="object"){const D=JSON.stringify(r.getEditorState().toJSON()),H=JSON.stringify(d);if(D!==H){const U=r.parseEditorState(H);r.setEditorState(U)}}}})),l!=null&&a.push(e.Value.on(l,d=>{r.setEditable(!d)})),a.push(r.registerCommand(n.BLUR_COMMAND,()=>(M&&M(r),g&&r.getEditorState().read(async()=>{if(f==="markdown"){const d=await K(r);g(d,r)}else if(f==="html"){const d=await Y(r);g(d,r)}else f==="json"&&g(r.getEditorState().toJSON(),r)}),!1),n.COMMAND_PRIORITY_LOW)),a.push(N.on(d=>{const D=r.getRootElement();D&&(D.dataset.theme=d)})),h)r.focus();else{const d=r.getRootElement();d&&d===document.activeElement&&d.blur()}C&&C(r)}catch(S){console.error("[BeatUI] Failed to initialize Lexical editor:",S);const T=b;T.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{a.forEach(S=>S())}catch{}try{L?.setRootElement(null)}catch{}E.set(null)})}))))},yo=t=>{const{value:o,before:s,after:c,onChange:l,onInput:u,onBlur:p,disabled:O,hasError:v,name:A,placeholder:h,id:k,required:y,tabIndex:g,size:M,class:C,namespace:E,format:x,plugins:R,readOnly:P,onError:N,onReady:b,marks:L,autoFocus:a}=t,I=O!=null&&P!=null?e.computedOf(O,P)((S,T)=>(S??!1)||(T??!1)):O??P;return Ct.InputContainer({disabled:O,hasError:v,size:M,baseContainer:!0,growInput:!0,focusableSelector:"[contenteditable]",before:s,after:c,input:e.html.div(e.attr.class("bc-lexical-editor-input"),e.attr.name(A),e.attr.id(k),y!=null?e.aria.required(y):null,g!=null?e.attr.tabindex(g):null,v!=null?e.attr.class(e.Value.map(v,S=>S?"bc-lexical-editor-input--error":"")):null,Ke({value:o,format:x??"markdown",plugins:R,readOnly:I,placeholder:h,namespace:E,class:C,autoFocus:a,onError:N,onReady:b,onInput:u?(S,T)=>{u(S)}:void 0,onChange:l?(S,T)=>{l(S)}:void 0,onBlur:p?S=>{p()}:void 0}))})};Object.defineProperty(exports,"INSERT_CHECK_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_CHECK_LIST_COMMAND});Object.defineProperty(exports,"INSERT_ORDERED_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_ORDERED_LIST_COMMAND});Object.defineProperty(exports,"INSERT_UNORDERED_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_UNORDERED_LIST_COMMAND});Object.defineProperty(exports,"REMOVE_LIST_COMMAND",{enumerable:!0,get:()=>F.REMOVE_LIST_COMMAND});Object.defineProperty(exports,"BLUR_COMMAND",{enumerable:!0,get:()=>n.BLUR_COMMAND});Object.defineProperty(exports,"CLEAR_EDITOR_COMMAND",{enumerable:!0,get:()=>n.CLEAR_EDITOR_COMMAND});Object.defineProperty(exports,"CLICK_COMMAND",{enumerable:!0,get:()=>n.CLICK_COMMAND});Object.defineProperty(exports,"COMMAND_PRIORITY_CRITICAL",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_CRITICAL});Object.defineProperty(exports,"COMMAND_PRIORITY_EDITOR",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_EDITOR});Object.defineProperty(exports,"COMMAND_PRIORITY_HIGH",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_HIGH});Object.defineProperty(exports,"COMMAND_PRIORITY_LOW",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_LOW});Object.defineProperty(exports,"COMMAND_PRIORITY_NORMAL",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_NORMAL});Object.defineProperty(exports,"COPY_COMMAND",{enumerable:!0,get:()=>n.COPY_COMMAND});Object.defineProperty(exports,"CUT_COMMAND",{enumerable:!0,get:()=>n.CUT_COMMAND});Object.defineProperty(exports,"DecoratorNode",{enumerable:!0,get:()=>n.DecoratorNode});Object.defineProperty(exports,"ElementNode",{enumerable:!0,get:()=>n.ElementNode});Object.defineProperty(exports,"FOCUS_COMMAND",{enumerable:!0,get:()=>n.FOCUS_COMMAND});Object.defineProperty(exports,"FORMAT_ELEMENT_COMMAND",{enumerable:!0,get:()=>n.FORMAT_ELEMENT_COMMAND});Object.defineProperty(exports,"FORMAT_TEXT_COMMAND",{enumerable:!0,get:()=>n.FORMAT_TEXT_COMMAND});Object.defineProperty(exports,"INDENT_CONTENT_COMMAND",{enumerable:!0,get:()=>n.INDENT_CONTENT_COMMAND});Object.defineProperty(exports,"INSERT_PARAGRAPH_COMMAND",{enumerable:!0,get:()=>n.INSERT_PARAGRAPH_COMMAND});Object.defineProperty(exports,"KEY_ENTER_COMMAND",{enumerable:!0,get:()=>n.KEY_ENTER_COMMAND});Object.defineProperty(exports,"KEY_ESCAPE_COMMAND",{enumerable:!0,get:()=>n.KEY_ESCAPE_COMMAND});Object.defineProperty(exports,"KEY_TAB_COMMAND",{enumerable:!0,get:()=>n.KEY_TAB_COMMAND});Object.defineProperty(exports,"OUTDENT_CONTENT_COMMAND",{enumerable:!0,get:()=>n.OUTDENT_CONTENT_COMMAND});Object.defineProperty(exports,"PASTE_COMMAND",{enumerable:!0,get:()=>n.PASTE_COMMAND});Object.defineProperty(exports,"REDO_COMMAND",{enumerable:!0,get:()=>n.REDO_COMMAND});Object.defineProperty(exports,"SELECTION_CHANGE_COMMAND",{enumerable:!0,get:()=>n.SELECTION_CHANGE_COMMAND});Object.defineProperty(exports,"TextNode",{enumerable:!0,get:()=>n.TextNode});Object.defineProperty(exports,"UNDO_COMMAND",{enumerable:!0,get:()=>n.UNDO_COMMAND});Object.defineProperty(exports,"createCommand",{enumerable:!0,get:()=>n.createCommand});exports.$createHorizontalRuleNode=se;exports.$isHorizontalRuleNode=Ue;exports.BareEditor=Ke;exports.BlockHandle=et;exports.ContextualEditor=Co;exports.DEFAULT_BLOCK_COMMANDS=Qe;exports.DEFAULT_INLINE_STYLE_PROPERTIES=qe;exports.DEFAULT_SLASH_COMMANDS=ho;exports.DockedEditor=po;exports.FloatingToolbar=Ze;exports.HR_TRANSFORMER=Ge;exports.HorizontalRuleNode=oe;exports.INSERT_HORIZONTAL_RULE_COMMAND=ce;exports.INSERT_IMAGE_COMMAND=xt;exports.LexicalEditorInput=yo;exports.LexicalToolbar=Ve;exports.SlashCommandPalette=bo;exports.TOGGLE_SLASH_COMMAND_PALETTE=St;exports.TOOLBAR_SEPARATOR=Ot;exports.applyMark=Ut;exports.buildInlineStyleImportMap=We;exports.buildStyleImportMap=ue;exports.createDefaultPluginConfig=pe;exports.createHeadlessEditor=de;exports.executeSlashCommand=Nt;exports.exportEditorToFile=_t;exports.exportToHtml=Y;exports.exportToMarkdown=K;exports.getCharacterCount=Wt;exports.getMarkdownTransformers=kt;exports.getNodesForPlugins=me;exports.getSelectionInfo=qt;exports.getTextContent=we;exports.getWordCount=Kt;exports.htmlToLexicalJson=ro;exports.importFileToEditor=vt;exports.importFromHtml=X;exports.importFromMarkdown=V;exports.insertTable=At;exports.insertTextAtCursor=Yt;exports.lexicalJsonToHtml=io;exports.lexicalJsonToMarkdown=no;exports.loadLexicalCore=ze;exports.loadOffsetUtils=Jt;exports.markdownToLexicalJson=oo;exports.registerAutoLinkPlugin=Bt;exports.registerClipboardPlugin=ye;exports.registerCodePlugin=Lt;exports.registerCodeShikiPlugin=It;exports.registerDragonPlugin=Ne;exports.registerHashtagPlugin=$t;exports.registerHistoryPlugin=Ce;exports.registerHorizontalRulePlugin=Te;exports.registerLinkPlugin=Oe;exports.registerListPlugin=Ee;exports.registerMarkPlugin=jt;exports.registerOverflowPlugin=Gt;exports.registerPlainTextPlugin=be;exports.registerRichTextPlugin=he;exports.registerSlashCommandsPlugin=Mt;exports.registerTablePlugin=Me;exports.registerYjsPlugin=Se;exports.removeMark=zt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("@lexical/rich-text"),F=require("@lexical/list"),G=require("@lexical/table"),ee=require("@lexical/link"),ie=require("@lexical/code"),Re=require("@lexical/hashtag"),ne=require("@lexical/mark"),dt=require("@lexical/overflow"),n=require("lexical"),ft=require("@lexical/plain-text"),Fe=require("@lexical/history");require("@lexical/clipboard");const Ae=require("@lexical/markdown"),Be=require("@lexical/html"),B=require("@lexical/selection"),gt=require("@lexical/text"),ge=require("@lexical/utils"),mt=require("@lexical/offset"),pt=require("@lexical/dragon");require("@lexical/file");const ht=require("@lexical/yjs");require("@lexical/headless");const e=require("@tempots/dom"),Le=require("../link-portal-_tiDFZqh.cjs"),Ie=require("../theme-DogY9oT1.cjs"),J=require("../menu-B60Q9j3-.cjs"),q=require("../translations-Dbx7L7Q1.cjs"),ve=require("../editor-toolbar-group-mkL4QozO.cjs"),bt=require("@tempots/std"),je=require("../toolbar-DoKdYXIL.cjs"),Ct=require("../input-container-Di1YvVB_.cjs");function ae(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const s=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(o,a,s.get?s:{enumerable:!0,get:()=>t[a]})}}return o.default=t,Object.freeze(o)}const fe=ae(G),re=ae(ie),yt=ae(n),Et=ae(mt),ke=ae(pt),Ot={separator:!0};class oe extends n.DecoratorNode{static getType(){return"horizontal-rule"}static clone(o){return new oe(o.__key)}static importJSON(o){return se()}static importDOM(){return{hr:()=>({conversion:Tt,priority:0})}}exportJSON(){return{...super.exportJSON(),type:"horizontal-rule",version:1}}exportDOM(){return{element:document.createElement("hr")}}createDOM(){return document.createElement("hr")}updateDOM(){return!1}getTextContent(){return`
|
|
2
|
+
`}isInline(){return!1}decorate(){return null}}function Tt(){return{node:se()}}function se(){return n.$applyNodeReplacement(new oe)}function Ue(t){return t instanceof oe}function me(t){const o=[j.HeadingNode,j.QuoteNode,F.ListNode,F.ListItemNode,ee.LinkNode,ie.CodeNode,ie.CodeHighlightNode,oe];return t.table&&o.push(G.TableNode,G.TableCellNode,G.TableRowNode),t.autoLink&&o.push(ee.AutoLinkNode),t.hashtag&&o.push(Re.HashtagNode),t.mark&&o.push(ne.MarkNode),t.overflow&&o.push(dt.OverflowNode),[...new Set(o)]}function pe(t){switch(t){case"bare":return{richText:!0,history:!0,clipboard:!0};case"docked":return{richText:!0,history:!0,clipboard:!0,list:!0,link:!0,autoLink:!0,code:!0,table:!0};case"contextual":return{richText:!0,history:!0,clipboard:!0,list:!0,link:!0,autoLink:!0,code:!0,table:!0}}}async function ze(){return yt}async function he(t){return j.registerRichText(t)}async function be(t){return ft.registerPlainText(t)}async function Ce(t,o){const a=Fe.createEmptyHistoryState(),s=o?.delay??300;return Fe.registerHistory(t,a,s)}async function ye(t){return()=>{}}async function Ee(t){return typeof F.registerList=="function"?typeof F.registerCheckList=="function"?ge.mergeRegister(F.registerList(t),F.registerCheckList(t)):F.registerList(t):ge.mergeRegister(t.registerCommand(F.INSERT_ORDERED_LIST_COMMAND,()=>(F.insertList(t,"number"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.INSERT_UNORDERED_LIST_COMMAND,()=>(F.insertList(t,"bullet"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.INSERT_CHECK_LIST_COMMAND,()=>(F.insertList(t,"check"),!0),n.COMMAND_PRIORITY_LOW),t.registerCommand(F.REMOVE_LIST_COMMAND,()=>(F.removeList(t),!0),n.COMMAND_PRIORITY_LOW))}async function Oe(t){return t.registerCommand(ee.TOGGLE_LINK_COMMAND,o=>(o===null||typeof o=="string"?ee.toggleLink(o):ee.toggleLink(o.url,o),!0),n.COMMAND_PRIORITY_LOW)}async function Nt(t,o,a){const s=o?.trigger||"/";let i=!1,u=null,h=0;const O=()=>t.getEditorState().read(()=>{const y=n.$getSelection();if(!n.$isRangeSelection(y)||!y.isCollapsed())return!1;const E=y.anchor,M=E.getNode();if(!n.$isTextNode(M))return!1;const _=M.getTextContent(),I=E.offset;if(I===0||_[I-1]!==s)return!1;if(I===1)return!0;const C=_[I-2];return!!/\s/.test(C)}),A=()=>u?t.getEditorState().read(()=>{if(!u)return"";const y=u.getTextContent(),E=y.indexOf(s,h);if(E===-1)return"";const M=n.$getSelection();if(!n.$isRangeSelection(M))return"";const _=M.anchor;if(_.getNode().getKey()!==u.getKey())return"";const N=_.offset;return N<=E?"":y.slice(E+1,N)}):"",R=()=>{t.getEditorState().read(()=>{const y=n.$getSelection();if(n.$isRangeSelection(y)){const E=y.anchor,M=E.getNode();if(n.$isTextNode(M)){u=M,h=E.offset-1,i=!0;const _={isActive:!0,filterText:"",anchorNode:u,anchorOffset:h};a?.onTrigger?.(_,k),a?.onUpdate?.(_,k)}}})},b=()=>{i&&(i=!1,u=null,h=0,a?.onClose?.())},k=()=>{u&&t.update(()=>{if(!u)return;const y=u.getTextContent(),E=y.indexOf(s,h);if(E===-1)return;const M=n.$getSelection();if(!n.$isRangeSelection(M))return;const _=M.anchor;if(_.getNode().getKey()!==u.getKey())return;const N=_.offset,C=y.slice(0,E),v=y.slice(N);u.setTextContent(C+v);const c=n.$getSelection();n.$isRangeSelection(c)&&(c.anchor.set(u.getKey(),E,"text"),c.focus.set(u.getKey(),E,"text"))})},S=()=>{if(!i)return;const E={isActive:!0,filterText:A(),anchorNode:u,anchorOffset:h};a?.onUpdate?.(E,k)},m=t.registerMutationListener(n.TextNode,y=>{if(!i&&O()){R();return}i&&(u&&!y.has(u.getKey())?S():b())}),T=ge.mergeRegister(t.registerUpdateListener(({editorState:y})=>{y.read(()=>{if(!i)return;const E=n.$getSelection();if(!n.$isRangeSelection(E)){b();return}const M=E.anchor,_=M.getNode();if(!u||_.getKey()!==u.getKey()){b();return}const N=u.getTextContent().indexOf(s,h);if(N===-1||M.offset<=N){b();return}})}),t.registerCommand(n.KEY_ARROW_DOWN_COMMAND,y=>i?(y.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ARROW_UP_COMMAND,y=>i?(y.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ENTER_COMMAND,y=>i?(y?.preventDefault(),!0):!1,n.COMMAND_PRIORITY_LOW),t.registerCommand(n.KEY_ESCAPE_COMMAND,y=>i?(y?.preventDefault(),b(),!0):!1,n.COMMAND_PRIORITY_LOW));return()=>{b(),m(),T()}}function St(t,o,a){a(),o.handler(t),t.focus()}const Mt=n.createCommand("TOGGLE_SLASH_COMMAND_PALETTE"),ce=n.createCommand("INSERT_HORIZONTAL_RULE_COMMAND"),xt=n.createCommand("INSERT_IMAGE_COMMAND");function Te(t){return t.registerCommand(ce,()=>{const o=n.$getSelection();if(!n.$isRangeSelection(o))return!1;if(o.focus.getNode()!==null){const s=se();o.insertNodes([s]);const i=n.$createParagraphNode();s.insertAfter(i),i.selectStart()}return!0},n.COMMAND_PRIORITY_LOW)}const Ge={dependencies:[oe],export:t=>Ue(t)?"---":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(t,o,a,s)=>{const i=se();if(s)t.replace(i);else{t.replace(i);const u=n.$createParagraphNode();i.insertAfter(u),u.selectStart()}},type:"element"},De=[...Ae.TRANSFORMERS,Ge];async function K(t){let o="";return t.getEditorState().read(()=>{o=Ae.$convertToMarkdownString(De)}),o}async function V(t,o){t.update(()=>{Ae.$convertFromMarkdownString(o,De)})}async function kt(){return De}async function Y(t){let o="";return t.getEditorState().read(()=>{o=Be.$generateHtmlFromNodes(t)}),o}async function X(t,o){t.update(()=>{const s=new DOMParser().parseFromString(o,"text/html"),i=Be.$generateNodesFromDOM(t,s);n.$getRoot().clear(),n.$insertNodes(i)})}async function _t(t,o,a){let s,i,u;switch(o){case"markdown":s=await K(t),i="text/markdown",u="md";break;case"html":s=await Y(t),i="text/html",u="html";break;case"json":s=JSON.stringify(t.getEditorState().toJSON(),null,2),i="application/json",u="json";break}const h=new Blob([s],{type:i}),O=URL.createObjectURL(h),A=document.createElement("a");A.href=O,A.download=a??`document.${u}`,A.click(),URL.revokeObjectURL(O)}async function vt(t,o,a){const s=await new Promise((u,h)=>{const O=new FileReader;O.onload=()=>u(O.result),O.onerror=()=>h(O.error),O.readAsText(o)});switch(a??Rt(o.name)){case"markdown":{await V(t,s);break}case"html":{await X(t,s);break}case"json":{const u=t.parseEditorState(s);t.setEditorState(u);break}}}function Rt(t){return t.endsWith(".md")||t.endsWith(".markdown")?"markdown":t.endsWith(".html")||t.endsWith(".htm")?"html":"json"}async function Ne(t,o){return"registerTablePlugin"in fe&&typeof fe.registerTablePlugin=="function"?fe.registerTablePlugin(t):()=>{}}async function At(t,o=3,a=3){t.dispatchCommand(fe.INSERT_TABLE_COMMAND,{rows:String(o),columns:String(a),includeHeaders:!0})}async function Lt(t,o){return"registerCodeHighlighting"in re&&typeof re.registerCodeHighlighting=="function"?re.registerCodeHighlighting(t):()=>{}}async function It(t,o){return"registerCodeHighlighting"in re&&typeof re.registerCodeHighlighting=="function"?re.registerCodeHighlighting(t):()=>{}}const Dt=/#[\w\u0590-\u05ff]+/;function wt(t){return new Re.HashtagNode(t)}async function $t(t,o){const a=[],s=gt.registerLexicalTextEntity(t,i=>{const u=Dt.exec(i);return u?{start:u.index,end:u.index+u[0].length}:null},Re.HashtagNode,wt);if(Array.isArray(s)?a.push(...s):typeof s=="function"&&a.push(s),o?.onHashtagClick){const i=t.registerCommand(n.CLICK_COMMAND,u=>{const h=u.target;if(h.classList.contains("bc-lexical-hashtag")){const O=h.textContent;if(O)return o.onHashtagClick(O.replace("#","")),!0}return!1},n.COMMAND_PRIORITY_LOW);a.push(i)}return()=>{a.forEach(i=>i())}}const Pt=/((https?:\/\/(www\.)?|www\.)[^\s<>]+)/g,Ht=/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/g,Ft=[{pattern:Pt,urlTransformer:t=>t.startsWith("http")?t:`https://${t}`},{pattern:Ht,urlTransformer:t=>`mailto:${t}`}];async function Bt(t,o){const a=o?.matchers??Ft;return t.registerMutationListener(n.TextNode,s=>{t.update(()=>{for(const[i,u]of s){if(u!=="created"&&u!=="updated")continue;const h=n.$getNodeByKey(i);if(!h||!n.$isTextNode(h))continue;const O=h.getTextContent();for(const A of a){const R=new RegExp(A.pattern.source,A.pattern.flags);let b;for(;(b=R.exec(O))!==null;)A.urlTransformer(b[0])}}})})}async function jt(t,o){const a=[];return o?.onMarkClick&&a.push(t.registerCommand(n.CLICK_COMMAND,s=>{const i=s.target;if(i.classList.contains("bc-lexical-mark")){const u=i.dataset.markId;if(u)return o.onMarkClick(u,{id:u,type:i.dataset.markType||"annotation",data:{}}),!0}return!1},n.COMMAND_PRIORITY_LOW)),()=>a.forEach(s=>s())}async function Ut(t,o,a){t.update(()=>{const s=n.$getSelection();n.$isRangeSelection(s)&&ne.$wrapSelectionInMarkNode(s,s.isBackward(),o)})}async function zt(t,o){t.update(()=>{const s=n.$getRoot().getAllTextNodes().filter(i=>{const u=i.getParent();return ne.$isMarkNode(u)?ne.$getMarkIDs(i,0)?.includes(o)??!1:!1});for(const i of s){const u=i.getParent();ne.$isMarkNode(u)&&ne.$unwrapMarkNode(u)}})}async function Gt(t,o){const{maxLength:a,onOverflow:s}=o;return t.registerUpdateListener(({editorState:i})=>{i.read(()=>{const O=n.$getRoot().getTextContent().length,A=O>a;s&&s(A,O)})})}async function Se(t){return"registerDragonSupport"in ke&&typeof ke.registerDragonSupport=="function"?ke.registerDragonSupport(t):()=>{}}async function Me(t,o){const a=o.docMap??new Map,s=o.id??"lexical",i=o.doc.getText(s),u=ht.createBinding(t,o.provider,i,o.doc,a),h=t.registerUpdateListener(()=>{});return()=>{h(),u&&typeof u.destroy=="function"&&u.destroy()}}function qt(t){let o={hasSelection:!1,selectedText:"",anchorOffset:0,focusOffset:0};return t.getEditorState().read(()=>{const a=n.$getSelection();n.$isRangeSelection(a)&&(o={hasSelection:!a.isCollapsed(),selectedText:a.getTextContent(),anchorOffset:a.anchor.offset,focusOffset:a.focus.offset})}),o}function we(t){let o="";return t.getEditorState().read(()=>{o=n.$getRoot().getTextContent()}),o}function Wt(t){return we(t).length}function Kt(t){const o=we(t).trim();return o?o.split(/\s+/).length:0}function Yt(t,o){t.update(()=>{const a=n.$getSelection();n.$isRangeSelection(a)&&a.insertText(o)}),t.focus()}async function Jt(){return Et}function le(t,o,a){const s=new Map;if(t)for(const i of t.split(";")){const u=i.trim();if(!u)continue;const h=u.indexOf(":");if(h===-1)continue;const O=u.slice(0,h).trim(),A=u.slice(h+1).trim();s.set(O,A)}return a?s.set(o,a):s.delete(o),s.size===0?"":Array.from(s.entries()).map(([i,u])=>`${i}: ${u}`).join("; ")}function te(t,o){if(!t)return"";const a=new RegExp(`(?:^|;)\\s*${o.replace(/-/g,"\\-")}:\\s*([^;]+)`),s=t.match(a);return s?s[1].trim():""}function Vt(t,o){const a=t.getElementByKey(o);a&&t.getEditorState().read(()=>{const s=n.$getNodeByKey(o);if(!n.$isElementNode(s)||n.$isRootNode(s))return;const i=s.getStyle(),u=te(i,"background-color");a.style.backgroundColor=u||"";const h=te(i,"line-height");a.style.lineHeight=h||""})}function $e(t){const o=t.registerUpdateListener(({dirtyElements:a})=>{if(a.size!==0)for(const[s]of a)Vt(t,s)});return t.getEditorState().read(()=>{const a=n.$getRoot();for(const s of a.getChildren())if(n.$isElementNode(s)){const i=s.getStyle();if(i){const u=t.getElementByKey(s.getKey());if(u){const h=te(i,"background-color");h&&(u.style.backgroundColor=h);const O=te(i,"line-height");O&&(u.style.lineHeight=O)}}}}),o}function _e(t,o){const a=o.exportDOM(t);if(a.element&&ge.isHTMLElement(a.element)&&n.$isElementNode(o)){const s=o.getStyle(),i=te(s,"background-color");i&&(a.element.style.backgroundColor=i);const u=te(s,"line-height");u&&(a.element.style.lineHeight=u)}return a}function xe(){const t=new Map;return t.set(n.ParagraphNode,_e),t.set(j.HeadingNode,_e),t.set(j.QuoteNode,_e),t}function Xt(){const t=o=>()=>({conversion:a=>{const s=o(a);if(s&&n.$isElementNode(s)){a.style?.textAlign&&s.setFormat(a.style.textAlign);let i="";a.style?.backgroundColor&&(i=le(i,"background-color",a.style.backgroundColor)),a.style?.lineHeight&&(i=le(i,"line-height",a.style.lineHeight)),i&&s.setStyle(i)}return{node:s}},priority:1});return{p:t(()=>n.$createParagraphNode()),h1:t(()=>j.$createHeadingNode("h1")),h2:t(()=>j.$createHeadingNode("h2")),h3:t(()=>j.$createHeadingNode("h3")),h4:t(()=>j.$createHeadingNode("h4")),h5:t(()=>j.$createHeadingNode("h5")),h6:t(()=>j.$createHeadingNode("h6"))}}const qe=["color","font-size","font-family","background-color","line-height"],Zt=new Set(["font-weight","font-style","text-decoration","text-decoration-line","vertical-align"]),Qt={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"},eo=["span","b","em","i","strong","u","s","sub","sup","code","mark"];function to(t,o,a){if(!n.$isTextNode(o))return;const s=t.fontWeight,i=t.textDecoration.split(" ");(s==="700"||s==="bold")&&!o.hasFormat("bold")&&o.toggleFormat("bold"),t.fontStyle==="italic"&&!o.hasFormat("italic")&&o.toggleFormat("italic"),i.includes("line-through")&&!o.hasFormat("strikethrough")&&o.toggleFormat("strikethrough"),i.includes("underline")&&!o.hasFormat("underline")&&o.toggleFormat("underline"),t.verticalAlign==="sub"&&!o.hasFormat("subscript")&&o.toggleFormat("subscript"),t.verticalAlign==="super"&&!o.hasFormat("superscript")&&o.toggleFormat("superscript"),a&&!o.hasFormat(a)&&o.toggleFormat(a)}function We(t=qe){const o={};for(const a of eo)o[a]=s=>{const i=s.style,u=Qt[a],h=a==="b"?i.fontWeight!=="normal"?"bold":void 0:u;return{conversion:()=>({node:null,forChild:O=>{if(!n.$isTextNode(O))return O;to(i,O,h);let A=O.getStyle();for(const R of t){if(Zt.has(R))continue;const b=i.getPropertyValue(R);b&&(A=le(A,R,b))}return A&&O.setStyle(A),O}}),priority:1}};return o}function ue(t){return{...Xt(),...We(t)}}async function de(t={}){const{nodes:o=[],plugins:a=[],onError:s}=t,u=(await ze()).createEditor({namespace:"BeatUIHeadless",nodes:o,onError:h=>{s?s(h,u):console.error("[BeatUI Headless]",h)},editable:!1,html:{export:xe(),import:ue()}});if(a.length>0)for(const h of a)h.register(u);return u}async function oo(t){const o=await de();return await V(o,t),o.getEditorState().toJSON()}async function no(t){const o=await de(),a=o.parseEditorState(JSON.stringify(t));return o.setEditorState(a),await K(o)}async function ro(t){const o=await de();return await X(o,t),o.getEditorState().toJSON()}async function io(t){const o=await de(),a=o.parseEditorState(JSON.stringify(t));return o.setEditorState(a),await Y(o)}const Ke=t=>{const{value:o,format:a,plugins:s,readOnly:i,placeholder:u,class:h,namespace:O="BeatUILexical",heightMode:A="auto",autoFocus:R=!1,onError:b,onInput:k,onChange:S,onBlur:m,onReady:T}=t;return e.Use(Ie.Theme,({appearance:y})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:E})=>Le.LinkPortal({id:"beatui-lexical-css",href:E})),e.attr.class("bc-lexical-editor-container"),A==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(h),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${A}`),e.attr.contenteditable(i!=null?e.Value.map(i,E=>!E):!0),i!=null?e.attr.class(e.Value.map(i,E=>E?"bc-lexical-editor--readonly":"")):null,e.WithElement(E=>{let M=null;const _=[];return(async()=>{try{const N=s??pe("bare"),C=me(N),v=e.Value.get(a??"markdown"),c=n.createEditor({namespace:O,nodes:C,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:f=>{b?b(f,c):console.error("[BeatUI Lexical]",f)},editable:i?!e.Value.get(i):!0,html:{export:xe(),import:ue()}});M=c,c.setRootElement(E);const D=[];if(N.richText?D.push(he(c)):N.plainText&&D.push(be(c)),N.history){const f=typeof N.history=="object"?N.history:void 0;D.push(Ce(c,f))}if(N.clipboard&&D.push(ye(c)),N.list&&D.push(Ee(c)),N.link&&D.push(Oe(c)),N.yjs&&D.push(Me(c,N.yjs)),N.dragon&&D.push(Se(c)),N.table&&D.push(Ne(c)),(await Promise.all(D)).forEach(f=>{f&&_.push(f)}),_.push(Te(c)),_.push($e(c)),o!=null){const f=e.Value.get(o);if(f!=null&&(f!==""||v==="json"&&typeof f=="object")){if(v==="markdown"&&typeof f=="string")await V(c,f);else if(v==="html"&&typeof f=="string")await X(c,f);else if(v==="json"&&typeof f=="object")try{const l=JSON.stringify(f),L=c.parseEditorState(l);c.setEditorState(L)}catch(l){console.error("[BeatUI] Failed to parse JSON editor state:",l),b&&b(l instanceof Error?l:new Error(String(l)),c)}}}if(_.push(c.registerUpdateListener(({editorState:f,dirtyElements:d,dirtyLeaves:l})=>{d.size===0&&l.size===0||k&&f.read(async()=>{if(v==="markdown"){const L=await K(c);k(L,c)}else if(v==="html"){const L=await Y(c);k(L,c)}else v==="json"&&k(f.toJSON(),c)})})),o!=null&&_.push(e.Value.on(o,async f=>{if(f!=null){if(v==="markdown"&&typeof f=="string"){const d=await K(c);f!==d&&await V(c,f)}else if(v==="html"&&typeof f=="string"){const d=await Y(c);f!==d&&await X(c,f)}else if(v==="json"&&typeof f=="object"){const d=JSON.stringify(c.getEditorState().toJSON()),l=JSON.stringify(f);if(d!==l){const L=c.parseEditorState(l);c.setEditorState(L)}}}})),i!=null&&_.push(e.Value.on(i,f=>{c.setEditable(!f)})),_.push(c.registerCommand(n.BLUR_COMMAND,()=>(m&&m(c),S&&c.getEditorState().read(async()=>{if(v==="markdown"){const f=await K(c);S(f,c)}else if(v==="html"){const f=await Y(c);S(f,c)}else v==="json"&&S(c.getEditorState().toJSON(),c)}),!1),n.COMMAND_PRIORITY_LOW)),_.push(y.on(f=>{const d=c.getRootElement();d&&(d.dataset.theme=f)})),R)c.focus();else{const f=c.getRootElement();f&&f===document.activeElement&&f.blur()}T&&T(c)}catch(N){console.error("[BeatUI] Failed to initialize Lexical editor:",N);const C=E;C.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{_.forEach(N=>N())}catch{}try{M?.setRootElement(null)}catch{}})}))))};function Ye(t,o,a){const s=(m,T)=>o.map(()=>{const y=t.value;return y?y.getEditorState().read(()=>{const E=n.$getSelection();return n.$isRangeSelection(E)?m(E):T}):T}),i=m=>{const T=m.anchor.getNode();return T.getKey()==="root"?T:T.getTopLevelElementOrThrow()};return{withSelection:s,getAnchorElement:i,textFormatActive:m=>s(T=>T.hasFormat(m),!1),blockTypeActive:m=>s(T=>i(T).getType()===m,!1),listTypeActive:m=>s(T=>{const y=i(T).getParent();return F.$isListNode(y)&&y.getListType()===m},!1),headingActive:m=>o.map(()=>{const T=t.value;return T?T.getEditorState().read(()=>{const y=n.$getSelection();if(n.$isRangeSelection(y)){const E=i(y);if(E.getType()==="heading")return T.getElementByKey(E.getKey())?.tagName===`H${m}`}return!1}):!1}),linkActive:()=>s(m=>{const T=m.anchor.getNode();return T.getParent()?.getType()==="link"||T.getType()==="link"},!1),dispatch:(m,T)=>()=>{const y=t.value;y&&(y.dispatchCommand(m,T),y.focus())},toggleBlock:(m,T)=>()=>{const y=t.value;y&&(y.update(()=>{const E=n.$getSelection();if(n.$isRangeSelection(E)){const M=i(E);B.$setBlocksType(E,()=>M.getType()===m?n.$createParagraphNode():T())}}),y.focus())},toggleLink:()=>{const m=t.value;m&&(m.getEditorState().read(()=>{const T=n.$getSelection();if(n.$isRangeSelection(T)){const y=T.anchor.getNode();if(y.getParent()?.getType()==="link"||y.getType()==="link")m.dispatchCommand(ee.TOGGLE_LINK_COMMAND,null);else{const _=prompt(a?.enterUrlMessage?.()??"Enter URL:");_&&m.dispatchCommand(ee.TOGGLE_LINK_COMMAND,_)}}}),m.focus())}}}function Je(t,o){return a=>s=>ve.EditorToolbarButton({...s,display:a,disabled:t,size:o})}const lo={font:["font-family","font-size","line-height"],color:["font-color","highlight-color","background-color"],"text-formatting":["bold","italic","underline","strikethrough","code"],"clear-formatting":["clear-formatting"],headings:["paragraph","heading-1","heading-2","heading-3","heading-4","heading-5","heading-6"],lists:["bullet-list","ordered-list","check-list"],indent:["indent","outdent"],blocks:["blockquote","code-block","horizontal-rule"],tables:["insert-table"],links:["link"],history:["undo","redo"],clipboard:["cut","copy","paste"]},ao=["font","color","text-formatting","clear-formatting","headings","lists","indent","blocks","tables","links","history","clipboard"];function so(){return ao.map(t=>({group:t}))}function co(t){if(t.layout)return t.layout;const{visibleGroups:o,hiddenGroups:a,customGroups:s}=t;let i=so();if((o||a)&&(i=i.filter(u=>{if("separator"in u||"customGroup"in u)return!0;const h=u.group;return!(a?.includes(h)||o&&!o.includes(h))})),s&&s.length>0)for(const u of s)i.push({customGroup:u.id});return i}const uo=[{value:"Arial",label:"Arial"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Times New Roman",label:"Times New Roman"},{value:"Trebuchet MS",label:"Trebuchet MS"},{value:"Verdana",label:"Verdana"}],fo=[{value:"10px",label:"10"},{value:"12px",label:"12"},{value:"14px",label:"14"},{value:"16px",label:"16"},{value:"18px",label:"18"},{value:"20px",label:"20"},{value:"24px",label:"24"},{value:"30px",label:"30"},{value:"36px",label:"36"}],go=[{value:"1",label:"1"},{value:"1.15",label:"1.15"},{value:"1.5",label:"1.5"},{value:"2",label:"2"},{value:"2.5",label:"2.5"},{value:"3",label:"3"}];function Ve({editor:t,stateUpdate:o,toolbar:a={},readOnly:s=e.signal(!1),size:i="sm"}){const{maxHeadingLevel:u=3}=a,h=co(a);return e.Use(q.BeatUII18n,O=>e.Ensure(t,A=>{const R=A,b=O.$.lexical,{getAnchorElement:k,textFormatActive:S,blockTypeActive:m,listTypeActive:T,headingActive:y,linkActive:E,dispatch:M,toggleBlock:_,toggleLink:I}=Ye(R,o,{enterUrlMessage:()=>O.value.lexical.enterUrl}),C=Je(s,i)(e.signal(!0)),v=()=>{const r=R.value;r&&(r.update(()=>{const p=n.$getSelection();n.$isRangeSelection(p)&&B.$setBlocksType(p,()=>n.$createParagraphNode())}),r.focus())},c=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=`h${r}`,Q=p.getElementByKey(z.getKey());z.getType()==="heading"&&Q?.tagName===`H${r}`?B.$setBlocksType(w,()=>n.$createParagraphNode()):B.$setBlocksType(w,()=>j.$createHeadingNode(Z))}}),p.focus())},D=()=>{const r=R.value;if(!r)return;const p=r.getRootElement();p&&(p.focus(),document.execCommand("copy"))},x=()=>{const r=R.value;if(!r)return;const p=r.getRootElement();p&&(p.focus(),document.execCommand("cut"))},f=()=>{const r=R.value;r&&navigator.clipboard.readText().then(p=>{r.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&w.insertText(p)}),r.focus()}).catch(()=>{})},d=()=>{const r=R.value;r&&(r.update(()=>{const p=n.$getSelection();if(n.$isRangeSelection(p))for(const w of p.getNodes())n.$isTextNode(w)&&(w.setFormat(0),w.setStyle(""))}),r.focus())},l=()=>{const r=R.value;r&&(r.dispatchCommand(G.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0}),r.focus())},L={value:"",label:O.value.lexical.defaultOption},W=[L,...a.fontFamilies??uo],g=[L,...a.fontSizes??fo],P=[L,...a.lineHeights??go],H=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)?B.$getSelectionStyleValueForProperty(p,"font-family",""):""}):""}),U=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)?B.$getSelectionStyleValueForProperty(p,"font-size",""):""}):""}),tt=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"font-family":r||null})}),p.focus())},ot=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"font-size":r||null})}),p.focus())},nt=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)&&B.$getSelectionStyleValueForProperty(p,"color","")||"#000000"}):"#000000"}),rt=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();return n.$isRangeSelection(p)&&B.$getSelectionStyleValueForProperty(p,"background-color","")||"#ffffff"}):"#ffffff"}),it=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();if(n.$isRangeSelection(p)){const z=k(p).getStyle();return te(z,"background-color")||"#ffffff"}return"#ffffff"}):"#ffffff"}),lt=o.map(()=>{const r=R.value;return r?r.getEditorState().read(()=>{const p=n.$getSelection();if(n.$isRangeSelection(p)){const z=k(p).getStyle();return te(z,"line-height")||""}return""}):""}),at=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{color:r})}),p.focus())},st=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();n.$isRangeSelection(w)&&B.$patchStyleText(w,{"background-color":r})}),p.focus())},ct=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=z.getStyle(),Q=le(Z,"background-color",r);z.setStyle(Q)}}),p.focus())},ut=r=>{const p=R.value;p&&(p.update(()=>{const w=n.$getSelection();if(n.$isRangeSelection(w)){const z=k(w),Z=z.getStyle(),Q=le(Z,"line-height",r);z.setStyle(Q)}}),p.focus())},$=new Map;$.set("bold",()=>C({active:S("bold"),onClick:M(n.FORMAT_TEXT_COMMAND,"bold"),label:b.map(r=>r.bold),icon:"mdi:format-bold"})),$.set("italic",()=>C({active:S("italic"),onClick:M(n.FORMAT_TEXT_COMMAND,"italic"),label:b.map(r=>r.italic),icon:"mdi:format-italic"})),$.set("underline",()=>C({active:S("underline"),onClick:M(n.FORMAT_TEXT_COMMAND,"underline"),label:b.map(r=>r.underline),icon:"mdi:format-underline"})),$.set("strikethrough",()=>C({active:S("strikethrough"),onClick:M(n.FORMAT_TEXT_COMMAND,"strikethrough"),label:b.map(r=>r.strikethrough),icon:"mdi:format-strikethrough"})),$.set("code",()=>C({active:S("code"),onClick:M(n.FORMAT_TEXT_COMMAND,"code"),label:b.map(r=>r.code),icon:"mdi:code-tags"})),$.set("clear-formatting",()=>C({active:e.signal(!1),onClick:d,label:b.map(r=>r.clearFormatting),icon:"mdi:format-clear"})),$.set("paragraph",()=>C({active:m("paragraph"),onClick:v,label:b.map(r=>r.normal),icon:"mdi:format-paragraph"}));for(let r=1;r<=u;r++)$.set(`heading-${r}`,()=>C({active:y(r),onClick:()=>c(r),label:b.map(p=>p.heading(r)),icon:`mdi:format-header-${r}`}));$.set("bullet-list",()=>C({active:T("bullet"),onClick:M(F.INSERT_UNORDERED_LIST_COMMAND,void 0),label:b.map(r=>r.bulletList),icon:"mdi:format-list-bulleted"})),$.set("ordered-list",()=>C({active:T("number"),onClick:M(F.INSERT_ORDERED_LIST_COMMAND,void 0),label:b.map(r=>r.orderedList),icon:"mdi:format-list-numbered"})),$.set("check-list",()=>C({active:T("check"),onClick:M(F.INSERT_CHECK_LIST_COMMAND,void 0),label:b.map(r=>r.checkList),icon:"mdi:format-list-checks"})),$.set("indent",()=>C({active:e.signal(!1),onClick:M(n.INDENT_CONTENT_COMMAND,void 0),label:b.map(r=>r.indent),icon:"mdi:format-indent-increase"})),$.set("outdent",()=>C({active:e.signal(!1),onClick:M(n.OUTDENT_CONTENT_COMMAND,void 0),label:b.map(r=>r.outdent),icon:"mdi:format-indent-decrease"})),$.set("blockquote",()=>C({active:m("quote"),onClick:_("quote",j.$createQuoteNode),label:b.map(r=>r.blockquote),icon:"mdi:format-quote-close"})),$.set("code-block",()=>C({active:m("code"),onClick:_("code",ie.$createCodeNode),label:b.map(r=>r.codeBlock),icon:"mdi:code-braces"})),$.set("horizontal-rule",()=>C({active:e.signal(!1),onClick:M(ce,void 0),label:b.map(r=>r.horizontalRule),icon:"mdi:minus"})),$.set("insert-table",()=>C({active:e.signal(!1),onClick:l,label:b.map(r=>r.insertTable),icon:"mdi:table-plus"})),$.set("link",()=>C({active:E(),onClick:I,label:b.map(r=>r.link),icon:"mdi:link"})),$.set("undo",()=>C({active:e.signal(!1),onClick:M(n.UNDO_COMMAND,void 0),label:b.map(r=>r.undo),icon:"mdi:undo"})),$.set("redo",()=>C({active:e.signal(!1),onClick:M(n.REDO_COMMAND,void 0),label:b.map(r=>r.redo),icon:"mdi:redo"})),$.set("cut",()=>C({active:e.signal(!1),onClick:x,label:b.map(r=>r.cut),icon:"mdi:content-cut"})),$.set("copy",()=>C({active:e.signal(!1),onClick:D,label:b.map(r=>r.copy),icon:"mdi:content-copy"})),$.set("paste",()=>C({active:e.signal(!1),onClick:f,label:b.map(r=>r.paste),icon:"mdi:content-paste"})),$.set("font-family",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(b.map(r=>r.fontFamily)),e.attr.disabled(s),e.on.change(r=>tt(r.target.value)),...W.map(r=>e.html.option(e.attr.value(r.value),e.attr.selected(H.map(p=>p===r.value)),r.label)))),$.set("font-size",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(b.map(r=>r.fontSize)),e.attr.disabled(s),e.on.change(r=>ot(r.target.value)),...g.map(r=>e.html.option(e.attr.value(r.value),e.attr.selected(U.map(p=>p===r.value)),r.label)))),$.set("line-height",()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(b.map(r=>r.lineHeight)),e.attr.disabled(s),e.on.change(r=>ut(r.target.value)),...P.map(r=>e.html.option(e.attr.value(r.value),e.attr.selected(lt.map(p=>p===r.value)),r.label)))),$.set("font-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(b.map(r=>r.fontColor)),e.html.input(e.attr.type("color"),e.attr.value(nt),e.attr.disabled(s),e.on.input(r=>at(r.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon"),"A"))),$.set("highlight-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(b.map(r=>r.highlightColor)),e.html.input(e.attr.type("color"),e.attr.value(rt),e.attr.disabled(s),e.on.input(r=>st(r.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--highlight"),"A"))),$.set("background-color",()=>e.html.label(e.attr.class("bc-lexical-toolbar-color"),e.attr.title(b.map(r=>r.backgroundColor)),e.html.input(e.attr.type("color"),e.attr.value(it),e.attr.disabled(s),e.on.input(r=>ct(r.target.value))),e.html.span(e.attr.class("bc-lexical-toolbar-color-icon bc-lexical-toolbar-color-icon--bg"),"■")));const Pe={editor:R,stateUpdate:o,readOnly:s,size:i,button:r=>C({active:r.active??e.signal(!1),onClick:r.onClick,label:r.label,icon:r.icon})},He=r=>{if(r.type==="button"){const p=r;$.set(r.id,()=>C({active:p.active?.(Pe)??e.signal(!1),onClick:()=>p.onClick(R.value),label:p.label,icon:p.icon}))}else if(r.type==="select"){const p=r,w=p.resetOnSelect!==!1;$.set(r.id,()=>e.html.select(e.attr.class("bc-lexical-toolbar-select"),e.attr.title(p.label),e.attr.disabled(s),e.on.change(z=>{const Z=z.target,Q=Z.value;Q!==""&&(p.onSelect(Q,R.value),w&&(Z.value=""))}),e.html.option(e.attr.value(""),e.attr.disabled(w),e.attr.selected(!0),p.label),...p.options.map(z=>e.html.option(e.attr.value(z.value),z.label))))}else if(r.type==="custom"){const p=r;$.set(r.id,()=>p.render(Pe))}};if(a.customItems)for(const r of a.customItems)He(r);if(a.customGroups)for(const r of a.customGroups)for(const p of r.items)He(p);return je.Toolbar({},e.attr.class("bc-lexical-toolbar"),...mo(h,$,u,a.customGroups))}))}function mo(t,o,a,s){const i=new Map;if(s)for(const h of s)i.set(h.id,h);const u=[];for(const h of t){if("separator"in h){u.push(je.ToolbarDivider());continue}if("customGroup"in h){const b=i.get(h.customGroup);if(!b)continue;const k=[];for(const m of b.items){const T=o.get(m.id);T&&k.push(T())}if(k.length===0)continue;const S=k.map(()=>e.signal(!0));u.push(ve.EditorToolbarGroup({display:S},...k));continue}let O=h.items??lo[h.group]??[];h.group==="headings"&&!h.items&&(O=O.filter(b=>b.startsWith("heading-")?parseInt(b.split("-")[1],10)<=a:!0));const A=[];for(const b of O){const k=o.get(b);k&&A.push(k())}if(A.length===0)continue;const R=A.map(()=>e.signal(!0));u.push(ve.EditorToolbarGroup({display:R},...A))}return u}function Xe({editor:t,stateUpdate:o,readOnly:a=e.signal(!1)}){const s=e.prop(!1),i=e.prop(0),u=e.prop(0);let h=null;const O=e.prop(!1),A=I=>{let N=null;return I.getEditorState().read(()=>{const C=n.$getSelection();if(!n.$isRangeSelection(C))return;let v=C.anchor.getNode();for(;v;){if(G.$isTableCellNode(v)){N=v;break}if(v=v.getParent(),!v||v.getKey()==="root")break}}),N},R=(I,N)=>{const C=I.getBoundingClientRect(),v=N.closest(".bc-lexical-editor-container"),c=v?v.getBoundingClientRect():N.getBoundingClientRect();return i.value=C.top-c.top+2,u.value=c.right-C.right+2,!0},b=()=>{const I=t.value;if(!I){s.value=!1;return}const N=A(I);if(!N){O.value||(s.value=!1);return}const C=I.getElementByKey(N.getKey()),v=I.getRootElement();C&&v?(R(C,v),s.value=!0):s.value=!1};o.onChange(b);const k=I=>()=>{const N=t.value;N&&(N.update(I),h?.set(!1),N.focus())},S=k(()=>G.$insertTableRowAtSelection(!1)),m=k(()=>G.$insertTableRowAtSelection(!0)),T=k(()=>G.$insertTableColumnAtSelection(!1)),y=k(()=>G.$insertTableColumnAtSelection(!0)),E=k(()=>G.$deleteTableRowAtSelection()),M=k(()=>G.$deleteTableColumnAtSelection()),_=k(()=>{const I=n.$getSelection();if(!n.$isRangeSelection(I))return;const N=I.anchor.getNode(),C=G.$getTableCellNodeFromLexicalNode(N);if(!C)return;G.$getTableNodeFromLexicalNodeOrThrow(C).remove()});return e.Use(q.BeatUII18n,I=>e.Ensure(t,N=>{const C=N,v=I.$.lexical,c=d=>{const l=C.value;if(!l||a.value)return;const L=l.getRootElement();if(!L)return;const g=d.target.closest("td, th");g&&L.contains(g)&&(d.preventDefault(),R(g,L)&&(s.value=!0),bt.delayedAnimationFrame(()=>{h?.set(!0)}))},D=C.value?.getRootElement(),f=D?.closest(".bc-lexical-editor-container")??D??document;return f.addEventListener("contextmenu",c),[e.OnDispose(()=>{f.removeEventListener("contextmenu",c)}),e.When(s,()=>e.html.div(e.attr.class("bc-table-cell-marker"),e.style.position("absolute"),e.style.top(i.map(d=>`${d}px`)),e.style.right(u.map(d=>`${d}px`)),e.style.zIndex("10"),e.WithElement(d=>{d.addEventListener("mousedown",l=>{l.preventDefault()})}),e.html.button(e.attr.class("bc-table-cell-marker__button"),e.attr.type("button"),e.attr.title(v.map(d=>d.tableActions)),e.attr.disabled(a),q.Icon({icon:"lucide:chevron-down",size:"xs"}),e.WithElement(d=>{const l=new MutationObserver(()=>{const L=d.getAttribute("aria-expanded")==="true";O.value=L});return l.observe(d,{attributes:!0,attributeFilter:["aria-expanded"]}),e.OnDispose(()=>l.disconnect())}),J.Menu({items:()=>[J.MenuItem({key:"insert-row-above",content:v.map(d=>d.insertRowAbove),before:q.Icon({icon:"lucide:arrow-up",size:"sm"}),onClick:S,disabled:a}),J.MenuItem({key:"insert-row-below",content:v.map(d=>d.insertRowBelow),before:q.Icon({icon:"lucide:arrow-down",size:"sm"}),onClick:m,disabled:a}),J.MenuItem({key:"insert-column-left",content:v.map(d=>d.insertColumnLeft),before:q.Icon({icon:"lucide:arrow-left",size:"sm"}),onClick:T,disabled:a}),J.MenuItem({key:"insert-column-right",content:v.map(d=>d.insertColumnRight),before:q.Icon({icon:"lucide:arrow-right",size:"sm"}),onClick:y,disabled:a}),J.MenuSeparator(),J.MenuItem({key:"delete-row",content:v.map(d=>d.deleteRow),before:q.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:E,disabled:a}),J.MenuItem({key:"delete-column",content:v.map(d=>d.deleteColumn),before:q.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:M,disabled:a}),J.MenuItem({key:"delete-table",content:v.map(d=>d.deleteTable),before:q.Icon({icon:"lucide:trash-2",size:"sm"}),onClick:_,disabled:a})],placement:"bottom-end",showOn:d=>(h=d,e.on.click(()=>{d.set(!d.value)})),showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const d=C.value;d&&d.focus()},ariaLabel:v.map(d=>d.tableActions)}))))]}))}const po=t=>{const{value:o,format:a,plugins:s,readOnly:i,placeholder:u,class:h,namespace:O="BeatUILexical",heightMode:A="fixed",toolbar:R,autoFocus:b=!1,onError:k,onInput:S,onChange:m,onBlur:T,onReady:y}=t,E=e.prop(null),M=e.prop(0),_=N=>typeof N=="object"&&N!==null&&"map"in N&&typeof N.map=="function",I=i!=null?_(i)?i:e.prop(e.Value.get(i)):e.prop(!1);return e.Use(Ie.Theme,({appearance:N})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:C})=>Le.LinkPortal({id:"beatui-lexical-css",href:C})),e.attr.class("bc-lexical-editor-container"),A==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(h),e.When(I.map(C=>!C),()=>Ve({editor:E,stateUpdate:M,toolbar:R,readOnly:I,size:"sm"})),Xe({editor:E,stateUpdate:M,readOnly:I}),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${A}`),e.attr.contenteditable(i!=null?e.Value.map(i,C=>!C):!0),i!=null?e.attr.class(e.Value.map(i,C=>C?"bc-lexical-editor--readonly":"")):null,e.WithElement(C=>{let v=null;const c=[];return(async()=>{try{const x=s??pe("docked"),f=me(x),d=e.Value.get(a??"markdown"),l=n.createEditor({namespace:O,nodes:f,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:g=>{k?k(g,l):console.error("[BeatUI Lexical]",g)},editable:i?!e.Value.get(i):!0,html:{export:xe(),import:ue()}});v=l,E.set(l),l.setRootElement(C);const L=[];if(x.richText?L.push(he(l)):x.plainText&&L.push(be(l)),x.history){const g=typeof x.history=="object"?x.history:void 0;L.push(Ce(l,g))}if(x.clipboard&&L.push(ye(l)),x.list&&L.push(Ee(l)),x.link&&L.push(Oe(l)),x.yjs&&L.push(Me(l,x.yjs)),x.dragon&&L.push(Se(l)),x.table&&L.push(Ne(l)),(await Promise.all(L)).forEach(g=>{g&&c.push(g)}),c.push(Te(l)),c.push($e(l)),c.push(l.registerCommand(n.SELECTION_CHANGE_COMMAND,()=>(M.set(M.value+1),!1),n.COMMAND_PRIORITY_LOW)),c.push(l.registerUpdateListener(({editorState:g,dirtyElements:P,dirtyLeaves:H})=>{(P.size>0||H.size>0)&&M.set(M.value+1),S&&(P.size>0||H.size>0)&&g.read(async()=>{if(d==="markdown"){const U=await K(l);S(U,l)}else if(d==="html"){const U=await Y(l);S(U,l)}else d==="json"&&S(g.toJSON(),l)})})),o!=null){const g=e.Value.get(o);if(g!=null&&(g!==""||d==="json"&&typeof g=="object")){if(d==="markdown"&&typeof g=="string")await V(l,g);else if(d==="html"&&typeof g=="string")await X(l,g);else if(d==="json"&&typeof g=="object")try{const H=JSON.stringify(g),U=l.parseEditorState(H);l.setEditorState(U)}catch(H){console.error("[BeatUI] Failed to parse JSON editor state:",H),k&&k(H instanceof Error?H:new Error(String(H)),l)}}}if(o!=null&&c.push(e.Value.on(o,async g=>{if(g!=null){if(d==="markdown"&&typeof g=="string"){const P=await K(l);g!==P&&await V(l,g)}else if(d==="html"&&typeof g=="string"){const P=await Y(l);g!==P&&await X(l,g)}else if(d==="json"&&typeof g=="object"){const P=JSON.stringify(l.getEditorState().toJSON()),H=JSON.stringify(g);if(P!==H){const U=l.parseEditorState(H);l.setEditorState(U)}}}})),i!=null&&c.push(e.Value.on(i,g=>{l.setEditable(!g)})),c.push(l.registerCommand(n.BLUR_COMMAND,()=>(T&&T(l),m&&l.getEditorState().read(async()=>{if(d==="markdown"){const g=await K(l);m(g,l)}else if(d==="html"){const g=await Y(l);m(g,l)}else d==="json"&&m(l.getEditorState().toJSON(),l)}),!1),n.COMMAND_PRIORITY_LOW)),c.push(N.on(g=>{const P=l.getRootElement();P&&(P.dataset.theme=g)})),b)l.focus();else{const g=l.getRootElement();g&&g===document.activeElement&&g.blur()}y&&y(l)}catch(x){console.error("[BeatUI] Failed to initialize Lexical editor:",x);const f=C;f.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{c.forEach(x=>x())}catch{}try{v?.setRootElement(null)}catch{}E.set(null)})}))))};function Ze({editor:t,stateUpdate:o,groups:a=["text-formatting"],readOnly:s=e.signal(!1),size:i="sm"}){const u=e.prop(!1),h=e.prop(0),O=e.prop(0);return e.Use(q.BeatUII18n,A=>e.Ensure(t,R=>{const b=R,k=A.$.lexical,S=c=>a.includes(c),{textFormatActive:m,linkActive:T,dispatch:y,toggleLink:E}=Ye(b,o,{enterUrlMessage:()=>A.value.lexical.enterUrl}),_=Je(s,i)(e.signal(!0)),I=()=>{const c=b.value;if(!c){u.value=!1;return}const D=c.getRootElement();if(!D){u.value=!1;return}const x=window.getSelection();if(!x||x.rangeCount===0||x.isCollapsed){u.value=!1;return}const f=x.anchorNode;if(f&&!D.contains(f)){u.value=!1;return}const l=x.getRangeAt(0).getBoundingClientRect();if(l.width===0&&l.height===0){u.value=!1;return}const L=40,W=8;let g=l.top-L-W;const P=l.left+l.width/2;g<0&&(g=l.bottom+W),h.value=g,O.value=P,u.value=!0},N=o.onChange(I),C=()=>{I()};document.addEventListener("selectionchange",C);const v=e.html.div(e.attr.class("bc-floating-toolbar"),e.style.position("fixed"),e.style.top(h.map(c=>`${c}px`)),e.style.left(O.map(c=>`${c}px`)),e.style.transform("translateX(-50%)"),e.WithElement(c=>{const D=f=>{if(f.key==="Escape"&&u.value){u.value=!1;const d=b.value;d&&d.focus()}},x=f=>{if(u.value&&!c.contains(f.target)){const d=b.value;if(d){const l=d.getRootElement();if(l&&l.contains(f.target))return}u.value=!1}};return document.addEventListener("keydown",D),document.addEventListener("mousedown",x),e.OnDispose(()=>{N(),document.removeEventListener("keydown",D),document.removeEventListener("mousedown",x),document.removeEventListener("selectionchange",C)})}),...S("text-formatting")?[_({active:m("bold"),onClick:y(n.FORMAT_TEXT_COMMAND,"bold"),label:k.map(c=>c.bold),icon:"mdi:format-bold"}),_({active:m("italic"),onClick:y(n.FORMAT_TEXT_COMMAND,"italic"),label:k.map(c=>c.italic),icon:"mdi:format-italic"}),_({active:m("underline"),onClick:y(n.FORMAT_TEXT_COMMAND,"underline"),label:k.map(c=>c.underline),icon:"mdi:format-underline"}),_({active:m("strikethrough"),onClick:y(n.FORMAT_TEXT_COMMAND,"strikethrough"),label:k.map(c=>c.strikethrough),icon:"mdi:format-strikethrough"}),_({active:m("code"),onClick:y(n.FORMAT_TEXT_COMMAND,"code"),label:k.map(c=>c.code),icon:"mdi:code-tags"})]:[],...S("links")?[_({active:T(),onClick:E,label:k.map(c=>c.link),icon:"mdi:link"})]:[],...S("clipboard")?[_({active:e.signal(!1),onClick:()=>{const c=b.value;if(!c)return;const D=c.getRootElement();D&&(D.focus(),document.execCommand("cut"))},label:k.map(c=>c.cut),icon:"mdi:content-cut"}),_({active:e.signal(!1),onClick:()=>{const c=b.value;if(!c)return;const D=c.getRootElement();D&&(D.focus(),document.execCommand("copy"))},label:k.map(c=>c.copy),icon:"mdi:content-copy"}),_({active:e.signal(!1),onClick:()=>{const c=b.value;c&&navigator.clipboard.readText().then(D=>{c.update(()=>{const x=n.$getSelection();n.$isRangeSelection(x)&&x.insertText(D)}),c.focus()}).catch(()=>{})},label:k.map(c=>c.paste),icon:"mdi:content-paste"})]:[]);return e.When(u,()=>v)}))}const ho=[{id:"heading1",label:"Heading 1",description:"Large section heading",icon:"mdi:format-header-1",keywords:["h1","heading","title"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h1"))})}},{id:"heading2",label:"Heading 2",description:"Medium section heading",icon:"mdi:format-header-2",keywords:["h2","heading"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h2"))})}},{id:"heading3",label:"Heading 3",description:"Small section heading",icon:"mdi:format-header-3",keywords:["h3","heading"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h3"))})}},{id:"bullet-list",label:"Bullet List",description:"Create a bulleted list",icon:"mdi:format-list-bulleted",keywords:["ul","unordered","bullets"],category:"Lists",handler:t=>{t.dispatchCommand(F.INSERT_UNORDERED_LIST_COMMAND,void 0)}},{id:"ordered-list",label:"Ordered List",description:"Create a numbered list",icon:"mdi:format-list-numbered",keywords:["ol","numbered","1","2","3"],category:"Lists",handler:t=>{t.dispatchCommand(F.INSERT_ORDERED_LIST_COMMAND,void 0)}},{id:"quote",label:"Quote",description:"Insert a blockquote",icon:"mdi:format-quote-close",keywords:["blockquote","citation"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createQuoteNode())})}},{id:"code-block",label:"Code Block",description:"Insert a code block",icon:"mdi:code-braces",keywords:["code","pre","programming"],category:"Basic blocks",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>ie.$createCodeNode())})}},{id:"divider",label:"Divider",description:"Insert a horizontal rule",icon:"mdi:minus",keywords:["hr","horizontal","line","separator"],category:"Basic blocks",handler:t=>{t.dispatchCommand(ce,void 0)}},{id:"table",label:"Table",description:"Insert a table",icon:"mdi:table",keywords:["table","grid","cells","rows","columns"],category:"Advanced",handler:t=>{t.dispatchCommand(G.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0})}}];function bo({commands:t,isVisible:o,filterText:a,position:s,onSelect:i,onClose:u}){const h=e.prop(0),O=a.map(S=>{const m=S.toLowerCase().trim();return m?t.filter(T=>[T.label.toLowerCase(),T.description?.toLowerCase()||"",...T.keywords?.map(E=>E.toLowerCase())||[]].join(" ").includes(m)):t});O.onChange(()=>{h.value=0});const A=S=>{const m=O.value;if(S>=0&&S<m.length){const T=m[S];i(T)}},R=S=>{if(!o.value)return;const T=O.value.length-1;switch(S.key){case"ArrowDown":S.preventDefault(),h.value=Math.min(h.value+1,T);break;case"ArrowUp":S.preventDefault(),h.value=Math.max(h.value-1,0);break;case"Enter":S.preventDefault(),A(h.value);break;case"Escape":S.preventDefault(),u();break}},b=(S,m)=>{const T=h.map(E=>E===m),y=`slash-cmd-${S.id}`;return e.html.div(e.attr.class("bc-slash-command-palette__item"),e.attr.id(y),e.attr.role("option"),e.aria.selected(T),e.WithElement(E=>{const M=()=>{h.value=m},_=()=>{A(m)};return E.addEventListener("mouseenter",M),E.addEventListener("click",_),e.OnDispose(()=>{E.removeEventListener("mouseenter",M),E.removeEventListener("click",_)})}),typeof S.icon=="string"?e.html.div(e.attr.class("bc-slash-command-palette__icon"),q.Icon({icon:S.icon,size:"sm"})):S.icon,e.html.div(e.attr.class("bc-slash-command-palette__content"),e.html.div(e.attr.class("bc-slash-command-palette__label"),S.label),S.description?e.html.div(e.attr.class("bc-slash-command-palette__description"),S.description):void 0),S.category?e.html.div(e.attr.class("bc-slash-command-palette__category"),S.category):void 0)},k=e.Use(q.BeatUII18n,S=>e.html.div(e.attr.class("bc-slash-command-palette"),e.attr.role("listbox"),e.aria.label(S.$.lexical.map(m=>m.slashCommands)),e.style.position("absolute"),e.style.top(s.map(m=>`${m.top}px`)),e.style.left(s.map(m=>`${m.left}px`)),e.WithElement(()=>(document.addEventListener("keydown",R),e.OnDispose(()=>{document.removeEventListener("keydown",R)}))),e.When(O.map(m=>m.length===0),()=>e.html.div(e.attr.class("bc-slash-command-palette__empty"),S.$.lexical.map(m=>m.noCommandsFound))),e.ForEach(O,(m,T)=>{const y=m.value;return b(y,T.index)})));return e.When(o,()=>k)}const Qe=[{id:"paragraph",label:"Paragraph",icon:"mdi:format-paragraph",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>n.$createParagraphNode())})}},{id:"heading1",label:"Heading 1",icon:"mdi:format-header-1",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h1"))})}},{id:"heading2",label:"Heading 2",icon:"mdi:format-header-2",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h2"))})}},{id:"heading3",label:"Heading 3",icon:"mdi:format-header-3",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createHeadingNode("h3"))})}},{id:"bullet-list",label:"Bullet List",icon:"mdi:format-list-bulleted",handler:t=>{t.dispatchCommand(F.INSERT_UNORDERED_LIST_COMMAND,void 0)}},{id:"ordered-list",label:"Ordered List",icon:"mdi:format-list-numbered",handler:t=>{t.dispatchCommand(F.INSERT_ORDERED_LIST_COMMAND,void 0)}},{id:"quote",label:"Quote",icon:"mdi:format-quote-close",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>j.$createQuoteNode())})}},{id:"code-block",label:"Code Block",icon:"mdi:code-braces",handler:t=>{t.update(()=>{const o=n.$getSelection();n.$isRangeSelection(o)&&B.$setBlocksType(o,()=>ie.$createCodeNode())})}},{id:"divider",label:"Divider",icon:"mdi:minus",handler:t=>{t.dispatchCommand(ce,void 0)}},{id:"table",label:"Table",icon:"mdi:table",handler:t=>{t.dispatchCommand(G.INSERT_TABLE_COMMAND,{rows:"3",columns:"3",includeHeaders:!0})}}];function et({editor:t,stateUpdate:o,readOnly:a=e.signal(!1),commands:s=Qe}){const i=e.prop(!1),u=e.prop(!1),h=e.prop(0),O=e.prop(0);return e.Use(q.BeatUII18n,A=>e.Ensure(t,R=>{const b=R;let k=null,S=!1,m=null;const T=24,y=4,E=200,M=f=>{if(f===k&&i.value)return;k=f;const d=f.getBoundingClientRect();h.value=d.top,O.value=d.left-T-y,i.value=!0},_=()=>{m!=null&&(clearTimeout(m),m=null)},I=()=>{u.value||(_(),m=setTimeout(()=>{m=null,u.value||(i.value=!1,k=null)},E))},N=()=>{const f=b.value;if(!f)return;const d=f.getRootElement();d&&(c(d),f.getEditorState().read(()=>{const l=n.$getSelection();if(n.$isRangeSelection(l))try{const W=l.anchor.getNode().getTopLevelElementOrThrow(),g=f.getElementByKey(W.getKey());g&&M(g)}catch{}}))},C=f=>{if(u.value)return;const d=b.value;if(!d)return;const l=d.getRootElement();if(l)for(const L of Array.from(l.children)){const W=L.getBoundingClientRect();if(f.clientY>=W.top&&f.clientY<=W.bottom){_(),M(L);return}}},v=()=>{I()},c=f=>{S||(S=!0,f.addEventListener("mousemove",C),f.addEventListener("mouseleave",v))},D=o.onChange(N);return[e.OnDispose(()=>{D(),_();const f=b.value;if(f){const d=f.getRootElement();d&&S&&(d.removeEventListener("mousemove",C),d.removeEventListener("mouseleave",v))}}),e.When(i,()=>e.html.div(e.attr.class("bc-block-handle"),e.style.position("fixed"),e.style.top(h.map(f=>`${f}px`)),e.style.left(O.map(f=>`${f}px`)),e.on.mouseenter(_),e.on.mouseleave(()=>I()),e.WithElement(f=>{f.addEventListener("mousedown",d=>{d.preventDefault()})}),e.html.button(e.attr.class("bc-block-handle__button"),e.attr.type("button"),e.attr.title(A.$.lexical.map(f=>f.changeBlockType)),e.attr.disabled(a),q.Icon({icon:"mdi:drag-horizontal-variant",size:"sm"}),e.WithElement(f=>{const d=new MutationObserver(()=>{const l=f.getAttribute("aria-expanded")==="true";u.value=l});return d.observe(f,{attributes:!0,attributeFilter:["aria-expanded"]}),e.OnDispose(()=>d.disconnect())}),J.Menu({items:()=>s.map(f=>J.MenuItem({key:f.id,content:f.label,before:q.Icon({icon:f.icon,size:"sm"}),onClick:()=>{const d=b.value;d&&(f.handler(d),d.focus())}})),placement:"bottom-start",showOn:"click",showDelay:0,hideDelay:0,mainAxisOffset:4,onClose:()=>{const f=b.value;f&&f.focus()},ariaLabel:A.value.lexical.blockTypes}))))]}))}const Co=t=>{const{value:o,format:a,plugins:s,readOnly:i,placeholder:u,class:h,namespace:O="BeatUILexical",heightMode:A="auto",floatingToolbarGroups:R,autoFocus:b=!1,onError:k,onInput:S,onChange:m,onBlur:T,onReady:y}=t,E=e.prop(null),M=e.prop(0),_=N=>typeof N=="object"&&N!==null&&"map"in N&&typeof N.map=="function",I=i!=null?_(i)?i:e.prop(e.Value.get(i)):e.prop(!1);return e.Use(Ie.Theme,({appearance:N})=>e.html.div(e.Task(()=>Promise.resolve().then(()=>require("../styles-url-CkPTI32j.cjs")),({default:C})=>Le.LinkPortal({id:"beatui-lexical-css",href:C})),e.attr.class("bc-lexical-editor-container"),A==="fixed"?e.attr.class("bc-lexical-editor-container--fixed"):null,e.attr.class(h),Ze({editor:E,stateUpdate:M,groups:R??["text-formatting","links"],readOnly:I}),et({editor:E,stateUpdate:M,readOnly:I}),Xe({editor:E,stateUpdate:M,readOnly:I}),e.html.div(e.attr.class("bc-lexical-editor"),e.attr.class(`bc-lexical-editor--${A}`),e.attr.contenteditable(i!=null?e.Value.map(i,C=>!C):!0),i!=null?e.attr.class(e.Value.map(i,C=>C?"bc-lexical-editor--readonly":"")):null,e.WithElement(C=>{let v=null;const c=[];return(async()=>{try{const x=s??pe("contextual"),f=me(x),d=e.Value.get(a??"markdown"),l=n.createEditor({namespace:O,nodes:f,theme:{heading:{h1:"bc-lexical-h1",h2:"bc-lexical-h2",h3:"bc-lexical-h3",h4:"bc-lexical-h4",h5:"bc-lexical-h5",h6:"bc-lexical-h6"},text:{bold:"bc-lexical-bold",italic:"bc-lexical-italic",underline:"bc-lexical-underline",strikethrough:"bc-lexical-strikethrough",code:"bc-lexical-code"},list:{ul:"bc-lexical-ul",ol:"bc-lexical-ol",listitem:"bc-lexical-li",listitemChecked:"bc-lexical-li-checked",listitemUnchecked:"bc-lexical-li-unchecked"},link:"bc-lexical-link",quote:"bc-lexical-blockquote",code:"bc-lexical-code-block",codeHighlight:{},hashtag:"bc-lexical-hashtag",table:"bc-lexical-table",tableCell:"bc-lexical-table-cell",tableCellHeader:"bc-lexical-table-cell-header",tableRow:"bc-lexical-table-row",mark:"bc-lexical-mark",paragraph:"bc-lexical-paragraph"},onError:g=>{k?k(g,l):console.error("[BeatUI Lexical]",g)},editable:i?!e.Value.get(i):!0,html:{export:xe(),import:ue()}});v=l,E.set(l),l.setRootElement(C);const L=[];if(x.richText?L.push(he(l)):x.plainText&&L.push(be(l)),x.history){const g=typeof x.history=="object"?x.history:void 0;L.push(Ce(l,g))}if(x.clipboard&&L.push(ye(l)),x.list&&L.push(Ee(l)),x.link&&L.push(Oe(l)),x.yjs&&L.push(Me(l,x.yjs)),x.dragon&&L.push(Se(l)),x.table&&L.push(Ne(l)),(await Promise.all(L)).forEach(g=>{g&&c.push(g)}),c.push(Te(l)),c.push($e(l)),c.push(l.registerCommand(n.SELECTION_CHANGE_COMMAND,()=>(M.set(M.value+1),!1),n.COMMAND_PRIORITY_LOW)),c.push(l.registerUpdateListener(({editorState:g,dirtyElements:P,dirtyLeaves:H})=>{(P.size>0||H.size>0)&&M.set(M.value+1),S&&(P.size>0||H.size>0)&&g.read(async()=>{if(d==="markdown"){const U=await K(l);S(U,l)}else if(d==="html"){const U=await Y(l);S(U,l)}else d==="json"&&S(g.toJSON(),l)})})),o!=null){const g=e.Value.get(o);if(g!=null&&(g!==""||d==="json"&&typeof g=="object")){if(d==="markdown"&&typeof g=="string")await V(l,g);else if(d==="html"&&typeof g=="string")await X(l,g);else if(d==="json"&&typeof g=="object")try{const H=JSON.stringify(g),U=l.parseEditorState(H);l.setEditorState(U)}catch(H){console.error("[BeatUI] Failed to parse JSON editor state:",H),k&&k(H instanceof Error?H:new Error(String(H)),l)}}}if(o!=null&&c.push(e.Value.on(o,async g=>{if(g!=null){if(d==="markdown"&&typeof g=="string"){const P=await K(l);g!==P&&await V(l,g)}else if(d==="html"&&typeof g=="string"){const P=await Y(l);g!==P&&await X(l,g)}else if(d==="json"&&typeof g=="object"){const P=JSON.stringify(l.getEditorState().toJSON()),H=JSON.stringify(g);if(P!==H){const U=l.parseEditorState(H);l.setEditorState(U)}}}})),i!=null&&c.push(e.Value.on(i,g=>{l.setEditable(!g)})),c.push(l.registerCommand(n.BLUR_COMMAND,()=>(T&&T(l),m&&l.getEditorState().read(async()=>{if(d==="markdown"){const g=await K(l);m(g,l)}else if(d==="html"){const g=await Y(l);m(g,l)}else d==="json"&&m(l.getEditorState().toJSON(),l)}),!1),n.COMMAND_PRIORITY_LOW)),c.push(N.on(g=>{const P=l.getRootElement();P&&(P.dataset.theme=g)})),b)l.focus();else{const g=l.getRootElement();g&&g===document.activeElement&&g.blur()}y&&y(l)}catch(x){console.error("[BeatUI] Failed to initialize Lexical editor:",x);const f=C;f.textContent="Failed to load Lexical editor."}})(),e.OnDispose(()=>{try{c.forEach(x=>x())}catch{}try{v?.setRootElement(null)}catch{}E.set(null)})}))))},yo=t=>{const{value:o,before:a,after:s,onChange:i,onInput:u,onBlur:h,disabled:O,hasError:A,name:R,placeholder:b,id:k,required:S,tabIndex:m,size:T,class:y,namespace:E,format:M,plugins:_,readOnly:I,onError:N,onReady:C,marks:v,autoFocus:c}=t,D=O!=null&&I!=null?e.computedOf(O,I)((x,f)=>(x??!1)||(f??!1)):O??I;return Ct.InputContainer({disabled:O,hasError:A,size:T,baseContainer:!0,growInput:!0,focusableSelector:"[contenteditable]",before:a,after:s,input:e.html.div(e.attr.class("bc-lexical-editor-input"),e.attr.name(R),e.attr.id(k),S!=null?e.aria.required(S):null,m!=null?e.attr.tabindex(m):null,A!=null?e.attr.class(e.Value.map(A,x=>x?"bc-lexical-editor-input--error":"")):null,Ke({value:o,format:M??"markdown",plugins:_,readOnly:D,placeholder:b,namespace:E,class:y,autoFocus:c,onError:N,onReady:C,onInput:u?(x,f)=>{u(x)}:void 0,onChange:i?(x,f)=>{i(x)}:void 0,onBlur:h?x=>{h()}:void 0}))})};Object.defineProperty(exports,"INSERT_CHECK_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_CHECK_LIST_COMMAND});Object.defineProperty(exports,"INSERT_ORDERED_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_ORDERED_LIST_COMMAND});Object.defineProperty(exports,"INSERT_UNORDERED_LIST_COMMAND",{enumerable:!0,get:()=>F.INSERT_UNORDERED_LIST_COMMAND});Object.defineProperty(exports,"REMOVE_LIST_COMMAND",{enumerable:!0,get:()=>F.REMOVE_LIST_COMMAND});Object.defineProperty(exports,"BLUR_COMMAND",{enumerable:!0,get:()=>n.BLUR_COMMAND});Object.defineProperty(exports,"CLEAR_EDITOR_COMMAND",{enumerable:!0,get:()=>n.CLEAR_EDITOR_COMMAND});Object.defineProperty(exports,"CLICK_COMMAND",{enumerable:!0,get:()=>n.CLICK_COMMAND});Object.defineProperty(exports,"COMMAND_PRIORITY_CRITICAL",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_CRITICAL});Object.defineProperty(exports,"COMMAND_PRIORITY_EDITOR",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_EDITOR});Object.defineProperty(exports,"COMMAND_PRIORITY_HIGH",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_HIGH});Object.defineProperty(exports,"COMMAND_PRIORITY_LOW",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_LOW});Object.defineProperty(exports,"COMMAND_PRIORITY_NORMAL",{enumerable:!0,get:()=>n.COMMAND_PRIORITY_NORMAL});Object.defineProperty(exports,"COPY_COMMAND",{enumerable:!0,get:()=>n.COPY_COMMAND});Object.defineProperty(exports,"CUT_COMMAND",{enumerable:!0,get:()=>n.CUT_COMMAND});Object.defineProperty(exports,"DecoratorNode",{enumerable:!0,get:()=>n.DecoratorNode});Object.defineProperty(exports,"ElementNode",{enumerable:!0,get:()=>n.ElementNode});Object.defineProperty(exports,"FOCUS_COMMAND",{enumerable:!0,get:()=>n.FOCUS_COMMAND});Object.defineProperty(exports,"FORMAT_ELEMENT_COMMAND",{enumerable:!0,get:()=>n.FORMAT_ELEMENT_COMMAND});Object.defineProperty(exports,"FORMAT_TEXT_COMMAND",{enumerable:!0,get:()=>n.FORMAT_TEXT_COMMAND});Object.defineProperty(exports,"INDENT_CONTENT_COMMAND",{enumerable:!0,get:()=>n.INDENT_CONTENT_COMMAND});Object.defineProperty(exports,"INSERT_PARAGRAPH_COMMAND",{enumerable:!0,get:()=>n.INSERT_PARAGRAPH_COMMAND});Object.defineProperty(exports,"KEY_ENTER_COMMAND",{enumerable:!0,get:()=>n.KEY_ENTER_COMMAND});Object.defineProperty(exports,"KEY_ESCAPE_COMMAND",{enumerable:!0,get:()=>n.KEY_ESCAPE_COMMAND});Object.defineProperty(exports,"KEY_TAB_COMMAND",{enumerable:!0,get:()=>n.KEY_TAB_COMMAND});Object.defineProperty(exports,"OUTDENT_CONTENT_COMMAND",{enumerable:!0,get:()=>n.OUTDENT_CONTENT_COMMAND});Object.defineProperty(exports,"PASTE_COMMAND",{enumerable:!0,get:()=>n.PASTE_COMMAND});Object.defineProperty(exports,"REDO_COMMAND",{enumerable:!0,get:()=>n.REDO_COMMAND});Object.defineProperty(exports,"SELECTION_CHANGE_COMMAND",{enumerable:!0,get:()=>n.SELECTION_CHANGE_COMMAND});Object.defineProperty(exports,"TextNode",{enumerable:!0,get:()=>n.TextNode});Object.defineProperty(exports,"UNDO_COMMAND",{enumerable:!0,get:()=>n.UNDO_COMMAND});Object.defineProperty(exports,"createCommand",{enumerable:!0,get:()=>n.createCommand});exports.$createHorizontalRuleNode=se;exports.$isHorizontalRuleNode=Ue;exports.BareEditor=Ke;exports.BlockHandle=et;exports.ContextualEditor=Co;exports.DEFAULT_BLOCK_COMMANDS=Qe;exports.DEFAULT_INLINE_STYLE_PROPERTIES=qe;exports.DEFAULT_SLASH_COMMANDS=ho;exports.DockedEditor=po;exports.FloatingToolbar=Ze;exports.HR_TRANSFORMER=Ge;exports.HorizontalRuleNode=oe;exports.INSERT_HORIZONTAL_RULE_COMMAND=ce;exports.INSERT_IMAGE_COMMAND=xt;exports.LexicalEditorInput=yo;exports.LexicalToolbar=Ve;exports.SlashCommandPalette=bo;exports.TOGGLE_SLASH_COMMAND_PALETTE=Mt;exports.TOOLBAR_SEPARATOR=Ot;exports.applyMark=Ut;exports.buildInlineStyleImportMap=We;exports.buildStyleImportMap=ue;exports.createDefaultPluginConfig=pe;exports.createHeadlessEditor=de;exports.executeSlashCommand=St;exports.exportEditorToFile=_t;exports.exportToHtml=Y;exports.exportToMarkdown=K;exports.getCharacterCount=Wt;exports.getMarkdownTransformers=kt;exports.getNodesForPlugins=me;exports.getSelectionInfo=qt;exports.getTextContent=we;exports.getWordCount=Kt;exports.htmlToLexicalJson=ro;exports.importFileToEditor=vt;exports.importFromHtml=X;exports.importFromMarkdown=V;exports.insertTable=At;exports.insertTextAtCursor=Yt;exports.lexicalJsonToHtml=io;exports.lexicalJsonToMarkdown=no;exports.loadLexicalCore=ze;exports.loadOffsetUtils=Jt;exports.markdownToLexicalJson=oo;exports.registerAutoLinkPlugin=Bt;exports.registerClipboardPlugin=ye;exports.registerCodePlugin=Lt;exports.registerCodeShikiPlugin=It;exports.registerDragonPlugin=Se;exports.registerHashtagPlugin=$t;exports.registerHistoryPlugin=Ce;exports.registerHorizontalRulePlugin=Te;exports.registerLinkPlugin=Oe;exports.registerListPlugin=Ee;exports.registerMarkPlugin=jt;exports.registerOverflowPlugin=Gt;exports.registerPlainTextPlugin=be;exports.registerRichTextPlugin=he;exports.registerSlashCommandsPlugin=Nt;exports.registerTablePlugin=Ne;exports.registerYjsPlugin=Me;exports.removeMark=zt;
|