@lyfie/luthor 2.6.7 → 2.7.0

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.
@@ -0,0 +1 @@
1
+ import {a,b as b$1}from'./chunk-RS22WMZX.js';import {ha,sa,Ea}from'./chunk-CVDX3AKZ.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};
@@ -0,0 +1,18 @@
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,o)=>t in e?pi(e,t,{enumerable:true,configurable:true,writable:true,value:o}):e[t]=o;var Bs=(e,t,o)=>bi(e,typeof t!="symbol"?t+"":t,o);var je=["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"]}]},Co={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)?xn(t):false}function xn(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"}function Tn(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 [...je];let t=new Set,o=[];for(let n of e)!je.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...je]}function $o(e,t){return Oi(qo(t),t?.shortcutConfig).filter(n=>!n.condition||n.condition(e))}function ne(e,t){return typeof e[t]=="function"}function vo(e){if(!e||e.length===0)return new Set;let t=e.map(o=>o.trim()).filter(o=>o.length>0);return new Set(t)}function Ii(e){if(!e)return {allowlist:new Set,denylist:new Set};if(Array.isArray(e)){let o=[];for(let n of e)for(let[i,r]of Object.entries(n))r&&o.push(i);return {allowlist:vo(o),denylist:new Set}}let t=e;return {allowlist:vo(t.allowlist),denylist:vo(t.denylist)}}function In(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],o=[];for(let n of t){let i=In(n);i&&o.push(i);}return o}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 o=vo(t.disabledCommandIds),n=t.bindings,i=t.preventNativeConflicts!==false,r=t.preventCollisions!==false,l=new Set;return e.filter(u=>!o.has(u.id)).map(u=>{let d=u.shortcuts?[...u.shortcuts]:void 0;if(!!n&&Object.prototype.hasOwnProperty.call(n,u.id)&&n){let C=n[u.id],k=C===void 0?[]:Fi(C);d=k.length>0?k:void 0;}if(d&&d.length>0){let C=[];for(let k of d){let g=In(k);if(!g||i&&xn(g))continue;let f=Mi(g);r&&l.has(f)||(l.add(f),C.push(g));}d=C.length>0?C:void 0;}return {...u,shortcuts:d}})}function qo(e){let t=e?.isFeatureEnabled??(()=>true),o=xi(e?.headingOptions),n=e?.paragraphLabel?.trim()||"Paragraph",i=o.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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(r,"formatText")},{id:"block.paragraph",label:n,description:"Convert to paragraph",category:"Block",action:r=>r.toggleParagraph?.(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"],condition:r=>t("blockFormat")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&Tn(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")&&Tn(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(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")&&ne(r,"showCommandPalette")}]}function Fn(e,t){let o=t?.commandPaletteShortcutOnly===true;return $o(e,t).filter(n=>!o||!!n.shortcuts&&n.shortcuts.length>0).map(n=>({id:n.id,label:n.label,description:n.description,category:n.category,action:()=>n.action(e),keywords:n.keywords,shortcut:n.shortcuts?.[0]?On(n.shortcuts[0]):void 0}))}function Mn(e,t){let o=new Set(["block.paragraph","block.quote","block.codeblock"]),n=s=>s.category==="Insert"||s.category==="List"?true:s.category==="Block"?s.id.startsWith("block.heading")?true:o.has(s.id):false,{allowlist:i,denylist:r}=Ii(t?.slashCommandVisibility),l=i.size>0;return $o(e,t).filter(s=>r.has(s.id)?false:l?i.has(s.id):n(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]?On(s.shortcuts[0]):void 0}))}function On(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 Nn(e,t=document.body,o){let n=$o(e,o),i=(l,s)=>l.key.toLowerCase()===s.key.toLowerCase()||s.key==="`"&&l.code==="Backquote",r=l=>{let s=typeof o?.scope=="function"?o.scope():o?.scope;if(!(s&&l.target instanceof Node&&!s.contains(l.target))){for(let u of n)if(u.shortcuts){for(let d of u.shortcuts)if(!(o?.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 o=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 o.displayName=e,o}var Eo=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"})),ko=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"})]})),Lo=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"})]})),wo=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"})]})),So=U("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),Hn=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"})]})),xt=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"})]})),Qt=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"})]})),Zt=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"})]})),eo=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"})]})),Rn=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"})]})),Pn=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"})]})),Yo=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"})]})),It=U("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),An=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"})]})),Jo=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"})]})),zn=U("MinusIcon",jsx("path",{d:"M5 12h14"})),Dn=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"})]})),Bn=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"})]})),Un=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"})]})),To=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"})),Kn=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"})]})),_n=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"})]})),xo=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"})]})),Vn=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"})]})),jn=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"})]})),$n=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"})]})),qn=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"})),Yn=U("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Go=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"})]})),Jn=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"})]})),Gn=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"})),Wn=U("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Zn({isOpen:e,onClose:t,commands:o}){let[n,i]=useState(""),[r,l]=useState(0),s=useRef(null),u=useRef(null),d=o.filter(k=>`${k.label} ${k.description||""} ${k.keywords?.join(" ")||""}`.toLowerCase().includes(n.toLowerCase())),v=d.reduce((k,g)=>{let f=g.category||"Other";return k[f]||(k[f]=[]),k[f].push(g),k},{}),C=d;return useEffect(()=>{l(0);},[n]),useEffect(()=>{e&&s.current&&(s.current.focus({preventScroll:true}),i(""),l(0));},[e]),useEffect(()=>{if(!e)return;let k=u.current;if(!k)return;k.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,n]),useEffect(()=>{let k=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,C.length-1));break;case "ArrowUp":g.preventDefault(),g.stopPropagation(),l(f=>Math.max(f-1,0));break;case "Enter":g.preventDefault(),g.stopPropagation(),C[r]&&(C[r].action(),t());break}};return document.addEventListener("keydown",k,true),()=>document.removeEventListener("keydown",k,true)},[e,r,C,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:k=>k.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(Yn,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:s,type:"text",placeholder:"Type a command or search...",value:n,onChange:k=>i(k.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(([k,g])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:k}),g.map(f=>{let h=C.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)})]},k))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(To,{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 Pi(e){return e?Ri(e)??e:null}function Ai(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),o={};for(let[n,i]of Object.entries(Hi)){let r=t.getPropertyValue(n).trim()||i;o[n]=r;}return o}function $e(e){return Ai(Pi(e))}function _t(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return $e(o)}function Ft(e){return e?e.closest(".luthor-editor-wrapper")??null:null}function er(e,t,o){return e<t?t:e>o?o:e}function zi(e){if(!e||typeof window>"u"){let o=typeof window>"u"?0:window.innerWidth,n=typeof window>"u"?0:window.innerHeight;return {left:0,top:0,right:o,bottom:n,width:o,height:n}}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,o,n,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=o.left+n,v=Math.max(d,o.right-t-n);if(r){let C=u<d||u>v,k=s>=d&&s<=v;C&&k&&(u=s);}return er(u,d,v)}function Bi(e,t,o,n,i,r,l){let s=r==="top"?e.top-t-n:e.bottom+n,u=r==="top"?e.bottom+n:e.top-t-n,d=s,v=o.top+i,C=Math.max(v,o.bottom-t-i);if(l){let k=d<v||d>C,g=u>=v&&u<=C;k&&g&&(d=u);}return er(d,v,C)}function ke({anchorRect:e,overlay:t,portalContainer:o=null,gap:n=4,margin:i=8,preferredX:r="start",preferredY:l="bottom",flipX:s=true,flipY:u=true}){let d=zi(o),v=Math.max(0,d.width-i*2),C=Math.max(0,d.height-i*2),k=Math.max(0,Math.min(t.width,v)),g=Math.max(0,Math.min(t.height,C)),f=Di(e,k,d,i,r,s),h=Bi(e,g,d,n,i,l,u);if(o){let F=o.getBoundingClientRect();return {position:"absolute",left:f-F.left+o.scrollLeft,top:h-F.top+o.scrollTop,maxWidth:v>0?v:void 0,maxHeight:C>0?C:void 0}}return {position:"fixed",left:f,top:h,maxWidth:v>0?v:void 0,maxHeight:C>0?C:void 0}}function Fo(e,t){return {x:e,y:t,width:1,height:1,left:e,right:e+1,top:t,bottom:t+1,toJSON:()=>({})}}function or({isOpen:e,query:t,position:o,portalContainer:n,suggestions:i,onClose:r,onExecute:l}){let[s,u]=useState(0),d=useRef(null),[v,C]=useState(void 0);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let f=h=>{let F=i.length>0;switch(h.key){case "Escape":h.preventDefault(),h.stopPropagation(),r();break;case "ArrowDown":if(!F)return;h.preventDefault(),h.stopPropagation(),u(p=>Math.min(p+1,Math.max(i.length-1,0)));break;case "ArrowUp":if(!F)return;h.preventDefault(),h.stopPropagation(),u(p=>Math.max(p-1,0));break;case "Enter":case "Tab":if(!F||!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 k=useCallback(f=>{if(!o)return;let h=d.current?.getBoundingClientRect(),F=ke({anchorRect:Fo(o.x,o.y),overlay:{width:h?.width??320,height:h?.height??280},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});C({...F,visibility:f?"visible":"hidden",..._t()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;k(false);let f=window.requestAnimationFrame(()=>k(true));return ()=>window.cancelAnimationFrame(f)},[e,o,k]),useEffect(()=>{if(!e||!o)return;let f=()=>k(true);return window.addEventListener("resize",f),window.addEventListener("scroll",f,true),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,true);}},[e,o,k]),!e||!o)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 F=h===s,p=f.shortcodes[0]?`:${f.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${F?"selected":""}`,onMouseEnter:()=>u(h),onMouseDown:L=>{L.preventDefault(),L.stopPropagation();},onClick:L=>{L.preventDefault(),L.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}),p&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:p})]})]},`${f.emoji}-${f.label}`)})})]});return typeof document>"u"?g:createPortal(g,n??document.body)}var Qo=360,Yi=.5,Ji=420;function lr(){if(typeof window>"u")return Qo;let e=Math.floor(window.innerHeight*Yi);return e<=0?Qo:Math.min(Qo,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:o,portalContainer:n,commands:i,onClose:r,onExecute:l}){let[s,u]=useState(0),d=useRef(null),[v,C]=useState(void 0),k=useRef(false),g=useMemo(()=>{let p=t.trim().toLowerCase();return p?i.filter(L=>`${L.label} ${L.description||""} ${L.keywords?.join(" ")||""}`.toLowerCase().includes(p)):i},[i,t]),f=useMemo(()=>g.reduce((p,L)=>{let I=L.category||"Other";return p[I]||(p[I]=[]),p[I].push(L),p},{}),[g]);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let p=L=>{let I=g.length>0;switch(L.key){case "Escape":L.preventDefault(),L.stopPropagation(),r();break;case "ArrowDown":if(!I)return;L.preventDefault(),L.stopPropagation(),u(M=>Math.min(M+1,Math.max(g.length-1,0)));break;case "ArrowUp":if(!I)return;L.preventDefault(),L.stopPropagation(),u(M=>Math.max(M-1,0));break;case "Enter":case "Tab":if(!I||!g[s])return;L.preventDefault(),L.stopPropagation(),l(g[s].id);break}};return document.addEventListener("keydown",p,true),()=>document.removeEventListener("keydown",p,true)},[g,e,r,l,s]);let h=useCallback(p=>{if(!o)return;let L=lr(),I=d.current?.getBoundingClientRect(),M=ke({anchorRect:Fo(o.x,o.y),overlay:{width:I?.width??Ji,height:Math.min(I?.height??L,L)},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});C({...M,maxHeight:Gi(M.maxHeight),visibility:p?"visible":"hidden",..._t()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o){k.current=false;return}if(!k.current){k.current=true,h(false);let p=window.requestAnimationFrame(()=>h(true));return ()=>window.cancelAnimationFrame(p)}h(true);},[e,o,h]),useEffect(()=>{if(!e||!o)return;let p=()=>h(true);return window.addEventListener("resize",p),window.addEventListener("scroll",p,true),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,true);}},[e,o,h]),!e||!o)return null;let F=jsxs("div",{className:"luthor-slash-menu",ref:d,style:v,onPointerDown:p=>{p.stopPropagation();},onMouseDown:p=>{p.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(([p,L])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:p}),L.map(I=>{let M=g.indexOf(I);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${M===s?"selected":""}`,onMouseEnter:()=>u(M),onMouseDown:Z=>{Z.preventDefault(),Z.stopPropagation();},onClick:Z=>{Z.preventDefault(),Z.stopPropagation(),l(I.id);},children:[jsxs("span",{className:"luthor-slash-menu-item-content",children:[jsx("span",{className:"luthor-slash-menu-item-title",children:I.label}),I.description&&jsx("span",{className:"luthor-slash-menu-item-description",children:I.description})]}),I.shortcut&&jsx("kbd",{className:"luthor-slash-menu-item-shortcut",children:I.shortcut})]},I.id)})]},p))})]});return typeof document>"u"?F:createPortal(F,n??document.body)}function H({children:e,onClick:t,title:o,active:n,disabled:i,className:r,type:l="button"}){return jsx("button",{type:l,className:`luthor-toolbar-button${n?" active":""}${r?` ${r}`:""}`,onClick:t,title:o,disabled:i,children:e})}function Zo({children:e,onClick:t,variant:o="primary",type:n="button",className:i}){return jsx("button",{type:n,onClick:t,className:`${o==="primary"?"luthor-button-primary":"luthor-button-secondary"}${i?` ${i}`:""}`,children:e})}function io({value:e,onValueChange:t,options:o,placeholder:n="Select..."}){let[i,r]=useState(false),[l,s]=useState(void 0),[u,d]=useState(null),v=useRef(null),C=useRef(null);useEffect(()=>{if(!i)return;let g=()=>{let h=v.current?.querySelector(".luthor-select-trigger");if(!h)return;let F=h.getBoundingClientRect(),p=C.current?.getBoundingClientRect(),L=Math.max(p?.width??0,C.current?.scrollWidth??0),I=Ft(h);d(I);let M=Math.max(F.width,L),R=p?.height??220,Z=ke({anchorRect:F,overlay:{width:M,height:R},portalContainer:I,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});s({...Z,width:M,...$e(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=Ft(g);d(h);let F=ke({anchorRect:f,overlay:{width:f.width,height:220},portalContainer:h,gap:4,margin:8});s({...F,width:f.width,...$e(g)});let p=window.requestAnimationFrame(()=>{let L=C.current?.getBoundingClientRect(),I=Math.max(L?.width??0,C.current?.scrollWidth??0),M=Math.max(f.width,I),R=ke({anchorRect:f,overlay:{width:M,height:L?.height??220},portalContainer:h,gap:4,margin:8});s({...R,width:M,...$e(g)});});return ()=>window.cancelAnimationFrame(p)},[i]),useEffect(()=>{function g(f){let h=f.target;v.current?.contains(h)||C.current?.contains(h)||r(false);}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);let k=o.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:k?.label||n}),jsx(Ut,{size:14})]}),i&&typeof document<"u"&&createPortal(jsx("div",{ref:C,className:"luthor-select-dropdown",style:l,children:o.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:o,onOpenChange:n}){let i=useRef(null),r=useRef(null),l=useRef(null),[s,u]=useState(void 0),[d,v]=useState(null);return useEffect(()=>{if(!o)return;let C=()=>{let g=r.current;if(!g)return;let f=g.getBoundingClientRect(),h=l.current?.getBoundingClientRect(),F=Ft(g);v(F);let p=ke({anchorRect:f,overlay:{width:h?.width??220,height:h?.height??200},portalContainer:F,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});u({...p,...$e(g)});},k=()=>C();return window.addEventListener("resize",k),window.addEventListener("scroll",k,true),()=>{window.removeEventListener("resize",k),window.removeEventListener("scroll",k,true),v(null);}},[o]),useLayoutEffect(()=>{if(!o)return;let C=r.current;if(!C)return;let k=C.getBoundingClientRect(),g=Ft(C);v(g);let f=ke({anchorRect:k,overlay:{width:220,height:200},portalContainer:g,gap:4,margin:8});u({...f,...$e(C)});let h=window.requestAnimationFrame(()=>{let F=l.current?.getBoundingClientRect(),p=ke({anchorRect:k,overlay:{width:F?.width??220,height:F?.height??200},portalContainer:g,gap:4,margin:8});u({...p,...$e(C)});});return ()=>window.cancelAnimationFrame(h)},[o]),useEffect(()=>{function C(k){let g=k.target;i.current?.contains(g)||l.current?.contains(g)||n(false);}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[n]),jsxs("div",{className:"luthor-dropdown",ref:i,children:[jsx("div",{ref:r,onClick:()=>n(!o),children:e}),o&&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:o,children:n}){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:o}),jsx("button",{className:"luthor-dialog-close",onClick:t,type:"button",children:jsx(Wn,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:n})]})}):null}function dr({isVisible:e,selectionRect:t,commands:o,activeStates:n,editorTheme:i="light",hide:r,isFeatureEnabled:l=()=>true}){let u=useRef(null),[d,v]=useState(""),[C,k]=useState(""),[g,f]=useState(""),[h,F]=useState(""),[p,L]=useState(""),[I,M]=useState(""),[R,Z]=useState(null),[le,fe]=useState(null),[K,E]=useState(null),w=!!n.isIframeEmbedSelected,T=!!n.isYouTubeEmbedSelected,D=l("iframeEmbed"),V=l("youTubeEmbed"),se=l("image"),ye=D&&w||V&&T;if(useEffect(()=>{if(!e)return;let P=G=>{let ce=G.target;ce&&(u.current?.contains(ce)||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||!w)return;let P=false;return typeof o.getIframeEmbedCaption=="function"&&o.getIframeEmbedCaption().then(G=>{P||k(G??"");}),typeof o.getIframeEmbedUrl=="function"&&o.getIframeEmbedUrl().then(G=>{P||v(G??"");}),Z(null),()=>{P=true;}},[o,w,e]),useEffect(()=>{if(!e||!n.imageSelected)return;let P=false;return typeof o.getImageCaption=="function"&&o.getImageCaption().then(G=>{P||f(G??"");}),()=>{P=true;}},[n.imageSelected,o,e]),useEffect(()=>{if(!e||!T)return;let P=false;return typeof o.getYouTubeEmbedCaption=="function"&&o.getYouTubeEmbedCaption().then(G=>{P||F(G??"");}),typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(G=>{P||L(G??"");}),fe(null),()=>{P=true;}},[o,e,T]),useEffect(()=>{if(!e||!n.isLink)return;let P=false;return typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(G=>{!P&&G&&M(G.url??"");}),E(null),()=>{P=true;}},[n.isLink,o,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(ye){let P=Q=>{if(w){o.setIframeEmbedAlignment?.(Q);return}T&&o.setYouTubeEmbedAlignment?.(Q);},G=w?n.isIframeEmbedAlignedLeft:n.isYouTubeEmbedAlignedLeft,ce=w?n.isIframeEmbedAlignedCenter:n.isYouTubeEmbedAlignedCenter,Ze=w?n.isIframeEmbedAlignedRight:n.isYouTubeEmbedAlignedRight,et=w?typeof o.setIframeEmbedCaption=="function":typeof o.setYouTubeEmbedCaption=="function",Je=w?typeof o.updateIframeEmbedUrl=="function":typeof o.updateYouTubeEmbedUrl=="function",Be=w?C:h,he=w?k:F,it=w?d:p,te=w?R:le,Oe=()=>{if(et){if(w){o.setIframeEmbedCaption?.(C);return}o.setYouTubeEmbedCaption?.(h);}},Ce=Q=>{w?Z(Q):fe(Q);},Ge=Q=>{w?v(Q):L(Q);},lt=()=>{if(!Je)return;if(!(w?o.updateIframeEmbedUrl?.(d)??false:o.updateYouTubeEmbedUrl?.(p)??false)){Ce(w?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),w&&typeof o.getIframeEmbedUrl=="function"?o.getIframeEmbedUrl().then(ve=>v(ve??"")):!w&&typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(ve=>L(ve??""));return}Ce(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:pe,children:[jsx(H,{onClick:()=>P("left"),active:G,title:"Align Left",children:jsx(Dt,{size:14})}),jsx(H,{onClick:()=>P("center"),active:ce,title:"Align Center",children:jsx(It,{size:14})}),jsx(H,{onClick:()=>P("right"),active:Ze,title:"Align Right",children:jsx(Bt,{size:14})}),et||Je?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[Je?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:it,className:`luthor-floating-toolbar-input${te?" is-error":""}`,placeholder:w?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":w?"Iframe URL":"YouTube URL","aria-invalid":te?true:void 0,onChange:Q=>{Ge(Q.target.value),te&&Ce(null);},onBlur:lt,onKeyDown:Q=>{Q.key==="Enter"&&(Q.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,et?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:Be,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":w?"Iframe caption":"YouTube caption",onChange:Q=>he(Q.target.value),onBlur:Oe,onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),Oe());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:Oe,children:"Update Caption"})]}):null]})]}):null]})}if(se&&n.imageSelected){let P=typeof o.setImageCaption=="function",G=()=>{P&&o.setImageCaption(g);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:pe,children:[jsx(H,{onClick:()=>o.setImageAlignment("left"),active:n.isImageAlignedLeft,title:"Align Left",children:jsx(Dt,{size:14})}),jsx(H,{onClick:()=>o.setImageAlignment("center"),active:n.isImageAlignedCenter,title:"Align Center",children:jsx(It,{size:14})}),jsx(H,{onClick:()=>o.setImageAlignment("right"),active:n.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:ce=>f(ce.target.value),onBlur:G,onKeyDown:ce=>{ce.key==="Enter"&&(ce.preventDefault(),G());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:G,children:"Update Caption"})]})]}):null]})}let X=l("bold"),ee=l("italic"),J=l("underline"),ge=l("strikethrough"),O=l("codeFormat"),ze=!!(n.unorderedList||n.orderedList||n.checkList),Me=l("blockFormat")&&!ze,be=l("link"),Qe=l("list")&&!ze,qe=X||ee||J||ge,we=O||Me||be,Se=Qe,Ye=!!n.isLink&&typeof o.updateLink=="function"&&typeof o.removeLink=="function",De=()=>{if(!Ye)return;if(!(o.updateLink?.(I)??false)){E("Enter a valid URL"),typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(G=>{M(G?.url??"");});return}E(null);};return !qe&&!we&&!Se?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:pe,children:[qe?jsxs(Fragment,{children:[X?jsx(H,{onClick:()=>o.toggleBold(),active:n.bold,title:"Bold",children:jsx(Eo,{size:14})}):null,ee?jsx(H,{onClick:()=>o.toggleItalic(),active:n.italic,title:"Italic",children:jsx(ko,{size:14})}):null,J?jsx(H,{onClick:()=>o.toggleUnderline(),active:n.underline,title:"Underline",children:jsx(Lo,{size:14})}):null,ge?jsx(H,{onClick:()=>o.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(wo,{size:14})}):null]}):null,qe&&we?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,we?jsxs(Fragment,{children:[O?jsx(H,{onClick:()=>o.formatText("code"),active:n.code,disabled:n.isInCodeBlock,title:"Inline Code",children:jsx(So,{size:14})}):null,Me?jsx(H,{onClick:()=>o.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(xo,{size:14})}):null,be?jsxs(Fragment,{children:[jsx(H,{onClick:()=>n.isLink?o.removeLink():o.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(xt,{size:14}):jsx(zt,{size:14})}),Ye?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:I,className:`luthor-floating-toolbar-input${K?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":K?true:void 0,onChange:P=>{M(P.target.value),K&&E(null);},onBlur:De,onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),De());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:De,children:"Update Link"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-danger",onClick:()=>o.removeLink(),"aria-label":"Unlink",children:jsx(xt,{size:13})})]}):null]}):null]}):null,(qe||we)&&Se?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,Se?jsxs(Fragment,{children:[jsx(H,{onClick:()=>o.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(Qt,{size:14})}),jsx(H,{onClick:()=>o.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(eo,{size:14})}),jsx(H,{onClick:()=>o.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(Zt,{size:14})})]}):null]})}var nt={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function en(e,t,o,n=()=>true){nt.commands=e,nt.activeStates=t,nt.editorTheme=o,nt.isFeatureEnabled=n;}function mr(){let e=dr,t=new FloatingToolbarExtension;return t.config={...t.config,render:o=>createElement(e,{...o,commands:nt.commands,activeStates:nt.activeStates,editorTheme:nt.editorTheme,isFeatureEnabled:nt.isFeatureEnabled}),getCommands:()=>nt.commands,getActiveStates:()=>nt.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 o=e.closest("a");return !(o instanceof HTMLAnchorElement)||!t.contains(o)?null:o}function br({editor:e,commands:t,editorTheme:o="light",disabled:n=false}){let i=useRef(null),r=useRef(null),l=useRef(null),s=useRef(null),[u,d]=useState(null),[v,C]=useState(false),[k,g]=useState(""),[f,h]=useState(null),[F,p]=useState(null),[L,I]=useState(null),M=useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]),R=useCallback(()=>{M(),d(null),C(false),g(""),h(null),p(null);},[M]),Z=useCallback(()=>{M(),s.current=window.setTimeout(()=>{R();},rl);},[M,R]),le=useCallback((T,D)=>{let V=T.getBoundingClientRect(),se=i.current?.getBoundingClientRect(),ye=ke({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});p({top:typeof ye.top=="number"?ye.top:0,left:typeof ye.left=="number"?ye.left:0});},[]),fe=useCallback((T,D)=>{if(typeof t.getLinkByKey!="function"){d(V=>!V||V.nodeKey!==T?V:{...V,url:D});return}t.getLinkByKey(T).then(V=>{if(!V){R();return}d(se=>!se||se.nodeKey!==T?se:{...se,url:V.url});});},[t,R]);useEffect(()=>{if(!e||n||typeof window>"u"){R(),I(null),r.current=null;return}let T=e.getRootElement();if(!T){R(),I(null),r.current=null;return}let D=T.closest(".luthor-editor-wrapper")??null;I(D),r.current=D;let V=ee=>{let J=fr(ee.target,T);if(!J)return;if(gr()){R();return}M();let ge=resolveLinkNodeKeyFromAnchor(e,J);if(!ge)return;let O=J.getAttribute("href")??J.href;d({nodeKey:ge,url:O,anchorEl:J}),le(J,r.current),h(null),v||g(O),fe(ge,O);},se=ee=>{if(!u)return;let J=ee.relatedTarget;J&&i.current?.contains(J)||fr(J,T)||Z();},ye=()=>{gr()&&R();},pe=()=>{d(ee=>{if(!ee)return ee;let J=ee.anchorEl.isConnected&&T.contains(ee.anchorEl)?ee.anchorEl:T.querySelector(`a[data-lexical-node-key="${ee.nodeKey}"]`);return J?(le(J,r.current),{...ee,anchorEl:J,url:J.getAttribute("href")??J.href}):(R(),null)});},X=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,pe();}));};return T.addEventListener("mouseover",V),T.addEventListener("mouseout",se),document.addEventListener("selectionchange",ye),window.addEventListener("scroll",X,true),window.addEventListener("resize",X),()=>{T.removeEventListener("mouseover",V),T.removeEventListener("mouseout",se),document.removeEventListener("selectionchange",ye),window.removeEventListener("scroll",X,true),window.removeEventListener("resize",X),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),M();}},[t,n,e,u,v,R,Z,fe,le,M]),useLayoutEffect(()=>{u&&le(u.anchorEl,r.current);},[u,v,le]);let K=useMemo(()=>{if(!(!u||!F))return {...$e(u.anchorEl),position:L?"absolute":"fixed",top:F.top,left:F.left,zIndex:"var(--luthor-z-menu, 460)"}},[u,F,L]);if(!u||!F||typeof document>"u")return null;let E=()=>{(t.removeLinkByKey?.(u.nodeKey)??false)&&R();},w=()=>{let T=k.trim();if(!(t.updateLinkByKey?.(u.nodeKey,T)??false)){h("Enter a valid URL"),fe(u.nodeKey,u.url);return}d(V=>!V||V.nodeKey!==u.nodeKey?V:{...V,url:T}),h(null),C(false),queueMicrotask(()=>{fe(u.nodeKey,T);});};return createPortal(jsx("div",{ref:i,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":o,style:K,onMouseEnter:M,onMouseLeave:Z,children:v?jsxs(Fragment,{children:[jsx("input",{type:"url",value:k,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:T=>{g(T.target.value),f&&h(null);},onKeyDown:T=>{if(T.key==="Enter"){T.preventDefault(),w();return}T.key==="Escape"&&(T.preventDefault(),C(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:w,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{C(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),C(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:E,"aria-label":"Unlink",children:jsx(xt,{size:13})})]})}),L??document.body)}var sl=400,ul=14,cl=.6,tn=2;function dl(e){return e?e.split(`
2
+ `):[""]}function on(e){return Array.from({length:Math.max(1,e)},(t,o)=>`${o+1}`).join(`
3
+ `)}function nn(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function ml(e){let o=(nn(e.fontSize)||ul)*cl;if(typeof document>"u")return o;try{if(!document.body)return o;let n="0000000000",i=document.createElement("span");i.textContent=n,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/n.length}catch{return o}return o}function gl(e){let t=window.getComputedStyle(e),o=nn(t.paddingLeft)+nn(t.paddingRight),n=Math.max(0,e.clientWidth-o);if(n<=0)return 0;let i=ml(t);return i<=0?0:Math.max(1,Math.floor(n/i))}function fl(e){let t=window.getComputedStyle(e),o=Number.parseInt(t.tabSize,10);return Number.isFinite(o)&&o>0?o:tn}function hl(e,t,o){if(t<=0)return 1;let n=0;for(let i of e){if(i===" "){let r=n%o,l=r===0?o:o-r;n+=l;continue}n+=1;}return Math.max(1,Math.ceil(n/t))}function pl(e,t,o){if(t<=0)return on(e.length);let n=[];for(let i=0;i<e.length;i+=1){n.push(`${i+1}`);let r=hl(e[i]??"",t,o);for(let l=1;l<r;l+=1)n.push("");}return n.join(`
4
+ `)}function Lr({mode:e,onModeChange:t,labels:o,availableModes:n,isConverting:i}){let r=h=>h==="visual"?"visual-editor":h,l=(n??[]).includes("visual-editor")?"visual-editor":"visual",s=h=>h==="visual-editor"?l:h,u=["visual-only","visual-editor","json","markdown","html"],d=n??["visual-only","visual-editor","json","markdown","html"],v=new Set(d.map(r)),C=u.filter(h=>v.has(h)),k=r(e),g=i?r(i):null,f={"visual-only":o?.["visual-only"]??"Visual Only","visual-editor":o?.["visual-editor"]??o?.visual??"Visual Editor",json:o?.json??"JSON",markdown:o?.markdown??"Markdown",html:o?.html??"HTML"};return jsx("div",{className:"luthor-mode-tabs",children:C.map(h=>jsxs("button",{className:`luthor-mode-tab ${k===h?"active":""}`,onClick:()=>t(s(h)),children:[f[h],g===h&&jsx("span",{className:"luthor-tab-converting-spinner"})]},h))})}function Oo({value:e,onChange:t,placeholder:o,className:n,wrap:i,showLineNumbers:r=true}){let l=useRef(null),s=useRef(null),u=(i??"off")!=="off",d=useMemo(()=>dl(e),[e]),v=d.length,[C,k]=useState(0),[g,f]=useState(tn),h=useCallback(()=>{if(!r||!u){k(0),f(tn);return}let L=l.current;if(!L)return;let I=gl(L),M=fl(L);k(R=>R===I?R:I),f(R=>R===M?R:M);},[u,r]),F=useMemo(()=>!u||C<=0?on(v):pl(d,C,g),[u,v,d,C,g]),p=`luthor-source-view${n?` ${n}`:""}`;return useLayoutEffect(()=>{let L=l.current;if(!L)return;L.style.height="auto";let I=Math.max(0,L.offsetHeight-L.clientHeight),M=Math.max(L.scrollHeight+I+1,sl);L.style.height=`${M}px`;},[e]),useLayoutEffect(()=>{h();},[h,e]),useEffect(()=>{if(!r||!u)return;let L=l.current;if(!L||typeof ResizeObserver>"u")return;let I=new ResizeObserver(()=>{h();});return I.observe(L),()=>{I.disconnect();}},[u,h,r]),useEffect(()=>{if(!r)return;let L=l.current,I=s.current;if(!L||!I)return;let M=()=>{I.scrollTop=L.scrollTop;};return M(),L.addEventListener("scroll",M,{passive:true}),()=>{L.removeEventListener("scroll",M);}},[F,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:F}),jsx("textarea",{ref:l,className:`${p} luthor-source-view--with-line-numbers`,value:e,onChange:L=>t(L.target.value),placeholder:o,spellCheck:false,wrap:i??"off"})]}):jsx("textarea",{ref:l,className:p,value:e,onChange:L=>t(L.target.value),placeholder:o,spellCheck:false,wrap:i??"off"})}function Sr(e,t){let o=`luthor-preset-${e}`;return {placeholder:t,classNames:{container:`luthor-preset ${o} ${o}__container`,contentEditable:`luthor-content-editable ${o}__content`,placeholder:`luthor-placeholder ${o}__placeholder`}}}function Ho(e){return e.replace(/\r\n?/g,`
5
+ `)}function bl(e){return e.replace(/&#(9|10|13|32|160);/g,(t,o)=>{switch(o){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 o=t.replace(/([*~])/g,"\\$1"),n=e;return n=n.replace(new RegExp(`${o}(\\s+)([^\\n]+?)${o}`,"g"),(i,r,l)=>`${r}${t}${l}${t}`),n=n.replace(new RegExp(`${o}([^\\n]+?)(\\s+)${o}`,"g"),(i,r,l)=>`${t}${r}${t}${l}`),n}function Cl(e){return ["***","**","~~","*"].reduce((o,n)=>yl(o,n),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,Ro=3,wl=8;function Tr(e){return e.nodeType===Ll}function rn(e){return e.nodeType===Ro&&(e.textContent??"").trim().length>0}function No(e){return e.tagName.toLowerCase()}function xr(e){return Array.from(e.childNodes).filter(t=>t.nodeType!==Ro?true:rn(t))}function Sl(e){let t=e.outerHTML,o=t.indexOf(">");return o===-1?`<${No(e)}>`:t.slice(0,o+1)}function Tl(e){let t=No(e);if(vl.has(t)||El.has(t))return false;let o=xr(e);if(o.length===0||o.some(rn))return false;let n=o.filter(Tr);return n.length===0?false:n.every(i=>kl.has(No(i)))}function Ir(e,t){let o=" ".repeat(Math.max(t,0));if(e.nodeType===wl)return `${o}<!--${e.data}-->`;if(e.nodeType===Ro){let r=Ho(e.textContent??"");return r.trim()?`${o}${r.trim()}`:null}if(!Tr(e))return null;if(!Tl(e))return `${o}${e.outerHTML}`;let n=No(e),i=[`${o}${Sl(e)}`];for(let r of xr(e)){let l=Ir(r,t+1);l&&i.push(l);}return i.push(`${o}</${n}>`),i.join(`
7
+ `)}function xl(e){if(typeof DOMParser>"u")return e;let t=new DOMParser().parseFromString(e,"text/html"),n=Array.from(t.body.childNodes).filter(i=>i.nodeType!==Ro?true:rn(i)).map(i=>Ir(i,0)).filter(i=>typeof i=="string"&&i.length>0);return n.length===0?t.body.innerHTML.trim()||e:n.join(`
8
+ `)}function Fr(e){let t=Ho(e).trim();if(!t)return "";try{let o=JSON.parse(t);return JSON.stringify(o,null,2)}catch{return t}}function Mr(e){return Cl(bl(Ho(e))).trim()}function Or(e){let t=Ho(e).trim();if(!t)return "";try{return xl(t)}catch{return t}}var an=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 Pl({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 Al({pattern:e}){let t=Rl(e),o=[12.5,24.5,36.5,48.5,60.5],n=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"}),o.map((r,l)=>{let s=n[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(Pl,{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],o=[0,1,1,2,0],n=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=o[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:n[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 Ao(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Dl(e,t){let o=Ao(t);for(let n of e)if(Ao(n.value)===o)return n.color;return null}function Bl(e,t,o){if(!e||e==="default")return o;let n=Dl(t,e);return n||e}function Ul(e,t){let o=e.trim();return /^#([\da-f]{6})$/i.test(o)?o:/^#([\da-f]{3})$/i.test(o)?`#${o.slice(1).split("").map(i=>`${i}${i}`).join("")}`:t}var sn="Inherited",Po="16px",un="1.5";function Le(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Rr(e){let t=e.split(",")[0]??"";return Le(t.replace(/["']/g,""))}function zo(e){let t=e.trim().toLowerCase().match(/^(-?\d*\.?\d+)px$/);if(!t)return null;let o=Number(t[1]);return Number.isFinite(o)?o:null}function Ot(){if(typeof window>"u")return null;let t=window.getSelection()?.anchorNode;if(!t)return null;let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!o||!o.closest(".luthor-content-editable"))return null;let i=window.getComputedStyle(o);return {fontFamily:i.fontFamily,fontSize:i.fontSize,lineHeight:i.lineHeight}}function ln(){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 Pr(e){return (e.split(",")[0]?.trim()??"").replace(/^['"]|['"]$/g,"").trim()}function Kl(e,t){let o=Le(e);if(o&&o!=="inherit"){let i=Pr(e);if(i)return i}return Pr(t?.fontFamily??"")||sn}function _l(e,t){let o=Le(e);return o&&o!=="inherit"?e.trim():(t?.fontSize??"").trim()||Po}function Vl(e,t){let o=Le(e);return o&&o!=="normal"?e.trim():(t?.lineHeight??"").trim()||un}function jl(e,t){if(!e)return null;let o=Rr(e);return o?t.find(i=>Le(i.value)===o?true:Rr(i.fontFamily)===o)?.value??null:null}function $l(e,t){if(!e)return null;let o=Le(e),n=t.find(l=>Le(String(l.value))===o?true:Le(String(l.fontSize))===o);if(n)return String(n.value);let i=zo(e);if(i==null)return null;let r=null;for(let l of t){let s=zo(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,o){if(!e)return null;let n=Le(e),i=o.find(d=>Le(d.value)===n?true:Le(d.lineHeight)===n);if(i)return i.value;let r=t?zo(t):null,l=zo(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 o){let v=Number(d.lineHeight);if(!Number.isFinite(v))continue;let C=Math.abs(v-s);(!u||C<u.distance)&&(u={value:d.value,distance:C});}return u?.value??null}function Ar({title:e,value:t,options:o,recentColors:n,active:i,fallbackColor:r,highlight:l,onChange:s,onClear:u,onAddRecent:d}){let v=useRef(null),C=useRef(null),k=useRef(null),g=useRef(null),f=useRef(null),[h,F]=useState(false),[p,L]=useState(void 0),[I,M]=useState(null),R=Bl(t,o,r),Z=useMemo(()=>Ol,[]),le=useMemo(()=>{let E=[...n].slice(0,an);for(;E.length<an;)E.push("");return E},[n]);useEffect(()=>()=>{g.current&&window.cancelAnimationFrame(g.current);},[]);let fe=useCallback(E=>{f.current=E,!g.current&&(g.current=window.requestAnimationFrame(()=>{g.current=null,f.current&&(s(f.current),f.current=null);}));},[s]),K=useCallback(E=>{let w=v.current;if(!w)return;let T=w.getBoundingClientRect(),D=C.current?.getBoundingClientRect(),V=Ft(w);M(V);let se=ke({anchorRect:T,overlay:{width:D?.width??248,height:D?.height??340},portalContainer:V,gap:6,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});L({...se,visibility:E?"visible":"hidden",...$e(w)});},[]);return useLayoutEffect(()=>{if(!h)return;K(false);let E=window.requestAnimationFrame(()=>{K(true);});return ()=>{window.cancelAnimationFrame(E);}},[h,K]),useEffect(()=>{if(!h)return;let E=D=>{let V=D.target;v.current?.contains(V)||C.current?.contains(V)||F(false);},w=D=>{D.key==="Escape"&&F(false);},T=()=>K(true);return window.addEventListener("resize",T),window.addEventListener("scroll",T,true),document.addEventListener("mousedown",E),document.addEventListener("keydown",w),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,true),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",w),M(null);}},[h,K]),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:()=>F(E=>!E),children:[l?jsx(Un,{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:R}})]}),h&&typeof document<"u"&&createPortal(jsxs("div",{ref:C,className:"luthor-color-picker",style:p,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:Z.map(E=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:E},"aria-label":`Use color ${E}`,onClick:()=>{s(E),d(E),F(false);}},E))})]}),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((E,w)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:E||"transparent"},"aria-label":E?`Use recent color ${E}`:"Empty recent color slot",disabled:!E,onClick:()=>{E&&(s(E),d(E),F(false));}},`${E||"empty"}-${w}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{u(),F(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>k.current?.click(),children:[jsx(Kn,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:k,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Ul(R,r),onInput:E=>{fe(E.target.value);},onChange:E=>{let w=E.target.value;s(w),d(w);}})]})]}),I??document.body)]})}function Yl(e,t){let o=useRef(null),n=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:()=>o.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:()=>n.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:o,gifInputRef:n}}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,o){return Gl(e,t)?o?.[e]!==false:false}function Xl(e,t,o){return {sections:e.sections.map(n=>({...n,items:n.items.filter(i=>Wl(i,t,o))})).filter(n=>n.items.length>0)}}function zr({commands:e,hasExtension:t,activeStates:o,isDark:n,toggleTheme:i,onCommandPaletteOpen:r,imageUploadHandler:l,classNames:s,toolbarStyleVars:u,layout:d,toolbarVisibility:v,headingOptions:C,paragraphLabel:k,isListStyleDropdownEnabled:g=true}){let{handlers:f,fileInputRef:h,gifInputRef:F}=Yl(e,l),p=Jl(e),L=t("iframeEmbed")||t("youtubeEmbed"),I=o.isIframeEmbedSelected||o.isYouTubeEmbedSelected,[M,R]=useState(false),[Z,le]=useState(false),[fe,K]=useState(false),[E,w]=useState(false),[T,D]=useState(false),[V,se]=useState(false),[ye,pe]=useState(false),[X,ee]=useState(false),[J,ge]=useState("default"),[O,ze]=useState([{value:"default",label:sn}]),[Me,be]=useState("default"),[Qe,qe]=useState([{value:"default",label:Po}]),[we,Se]=useState("default"),[Ye,De]=useState([{value:"default",label:un}]),[P,G]=useState("default"),[ce,Ze]=useState([{value:"default",label:"Default",color:"inherit"}]),[et,Je]=useState([]),[Be,he]=useState("default"),[it,te]=useState([{value:"default",label:"Default",color:"transparent"}]),[Oe,Ce]=useState([]),[Ge,lt]=useState(0),[Ue,Q]=useState({rows:3,columns:3,includeHeaders:false}),ve=useRef(null),at=useRef("");useEffect(()=>{if(typeof document>"u")return;let y=()=>{ve.current===null&&(ve.current=window.requestAnimationFrame(()=>{ve.current=null;let b=window.getSelection();if(!b||b.rangeCount===0||!b.getRangeAt(0).collapsed)return;let A=Ot();if(!A)return;let B=`${A.fontFamily}|${A.fontSize}|${A.lineHeight}`;B!==at.current&&(at.current=B,lt(W=>W+1));}));};return document.addEventListener("selectionchange",y),()=>{document.removeEventListener("selectionchange",y),ve.current!==null&&(cancelAnimationFrame(ve.current),ve.current=null);}},[]);let st=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 y=Ot()??ln(),b=e.getFontFamilyOptions().map(B=>({value:B.value,label:Le(B.value)==="default"?Kl(B.fontFamily,y):B.label})),A=b.length>0?b:[{value:"default",label:sn}];ze(A),ge(B=>A.some(W=>W.value===B)?B:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let y=e.getFontFamilyOptions;if(typeof y!="function")return;let b=false;return e.getCurrentFontFamily().then(A=>{if(b)return;if(A&&A!=="default"){ge(A);return}let B=Ot(),W=jl(B?.fontFamily,y());ge(W??"default");}),()=>{b=true;}},[o,e,t,Ge]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let y=Ot()??ln(),b=e.getFontSizeOptions().map(W=>({value:String(W.value).trim(),label:Le(String(W.value))==="default"?_l(String(W.fontSize),y):String(W.label).trim()})).filter(W=>W.value.length>0&&W.label.length>0),A=b.some(W=>Le(W.value)==="default"),B=b.length===0?[{value:"default",label:Po}]:A?b:[{value:"default",label:Po},...b];qe(B),be(W=>B.some(me=>me.value===W)?W:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let y=e.getFontSizeOptions;if(typeof y!="function")return;let b=false;return e.getCurrentFontSize().then(A=>{if(b)return;if(A&&A!=="default"){be(A);return}let B=Ot(),W=$l(B?.fontSize,y());be(W??"default");}),()=>{b=true;}},[o,e,t,Ge]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let y=Ot()??ln(),b=e.getLineHeightOptions().map(B=>({value:B.value,label:Le(B.value)==="default"?Vl(B.lineHeight,y):B.label})),A=b.length>0?b:[{value:"default",label:un}];De(A);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let y=e.getLineHeightOptions;if(typeof y!="function")return;let b=false;return e.getCurrentLineHeight().then(A=>{if(b)return;if(A){Se(A);return}let B=Ot(),W=ql(B?.lineHeight,B?.fontSize,y());Se(W??"default");}),()=>{b=true;}},[o,e,t,Ge]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let y=e.getTextColorOptions().map(b=>({value:b.value,label:b.label,color:b.color}));y.length>0&&Ze(y);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let y=false;return e.getCurrentTextColor().then(b=>{y||G(b??"default");}),()=>{y=true;}},[o,e,t,Ge]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let y=e.getTextHighlightOptions().map(b=>({value:b.value,label:b.label,color:b.backgroundColor}));y.length>0&&te(y);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let y=false;return e.getCurrentTextHighlight().then(b=>{y||he(b??"default");}),()=>{y=true;}},[o,e,t,Ge]);let tt=useMemo(()=>{if(!C||C.length===0)return [...je];let y=new Set,b=[];for(let A of C)!je.includes(A)||y.has(A)||(y.add(A),b.push(A));return b.length>0?b:[...je]},[C]),gt=k?.trim()||"Paragraph",ot=useMemo(()=>{let y=tt.map(b=>({value:b,label:`Heading ${b.slice(1)}`}));return [{value:"p",label:gt},...y]},[tt,gt]),ft=o.isH1?"h1":o.isH2?"h2":o.isH3?"h3":o.isH4?"h4":o.isH5?"h5":o.isH6?"h6":"p",Ke=ot.some(y=>y.value===ft)?ft:"p",We=y=>{y==="p"?e.toggleParagraph():y.startsWith("h")&&tt.includes(y)&&e.toggleHeading(y);},_e=y=>{y==="default"?e.clearFontFamily?.():e.setFontFamily?.(y),ge(y);},Te=y=>{y==="default"?e.clearFontSize?.():e.setFontSize?.(y),be(y);},Ve=y=>{e.setLineHeight?.(y),Se(y);},ht=(y,b)=>{y(A=>{let B=Ao(b),W=A.filter(me=>Ao(me)!==B);return [b,...W].slice(0,an)});},Rt=y=>{if(y==="default"){e.clearTextColor?.(),G("default");return}e.setTextColor?.(y),G(y);},Ne=y=>{if(y==="default"){e.clearTextHighlight?.(),he("default");return}e.setTextHighlight?.(y),he(y);},Lt=y=>{if(typeof e.setOrderedListPattern=="function"){e.setOrderedListPattern(y);return}e.toggleOrderedList();},wt=y=>{if(typeof e.setUnorderedListPattern=="function"){e.setUnorderedListPattern(y);return}e.toggleUnorderedList();},St=y=>{if(typeof e.setCheckListVariant=="function"){e.setCheckListVariant(y);return}e.toggleCheckList();},pt=y=>{switch(y){case "fontFamily":return t("fontFamily")?jsx(io,{value:J,onValueChange:_e,options:O,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(io,{value:Me,onValueChange:Te,options:Qe,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(io,{value:we,onValueChange:Ve,options:Ye,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(Ar,{title:"Text Color",value:P,options:ce,recentColors:et,active:o.hasCustomTextColor,fallbackColor:"#0f172a",onChange:Rt,onClear:()=>Rt("default"),onAddRecent:b=>ht(Je,b)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(Ar,{title:"Text Highlight",value:Be,options:it,recentColors:Oe,active:o.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:Ne,onClear:()=>Ne("default"),onAddRecent:b=>ht(Ce,b)},"textHighlight"):null;case "bold":return jsx(H,{onClick:()=>e.toggleBold(),active:o.bold,title:"Bold (Ctrl+B)",children:jsx(Eo,{size:16})},"bold");case "italic":return jsx(H,{onClick:()=>e.toggleItalic(),active:o.italic,title:"Italic (Ctrl+I)",children:jsx(ko,{size:16})},"italic");case "underline":return jsx(H,{onClick:()=>e.toggleUnderline(),active:o.underline,title:"Underline (Ctrl+U)",children:jsx(Lo,{size:16})},"underline");case "strikethrough":return jsx(H,{onClick:()=>e.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(wo,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(H,{onClick:()=>e.toggleSubscript?.(),active:o.subscript,title:"Subscript",children:jsx(Jn,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(H,{onClick:()=>e.toggleSuperscript?.(),active:o.superscript,title:"Superscript",children:jsx(Gn,{size:16})},"superscript"):null;case "code":return jsx(H,{onClick:()=>e.formatText("code"),active:o.code,disabled:o.isInCodeBlock,title:"Inline Code",children:jsx(So,{size:16})},"code");case "link":return jsx(H,{onClick:()=>o.isLink?e.removeLink():e.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(xt,{size:16}):jsx(zt,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(io,{value:Ke,onValueChange:We,options:ot,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(H,{onClick:()=>e.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(xo,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(H,{onClick:()=>e.setTextAlignment("left"),active:o.isTextAlignedLeft,title:"Align Left",children:jsx(Dt,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(H,{onClick:()=>e.setTextAlignment("center"),active:o.isTextAlignedCenter,title:"Align Center",children:jsx(It,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(H,{onClick:()=>e.setTextAlignment("right"),active:o.isTextAlignedRight,title:"Align Right",children:jsx(Bt,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(H,{onClick:()=>e.setTextAlignment("justify"),active:o.isTextAlignedJustify,title:"Justify",children:jsx(An,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(H,{onClick:()=>e.toggleCodeBlock(),active:o.isInCodeBlock,title:"Code Block",children:jsx(Hn,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?g?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(H,{onClick:()=>e.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(Qt,{size:16})}),jsx(Ct,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.unorderedList?" active":""}`,title:"Bullet List Styles","aria-label":"Bullet List Styles",children:jsx(Ut,{size:12})}),isOpen:T,onOpenChange:D,children:jsx("div",{className:"luthor-unordered-variant-grid",children:Hl.map(b=>jsx("button",{className:"luthor-unordered-variant-option",type:"button",title:b.title,"aria-label":b.title,onClick:()=>{wt(b.pattern),D(false);},children:jsx(Al,{pattern:b.pattern})},b.pattern))})})]},"unorderedList"):jsx(H,{onClick:()=>e.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(Qt,{size:16})},"unorderedList"):null;case "orderedList":return t("list")?g?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(H,{onClick:()=>e.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(eo,{size:16})}),jsx(Ct,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.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(b=>jsx("button",{className:"luthor-ordered-variant-option",type:"button",title:b.title,"aria-label":b.title,onClick:()=>{Lt(b.pattern),se(false);},children:jsx(zl,{pattern:b.pattern})},b.pattern))})})]},"orderedList"):jsx(H,{onClick:()=>e.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(eo,{size:16})},"orderedList"):null;case "checkList":return t("list")?g?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(H,{onClick:()=>e.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(Zt,{size:16})}),jsx(Ct,{trigger:jsx("button",{type:"button",className:`luthor-toolbar-button luthor-toolbar-button-arrow${o.checkList?" active":""}`,title:"Checklist Styles","aria-label":"Checklist Styles",children:jsx(Ut,{size:12})}),isOpen:ye,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:()=>{St("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:()=>{St("plain"),pe(false);},children:jsx(Hr,{variant:"plain"})})]})})]},"checkList"):jsx(H,{onClick:()=>e.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(Zt,{size:16})},"checkList"):null;case "indentList":return t("list")?jsx(H,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(Vn,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(H,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(jn,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(H,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(zn,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(H,{onClick:()=>ee(true),title:"Insert Table",children:jsx(Dn,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(Ct,{trigger:jsx("button",{className:`luthor-toolbar-button ${o.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Yo,{size:16})}),isOpen:M,onOpenChange:R,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromUrl(),R(false);},children:[jsx(zt,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromFile(),R(false);},children:[jsx(Jo,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromUrl(),R(false);},children:[jsx(Go,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromFile(),R(false);},children:[jsx(Jo,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),o.imageSelected&&jsxs(Ct,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(It,{size:16})}),isOpen:fe,onOpenChange:K,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("left"),K(false);},children:[jsx(Dt,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("center"),K(false);},children:[jsx(It,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("right"),K(false);},children:[jsx(Bt,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setCaption(),K(false);},children:[jsx(_n,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||st.length===0?null:jsx(Ct,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Go,{size:16})}),isOpen:Z,onOpenChange:le,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:st.map(b=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:b.shortcodes[0]?`${b.label} (:${b.shortcodes[0]}:)`:b.label,onClick:()=>{e.insertEmoji?.(b.emoji),le(false);},children:b.emoji},`${b.emoji}-${b.label}`))})},"emoji");case "embed":return L?jsxs(Ct,{trigger:jsx("button",{className:`luthor-toolbar-button ${I?"active":""}`,title:"Insert Embed",children:jsx(Bn,{size:16})}),isOpen:E,onOpenChange:w,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{p.insertIframe(),w(false);},children:[jsx(zt,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{p.insertYouTube(),w(false);},children:[jsx(Yo,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(H,{onClick:()=>e.undo(),disabled:!o.canUndo,title:"Undo (Ctrl+Z)",children:jsx(Rn,{size:16})},"undo"):null;case "redo":return t("history")?jsx(H,{onClick:()=>e.redo(),disabled:!o.canRedo,title:"Redo (Ctrl+Y)",children:jsx(Pn,{size:16})},"redo"):null;case "commandPalette":return jsx(H,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(To,{size:16})},"commandPalette");case "themeToggle":return jsx(H,{onClick:i,title:n?"Light Mode":"Dark Mode",children:n?jsx($n,{size:16}):jsx(qn,{size:16})},"themeToggle");default:return null}},ut=d??Co,bt=useMemo(()=>Xl(ut,t,v),[ut,t,v]);return jsxs(Fragment,{children:[jsx("div",{className:s?.toolbar??"luthor-toolbar",style:u,children:bt.sections.map((y,b)=>{let A=y.items.map((B,W)=>{let me=pt(B);return me?Array.isArray(me)?me.map((xe,yt)=>xe&&typeof xe=="object"&&"key"in xe&&xe.key!=null?xe:jsx("span",{children:xe},`toolbar-item-${b}-${W}-${yt}`)):me.type===Il.Fragment?jsx("span",{children:me},`toolbar-item-${b}-${W}`):me&&typeof me=="object"&&"key"in me&&me.key!=null?me:jsx("span",{children:me},`toolbar-item-${b}-${W}`):null}).flat().filter(B=>B!==null);return A.length===0?null:jsx("div",{className:s?.section??"luthor-toolbar-section",children:A},b)})}),jsx("input",{ref:h,type:"file",accept:"image/*",onChange:f.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:F,type:"file",accept:"image/gif",onChange:f.handleGifUpload,className:"luthor-file-input"}),jsx(cr,{isOpen:X,onClose:()=>ee(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:Ue.rows,onChange:y=>Q(b=>({...b,rows:parseInt(y.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:Ue.columns,onChange:y=>Q(b=>({...b,columns:parseInt(y.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:Ue.includeHeaders||false,onChange:y=>Q(b=>({...b,includeHeaders:y.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(Zo,{variant:"secondary",onClick:()=>ee(false),children:"Cancel"}),jsx(Zo,{variant:"primary",onClick:()=>{e.insertTable(Ue),ee(false);},children:"Insert Table"})]})]})})]})}var pn=["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 co(e){let t={...jr};if(!e)return t;for(let o of pn)typeof e[o]=="boolean"&&(t[o]=e[o]);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"},uo="1.5",Ma=1;function Nt(e){return e.trim().toLowerCase()}function qr(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function Oa(e){return Nt(e)==="default"?true:Bo(e)!==null}function Na(e){let t=e??Kr,o=new Set,n=[];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=Nt(l);o.has(d)||(o.add(d),n.push({value:l,label:s,fontFamily:u,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return n.length===0?Kr:n.some(r=>Nt(r.value)==="default")?n:[xa,...n]}function Ha(e){let t=e??_r,o=new Set,n=[];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=Nt(l);o.has(d)||(o.add(d),n.push({value:l,label:s,fontSize:u}));}return n.length===0?_r:n.some(r=>Nt(r.value)==="default")?n:[Ia,...n]}function Bo(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let o=Number(t);return !Number.isFinite(o)||o<Ma?null:o.toString()}function Ra(e){if(!Number.isFinite(e))return Ur;let t=Math.floor(e);return t>=0?t:Ur}function Pa(e){return typeof e=="number"?Number.isFinite(e)?Bo(e.toString())??uo:uo:typeof e=="string"?Bo(e)??uo:uo}function Aa(e,t=uo){let o=e??Vr,n=new Set,i=[];for(let l of o){let s=String(l.value).trim(),u=String(l.label).trim();if(!s||!u||!Oa(s))continue;let d=Nt(s);if(n.has(d))continue;if(d==="default"){n.add(d),i.push({value:s,label:u,lineHeight:t});continue}let v=Bo(String(l.lineHeight));v&&(n.add(d),i.push({value:s,label:u,lineHeight:v}));}return i.length===0?Vr:i.some(l=>Nt(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"})]}),Uo=new ImageExtension;Uo.config={...Uo.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var cn=new TableExtension;cn.config={...cn.config,enableContextMenu:true,tableBubbleRenderer:({headersEnabled:e,setHeadersEnabled:t,actions:o})=>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:o.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:o.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:o.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:o.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:o.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:o.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:o.deleteTable,children:jsx(Va,{})})]})};var dn=new IframeEmbedExtension;dn.config={...dn.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var mn=new YouTubeEmbedExtension;mn.config={...mn.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var $a=mr(),gn=new ContextMenuExtension;gn.config={...gn.config,preventDefault:true};var qa=new CommandPaletteExtension,Ya=new SlashCommandExtension,Ja=new EmojiExtension,fn=new DraggableBlockExtension;fn.config={...fn.config,buttonStackPosition:"left"};var hn=new LinkExtension;hn.config={...hn.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:o,minimumDefaultLineHeight:n,featureFlags:i,isDraggableBoxEnabled:r,scaleByRatio:l,syntaxHighlighting:s,grammarPreloadMode:u,codeHighlightProvider:d,loadCodeHighlightProvider:v,maxAutoDetectCodeLength:C,isCopyAllowed:k,languageOptions:g,showLineNumbers:f,maxListIndentation:h}={}){let F=co(i),p=w=>$r(F,w),L=(r??true)&&p("draggableBlock"),I=Pa(n),M=Ra(h),R=new FontFamilyExtension().configure({options:Na(e),cssLoadStrategy:"on-demand"}),Z=new FontSizeExtension().configure({options:Ha(t)}),le=new LineHeightExtension().configure({options:Aa(o,I),defaultLineHeight:I});Uo.configure({scaleByRatio:l??false}),codeExtension.configure({syntaxHighlighting:s??"auto",grammarPreloadMode:u??"lazy",provider:d??void 0,loadProvider:v,showLineNumbers:f??true}),codeIntelligenceExtension.configure({provider:d??void 0,loadProvider:v,maxAutoDetectLength:C,isCopyAllowed:k??true,languageOptions:g});let fe=new ListExtension({maxDepth:M+1}),K=new TabIndentExtension({maxListDepth:M+1}),E=[];return p("bold")&&E.push(boldExtension),p("italic")&&E.push(italicExtension),p("underline")&&E.push(underlineExtension),p("strikethrough")&&E.push(strikethroughExtension),p("fontFamily")&&E.push(R),p("fontSize")&&E.push(Z),p("lineHeight")&&E.push(le),p("textColor")&&E.push(Ga),p("textHighlight")&&E.push(Wa),p("subscript")&&E.push(subscriptExtension),p("superscript")&&E.push(superscriptExtension),p("link")&&E.push(hn),p("horizontalRule")&&E.push(horizontalRuleExtension),p("table")&&E.push(cn),p("list")&&E.push(fe),p("history")&&E.push(historyExtension),p("image")&&E.push(Uo),p("blockFormat")&&E.push(blockFormatExtension),p("code")&&E.push(codeExtension),p("codeIntelligence")&&E.push(codeIntelligenceExtension),p("codeFormat")&&E.push(codeFormatExtension),p("tabIndent")&&E.push(K),p("enterKeyBehavior")&&E.push(enterKeyBehaviorExtension),p("iframeEmbed")&&E.push(dn),p("youTubeEmbed")&&E.push(mn),p("floatingToolbar")&&E.push($a),p("contextMenu")&&E.push(gn),p("commandPalette")&&E.push(qa),p("slashCommand")&&E.push(Ya),p("emoji")&&E.push(Ja),L&&E.push(fn),p("customNode")&&E.push(Xa),E}function mo(e){return Yr(e)}var bn=Yr();function Jr(e){if(!e)return "__default__";let t=Object.entries(e).filter(([,o])=>typeof o=="string"&&o.trim().length>0).sort(([o],[n])=>o.localeCompare(n));return t.length>0?JSON.stringify(t):"__default__"}function Gr(e){if(!e)return;let t={},o=(n,i)=>{typeof i=="string"&&i.trim().length>0&&(t[n]=i.trim());};return o("--luthor-fg",e.font?.color),o("--luthor-text-bold-color",e.font?.boldColor),o("--luthor-link-color",e.link?.color),o("--luthor-list-marker-color",e.list?.markerColor),o("--luthor-list-checkbox-color",e.list?.checkboxColor),o("--luthor-quote-bg",e.quote?.backgroundColor),o("--luthor-quote-fg",e.quote?.color),o("--luthor-quote-border",e.quote?.indicatorColor),o("--luthor-table-border-color",e.table?.borderColor),o("--luthor-table-header-bg",e.table?.headerBackgroundColor),o("--luthor-hr-color",e.hr?.color),o("--luthor-placeholder-color",e.placeholder?.color),o("--luthor-codeblock-bg",e.codeblock?.backgroundColor),o("--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 o=e.ctrlKey||e.metaKey;return !(!!t.requiresPrimary!==o||!!t.shift!=!!e.shiftKey||!!t.alt!=!!e.altKey)}function Qr(e,t,o){let n={...e??{}};for(let[i,r]of Object.entries(o))(Array.isArray(r)?r:[r]).some(u=>t[u]!==false)||(n[i]=false);return n}function Zr(e,t,o){let n={...e},i=(r,l)=>{t[r]===false&&l();};return i("bold",()=>{n.toggleBold=()=>{};}),i("italic",()=>{n.toggleItalic=()=>{};}),i("underline",()=>{n.toggleUnderline=()=>{};}),i("strikethrough",()=>{n.toggleStrikethrough=()=>{};}),i("codeFormat",()=>{n.formatText=()=>{};}),i("fontFamily",()=>{n.setFontFamily=()=>{},n.clearFontFamily=()=>{};}),i("fontSize",()=>{n.setFontSize=()=>{},n.clearFontSize=()=>{};}),i("lineHeight",()=>{n.setLineHeight=()=>{},n.clearLineHeight=()=>{};}),i("textColor",()=>{n.setTextColor=()=>{},n.clearTextColor=()=>{};}),i("textHighlight",()=>{n.setTextHighlight=()=>{},n.clearTextHighlight=()=>{};}),i("subscript",()=>{n.toggleSubscript=()=>{};}),i("superscript",()=>{n.toggleSuperscript=()=>{};}),i("link",()=>{n.insertLink=()=>{},n.removeLink=()=>{},n.updateLink=()=>false,n.getCurrentLink=async()=>null,n.getLinkByKey=async()=>null,n.updateLinkByKey=()=>false,n.removeLinkByKey=()=>false;}),i("blockFormat",()=>{n.toggleParagraph=()=>{},n.toggleHeading=()=>{},n.toggleQuote=()=>{},n.setTextAlignment=()=>{};}),i("code",()=>{n.toggleCodeBlock=()=>{};}),i("codeIntelligence",()=>{n.setCodeLanguage=()=>{},n.autoDetectCodeLanguage=async()=>null,n.copySelectedCodeBlock=async()=>false;}),i("list",()=>{n.toggleUnorderedList=()=>{},n.toggleOrderedList=()=>{},n.toggleCheckList=()=>{},n.indentList=()=>{},n.outdentList=()=>{};}),i("horizontalRule",()=>{n.insertHorizontalRule=()=>{};}),i("table",()=>{n.insertTable=()=>{};}),i("image",()=>{n.insertImage=()=>{},n.setImageAlignment=()=>{},n.setImageCaption=()=>{},n.getImageCaption=async()=>"";}),i("emoji",()=>{n.insertEmoji=()=>{},n.executeEmojiSuggestion=()=>false,n.closeEmojiSuggestions=()=>{},n.getEmojiSuggestions=()=>[],n.getEmojiCatalog=()=>[],n.resolveEmojiShortcode=()=>null,n.setEmojiCatalog=()=>{},n.setEmojiCatalogAdapter=()=>{},n.getEmojiCatalogAdapter=()=>({search:()=>[],resolveShortcode:()=>null,getAll:()=>[]});}),i("iframeEmbed",()=>{n.insertIframeEmbed=()=>{},n.setIframeEmbedAlignment=()=>{},n.resizeIframeEmbed=()=>{},n.setIframeEmbedCaption=()=>{},n.getIframeEmbedCaption=async()=>"",n.updateIframeEmbedUrl=()=>false,n.getIframeEmbedUrl=async()=>"";}),i("youTubeEmbed",()=>{n.insertYouTubeEmbed=()=>{},n.setYouTubeEmbedAlignment=()=>{},n.resizeYouTubeEmbed=()=>{},n.setYouTubeEmbedCaption=()=>{},n.getYouTubeEmbedCaption=async()=>"",n.updateYouTubeEmbedUrl=()=>false,n.getYouTubeEmbedUrl=async()=>"";}),i("history",()=>{n.undo=()=>{},n.redo=()=>{};}),i("commandPalette",()=>{n.showCommandPalette=()=>{},n.hideCommandPalette=()=>{},n.registerCommand=()=>{},n.unregisterCommand=()=>{};}),i("slashCommand",()=>{n.registerSlashCommand=()=>{},n.unregisterSlashCommand=()=>{},n.setSlashCommands=()=>{},n.closeSlashMenu=()=>{},n.executeSlashCommand=()=>false;}),o&&(n.toggleBold=()=>{},n.toggleItalic=()=>{},n.toggleUnderline=()=>{},n.toggleStrikethrough=()=>{},n.formatText=()=>{},n.setFontFamily=()=>{},n.clearFontFamily=()=>{},n.setFontSize=()=>{},n.clearFontSize=()=>{},n.setLineHeight=()=>{},n.clearLineHeight=()=>{},n.setTextColor=()=>{},n.clearTextColor=()=>{},n.setTextHighlight=()=>{},n.clearTextHighlight=()=>{},n.toggleSubscript=()=>{},n.toggleSuperscript=()=>{},n.insertLink=()=>{},n.removeLink=()=>{},n.updateLink=()=>false,n.toggleParagraph=()=>{},n.toggleHeading=()=>{},n.toggleQuote=()=>{},n.setTextAlignment=()=>{},n.toggleUnorderedList=()=>{},n.toggleOrderedList=()=>{},n.toggleCheckList=()=>{},n.indentList=()=>{},n.outdentList=()=>{},n.insertHorizontalRule=()=>{},n.insertTable=()=>{},n.insertImage=()=>{},n.setImageAlignment=()=>{},n.setImageCaption=()=>{},n.insertIframeEmbed=()=>{},n.setIframeEmbedAlignment=()=>{},n.resizeIframeEmbed=()=>{},n.setIframeEmbedCaption=()=>{},n.updateIframeEmbedUrl=()=>false,n.insertYouTubeEmbed=()=>{},n.setYouTubeEmbedAlignment=()=>{},n.resizeYouTubeEmbed=()=>{},n.setYouTubeEmbedCaption=()=>{},n.updateYouTubeEmbedUrl=()=>false),n}function ei(e){return new Set(e)}function yn(e,t){e.clear();for(let o of t)e.add(o);}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 fo(e){return e==="visual"?"visual-editor":e}function oe(e){return fo(e)==="visual-editor"}function En(e,t){return e.some(o=>fo(o)===t)}function Ko(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,o=n=>{n&&t.add(n);};if(o(e),o(e.closest(".luthor-richtext-container")),o(e.closest(".luthor-editor-visual-shell")),o(e.closest(".luthor-editor")),o(e.closest(".luthor-editor-wrapper")),typeof window<"u"){let n=e.parentElement;for(;n&&n!==document.body&&n!==document.documentElement;){let i=gi(window.getComputedStyle(n));mi.has(i)&&o(n),n=n.parentElement;}}t.forEach(n=>{cs(n);});}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=[],o=e.parentElement;for(;o&&o!==document.body&&o!==document.documentElement;){let n=window.getComputedStyle(o),i=gi(n);if(!mi.has(i)){o=o.parentElement;continue}if(o.scrollHeight>o.clientHeight+1)break;if(i==="auto"||i==="overlay"){t.push({element:o,overflowY:o.style.overflowY}),o.style.overflowY="visible",o=o.parentElement;continue}break}return ()=>{for(let n=t.length-1;n>=0;n-=1){let i=t[n];i&&(i.element.style.overflowY=i.overflowY);}}}function gs(e){if(typeof window>"u")return ()=>{};let t=si(e),o=()=>{t(),t=si(e);};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),t();}}function kn(e){let o=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:(o.length>0?o:[""]).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 go=kn("");function ui(e,t,o){return o<=t?t:Math.min(o,Math.max(t,e))}function fs(e,t){let o=document,n=window.getSelection();if(!n)return false;let i=o.caretPositionFromPoint?.(e,t);if(i){let l=document.createRange();return l.setStart(i.offsetNode,i.offset),l.collapse(true),n.removeAllRanges(),n.addRange(l),true}let r=o.caretRangeFromPoint?.(e,t);return r?(r.collapse(true),n.removeAllRanges(),n.addRange(r),true):false}function hs(e,t,o){let r=Array.from(e.children).filter(v=>v instanceof HTMLElement).reduce((v,C)=>{let k=C.getBoundingClientRect(),g=k.top+k.height/2;if(!v)return C;let f=v.getBoundingClientRect(),h=f.top+f.height/2;return Math.abs(g-o)<Math.abs(h-o)?C:v},null)??e.firstElementChild??e,l=e.getBoundingClientRect(),s=r.getBoundingClientRect(),u=ui(t,l.left+1,l.right-1),d=ui(o,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(kn(e))}}function Fe(e,t,o="preserve",n="luthor"){let i=t??go;if(e==="json")return Fr(JSON.stringify(i));if(e==="markdown"){let l=n==="lexical-native"?jsonToMarkdown(i,{bridgeFlavor:"lexical-native"}):o==="none"?jsonToMarkdown(i,{metadataMode:"none"}):jsonToMarkdown(i);return Mr(l)}let r=o==="none"?jsonToHTML(i,{metadataMode:"none"}):jsonToHTML(i);return Or(r)}function ci(e){let t=e.replace(/\r\n?/g,`
10
+ `),o=t.split(`
11
+ `);if(o.length<3)return {frontmatter:null,body:t};if((o[0]??"").replace(/^\uFEFF/,"").trim()!=="---")return {frontmatter:null,body:t};let i=-1;for(let l=1;l<o.length;l+=1){let s=(o[l]??"").trim();if(s==="---"||s==="..."){i=l;break}}if(i<2)return {frontmatter:null,body:t};let r=o.slice(1,i).join(`
12
+ `);return /^[^#\n]*:/m.test(r)?{frontmatter:o.slice(0,i+1).join(`
13
+ `).trim(),body:o.slice(i+1).join(`
14
+ `)}:{frontmatter:null,body:t}}function bs(e,t){let o=ci(e);if(!o.frontmatter||ci(t).frontmatter)return t;let i=t.replace(/\r\n?/g,`
15
+ `).trim();return i.length>0?`${o.frontmatter}
16
+
17
+ ${i}`:`${o.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 o=e.trim();if(o.length===0)return "1.5";let n=Number(o);return !Number.isFinite(n)||n<1?"1.5":n.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 vn(e){return Jr(e)}function Ls(e){if(!e)return "__default__";if(Array.isArray(e))return JSON.stringify({mode:"append",values:e.map(n=>n.trim())});let t=e,o=Array.isArray(t.values)?t.values:[];return JSON.stringify({mode:t.mode??"append",values:o.map(n=>n.trim())})}function ws(e){return Gr(e)}function Ss(e){let t=co(e);return JSON.stringify(pn.map(o=>[o,t[o]]))}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,o){return Zr(e,t,o)}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 [...je];let t=new Set,o=[];for(let n of e)!je.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...je]}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},o=e,n=t(o.allowlist),i=t(o.denylist);return n.length===0&&i.length===0?"__default__":JSON.stringify({allowlist:n,denylist:i})}function Hs(e){if(!e||e.length===0)return [];let t=new Set,o=[];for(let n of e){let i=n.trim();!i||t.has(i)||(t.add(i),o.push(i));}return o}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 Ps(e){if(!e)return "__default__";let t=Array.isArray(e.disabledCommandIds)?[...e.disabledCommandIds].map(n=>n.trim()).filter(n=>n.length>0).sort((n,i)=>n.localeCompare(i)):[],o=e.bindings?Object.entries(e.bindings).map(([n,i])=>{if(i===false||i===null)return [n,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?[n,false]:[n,l]}).sort(([n],[i])=>n.localeCompare(i)):[];return JSON.stringify({disabledCommandIds:t,bindings:o,preventCollisions:e.preventCollisions!==false,preventNativeConflicts:e.preventNativeConflicts!==false})}function As({isDark:e,toggleTheme:t,visualPlaceholder:o,jsonPlaceholder:n,markdownPlaceholder:i,htmlPlaceholder:r,initialMode:l,availableModes:s,onReady:u,toolbarLayout:d,toolbarVisibility:v,toolbarPosition:C,toolbarAlignment:k,toolbarClassName:g,toolbarStyleVars:f,isToolbarEnabled:h,isToolbarPinned:F,isEditorViewTabsVisible:p,headingOptions:L,paragraphLabel:I,syncHeadingOptionsWithCommands:M,slashCommandVisibility:R,shortcutConfig:Z,commandPaletteShortcutOnly:le,isListStyleDropdownEnabled:fe,featureFlags:K,editOnClick:E,sourceMetadataMode:w,markdownBridgeFlavor:T,markdownSourceOfTruth:D,showLineNumbers:V}){let{commands:se,hasExtension:ye,activeStates:pe,lexical:X,extensions:ee,export:J,import:ge}=ss(),[O,ze]=useState(l),[Me,be]=useState({json:"",markdown:"",html:""}),[Qe,qe]=useState(null),[we,Se]=useState(null),[Ye,De]=useState({isOpen:false,commands:[]}),[P,G]=useState({isOpen:false,query:"",position:null,commands:[]}),[ce,Ze]=useState({isOpen:false,query:"",position:null,suggestions:[]}),et=useRef(false),Je=useMemo(()=>Os(L),[L]),Be=M?Je:void 0,he=M?I:void 0,it=pe.isInCodeBlock===true,te=useMemo(()=>Is(se,K,it),[se,K,it]),Oe=useMemo(()=>m=>Object.prototype.hasOwnProperty.call(K,m)?K[m]!==false:true,[K]),Ce=useMemo(()=>m=>oe(O)&&Oe(m),[O,Oe]),Ge=useMemo(()=>Ms(v,K),[v,K]),lt=K.draggableBlock!==false,Ue=Ns(R),Q=useRef(R),ve=useRef(Ue),at=Ps(Z),st=useRef(Z),tt=useRef(at),gt=useMemo(()=>Hs(Z?.disabledCommandIds),[Z?.disabledCommandIds]),ot=useMemo(()=>new Set(gt),[gt]),ft=useMemo(()=>ot.size===0?[]:qo({headingOptions:Be,paragraphLabel:he,isFeatureEnabled:Oe}).filter(m=>ot.has(m.id)).flatMap(m=>m.shortcuts??[]),[ot,Be,he,Oe]);ve.current!==Ue&&(ve.current=Ue,Q.current=R),tt.current!==at&&(tt.current=at,st.current=Z);let Ke=useRef(ei(["visual-editor"])),We=useRef({json:false,markdown:false,html:false}),_e=useRef(""),Te=useRef(true),Ve=useRef(false),ht=useRef(false),Rt=useRef(0),Ne=useRef(null);useEffect(()=>{en(te,pe,e?"dark":"light",Ce);},[te,pe,e,Ce]);let Lt=useMemo(()=>{let m=Xe=>{let Tt=Fe("json",Xe,w,T),jo=Fe("markdown",Xe,w,T),Sn=Fe("html",Xe,w,T);be(yo=>yo.json===Tt&&yo.markdown===jo&&yo.html===Sn?yo:{json:Tt,markdown:jo,html:Sn}),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&&(_e.current=jo,Te.current=false);},S=Xe=>{setTimeout(()=>{try{let Tt=JSON.parse(Xe);ge.fromJSON(Tt),m(Tt);}catch(Tt){console.error("Failed to inject JSON:",Tt);return}},100);},z=()=>{if(!D)return Fe("markdown",J.toJSON(),w,T);if(Te.current){let Xe=Fe("markdown",J.toJSON(),w,T);_e.current=Xe,Te.current=false;}return _e.current},j=()=>{let Xe=z();return T==="lexical-native"?markdownToJSON(Xe,{bridgeFlavor:"lexical-native"}):w==="none"?markdownToJSON(Xe,{metadataMode:"none"}):markdownToJSON(Xe)};return {injectJSON:S,getJSON:()=>D?Fe("json",j(),w,T):Fe("json",J.toJSON()),getMarkdown:()=>z(),getHTML:()=>D?Fe("html",j(),w,T):Fe("html",J.toJSON(),w,T)}},[J,ge,T,D,w]);useEffect(()=>{if(!X||!te)return;let m=te,S=Fn(m,{headingOptions:Be,paragraphLabel:he,isFeatureEnabled:Ce,shortcutConfig:st.current,commandPaletteShortcutOnly:le});typeof m.registerCommand=="function"&&S.forEach(Y=>m.registerCommand(Y));let z=Mn(m,{headingOptions:Be,paragraphLabel:he,slashCommandVisibility:Q.current,isFeatureEnabled:Ce,shortcutConfig:st.current});typeof m.setSlashCommands=="function"?m.setSlashCommands(z):z.forEach(Y=>m.registerSlashCommand?.(Y));let j=Nn(m,document.body,{headingOptions:Be,paragraphLabel:he,isFeatureEnabled:Ce,shortcutConfig:st.current,scope:()=>X.getRootElement()});return et.current||(et.current=true,u?.(Lt)),()=>{j(),typeof m.unregisterCommand=="function"&&S.forEach(Y=>m.unregisterCommand(Y.id)),typeof m.setSlashCommands=="function"?m.setSlashCommands([]):z.forEach(Y=>m.unregisterSlashCommand?.(Y.id));}},[X,te,Lt,u,Be,he,Ue,at,Ce,le]),useEffect(()=>{let m=()=>X?.getRootElement(),S=Ts.filter(j=>K[j.feature]===false);if(S.length===0)return;let z=j=>{let Y=m();Y&&j.target instanceof Node&&!Y.contains(j.target)||!di(j.target)||!S.some(wn=>xs(j,wn))||(j.preventDefault(),j.stopPropagation());};return document.addEventListener("keydown",z,true),()=>{document.removeEventListener("keydown",z,true);}},[X,K]),useEffect(()=>{let m=ee.find(S=>S.name==="commandPalette");if(!(!m||!m.subscribe))return m.subscribe((S,z)=>{let j=z.filter(Y=>ot.has(Y.id)?false:le?typeof Y.shortcut=="string"&&Y.shortcut.trim().length>0:true);De({isOpen:oe(O)?S:false,commands:j});})},[ee,ot,le,O]),useEffect(()=>{if(ft.length===0)return;let m=()=>X?.getRootElement(),S=z=>{let j=m();j&&z.target instanceof Node&&!j.contains(z.target)||!di(z.target)||!ft.some(Ee=>Rs(z,Ee))||(z.preventDefault(),z.stopPropagation());};return document.addEventListener("keydown",S,true),()=>{document.removeEventListener("keydown",S,true);}},[X,ft]),useEffect(()=>{let m=ee.find(S=>S.name==="slashCommand");if(!(!m||!m.subscribe))return m.subscribe(S=>{G({isOpen:oe(O)?S.isOpen:false,query:oe(O)?S.query:"",position:oe(O)?S.position:null,commands:oe(O)?S.commands:[]});})},[ee,O]),useEffect(()=>{let m=ee.find(S=>S.name==="emoji");if(!(!m||!m.subscribe))return m.subscribe(S=>{Ze({isOpen:oe(O)?S.isOpen:false,query:oe(O)?S.query:"",position:oe(O)?S.position:null,suggestions:oe(O)?S.suggestions:[]});})},[ee,O]),useEffect(()=>{oe(O)||(De(m=>m.isOpen?{...m,isOpen:false}:m),G(m=>m.isOpen||m.query.length>0||m.position!==null||m.commands.length>0?{isOpen:false,query:"",position:null,commands:[]}:m),Ze(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?.());},[O,te]),useEffect(()=>!X||!J?void 0:X.registerUpdateListener(({dirtyElements:S,dirtyLeaves:z})=>{if((S.size>0||z.size>0)&&(Rt.current+=1,yn(Ke.current,["visual-editor"]),D)){if(!oe(O)||ht.current)return;if(Ve.current){Ve.current=false;return}Te.current=true;}}),[X,J,D,O]);let wt=m=>T==="lexical-native"?markdownToJSON(m,{bridgeFlavor:"lexical-native"}):w==="none"?markdownToJSON(m,{metadataMode:"none"}):markdownToJSON(m),St=(m,S)=>m==="json"?S.trim()?JSON.parse(S):kn(""):m==="markdown"?wt(S):w==="none"?htmlToJSON(S,{metadataMode:"none"}):htmlToJSON(S),pt=m=>{let S=J.toJSON()??go;return Fe(m,S,w,T)},ut=()=>{let m=pt("markdown"),S=bs(_e.current,m);return _e.current=S,Te.current=false,We.current.markdown=false,Jt(Ke.current,"markdown"),be(z=>z.markdown===S?z:{...z,markdown:S}),S},bt=()=>D?Te.current?ut():_e.current:pt("markdown"),y=m=>{let S=bt(),z=wt(S);return Fe(m,z,w,T)},b=m=>{let S=Me[m],z=St(m,S),j=D&&m==="markdown";D&&m==="markdown"&&(Ve.current=true),j&&(ht.current=true);try{ge.fromJSON(z);}finally{j&&(ht.current=false);}D&&(m==="markdown"?(_e.current=S,Te.current=false):Te.current=true),We.current[m]=false,yn(Ke.current,["visual-editor"]);},A=(m,S,z)=>{be(j=>({...j,[m]:S})),We.current[m]=z?.dirty===true,D&&m==="markdown"&&(_e.current=S,Te.current=false);},B=async m=>{let S=fo(m);if(S===O||!En(s,S))return;let z=O,j=null;try{if(Se(null),Ko(z)){let Y=z;We.current[Y]&&(j=Y,b(Y),await new Promise(Ee=>setTimeout(Ee,50)),j=null);}if(D&&Te.current&&(oe(z)||Ko(z)&&z!=="markdown")&&ut(),oe(z)&&!oe(S)&&(X&&clearLexicalSelection(X),X?.getRootElement()?.blur()),ze(S),Ko(S)){let Y=S;if(!ti(Ke.current,Y)){qe(Y),await new Promise(Ee=>setTimeout(Ee,50));try{j=Y;let Ee=D?Y==="markdown"?bt():y(Y):pt(Y);A(Y,Ee),Jt(Ke.current,Y),j=null;}finally{qe(null);}}}oe(S)&&(z==="visual-only"&&Ne.current!==null?setTimeout(()=>X?.focus(),100):ms(()=>{let Ee=X?.getRootElement();Ee&&ds(Ee);}));}catch(Y){let Ee=Y instanceof Error?Y.message:"Invalid format - could not parse content";j&&typeof window<"u"&&Se({mode:j,error:Ee});}},W=m=>{!E||O!=="visual-only"||!En(s,"visual-editor")||(Ne.current=m,B("visual-editor"));};useEffect(()=>{if(!oe(O))return;let m=Ne.current;if(!m)return;Ne.current=null;let S=()=>{let j=X?.getRootElement();j&&hs(j,m.clientX,m.clientY);};if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(()=>S());return}let z=globalThis.setTimeout(S,0);return ()=>{globalThis.clearTimeout(z);}},[X,O]);let me=h?jsx(zr,{commands:te,hasExtension:m=>ye(m),activeStates:pe,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{oe(O)&&K.commandPalette!==false&&te.showCommandPalette();},imageUploadHandler:m=>ee.find(S=>S.name==="image")?.config?.uploadHandler?.(m)??Promise.resolve(URL.createObjectURL(m)),layout:d??Co,toolbarVisibility:Ge,toolbarStyleVars:f,headingOptions:Je,paragraphLabel:I,isListStyleDropdownEnabled:fe,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${k}${g?` ${g}`:""}`}}):null,xe=p,yt=oe(O)&&h&&C==="top",ho=["luthor-editor-top-region",F&&C==="top"&&xe?"luthor-editor-top-region--pinned":""].filter(Boolean).join(" "),po=["luthor-editor-toolbar-slot","luthor-editor-toolbar-slot--top",yt&&(F&&C==="top"&&!xe)?"luthor-editor-toolbar-slot--pinned":""].filter(Boolean).join(" "),Vo=oe(O)&&h&&C==="bottom",bo=X?.getRootElement()?.closest(".luthor-editor-wrapper")??null,ue=Ko(O)?O:null,Pt=O==="visual-only",Xt=oe(O)||Pt,At=!lt||!oe(O);return jsxs(Fragment,{children:[jsxs("div",{className:`luthor-editor${At?" luthor-editor--draggable-disabled":""}`,"data-mode":O,children:[(xe||yt)&&jsxs("div",{className:ho,children:[xe&&jsx("div",{className:"luthor-editor-header",children:jsx(Lr,{mode:O,onModeChange:B,availableModes:s,isConverting:Qe})}),yt&&jsx("div",{className:po,children:me})]}),jsxs("div",{className:`luthor-editor-visual-shell${Xt?"":" is-hidden"}${At?" luthor-editor-visual-shell--no-gutter":""}`,"aria-hidden":!Xt,children:[!At&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:o,nonEditableVisualMode:Pt,onEditIntent:Pt?W: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"}})]}),ue&&jsxs("div",{className:"luthor-source-panel",children:[we&&we.mode===ue&&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[ue]}),jsx("p",{children:we.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),ue==="json"&&jsx(Oo,{value:Me.json,onChange:m=>A("json",m,{dirty:true}),placeholder:n,showLineNumbers:V}),ue==="markdown"&&jsx(Oo,{value:Me.markdown,onChange:m=>A("markdown",m,{dirty:true}),placeholder:i,className:"luthor-source-view--wrapped",wrap:"soft",showLineNumbers:V}),ue==="html"&&jsx(Oo,{value:Me.html,onChange:m=>A("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:!oe(O)}),Vo&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:me}),oe(O)&&jsx(Zn,{isOpen:Ye.isOpen,onClose:()=>te.hideCommandPalette(),commands:Ye.commands}),oe(O)&&jsx(ar,{isOpen:P.isOpen,query:P.query,position:P.position,portalContainer:bo,commands:P.commands,onClose:()=>te.closeSlashMenu?.(),onExecute:m=>{te.executeSlashCommand?.(m);}}),oe(O)&&jsx(or,{isOpen:ce.isOpen,query:ce.query,position:ce.position,portalContainer:bo,suggestions:ce.suggestions,onClose:()=>te.closeEmojiSuggestions?.(),onExecute:m=>{te.executeEmojiSuggestion?.(m);}})]})}var _o=forwardRef(({className:e,onReady:t,initialTheme:o="light",onThemeChange:n,theme:i,defaultContent:r,showDefaultContent:l=true,placeholder:s=ri,defaultEditorView:u,initialMode:d="visual-editor",isEditorViewTabsVisible:v,isEditorViewsTabVisible:C,availableModes:k=["visual-editor","visual-only","json","markdown","html"],variantClassName:g,toolbarLayout:f,toolbarVisibility:h,toolbarPosition:F="top",toolbarAlignment:p="left",toolbarClassName:L,toolbarStyleVars:I,quoteClassName:M,quoteStyleVars:R,defaultSettings:Z,editorThemeOverrides:le,isToolbarEnabled:fe=true,isToolbarPinned:K=false,fontFamilyOptions:E,fontSizeOptions:w,lineHeightOptions:T,minimumDefaultLineHeight:D=1.5,scaleByRatio:V=false,headingOptions:se,paragraphLabel:ye,syncHeadingOptionsWithCommands:pe=true,slashCommandVisibility:X,shortcutConfig:ee,commandPaletteShortcutOnly:J=false,isListStyleDropdownEnabled:ge=true,editOnClick:O=true,isDraggableBoxEnabled:ze,featureFlags:Me,sourceMetadataMode:be="preserve",markdownBridgeFlavor:Qe="luthor",markdownSourceOfTruth:qe=false,syntaxHighlighting:we,grammarPreloadMode:Se="lazy",codeHighlightProvider:Ye,loadCodeHighlightProvider:De,maxAutoDetectCodeLength:P,isCopyAllowed:G=true,languageOptions:ce,showLineNumbers:Ze=true,inlineCodeHighlighting:et=true,maxListIndentation:Je=8},Be)=>{let[he,it]=useState(o),te=useRef(null),Oe=he==="dark",Ce=fo(u??d),Ge=En(k,Ce)?Ce:fo(k[0]??"visual-editor"),lt=v??C??true,Ue=()=>it(Oe?"light":"dark"),Q=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(()=>{it(o);},[o]),useEffect(()=>{n?.(he);},[he,n]),useEffect(()=>{if(!K||F!=="top")return;let ue=te.current;if(ue)return gs(ue)},[K,F]);let ve=useMemo(()=>ys(E),[E]),at=useMemo(()=>Cs(w),[w]),st=useMemo(()=>vs(T),[T]),tt=useMemo(()=>Es(D),[D]),gt=useMemo(()=>ks(Je),[Je]),ot=we??"unset",ft=Se,Ke=typeof P=="number"?P.toString():"unset",We=useMemo(()=>Ls(ce),[ce]),_e=G?"copy-on":"copy-off",Te=Ze?"line-numbers-on":"line-numbers-off",Ve=useMemo(()=>typeof ze!="boolean"?Me:{...Me??{},draggableBlock:ze},[Me,ze]),ht=useMemo(()=>Ss(Ve),[Ve]),Rt=useMemo(()=>co(Ve),[Ve]),Ne=`${ve}::${at}::${st}::${tt}::${gt}::${V?"ratio-on":"ratio-off"}::${ot}::${ft}::${Ke}::${_e}::${Te}::${We}::${ht}`,Lt=useRef(E),wt=useRef(w),St=useRef(T),pt=useRef(D),ut=useRef(Ve),bt=useRef(ce),y=useRef(Ye),b=useRef(De),A=useRef(Ne);(A.current!==Ne||y.current!==Ye||b.current!==De)&&(A.current=Ne,Lt.current=E,wt.current=w,St.current=T,pt.current=D,ut.current=Ve,bt.current=ce,y.current=Ye,b.current=De);let B=useRef(null);if(!B.current||B.current.key!==Ne){let ue={fontFamilyOptions:Lt.current,fontSizeOptions:wt.current,lineHeightOptions:St.current,minimumDefaultLineHeight:pt.current,maxListIndentation:Number(gt),scaleByRatio:V,...we!==void 0?{syntaxHighlighting:we}:{},...Se!==void 0?{grammarPreloadMode:Se}:{},...y.current!==void 0?{codeHighlightProvider:y.current}:{},...b.current!==void 0?{loadCodeHighlightProvider:b.current}:{},...P!==void 0?{maxAutoDetectCodeLength:P}:{},isCopyAllowed:G,showLineNumbers:Ze,...bt.current!==void 0?{languageOptions:bt.current}:{},...typeof ze=="boolean"?{isDraggableBoxEnabled:ze}:{},...ut.current?{featureFlags:ut.current}:{}};B.current={key:Ne,value:mo(ue)};}let W=B.current.value,me=useMemo(()=>{let ue=mergeThemes(defaultLuthorTheme,i??{});return M?{...ue,quote:`${ue.quote??""} ${M}`.trim()}:ue},[i,M]),xe=useMemo(()=>vn(le),[le]),yt=useMemo(()=>vn(R),[R]),Wt=useMemo(()=>ws(Z),[Z]),ho=useMemo(()=>vn(Wt),[Wt]),Ln=useMemo(()=>{let ue=Wt,Pt=createEditorThemeStyleVars(le),Xt=R,At={"--luthor-default-line-height":tt};return !ue&&!Pt&&!Xt?At:{...ue??{},...Pt,...Xt??{},...At}},[tt,Wt,le,R,ho,xe,yt]),[po,Vo]=useState(null);useImperativeHandle(Be,()=>po??{injectJSON:()=>{},getJSON:()=>Fe("json",go),getMarkdown:()=>Fe("markdown",go,be,Qe),getHTML:()=>Fe("html",go,be,Qe)},[Qe,po,be]);let bo=ue=>{Vo(ue),r&&ue.injectJSON(ps(r)),t?.(ue);};return jsx("div",{ref:te,className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper${K?" luthor-editor-wrapper--toolbar-pinned":""} ${g||""} ${e||""}`.trim(),"data-editor-theme":he,"data-inline-code-highlighting":et?"on":"off",style:Ln,children:jsx(as,{extensions:W,config:{theme:me},children:jsx(As,{isDark:Oe,toggleTheme:Ue,visualPlaceholder:Q.visual,jsonPlaceholder:Q.json,markdownPlaceholder:Q.markdown,htmlPlaceholder:Q.html,initialMode:Ge,availableModes:k,onReady:bo,toolbarLayout:f,toolbarVisibility:h,toolbarPosition:F,toolbarAlignment:p,toolbarClassName:L,toolbarStyleVars:I,isToolbarEnabled:fe,isToolbarPinned:K,isEditorViewTabsVisible:lt,headingOptions:se,paragraphLabel:ye,syncHeadingOptionsWithCommands:pe,slashCommandVisibility:X,shortcutConfig:ee,commandPaletteShortcutOnly:J,isListStyleDropdownEnabled:ge,featureFlags:Rt,editOnClick:O,sourceMetadataMode:be,markdownBridgeFlavor:Qe,markdownSourceOfTruth:qe,showLineNumbers:Ze})})})});_o.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:[...bn],components:{Editor:_o},toolbar:[...fi],config:Sr("extensive","Write anything..."),css:"extensive/styles.css"};function Ds(e={}){return {...hi,extensions:[...mo({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,maxListIndentation:e.maxListIndentation,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions,showLineNumbers:e.showLineNumbers,grammarPreloadMode:e.grammarPreloadMode})]}}export{Ct as $,Jo as A,ei as Aa,zn as B,yn as Ba,Dn as C,ti as Ca,Bn as D,Jt as Da,qs as E,_o as Ea,Un as F,fi as Fa,Ys as G,hi as Ga,To as H,Ds as Ha,Kn as I,_n as J,xo as K,Vn as L,jn as M,$n as N,qn as O,Yn as P,Go as Q,Jn as R,Gn as S,Ut as T,Wn as U,Zn as V,or as W,ar as X,H as Y,Zo as Z,io as _,Bs as a,cr as aa,je as b,dr as ba,Ks as c,en as ca,Co as d,mr as da,qo as e,br as ea,Fn as f,Lr as fa,Mn as g,Oo as ga,Nn as h,Sr as ha,Eo as i,Fr as ia,ko as j,Mr as ja,Lo as k,Or as ka,wo as l,Gl as la,So as m,Wl as ma,Hn as n,Xl as na,zt as o,zr as oa,xt as p,jr as pa,Qt as q,co as qa,Zt as r,$r as ra,eo as s,mo as sa,Rn as t,bn as ta,Pn as u,Jr as ua,Yo as v,Gr as va,Dt as w,Wr as wa,It as x,Xr as xa,An as y,Qr as ya,Bt as z,Zr as za};
@@ -1 +1 @@
1
- import {d,f,e as e$1}from'./chunk-SQTZVN2Z.js';import {b}from'./chunk-WM5NNMZA.js';import {ha,sa}from'./chunk-QON7NKIG.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var e={...d,codeIntelligence:true},L=e$1,r=forwardRef(({className:n,variantClassName:l,toolbarClassName:E,toolbarLayout:m,initialMode:c="visual",defaultEditorView:p,featureFlags:u,...M},f$1)=>{let D={...e,...u??{}};return jsx(f,{ref:f$1,...M,className:b("luthor-preset-md-editor",n),variantClassName:b("luthor-preset-md-editor__variant",l),toolbarClassName:b("luthor-preset-md-editor__toolbar",E),sourceFormat:"markdown",initialMode:c,defaultEditorView:p,markdownBridgeFlavor:"github",markdownSourceOfTruth:true,featureFlags:D,toolbarLayout:m??L})});r.displayName="MarkDownEditor";var g={id:"md-editor",label:"MD Editor",description:"Markdown-native feature set with visual, JSON, and MD source views.",extensions:sa({featureFlags:e}),components:{Editor:r},toolbar:["undo","redo","blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule","table","image"],config:ha("md-editor","Write markdown..."),css:"md-editor/styles.css"};export{r as a,g as b};
1
+ import {d,f,e as e$1}from'./chunk-PFWQGTSK.js';import {b}from'./chunk-RS22WMZX.js';import {ha,sa}from'./chunk-CVDX3AKZ.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var e={...d,codeIntelligence:true},L=e$1,r=forwardRef(({className:n,variantClassName:l,toolbarClassName:E,toolbarLayout:m,initialMode:c="visual",defaultEditorView:p,featureFlags:u,...M},f$1)=>{let D={...e,...u??{}};return jsx(f,{ref:f$1,...M,className:b("luthor-preset-md-editor",n),variantClassName:b("luthor-preset-md-editor__variant",l),toolbarClassName:b("luthor-preset-md-editor__toolbar",E),sourceFormat:"markdown",initialMode:c,defaultEditorView:p,markdownBridgeFlavor:"github",markdownSourceOfTruth:true,featureFlags:D,toolbarLayout:m??L})});r.displayName="MarkDownEditor";var g={id:"md-editor",label:"MD Editor",description:"Markdown-native feature set with visual, JSON, and MD source views.",extensions:sa({featureFlags:e}),components:{Editor:r},toolbar:["undo","redo","blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule","table","image"],config:ha("md-editor","Write markdown..."),css:"md-editor/styles.css"};export{r as a,g as b};
@@ -1 +1 @@
1
- import {ha,sa,Ea,ja}from'./chunk-QON7NKIG.js';import {jsonToMarkdown}from'@lyfie/luthor-headless';import {useRef,useState,useMemo,useCallback,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';var W=JSON.stringify({root:{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"",type:"text",version:1}],direction:null,format:"",indent:0,type:"paragraph",version:1}],direction:null,format:"",indent:0,type:"root",version:1}});function N(o){return typeof o=="number"?`${o}px`:o}function D(o,n){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){let l=o.trim();if(l.length===0)return n;let g=Number.parseFloat(l.replace("px",""));if(Number.isFinite(g))return g}return n}function ce(o){try{let n=o?JSON.parse(o):void 0;return ja(jsonToMarkdown(n))}catch{return ""}}function Z(o,n,l){return l<=n?n:Math.min(l,Math.max(n,o))}function me(o,n,l){o.focus();let L=Array.from(o.children).filter(s=>s instanceof HTMLElement).reduce((s,r)=>{let u=r.getBoundingClientRect(),M=u.top+u.height/2;if(!s)return r;let y=s.getBoundingClientRect(),P=y.top+y.height/2;return Math.abs(M-l)<Math.abs(P-l)?r:s},null)??o.firstElementChild??o,C=o.getBoundingClientRect(),x=L.getBoundingClientRect(),a=Z(n,C.left+1,C.right-1),c=Z(l,x.top+1,x.bottom-1),d=document,m=d.caretPositionFromPoint?.(a,c);if(m){let s=window.getSelection();if(!s)return;let r=document.createRange();r.setStart(m.offsetNode,m.offset),r.collapse(true),s.removeAllRanges(),s.addRange(r);return}let f=d.caretRangeFromPoint?.(a,c);if(!f)return;let p=window.getSelection();p&&(f.collapse(true),p.removeAllRanges(),p.addRange(f));}function j({className:o,variantClassName:n,initialTheme:l,onThemeChange:g,theme:z,defaultContent:L,showDefaultContent:C=false,placeholder:x,formattingOptions:a,onSend:c,outputFormat:d="md",clearOnSend:m=true,allowEmptySend:f=false,submitOnEnter:p=false,allowShiftEnter:s=true,minHeight:r=56,maxHeight:u=220,minWidth:M=240,maxWidth:y="100%",showBottomToolbar:P=true,toolbarButtons:te=[],toolbarClassName:oe,toolbarStyle:re,showSendButton:R=true,sendButtonPlacement:w="inside",sendButtonContent:K="Send",sendButtonAriaLabel:V="Send message",sendButtonClassName:I,scrollAreaClassName:B}){let F=useRef(null),E=useRef(null),[J,ie]=useState(()=>D(r,56)),q=useMemo(()=>D(r,56),[r]),A=useMemo(()=>D(u,220),[u]),O=useMemo(()=>({bold:a?.bold!==false,italic:a?.italic!==false,strikethrough:a?.strikethrough!==false}),[a]),ne=useMemo(()=>({disabledCommandIds:["history.undo","history.redo"],bindings:{"format.bold":[{key:"b",ctrlKey:true},{key:"b",metaKey:true}],"format.italic":[{key:"i",ctrlKey:true},{key:"i",metaKey:true}],"format.strikethrough":[{key:"x",ctrlKey:true,shiftKey:true},{key:"x",metaKey:true,shiftKey:true}],"format.code":false,"block.codeblock":false}}),[]),_=useCallback(()=>{let e=F.current?.getJSON()??W,t=ce(e);return {json:e,markdown:t,text:d==="json"?e:t}},[d]),T=useCallback(()=>{if(!c)return;let e=_();!f&&!e.markdown.trim()||(c({format:d,text:e.text,markdown:e.markdown,json:e.json}),m&&F.current?.injectJSON(W));},[f,m,c,d,_]),h=useCallback(()=>{let e=E.current;if(!e)return;let t=e.querySelector(".luthor-content-editable");if(!t)return;let i=Math.max(q,Math.min(A,t.scrollHeight));ie(i);},[A,q]),se=useCallback(e=>{!p||e.key!=="Enter"||e.nativeEvent.isComposing||e.shiftKey&&s||(e.preventDefault(),T());},[s,T,p]),le=useCallback(e=>{let t=e.target;if(t.closest("button, a, input, textarea, [contenteditable='true']")||t.closest(".luthor-simple-editor-bottom-toolbar"))return;let S=E.current?.querySelector(".luthor-content-editable");S&&(e.preventDefault(),me(S,e.clientX,e.clientY));},[]);useEffect(()=>{h();},[h]),useEffect(()=>{let e=E.current;if(!e)return;let t=e.querySelector(".luthor-content-editable");if(!t)return;let i=()=>h();t.addEventListener("input",i),t.addEventListener("keyup",i),t.addEventListener("paste",i);let S=typeof ResizeObserver<"u"?new ResizeObserver(()=>h()):null;S?.observe(t);let Y=new MutationObserver(()=>h());return Y.observe(t,{childList:true,subtree:true,characterData:true}),()=>{t.removeEventListener("input",i),t.removeEventListener("keyup",i),t.removeEventListener("paste",i),S?.disconnect(),Y.disconnect();}},[h]),useEffect(()=>{let t=E.current?.querySelector(".luthor-richtext-container");if(!t||!B)return;let i=B.split(/\s+/).filter(Boolean);if(i.length!==0)return t.classList.add(...i),()=>{t.classList.remove(...i);}},[B]);let ae=useMemo(()=>({"--luthor-simple-editor-min-height":N(r),"--luthor-simple-editor-max-height":N(u),"--luthor-simple-editor-current-height":`${J}px`,"--luthor-simple-editor-min-width":N(M),"--luthor-simple-editor-max-width":N(y)}),[J,u,y,r,M]);return jsx("div",{ref:E,className:["luthor-preset-simple-editor",R&&w==="inside"?"luthor-preset-simple-editor--send-inside":"",o].filter(Boolean).join(" "),style:ae,onKeyDownCapture:se,onMouseDownCapture:le,children:jsxs("div",{className:"luthor-simple-editor-row",children:[jsxs("div",{className:"luthor-simple-editor-shell",children:[jsx(Ea,{ref:F,initialTheme:l,onThemeChange:g,theme:z,defaultContent:L,showDefaultContent:C,placeholder:x,variantClassName:["luthor-preset-simple-editor__variant",n].filter(Boolean).join(" "),isToolbarEnabled:false,availableModes:["visual-only","visual"],initialMode:"visual",shortcutConfig:ne,featureFlags:{bold:O.bold,italic:O.italic,underline:false,strikethrough:O.strikethrough,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:false,horizontalRule:false,table:false,list:false,image:false,blockFormat:false,code:false,codeIntelligence:false,codeFormat:false,iframeEmbed:false,youTubeEmbed:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,emoji:false,draggableBlock:false,customNode:false,themeToggle:false,history:false}}),R&&w==="inside"&&jsx("button",{type:"button",className:["luthor-simple-editor-action","luthor-simple-editor-action-send","luthor-simple-editor-action-send--inside",I].filter(Boolean).join(" "),"data-testid":"simple-editor-send-button",onClick:T,"aria-label":V,children:K}),P&&jsx("div",{className:["luthor-simple-editor-bottom-toolbar",oe].filter(Boolean).join(" "),style:re,"data-testid":"simple-editor-actions",children:te.map(e=>jsx("button",{type:"button",className:["luthor-simple-editor-action",e.className].filter(Boolean).join(" "),"aria-label":e.ariaLabel,disabled:e.disabled,title:e.title,onClick:e.onClick,children:e.content},e.id))})]}),R&&w==="right"&&jsx("button",{type:"button",className:["luthor-simple-editor-action","luthor-simple-editor-action-send","luthor-simple-editor-action-send--right",I].filter(Boolean).join(" "),"data-testid":"simple-editor-send-button",onClick:T,"aria-label":V,children:K})]})})}var fe={id:"simple-editor",label:"Simple Editor",description:"Lightweight editor with constrained formatting and send controls.",extensions:sa({featureFlags:{bold:true,italic:true,underline:false,strikethrough:true,table:false,image:false,blockFormat:false,code:false,codeIntelligence:false,codeFormat:false,list:false,iframeEmbed:false,youTubeEmbed:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false,history:false}}),components:{Editor:j},toolbar:[],config:ha("simple-editor","Type your message..."),css:"simple-editor/styles.css"};export{j as a,fe as b};
1
+ import {ha,sa,Ea,ja}from'./chunk-CVDX3AKZ.js';import {jsonToMarkdown}from'@lyfie/luthor-headless';import {useRef,useState,useMemo,useCallback,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';var W=JSON.stringify({root:{children:[{children:[{detail:0,format:0,mode:"normal",style:"",text:"",type:"text",version:1}],direction:null,format:"",indent:0,type:"paragraph",version:1}],direction:null,format:"",indent:0,type:"root",version:1}});function N(o){return typeof o=="number"?`${o}px`:o}function D(o,n){if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"){let l=o.trim();if(l.length===0)return n;let g=Number.parseFloat(l.replace("px",""));if(Number.isFinite(g))return g}return n}function ce(o){try{let n=o?JSON.parse(o):void 0;return ja(jsonToMarkdown(n))}catch{return ""}}function Z(o,n,l){return l<=n?n:Math.min(l,Math.max(n,o))}function me(o,n,l){o.focus();let L=Array.from(o.children).filter(s=>s instanceof HTMLElement).reduce((s,r)=>{let u=r.getBoundingClientRect(),M=u.top+u.height/2;if(!s)return r;let y=s.getBoundingClientRect(),P=y.top+y.height/2;return Math.abs(M-l)<Math.abs(P-l)?r:s},null)??o.firstElementChild??o,C=o.getBoundingClientRect(),x=L.getBoundingClientRect(),a=Z(n,C.left+1,C.right-1),c=Z(l,x.top+1,x.bottom-1),d=document,m=d.caretPositionFromPoint?.(a,c);if(m){let s=window.getSelection();if(!s)return;let r=document.createRange();r.setStart(m.offsetNode,m.offset),r.collapse(true),s.removeAllRanges(),s.addRange(r);return}let f=d.caretRangeFromPoint?.(a,c);if(!f)return;let p=window.getSelection();p&&(f.collapse(true),p.removeAllRanges(),p.addRange(f));}function j({className:o,variantClassName:n,initialTheme:l,onThemeChange:g,theme:z,defaultContent:L,showDefaultContent:C=false,placeholder:x,formattingOptions:a,onSend:c,outputFormat:d="md",clearOnSend:m=true,allowEmptySend:f=false,submitOnEnter:p=false,allowShiftEnter:s=true,minHeight:r=56,maxHeight:u=220,minWidth:M=240,maxWidth:y="100%",showBottomToolbar:P=true,toolbarButtons:te=[],toolbarClassName:oe,toolbarStyle:re,showSendButton:R=true,sendButtonPlacement:w="inside",sendButtonContent:K="Send",sendButtonAriaLabel:V="Send message",sendButtonClassName:I,scrollAreaClassName:B}){let F=useRef(null),E=useRef(null),[J,ie]=useState(()=>D(r,56)),q=useMemo(()=>D(r,56),[r]),A=useMemo(()=>D(u,220),[u]),O=useMemo(()=>({bold:a?.bold!==false,italic:a?.italic!==false,strikethrough:a?.strikethrough!==false}),[a]),ne=useMemo(()=>({disabledCommandIds:["history.undo","history.redo"],bindings:{"format.bold":[{key:"b",ctrlKey:true},{key:"b",metaKey:true}],"format.italic":[{key:"i",ctrlKey:true},{key:"i",metaKey:true}],"format.strikethrough":[{key:"x",ctrlKey:true,shiftKey:true},{key:"x",metaKey:true,shiftKey:true}],"format.code":false,"block.codeblock":false}}),[]),_=useCallback(()=>{let e=F.current?.getJSON()??W,t=ce(e);return {json:e,markdown:t,text:d==="json"?e:t}},[d]),T=useCallback(()=>{if(!c)return;let e=_();!f&&!e.markdown.trim()||(c({format:d,text:e.text,markdown:e.markdown,json:e.json}),m&&F.current?.injectJSON(W));},[f,m,c,d,_]),h=useCallback(()=>{let e=E.current;if(!e)return;let t=e.querySelector(".luthor-content-editable");if(!t)return;let i=Math.max(q,Math.min(A,t.scrollHeight));ie(i);},[A,q]),se=useCallback(e=>{!p||e.key!=="Enter"||e.nativeEvent.isComposing||e.shiftKey&&s||(e.preventDefault(),T());},[s,T,p]),le=useCallback(e=>{let t=e.target;if(t.closest("button, a, input, textarea, [contenteditable='true']")||t.closest(".luthor-simple-editor-bottom-toolbar"))return;let S=E.current?.querySelector(".luthor-content-editable");S&&(e.preventDefault(),me(S,e.clientX,e.clientY));},[]);useEffect(()=>{h();},[h]),useEffect(()=>{let e=E.current;if(!e)return;let t=e.querySelector(".luthor-content-editable");if(!t)return;let i=()=>h();t.addEventListener("input",i),t.addEventListener("keyup",i),t.addEventListener("paste",i);let S=typeof ResizeObserver<"u"?new ResizeObserver(()=>h()):null;S?.observe(t);let Y=new MutationObserver(()=>h());return Y.observe(t,{childList:true,subtree:true,characterData:true}),()=>{t.removeEventListener("input",i),t.removeEventListener("keyup",i),t.removeEventListener("paste",i),S?.disconnect(),Y.disconnect();}},[h]),useEffect(()=>{let t=E.current?.querySelector(".luthor-richtext-container");if(!t||!B)return;let i=B.split(/\s+/).filter(Boolean);if(i.length!==0)return t.classList.add(...i),()=>{t.classList.remove(...i);}},[B]);let ae=useMemo(()=>({"--luthor-simple-editor-min-height":N(r),"--luthor-simple-editor-max-height":N(u),"--luthor-simple-editor-current-height":`${J}px`,"--luthor-simple-editor-min-width":N(M),"--luthor-simple-editor-max-width":N(y)}),[J,u,y,r,M]);return jsx("div",{ref:E,className:["luthor-preset-simple-editor",R&&w==="inside"?"luthor-preset-simple-editor--send-inside":"",o].filter(Boolean).join(" "),style:ae,onKeyDownCapture:se,onMouseDownCapture:le,children:jsxs("div",{className:"luthor-simple-editor-row",children:[jsxs("div",{className:"luthor-simple-editor-shell",children:[jsx(Ea,{ref:F,initialTheme:l,onThemeChange:g,theme:z,defaultContent:L,showDefaultContent:C,placeholder:x,variantClassName:["luthor-preset-simple-editor__variant",n].filter(Boolean).join(" "),isToolbarEnabled:false,availableModes:["visual-only","visual"],initialMode:"visual",shortcutConfig:ne,featureFlags:{bold:O.bold,italic:O.italic,underline:false,strikethrough:O.strikethrough,fontFamily:false,fontSize:false,lineHeight:false,textColor:false,textHighlight:false,subscript:false,superscript:false,link:false,horizontalRule:false,table:false,list:false,image:false,blockFormat:false,code:false,codeIntelligence:false,codeFormat:false,iframeEmbed:false,youTubeEmbed:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,emoji:false,draggableBlock:false,customNode:false,themeToggle:false,history:false}}),R&&w==="inside"&&jsx("button",{type:"button",className:["luthor-simple-editor-action","luthor-simple-editor-action-send","luthor-simple-editor-action-send--inside",I].filter(Boolean).join(" "),"data-testid":"simple-editor-send-button",onClick:T,"aria-label":V,children:K}),P&&jsx("div",{className:["luthor-simple-editor-bottom-toolbar",oe].filter(Boolean).join(" "),style:re,"data-testid":"simple-editor-actions",children:te.map(e=>jsx("button",{type:"button",className:["luthor-simple-editor-action",e.className].filter(Boolean).join(" "),"aria-label":e.ariaLabel,disabled:e.disabled,title:e.title,onClick:e.onClick,children:e.content},e.id))})]}),R&&w==="right"&&jsx("button",{type:"button",className:["luthor-simple-editor-action","luthor-simple-editor-action-send","luthor-simple-editor-action-send--right",I].filter(Boolean).join(" "),"data-testid":"simple-editor-send-button",onClick:T,"aria-label":V,children:K})]})})}var fe={id:"simple-editor",label:"Simple Editor",description:"Lightweight editor with constrained formatting and send controls.",extensions:sa({featureFlags:{bold:true,italic:true,underline:false,strikethrough:true,table:false,image:false,blockFormat:false,code:false,codeIntelligence:false,codeFormat:false,list:false,iframeEmbed:false,youTubeEmbed:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false,history:false}}),components:{Editor:j},toolbar:[],config:ha("simple-editor","Type your message..."),css:"simple-editor/styles.css"};export{j as a,fe as b};
@@ -0,0 +1 @@
1
+ import {a,b as b$1}from'./chunk-RS22WMZX.js';import {Ea,ha,sa}from'./chunk-CVDX3AKZ.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};
@@ -0,0 +1 @@
1
+ import {a,b}from'./chunk-RS22WMZX.js';import {Ea,ha,sa}from'./chunk-CVDX3AKZ.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};
@@ -1 +1 @@
1
- import {a}from'./chunk-QON7NKIG.js';var s=class{constructor(e,a$1={}){a(this,"defaults");a(this,"enforced");this.defaults={...e},this.enforced={...a$1};}resolve(e){return {...this.defaults,...e??{},...this.enforced}}};function n(...t){return t.filter(e=>typeof e=="string"&&e.trim().length>0).join(" ")}export{s as a,n as b};
1
+ import {a}from'./chunk-CVDX3AKZ.js';var s=class{constructor(e,a$1={}){a(this,"defaults");a(this,"enforced");this.defaults={...e},this.enforced={...a$1};}resolve(e){return {...this.defaults,...e??{},...this.enforced}}};function n(...t){return t.filter(e=>typeof e=="string"&&e.trim().length>0).join(" ")}export{s as a,n as b};
@@ -1 +1 @@
1
- import {f as f$1,e,d}from'./chunk-SQTZVN2Z.js';import {b}from'./chunk-WM5NNMZA.js';import {ha,sa}from'./chunk-QON7NKIG.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var a=d,f=e,o=forwardRef(({className:l,variantClassName:E,toolbarClassName:m,toolbarLayout:L,initialMode:n="visual",defaultEditorView:c,...p},T)=>jsx(f$1,{ref:T,...p,className:b("luthor-preset-html-editor",l),variantClassName:b("luthor-preset-html-editor__variant",E),toolbarClassName:b("luthor-preset-html-editor__toolbar",m),sourceFormat:"html",initialMode:n,defaultEditorView:c,toolbarLayout:L??f}));o.displayName="HTMLEditor";var _={id:"html-editor",label:"HTML Editor",description:"HTML-focused preset with visual, JSON, and HTML source views.",extensions:sa({featureFlags:a}),components:{Editor:o},toolbar:["undo","redo","blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule","table","image"],config:ha("html-editor","Write HTML-compatible content..."),css:"html-editor/styles.css"};export{o as a,_ as b};
1
+ import {f as f$1,e,d}from'./chunk-PFWQGTSK.js';import {b}from'./chunk-RS22WMZX.js';import {ha,sa}from'./chunk-CVDX3AKZ.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var a=d,f=e,o=forwardRef(({className:l,variantClassName:E,toolbarClassName:m,toolbarLayout:L,initialMode:n="visual",defaultEditorView:c,...p},T)=>jsx(f$1,{ref:T,...p,className:b("luthor-preset-html-editor",l),variantClassName:b("luthor-preset-html-editor__variant",E),toolbarClassName:b("luthor-preset-html-editor__toolbar",m),sourceFormat:"html",initialMode:n,defaultEditorView:c,toolbarLayout:L??f}));o.displayName="HTMLEditor";var _={id:"html-editor",label:"HTML Editor",description:"HTML-focused preset with visual, JSON, and HTML source views.",extensions:sa({featureFlags:a}),components:{Editor:o},toolbar:["undo","redo","blockFormat","quote","alignLeft","alignCenter","alignRight","alignJustify","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule","table","image"],config:ha("html-editor","Write HTML-compatible content..."),css:"html-editor/styles.css"};export{o as a,_ as b};
@@ -0,0 +1 @@
1
+ import {a,b}from'./chunk-RS22WMZX.js';import {sa,ha,ka,ja,ia,fa,ga}from'./chunk-CVDX3AKZ.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};