@lyfie/luthor 2.7.3 → 2.7.5
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/README.md +1 -1
- package/dist/{LegacyRichEditor-BK1LjaUd.d.ts → LegacyRichEditor-BJYk4DIh.d.ts} +1 -1
- package/dist/{chunk-6UNJGUCM.js → chunk-3DVRGGFP.js} +1 -1
- package/dist/{chunk-IZH46QEO.js → chunk-4QWDXM4Z.js} +1 -1
- package/dist/chunk-6XCGMELC.js +1 -0
- package/dist/{chunk-S4COFPXG.js → chunk-I2DU3ERA.js} +1 -1
- package/dist/chunk-LTDDNZY7.js +1 -0
- package/dist/chunk-NSEVF7IZ.js +1 -0
- package/dist/chunk-V2UXNC6V.js +1 -0
- package/dist/{chunk-CNIX7SRP.js → chunk-XKUPKZG4.js} +1 -1
- package/dist/chunk-ZD3C3KYY.js +18 -0
- package/dist/{index-eZXI9w3M.d.ts → index-D8EFfJrS.d.ts} +0 -2
- package/dist/{index-D2lyPRu1.d.ts → index-oHYmGmpX.d.ts} +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/presets/compose/index.d.ts +1 -1
- package/dist/presets/compose/index.js +1 -1
- package/dist/presets/extensive/index.d.ts +2 -2
- package/dist/presets/extensive/index.js +1 -1
- package/dist/presets/headless-editor/index.d.ts +1 -1
- package/dist/presets/headless-editor/index.js +1 -1
- package/dist/presets/html-editor/index.d.ts +2 -2
- package/dist/presets/html-editor/index.js +1 -1
- package/dist/presets/legacy-rich/index.d.ts +2 -2
- package/dist/presets/legacy-rich/index.js +1 -1
- package/dist/presets/md-editor/index.d.ts +2 -2
- package/dist/presets/md-editor/index.js +1 -1
- package/dist/presets/simple-editor/index.d.ts +1 -1
- package/dist/presets/simple-editor/index.js +1 -1
- package/dist/presets/slash-editor/index.d.ts +1 -1
- package/dist/presets/slash-editor/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-4DHY4VVC.js +0 -18
- package/dist/chunk-5VVQH4YY.js +0 -1
- package/dist/chunk-6KIISXIV.js +0 -1
- package/dist/chunk-CXFVQX2C.js +0 -1
- package/dist/chunk-H33QXH5Y.js +0 -1
package/dist/chunk-4DHY4VVC.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {ImageExtension,TableExtension,IframeEmbedExtension,YouTubeEmbedExtension,ContextMenuExtension,CommandPaletteExtension,SlashCommandExtension,EmojiExtension,DraggableBlockExtension,LinkExtension,textColorExtension,textHighlightExtension,createCustomNodeExtension,createEditorSystem,mergeThemes,defaultLuthorTheme,createEditorThemeStyleVars,FloatingToolbarExtension,FontFamilyExtension,FontSizeExtension,LineHeightExtension,codeExtension,codeIntelligenceExtension,ListExtension,TabIndentExtension,boldExtension,italicExtension,underlineExtension,strikethroughExtension,subscriptExtension,superscriptExtension,horizontalRuleExtension,historyExtension,blockFormatExtension,codeFormatExtension,enterKeyBehaviorExtension,jsonToMarkdown,jsonToHTML,RichText,markdownToJSON,clearLexicalSelection,resolveLinkNodeKeyFromAnchor,htmlToJSON}from'@lyfie/luthor-headless';import Il,{forwardRef,useState,useRef,useMemo,useEffect,useImperativeHandle,createElement,useCallback,useLayoutEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var pi=Object.defineProperty;var bi=(e,t,n)=>t in e?pi(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var Bs=(e,t,n)=>bi(e,typeof t!="symbol"?t+"":t,n);var Ve=["h1","h2","h3","h4","h5","h6"],Ks={sections:[{items:["fontFamily","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","code","link"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","codeBlock"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["horizontalRule"]},{items:["table"]},{items:["image"]},{items:["emoji"]},{items:["embed"]},{items:["customComponent"]},{items:["undo","redo"]},{items:["commandPalette"]},{items:["themeToggle"]}]},pn={sections:[{items:["undo","redo"]},{items:["fontFamily","blockFormat","fontSize","lineHeight"]},{items:["bold","italic","underline","strikethrough","textColor","textHighlight"]},{items:["alignLeft","alignCenter","alignRight","alignJustify"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["link"]},{items:["image","table","code","codeBlock","horizontalRule","quote"]},{items:["subscript","superscript","emoji","embed","customComponent"]},{items:["commandPalette","themeToggle"]}]};function yi(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function Ci(e,t){return yi(e.target)?xo(t):false}function xo(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"}function To(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function vi(e){return typeof e.toggleSubscript=="function"}function Ei(e){return typeof e.toggleSuperscript=="function"}function ki(e){return typeof e.insertIframeEmbed=="function"}function Li(e){return typeof e.insertYouTubeEmbed=="function"}function wi(e){return typeof e.insertEmoji=="function"}function Si(e){return e.slice(1)}function Ti(e){switch(e){case "h1":return "Convert to large heading";case "h2":return "Convert to medium heading";case "h3":return "Convert to small heading";case "h4":return "Convert to heading level 4";case "h5":return "Convert to heading level 5";case "h6":return "Convert to heading level 6"}}function xi(e){if(!e||e.length===0)return [...Ve];let t=new Set,n=[];for(let o of e)!Ve.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Ve]}function Vn(e,t){return Oi(jn(t),t?.shortcutConfig).filter(o=>!o.condition||o.condition(e))}function oe(e,t){return typeof e[t]=="function"}function bn(e){if(!e||e.length===0)return new Set;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return new Set(t)}function Ii(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let n=[];for(let o of e)for(let[i,r]of Object.entries(o))r&&n.push(i);return {allowlist:bn(n),denylist:new Set}}let t=e;return {allowlist:bn(t.allowlist),denylist:bn(t.denylist)}}function Io(e){let t=e.key.trim();return t?{key:t,ctrlKey:!!e.ctrlKey,metaKey:!!e.metaKey,shiftKey:!!e.shiftKey,altKey:!!e.altKey,preventDefault:e.preventDefault}:null}function Fi(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],n=[];for(let o of t){let i=Io(o);i&&n.push(i);}return n}function Mi(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function Oi(e,t){if(!t)return [...e];let n=bn(t.disabledCommandIds),o=t.bindings,i=t.preventNativeConflicts!==false,r=t.preventCollisions!==false,l=new Set;return e.filter(u=>!n.has(u.id)).map(u=>{let d=u.shortcuts?[...u.shortcuts]:void 0;if(!!o&&Object.prototype.hasOwnProperty.call(o,u.id)&&o){let b=o[u.id],E=b===void 0?[]:Fi(b);d=E.length>0?E:void 0;}if(d&&d.length>0){let b=[];for(let E of d){let g=Io(E);if(!g||i&&xo(g))continue;let f=Mi(g);r&&l.has(f)||(l.add(f),b.push(g));}d=b.length>0?b:void 0;}return {...u,shortcuts:d}})}function jn(e){let t=e?.isFeatureEnabled??(()=>true),n=xi(e?.headingOptions),o=e?.paragraphLabel?.trim()||"Paragraph",i=n.map(r=>{let l=Si(r);return {id:`block.heading${l}`,label:`Heading ${l}`,description:Ti(r),category:"Block",action:s=>s.toggleHeading?.(r),shortcuts:[{key:l,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:s=>t("blockFormat")&&oe(s,"toggleHeading")}});return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:r=>r.toggleBold?.(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"],condition:r=>t("bold")&&oe(r,"toggleBold")},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:r=>r.toggleItalic?.(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"],condition:r=>t("italic")&&oe(r,"toggleItalic")},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:r=>r.toggleUnderline?.(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"],condition:r=>t("underline")&&oe(r,"toggleUnderline")},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:r=>r.toggleStrikethrough?.(),keywords:["strikethrough","format"],condition:r=>t("strikethrough")&&oe(r,"toggleStrikethrough")},{id:"format.subscript",label:"Toggle Subscript",description:"Format text as subscript",category:"Format",action:r=>r.toggleSubscript?.(),keywords:["subscript","format"],condition:r=>t("subscript")&&vi(r)},{id:"format.superscript",label:"Toggle Superscript",description:"Format text as superscript",category:"Format",action:r=>r.toggleSuperscript?.(),keywords:["superscript","format"],condition:r=>t("superscript")&&Ei(r)},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:r=>r.formatText?.("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"],condition:r=>t("codeFormat")&&oe(r,"formatText")},{id:"block.paragraph",label:o,description:"Convert to paragraph",category:"Block",action:r=>r.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:r=>t("blockFormat")&&oe(r,"toggleParagraph")},...i,{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:r=>r.toggleQuote?.(),keywords:["quote","blockquote"],condition:r=>t("blockFormat")&&oe(r,"toggleQuote")},{id:"block.align-left",label:"Align Left",description:"Align selected blocks to the left",category:"Block",action:r=>r.setTextAlignment?.("left"),keywords:["align","left","text"],condition:r=>t("blockFormat")&&oe(r,"setTextAlignment")},{id:"block.align-center",label:"Align Center",description:"Center-align selected blocks",category:"Block",action:r=>r.setTextAlignment?.("center"),keywords:["align","center","text"],condition:r=>t("blockFormat")&&oe(r,"setTextAlignment")},{id:"block.align-right",label:"Align Right",description:"Align selected blocks to the right",category:"Block",action:r=>r.setTextAlignment?.("right"),keywords:["align","right","text"],condition:r=>t("blockFormat")&&oe(r,"setTextAlignment")},{id:"block.align-justify",label:"Justify",description:"Justify selected blocks",category:"Block",action:r=>r.setTextAlignment?.("justify"),keywords:["align","justify","text"],condition:r=>t("blockFormat")&&oe(r,"setTextAlignment")},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:r=>r.toggleCodeBlock?.(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"],condition:r=>t("code")&&oe(r,"toggleCodeBlock")},{id:"block.code-language",label:"Set Code Language",description:"Set language for selected code block",category:"Block",action:r=>{if(!r.setCodeLanguage)return;let l=prompt("Code language (e.g. ts, css, python):")?.trim();l&&r.setCodeLanguage(l);},keywords:["code","language","syntax"],condition:r=>t("codeIntelligence")&&To(r)},{id:"block.code-language.auto",label:"Auto-Detect Code Language",description:"Detect language from selected code block",category:"Block",action:r=>{r.autoDetectCodeLanguage?.();},keywords:["code","language","auto","detect"],condition:r=>t("codeIntelligence")&&To(r)},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:r=>r.toggleUnorderedList?.(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"],condition:r=>t("list")&&oe(r,"toggleUnorderedList")},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:r=>r.toggleOrderedList?.(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"],condition:r=>t("list")&&oe(r,"toggleOrderedList")},{id:"list.check",label:"Checklist",description:"Create or toggle checklist",category:"List",action:r=>r.toggleCheckList?.(),shortcuts:[{key:"x",ctrlKey:true,shiftKey:true}],keywords:["list","check","todo","task"],condition:r=>t("list")&&oe(r,"toggleCheckList")},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:r=>r.insertLink?.(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"],condition:r=>t("link")&&oe(r,"insertLink")},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:r=>r.removeLink?.(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"],condition:r=>t("link")&&oe(r,"removeLink")},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:r=>r.insertHorizontalRule?.(),keywords:["horizontal","rule","hr","divider","separator"],condition:r=>t("horizontalRule")&&oe(r,"insertHorizontalRule")},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:r=>{let l=prompt("Enter image URL:");if(l){let s=prompt("Enter alt text:")||"";r.insertImage?.({src:l,alt:s});}},keywords:["image","photo"],condition:r=>t("image")&&oe(r,"insertImage")},{id:"insert.gif",label:"Insert GIF",description:"Insert an animated GIF from URL",category:"Insert",action:r=>{let l=prompt("Enter GIF URL:");l&&r.insertImage?.({src:l,alt:"GIF"});},keywords:["gif","animated","image"],condition:r=>t("image")&&oe(r,"insertImage")},{id:"insert.emoji",label:"Insert Emoji",description:"Insert an emoji character",category:"Insert",action:r=>{let l=prompt("Enter emoji or shortcode (example :sparkles:):")?.trim();if(!l||typeof r.insertEmoji!="function")return;let s=l.match(/^:([a-z0-9_+-]+):$/i);if(s){let u=s[1];if(!u)return;if(typeof r.resolveEmojiShortcode=="function"){let d=r.resolveEmojiShortcode(u);if(d?.emoji){r.insertEmoji(d.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[d]=r.getEmojiSuggestions(u);if(d?.emoji){r.insertEmoji(d.emoji);return}}}r.insertEmoji(l);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&wi(r)},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:r=>r.insertTable?.({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"],condition:r=>t("table")&&oe(r,"insertTable")},{id:"insert.iframe",label:"Insert iframe",description:"Insert an iframe embed from URL",category:"Insert",action:r=>{if(typeof r.insertIframeEmbed!="function")return;let l=prompt("Enter iframe URL:");l&&r.insertIframeEmbed(l);},keywords:["iframe","embed","url"],condition:r=>t("iframeEmbed")&&ki(r)},{id:"insert.youtube",label:"Insert YouTube Video",description:"Insert an embedded YouTube video",category:"Insert",action:r=>{if(typeof r.insertYouTubeEmbed!="function")return;let l=prompt("Enter YouTube URL:");l&&r.insertYouTubeEmbed(l);},keywords:["youtube","video","embed"],condition:r=>t("youTubeEmbed")&&Li(r)},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:r=>r.undo?.(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"],condition:r=>t("history")&&oe(r,"undo")},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:r=>r.redo?.(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"],condition:r=>t("history")&&oe(r,"redo")},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:r=>r.showCommandPalette?.(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"],condition:r=>t("commandPalette")&&oe(r,"showCommandPalette")}]}function Fo(e,t){let n=t?.commandPaletteShortcutOnly===true;return Vn(e,t).filter(o=>!n||!!o.shortcuts&&o.shortcuts.length>0).map(o=>({id:o.id,label:o.label,description:o.description,category:o.category,action:()=>o.action(e),keywords:o.keywords,shortcut:o.shortcuts?.[0]?Oo(o.shortcuts[0]):void 0}))}function Mo(e,t){let n=new Set(["block.paragraph","block.quote","block.codeblock"]),o=s=>s.category==="Insert"||s.category==="List"?true:s.category==="Block"?s.id.startsWith("block.heading")?true:n.has(s.id):false,{allowlist:i,denylist:r}=Ii(t?.slashCommandVisibility),l=i.size>0;return Vn(e,t).filter(s=>r.has(s.id)?false:l?i.has(s.id):o(s)).map(s=>({id:s.id,label:s.label,description:s.description,category:s.category,action:()=>s.action(e),keywords:s.keywords,shortcut:s.shortcuts?.[0]?Oo(s.shortcuts[0]):void 0}))}function Oo(e){let t=[];return e.ctrlKey&&t.push("Ctrl"),e.metaKey&&t.push("Cmd"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),t.push(e.key.toUpperCase()),t.join("+")}function No(e,t=document.body,n){let o=Vn(e,n),i=(l,s)=>l.key.toLowerCase()===s.key.toLowerCase()||s.key==="`"&&l.code==="Backquote",r=l=>{let s=typeof n?.scope=="function"?n.scope():n?.scope;if(!(s&&l.target instanceof Node&&!s.contains(l.target))){for(let u of o)if(u.shortcuts){for(let d of u.shortcuts)if(!(n?.shortcutConfig?.preventNativeConflicts!==false&&Ci(l,d))&&i(l,d)&&!!l.ctrlKey==!!d.ctrlKey&&!!l.metaKey==!!d.metaKey&&!!l.shiftKey==!!d.shiftKey&&!!l.altKey==!!d.altKey){d.preventDefault!==false&&l.preventDefault(),(!u.condition||u.condition(e))&&u.action(e);return}}}};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)}function U(e,t){let n=forwardRef(function({size:i=24,strokeWidth:r=2,...l},s){return jsx("svg",{ref:s,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...l,children:t})});return n.displayName=e,n}var yn=U("BoldIcon",jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})),Cn=U("ItalicIcon",jsxs(Fragment,{children:[jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})),vn=U("UnderlineIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})),En=U("StrikethroughIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})),kn=U("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),Ho=U("CodeBlockIcon",jsxs(Fragment,{children:[jsx("path",{d:"m10 9-3 3 3 3"}),jsx("path",{d:"m14 15 3-3-3-3"}),jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"})]})),zt=U("LinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),Ft=U("UnlinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71"}),jsx("path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71"}),jsx("line",{x1:"8",x2:"8",y1:"2",y2:"5"}),jsx("line",{x1:"2",x2:"5",y1:"8",y2:"8"}),jsx("line",{x1:"16",x2:"16",y1:"19",y2:"22"}),jsx("line",{x1:"19",x2:"22",y1:"16",y2:"16"})]})),Xt=U("ListIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h.01"}),jsx("path",{d:"M3 12h.01"}),jsx("path",{d:"M3 19h.01"}),jsx("path",{d:"M8 5h13"}),jsx("path",{d:"M8 12h13"}),jsx("path",{d:"M8 19h13"})]})),Qt=U("ListCheckIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 5H3"}),jsx("path",{d:"M16 12H3"}),jsx("path",{d:"M11 19H3"}),jsx("path",{d:"m15 18 2 2 4-4"})]})),Zt=U("ListOrderedIcon",jsxs(Fragment,{children:[jsx("path",{d:"M11 5h10"}),jsx("path",{d:"M11 12h10"}),jsx("path",{d:"M11 19h10"}),jsx("path",{d:"M4 4h1v5"}),jsx("path",{d:"M4 9h2"}),jsx("path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"})]})),Ro=U("UndoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})),Ao=U("RedoIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})]})),$n=U("ImageIcon",jsxs(Fragment,{children:[jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),jsx("circle",{cx:"9",cy:"9",r:"2"}),jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})),Dt=U("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M15 12H3"}),jsx("path",{d:"M17 19H3"})]})),Mt=U("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),Po=U("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h18"}),jsx("path",{d:"M3 12h18"}),jsx("path",{d:"M3 19h18"})]})),Bt=U("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M21 12H9"}),jsx("path",{d:"M21 19H7"})]})),qn=U("UploadIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v12"}),jsx("path",{d:"m17 8-5-5-5 5"}),jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"})]})),zo=U("MinusIcon",jsx("path",{d:"M5 12h14"})),Do=U("TableIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 3v18"}),jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),jsx("path",{d:"M3 9h18"}),jsx("path",{d:"M3 15h18"})]})),Bo=U("FileCodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"}),jsx("path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}),jsx("path",{d:"M10 12.5 8 15l2 2.5"}),jsx("path",{d:"m14 12.5 2 2.5-2 2.5"})]})),qs=U("EyeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]})),Uo=U("HighlighterIcon",jsxs(Fragment,{children:[jsx("path",{d:"m9 11-6 6v3h9l3-3"}),jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})),Ys=U("PencilIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"}),jsx("path",{d:"m15 5 4 4"})]})),Ln=U("CommandIcon",jsx("path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3"})),Ko=U("PaletteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"})]})),_o=U("TypeIcon",jsxs(Fragment,{children:[jsx("path",{d:"M12 4v16"}),jsx("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),jsx("path",{d:"M9 20h6"})]})),wn=U("QuoteIcon",jsxs(Fragment,{children:[jsx("path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"}),jsx("path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"})]})),Vo=U("IndentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m3 8 4 4-4 4"})]})),jo=U("OutdentIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H11"}),jsx("path",{d:"M21 12H11"}),jsx("path",{d:"M21 19H11"}),jsx("path",{d:"m7 8-4 4 4 4"})]})),$o=U("SunIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})),qo=U("MoonIcon",jsx("path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"})),Yo=U("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Yn=U("EmojiIcon",jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"10"}),jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),jsx("line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}),jsx("line",{x1:"15",x2:"15.01",y1:"9",y2:"9"})]})),Jo=U("SubscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 5 8 8"}),jsx("path",{d:"m12 5-8 8"}),jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})),Go=U("SuperscriptIcon",jsxs(Fragment,{children:[jsx("path",{d:"m4 19 8-8"}),jsx("path",{d:"m12 19-8-8"}),jsx("path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06"})]})),Ut=U("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),Wo=U("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Zo({isOpen:e,onClose:t,commands:n}){let[o,i]=useState(""),[r,l]=useState(0),s=useRef(null),u=useRef(null),d=n.filter(E=>`${E.label} ${E.description||""} ${E.keywords?.join(" ")||""}`.toLowerCase().includes(o.toLowerCase())),v=d.reduce((E,g)=>{let f=g.category||"Other";return E[f]||(E[f]=[]),E[f].push(g),E},{}),b=d;return useEffect(()=>{l(0);},[o]),useEffect(()=>{e&&s.current&&(s.current.focus({preventScroll:true}),i(""),l(0));},[e]),useEffect(()=>{if(!e)return;let E=u.current;if(!E)return;E.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,o]),useEffect(()=>{let E=g=>{if(e)switch(g.key){case "Escape":g.preventDefault(),g.stopPropagation(),t();break;case "ArrowDown":g.preventDefault(),g.stopPropagation(),l(f=>Math.min(f+1,b.length-1));break;case "ArrowUp":g.preventDefault(),g.stopPropagation(),l(f=>Math.max(f-1,0));break;case "Enter":g.preventDefault(),g.stopPropagation(),b[r]&&(b[r].action(),t());break}};return document.addEventListener("keydown",E,true),()=>document.removeEventListener("keydown",E,true)},[e,r,b,t]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:t,children:jsxs("div",{className:"luthor-command-palette",role:"dialog","aria-modal":"true","aria-label":"Command Palette",onClick:E=>E.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(Yo,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:s,type:"text",placeholder:"Type a command or search...",value:o,onChange:E=>i(E.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{ref:u,className:"luthor-command-palette-list",children:Object.keys(v).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(v).map(([E,g])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:E}),g.map(f=>{let h=b.indexOf(f);return jsxs("div",{className:`luthor-command-palette-item ${h===r?"selected":""}`,onClick:()=>{f.action(),t();},onMouseEnter:()=>l(h),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:f.label}),f.description&&jsx("div",{className:"luthor-command-palette-item-description",children:f.description})]}),f.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:f.shortcut})]},f.id)})]},E))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Ln,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var Hi={"--luthor-bg":"#ffffff","--luthor-fg":"#0f172a","--luthor-border":"#e2e8f0","--luthor-border-hover":"#cbd5e1","--luthor-border-active":"#94a3b8","--luthor-accent":"#0f172a","--luthor-accent-hover":"#1e293b","--luthor-shadow":"rgba(0, 0, 0, 0.08)","--luthor-muted":"#f8fafc","--luthor-muted-fg":"#64748b","--luthor-theme-transition":"0.2s ease","--luthor-drag-gutter-width":"56px","--luthor-line-height-ratio":"1","--luthor-toolbar-bg":"#f8fafc","--luthor-toolbar-section-border":"#e2e8f0","--luthor-toolbar-button-fg":"#0f172a","--luthor-toolbar-button-hover-bg":"#f8fafc","--luthor-toolbar-button-hover-border":"#cbd5e1","--luthor-toolbar-button-hover-shadow":"0 4px 12px rgba(0, 0, 0, 0.15)","--luthor-toolbar-button-press-shadow":"0 2px 8px rgba(0, 0, 0, 0.1)","--luthor-toolbar-button-active-bg":"#0f172a","--luthor-toolbar-button-active-border":"#0f172a","--luthor-toolbar-button-active-fg":"#ffffff","--luthor-toolbar-button-active-shadow":"0 2px 8px rgba(0, 0, 0, 0.2)","--luthor-toolbar-button-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%)","--luthor-toolbar-button-active-overlay":"linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%)","--luthor-toolbar-color-indicator-border":"#000000","--luthor-toolbar-highlight-bg":"#f8fafc","--luthor-quote-bg":"#f8fafc","--luthor-quote-fg":"#0f172a","--luthor-quote-border":"#0f172a","--luthor-syntax-comment":"#64748b","--luthor-syntax-keyword":"#64748b","--luthor-syntax-string":"#64748b","--luthor-syntax-number":"#64748b","--luthor-syntax-function":"#64748b","--luthor-syntax-variable":"#64748b","--luthor-floating-bg":"#ffffff","--luthor-floating-fg":"#0f172a","--luthor-floating-border":"#e2e8f0","--luthor-floating-shadow":"rgba(0, 0, 0, 0.08)","--luthor-floating-muted":"#f8fafc","--luthor-floating-border-hover":"#cbd5e1","--luthor-floating-border-active":"#94a3b8","--luthor-floating-accent":"#0f172a","--luthor-floating-accent-fg":"#ffffff","--luthor-z-dropdown":"60","--luthor-z-popover":"64","--luthor-z-menu":"68","--luthor-z-overlay":"72","--luthor-z-modal":"76","--luthor-preset-bg":"#ffffff","--luthor-preset-fg":"#0f172a","--luthor-preset-border":"#dbe2ea","--luthor-preset-muted":"#f8fafc","--luthor-preset-muted-fg":"#64748b","--luthor-preset-accent":"#2563eb","--luthor-preset-radius":"10px","--luthor-preset-shadow":"0 1px 3px rgba(15, 23, 42, 0.08)","--luthor-preset-content-padding":"16px","--luthor-preset-content-min-height":"180px"};function Ri(e){return e?e.closest(".luthor-editor-wrapper"):null}function Ai(e){return e?Ri(e)??e:null}function Pi(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),n={};for(let[o,i]of Object.entries(Hi)){let r=t.getPropertyValue(o).trim()||i;n[o]=r;}return n}function je(e){return Pi(Ai(e))}function _t(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return je(n)}function Ot(e){return e?e.closest(".luthor-editor-wrapper")??null:null}function er(e,t,n){return e<t?t:e>n?n:e}function zi(e){if(!e||typeof window>"u"){let n=typeof window>"u"?0:window.innerWidth,o=typeof window>"u"?0:window.innerHeight;return {left:0,top:0,right:n,bottom:o,width:n,height:o}}let t=e.getBoundingClientRect();return {left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height}}function Di(e,t,n,o,i,r){let l=i==="end"?e.right-t:i==="center"?e.left+e.width/2-t/2:e.left,s=i==="end"?e.left:i==="center"?e.left+e.width/2-t/2:e.right-t,u=l,d=n.left+o,v=Math.max(d,n.right-t-o);if(r){let b=u<d||u>v,E=s>=d&&s<=v;b&&E&&(u=s);}return er(u,d,v)}function Bi(e,t,n,o,i,r,l){let s=r==="top"?e.top-t-o:e.bottom+o,u=r==="top"?e.bottom+o:e.top-t-o,d=s,v=n.top+i,b=Math.max(v,n.bottom-t-i);if(l){let E=d<v||d>b,g=u>=v&&u<=b;E&&g&&(d=u);}return er(d,v,b)}function Se({anchorRect:e,overlay:t,portalContainer:n=null,gap:o=4,margin:i=8,preferredX:r="start",preferredY:l="bottom",flipX:s=true,flipY:u=true}){let d=zi(n),v=Math.max(0,d.width-i*2),b=Math.max(0,d.height-i*2),E=Math.max(0,Math.min(t.width,v)),g=Math.max(0,Math.min(t.height,b)),f=Di(e,E,d,i,r,s),h=Bi(e,g,d,o,i,l,u);if(n){let y=n.getBoundingClientRect();return {position:"absolute",left:f-y.left+n.scrollLeft,top:h-y.top+n.scrollTop,maxWidth:v>0?v:void 0,maxHeight:b>0?b:void 0}}return {position:"fixed",left:f,top:h,maxWidth:v>0?v:void 0,maxHeight:b>0?b:void 0}}function Tn(e,t){return {x:e,y:t,width:1,height:1,left:e,right:e+1,top:t,bottom:t+1,toJSON:()=>({})}}function nr({isOpen:e,query:t,position:n,portalContainer:o,suggestions:i,onClose:r,onExecute:l}){let[s,u]=useState(0),d=useRef(null),[v,b]=useState(void 0);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let f=h=>{let y=i.length>0;switch(h.key){case "Escape":h.preventDefault(),h.stopPropagation(),r();break;case "ArrowDown":if(!y)return;h.preventDefault(),h.stopPropagation(),u(T=>Math.min(T+1,Math.max(i.length-1,0)));break;case "ArrowUp":if(!y)return;h.preventDefault(),h.stopPropagation(),u(T=>Math.max(T-1,0));break;case "Enter":case "Tab":if(!y||!i[s])return;h.preventDefault(),h.stopPropagation(),l(i[s].emoji);break}};return document.addEventListener("keydown",f,true),()=>document.removeEventListener("keydown",f,true)},[e,r,l,s,i]);let E=useCallback(f=>{if(!n)return;let h=d.current?.getBoundingClientRect(),y=Se({anchorRect:Tn(n.x,n.y),overlay:{width:h?.width??320,height:h?.height??280},portalContainer:o??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});b({...y,visibility:f?"visible":"hidden",..._t()});},[o,n]);if(useLayoutEffect(()=>{if(!e||!n)return;E(false);let f=window.requestAnimationFrame(()=>E(true));return ()=>window.cancelAnimationFrame(f)},[e,n,E]),useEffect(()=>{if(!e||!n)return;let f=()=>E(true);return window.addEventListener("resize",f),window.addEventListener("scroll",f,true),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,true);}},[e,n,E]),!e||!n)return null;let g=jsxs("div",{className:"luthor-emoji-menu",ref:d,style:v,onPointerDown:f=>{f.stopPropagation();},onMouseDown:f=>{f.stopPropagation();},children:[jsxs("div",{className:"luthor-emoji-menu-header",children:[jsx("span",{className:"luthor-emoji-menu-title",children:"Emoji"}),jsxs("span",{className:"luthor-emoji-menu-query",children:[":",t]})]}),jsx("div",{className:"luthor-emoji-menu-list",children:i.length===0?jsx("div",{className:"luthor-emoji-menu-empty",children:"No matching emoji"}):i.map((f,h)=>{let y=h===s,T=f.shortcodes[0]?`:${f.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${y?"selected":""}`,onMouseEnter:()=>u(h),onMouseDown:k=>{k.preventDefault(),k.stopPropagation();},onClick:k=>{k.preventDefault(),k.stopPropagation(),l(f.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:f.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:f.label}),T&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:T})]})]},`${f.emoji}-${f.label}`)})})]});return typeof document>"u"?g:createPortal(g,o??document.body)}var Wn=360,Yi=.5,Ji=420;function lr(){if(typeof window>"u")return Wn;let e=Math.floor(window.innerHeight*Yi);return e<=0?Wn:Math.min(Wn,e)}function Gi(e){let t=lr();return typeof e!="number"?t:Math.max(0,Math.min(e,t))}function ar({isOpen:e,query:t,position:n,portalContainer:o,commands:i,onClose:r,onExecute:l}){let[s,u]=useState(0),d=useRef(null),[v,b]=useState(void 0),E=useRef(false),g=useMemo(()=>{let T=t.trim().toLowerCase();return T?i.filter(k=>`${k.label} ${k.description||""} ${k.keywords?.join(" ")||""}`.toLowerCase().includes(T)):i},[i,t]),f=useMemo(()=>g.reduce((T,k)=>{let F=k.category||"Other";return T[F]||(T[F]=[]),T[F].push(k),T},{}),[g]);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let T=k=>{let F=g.length>0;switch(k.key){case "Escape":k.preventDefault(),k.stopPropagation(),r();break;case "ArrowDown":if(!F)return;k.preventDefault(),k.stopPropagation(),u(M=>Math.min(M+1,Math.max(g.length-1,0)));break;case "ArrowUp":if(!F)return;k.preventDefault(),k.stopPropagation(),u(M=>Math.max(M-1,0));break;case "Enter":case "Tab":if(!F||!g[s])return;k.preventDefault(),k.stopPropagation(),l(g[s].id);break}};return document.addEventListener("keydown",T,true),()=>document.removeEventListener("keydown",T,true)},[g,e,r,l,s]);let h=useCallback(T=>{if(!n)return;let k=lr(),F=d.current?.getBoundingClientRect(),M=Se({anchorRect:Tn(n.x,n.y),overlay:{width:F?.width??Ji,height:Math.min(F?.height??k,k)},portalContainer:o??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});b({...M,maxHeight:Gi(M.maxHeight),visibility:T?"visible":"hidden",..._t()});},[o,n]);if(useLayoutEffect(()=>{if(!e||!n){E.current=false;return}if(!E.current){E.current=true,h(false);let T=window.requestAnimationFrame(()=>h(true));return ()=>window.cancelAnimationFrame(T)}h(true);},[e,n,h]),useEffect(()=>{if(!e||!n)return;let T=()=>h(true);return window.addEventListener("resize",T),window.addEventListener("scroll",T,true),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,true);}},[e,n,h]),!e||!n)return null;let y=jsxs("div",{className:"luthor-slash-menu",ref:d,style:v,onPointerDown:T=>{T.stopPropagation();},onMouseDown:T=>{T.stopPropagation();},children:[jsxs("div",{className:"luthor-slash-menu-header",children:[jsx("span",{className:"luthor-slash-menu-title",children:"Insert block"}),jsxs("span",{className:"luthor-slash-menu-query",children:["/",t]})]}),jsx("div",{className:"luthor-slash-menu-list",children:g.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(f).map(([T,k])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:T}),k.map(F=>{let M=g.indexOf(F);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${M===s?"selected":""}`,onMouseEnter:()=>u(M),onMouseDown:Q=>{Q.preventDefault(),Q.stopPropagation();},onClick:Q=>{Q.preventDefault(),Q.stopPropagation(),l(F.id);},children:[jsxs("span",{className:"luthor-slash-menu-item-content",children:[jsx("span",{className:"luthor-slash-menu-item-title",children:F.label}),F.description&&jsx("span",{className:"luthor-slash-menu-item-description",children:F.description})]}),F.shortcut&&jsx("kbd",{className:"luthor-slash-menu-item-shortcut",children:F.shortcut})]},F.id)})]},T))})]});return typeof document>"u"?y:createPortal(y,o??document.body)}function R({children:e,onClick:t,title:n,active:o,disabled:i,className:r,type:l="button"}){return jsx("button",{type:l,className:`luthor-toolbar-button${o?" active":""}${r?` ${r}`:""}`,onClick:t,title:n,disabled:i,children:e})}function Xn({children:e,onClick:t,variant:n="primary",type:o="button",className:i}){return jsx("button",{type:o,onClick:t,className:`${n==="primary"?"luthor-button-primary":"luthor-button-secondary"}${i?` ${i}`:""}`,children:e})}function rn({value:e,onValueChange:t,options:n,placeholder:o="Select..."}){let[i,r]=useState(false),[l,s]=useState(void 0),[u,d]=useState(null),v=useRef(null),b=useRef(null);useEffect(()=>{if(!i)return;let g=()=>{let h=v.current?.querySelector(".luthor-select-trigger");if(!h)return;let y=h.getBoundingClientRect(),T=b.current?.getBoundingClientRect(),k=Math.max(T?.width??0,b.current?.scrollWidth??0),F=Ot(h);d(F);let M=Math.max(y.width,k),A=T?.height??220,Q=Se({anchorRect:y,overlay:{width:M,height:A},portalContainer:F,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});s({...Q,width:M,...je(h)});};g();let f=()=>g();return window.addEventListener("resize",f),window.addEventListener("scroll",f,true),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,true),d(null);}},[i]),useLayoutEffect(()=>{if(!i)return;let g=v.current?.querySelector(".luthor-select-trigger");if(!g)return;let f=g.getBoundingClientRect(),h=Ot(g);d(h);let y=Se({anchorRect:f,overlay:{width:f.width,height:220},portalContainer:h,gap:4,margin:8});s({...y,width:f.width,...je(g)});let T=window.requestAnimationFrame(()=>{let k=b.current?.getBoundingClientRect(),F=Math.max(k?.width??0,b.current?.scrollWidth??0),M=Math.max(f.width,F),A=Se({anchorRect:f,overlay:{width:M,height:k?.height??220},portalContainer:h,gap:4,margin:8});s({...A,width:M,...je(g)});});return ()=>window.cancelAnimationFrame(T)},[i]),useEffect(()=>{function g(f){let h=f.target;v.current?.contains(h)||b.current?.contains(h)||r(false);}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);let E=n.find(g=>g.value===e);return jsxs("div",{className:"luthor-select",ref:v,children:[jsxs("button",{className:`luthor-select-trigger ${i?"open":""}`,onClick:()=>r(!i),type:"button",children:[jsx("span",{children:E?.label||o}),jsx(Ut,{size:14})]}),i&&typeof document<"u"&&createPortal(jsx("div",{ref:b,className:"luthor-select-dropdown",style:l,children:n.map(g=>jsx("button",{className:`luthor-select-option ${e===g.value?"selected":""}`,onClick:()=>{t(g.value),r(false);},type:"button",children:g.label},g.value))}),u??document.body)]})}function Ct({trigger:e,children:t,isOpen:n,onOpenChange:o}){let i=useRef(null),r=useRef(null),l=useRef(null),[s,u]=useState(void 0),[d,v]=useState(null);return useEffect(()=>{if(!n)return;let b=()=>{let g=r.current;if(!g)return;let f=g.getBoundingClientRect(),h=l.current?.getBoundingClientRect(),y=Ot(g);v(y);let T=Se({anchorRect:f,overlay:{width:h?.width??220,height:h?.height??200},portalContainer:y,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});u({...T,...je(g)});},E=()=>b();return window.addEventListener("resize",E),window.addEventListener("scroll",E,true),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,true),v(null);}},[n]),useLayoutEffect(()=>{if(!n)return;let b=r.current;if(!b)return;let E=b.getBoundingClientRect(),g=Ot(b);v(g);let f=Se({anchorRect:E,overlay:{width:220,height:200},portalContainer:g,gap:4,margin:8});u({...f,...je(b)});let h=window.requestAnimationFrame(()=>{let y=l.current?.getBoundingClientRect(),T=Se({anchorRect:E,overlay:{width:y?.width??220,height:y?.height??200},portalContainer:g,gap:4,margin:8});u({...T,...je(b)});});return ()=>window.cancelAnimationFrame(h)},[n]),useEffect(()=>{function b(E){let g=E.target;i.current?.contains(g)||l.current?.contains(g)||o(false);}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[o]),jsxs("div",{className:"luthor-dropdown",ref:i,children:[jsx("div",{ref:r,onClick:()=>o(!n),children:e}),n&&typeof document<"u"&&createPortal(jsx("div",{ref:l,className:"luthor-dropdown-content",style:s,children:t}),d??document.body)]})}function cr({isOpen:e,onClose:t,title:n,children:o}){let i=useRef(null);return useEffect(()=>{function r(s){i.current&&!i.current.contains(s.target)&&t();}function l(s){s.key==="Escape"&&t();}return e&&(document.addEventListener("mousedown",r),document.addEventListener("keydown",l)),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",l);}},[e,t]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:i,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:n}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(Wo,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:o})]})}):null}function dr({isVisible:e,selectionRect:t,commands:n,activeStates:o,editorTheme:i="light",hide:r,isFeatureEnabled:l=()=>true}){let u=useRef(null),[d,v]=useState(""),[b,E]=useState(""),[g,f]=useState(""),[h,y]=useState(""),[T,k]=useState(""),[F,M]=useState(""),[A,Q]=useState(null),[le,ge]=useState(null),[L,O]=useState(null),S=!!o.isIframeEmbedSelected,x=!!o.isYouTubeEmbedSelected,D=l("iframeEmbed"),V=l("youTubeEmbed"),se=l("image"),Ce=D&&S||V&&x;if(useEffect(()=>{if(!e)return;let P=j=>{let de=j.target;de&&(u.current?.contains(de)||r?.());};return document.addEventListener("mousedown",P,true),document.addEventListener("touchstart",P,true),()=>{document.removeEventListener("mousedown",P,true),document.removeEventListener("touchstart",P,true);}},[e,r]),useEffect(()=>{if(!e||!S)return;let P=false;return typeof n.getIframeEmbedCaption=="function"&&n.getIframeEmbedCaption().then(j=>{P||E(j??"");}),typeof n.getIframeEmbedUrl=="function"&&n.getIframeEmbedUrl().then(j=>{P||v(j??"");}),Q(null),()=>{P=true;}},[n,S,e]),useEffect(()=>{if(!e||!o.imageSelected)return;let P=false;return typeof n.getImageCaption=="function"&&n.getImageCaption().then(j=>{P||f(j??"");}),()=>{P=true;}},[o.imageSelected,n,e]),useEffect(()=>{if(!e||!x)return;let P=false;return typeof n.getYouTubeEmbedCaption=="function"&&n.getYouTubeEmbedCaption().then(j=>{P||y(j??"");}),typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(j=>{P||k(j??"");}),ge(null),()=>{P=true;}},[n,e,x]),useEffect(()=>{if(!e||!o.isLink)return;let P=false;return typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(j=>{!P&&j&&M(j.url??"");}),O(null),()=>{P=true;}},[o.isLink,n,e]),!e||!t)return null;let pe={..._t(),position:"absolute",top:t.y,left:t.positionFromRight?"auto":t.x,right:t.positionFromRight?20:"auto",maxWidth:"calc(100% - 40px)",boxSizing:"border-box",zIndex:"var(--luthor-z-menu, 460)",pointerEvents:"auto"};if(Ce){let P=ee=>{if(S){n.setIframeEmbedAlignment?.(ee);return}x&&n.setYouTubeEmbedAlignment?.(ee);},j=S?o.isIframeEmbedAlignedLeft:o.isYouTubeEmbedAlignedLeft,de=S?o.isIframeEmbedAlignedCenter:o.isYouTubeEmbedAlignedCenter,ht=S?o.isIframeEmbedAlignedRight:o.isYouTubeEmbedAlignedRight,Ye=S?typeof n.setIframeEmbedCaption=="function":typeof n.setYouTubeEmbedCaption=="function",Ze=S?typeof n.updateIframeEmbedUrl=="function":typeof n.updateYouTubeEmbedUrl=="function",ve=S?b:h,Ee=S?E:y,it=S?d:T,te=S?A:le,Ae=()=>{if(Ye){if(S){n.setIframeEmbedCaption?.(b);return}n.setYouTubeEmbedCaption?.(h);}},Fe=ee=>{S?Q(ee):ge(ee);},Je=ee=>{S?v(ee):k(ee);},lt=()=>{if(!Ze)return;if(!(S?n.updateIframeEmbedUrl?.(d)??false:n.updateYouTubeEmbedUrl?.(T)??false)){Fe(S?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),S&&typeof n.getIframeEmbedUrl=="function"?n.getIframeEmbedUrl().then(Le=>v(Le??"")):!S&&typeof n.getYouTubeEmbedUrl=="function"&&n.getYouTubeEmbedUrl().then(Le=>k(Le??""));return}Fe(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:pe,children:[jsx(R,{onClick:()=>P("left"),active:j,title:"Align Left",children:jsx(Dt,{size:14})}),jsx(R,{onClick:()=>P("center"),active:de,title:"Align Center",children:jsx(Mt,{size:14})}),jsx(R,{onClick:()=>P("right"),active:ht,title:"Align Right",children:jsx(Bt,{size:14})}),Ye||Ze?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[Ze?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:it,className:`luthor-floating-toolbar-input${te?" is-error":""}`,placeholder:S?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":S?"Iframe URL":"YouTube URL","aria-invalid":te?true:void 0,onChange:ee=>{Je(ee.target.value),te&&Fe(null);},onBlur:lt,onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),lt());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:lt,children:"Update URL"})]}):null,Ye?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:ve,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":S?"Iframe caption":"YouTube caption",onChange:ee=>Ee(ee.target.value),onBlur:Ae,onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),Ae());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:Ae,children:"Update Caption"})]}):null]})]}):null]})}if(se&&o.imageSelected){let P=typeof n.setImageCaption=="function",j=()=>{P&&n.setImageCaption(g);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:pe,children:[jsx(R,{onClick:()=>n.setImageAlignment("left"),active:o.isImageAlignedLeft,title:"Align Left",children:jsx(Dt,{size:14})}),jsx(R,{onClick:()=>n.setImageAlignment("center"),active:o.isImageAlignedCenter,title:"Align Center",children:jsx(Mt,{size:14})}),jsx(R,{onClick:()=>n.setImageAlignment("right"),active:o.isImageAlignedRight,title:"Align Right",children:jsx(Bt,{size:14})}),P?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:g,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":"Image caption",onChange:de=>f(de.target.value),onBlur:j,onKeyDown:de=>{de.key==="Enter"&&(de.preventDefault(),j());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:j,children:"Update Caption"})]})]}):null]})}let X=l("bold"),Z=l("italic"),W=l("underline"),me=l("strikethrough"),N=l("codeFormat"),Ue=!!(o.unorderedList||o.orderedList||o.checkList),He=l("blockFormat")&&!Ue,be=l("link"),Qe=l("list")&&!Ue,$e=X||Z||W||me,xe=N||He||be,Ie=Qe,qe=!!o.isLink&&typeof n.updateLink=="function"&&typeof n.removeLink=="function",Re=()=>{if(!qe)return;if(!(n.updateLink?.(F)??false)){O("Enter a valid URL"),typeof n.getCurrentLink=="function"&&n.getCurrentLink().then(j=>{M(j?.url??"");});return}O(null);};return !$e&&!xe&&!Ie?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:pe,children:[$e?jsxs(Fragment,{children:[X?jsx(R,{onClick:()=>n.toggleBold(),active:o.bold,title:"Bold",children:jsx(yn,{size:14})}):null,Z?jsx(R,{onClick:()=>n.toggleItalic(),active:o.italic,title:"Italic",children:jsx(Cn,{size:14})}):null,W?jsx(R,{onClick:()=>n.toggleUnderline(),active:o.underline,title:"Underline",children:jsx(vn,{size:14})}):null,me?jsx(R,{onClick:()=>n.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(En,{size:14})}):null]}):null,$e&&xe?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,xe?jsxs(Fragment,{children:[N?jsx(R,{onClick:()=>n.formatText("code"),active:o.code,disabled:o.isInCodeBlock,title:"Inline Code",children:jsx(kn,{size:14})}):null,He?jsx(R,{onClick:()=>n.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(wn,{size:14})}):null,be?jsxs(Fragment,{children:[jsx(R,{onClick:()=>o.isLink?n.removeLink():n.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(Ft,{size:14}):jsx(zt,{size:14})}),qe?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:F,className:`luthor-floating-toolbar-input${L?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":L?true:void 0,onChange:P=>{M(P.target.value),L&&O(null);},onBlur:Re,onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),Re());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:Re,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>n.removeLink(),"aria-label":"Unlink",children:jsx(Ft,{size:13})})]}):null]}):null]}):null,($e||xe)&&Ie?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,Ie?jsxs(Fragment,{children:[jsx(R,{onClick:()=>n.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(Xt,{size:14})}),jsx(R,{onClick:()=>n.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(Zt,{size:14})}),jsx(R,{onClick:()=>n.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(Qt,{size:14})})]}):null]})}var ot={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function Qn(e,t,n,o=()=>true){ot.commands=e,ot.activeStates=t,ot.editorTheme=n,ot.isFeatureEnabled=o;}function mr(){let e=dr,t=new FloatingToolbarExtension;return t.config={...t.config,render:n=>createElement(e,{...n,commands:ot.commands,activeStates:ot.activeStates,editorTheme:ot.editorTheme,isFeatureEnabled:ot.isFeatureEnabled}),getCommands:()=>ot.commands,getActiveStates:()=>ot.activeStates},t}var rl=120,il=58;function ll(e,t=il){return e.length<=t?e:`${e.slice(0,t-3)}...`}function gr(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function fr(e,t){if(!(e instanceof Element))return null;let n=e.closest("a");return !(n instanceof HTMLAnchorElement)||!t.contains(n)?null:n}function br({editor:e,commands:t,editorTheme:n="light",disabled:o=false}){let i=useRef(null),r=useRef(null),l=useRef(null),s=useRef(null),[u,d]=useState(null),[v,b]=useState(false),[E,g]=useState(""),[f,h]=useState(null),[y,T]=useState(null),[k,F]=useState(null),M=useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]),A=useCallback(()=>{M(),d(null),b(false),g(""),h(null),T(null);},[M]),Q=useCallback(()=>{M(),s.current=window.setTimeout(()=>{A();},rl);},[M,A]),le=useCallback((x,D)=>{let V=x.getBoundingClientRect(),se=i.current?.getBoundingClientRect(),Ce=Se({anchorRect:V,overlay:{width:se?.width??340,height:se?.height??48},portalContainer:D,gap:8,margin:10,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});T({top:typeof Ce.top=="number"?Ce.top:0,left:typeof Ce.left=="number"?Ce.left:0});},[]),ge=useCallback((x,D)=>{if(typeof t.getLinkByKey!="function"){d(V=>!V||V.nodeKey!==x?V:{...V,url:D});return}t.getLinkByKey(x).then(V=>{if(!V){A();return}d(se=>!se||se.nodeKey!==x?se:{...se,url:V.url});});},[t,A]);useEffect(()=>{if(!e||o||typeof window>"u"){A(),F(null),r.current=null;return}let x=e.getRootElement();if(!x){A(),F(null),r.current=null;return}let D=x.closest(".luthor-editor-wrapper")??null;F(D),r.current=D;let V=Z=>{let W=fr(Z.target,x);if(!W)return;if(gr()){A();return}M();let me=resolveLinkNodeKeyFromAnchor(e,W);if(!me)return;let N=W.getAttribute("href")??W.href;d({nodeKey:me,url:N,anchorEl:W}),le(W,r.current),h(null),v||g(N),ge(me,N);},se=Z=>{if(!u)return;let W=Z.relatedTarget;W&&i.current?.contains(W)||fr(W,x)||Q();},Ce=()=>{gr()&&A();},pe=()=>{d(Z=>{if(!Z)return Z;let W=Z.anchorEl.isConnected&&x.contains(Z.anchorEl)?Z.anchorEl:x.querySelector(`a[data-lexical-node-key="${Z.nodeKey}"]`);return W?(le(W,r.current),{...Z,anchorEl:W,url:W.getAttribute("href")??W.href}):(A(),null)});},X=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,pe();}));};return x.addEventListener("mouseover",V),x.addEventListener("mouseout",se),document.addEventListener("selectionchange",Ce),window.addEventListener("scroll",X,true),window.addEventListener("resize",X),()=>{x.removeEventListener("mouseover",V),x.removeEventListener("mouseout",se),document.removeEventListener("selectionchange",Ce),window.removeEventListener("scroll",X,true),window.removeEventListener("resize",X),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),M();}},[t,o,e,u,v,A,Q,ge,le,M]),useLayoutEffect(()=>{u&&le(u.anchorEl,r.current);},[u,v,le]);let L=useMemo(()=>{if(!(!u||!y))return {...je(u.anchorEl),position:k?"absolute":"fixed",top:y.top,left:y.left,zIndex:"var(--luthor-z-menu, 460)"}},[u,y,k]);if(!u||!y||typeof document>"u")return null;let O=()=>{(t.removeLinkByKey?.(u.nodeKey)??false)&&A();},S=()=>{let x=E.trim();if(!(t.updateLinkByKey?.(u.nodeKey,x)??false)){h("Enter a valid URL"),ge(u.nodeKey,u.url);return}d(V=>!V||V.nodeKey!==u.nodeKey?V:{...V,url:x}),h(null),b(false),queueMicrotask(()=>{ge(u.nodeKey,x);});};return createPortal(jsx("div",{ref:i,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":n,style:L,onMouseEnter:M,onMouseLeave:Q,children:v?jsxs(Fragment,{children:[jsx("input",{type:"url",value:E,className:`luthor-link-hover-bubble-input${f?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":f?true:void 0,onChange:x=>{g(x.target.value),f&&h(null);},onKeyDown:x=>{if(x.key==="Enter"){x.preventDefault(),S();return}x.key==="Escape"&&(x.preventDefault(),b(false),g(u.url),h(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:S,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{b(false),g(u.url),h(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:u.url,children:ll(u.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{g(u.url),b(true),h(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:O,"aria-label":"Unlink",children:jsx(Ft,{size:13})})]})}),k??document.body)}var sl=400,ul=14,cl=.6,Zn=2;function dl(e){return e?e.split(`
|
|
2
|
-
`):[""]}function eo(e){return Array.from({length:Math.max(1,e)},(t,n)=>`${n+1}`).join(`
|
|
3
|
-
`)}function to(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function ml(e){let n=(to(e.fontSize)||ul)*cl;if(typeof document>"u")return n;try{if(!document.body)return n;let o="0000000000",i=document.createElement("span");i.textContent=o,i.style.position="absolute",i.style.visibility="hidden",i.style.whiteSpace="pre",i.style.font=e.font,i.style.fontFamily=e.fontFamily,i.style.fontSize=e.fontSize,i.style.fontWeight=e.fontWeight,i.style.letterSpacing=e.letterSpacing,i.style.lineHeight=e.lineHeight,i.style.padding="0",i.style.border="0",i.style.margin="0",document.body.appendChild(i);let r=i.getBoundingClientRect().width;if(i.remove(),Number.isFinite(r)&&r>0)return r/o.length}catch{return n}return n}function gl(e){let t=window.getComputedStyle(e),n=to(t.paddingLeft)+to(t.paddingRight),o=Math.max(0,e.clientWidth-n);if(o<=0)return 0;let i=ml(t);return i<=0?0:Math.max(1,Math.floor(o/i))}function fl(e){let t=window.getComputedStyle(e),n=Number.parseInt(t.tabSize,10);return Number.isFinite(n)&&n>0?n:Zn}function hl(e,t,n){if(t<=0)return 1;let o=0;for(let i of e){if(i===" "){let r=o%n,l=r===0?n:n-r;o+=l;continue}o+=1;}return Math.max(1,Math.ceil(o/t))}function pl(e,t,n){if(t<=0)return eo(e.length);let o=[];for(let i=0;i<e.length;i+=1){o.push(`${i+1}`);let r=hl(e[i]??"",t,n);for(let l=1;l<r;l+=1)o.push("");}return o.join(`
|
|
4
|
-
`)}function Lr({mode:e,onModeChange:t,labels:n,availableModes:o,isConverting:i}){let r=h=>h==="visual"?"visual-editor":h,l=(o??[]).includes("visual-editor")?"visual-editor":"visual",s=h=>h==="visual-editor"?l:h,u=["visual-only","visual-editor","json","markdown","html"],d=o??["visual-only","visual-editor","json","markdown","html"],v=new Set(d.map(r)),b=u.filter(h=>v.has(h)),E=r(e),g=i?r(i):null,f={"visual-only":n?.["visual-only"]??"Visual Only","visual-editor":n?.["visual-editor"]??n?.visual??"Visual Editor",json:n?.json??"JSON",markdown:n?.markdown??"Markdown",html:n?.html??"HTML"};return jsx("div",{className:"luthor-mode-tabs",children:b.map(h=>jsxs("button",{className:`luthor-mode-tab ${E===h?"active":""}`,onClick:()=>t(s(h)),children:[f[h],g===h&&jsx("span",{className:"luthor-tab-converting-spinner"})]},h))})}function In({value:e,onChange:t,placeholder:n,className:o,wrap:i,showLineNumbers:r=true}){let l=useRef(null),s=useRef(null),u=(i??"off")!=="off",d=useMemo(()=>dl(e),[e]),v=d.length,[b,E]=useState(0),[g,f]=useState(Zn),h=useCallback(()=>{if(!r||!u){E(0),f(Zn);return}let k=l.current;if(!k)return;let F=gl(k),M=fl(k);E(A=>A===F?A:F),f(A=>A===M?A:M);},[u,r]),y=useMemo(()=>!u||b<=0?eo(v):pl(d,b,g),[u,v,d,b,g]),T=`luthor-source-view${o?` ${o}`:""}`;return useLayoutEffect(()=>{let k=l.current;if(!k)return;k.style.height="auto";let F=Math.max(0,k.offsetHeight-k.clientHeight),M=Math.max(k.scrollHeight+F+1,sl);k.style.height=`${M}px`;},[e]),useLayoutEffect(()=>{h();},[h,e]),useEffect(()=>{if(!r||!u)return;let k=l.current;if(!k||typeof ResizeObserver>"u")return;let F=new ResizeObserver(()=>{h();});return F.observe(k),()=>{F.disconnect();}},[u,h,r]),useEffect(()=>{if(!r)return;let k=l.current,F=s.current;if(!k||!F)return;let M=()=>{F.scrollTop=k.scrollTop;};return M(),k.addEventListener("scroll",M,{passive:true}),()=>{k.removeEventListener("scroll",M);}},[y,r]),r?jsxs("div",{className:"luthor-source-view-shell",style:{"--luthor-source-line-number-gutter-width":`${Math.max(2,String(v).length)}ch`},children:[jsx("div",{ref:s,className:"luthor-source-view-line-numbers","aria-hidden":"true",children:y}),jsx("textarea",{ref:l,className:`${T} luthor-source-view--with-line-numbers`,value:e,onChange:k=>t(k.target.value),placeholder:n,spellCheck:false,wrap:i??"off"})]}):jsx("textarea",{ref:l,className:T,value:e,onChange:k=>t(k.target.value),placeholder:n,spellCheck:false,wrap:i??"off"})}function Sr(e,t){let n=`luthor-preset-${e}`;return {placeholder:t,classNames:{container:`luthor-preset ${n} ${n}__container`,contentEditable:`luthor-content-editable ${n}__content`,placeholder:`luthor-placeholder ${n}__placeholder`}}}function Mn(e){return e.replace(/\r\n?/g,`
|
|
5
|
-
`)}function bl(e){return e.replace(/&#(9|10|13|32|160);/g,(t,n)=>{switch(n){case "9":return " ";case "10":return `
|
|
6
|
-
`;case "13":return "\r";case "32":return " ";case "160":return " ";default:return t}})}function yl(e,t){let n=t.replace(/([*~])/g,"\\$1"),o=e;return o=o.replace(new RegExp(`${n}(\\s+)([^\\n]+?)${n}`,"g"),(i,r,l)=>`${r}${t}${l}${t}`),o=o.replace(new RegExp(`${n}([^\\n]+?)(\\s+)${n}`,"g"),(i,r,l)=>`${t}${r}${t}${l}`),o}function Cl(e){return ["***","**","~~","*"].reduce((n,o)=>yl(n,o),e)}var vl=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),El=new Set(["pre","script","style","textarea"]),kl=new Set(["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","menu","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"]),Ll=1,On=3,wl=8;function Tr(e){return e.nodeType===Ll}function no(e){return e.nodeType===On&&(e.textContent??"").trim().length>0}function Fn(e){return e.tagName.toLowerCase()}function xr(e){return Array.from(e.childNodes).filter(t=>t.nodeType!==On?true:no(t))}function Sl(e){let t=e.outerHTML,n=t.indexOf(">");return n===-1?`<${Fn(e)}>`:t.slice(0,n+1)}function Tl(e){let t=Fn(e);if(vl.has(t)||El.has(t))return false;let n=xr(e);if(n.length===0||n.some(no))return false;let o=n.filter(Tr);return o.length===0?false:o.every(i=>kl.has(Fn(i)))}function Ir(e,t){let n=" ".repeat(Math.max(t,0));if(e.nodeType===wl)return `${n}<!--${e.data}-->`;if(e.nodeType===On){let r=Mn(e.textContent??"");return r.trim()?`${n}${r.trim()}`:null}if(!Tr(e))return null;if(!Tl(e))return `${n}${e.outerHTML}`;let o=Fn(e),i=[`${n}${Sl(e)}`];for(let r of xr(e)){let l=Ir(r,t+1);l&&i.push(l);}return i.push(`${n}</${o}>`),i.join(`
|
|
7
|
-
`)}function xl(e){if(typeof DOMParser>"u")return e;let t=new DOMParser().parseFromString(e,"text/html"),o=Array.from(t.body.childNodes).filter(i=>i.nodeType!==On?true:no(i)).map(i=>Ir(i,0)).filter(i=>typeof i=="string"&&i.length>0);return o.length===0?t.body.innerHTML.trim()||e:o.join(`
|
|
8
|
-
`)}function Fr(e){let t=Mn(e).trim();if(!t)return "";try{let n=JSON.parse(t);return JSON.stringify(n,null,2)}catch{return t}}function Mr(e){return Cl(bl(Mn(e))).trim()}function Or(e){let t=Mn(e).trim();if(!t)return "";try{return xl(t)}catch{return t}}var ro=6,Ol=["#ffffff","#f2f2f2","#d9d9d9","#bfbfbf","#808080","#404040","#000000","#fbe5d6","#f8cbad","#f4b183","#ed7d31","#c55a11","#fff2cc","#ffe699","#ffd966","#ffc000","#bf9000","#7f6000","#e2f0d9","#c6e0b4","#a9d18e","#70ad47","#548235","#375623","#ddebf7","#bdd7ee","#9dc3e6","#5b9bd5","#2f75b5","#1f4e78","#e4dfec","#d9c2e9","#b4a7d6","#8e7cc3","#674ea7","#351c75"],Nl=[{title:"1. a. i. style",pattern:"decimal-alpha-roman"},{title:"A. a. i. style",pattern:"upper-alpha-lower-alpha"},{title:"1. 1.1 1.2 style",pattern:"decimal-hierarchical"},{title:"I. A. 1. style",pattern:"upper-roman-upper-alpha"}],Hl=[{title:"Dot / Circle / Square",pattern:"disc-circle-square"},{title:"Arrow / Diamond / Dot",pattern:"arrow-diamond-disc"},{title:"Square / Square / Square",pattern:"square-square-square"},{title:"Arrow / Circle / Square",pattern:"arrow-circle-square"}];function Rl(e){switch(e){case "disc-circle-square":return ["disc","circle","square"];case "arrow-diamond-disc":return ["arrow","diamond","disc"];case "square-square-square":return ["square","square","square"];case "arrow-circle-square":return ["arrow","circle","square"]}}function Al({type:e,cy:t}){switch(e){case "disc":return jsx("circle",{cx:"16",cy:t,r:"3.2",className:"luthor-unordered-variant-marker"});case "circle":return jsx("circle",{cx:"16",cy:t,r:"3.2",className:"luthor-unordered-variant-marker-open"});case "square":return jsx("rect",{x:"12.8",y:t-3.2,width:"6.4",height:"6.4",className:"luthor-unordered-variant-marker"});case "diamond":return jsx("path",{d:`M16 ${t-3.8} L19.8 ${t} L16 ${t+3.8} L12.2 ${t} Z`,className:"luthor-unordered-variant-marker"});case "arrow":return jsx("path",{d:`M11.6 ${t-2.8} L16.8 ${t} L11.6 ${t+2.8} M11.6 ${t} H19.6`,className:"luthor-unordered-variant-arrow"})}}function Pl({pattern:e}){let t=Rl(e),n=[12.5,24.5,36.5,48.5,60.5],o=e==="disc-circle-square"?[0,1,1,2,0]:e==="arrow-diamond-disc"?[0,1,1,2,0]:e==="square-square-square"?[0,1,2,1,0]:[0,1,1,2,0],i=[t[0],t[1],t[1],t[2],t[0]];return jsxs("svg",{width:"94",height:"74",viewBox:"0 0 94 74",role:"img","aria-hidden":"true",className:"luthor-unordered-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"93",height:"73",rx:"3",className:"luthor-unordered-variant-frame"}),n.map((r,l)=>{let s=o[l]??0,u=12+s*12,d=24+s*12,v=57-s*10;return jsxs("g",{children:[jsx("g",{transform:`translate(${u-16}, 0)`,children:jsx(Al,{type:i[l]??t[0],cy:r})}),jsx("rect",{x:d,y:r-2.5,width:v,height:"5",rx:"2.5",className:"luthor-unordered-variant-line"})]},`${e}-row-${l}`)})]})}function Hr({variant:e}){return jsxs("svg",{width:"78",height:"42",viewBox:"0 0 78 42",role:"img","aria-hidden":"true",className:"luthor-checklist-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"77",height:"41",rx:"3",className:"luthor-checklist-variant-frame"}),jsx("rect",{x:"10.5",y:"10.5",width:"10",height:"10",rx:"1.5",className:"luthor-checklist-variant-box"}),jsx("rect",{x:"10.5",y:"24.5",width:"10",height:"10",rx:"1.5",className:"luthor-checklist-variant-box"}),jsx("path",{d:"M12.6 29.2l2 2.2 3.8-4.3",className:"luthor-checklist-variant-check"}),jsx("rect",{x:"26.5",y:"11.8",width:"40",height:"6",rx:"2",className:"luthor-checklist-variant-line"}),jsx("rect",{x:"26.5",y:"25.8",width:"40",height:"6",rx:"2",className:"luthor-checklist-variant-line"}),e==="strikethrough"?jsx(Fragment,{children:jsx("line",{x1:"26.5",y1:"28.8",x2:"66.5",y2:"28.8",className:"luthor-checklist-variant-strike"})}):null]})}function zl({pattern:e}){let t=[12.5,24.5,36.5,48.5,60.5],n=[0,1,1,2,0],o=e==="decimal-alpha-roman"?["1.","a.","b.","i.","2."]:e==="upper-alpha-lower-alpha"?["A.","a.","b.","i.","B."]:e==="decimal-hierarchical"?["1.","1.1.","1.2.","1.2.1.","2."]:["I.","A.","B.","1.","II."];return jsxs("svg",{width:"94",height:"74",viewBox:"0 0 94 74",role:"img","aria-hidden":"true",className:"luthor-ordered-variant-svg",children:[jsx("rect",{x:"0.5",y:"0.5",width:"93",height:"73",rx:"3",className:"luthor-ordered-variant-frame"}),t.map((i,r)=>{let l=n[r]??0,s=9+l*12,u=26+l*12,d=56-l*10;return jsxs("g",{children:[jsx("text",{x:s,y:i+2.8,className:"luthor-ordered-variant-label",children:o[r]}),jsx("rect",{x:u,y:i-2.5,width:d,height:"5",rx:"2.5",className:"luthor-ordered-variant-line"})]},`${e}-ordered-row-${r}`)})]})}function Hn(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Dl(e,t){let n=Hn(t);for(let o of e)if(Hn(o.value)===n)return o.color;return null}function Bl(e,t,n){if(!e||e==="default")return n;let o=Dl(t,e);return o||e}function Ul(e,t){let n=e.trim();return /^#([\da-f]{6})$/i.test(n)?n:/^#([\da-f]{3})$/i.test(n)?`#${n.slice(1).split("").map(i=>`${i}${i}`).join("")}`:t}var io="Inherited",Nn="16px",lo="1.5";function Te(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Rr(e){let t=e.split(",")[0]??"";return Te(t.replace(/["']/g,""))}function Rn(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function Ht(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let n=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!n||!n.closest(".luthor-content-editable"))return null;let i=window.getComputedStyle(n);return {fontFamily:i.fontFamily,fontSize:i.fontSize,lineHeight:i.lineHeight}}function oo(){if(typeof window>"u"||typeof document>"u")return null;let e=document.querySelector(".luthor-content-editable");if(!(e instanceof HTMLElement))return null;let t=window.getComputedStyle(e);return {fontFamily:t.fontFamily,fontSize:t.fontSize,lineHeight:t.lineHeight}}function Ar(e){return (e.split(",")[0]?.trim()??"").replace(/^['"]|['"]$/g,"").trim()}function Kl(e,t){let n=Te(e);if(n&&n!=="inherit"){let i=Ar(e);if(i)return i}return Ar(t?.fontFamily??"")||io}function _l(e,t){let n=Te(e);return n&&n!=="inherit"?e.trim():(t?.fontSize??"").trim()||Nn}function Vl(e,t){let n=Te(e);return n&&n!=="normal"?e.trim():(t?.lineHeight??"").trim()||lo}function jl(e,t){if(!e)return null;let n=Rr(e);return n?t.find(i=>Te(i.value)===n?true:Rr(i.fontFamily)===n)?.value??null:null}function $l(e,t){if(!e)return null;let n=Te(e),o=t.find(l=>Te(String(l.value))===n?true:Te(String(l.fontSize))===n);if(o)return String(o.value);let i=Rn(e);if(i==null)return null;let r=null;for(let l of t){let s=Rn(String(l.fontSize));if(s==null)continue;let u=Math.abs(s-i);(!r||u<r.distance)&&(r={value:String(l.value),distance:u});}return r?.value??null}function ql(e,t,n){if(!e)return null;let o=Te(e),i=n.find(d=>Te(d.value)===o?true:Te(d.lineHeight)===o);if(i)return i.value;let r=t?Rn(t):null,l=Rn(e),s=null;if(l!=null&&r!=null&&r>0)s=l/r;else {let d=Number(e);Number.isFinite(d)&&(s=d);}if(s==null)return null;let u=null;for(let d of n){let v=Number(d.lineHeight);if(!Number.isFinite(v))continue;let b=Math.abs(v-s);(!u||b<u.distance)&&(u={value:d.value,distance:b});}return u?.value??null}function Pr({title:e,value:t,options:n,recentColors:o,active:i,fallbackColor:r,highlight:l,onChange:s,onClear:u,onAddRecent:d}){let v=useRef(null),b=useRef(null),E=useRef(null),g=useRef(null),f=useRef(null),[h,y]=useState(false),[T,k]=useState(void 0),[F,M]=useState(null),A=Bl(t,n,r),Q=useMemo(()=>Ol,[]),le=useMemo(()=>{let O=[...o].slice(0,ro);for(;O.length<ro;)O.push("");return O},[o]);useEffect(()=>()=>{g.current&&window.cancelAnimationFrame(g.current);},[]);let ge=useCallback(O=>{f.current=O,!g.current&&(g.current=window.requestAnimationFrame(()=>{g.current=null,f.current&&(s(f.current),f.current=null);}));},[s]),L=useCallback(O=>{let S=v.current;if(!S)return;let x=S.getBoundingClientRect(),D=b.current?.getBoundingClientRect(),V=Ot(S);M(V);let se=Se({anchorRect:x,overlay:{width:D?.width??248,height:D?.height??340},portalContainer:V,gap:6,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});k({...se,visibility:O?"visible":"hidden",...je(S)});},[]);return useLayoutEffect(()=>{if(!h)return;L(false);let O=window.requestAnimationFrame(()=>{L(true);});return ()=>{window.cancelAnimationFrame(O);}},[h,L]),useEffect(()=>{if(!h)return;let O=D=>{let V=D.target;v.current?.contains(V)||b.current?.contains(V)||y(false);},S=D=>{D.key==="Escape"&&y(false);},x=()=>L(true);return window.addEventListener("resize",x),window.addEventListener("scroll",x,true),document.addEventListener("mousedown",O),document.addEventListener("keydown",S),()=>{window.removeEventListener("resize",x),window.removeEventListener("scroll",x,true),document.removeEventListener("mousedown",O),document.removeEventListener("keydown",S),M(null);}},[h,L]),jsxs(Fragment,{children:[jsxs("button",{ref:v,type:"button",className:`luthor-toolbar-button luthor-color-button${i?" active":""}${l?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>y(O=>!O),children:[l?jsx(Uo,{size:15,className:"luthor-color-button-highlighter"}):jsx("span",{className:"luthor-color-button-letter",children:"A"}),jsx("span",{className:"luthor-color-button-indicator",style:{backgroundColor:A}})]}),h&&typeof document<"u"&&createPortal(jsxs("div",{ref:b,className:"luthor-color-picker",style:T,children:[jsx("div",{className:"luthor-color-picker-header",children:jsx("span",{className:"luthor-color-picker-title",children:e})}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Colors"}),jsx("div",{className:"luthor-color-swatch-grid",children:Q.map(O=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:O},"aria-label":`Use color ${O}`,onClick:()=>{s(O),d(O),y(false);}},O))})]}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Recent colors"}),jsx("div",{className:"luthor-color-swatch-row",children:le.map((O,S)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:O||"transparent"},"aria-label":O?`Use recent color ${O}`:"Empty recent color slot",disabled:!O,onClick:()=>{O&&(s(O),d(O),y(false));}},`${O||"empty"}-${S}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{u(),y(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>E.current?.click(),children:[jsx(Ko,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:E,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Ul(A,r),onInput:O=>{ge(O.target.value);},onChange:O=>{let S=O.target.value;s(S),d(S);}})]})]}),F??document.body)]})}function Yl(e,t){let n=useRef(null),o=useRef(null);return {handlers:useMemo(()=>({insertFromUrl:()=>{let r=prompt("Enter image URL:");if(!r)return;let l=prompt("Enter alt text:")||"",s=prompt("Enter caption (optional):")||void 0;e.insertImage({src:r,alt:l,caption:s});},insertFromFile:()=>n.current?.click(),insertGifFromUrl:()=>{let r=prompt("Enter GIF URL:");if(!r)return;let l=prompt("Enter alt text (optional):")||"GIF";e.insertImage({src:r,alt:l});},insertGifFromFile:()=>o.current?.click(),handleUpload:async r=>{let l=r.target.files?.[0];if(!l)return;let s;if(t)try{s=await t(l);}catch{alert("Failed to upload image");return}else s=URL.createObjectURL(l);e.insertImage({src:s,alt:l.name,file:l}),r.target.value="";},handleGifUpload:async r=>{let l=r.target.files?.[0];if(!l)return;if(!(l.type==="image/gif"||l.name.toLowerCase().endsWith(".gif"))){alert("Please select a GIF file."),r.target.value="";return}let u;if(t)try{u=await t(l);}catch{alert("Failed to upload GIF");return}else u=URL.createObjectURL(l);e.insertImage({src:u,alt:l.name||"GIF",file:l}),r.target.value="";},setAlignment:r=>{e.setImageAlignment(r);},setCaption:()=>{let r=prompt("Enter caption:")||"";e.setImageCaption(r);}}),[e,t]),fileInputRef:n,gifInputRef:o}}function Jl(e){return useMemo(()=>({insertIframe:()=>{let t=prompt("Enter iframe URL:");t&&typeof e.insertIframeEmbed=="function"&&e.insertIframeEmbed(t);},insertYouTube:()=>{let t=prompt("Enter YouTube URL:");t&&typeof e.insertYouTubeEmbed=="function"&&e.insertYouTubeEmbed(t);}}),[e])}function Gl(e,t){switch(e){case "fontFamily":return t("fontFamily");case "fontSize":return t("fontSize");case "lineHeight":return t("lineHeight");case "textColor":return t("textColor");case "textHighlight":return t("textHighlight");case "subscript":return t("subscript");case "superscript":return t("superscript");case "blockFormat":case "quote":case "alignLeft":case "alignCenter":case "alignRight":case "alignJustify":return t("blockFormat");case "codeBlock":return t("code");case "unorderedList":case "orderedList":case "checkList":case "indentList":case "outdentList":return t("list");case "horizontalRule":return t("horizontalRule");case "table":return t("table");case "image":return t("image");case "emoji":return t("emoji");case "embed":return t("iframeEmbed")||t("youtubeEmbed");case "undo":case "redo":return t("history");default:return true}}function Wl(e,t,n){return Gl(e,t)?n?.[e]!==false:false}function Xl(e,t,n){return {sections:e.sections.map(o=>({...o,items:o.items.filter(i=>Wl(i,t,n))})).filter(o=>o.items.length>0)}}function zr({commands:e,hasExtension:t,activeStates:n,isDark:o,toggleTheme:i,onCommandPaletteOpen:r,imageUploadHandler:l,classNames:s,toolbarStyleVars:u,layout:d,toolbarVisibility:v,headingOptions:b,paragraphLabel:E,isListStyleDropdownEnabled:g=true}){let{handlers:f,fileInputRef:h,gifInputRef:y}=Yl(e,l),T=Jl(e),k=t("iframeEmbed")||t("youtubeEmbed"),F=n.isIframeEmbedSelected||n.isYouTubeEmbedSelected,[M,A]=useState(false),[Q,le]=useState(false),[ge,L]=useState(false),[O,S]=useState(false),[x,D]=useState(false),[V,se]=useState(false),[Ce,pe]=useState(false),[X,Z]=useState(false),[W,me]=useState("default"),[N,Ue]=useState([{value:"default",label:io}]),[He,be]=useState("default"),[Qe,$e]=useState([{value:"default",label:Nn}]),[xe,Ie]=useState("default"),[qe,Re]=useState([{value:"default",label:lo}]),[P,j]=useState("default"),[de,ht]=useState([{value:"default",label:"Default",color:"inherit"}]),[Ye,Ze]=useState([]),[ve,Ee]=useState("default"),[it,te]=useState([{value:"default",label:"Default",color:"transparent"}]),[Ae,Fe]=useState([]),[Je,lt]=useState(0),[ke,ee]=useState({rows:3,columns:3,includeHeaders:false}),Le=useRef(null),at=useRef("");useEffect(()=>{if(typeof document>"u")return;let C=()=>{Le.current===null&&(Le.current=window.requestAnimationFrame(()=>{Le.current=null;let p=window.getSelection();if(!p||p.rangeCount===0||!p.getRangeAt(0).collapsed)return;let B=Ht();if(!B)return;let K=`${B.fontFamily}|${B.fontSize}|${B.lineHeight}`;K!==at.current&&(at.current=K,lt(J=>J+1));}));};return document.addEventListener("selectionchange",C),()=>{document.removeEventListener("selectionchange",C),Le.current!==null&&(cancelAnimationFrame(Le.current),Le.current=null);}},[]);let Ge=useMemo(()=>t("emoji")?typeof e.getEmojiSuggestions=="function"?e.getEmojiSuggestions(""):typeof e.getEmojiCatalog=="function"?e.getEmojiCatalog():[]:[],[e,t]);useEffect(()=>{if(!t("fontFamily")||typeof e.getFontFamilyOptions!="function")return;let C=Ht()??oo(),p=e.getFontFamilyOptions().map(K=>({value:K.value,label:Te(K.value)==="default"?Kl(K.fontFamily,C):K.label})),B=p.length>0?p:[{value:"default",label:io}];Ue(B),me(K=>B.some(J=>J.value===K)?K:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let C=e.getFontFamilyOptions;if(typeof C!="function")return;let p=false;return e.getCurrentFontFamily().then(B=>{if(p)return;if(B&&B!=="default"){me(B);return}let K=Ht(),J=jl(K?.fontFamily,C());me(J??"default");}),()=>{p=true;}},[n,e,t,Je]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let C=Ht()??oo(),p=e.getFontSizeOptions().map(J=>({value:String(J.value).trim(),label:Te(String(J.value))==="default"?_l(String(J.fontSize),C):String(J.label).trim()})).filter(J=>J.value.length>0&&J.label.length>0),B=p.some(J=>Te(J.value)==="default"),K=p.length===0?[{value:"default",label:Nn}]:B?p:[{value:"default",label:Nn},...p];$e(K),be(J=>K.some(ue=>ue.value===J)?J:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let C=e.getFontSizeOptions;if(typeof C!="function")return;let p=false;return e.getCurrentFontSize().then(B=>{if(p)return;if(B&&B!=="default"){be(B);return}let K=Ht(),J=$l(K?.fontSize,C());be(J??"default");}),()=>{p=true;}},[n,e,t,Je]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let C=Ht()??oo(),p=e.getLineHeightOptions().map(K=>({value:K.value,label:Te(K.value)==="default"?Vl(K.lineHeight,C):K.label})),B=p.length>0?p:[{value:"default",label:lo}];Re(B);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let C=e.getLineHeightOptions;if(typeof C!="function")return;let p=false;return e.getCurrentLineHeight().then(B=>{if(p)return;if(B){Ie(B);return}let K=Ht(),J=ql(K?.lineHeight,K?.fontSize,C());Ie(J??"default");}),()=>{p=true;}},[n,e,t,Je]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let C=e.getTextColorOptions().map(p=>({value:p.value,label:p.label,color:p.color}));C.length>0&&ht(C);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let C=false;return e.getCurrentTextColor().then(p=>{C||j(p??"default");}),()=>{C=true;}},[n,e,t,Je]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let C=e.getTextHighlightOptions().map(p=>({value:p.value,label:p.label,color:p.backgroundColor}));C.length>0&&te(C);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let C=false;return e.getCurrentTextHighlight().then(p=>{C||Ee(p??"default");}),()=>{C=true;}},[n,e,t,Je]);let st=useMemo(()=>{if(!b||b.length===0)return [...Ve];let C=new Set,p=[];for(let B of b)!Ve.includes(B)||C.has(B)||(C.add(B),p.push(B));return p.length>0?p:[...Ve]},[b]),Lt=E?.trim()||"Paragraph",et=useMemo(()=>{let C=st.map(p=>({value:p,label:`Heading ${p.slice(1)}`}));return [{value:"p",label:Lt},...C]},[st,Lt]),pt=n.isH1?"h1":n.isH2?"h2":n.isH3?"h3":n.isH4?"h4":n.isH5?"h5":n.isH6?"h6":"p",Ke=et.some(C=>C.value===pt)?pt:"p",We=C=>{C==="p"?e.toggleParagraph():C.startsWith("h")&&st.includes(C)&&e.toggleHeading(C);},fe=C=>{C==="default"?e.clearFontFamily?.():e.setFontFamily?.(C),me(C);},Me=C=>{C==="default"?e.clearFontSize?.():e.setFontSize?.(C),be(C);},wt=C=>{e.setLineHeight?.(C),Ie(C);},_e=(C,p)=>{C(B=>{let K=Hn(p),J=B.filter(ue=>Hn(ue)!==K);return [p,...J].slice(0,ro)});},St=C=>{if(C==="default"){e.clearTextColor?.(),j("default");return}e.setTextColor?.(C),j(C);},tt=C=>{if(C==="default"){e.clearTextHighlight?.(),Ee("default");return}e.setTextHighlight?.(C),Ee(C);},Tt=C=>{if(typeof e.setOrderedListPattern=="function"){e.setOrderedListPattern(C);return}e.toggleOrderedList();},xt=C=>{if(typeof e.setUnorderedListPattern=="function"){e.setUnorderedListPattern(C);return}e.toggleUnorderedList();},bt=C=>{if(typeof e.setCheckListVariant=="function"){e.setCheckListVariant(C);return}e.toggleCheckList();},ut=C=>{switch(C){case "fontFamily":return t("fontFamily")?jsx(rn,{value:W,onValueChange:fe,options:N,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(rn,{value:He,onValueChange:Me,options:Qe,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(rn,{value:xe,onValueChange:wt,options:qe,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(Pr,{title:"Text Color",value:P,options:de,recentColors:Ye,active:n.hasCustomTextColor,fallbackColor:"#0f172a",onChange:St,onClear:()=>St("default"),onAddRecent:p=>_e(Ze,p)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(Pr,{title:"Text Highlight",value:ve,options:it,recentColors:Ae,active:n.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:tt,onClear:()=>tt("default"),onAddRecent:p=>_e(Fe,p)},"textHighlight"):null;case "bold":return jsx(R,{onClick:()=>e.toggleBold(),active:n.bold,title:"Bold (Ctrl+B)",children:jsx(yn,{size:16})},"bold");case "italic":return jsx(R,{onClick:()=>e.toggleItalic(),active:n.italic,title:"Italic (Ctrl+I)",children:jsx(Cn,{size:16})},"italic");case "underline":return jsx(R,{onClick:()=>e.toggleUnderline(),active:n.underline,title:"Underline (Ctrl+U)",children:jsx(vn,{size:16})},"underline");case "strikethrough":return jsx(R,{onClick:()=>e.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(En,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(R,{onClick:()=>e.toggleSubscript?.(),active:n.subscript,title:"Subscript",children:jsx(Jo,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(R,{onClick:()=>e.toggleSuperscript?.(),active:n.superscript,title:"Superscript",children:jsx(Go,{size:16})},"superscript"):null;case "code":return jsx(R,{onClick:()=>e.formatText("code"),active:n.code,disabled:n.isInCodeBlock,title:"Inline Code",children:jsx(kn,{size:16})},"code");case "link":return jsx(R,{onClick:()=>n.isLink?e.removeLink():e.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(Ft,{size:16}):jsx(zt,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(rn,{value:Ke,onValueChange:We,options:et,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(R,{onClick:()=>e.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(wn,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("left"),active:n.isTextAlignedLeft,title:"Align Left",children:jsx(Dt,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("center"),active:n.isTextAlignedCenter,title:"Align Center",children:jsx(Mt,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("right"),active:n.isTextAlignedRight,title:"Align Right",children:jsx(Bt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("justify"),active:n.isTextAlignedJustify,title:"Justify",children:jsx(Po,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(R,{onClick:()=>e.toggleCodeBlock(),active:n.isInCodeBlock,title:"Code Block",children:jsx(Ho,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?g?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(Xt,{size:16})}),jsx(Ct,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${n.unorderedList?" active":""}`,title:"Bullet List Styles","aria-label":"Bullet List Styles",children:jsx(Ut,{size:12})}),isOpen:x,onOpenChange:D,children:jsx("div",{className:"luthor-unordered-variant-grid",children:Hl.map(p=>jsx("button",{className:"luthor-unordered-variant-option",type:"button",title:p.title,"aria-label":p.title,onClick:()=>{xt(p.pattern),D(false);},children:jsx(Pl,{pattern:p.pattern})},p.pattern))})})]},"unorderedList"):jsx(R,{onClick:()=>e.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(Xt,{size:16})},"unorderedList"):null;case "orderedList":return t("list")?g?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(Zt,{size:16})}),jsx(Ct,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${n.orderedList?" active":""}`,title:"Numbered List Styles","aria-label":"Numbered List Styles",children:jsx(Ut,{size:12})}),isOpen:V,onOpenChange:se,children:jsx("div",{className:"luthor-ordered-variant-grid",children:Nl.map(p=>jsx("button",{className:"luthor-ordered-variant-option",type:"button",title:p.title,"aria-label":p.title,onClick:()=>{Tt(p.pattern),se(false);},children:jsx(zl,{pattern:p.pattern})},p.pattern))})})]},"orderedList"):jsx(R,{onClick:()=>e.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(Zt,{size:16})},"orderedList"):null;case "checkList":return t("list")?g?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(Qt,{size:16})}),jsx(Ct,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${n.checkList?" active":""}`,title:"Checklist Styles","aria-label":"Checklist Styles",children:jsx(Ut,{size:12})}),isOpen:Ce,onOpenChange:pe,children:jsxs("div",{className:"luthor-checklist-variant-grid",children:[jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Strike through","aria-label":"Checked = Strike through",onClick:()=>{bt("strikethrough"),pe(false);},children:jsx(Hr,{variant:"strikethrough"})}),jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Keep text","aria-label":"Checked = Keep text",onClick:()=>{bt("plain"),pe(false);},children:jsx(Hr,{variant:"plain"})})]})})]},"checkList"):jsx(R,{onClick:()=>e.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(Qt,{size:16})},"checkList"):null;case "indentList":return t("list")?jsx(R,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(Vo,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(R,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(jo,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(R,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(zo,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(R,{onClick:()=>Z(true),title:"Insert Table",children:jsx(Do,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(Ct,{trigger:jsx("button",{className:`luthor-toolbar-button ${n.imageSelected?"active":""}`,title:"Insert Image",children:jsx($n,{size:16})}),isOpen:M,onOpenChange:A,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromUrl(),A(false);},children:[jsx(zt,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromFile(),A(false);},children:[jsx(qn,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromUrl(),A(false);},children:[jsx(Yn,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromFile(),A(false);},children:[jsx(qn,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),n.imageSelected&&jsxs(Ct,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(Mt,{size:16})}),isOpen:ge,onOpenChange:L,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("left"),L(false);},children:[jsx(Dt,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("center"),L(false);},children:[jsx(Mt,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("right"),L(false);},children:[jsx(Bt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setCaption(),L(false);},children:[jsx(_o,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||Ge.length===0?null:jsx(Ct,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Yn,{size:16})}),isOpen:Q,onOpenChange:le,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:Ge.map(p=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:p.shortcodes[0]?`${p.label} (:${p.shortcodes[0]}:)`:p.label,onClick:()=>{e.insertEmoji?.(p.emoji),le(false);},children:p.emoji},`${p.emoji}-${p.label}`))})},"emoji");case "embed":return k?jsxs(Ct,{trigger:jsx("button",{className:`luthor-toolbar-button ${F?"active":""}`,title:"Insert Embed",children:jsx(Bo,{size:16})}),isOpen:O,onOpenChange:S,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{T.insertIframe(),S(false);},children:[jsx(zt,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{T.insertYouTube(),S(false);},children:[jsx($n,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(R,{onClick:()=>e.undo(),disabled:!n.canUndo,title:"Undo (Ctrl+Z)",children:jsx(Ro,{size:16})},"undo"):null;case "redo":return t("history")?jsx(R,{onClick:()=>e.redo(),disabled:!n.canRedo,title:"Redo (Ctrl+Y)",children:jsx(Ao,{size:16})},"redo"):null;case "commandPalette":return jsx(R,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(Ln,{size:16})},"commandPalette");case "themeToggle":return jsx(R,{onClick:i,title:o?"Light Mode":"Dark Mode",children:o?jsx($o,{size:16}):jsx(qo,{size:16})},"themeToggle");default:return null}},nt=d??pn,ct=useMemo(()=>Xl(nt,t,v),[nt,t,v]);return jsxs(Fragment,{children:[jsx("div",{className:s?.toolbar??"luthor-toolbar",style:u,children:ct.sections.map((C,p)=>{let B=C.items.map((K,J)=>{let ue=ut(K);return ue?Array.isArray(ue)?ue.map((ye,yt)=>ye&&typeof ye=="object"&&"key"in ye&&ye.key!=null?ye:jsx("span",{children:ye},`toolbar-item-${p}-${J}-${yt}`)):ue.type===Il.Fragment?jsx("span",{children:ue},`toolbar-item-${p}-${J}`):ue&&typeof ue=="object"&&"key"in ue&&ue.key!=null?ue:jsx("span",{children:ue},`toolbar-item-${p}-${J}`):null}).flat().filter(K=>K!==null);return B.length===0?null:jsx("div",{className:s?.section??"luthor-toolbar-section",children:B},p)})}),jsx("input",{ref:h,type:"file",accept:"image/*",onChange:f.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:y,type:"file",accept:"image/gif",onChange:f.handleGifUpload,className:"luthor-file-input"}),jsx(cr,{isOpen:X,onClose:()=>Z(false),title:"Insert Table",children:jsxs("div",{className:"luthor-table-dialog",children:[jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-rows",children:"Rows:"}),jsx("input",{id:"table-rows",type:"number",min:"1",max:"20",value:ke.rows,onChange:C=>ee(p=>({...p,rows:parseInt(C.target.value)||1})),className:"luthor-input"})]}),jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-columns",children:"Columns:"}),jsx("input",{id:"table-columns",type:"number",min:"1",max:"20",value:ke.columns,onChange:C=>ee(p=>({...p,columns:parseInt(C.target.value)||1})),className:"luthor-input"})]}),jsx("div",{className:"luthor-form-group",children:jsxs("label",{className:"luthor-checkbox-label",children:[jsx("input",{type:"checkbox",checked:ke.includeHeaders||false,onChange:C=>ee(p=>({...p,includeHeaders:C.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(Xn,{variant:"secondary",onClick:()=>Z(false),children:"Cancel"}),jsx(Xn,{variant:"primary",onClick:()=>{e.insertTable(ke),Z(false);},children:"Insert Table"})]})]})})]})}var fo=["bold","italic","underline","strikethrough","fontFamily","fontSize","lineHeight","textColor","textHighlight","subscript","superscript","link","horizontalRule","table","list","history","image","blockFormat","code","codeIntelligence","codeFormat","tabIndent","enterKeyBehavior","iframeEmbed","youTubeEmbed","floatingToolbar","contextMenu","commandPalette","slashCommand","emoji","draggableBlock","customNode","themeToggle"],jr={bold:true,italic:true,underline:true,strikethrough:true,fontFamily:true,fontSize:true,lineHeight:true,textColor:true,textHighlight:true,subscript:true,superscript:true,link:true,horizontalRule:true,table:true,list:true,history:true,image:true,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:true,youTubeEmbed:true,floatingToolbar:true,contextMenu:true,commandPalette:true,slashCommand:true,emoji:true,draggableBlock:true,customNode:true,themeToggle:true};function cn(e){let t={...jr};if(!e)return t;for(let n of fo)typeof e[n]=="boolean"&&(t[n]=e[n]);return t}function $r(e,t){return e[t]!==false}var Ur=8,Kr=[{value:"default",label:"Default",fontFamily:"inherit"},{value:"inter",label:"Inter",fontFamily:"'Inter', 'Segoe UI', Arial, sans-serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"},{value:"merriweather",label:"Merriweather",fontFamily:"'Merriweather', Georgia, 'Times New Roman', serif",cssImportUrl:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&display=swap"},{value:"jetbrains-mono",label:"JetBrains Mono",fontFamily:"'JetBrains Mono', 'Courier New', monospace",cssImportUrl:"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap"}],xa={value:"default",label:"Default",fontFamily:"inherit"},_r=[{value:"default",label:"Default",fontSize:"inherit"},{value:"12",label:"12px",fontSize:"12px"},{value:"14",label:"14px",fontSize:"14px"},{value:"16",label:"16px",fontSize:"16px"},{value:"18",label:"18px",fontSize:"18px"},{value:"20",label:"20px",fontSize:"20px"},{value:"24",label:"24px",fontSize:"24px"},{value:"32",label:"32px",fontSize:"32px"}],Ia={value:"default",label:"Default",fontSize:"inherit"},Vr=[{value:"default",label:"Default",lineHeight:"1.5"},{value:"1",label:"1.0",lineHeight:"1"},{value:"1.15",label:"1.15",lineHeight:"1.15"},{value:"1.5",label:"1.5",lineHeight:"1.5"},{value:"1.75",label:"1.75",lineHeight:"1.75"},{value:"2",label:"2.0",lineHeight:"2"}],Fa={value:"default",label:"Default",lineHeight:"1.5"},un="1.5",Ma=1;function Rt(e){return e.trim().toLowerCase()}function qr(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function Oa(e){return Rt(e)==="default"?true:Pn(e)!==null}function Na(e){let t=e??Kr,n=new Set,o=[];for(let r of t){let l=r.value.trim(),s=r.label.trim(),u=r.fontFamily.trim();if(!l||!s||!u||!qr(l))continue;let d=Rt(l);n.has(d)||(n.add(d),o.push({value:l,label:s,fontFamily:u,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return o.length===0?Kr:o.some(r=>Rt(r.value)==="default")?o:[xa,...o]}function Ha(e){let t=e??_r,n=new Set,o=[];for(let r of t){let l=String(r.value).trim(),s=String(r.label).trim(),u=String(r.fontSize).trim();if(!l||!s||!u||!qr(l))continue;let d=Rt(l);n.has(d)||(n.add(d),o.push({value:l,label:s,fontSize:u}));}return o.length===0?_r:o.some(r=>Rt(r.value)==="default")?o:[Ia,...o]}function Pn(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let n=Number(t);return !Number.isFinite(n)||n<Ma?null:n.toString()}function Ra(e){if(!Number.isFinite(e))return Ur;let t=Math.floor(e);return t>=0?t:Ur}function Aa(e){return typeof e=="number"?Number.isFinite(e)?Pn(e.toString())??un:un:typeof e=="string"?Pn(e)??un:un}function Pa(e,t=un){let n=e??Vr,o=new Set,i=[];for(let l of n){let s=String(l.value).trim(),u=String(l.label).trim();if(!s||!u||!Oa(s))continue;let d=Rt(s);if(o.has(d))continue;if(d==="default"){o.add(d),i.push({value:s,label:u,lineHeight:t});continue}let v=Pn(String(l.lineHeight));v&&(o.add(d),i.push({value:s,label:u,lineHeight:v}));}return i.length===0?Vr:i.some(l=>Rt(l.value)==="default")?i:[{...Fa,lineHeight:t},...i]}function kt({children:e}){return jsx("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e})}var za=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 14.5h3"}),jsx("path",{d:"M12 2.8v4.4"}),jsx("path",{d:"M9.8 5h4.4"})]}),Da=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M10.5 8.5h3"}),jsx("path",{d:"M12 16.8v4.4"}),jsx("path",{d:"M9.8 19h4.4"})]}),Ba=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M11.5 5v14"}),jsx("path",{d:"M7.5 10.5v3"}),jsx("path",{d:"M2.8 12h4.4"}),jsx("path",{d:"M5 9.8v4.4"})]}),Ua=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12.5 5v14"}),jsx("path",{d:"M16.5 10.5v3"}),jsx("path",{d:"M16.8 12h4.4"}),jsx("path",{d:"M19 9.8v4.4"})]}),Ka=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 11h17"}),jsx("path",{d:"M9.8 14.8l4.4 4.4"}),jsx("path",{d:"M14.2 14.8l-4.4 4.4"})]}),_a=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M12 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),Va=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M14.8 9.8l4.4 4.4"}),jsx("path",{d:"M19.2 9.8l-4.4 4.4"})]}),ja=()=>jsxs(kt,{children:[jsx("rect",{x:"3.5",y:"5",width:"17",height:"14",rx:"1.5"}),jsx("path",{d:"M3.5 10.5h17"}),jsx("path",{d:"M10.5 5v14"}),jsx("path",{d:"M3.5 8h17"})]}),zn=new ImageExtension;zn.config={...zn.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var ao=new TableExtension;ao.config={...ao.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:n})=>jsxs(Fragment,{children:[jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row above","aria-label":"Insert row above",onClick:n.insertRowAbove,children:jsx(za,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert row below","aria-label":"Insert row below",onClick:n.insertRowBelow,children:jsx(Da,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column left","aria-label":"Insert column left",onClick:n.insertColumnLeft,children:jsx(Ba,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Insert column right","aria-label":"Insert column right",onClick:n.insertColumnRight,children:jsx(Ua,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected row","aria-label":"Delete selected row",onClick:n.deleteSelectedRow,children:jsx(Ka,{})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon",title:"Delete selected column","aria-label":"Delete selected column",onClick:n.deleteSelectedColumn,children:jsx(_a,{})}),jsx("label",{className:"luthor-table-bubble-checkbox",title:"Use first row as table headers",children:jsx("button",{type:"button",className:`luthor-table-bubble-button luthor-table-bubble-button-icon${e?" luthor-table-bubble-button-active":""}`,title:"Use first row as table headers","aria-label":"Use first row as table headers","aria-pressed":e,onClick:()=>t(!e),children:jsx(ja,{})})}),jsx("button",{type:"button",className:"luthor-table-bubble-button luthor-table-bubble-button-icon luthor-table-bubble-button-danger",title:"Delete table","aria-label":"Delete table",onClick:n.deleteTable,children:jsx(Va,{})})]})};var so=new IframeEmbedExtension;so.config={...so.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var uo=new YouTubeEmbedExtension;uo.config={...uo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var $a=mr(),co=new ContextMenuExtension;co.config={...co.config,preventDefault:true};var qa=new CommandPaletteExtension,Ya=new SlashCommandExtension,Ja=new EmojiExtension,mo=new DraggableBlockExtension;mo.config={...mo.config,buttonStackPosition:"left"};var go=new LinkExtension;go.config={...go.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var Ga=textColorExtension.configure({options:[{value:"default",label:"Default",color:"inherit"},{value:"slate",label:"Slate",color:"#334155"},{value:"red",label:"Red",color:"#dc2626"},{value:"orange",label:"Orange",color:"#ea580c"},{value:"green",label:"Green",color:"#16a34a"},{value:"blue",label:"Blue",color:"#2563eb"},{value:"purple",label:"Purple",color:"#7c3aed"}]}),Wa=textHighlightExtension.configure({options:[{value:"default",label:"Default",backgroundColor:"transparent"},{value:"yellow",label:"Yellow",backgroundColor:"#fef08a"},{value:"green",label:"Green",backgroundColor:"#bbf7d0"},{value:"blue",label:"Blue",backgroundColor:"#bfdbfe"},{value:"pink",label:"Pink",backgroundColor:"#fbcfe8"},{value:"orange",label:"Orange",backgroundColor:"#fed7aa"}]}),{extension:Xa}=createCustomNodeExtension({nodeType:"featureCard",defaultPayload:{title:"AI Draft Block",description:"AI-generated first draft. Review and edit before publishing to customers.",tag:"AI Draft"},render:({payload:e,isSelected:t})=>jsxs("aside",{className:`luthor-extensive-feature-card${t?" is-selected":""}`,children:[jsx("div",{className:"luthor-extensive-feature-card__tag",children:e.tag??"AI Draft"}),jsx("h4",{className:"luthor-extensive-feature-card__title",children:e.title??"Generated Draft"}),jsx("p",{className:"luthor-extensive-feature-card__description",children:e.description??"AI-generated first pass. Review and finalize before sharing."})]})});function Yr({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:n,minimumDefaultLineHeight:o,featureFlags:i,isDraggableBoxEnabled:r,scaleByRatio:l,syntaxHighlighting:s,codeHighlightProvider:u,loadCodeHighlightProvider:d,maxAutoDetectCodeLength:v,isCopyAllowed:b,languageOptions:E,showLineNumbers:g,maxListIndentation:f}={}){let h=cn(i),y=O=>$r(h,O),T=(r??true)&&y("draggableBlock"),k=Aa(o),F=Ra(f),M=new FontFamilyExtension().configure({options:Na(e),cssLoadStrategy:"on-demand"}),A=new FontSizeExtension().configure({options:Ha(t)}),Q=new LineHeightExtension().configure({options:Pa(n,k),defaultLineHeight:k});zn.configure({scaleByRatio:l??false}),codeExtension.configure({syntaxHighlighting:s??"auto",provider:u??void 0,loadProvider:d,showLineNumbers:g??true}),codeIntelligenceExtension.configure({provider:u??void 0,loadProvider:d,maxAutoDetectLength:v,isCopyAllowed:b??true,languageOptions:E});let le=new ListExtension({maxDepth:F+1}),ge=new TabIndentExtension({maxListDepth:F+1}),L=[];return y("bold")&&L.push(boldExtension),y("italic")&&L.push(italicExtension),y("underline")&&L.push(underlineExtension),y("strikethrough")&&L.push(strikethroughExtension),y("fontFamily")&&L.push(M),y("fontSize")&&L.push(A),y("lineHeight")&&L.push(Q),y("textColor")&&L.push(Ga),y("textHighlight")&&L.push(Wa),y("subscript")&&L.push(subscriptExtension),y("superscript")&&L.push(superscriptExtension),y("link")&&L.push(go),y("horizontalRule")&&L.push(horizontalRuleExtension),y("table")&&L.push(ao),y("list")&&L.push(le),y("history")&&L.push(historyExtension),y("image")&&L.push(zn),y("blockFormat")&&L.push(blockFormatExtension),y("code")&&L.push(codeExtension),y("codeIntelligence")&&L.push(codeIntelligenceExtension),y("codeFormat")&&L.push(codeFormatExtension),y("tabIndent")&&L.push(ge),y("enterKeyBehavior")&&L.push(enterKeyBehaviorExtension),y("iframeEmbed")&&L.push(so),y("youTubeEmbed")&&L.push(uo),y("floatingToolbar")&&L.push($a),y("contextMenu")&&L.push(co),y("commandPalette")&&L.push(qa),y("slashCommand")&&L.push(Ya),y("emoji")&&L.push(Ja),T&&L.push(mo),y("customNode")&&L.push(Xa),L}function dn(e){return Yr(e)}var ho=Yr();function Jr(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,n])=>typeof n=="string"&&n.trim().length>0).sort(([n],[o])=>n.localeCompare(o));return t.length>0?JSON.stringify(t):"__default__"}function Gr(e){if(!e)return;let t={},n=(o,i)=>{typeof i=="string"&&i.trim().length>0&&(t[o]=i.trim());};return n("--luthor-fg",e.font?.color),n("--luthor-text-bold-color",e.font?.boldColor),n("--luthor-link-color",e.link?.color),n("--luthor-list-marker-color",e.list?.markerColor),n("--luthor-list-checkbox-color",e.list?.checkboxColor),n("--luthor-quote-bg",e.quote?.backgroundColor),n("--luthor-quote-fg",e.quote?.color),n("--luthor-quote-border",e.quote?.indicatorColor),n("--luthor-table-border-color",e.table?.borderColor),n("--luthor-table-header-bg",e.table?.headerBackgroundColor),n("--luthor-hr-color",e.hr?.color),n("--luthor-placeholder-color",e.placeholder?.color),n("--luthor-codeblock-bg",e.codeblock?.backgroundColor),n("--luthor-toolbar-bg",e.toolbar?.backgroundColor),Object.keys(t).length>0?t:void 0}function Wr(e){if(!(e instanceof Element))return false;if(e.closest('[contenteditable="true"]'))return true;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"}function Xr(e,t){if(e.key.toLowerCase()!==t.key.toLowerCase())return false;let n=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==n||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function Qr(e,t,n){let o={...e??{}};for(let[i,r]of Object.entries(n))(Array.isArray(r)?r:[r]).some(u=>t[u]!==false)||(o[i]=false);return o}function Zr(e,t,n){let o={...e},i=(r,l)=>{t[r]===false&&l();};return i("bold",()=>{o.toggleBold=()=>{};}),i("italic",()=>{o.toggleItalic=()=>{};}),i("underline",()=>{o.toggleUnderline=()=>{};}),i("strikethrough",()=>{o.toggleStrikethrough=()=>{};}),i("codeFormat",()=>{o.formatText=()=>{};}),i("fontFamily",()=>{o.setFontFamily=()=>{},o.clearFontFamily=()=>{};}),i("fontSize",()=>{o.setFontSize=()=>{},o.clearFontSize=()=>{};}),i("lineHeight",()=>{o.setLineHeight=()=>{},o.clearLineHeight=()=>{};}),i("textColor",()=>{o.setTextColor=()=>{},o.clearTextColor=()=>{};}),i("textHighlight",()=>{o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{};}),i("subscript",()=>{o.toggleSubscript=()=>{};}),i("superscript",()=>{o.toggleSuperscript=()=>{};}),i("link",()=>{o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.getCurrentLink=async()=>null,o.getLinkByKey=async()=>null,o.updateLinkByKey=()=>false,o.removeLinkByKey=()=>false;}),i("blockFormat",()=>{o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{};}),i("code",()=>{o.toggleCodeBlock=()=>{};}),i("codeIntelligence",()=>{o.setCodeLanguage=()=>{},o.autoDetectCodeLanguage=async()=>null,o.copySelectedCodeBlock=async()=>false;}),i("list",()=>{o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{};}),i("horizontalRule",()=>{o.insertHorizontalRule=()=>{};}),i("table",()=>{o.insertTable=()=>{};}),i("image",()=>{o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.getImageCaption=async()=>"";}),i("emoji",()=>{o.insertEmoji=()=>{},o.executeEmojiSuggestion=()=>false,o.closeEmojiSuggestions=()=>{},o.getEmojiSuggestions=()=>[],o.getEmojiCatalog=()=>[],o.resolveEmojiShortcode=()=>null,o.setEmojiCatalog=()=>{},o.setEmojiCatalogAdapter=()=>{},o.getEmojiCatalogAdapter=()=>({search:()=>[],resolveShortcode:()=>null,getAll:()=>[]});}),i("iframeEmbed",()=>{o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.getIframeEmbedCaption=async()=>"",o.updateIframeEmbedUrl=()=>false,o.getIframeEmbedUrl=async()=>"";}),i("youTubeEmbed",()=>{o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.getYouTubeEmbedCaption=async()=>"",o.updateYouTubeEmbedUrl=()=>false,o.getYouTubeEmbedUrl=async()=>"";}),i("history",()=>{o.undo=()=>{},o.redo=()=>{};}),i("commandPalette",()=>{o.showCommandPalette=()=>{},o.hideCommandPalette=()=>{},o.registerCommand=()=>{},o.unregisterCommand=()=>{};}),i("slashCommand",()=>{o.registerSlashCommand=()=>{},o.unregisterSlashCommand=()=>{},o.setSlashCommands=()=>{},o.closeSlashMenu=()=>{},o.executeSlashCommand=()=>false;}),n&&(o.toggleBold=()=>{},o.toggleItalic=()=>{},o.toggleUnderline=()=>{},o.toggleStrikethrough=()=>{},o.formatText=()=>{},o.setFontFamily=()=>{},o.clearFontFamily=()=>{},o.setFontSize=()=>{},o.clearFontSize=()=>{},o.setLineHeight=()=>{},o.clearLineHeight=()=>{},o.setTextColor=()=>{},o.clearTextColor=()=>{},o.setTextHighlight=()=>{},o.clearTextHighlight=()=>{},o.toggleSubscript=()=>{},o.toggleSuperscript=()=>{},o.insertLink=()=>{},o.removeLink=()=>{},o.updateLink=()=>false,o.toggleParagraph=()=>{},o.toggleHeading=()=>{},o.toggleQuote=()=>{},o.setTextAlignment=()=>{},o.toggleUnorderedList=()=>{},o.toggleOrderedList=()=>{},o.toggleCheckList=()=>{},o.indentList=()=>{},o.outdentList=()=>{},o.insertHorizontalRule=()=>{},o.insertTable=()=>{},o.insertImage=()=>{},o.setImageAlignment=()=>{},o.setImageCaption=()=>{},o.insertIframeEmbed=()=>{},o.setIframeEmbedAlignment=()=>{},o.resizeIframeEmbed=()=>{},o.setIframeEmbedCaption=()=>{},o.updateIframeEmbedUrl=()=>false,o.insertYouTubeEmbed=()=>{},o.setYouTubeEmbedAlignment=()=>{},o.resizeYouTubeEmbed=()=>{},o.setYouTubeEmbedCaption=()=>{},o.updateYouTubeEmbedUrl=()=>false),o}function ei(e){return new Set(e)}function po(e,t){e.clear();for(let n of t)e.add(n);}function ti(e,t){return e.has(t)}function Jt(e,t){e.add(t);}var{Provider:as,useEditor:ss}=createEditorSystem(),ri="Write anything...",ii="Enter JSON document content...",li="Enter Markdown content...",ai="Enter HTML content...",mi=new Set(["auto","scroll","overlay"]),us={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"};function gn(e){return e==="visual"?"visual-editor":e}function ne(e){return gn(e)==="visual-editor"}function Co(e,t){return e.some(n=>gn(n)===t)}function Dn(e){return e==="json"||e==="markdown"||e==="html"}function gi(e){let t=e.overflowY;return t&&t!=="visible"?t:e.overflow||t||"visible"}function cs(e){if(typeof e.scrollTo=="function")try{e.scrollTo({top:0,behavior:"auto"});}catch{e.scrollTop=0;return}e.scrollTop!==0&&(e.scrollTop=0);}function ds(e){let t=new Set,n=o=>{o&&t.add(o);};if(n(e),n(e.closest(".luthor-richtext-container")),n(e.closest(".luthor-editor-visual-shell")),n(e.closest(".luthor-editor")),n(e.closest(".luthor-editor-wrapper")),typeof window<"u"){let o=e.parentElement;for(;o&&o!==document.body&&o!==document.documentElement;){let i=gi(window.getComputedStyle(o));mi.has(i)&&n(o),o=o.parentElement;}}t.forEach(o=>{cs(o);});}function ms(e){if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e());});return}globalThis.setTimeout(e,0);}function si(e){if(typeof window>"u")return ()=>{};let t=[],n=e.parentElement;for(;n&&n!==document.body&&n!==document.documentElement;){let o=window.getComputedStyle(n),i=gi(o);if(!mi.has(i)){n=n.parentElement;continue}if(n.scrollHeight>n.clientHeight+1)break;if(i==="auto"||i==="overlay"){t.push({element:n,overflowY:n.style.overflowY}),n.style.overflowY="visible",n=n.parentElement;continue}break}return ()=>{for(let o=t.length-1;o>=0;o-=1){let i=t[o];i&&(i.element.style.overflowY=i.overflowY);}}}function gs(e){if(typeof window>"u")return ()=>{};let t=si(e),n=()=>{t(),t=si(e);};return window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n),t();}}function vo(e){let n=e.replace(/\r\n?/g,`
|
|
9
|
-
`).trim().split(/\n{2,}/).map(i=>i.replace(/\s+/g," ").trim()).filter(i=>i.length>0);return {root:{type:"root",version:1,format:"",indent:0,direction:null,children:(n.length>0?n:[""]).map(i=>({type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"text",version:1,text:i,detail:0,format:0,mode:"normal",style:""}]}))}}}var mn=vo("");function ui(e,t,n){return n<=t?t:Math.min(n,Math.max(t,e))}function fs(e,t){let n=document,o=window.getSelection();if(!o)return false;let i=n.caretPositionFromPoint?.(e,t);if(i){let l=document.createRange();return l.setStart(i.offsetNode,i.offset),l.collapse(true),o.removeAllRanges(),o.addRange(l),true}let r=n.caretRangeFromPoint?.(e,t);return r?(r.collapse(true),o.removeAllRanges(),o.addRange(r),true):false}function hs(e,t,n){let r=Array.from(e.children).filter(v=>v instanceof HTMLElement).reduce((v,b)=>{let E=b.getBoundingClientRect(),g=E.top+E.height/2;if(!v)return b;let f=v.getBoundingClientRect(),h=f.top+f.height/2;return Math.abs(g-n)<Math.abs(h-n)?b:v},null)??e.firstElementChild??e,l=e.getBoundingClientRect(),s=r.getBoundingClientRect(),u=ui(t,l.left+1,l.right-1),d=ui(n,s.top+1,s.bottom-1);fs(u,d);}function ps(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(vo(e))}}function Ne(e,t,n="preserve",o="luthor"){let i=t??mn;if(e==="json")return Fr(JSON.stringify(i));if(e==="markdown"){let l=o==="lexical-native"?jsonToMarkdown(i,{bridgeFlavor:"lexical-native"}):n==="none"?jsonToMarkdown(i,{metadataMode:"none"}):jsonToMarkdown(i);return Mr(l)}let r=n==="none"?jsonToHTML(i,{metadataMode:"none"}):jsonToHTML(i);return Or(r)}function ci(e){let t=e.replace(/\r\n?/g,`
|
|
10
|
-
`),n=t.split(`
|
|
11
|
-
`);if(n.length<3)return {frontmatter:null,body:t};if((n[0]??"").replace(/^\uFEFF/,"").trim()!=="---")return {frontmatter:null,body:t};let i=-1;for(let l=1;l<n.length;l+=1){let s=(n[l]??"").trim();if(s==="---"||s==="..."){i=l;break}}if(i<2)return {frontmatter:null,body:t};let r=n.slice(1,i).join(`
|
|
12
|
-
`);return /^[^#\n]*:/m.test(r)?{frontmatter:n.slice(0,i+1).join(`
|
|
13
|
-
`).trim(),body:n.slice(i+1).join(`
|
|
14
|
-
`)}:{frontmatter:null,body:t}}function bs(e,t){let n=ci(e);if(!n.frontmatter||ci(t).frontmatter)return t;let i=t.replace(/\r\n?/g,`
|
|
15
|
-
`).trim();return i.length>0?`${n.frontmatter}
|
|
16
|
-
|
|
17
|
-
${i}`:`${n.frontmatter}
|
|
18
|
-
`}function ys(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:t.value.trim(),label:t.label.trim(),fontFamily:t.fontFamily.trim(),cssImportUrl:t.cssImportUrl?.trim()||""})))}function Cs(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),fontSize:String(t.fontSize).trim()})))}function vs(e){return !e||e.length===0?"__default__":JSON.stringify(e.map(t=>({value:String(t.value).trim(),label:String(t.label).trim(),lineHeight:String(t.lineHeight).trim()})))}function Es(e){if(typeof e=="number")return !Number.isFinite(e)||e<1?"1.5":e.toString();if(typeof e=="string"){let n=e.trim();if(n.length===0)return "1.5";let o=Number(n);return !Number.isFinite(o)||o<1?"1.5":o.toString()}return "1.5"}function ks(e){if(!Number.isFinite(e))return "8";let t=Math.floor(e);return t<0?"8":t.toString()}function yo(e){return Jr(e)}function Ls(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(o=>o.trim())});let t=e,n=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:n.map(o=>o.trim())})}function ws(e){return Gr(e)}function Ss(e){let t=cn(e);return JSON.stringify(fo.map(n=>[n,t[n]]))}function di(e){return Wr(e)}var Ts=[{feature:"bold",key:"b",requiresPrimary:true},{feature:"italic",key:"i",requiresPrimary:true},{feature:"underline",key:"u",requiresPrimary:true},{feature:"link",key:"k",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true},{feature:"history",key:"y",requiresPrimary:true},{feature:"history",key:"z",requiresPrimary:true,shift:true},{feature:"commandPalette",key:"p",requiresPrimary:true,shift:true},{feature:"codeFormat",key:"`",requiresPrimary:true},{feature:"code",key:"`",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,shift:true},{feature:"list",key:"l",requiresPrimary:true,alt:true},{feature:"list",key:"x",requiresPrimary:true,shift:true},{feature:"blockFormat",key:"0",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"1",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"2",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"3",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"4",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"5",requiresPrimary:true,alt:true},{feature:"blockFormat",key:"6",requiresPrimary:true,alt:true}];function xs(e,t){return Xr(e,t)}function Is(e,t,n){return Zr(e,t,n)}var Fs={fontFamily:"fontFamily",fontSize:"fontSize",lineHeight:"lineHeight",textColor:"textColor",textHighlight:"textHighlight",bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",subscript:"subscript",superscript:"superscript",code:"codeFormat",link:"link",blockFormat:"blockFormat",quote:"blockFormat",alignLeft:"blockFormat",alignCenter:"blockFormat",alignRight:"blockFormat",alignJustify:"blockFormat",codeBlock:"code",unorderedList:"list",orderedList:"list",checkList:"list",indentList:"list",outdentList:"list",horizontalRule:"horizontalRule",table:"table",image:"image",emoji:"emoji",embed:["iframeEmbed","youTubeEmbed"],undo:"history",redo:"history",commandPalette:"commandPalette",themeToggle:"themeToggle"};function Ms(e,t){return Qr(e,t,Fs)}function Os(e){if(!e||e.length===0)return [...Ve];let t=new Set,n=[];for(let o of e)!Ve.includes(o)||t.has(o)||(t.add(o),n.push(o));return n.length>0?n:[...Ve]}function Ns(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,l=[];for(let s of e)for(let[u,d]of Object.entries(s)){let v=u.trim();!d||!v||r.has(v)||(r.add(v),l.push(v));}return l.length===0?"__default__":JSON.stringify({allowlist:l,denylist:[]})}let t=r=>{if(!r||r.length===0)return [];let l=new Set,s=[];for(let u of r){let d=u.trim();!d||l.has(d)||(l.add(d),s.push(d));}return s},n=e,o=t(n.allowlist),i=t(n.denylist);return o.length===0&&i.length===0?"__default__":JSON.stringify({allowlist:o,denylist:i})}function Hs(e){if(!e||e.length===0)return [];let t=new Set,n=[];for(let o of e){let i=o.trim();!i||t.has(i)||(t.add(i),n.push(i));}return n}function Rs(e,t){return e.key.toLowerCase()===t.key.toLowerCase()&&!!e.ctrlKey==!!t.ctrlKey&&!!e.metaKey==!!t.metaKey&&!!e.shiftKey==!!t.shiftKey&&!!e.altKey==!!t.altKey}function As(e){if(!e)return "__default__";let t=Array.isArray(e.disabledCommandIds)?[...e.disabledCommandIds].map(o=>o.trim()).filter(o=>o.length>0).sort((o,i)=>o.localeCompare(i)):[],n=e.bindings?Object.entries(e.bindings).map(([o,i])=>{if(i===false||i===null)return [o,false];let l=(Array.isArray(i)?i:[i]).map(s=>({key:s.key.trim(),ctrlKey:!!s.ctrlKey,metaKey:!!s.metaKey,shiftKey:!!s.shiftKey,altKey:!!s.altKey,preventDefault:s.preventDefault})).filter(s=>s.key.length>0).sort((s,u)=>{let d=`${s.key}:${s.ctrlKey?1:0}:${s.metaKey?1:0}:${s.shiftKey?1:0}:${s.altKey?1:0}`,v=`${u.key}:${u.ctrlKey?1:0}:${u.metaKey?1:0}:${u.shiftKey?1:0}:${u.altKey?1:0}`;return d.localeCompare(v)});return l.length===0?[o,false]:[o,l]}).sort(([o],[i])=>o.localeCompare(i)):[];return JSON.stringify({disabledCommandIds:t,bindings:n,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function Ps({isDark:e,toggleTheme:t,visualPlaceholder:n,jsonPlaceholder:o,markdownPlaceholder:i,htmlPlaceholder:r,initialMode:l,availableModes:s,onReady:u,toolbarLayout:d,toolbarVisibility:v,toolbarPosition:b,toolbarAlignment:E,toolbarClassName:g,toolbarStyleVars:f,isToolbarEnabled:h,isToolbarPinned:y,isEditorViewTabsVisible:T,headingOptions:k,paragraphLabel:F,syncHeadingOptionsWithCommands:M,slashCommandVisibility:A,shortcutConfig:Q,commandPaletteShortcutOnly:le,isListStyleDropdownEnabled:ge,featureFlags:L,editOnClick:O,sourceMetadataMode:S,markdownBridgeFlavor:x,markdownSourceOfTruth:D,showLineNumbers:V}){let{commands:se,hasExtension:Ce,activeStates:pe,lexical:X,extensions:Z,export:W,import:me}=ss(),[N,Ue]=useState(l),[He,be]=useState({json:"",markdown:"",html:""}),[Qe,$e]=useState(null),[xe,Ie]=useState(null),[qe,Re]=useState({isOpen:false,commands:[]}),[P,j]=useState({isOpen:false,query:"",position:null,commands:[]}),[de,ht]=useState({isOpen:false,query:"",position:null,suggestions:[]}),Ye=useRef(false),Ze=useMemo(()=>Os(k),[k]),ve=M?Ze:void 0,Ee=M?F:void 0,it=pe.isInCodeBlock===true,te=useMemo(()=>Is(se,L,it),[se,L,it]),Ae=useMemo(()=>m=>Object.prototype.hasOwnProperty.call(L,m)?L[m]!==false:true,[L]),Fe=useMemo(()=>m=>ne(N)&&Ae(m),[N,Ae]),Je=useMemo(()=>Ms(v,L),[v,L]),lt=L.draggableBlock!==false,ke=Ns(A),ee=useRef(A),Le=useRef(ke),at=As(Q),Ge=useRef(Q),st=useRef(at),Lt=useMemo(()=>Hs(Q?.disabledCommandIds),[Q?.disabledCommandIds]),et=useMemo(()=>new Set(Lt),[Lt]),pt=useMemo(()=>et.size===0?[]:jn({headingOptions:ve,paragraphLabel:Ee,isFeatureEnabled:Ae}).filter(m=>et.has(m.id)).flatMap(m=>m.shortcuts??[]),[et,ve,Ee,Ae]);Le.current!==ke&&(Le.current=ke,ee.current=A),st.current!==at&&(st.current=at,Ge.current=Q);let Ke=useRef(ei(["visual-editor"])),We=useRef({json:false,markdown:false,html:false}),fe=useRef(""),Me=useRef(true),wt=useRef(false),_e=useRef(false),St=useRef(0),tt=useRef(null);useEffect(()=>{Qn(te,pe,e?"dark":"light",Fe);},[te,pe,e,Fe]);let Tt=useMemo(()=>{let m=Xe=>{let It=Ne("json",Xe,S,x),_n=Ne("markdown",Xe,S,x),So=Ne("html",Xe,S,x);be(hn=>hn.json===It&&hn.markdown===_n&&hn.html===So?hn:{json:It,markdown:_n,html:So}),We.current.json=false,We.current.markdown=false,We.current.html=false,Jt(Ke.current,"json"),Jt(Ke.current,"markdown"),Jt(Ke.current,"html"),D&&(fe.current=_n,Me.current=false);},w=Xe=>{setTimeout(()=>{try{let It=JSON.parse(Xe);me.fromJSON(It),m(It);}catch(It){console.error("Failed to inject JSON:",It);return}},100);},z=()=>{if(!D)return Ne("markdown",W.toJSON(),S,x);if(Me.current){let Xe=Ne("markdown",W.toJSON(),S,x);fe.current=Xe,Me.current=false;}return fe.current},$=()=>{let Xe=z();return x==="lexical-native"?markdownToJSON(Xe,{bridgeFlavor:"lexical-native"}):S==="none"?markdownToJSON(Xe,{metadataMode:"none"}):markdownToJSON(Xe)};return {injectJSON:w,getJSON:()=>D?Ne("json",$(),S,x):Ne("json",W.toJSON()),getMarkdown:()=>z(),getHTML:()=>D?Ne("html",$(),S,x):Ne("html",W.toJSON(),S,x)}},[W,me,x,D,S]);useEffect(()=>{if(!X||!te)return;let m=te,w=Fo(m,{headingOptions:ve,paragraphLabel:Ee,isFeatureEnabled:Fe,shortcutConfig:Ge.current,commandPaletteShortcutOnly:le});typeof m.registerCommand=="function"&&w.forEach(G=>m.registerCommand(G));let z=Mo(m,{headingOptions:ve,paragraphLabel:Ee,slashCommandVisibility:ee.current,isFeatureEnabled:Fe,shortcutConfig:Ge.current});typeof m.setSlashCommands=="function"?m.setSlashCommands(z):z.forEach(G=>m.registerSlashCommand?.(G));let $=No(m,document.body,{headingOptions:ve,paragraphLabel:Ee,isFeatureEnabled:Fe,shortcutConfig:Ge.current,scope:()=>X.getRootElement()});return Ye.current||(Ye.current=true,u?.(Tt)),()=>{$(),typeof m.unregisterCommand=="function"&&w.forEach(G=>m.unregisterCommand(G.id)),typeof m.setSlashCommands=="function"?m.setSlashCommands([]):z.forEach(G=>m.unregisterSlashCommand?.(G.id));}},[X,te,Tt,u,ve,Ee,ke,at,Fe,le]),useEffect(()=>{let m=()=>X?.getRootElement(),w=Ts.filter($=>L[$.feature]===false);if(w.length===0)return;let z=$=>{let G=m();G&&$.target instanceof Node&&!G.contains($.target)||!di($.target)||!w.some(wo=>xs($,wo))||($.preventDefault(),$.stopPropagation());};return document.addEventListener("keydown",z,true),()=>{document.removeEventListener("keydown",z,true);}},[X,L]),useEffect(()=>{let m=Z.find(w=>w.name==="commandPalette");if(!(!m||!m.subscribe))return m.subscribe((w,z)=>{let $=z.filter(G=>et.has(G.id)?false:le?typeof G.shortcut=="string"&&G.shortcut.trim().length>0:true);Re({isOpen:ne(N)?w:false,commands:$});})},[Z,et,le,N]),useEffect(()=>{if(pt.length===0)return;let m=()=>X?.getRootElement(),w=z=>{let $=m();$&&z.target instanceof Node&&!$.contains(z.target)||!di(z.target)||!pt.some(we=>Rs(z,we))||(z.preventDefault(),z.stopPropagation());};return document.addEventListener("keydown",w,true),()=>{document.removeEventListener("keydown",w,true);}},[X,pt]),useEffect(()=>{let m=Z.find(w=>w.name==="slashCommand");if(!(!m||!m.subscribe))return m.subscribe(w=>{j({isOpen:ne(N)?w.isOpen:false,query:ne(N)?w.query:"",position:ne(N)?w.position:null,commands:ne(N)?w.commands:[]});})},[Z,N]),useEffect(()=>{let m=Z.find(w=>w.name==="emoji");if(!(!m||!m.subscribe))return m.subscribe(w=>{ht({isOpen:ne(N)?w.isOpen:false,query:ne(N)?w.query:"",position:ne(N)?w.position:null,suggestions:ne(N)?w.suggestions:[]});})},[Z,N]),useEffect(()=>{ne(N)||(Re(m=>m.isOpen?{...m,isOpen:false}:m),j(m=>m.isOpen||m.query.length>0||m.position!==null||m.commands.length>0?{isOpen:false,query:"",position:null,commands:[]}:m),ht(m=>m.isOpen||m.query.length>0||m.position!==null||m.suggestions.length>0?{isOpen:false,query:"",position:null,suggestions:[]}:m),te.hideCommandPalette?.(),te.closeSlashMenu?.(),te.closeEmojiSuggestions?.());},[N,te]),useEffect(()=>!X||!W?void 0:X.registerUpdateListener(({dirtyElements:w,dirtyLeaves:z})=>{if((w.size>0||z.size>0)&&(St.current+=1,po(Ke.current,["visual-editor"]),D)){if(!ne(N)||_e.current)return;if(wt.current){wt.current=false;return}Me.current=true;}}),[X,W,D,N]);let xt=m=>x==="lexical-native"?markdownToJSON(m,{bridgeFlavor:"lexical-native"}):S==="none"?markdownToJSON(m,{metadataMode:"none"}):markdownToJSON(m),bt=(m,w)=>m==="json"?w.trim()?JSON.parse(w):vo(""):m==="markdown"?xt(w):S==="none"?htmlToJSON(w,{metadataMode:"none"}):htmlToJSON(w),ut=m=>{let w=W.toJSON()??mn;return Ne(m,w,S,x)},nt=()=>{let m=ut("markdown"),w=bs(fe.current,m);return fe.current=w,Me.current=false,We.current.markdown=false,Jt(Ke.current,"markdown"),be(z=>z.markdown===w?z:{...z,markdown:w}),w},ct=()=>D?Me.current?nt():fe.current:ut("markdown"),C=m=>{let w=ct(),z=xt(w);return Ne(m,z,S,x)},p=m=>{let w=He[m],z=bt(m,w),$=D&&m==="markdown";D&&m==="markdown"&&(wt.current=true),$&&(_e.current=true);try{me.fromJSON(z);}finally{$&&(_e.current=false);}D&&(m==="markdown"?(fe.current=w,Me.current=false):Me.current=true),We.current[m]=false,po(Ke.current,["visual-editor"]);},B=(m,w,z)=>{be($=>({...$,[m]:w})),We.current[m]=z?.dirty===true,D&&m==="markdown"&&(fe.current=w,Me.current=false);},K=async m=>{let w=gn(m);if(w===N||!Co(s,w))return;let z=N,$=null;try{if(Ie(null),Dn(z)){let G=z;We.current[G]&&($=G,p(G),await new Promise(we=>setTimeout(we,50)),$=null);}if(D&&Me.current&&(ne(z)||Dn(z)&&z!=="markdown")&&nt(),ne(z)&&!ne(w)&&(X&&clearLexicalSelection(X),X?.getRootElement()?.blur()),Ue(w),Dn(w)){let G=w;if(!ti(Ke.current,G)){$e(G),await new Promise(we=>setTimeout(we,50));try{$=G;let we=D?G==="markdown"?ct():C(G):ut(G);B(G,we),Jt(Ke.current,G),$=null;}finally{$e(null);}}}ne(w)&&(z==="visual-only"&&tt.current!==null?setTimeout(()=>X?.focus(),100):ms(()=>{let we=X?.getRootElement();we&&ds(we);}));}catch(G){let we=G instanceof Error?G.message:"Invalid format - could not parse content";$&&typeof window<"u"&&Ie({mode:$,error:we});}},J=m=>{!O||N!=="visual-only"||!Co(s,"visual-editor")||(tt.current=m,K("visual-editor"));};useEffect(()=>{if(!ne(N))return;let m=tt.current;if(!m)return;tt.current=null;let w=()=>{let $=X?.getRootElement();$&&hs($,m.clientX,m.clientY);};if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(()=>w());return}let z=globalThis.setTimeout(w,0);return ()=>{globalThis.clearTimeout(z);}},[X,N]);let ue=h?jsx(zr,{commands:te,hasExtension:m=>Ce(m),activeStates:pe,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{ne(N)&&L.commandPalette!==false&&te.showCommandPalette();},imageUploadHandler:m=>Z.find(w=>w.name==="image")?.config?.uploadHandler?.(m)??Promise.resolve(URL.createObjectURL(m)),layout:d??pn,toolbarVisibility:Je,toolbarStyleVars:f,headingOptions:Ze,paragraphLabel:F,isListStyleDropdownEnabled:ge,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${E}${g?` ${g}`:""}`}}):null,ye=T,yt=ne(N)&&h&&b==="top",fn=["luthor-editor-top-region",y&&b==="top"&&ye?"luthor-editor-top-region--pinned":""].filter(Boolean).join(" "),Un=["luthor-editor-toolbar-slot","luthor-editor-toolbar-slot--top",yt&&(y&&b==="top"&&!ye)?"luthor-editor-toolbar-slot--pinned":""].filter(Boolean).join(" "),he=ne(N)&&h&&b==="bottom",Wt=X?.getRootElement()?.closest(".luthor-editor-wrapper")??null,dt=Dn(N)?N:null,Pt=N==="visual-only",Lo=ne(N)||Pt,Kn=!lt||!ne(N);return jsxs(Fragment,{children:[jsxs("div",{className:`luthor-editor${Kn?" luthor-editor--draggable-disabled":""}`,"data-mode":N,children:[(ye||yt)&&jsxs("div",{className:fn,children:[ye&&jsx("div",{className:"luthor-editor-header",children:jsx(Lr,{mode:N,onModeChange:K,availableModes:s,isConverting:Qe})}),yt&&jsx("div",{className:Un,children:ue})]}),jsxs("div",{className:`luthor-editor-visual-shell${Lo?"":" is-hidden"}${Kn?" luthor-editor-visual-shell--no-gutter":""}`,"aria-hidden":!Lo,children:[!Kn&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:n,nonEditableVisualMode:Pt,onEditIntent:Pt?J:void 0,classNames:{container:"luthor-richtext-container luthor-preset-extensive__container",contentEditable:"luthor-content-editable luthor-preset-extensive__content",placeholder:"luthor-placeholder luthor-preset-extensive__placeholder"}})]}),dt&&jsxs("div",{className:"luthor-source-panel",children:[xe&&xe.mode===dt&&jsxs("div",{className:"luthor-source-error",children:[jsx("div",{className:"luthor-source-error-icon",children:"!"}),jsxs("div",{className:"luthor-source-error-message",children:[jsx("strong",{children:us[dt]}),jsx("p",{children:xe.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),dt==="json"&&jsx(In,{value:He.json,onChange:m=>B("json",m,{dirty:true}),placeholder:o,showLineNumbers:V}),dt==="markdown"&&jsx(In,{value:He.markdown,onChange:m=>B("markdown",m,{dirty:true}),placeholder:i,className:"luthor-source-view--wrapped",wrap:"soft",showLineNumbers:V}),dt==="html"&&jsx(In,{value:He.html,onChange:m=>B("html",m,{dirty:true}),placeholder:r,className:"luthor-source-view--wrapped",wrap:"soft",showLineNumbers:V})]})]}),jsx(br,{editor:X,commands:te,editorTheme:e?"dark":"light",disabled:!ne(N)}),he&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:ue}),ne(N)&&jsx(Zo,{isOpen:qe.isOpen,onClose:()=>te.hideCommandPalette(),commands:qe.commands}),ne(N)&&jsx(ar,{isOpen:P.isOpen,query:P.query,position:P.position,portalContainer:Wt,commands:P.commands,onClose:()=>te.closeSlashMenu?.(),onExecute:m=>{te.executeSlashCommand?.(m);}}),ne(N)&&jsx(nr,{isOpen:de.isOpen,query:de.query,position:de.position,portalContainer:Wt,suggestions:de.suggestions,onClose:()=>te.closeEmojiSuggestions?.(),onExecute:m=>{te.executeEmojiSuggestion?.(m);}})]})}var Bn=forwardRef(({className:e,onReady:t,initialTheme:n="light",onThemeChange:o,theme:i,defaultContent:r,showDefaultContent:l=true,placeholder:s=ri,defaultEditorView:u,initialMode:d="visual-editor",isEditorViewTabsVisible:v,isEditorViewsTabVisible:b,availableModes:E=["visual-editor","visual-only","json","markdown","html"],variantClassName:g,toolbarLayout:f,toolbarVisibility:h,toolbarPosition:y="top",toolbarAlignment:T="left",toolbarClassName:k,toolbarStyleVars:F,quoteClassName:M,quoteStyleVars:A,defaultSettings:Q,editorThemeOverrides:le,isToolbarEnabled:ge=true,isToolbarPinned:L=false,fontFamilyOptions:O,fontSizeOptions:S,lineHeightOptions:x,minimumDefaultLineHeight:D=1.5,scaleByRatio:V=false,headingOptions:se,paragraphLabel:Ce,syncHeadingOptionsWithCommands:pe=true,slashCommandVisibility:X,shortcutConfig:Z,commandPaletteShortcutOnly:W=false,isListStyleDropdownEnabled:me=true,editOnClick:N=true,isDraggableBoxEnabled:Ue,featureFlags:He,sourceMetadataMode:be="preserve",markdownBridgeFlavor:Qe="luthor",markdownSourceOfTruth:$e=false,syntaxHighlighting:xe,codeHighlightProvider:Ie,loadCodeHighlightProvider:qe,maxAutoDetectCodeLength:Re,isCopyAllowed:P=true,languageOptions:j,showLineNumbers:de=true,inlineCodeHighlighting:ht=true,maxListIndentation:Ye=8},Ze)=>{let[ve,Ee]=useState(n),it=useRef(null),te=ve==="dark",Ae=gn(u??d),Fe=Co(E,Ae)?Ae:gn(E[0]??"visual-editor"),Je=v??b??true,lt=()=>Ee(te?"light":"dark"),ke=useMemo(()=>typeof s=="string"?{visual:s,json:ii,markdown:li,html:ai}:{visual:s.visual??ri,json:s.json??ii,markdown:s.markdown??li,html:s.html??ai},[s]);useEffect(()=>{Ee(n);},[n]),useEffect(()=>{o?.(ve);},[ve,o]),useEffect(()=>{if(!L||y!=="top")return;let he=it.current;if(he)return gs(he)},[L,y]);let ee=useMemo(()=>ys(O),[O]),Le=useMemo(()=>Cs(S),[S]),at=useMemo(()=>vs(x),[x]),Ge=useMemo(()=>Es(D),[D]),st=useMemo(()=>ks(Ye),[Ye]),Lt=xe??"unset",et=typeof Re=="number"?Re.toString():"unset",pt=useMemo(()=>Ls(j),[j]),Ke=P?"copy-on":"copy-off",We=de?"line-numbers-on":"line-numbers-off",fe=useMemo(()=>typeof Ue!="boolean"?He:{...He??{},draggableBlock:Ue},[He,Ue]),Me=useMemo(()=>Ss(fe),[fe]),wt=useMemo(()=>cn(fe),[fe]),_e=`${ee}::${Le}::${at}::${Ge}::${st}::${V?"ratio-on":"ratio-off"}::${Lt}::${et}::${Ke}::${We}::${pt}::${Me}`,St=useRef(O),tt=useRef(S),Tt=useRef(x),xt=useRef(D),bt=useRef(fe),ut=useRef(j),nt=useRef(Ie),ct=useRef(qe),C=useRef(_e);(C.current!==_e||nt.current!==Ie||ct.current!==qe)&&(C.current=_e,St.current=O,tt.current=S,Tt.current=x,xt.current=D,bt.current=fe,ut.current=j,nt.current=Ie,ct.current=qe);let p=useRef(null);if(!p.current||p.current.key!==_e){let he={fontFamilyOptions:St.current,fontSizeOptions:tt.current,lineHeightOptions:Tt.current,minimumDefaultLineHeight:xt.current,maxListIndentation:Number(st),scaleByRatio:V,...xe!==void 0?{syntaxHighlighting:xe}:{},...nt.current!==void 0?{codeHighlightProvider:nt.current}:{},...ct.current!==void 0?{loadCodeHighlightProvider:ct.current}:{},...Re!==void 0?{maxAutoDetectCodeLength:Re}:{},isCopyAllowed:P,showLineNumbers:de,...ut.current!==void 0?{languageOptions:ut.current}:{},...typeof Ue=="boolean"?{isDraggableBoxEnabled:Ue}:{},...bt.current?{featureFlags:bt.current}:{}};p.current={key:_e,value:dn(he)};}let B=p.current.value,K=useMemo(()=>{let he=mergeThemes(defaultLuthorTheme,i??{});return M?{...he,quote:`${he.quote??""} ${M}`.trim()}:he},[i,M]),J=useMemo(()=>yo(le),[le]),ue=useMemo(()=>yo(A),[A]),ye=useMemo(()=>ws(Q),[Q]),yt=useMemo(()=>yo(ye),[ye]),Eo=useMemo(()=>{let he=ye,Wt=createEditorThemeStyleVars(le),dt=A,Pt={"--luthor-default-line-height":Ge};return !he&&!Wt&&!dt?Pt:{...he??{},...Wt,...dt??{},...Pt}},[Ge,ye,le,A,yt,J,ue]),[fn,ko]=useState(null);useImperativeHandle(Ze,()=>fn??{injectJSON:()=>{},getJSON:()=>Ne("json",mn),getMarkdown:()=>Ne("markdown",mn,be,Qe),getHTML:()=>Ne("html",mn,be,Qe)},[Qe,fn,be]);let Un=he=>{ko(he),r&&he.injectJSON(ps(r)),t?.(he);};return jsx("div",{ref:it,className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper${L?" luthor-editor-wrapper--toolbar-pinned":""} ${g||""} ${e||""}`.trim(),"data-editor-theme":ve,"data-inline-code-highlighting":ht?"on":"off",style:Eo,children:jsx(as,{extensions:B,config:{theme:K},children:jsx(Ps,{isDark:te,toggleTheme:lt,visualPlaceholder:ke.visual,jsonPlaceholder:ke.json,markdownPlaceholder:ke.markdown,htmlPlaceholder:ke.html,initialMode:Fe,availableModes:E,onReady:Un,toolbarLayout:f,toolbarVisibility:h,toolbarPosition:y,toolbarAlignment:T,toolbarClassName:k,toolbarStyleVars:F,isToolbarEnabled:ge,isToolbarPinned:L,isEditorViewTabsVisible:Je,headingOptions:se,paragraphLabel:Ce,syncHeadingOptionsWithCommands:pe,slashCommandVisibility:X,shortcutConfig:Z,commandPaletteShortcutOnly:W,isListStyleDropdownEnabled:me,featureFlags:wt,editOnClick:N,sourceMetadataMode:be,markdownBridgeFlavor:Qe,markdownSourceOfTruth:$e,showLineNumbers:de})})})});Bn.displayName="ExtensiveEditor";var fi=["undo","redo","fontFamily","heading","fontSize","lineHeight","textColor","textHighlight","bold","italic","underline","strikethrough","subscript","superscript","link","image","table","horizontalRule","iframeEmbed","youtubeEmbed","blockquote","code","codeBlock","bulletedList","numberedList","checkList","commandPalette","floatingToolbar","contextMenu","draggableBlock","customNode","sourceMode","themeToggle"],hi={id:"extensive",label:"Extensive Editor",description:"Complete editing preset with all core features enabled.",extensions:[...ho],components:{Editor:Bn},toolbar:[...fi],config:Sr("extensive","Write anything..."),css:"extensive/styles.css"};function Ds(e={}){return {...hi,extensions:[...dn({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,maxListIndentation:e.maxListIndentation,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions,showLineNumbers:e.showLineNumbers})]}}export{Ct as $,qn as A,ei as Aa,zo as B,po as Ba,Do as C,ti as Ca,Bo as D,Jt as Da,qs as E,Bn as Ea,Uo as F,fi as Fa,Ys as G,hi as Ga,Ln as H,Ds as Ha,Ko as I,_o as J,wn as K,Vo as L,jo as M,$o as N,qo as O,Yo as P,Yn as Q,Jo as R,Go as S,Ut as T,Wo as U,Zo as V,nr as W,ar as X,R as Y,Xn as Z,rn as _,Bs as a,cr as aa,Ve as b,dr as ba,Ks as c,Qn as ca,pn as d,mr as da,jn as e,br as ea,Fo as f,Lr as fa,Mo as g,In as ga,No as h,Sr as ha,yn as i,Fr as ia,Cn as j,Mr as ja,vn as k,Or as ka,En as l,Gl as la,kn as m,Wl as ma,Ho as n,Xl as na,zt as o,zr as oa,Ft as p,jr as pa,Xt as q,cn as qa,Qt as r,$r as ra,Zt as s,dn as sa,Ro as t,ho as ta,Ao as u,Jr as ua,$n as v,Gr as va,Dt as w,Wr as wa,Mt as x,Xr as xa,Po as y,Qr as ya,Bt as z,Zr as za};
|
package/dist/chunk-5VVQH4YY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a,b}from'./chunk-6UNJGUCM.js';import {Ea,ha,sa}from'./chunk-4DHY4VVC.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var d=["visual-only","visual","json","markdown"],u=["visual-only","visual","json","html"],E=["visual-only","visual","markdown","html"],o={bold:true,italic:true,underline:false,strikethrough:true,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:true,horizontalRule:true,table:true,list:true,history:true,image:true,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:false,youTubeEmbed:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,emoji:false,draggableBlock:false,customNode:false,themeToggle:true},A={tabIndent:true,draggableBlock:false,iframeEmbed:false,youTubeEmbed:false,customNode:false,emoji:false,commandPalette:false,slashCommand:false},M=new a(o,A),m={sections:[{items:["undo","redo"]},{items:["blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify"]},{items:["bold","italic","strikethrough","code","link"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["codeBlock","horizontalRule","table","image"]},{items:["themeToggle"]}]};function v(e){return e==="both"?E:e==="html"?u:d}var r=forwardRef(({className:e,variantClassName:L,toolbarClassName:f,toolbarLayout:g,sourceFormat:h="both",initialMode:y="visual",defaultEditorView:_,featureFlags:R,...p},C)=>{let a=v(h),i=_??y,b$1=a.includes(i)?i:"visual";return jsx(Ea,{ref:C,...p,className:b("luthor-preset-legacy-rich",e),variantClassName:b("luthor-preset-legacy-rich__variant",L),toolbarClassName:b("luthor-preset-legacy-rich__toolbar",f),availableModes:a,initialMode:b$1,sourceMetadataMode:"none",isListStyleDropdownEnabled:false,toolbarLayout:g??m,featureFlags:M.resolve(R)})});r.displayName="LegacyRichEditor";var x={id:"legacy-rich",label:"Legacy Rich Editor",description:"Metadata-free rich text profile for native markdown and html compatibility.",extensions:sa({featureFlags:o}),components:{Editor:r},toolbar:["undo","redo","blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","bold","italic","strikethrough","code","link","unorderedList","orderedList","checkList","codeBlock","horizontalRule","table","image"],config:ha("legacy-rich","Write metadata-free content...")};export{d as a,u as b,E as c,o as d,m as e,r as f,x as g};
|
package/dist/chunk-6KIISXIV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a,b}from'./chunk-6UNJGUCM.js';import {sa,ha,ka,ja,ia,fa,ga}from'./chunk-4DHY4VVC.js';import {forwardRef,useState,useMemo,useRef,useEffect,useImperativeHandle,useCallback}from'react';import {createEditorSystem,jsonToHTML,jsonToMarkdown,RichText,htmlToJSON,markdownToJSON}from'@lyfie/luthor-headless';import {jsx,jsxs}from'react/jsx-runtime';var{Provider:me,useEditor:pe}=createEditorSystem(),te=["visual-only","visual","json","markdown","html"],Ee={"visual-only":"Visual Only",visual:"Visual",json:"JSON",markdown:"MD",html:"HTML"},ge={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"},Y="Start writing...",W="Enter JSON document content...",X="Enter Markdown content...",Z="Enter HTML content...",M={root:{type:"root",version:1,format:"",indent:0,direction:null,children:[{type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"text",version:1,text:"",detail:0,format:0,mode:"normal",style:""}]}]}},B={bold:true,italic:true,underline:false,strikethrough:true,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:false,horizontalRule:true,table:false,list:true,history:true,image:false,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:false,youTubeEmbed:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,emoji:false,draggableBlock:false,customNode:false,themeToggle:false},fe={draggableBlock:false,themeToggle:false,table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false,slashCommand:false,commandPalette:false,contextMenu:false,floatingToolbar:false},ve=new a(B,fe);function I(r){return r instanceof Error&&r.message.trim()?r.message.trim():"Unable to process the current source content."}function oe(r){return r&&typeof r=="object"?r:M}function se(r){let l=r.trim();return l?JSON.parse(l):M}function He(r,l){switch(r){case "json":return se(l);case "markdown":return markdownToJSON(l);case "html":return htmlToJSON(l)}}function x(r){return r==="visual"||r==="visual-only"}function c(r,l){let d=oe(l);switch(r){case "json":return ia(JSON.stringify(d));case "markdown":return ja(jsonToMarkdown(d));case "html":return ka(jsonToHTML(d))}}function Se(r){return typeof r=="string"||typeof r>"u"?{visual:r??Y,json:W,markdown:X,html:Z}:{visual:r.visual??Y,json:r.json??W,markdown:r.markdown??X,html:r.html??Z}}function _e({initialMode:r,placeholders:l,showLineNumbers:d,onReady:f}){let{activeStates:L,commands:t,export:u,import:p}=pe(),[a,H]=useState(r),[h,m]=useState({json:"",markdown:"",html:""}),[S,b]=useState(null),v=useRef(false),e=L,E=useCallback(()=>{let s=oe(u.toJSON()),i={json:c("json",s),markdown:c("markdown",s),html:c("html",s)};return m(i),i},[u]),C=useCallback((s,i)=>{let A=He(s,i);return p.fromJSON(A),A},[p]),w=useMemo(()=>({injectJSON:s=>{try{let i=se(s);p.fromJSON(i),b(null),E();}catch(i){b({mode:"json",error:I(i)});}},getJSON:()=>c("json",u.toJSON()),getMarkdown:()=>c("markdown",u.toJSON()),getHTML:()=>c("html",u.toJSON())}),[u,p,E]);useEffect(()=>{!f||v.current||(v.current=true,f(w));},[w,f]);let _=useCallback(s=>{if(s!==a){if(x(a)){if(!x(s))try{E(),b(null);}catch(i){b({mode:s,error:I(i)});return}H(s);return}try{let i=h[a],A=C(a,i);if(x(s)){b(null),H(s);return}let re=c(s,A);m(ae=>({...ae,[s]:re})),b(null),H(s);}catch(i){b({mode:a,error:I(i)});}}},[a,C,h,E]),T=useCallback(()=>{a==="visual"&&(e.bold&&t.toggleBold?.(),e.italic&&t.toggleItalic?.(),e.strikethrough&&t.toggleStrikethrough?.(),e.code&&t.formatText?.("code"),t.removeLink?.());},[t,a,e.bold,e.code,e.italic,e.strikethrough]),j=useCallback(()=>{a==="visual"&&(e.unorderedList&&t.toggleUnorderedList?.(),e.orderedList&&t.toggleOrderedList?.(),e.isQuote&&t.toggleQuote?.(),e.isInCodeBlock&&t.toggleCodeBlock?.(),t.toggleParagraph?.());},[t,a,e.isInCodeBlock,e.isQuote,e.orderedList,e.unorderedList]),P=useCallback(()=>{a==="visual"&&t.insertHardBreak?.();},[t,a]),k=x(a),n=a==="visual",F=a==="visual-only";return jsxs("div",{className:"luthor-editor","data-mode":a,children:[jsx("div",{className:"luthor-editor-header",children:jsx(fa,{mode:a,onModeChange:s=>_(s),availableModes:te,labels:Ee})}),jsxs("div",{className:"luthor-preset-headless-editor__toolbar",role:"toolbar","aria-label":"Headless editor toolbar",children:[jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.bold?" is-active":""}`,onClick:()=>t.toggleBold?.(),disabled:!n,children:"Bold"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.italic?" is-active":""}`,onClick:()=>t.toggleItalic?.(),disabled:!n,children:"Italic"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.strikethrough?" is-active":""}`,onClick:()=>t.toggleStrikethrough?.(),disabled:!n,children:"Strike"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.code?" is-active":""}`,onClick:()=>t.formatText?.("code"),disabled:!n||e.isInCodeBlock,children:"Code"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:T,disabled:!n,children:"Clear marks"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:j,disabled:!n,children:"Clear nodes"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isParagraph?" is-active":""}`,onClick:()=>t.toggleParagraph?.(),disabled:!n,children:"Paragraph"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isH1?" is-active":""}`,onClick:()=>t.toggleHeading?.("h1"),disabled:!n,children:"H1"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isH2?" is-active":""}`,onClick:()=>t.toggleHeading?.("h2"),disabled:!n,children:"H2"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isH3?" is-active":""}`,onClick:()=>t.toggleHeading?.("h3"),disabled:!n,children:"H3"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isH4?" is-active":""}`,onClick:()=>t.toggleHeading?.("h4"),disabled:!n,children:"H4"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isH5?" is-active":""}`,onClick:()=>t.toggleHeading?.("h5"),disabled:!n,children:"H5"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isH6?" is-active":""}`,onClick:()=>t.toggleHeading?.("h6"),disabled:!n,children:"H6"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.unorderedList?" is-active":""}`,onClick:()=>t.toggleUnorderedList?.(),disabled:!n,children:"Bullet list"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.orderedList?" is-active":""}`,onClick:()=>t.toggleOrderedList?.(),disabled:!n,children:"Ordered list"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isInCodeBlock?" is-active":""}`,onClick:()=>t.toggleCodeBlock?.(),disabled:!n,children:"Code block"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${e.isQuote?" is-active":""}`,onClick:()=>t.toggleQuote?.(),disabled:!n,children:"Blockquote"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>t.insertHorizontalRule?.(),disabled:!n,children:"Horizontal rule"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:P,disabled:!n,children:"Hard break"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>t.undo?.(),disabled:!n||!e.canUndo,children:"Undo"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>t.redo?.(),disabled:!n||!e.canRedo,children:"Redo"})]}),jsx("div",{className:`luthor-preset-headless-editor__visual-shell${k?"":" is-hidden"}`,"aria-hidden":!k,children:jsx(RichText,{placeholder:l.visual,nonEditableVisualMode:F,onEditIntent:F?()=>_("visual"):void 0,classNames:{container:"luthor-richtext-container luthor-preset-headless-editor__container",contentEditable:"luthor-content-editable luthor-preset-headless-editor__content",placeholder:"luthor-placeholder luthor-preset-headless-editor__placeholder"}})}),!k&&jsxs("div",{className:"luthor-source-panel",children:[S&&S.mode===a&&jsxs("div",{className:"luthor-source-error",children:[jsx("div",{className:"luthor-source-error-icon",children:"!"}),jsxs("div",{className:"luthor-source-error-message",children:[jsx("strong",{children:ge[a]}),jsx("p",{children:S.error}),jsx("small",{children:"Fix the source input and try again."})]})]}),a==="json"&&jsx(ga,{value:h.json,onChange:s=>{m(i=>({...i,json:s}));},placeholder:l.json,showLineNumbers:d}),a==="markdown"&&jsx(ga,{value:h.markdown,onChange:s=>{m(i=>({...i,markdown:s}));},placeholder:l.markdown,className:"luthor-source-view--wrapped",wrap:"soft",showLineNumbers:d}),a==="html"&&jsx(ga,{value:h.html,onChange:s=>{m(i=>({...i,html:s}));},placeholder:l.html,className:"luthor-source-view--wrapped",wrap:"soft",showLineNumbers:d})]})]})}var J=forwardRef(({className:r,variantClassName:l,initialTheme:d="light",onThemeChange:f,placeholder:L,onReady:t,defaultContent:u,showDefaultContent:p=true,initialMode:a="visual",defaultEditorView:H,showLineNumbers:h=true,featureFlags:m,...S},b$1)=>{let[v,e]=useState(d),E=H??a,C=te.includes(E)?E:"visual",w=useMemo(()=>Se(L),[L]),_=useMemo(()=>ve.resolve(m),[m]),T=useMemo(()=>JSON.stringify(_),[_]),j=useMemo(()=>{let s=JSON.parse(T);return sa({featureFlags:s,showLineNumbers:h})},[T,h]),[P,k]=useState(null),n=useRef(false);useEffect(()=>{e(d);},[d]),useEffect(()=>{f?.(v);},[v,f]),useImperativeHandle(b$1,()=>P??{injectJSON:()=>{},getJSON:()=>c("json",M),getMarkdown:()=>c("markdown",M),getHTML:()=>c("html",M)},[P]);let F=useCallback(s=>{k(s),n.current||(u&&s.injectJSON(u),n.current=true),t?.(s);},[u,t,p]);return jsx("div",{className:b("luthor-preset","luthor-preset-headless-editor","luthor-editor-wrapper","luthor-preset-headless-editor__variant",l,r),"data-editor-theme":v,children:jsx(me,{extensions:j,children:jsx(_e,{initialMode:C,placeholders:w,showLineNumbers:h,onReady:F})})})});J.displayName="HeadlessEditorPreset";var ke={id:"headless-editor",label:"Headless Editor",description:"Headless-style rich editor with text toolbar pills and source tabs.",extensions:sa({featureFlags:B}),components:{Editor:J},toolbar:["bold","italic","strikethrough","code","clearMarks","clearNodes","paragraph","h1","h2","h3","h4","h5","h6","unorderedList","orderedList","codeBlock","quote","horizontalRule","hardBreak","undo","redo"],config:ha("headless-editor","Start writing..."),css:"headless-editor/styles.css"};export{J as a,ke as b};
|
package/dist/chunk-CXFVQX2C.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a,b as b$1}from'./chunk-6UNJGUCM.js';import {Ea,ha,sa}from'./chunk-4DHY4VVC.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var E={bold:true,italic:true,underline:true,strikethrough:true,list:true,history:true,link:true,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,image:false,table:false,iframeEmbed:false,youTubeEmbed:false,emoji:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false},g=new a(E),o=forwardRef(({className:m,variantClassName:d,compactToolbar:t=false,toolbarClassName:p,featureFlags:c,...n},u)=>jsx("div",{className:b$1("luthor-preset-compose",m),children:jsx(Ea,{ref:u,...n,className:"luthor-preset-compose__editor",variantClassName:b$1(t?"luthor-preset-compose--compact":void 0,"luthor-preset-compose__variant",d),toolbarClassName:b$1(t?"luthor-preset-compose__toolbar--compact":void 0,p),availableModes:["visual-only","visual","json"],featureFlags:g.resolve(c)})}));o.displayName="ComposeEditor";var b={id:"compose",label:"Compose Editor",description:"Focused rich text drafting preset with a compact, practical toolbar.",extensions:sa({featureFlags:{image:false,table:false,iframeEmbed:false,youTubeEmbed:false,code:true,codeIntelligence:true,emoji:true,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false}}),components:{Editor:o},toolbar:["bold","italic","underline","strikethrough","link","unorderedList","orderedList","checkList","undo","redo"],config:ha("compose","Write your draft..."),css:"compose/styles.css"};export{o as a,b};
|
package/dist/chunk-H33QXH5Y.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a,b as b$1}from'./chunk-6UNJGUCM.js';import {ha,sa,Ea}from'./chunk-4DHY4VVC.js';import {jsx}from'react/jsx-runtime';var b=["visual-only","visual","json","markdown","html"],g={bold:true,italic:true,underline:true,strikethrough:true,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:true,horizontalRule:true,table:true,list:true,history:true,image:false,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:false,youTubeEmbed:false,slashCommand:true,draggableBlock:true,commandPalette:false,floatingToolbar:false,contextMenu:false,emoji:false,customNode:false,themeToggle:false},E={slashCommand:true,commandPalette:false},p=new a(g,E),t=["format.bold","format.italic","format.underline","format.strikethrough","format.code","block.paragraph","block.heading1","block.heading2","block.heading3","block.heading4","block.heading5","block.heading6","block.quote","block.codeblock","list.bullet","list.numbered","list.check","link.insert","insert.horizontal-rule","insert.table"],F={allowlist:t};function r({className:i,variantClassName:n,slashVisibility:d,isDraggableEnabled:u=true,featureFlags:m,isToolbarEnabled:c=false,...f}){let h={...p.resolve(m),draggableBlock:u};return jsx(Ea,{...f,className:b$1("luthor-preset-slash-editor",i),variantClassName:b$1("luthor-preset-slash-editor__variant",n),availableModes:b,isToolbarEnabled:c,slashCommandVisibility:d??F,featureFlags:h})}var T={id:"slash-editor",label:"Slash Editor",description:"Slash-first editing with curated commands and draggable block support.",extensions:sa({featureFlags:{bold:true,italic:true,underline:true,strikethrough:true,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:true,horizontalRule:true,table:true,list:true,history:true,image:false,blockFormat:true,code:true,codeIntelligence:true,codeFormat:true,tabIndent:true,enterKeyBehavior:true,iframeEmbed:false,youTubeEmbed:false,slashCommand:true,draggableBlock:true,floatingToolbar:false,contextMenu:false,commandPalette:false,emoji:false,customNode:false,themeToggle:false}}),components:{Editor:r},toolbar:[...t],config:ha("slash-editor","Type '/' for commands..."),css:"slash-editor/styles.css"};export{r as a,T as b};
|