@lyfie/luthor 2.6.4 → 2.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import {a,b as b$1}from'./chunk-KORFS25D.js';import {ha,sa,Ea}from'./chunk-G4AWPZBL.js';import {jsx}from'react/jsx-runtime';var b=["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:false,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:f=false,...c}){let h={...p.resolve(m),draggableBlock:u};return jsx(Ea,{...c,className:b$1("luthor-preset-slash-editor",i),variantClassName:b$1("luthor-preset-slash-editor__variant",n),availableModes:b,isToolbarEnabled:f,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:false,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};
1
+ import {a,b as b$1}from'./chunk-MNY5WN6Z.js';import {ha,sa,Ea}from'./chunk-GL7DJO7R.js';import {jsx}from'react/jsx-runtime';var b=["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:false,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:f=false,...c}){let h={...p.resolve(m),draggableBlock:u};return jsx(Ea,{...c,className:b$1("luthor-preset-slash-editor",i),variantClassName:b$1("luthor-preset-slash-editor__variant",n),availableModes:b,isToolbarEnabled:f,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:false,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 @@
1
+ import {a,b}from'./chunk-MNY5WN6Z.js';import {sa,ha,ka,ja,ia,fa,ga}from'./chunk-GL7DJO7R.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:ue,useEditor:ce}=createEditorSystem(),W=["visual","json","markdown","html"],he={visual:"Visual",json:"JSON",markdown:"MD",html:"HTML"},me={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"},Q="Start writing...",q="Enter JSON document content...",G="Enter Markdown content...",K="Enter HTML content...",y={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:""}]}]}},J={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:false,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},be={draggableBlock:false,themeToggle:false,table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false,slashCommand:false,commandPalette:false,contextMenu:false,floatingToolbar:false},pe=new a(J,be);function D(a){return a instanceof Error&&a.message.trim()?a.message.trim():"Unable to process the current source content."}function X(a){return a&&typeof a=="object"?a:y}function Z(a){let l=a.trim();return l?JSON.parse(l):y}function ge(a,l){switch(a){case "json":return Z(l);case "markdown":return markdownToJSON(l);case "html":return htmlToJSON(l)}}function c(a,l){let d=X(l);switch(a){case "json":return ia(JSON.stringify(d));case "markdown":return ja(jsonToMarkdown(d));case "html":return ka(jsonToHTML(d))}}function Ee(a){return typeof a=="string"||typeof a>"u"?{visual:a??Q,json:q,markdown:G,html:K}:{visual:a.visual??Q,json:a.json??q,markdown:a.markdown??G,html:a.html??K}}function fe({initialMode:a,placeholders:l,onReady:d}){let{activeStates:O,commands:e,export:h,import:b}=ce(),[n,S]=useState(a),[g,p]=useState({json:"",markdown:"",html:""}),[H,m]=useState(null),v=useRef(false),t=O,E=useCallback(()=>{let s=X(h.toJSON()),i={json:c("json",s),markdown:c("markdown",s),html:c("html",s)};return p(i),i},[h]),L=useCallback((s,i)=>{let u=ge(s,i);return b.fromJSON(u),u},[b]),M=useMemo(()=>({injectJSON:s=>{try{let i=Z(s);b.fromJSON(i),m(null),E();}catch(i){m({mode:"json",error:D(i)});}},getJSON:()=>c("json",h.toJSON()),getMarkdown:()=>c("markdown",h.toJSON()),getHTML:()=>c("html",h.toJSON())}),[h,b,E]);useEffect(()=>{!d||v.current||(v.current=true,d(M));},[M,d]);let C=useCallback(s=>{if(s!==n){if(n==="visual"){if(s!=="visual")try{E(),m(null);}catch(i){m({mode:s,error:D(i)});return}S(s);return}try{let i=g[n],u=L(n,i);if(s==="visual"){m(null),S("visual");return}let ee=c(s,u);p(te=>({...te,[s]:ee})),m(null),S(s);}catch(i){m({mode:n,error:D(i)});}}},[n,L,g,E]),w=useCallback(()=>{n==="visual"&&(t.bold&&e.toggleBold?.(),t.italic&&e.toggleItalic?.(),t.strikethrough&&e.toggleStrikethrough?.(),t.code&&e.formatText?.("code"),e.removeLink?.());},[e,n,t.bold,t.code,t.italic,t.strikethrough]),R=useCallback(()=>{n==="visual"&&(t.unorderedList&&e.toggleUnorderedList?.(),t.orderedList&&e.toggleOrderedList?.(),t.isQuote&&e.toggleQuote?.(),t.isInCodeBlock&&e.toggleCodeBlock?.(),e.toggleParagraph?.());},[e,n,t.isInCodeBlock,t.isQuote,t.orderedList,t.unorderedList]),T=useCallback(()=>{n==="visual"&&e.insertHardBreak?.();},[e,n]),r=n==="visual";return jsxs("div",{className:"luthor-editor","data-mode":n,children:[jsx("div",{className:"luthor-editor-header",children:jsx(fa,{mode:n,onModeChange:s=>C(s),availableModes:W,labels:he})}),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${t.bold?" is-active":""}`,onClick:()=>e.toggleBold?.(),disabled:!r,children:"Bold"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.italic?" is-active":""}`,onClick:()=>e.toggleItalic?.(),disabled:!r,children:"Italic"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.strikethrough?" is-active":""}`,onClick:()=>e.toggleStrikethrough?.(),disabled:!r,children:"Strike"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.code?" is-active":""}`,onClick:()=>e.formatText?.("code"),disabled:!r,children:"Code"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:w,disabled:!r,children:"Clear marks"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:R,disabled:!r,children:"Clear nodes"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isParagraph?" is-active":""}`,onClick:()=>e.toggleParagraph?.(),disabled:!r,children:"Paragraph"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH1?" is-active":""}`,onClick:()=>e.toggleHeading?.("h1"),disabled:!r,children:"H1"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH2?" is-active":""}`,onClick:()=>e.toggleHeading?.("h2"),disabled:!r,children:"H2"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH3?" is-active":""}`,onClick:()=>e.toggleHeading?.("h3"),disabled:!r,children:"H3"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH4?" is-active":""}`,onClick:()=>e.toggleHeading?.("h4"),disabled:!r,children:"H4"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH5?" is-active":""}`,onClick:()=>e.toggleHeading?.("h5"),disabled:!r,children:"H5"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH6?" is-active":""}`,onClick:()=>e.toggleHeading?.("h6"),disabled:!r,children:"H6"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.unorderedList?" is-active":""}`,onClick:()=>e.toggleUnorderedList?.(),disabled:!r,children:"Bullet list"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.orderedList?" is-active":""}`,onClick:()=>e.toggleOrderedList?.(),disabled:!r,children:"Ordered list"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isInCodeBlock?" is-active":""}`,onClick:()=>e.toggleCodeBlock?.(),disabled:!r,children:"Code block"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isQuote?" is-active":""}`,onClick:()=>e.toggleQuote?.(),disabled:!r,children:"Blockquote"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>e.insertHorizontalRule?.(),disabled:!r,children:"Horizontal rule"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:T,disabled:!r,children:"Hard break"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>e.undo?.(),disabled:!r||!t.canUndo,children:"Undo"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>e.redo?.(),disabled:!r||!t.canRedo,children:"Redo"})]}),jsx("div",{className:`luthor-preset-headless-editor__visual-shell${r?"":" is-hidden"}`,"aria-hidden":!r,children:jsx(RichText,{placeholder:l.visual,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"}})}),!r&&jsxs("div",{className:"luthor-source-panel",children:[H&&H.mode===n&&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:me[n]}),jsx("p",{children:H.error}),jsx("small",{children:"Fix the source input and try again."})]})]}),n==="json"&&jsx(ga,{value:g.json,onChange:s=>{p(i=>({...i,json:s}));},placeholder:l.json}),n==="markdown"&&jsx(ga,{value:g.markdown,onChange:s=>{p(i=>({...i,markdown:s}));},placeholder:l.markdown,className:"luthor-source-view--wrapped",wrap:"soft"}),n==="html"&&jsx(ga,{value:g.html,onChange:s=>{p(i=>({...i,html:s}));},placeholder:l.html,className:"luthor-source-view--wrapped",wrap:"soft"})]})]})}var A=forwardRef(({className:a,variantClassName:l,initialTheme:d="light",onThemeChange:O,placeholder:e,onReady:h,defaultContent:b$1,showDefaultContent:n=true,initialMode:S="visual",defaultEditorView:g,featureFlags:p,...H},m)=>{let[v,t]=useState(d),E=g??S,L=W.includes(E)?E:"visual",M=useMemo(()=>Ee(e),[e]),C=useMemo(()=>pe.resolve(p),[p]),w=useMemo(()=>JSON.stringify(C),[C]),R=useMemo(()=>{let u=JSON.parse(w);return sa({featureFlags:u})},[w]),[T,r]=useState(null),s=useRef(false);useEffect(()=>{t(d);},[d]),useEffect(()=>{O?.(v);},[v,O]),useImperativeHandle(m,()=>T??{injectJSON:()=>{},getJSON:()=>c("json",y),getMarkdown:()=>c("markdown",y),getHTML:()=>c("html",y)},[T]);let i=useCallback(u=>{r(u),s.current||(b$1&&u.injectJSON(b$1),s.current=true),h?.(u);},[b$1,h,n]);return jsx("div",{className:b("luthor-preset","luthor-preset-headless-editor","luthor-editor-wrapper","luthor-preset-headless-editor__variant",l,a),"data-editor-theme":v,children:jsx(ue,{extensions:R,children:jsx(fe,{initialMode:L,placeholders:M,onReady:i})})})});A.displayName="HeadlessEditorPreset";var ve={id:"headless-editor",label:"Headless Editor",description:"Headless-style rich editor with text toolbar pills and source tabs.",extensions:sa({featureFlags:J}),components:{Editor:A},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{A as a,ve as b};
@@ -1 +1 @@
1
- import {f as f$1,e,d}from'./chunk-BYUGKIJC.js';import {b}from'./chunk-KORFS25D.js';import {ha,sa}from'./chunk-G4AWPZBL.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var E=d,_=e,t=forwardRef(({className:a,variantClassName:l,toolbarClassName:m,toolbarLayout:L,initialMode:c="visual",defaultEditorView:p,...n},T)=>jsx(f$1,{ref:T,...n,className:b("luthor-preset-html-editor",a),variantClassName:b("luthor-preset-html-editor__variant",l),toolbarClassName:b("luthor-preset-html-editor__toolbar",m),sourceFormat:"html",initialMode:c,defaultEditorView:p,toolbarLayout:L??_}));t.displayName="HTMLEditor";var f={id:"html-editor",label:"HTML Editor",description:"HTML-focused preset with visual, JSON, and HTML source views.",extensions:sa({featureFlags:E}),components:{Editor:t},toolbar:["undo","redo","blockFormat","quote","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule"],config:ha("html-editor","Write HTML-compatible content..."),css:"html-editor/styles.css"};export{t as a,f as b};
1
+ import {f as f$1,e,d}from'./chunk-QR4BVSTW.js';import {b}from'./chunk-MNY5WN6Z.js';import {ha,sa}from'./chunk-GL7DJO7R.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var E=d,_=e,t=forwardRef(({className:a,variantClassName:l,toolbarClassName:m,toolbarLayout:L,initialMode:c="visual",defaultEditorView:p,...n},T)=>jsx(f$1,{ref:T,...n,className:b("luthor-preset-html-editor",a),variantClassName:b("luthor-preset-html-editor__variant",l),toolbarClassName:b("luthor-preset-html-editor__toolbar",m),sourceFormat:"html",initialMode:c,defaultEditorView:p,toolbarLayout:L??_}));t.displayName="HTMLEditor";var f={id:"html-editor",label:"HTML Editor",description:"HTML-focused preset with visual, JSON, and HTML source views.",extensions:sa({featureFlags:E}),components:{Editor:t},toolbar:["undo","redo","blockFormat","quote","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule"],config:ha("html-editor","Write HTML-compatible content..."),css:"html-editor/styles.css"};export{t as a,f as b};
@@ -0,0 +1,6 @@
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,clearLexicalSelection,markdownToJSON,htmlToJSON,resolveLinkNodeKeyFromAnchor}from'@lyfie/luthor-headless';import Bi,{forwardRef,useState,useRef,useMemo,useEffect,useImperativeHandle,createElement,useLayoutEffect,useCallback}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var Rr=Object.defineProperty;var Ar=(e,t,o)=>t in e?Rr(e,t,{enumerable:true,configurable:true,writable:true,value:o}):e[t]=o;var Qa=(e,t,o)=>Ar(e,typeof t!="symbol"?t+"":t,o);var Be=["h1","h2","h3","h4","h5","h6"],es={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"]}]},Xt={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 Pr(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 zr(e,t){return Pr(e.target)?Zo(t):false}function Zo(e){let t=e.key.toLowerCase();return !(!!e.ctrlKey||!!e.metaKey)||e.altKey?false:t==="b"||t==="i"||t==="u"||t==="k"}function Qo(e){return typeof e.setCodeLanguage=="function"&&typeof e.autoDetectCodeLanguage=="function"}function Br(e){return typeof e.toggleSubscript=="function"}function Dr(e){return typeof e.toggleSuperscript=="function"}function Ur(e){return typeof e.insertIframeEmbed=="function"}function Kr(e){return typeof e.insertYouTubeEmbed=="function"}function Vr(e){return typeof e.insertEmoji=="function"}function _r(e){return e.slice(1)}function jr(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 $r(e){if(!e||e.length===0)return [...Be];let t=new Set,o=[];for(let n of e)!Be.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Be]}function wo(e,t){return Gr(To(t),t?.shortcutConfig).filter(n=>!n.condition||n.condition(e))}function ee(e,t){return typeof e[t]=="function"}function Qt(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 qr(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:Qt(o),denylist:new Set}}let t=e;return {allowlist:Qt(t.allowlist),denylist:Qt(t.denylist)}}function en(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 Yr(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],o=[];for(let n of t){let i=en(n);i&&o.push(i);}return o}function Jr(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function Gr(e,t){if(!t)return [...e];let o=Qt(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 m=u.shortcuts?[...u.shortcuts]:void 0;if(!!n&&Object.prototype.hasOwnProperty.call(n,u.id)&&n){let v=n[u.id],y=v===void 0?[]:Yr(v);m=y.length>0?y:void 0;}if(m&&m.length>0){let v=[];for(let y of m){let f=en(y);if(!f||i&&Zo(f))continue;let h=Jr(f);r&&l.has(h)||(l.add(h),v.push(f));}m=v.length>0?v:void 0;}return {...u,shortcuts:m}})}function To(e){let t=e?.isFeatureEnabled??(()=>true),o=$r(e?.headingOptions),n=e?.paragraphLabel?.trim()||"Paragraph",i=o.map(r=>{let l=_r(r);return {id:`block.heading${l}`,label:`Heading ${l}`,description:jr(r),category:"Block",action:s=>s.toggleHeading?.(r),shortcuts:[{key:l,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:s=>t("blockFormat")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&Br(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")&&Dr(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&Qo(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")&&Qo(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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")&&ee(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 m=r.resolveEmojiShortcode(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[m]=r.getEmojiSuggestions(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}}r.insertEmoji(l);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&Vr(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")&&ee(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")&&Ur(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")&&Kr(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")&&ee(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")&&ee(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")&&ee(r,"showCommandPalette")}]}function tn(e,t){let o=t?.commandPaletteShortcutOnly===true;return wo(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]?nn(n.shortcuts[0]):void 0}))}function on(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}=qr(t?.slashCommandVisibility),l=i.size>0;return wo(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]?nn(s.shortcuts[0]):void 0}))}function nn(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 rn(e,t=document.body,o){let n=wo(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 m of u.shortcuts)if(!(o?.shortcutConfig?.preventNativeConflicts!==false&&zr(l,m))&&i(l,m)&&!!l.ctrlKey==!!m.ctrlKey&&!!l.metaKey==!!m.metaKey&&!!l.shiftKey==!!m.shiftKey&&!!l.altKey==!!m.altKey){m.preventDefault!==false&&l.preventDefault(),(!u.condition||u.condition(e))&&u.action(e);return}}}};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)}function z(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 Zt=z("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"})),eo=z("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"})]})),to=z("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"})]})),oo=z("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"})]})),no=z("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),ln=z("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"})]})),xt=z("LinkIcon",jsxs(Fragment,{children:[jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),ft=z("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"})]})),ro=z("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"})]})),io=z("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"})]})),lo=z("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"})]})),an=z("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"})]})),sn=z("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"})]})),So=z("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"})]})),It=z("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M15 12H3"}),jsx("path",{d:"M17 19H3"})]})),ht=z("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),un=z("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h18"}),jsx("path",{d:"M3 12h18"}),jsx("path",{d:"M3 19h18"})]})),Ft=z("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M21 12H9"}),jsx("path",{d:"M21 19H7"})]})),xo=z("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"})]})),cn=z("MinusIcon",jsx("path",{d:"M5 12h14"})),dn=z("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"})]})),mn=z("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"})]})),is=z("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"})]})),gn=z("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"})]})),ls=z("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"})]})),ao=z("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"})),fn=z("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"})]})),hn=z("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"})]})),so=z("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"})]})),pn=z("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"})]})),bn=z("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"})]})),yn=z("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"})]})),vn=z("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"})),Cn=z("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Io=z("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"})]})),En=z("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"})]})),kn=z("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"})]})),Mt=z("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),Ln=z("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Sn({isOpen:e,onClose:t,commands:o}){let[n,i]=useState(""),[r,l]=useState(0),s=useRef(null),u=useRef(null),m=o.filter(y=>`${y.label} ${y.description||""} ${y.keywords?.join(" ")||""}`.toLowerCase().includes(n.toLowerCase())),C=m.reduce((y,f)=>{let h=f.category||"Other";return y[h]||(y[h]=[]),y[h].push(f),y},{}),v=m;return useEffect(()=>{l(0);},[n]),useEffect(()=>{e&&s.current&&(s.current.focus({preventScroll:true}),i(""),l(0));},[e]),useEffect(()=>{if(!e)return;let y=u.current;if(!y)return;y.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,n]),useEffect(()=>{let y=f=>{if(e)switch(f.key){case "Escape":f.preventDefault(),f.stopPropagation(),t();break;case "ArrowDown":f.preventDefault(),f.stopPropagation(),l(h=>Math.min(h+1,v.length-1));break;case "ArrowUp":f.preventDefault(),f.stopPropagation(),l(h=>Math.max(h-1,0));break;case "Enter":f.preventDefault(),f.stopPropagation(),v[r]&&(v[r].action(),t());break}};return document.addEventListener("keydown",y,true),()=>document.removeEventListener("keydown",y,true)},[e,r,v,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:y=>y.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(Cn,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:s,type:"text",placeholder:"Type a command or search...",value:n,onChange:y=>i(y.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(C).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(C).map(([y,f])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:y}),f.map(h=>{let d=v.indexOf(h);return jsxs("div",{className:`luthor-command-palette-item ${d===r?"selected":""}`,onClick:()=>{h.action(),t();},onMouseEnter:()=>l(d),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:h.label}),h.description&&jsx("div",{className:"luthor-command-palette-item-description",children:h.description})]}),h.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:h.shortcut})]},h.id)})]},y))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(ao,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var Xr={"--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 Qr(e){return e?e.closest(".luthor-editor-wrapper"):null}function Zr(e){return e?Qr(e)??e:null}function ei(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),o={};for(let[n,i]of Object.entries(Xr)){let r=t.getPropertyValue(n).trim()||i;o[n]=r;}return o}function De(e){return ei(Zr(e))}function Nt(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return De(o)}function pt(e){return e?e.closest(".luthor-editor-wrapper")??null:null}function xn(e,t,o){return e<t?t:e>o?o:e}function ti(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 oi(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,m=o.left+n,C=Math.max(m,o.right-t-n);if(r){let v=u<m||u>C,y=s>=m&&s<=C;v&&y&&(u=s);}return xn(u,m,C)}function ni(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,m=s,C=o.top+i,v=Math.max(C,o.bottom-t-i);if(l){let y=m<C||m>v,f=u>=C&&u<=v;y&&f&&(m=u);}return xn(m,C,v)}function ve({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 m=ti(o),C=Math.max(0,m.width-i*2),v=Math.max(0,m.height-i*2),y=Math.max(0,Math.min(t.width,C)),f=Math.max(0,Math.min(t.height,v)),h=oi(e,y,m,i,r,s),d=ni(e,f,m,n,i,l,u);if(o){let E=o.getBoundingClientRect();return {position:"absolute",left:h-E.left+o.scrollLeft,top:d-E.top+o.scrollTop,maxWidth:C>0?C:void 0,maxHeight:v>0?v:void 0}}return {position:"fixed",left:h,top:d,maxWidth:C>0?C:void 0,maxHeight:v>0?v:void 0}}function co(e,t){return {x:e,y:t,width:1,height:1,left:e,right:e+1,top:t,bottom:t+1,toJSON:()=>({})}}function Fn({isOpen:e,query:t,position:o,portalContainer:n,suggestions:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[C,v]=useState(void 0);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let h=d=>{let E=i.length>0;switch(d.key){case "Escape":d.preventDefault(),d.stopPropagation(),r();break;case "ArrowDown":if(!E)return;d.preventDefault(),d.stopPropagation(),u(T=>Math.min(T+1,Math.max(i.length-1,0)));break;case "ArrowUp":if(!E)return;d.preventDefault(),d.stopPropagation(),u(T=>Math.max(T-1,0));break;case "Enter":case "Tab":if(!E||!i[s])return;d.preventDefault(),d.stopPropagation(),l(i[s].emoji);break}};return document.addEventListener("keydown",h,true),()=>document.removeEventListener("keydown",h,true)},[e,r,l,s,i]);let y=useCallback(h=>{if(!o)return;let d=m.current?.getBoundingClientRect(),E=ve({anchorRect:co(o.x,o.y),overlay:{width:d?.width??320,height:d?.height??280},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});v({...E,visibility:h?"visible":"hidden",...Nt()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;y(false);let h=window.requestAnimationFrame(()=>y(true));return ()=>window.cancelAnimationFrame(h)},[e,o,y]),useEffect(()=>{if(!e||!o)return;let h=()=>y(true);return window.addEventListener("resize",h),window.addEventListener("scroll",h,true),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,true);}},[e,o,y]),!e||!o)return null;let f=jsxs("div",{className:"luthor-emoji-menu",ref:m,style:C,onPointerDown:h=>{h.stopPropagation();},onMouseDown:h=>{h.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((h,d)=>{let E=d===s,T=h.shortcodes[0]?`:${h.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${E?"selected":""}`,onMouseEnter:()=>u(d),onMouseDown:I=>{I.preventDefault(),I.stopPropagation();},onClick:I=>{I.preventDefault(),I.stopPropagation(),l(h.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:h.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:h.label}),T&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:T})]})]},`${h.emoji}-${h.label}`)})})]});return typeof document>"u"?f:createPortal(f,n??document.body)}function Nn({isOpen:e,query:t,position:o,portalContainer:n,commands:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[C,v]=useState(void 0),y=useMemo(()=>{let E=t.trim().toLowerCase();return E?i.filter(T=>`${T.label} ${T.description||""} ${T.keywords?.join(" ")||""}`.toLowerCase().includes(E)):i},[i,t]),f=useMemo(()=>y.reduce((E,T)=>{let I=T.category||"Other";return E[I]||(E[I]=[]),E[I].push(T),E},{}),[y]);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let E=T=>{let I=y.length>0;switch(T.key){case "Escape":T.preventDefault(),T.stopPropagation(),r();break;case "ArrowDown":if(!I)return;T.preventDefault(),T.stopPropagation(),u(W=>Math.min(W+1,Math.max(y.length-1,0)));break;case "ArrowUp":if(!I)return;T.preventDefault(),T.stopPropagation(),u(W=>Math.max(W-1,0));break;case "Enter":case "Tab":if(!I||!y[s])return;T.preventDefault(),T.stopPropagation(),l(y[s].id);break}};return document.addEventListener("keydown",E,true),()=>document.removeEventListener("keydown",E,true)},[y,e,r,l,s]);let h=useCallback(E=>{if(!o)return;let T=m.current?.getBoundingClientRect(),I=ve({anchorRect:co(o.x,o.y),overlay:{width:T?.width??420,height:T?.height??360},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});v({...I,visibility:E?"visible":"hidden",...Nt()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;h(false);let E=window.requestAnimationFrame(()=>h(true));return ()=>window.cancelAnimationFrame(E)},[e,o,h]),useEffect(()=>{if(!e||!o)return;let E=()=>h(true);return window.addEventListener("resize",E),window.addEventListener("scroll",E,true),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,true);}},[e,o,h]),!e||!o)return null;let d=jsxs("div",{className:"luthor-slash-menu",ref:m,style:C,onPointerDown:E=>{E.stopPropagation();},onMouseDown:E=>{E.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:y.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(f).map(([E,T])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:E}),T.map(I=>{let W=y.indexOf(I);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${W===s?"selected":""}`,onMouseEnter:()=>u(W),onMouseDown:A=>{A.preventDefault(),A.stopPropagation();},onClick:A=>{A.preventDefault(),A.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)})]},E))})]});return typeof document>"u"?d:createPortal(d,n??document.body)}function R({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 Oo({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 Vt({value:e,onValueChange:t,options:o,placeholder:n="Select..."}){let[i,r]=useState(false),[l,s]=useState(void 0),[u,m]=useState(null),C=useRef(null),v=useRef(null);useEffect(()=>{if(!i)return;let f=()=>{let d=C.current?.querySelector(".luthor-select-trigger");if(!d)return;let E=d.getBoundingClientRect(),T=v.current?.getBoundingClientRect(),I=Math.max(T?.width??0,v.current?.scrollWidth??0),W=pt(d);m(W);let D=Math.max(E.width,I),A=T?.height??220,ne=ve({anchorRect:E,overlay:{width:D,height:A},portalContainer:W,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});s({...ne,width:D,...De(d)});};f();let h=()=>f();return window.addEventListener("resize",h),window.addEventListener("scroll",h,true),()=>{window.removeEventListener("resize",h),window.removeEventListener("scroll",h,true),m(null);}},[i]),useLayoutEffect(()=>{if(!i)return;let f=C.current?.querySelector(".luthor-select-trigger");if(!f)return;let h=f.getBoundingClientRect(),d=pt(f);m(d);let E=ve({anchorRect:h,overlay:{width:h.width,height:220},portalContainer:d,gap:4,margin:8});s({...E,width:h.width,...De(f)});let T=window.requestAnimationFrame(()=>{let I=v.current?.getBoundingClientRect(),W=Math.max(I?.width??0,v.current?.scrollWidth??0),D=Math.max(h.width,W),A=ve({anchorRect:h,overlay:{width:D,height:I?.height??220},portalContainer:d,gap:4,margin:8});s({...A,width:D,...De(f)});});return ()=>window.cancelAnimationFrame(T)},[i]),useEffect(()=>{function f(h){let d=h.target;C.current?.contains(d)||v.current?.contains(d)||r(false);}return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);let y=o.find(f=>f.value===e);return jsxs("div",{className:"luthor-select",ref:C,children:[jsxs("button",{className:`luthor-select-trigger ${i?"open":""}`,onClick:()=>r(!i),type:"button",children:[jsx("span",{children:y?.label||n}),jsx(Mt,{size:14})]}),i&&typeof document<"u"&&createPortal(jsx("div",{ref:v,className:"luthor-select-dropdown",style:l,children:o.map(f=>jsx("button",{className:`luthor-select-option ${e===f.value?"selected":""}`,onClick:()=>{t(f.value),r(false);},type:"button",children:f.label},f.value))}),u??document.body)]})}function lt({trigger:e,children:t,isOpen:o,onOpenChange:n}){let i=useRef(null),r=useRef(null),l=useRef(null),[s,u]=useState(void 0),[m,C]=useState(null);return useEffect(()=>{if(!o)return;let v=()=>{let f=r.current;if(!f)return;let h=f.getBoundingClientRect(),d=l.current?.getBoundingClientRect(),E=pt(f);C(E);let T=ve({anchorRect:h,overlay:{width:d?.width??220,height:d?.height??200},portalContainer:E,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});u({...T,...De(f)});},y=()=>v();return window.addEventListener("resize",y),window.addEventListener("scroll",y,true),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",y,true),C(null);}},[o]),useLayoutEffect(()=>{if(!o)return;let v=r.current;if(!v)return;let y=v.getBoundingClientRect(),f=pt(v);C(f);let h=ve({anchorRect:y,overlay:{width:220,height:200},portalContainer:f,gap:4,margin:8});u({...h,...De(v)});let d=window.requestAnimationFrame(()=>{let E=l.current?.getBoundingClientRect(),T=ve({anchorRect:y,overlay:{width:E?.width??220,height:E?.height??200},portalContainer:f,gap:4,margin:8});u({...T,...De(v)});});return ()=>window.cancelAnimationFrame(d)},[o]),useEffect(()=>{function v(y){let f=y.target;i.current?.contains(f)||l.current?.contains(f)||n(false);}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[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}),m??document.body)]})}function An({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(Ln,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:n})]})}):null}function Pn({isVisible:e,selectionRect:t,commands:o,activeStates:n,editorTheme:i="light",hide:r,isFeatureEnabled:l=()=>true}){let u=useRef(null),[m,C]=useState(""),[v,y]=useState(""),[f,h]=useState(""),[d,E]=useState(""),[T,I]=useState(""),[W,D]=useState(""),[A,ne]=useState(null),[ie,L]=useState(null),[ae,x]=useState(null),F=!!n.isIframeEmbedSelected,S=!!n.isYouTubeEmbedSelected,N=l("iframeEmbed"),P=l("youTubeEmbed"),Q=l("image"),se=N&&F||P&&S;if(useEffect(()=>{if(!e)return;let H=_=>{let ue=_.target;ue&&(u.current?.contains(ue)||r?.());};return document.addEventListener("mousedown",H,true),document.addEventListener("touchstart",H,true),()=>{document.removeEventListener("mousedown",H,true),document.removeEventListener("touchstart",H,true);}},[e,r]),useEffect(()=>{if(!e||!F)return;let H=false;return typeof o.getIframeEmbedCaption=="function"&&o.getIframeEmbedCaption().then(_=>{H||y(_??"");}),typeof o.getIframeEmbedUrl=="function"&&o.getIframeEmbedUrl().then(_=>{H||C(_??"");}),ne(null),()=>{H=true;}},[o,F,e]),useEffect(()=>{if(!e||!n.imageSelected)return;let H=false;return typeof o.getImageCaption=="function"&&o.getImageCaption().then(_=>{H||h(_??"");}),()=>{H=true;}},[n.imageSelected,o,e]),useEffect(()=>{if(!e||!S)return;let H=false;return typeof o.getYouTubeEmbedCaption=="function"&&o.getYouTubeEmbedCaption().then(_=>{H||E(_??"");}),typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(_=>{H||I(_??"");}),L(null),()=>{H=true;}},[o,e,S]),useEffect(()=>{if(!e||!n.isLink)return;let H=false;return typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(_=>{!H&&_&&D(_.url??"");}),x(null),()=>{H=true;}},[n.isLink,o,e]),!e||!t)return null;let O={...Nt(),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(se){let H=J=>{if(F){o.setIframeEmbedAlignment?.(J);return}S&&o.setYouTubeEmbedAlignment?.(J);},_=F?n.isIframeEmbedAlignedLeft:n.isYouTubeEmbedAlignedLeft,ue=F?n.isIframeEmbedAlignedCenter:n.isYouTubeEmbedAlignedCenter,Ge=F?n.isIframeEmbedAlignedRight:n.isYouTubeEmbedAlignedRight,Z=F?typeof o.setIframeEmbedCaption=="function":typeof o.setYouTubeEmbedCaption=="function",Re=F?typeof o.updateIframeEmbedUrl=="function":typeof o.updateYouTubeEmbedUrl=="function",Le=F?v:d,ct=F?y:E,je=F?m:T,Ae=F?A:ie,$e=()=>{if(Z){if(F){o.setIframeEmbedCaption?.(v);return}o.setYouTubeEmbedCaption?.(d);}},we=J=>{F?ne(J):L(J);},Pe=J=>{F?C(J):I(J);},pe=()=>{if(!Re)return;if(!(F?o.updateIframeEmbedUrl?.(m)??false:o.updateYouTubeEmbedUrl?.(T)??false)){we(F?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),F&&typeof o.getIframeEmbedUrl=="function"?o.getIframeEmbedUrl().then(Te=>C(Te??"")):!F&&typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(Te=>I(Te??""));return}we(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:O,children:[jsx(R,{onClick:()=>H("left"),active:_,title:"Align Left",children:jsx(It,{size:14})}),jsx(R,{onClick:()=>H("center"),active:ue,title:"Align Center",children:jsx(ht,{size:14})}),jsx(R,{onClick:()=>H("right"),active:Ge,title:"Align Right",children:jsx(Ft,{size:14})}),Z||Re?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[Re?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:je,className:`luthor-floating-toolbar-input${Ae?" is-error":""}`,placeholder:F?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":F?"Iframe URL":"YouTube URL","aria-invalid":Ae?true:void 0,onChange:J=>{Pe(J.target.value),Ae&&we(null);},onBlur:pe,onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),pe());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:pe,children:"Update URL"})]}):null,Z?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:Le,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":F?"Iframe caption":"YouTube caption",onChange:J=>ct(J.target.value),onBlur:$e,onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),$e());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:$e,children:"Update Caption"})]}):null]})]}):null]})}if(Q&&n.imageSelected){let H=typeof o.setImageCaption=="function",_=()=>{H&&o.setImageCaption(f);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:O,children:[jsx(R,{onClick:()=>o.setImageAlignment("left"),active:n.isImageAlignedLeft,title:"Align Left",children:jsx(It,{size:14})}),jsx(R,{onClick:()=>o.setImageAlignment("center"),active:n.isImageAlignedCenter,title:"Align Center",children:jsx(ht,{size:14})}),jsx(R,{onClick:()=>o.setImageAlignment("right"),active:n.isImageAlignedRight,title:"Align Right",children:jsx(Ft,{size:14})}),H?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:f,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":"Image caption",onChange:ue=>h(ue.target.value),onBlur:_,onKeyDown:ue=>{ue.key==="Enter"&&(ue.preventDefault(),_());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:_,children:"Update Caption"})]})]}):null]})}let fe=l("bold"),le=l("italic"),X=l("underline"),xe=l("strikethrough"),ge=l("codeFormat"),He=!!(n.unorderedList||n.orderedList||n.checkList),Ee=l("blockFormat")&&!He,Ue=l("link"),Ke=l("list")&&!He,he=fe||le||X||xe,ke=ge||Ee||Ue,be=Ke,Ve=!!n.isLink&&typeof o.updateLink=="function"&&typeof o.removeLink=="function",_e=()=>{if(!Ve)return;if(!(o.updateLink?.(W)??false)){x("Enter a valid URL"),typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(_=>{D(_?.url??"");});return}x(null);};return !he&&!ke&&!be?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:O,children:[he?jsxs(Fragment,{children:[fe?jsx(R,{onClick:()=>o.toggleBold(),active:n.bold,title:"Bold",children:jsx(Zt,{size:14})}):null,le?jsx(R,{onClick:()=>o.toggleItalic(),active:n.italic,title:"Italic",children:jsx(eo,{size:14})}):null,X?jsx(R,{onClick:()=>o.toggleUnderline(),active:n.underline,title:"Underline",children:jsx(to,{size:14})}):null,xe?jsx(R,{onClick:()=>o.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(oo,{size:14})}):null]}):null,he&&ke?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,ke?jsxs(Fragment,{children:[ge?jsx(R,{onClick:()=>o.formatText("code"),active:n.code,title:"Inline Code",children:jsx(no,{size:14})}):null,Ee?jsx(R,{onClick:()=>o.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(so,{size:14})}):null,Ue?jsxs(Fragment,{children:[jsx(R,{onClick:()=>n.isLink?o.removeLink():o.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(ft,{size:14}):jsx(xt,{size:14})}),Ve?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:W,className:`luthor-floating-toolbar-input${ae?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":ae?true:void 0,onChange:H=>{D(H.target.value),ae&&x(null);},onBlur:_e,onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),_e());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:_e,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(ft,{size:13})})]}):null]}):null]}):null,(he||ke)&&be?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,be?jsxs(Fragment,{children:[jsx(R,{onClick:()=>o.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(ro,{size:14})}),jsx(R,{onClick:()=>o.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(lo,{size:14})}),jsx(R,{onClick:()=>o.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(io,{size:14})})]}):null]})}var Ye={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function No(e,t,o,n=()=>true){Ye.commands=e,Ye.activeStates=t,Ye.editorTheme=o,Ye.isFeatureEnabled=n;}function zn(){let e=Pn,t=new FloatingToolbarExtension;return t.config={...t.config,render:o=>createElement(e,{...o,commands:Ye.commands,activeStates:Ye.activeStates,editorTheme:Ye.editorTheme,isFeatureEnabled:Ye.isFeatureEnabled}),getCommands:()=>Ye.commands,getActiveStates:()=>Ye.activeStates},t}var Ci=120,Ei=58;function ki(e,t=Ei){return e.length<=t?e:`${e.slice(0,t-3)}...`}function Bn(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function Dn(e,t){if(!(e instanceof Element))return null;let o=e.closest("a");return !(o instanceof HTMLAnchorElement)||!t.contains(o)?null:o}function Vn({editor:e,commands:t,editorTheme:o="light",disabled:n=false}){let i=useRef(null),r=useRef(null),l=useRef(null),s=useRef(null),[u,m]=useState(null),[C,v]=useState(false),[y,f]=useState(""),[h,d]=useState(null),[E,T]=useState(null),[I,W]=useState(null),D=useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]),A=useCallback(()=>{D(),m(null),v(false),f(""),d(null),T(null);},[D]),ne=useCallback(()=>{D(),s.current=window.setTimeout(()=>{A();},Ci);},[D,A]),ie=useCallback((S,N)=>{let P=S.getBoundingClientRect(),Q=i.current?.getBoundingClientRect(),se=ve({anchorRect:P,overlay:{width:Q?.width??340,height:Q?.height??48},portalContainer:N,gap:8,margin:10,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});T({top:typeof se.top=="number"?se.top:0,left:typeof se.left=="number"?se.left:0});},[]),L=useCallback((S,N)=>{if(typeof t.getLinkByKey!="function"){m(P=>!P||P.nodeKey!==S?P:{...P,url:N});return}t.getLinkByKey(S).then(P=>{if(!P){A();return}m(Q=>!Q||Q.nodeKey!==S?Q:{...Q,url:P.url});});},[t,A]);useEffect(()=>{if(!e||n||typeof window>"u"){A(),W(null),r.current=null;return}let S=e.getRootElement();if(!S){A(),W(null),r.current=null;return}let N=S.closest(".luthor-editor-wrapper")??null;W(N),r.current=N;let P=le=>{let X=Dn(le.target,S);if(!X)return;if(Bn()){A();return}D();let xe=resolveLinkNodeKeyFromAnchor(e,X);if(!xe)return;let ge=X.getAttribute("href")??X.href;m({nodeKey:xe,url:ge,anchorEl:X}),ie(X,r.current),d(null),C||f(ge),L(xe,ge);},Q=le=>{if(!u)return;let X=le.relatedTarget;X&&i.current?.contains(X)||Dn(X,S)||ne();},se=()=>{Bn()&&A();},O=()=>{m(le=>{if(!le)return le;let X=le.anchorEl.isConnected&&S.contains(le.anchorEl)?le.anchorEl:S.querySelector(`a[data-lexical-node-key="${le.nodeKey}"]`);return X?(ie(X,r.current),{...le,anchorEl:X,url:X.getAttribute("href")??X.href}):(A(),null)});},fe=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,O();}));};return S.addEventListener("mouseover",P),S.addEventListener("mouseout",Q),document.addEventListener("selectionchange",se),window.addEventListener("scroll",fe,true),window.addEventListener("resize",fe),()=>{S.removeEventListener("mouseover",P),S.removeEventListener("mouseout",Q),document.removeEventListener("selectionchange",se),window.removeEventListener("scroll",fe,true),window.removeEventListener("resize",fe),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),D();}},[t,n,e,u,C,A,ne,L,ie,D]),useLayoutEffect(()=>{u&&ie(u.anchorEl,r.current);},[u,C,ie]);let ae=useMemo(()=>{if(!(!u||!E))return {...De(u.anchorEl),position:I?"absolute":"fixed",top:E.top,left:E.left,zIndex:"var(--luthor-z-menu, 460)"}},[u,E,I]);if(!u||!E||typeof document>"u")return null;let x=()=>{(t.removeLinkByKey?.(u.nodeKey)??false)&&A();},F=()=>{let S=y.trim();if(!(t.updateLinkByKey?.(u.nodeKey,S)??false)){d("Enter a valid URL"),L(u.nodeKey,u.url);return}m(P=>!P||P.nodeKey!==u.nodeKey?P:{...P,url:S}),d(null),v(false),queueMicrotask(()=>{L(u.nodeKey,S);});};return createPortal(jsx("div",{ref:i,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":o,style:ae,onMouseEnter:D,onMouseLeave:ne,children:C?jsxs(Fragment,{children:[jsx("input",{type:"url",value:y,className:`luthor-link-hover-bubble-input${h?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":h?true:void 0,onChange:S=>{f(S.target.value),h&&d(null);},onKeyDown:S=>{if(S.key==="Enter"){S.preventDefault(),F();return}S.key==="Escape"&&(S.preventDefault(),v(false),f(u.url),d(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:F,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{v(false),f(u.url),d(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:u.url,children:ki(u.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{f(u.url),v(true),d(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:x,"aria-label":"Unlink",children:jsx(ft,{size:13})})]})}),I??document.body)}var Ti=400;function _n({mode:e,onModeChange:t,labels:o,availableModes:n,isConverting:i}){let r=d=>d==="visual"?"visual-editor":d,l=(n??[]).includes("visual-editor")?"visual-editor":"visual",s=d=>d==="visual-editor"?l:d,u=["visual-only","visual-editor","json","markdown","html"],m=n??["visual-only","visual-editor","json","markdown","html"],C=new Set(m.map(r)),v=u.filter(d=>C.has(d)),y=r(e),f=i?r(i):null,h={"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:v.map(d=>jsxs("button",{className:`luthor-mode-tab ${y===d?"active":""}`,onClick:()=>t(s(d)),children:[h[d],f===d&&jsx("span",{className:"luthor-tab-converting-spinner"})]},d))})}function go({value:e,onChange:t,placeholder:o,className:n,wrap:i}){let r=useRef(null);return useLayoutEffect(()=>{let l=r.current;if(!l)return;l.style.height="auto";let s=Math.max(0,l.offsetHeight-l.clientHeight),u=Math.max(l.scrollHeight+s+1,Ti);l.style.height=`${u}px`;},[e]),jsx("textarea",{ref:r,className:`luthor-source-view${n?` ${n}`:""}`,value:e,onChange:l=>t(l.target.value),placeholder:o,spellCheck:false,wrap:i??"off"})}function jn(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,`
2
+ `)}function xi(e){return e.replace(/&#(9|10|13|32|160);/g,(t,o)=>{switch(o){case "9":return " ";case "10":return `
3
+ `;case "13":return "\r";case "32":return " ";case "160":return " ";default:return t}})}function Ii(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 Fi(e){return ["***","**","~~","*"].reduce((o,n)=>Ii(o,n),e)}var Mi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Oi=new Set(["pre","script","style","textarea"]),Ni=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"]),Hi=1,po=3,Ri=8;function $n(e){return e.nodeType===Hi}function Ro(e){return e.nodeType===po&&(e.textContent??"").trim().length>0}function fo(e){return e.tagName.toLowerCase()}function qn(e){return Array.from(e.childNodes).filter(t=>t.nodeType!==po?true:Ro(t))}function Ai(e){let t=e.outerHTML,o=t.indexOf(">");return o===-1?`<${fo(e)}>`:t.slice(0,o+1)}function Pi(e){let t=fo(e);if(Mi.has(t)||Oi.has(t))return false;let o=qn(e);if(o.length===0||o.some(Ro))return false;let n=o.filter($n);return n.length===0?false:n.every(i=>Ni.has(fo(i)))}function Yn(e,t){let o=" ".repeat(Math.max(t,0));if(e.nodeType===Ri)return `${o}<!--${e.data}-->`;if(e.nodeType===po){let r=ho(e.textContent??"");return r.trim()?`${o}${r.trim()}`:null}if(!$n(e))return null;if(!Pi(e))return `${o}${e.outerHTML}`;let n=fo(e),i=[`${o}${Ai(e)}`];for(let r of qn(e)){let l=Yn(r,t+1);l&&i.push(l);}return i.push(`${o}</${n}>`),i.join(`
4
+ `)}function zi(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!==po?true:Ro(i)).map(i=>Yn(i,0)).filter(i=>typeof i=="string"&&i.length>0);return n.length===0?t.body.innerHTML.trim()||e:n.join(`
5
+ `)}function Jn(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 Gn(e){return Fi(xi(ho(e))).trim()}function Wn(e){let t=ho(e).trim();if(!t)return "";try{return zi(t)}catch{return t}}var Po=6,Ki=["#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"],Vi=[{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"}],_i=[{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 ji(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 $i({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 qi({pattern:e}){let t=ji(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,m=24+s*12,C=57-s*10;return jsxs("g",{children:[jsx("g",{transform:`translate(${u-16}, 0)`,children:jsx($i,{type:i[l]??t[0],cy:r})}),jsx("rect",{x:m,y:r-2.5,width:C,height:"5",rx:"2.5",className:"luthor-unordered-variant-line"})]},`${e}-row-${l}`)})]})}function Qn({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 Yi({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,m=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:m,height:"5",rx:"2.5",className:"luthor-ordered-variant-line"})]},`${e}-ordered-row-${r}`)})]})}function yo(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Ji(e,t){let o=yo(t);for(let n of e)if(yo(n.value)===o)return n.color;return null}function Gi(e,t,o){if(!e||e==="default")return o;let n=Ji(t,e);return n||e}function Wi(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 zo="Inherited",bo="16px",Bo="1.5";function Ce(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Zn(e){let t=e.split(",")[0]??"";return Ce(t.replace(/["']/g,""))}function vo(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 yt(){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 Ao(){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 er(e){return (e.split(",")[0]?.trim()??"").replace(/^['"]|['"]$/g,"").trim()}function Xi(e,t){let o=Ce(e);if(o&&o!=="inherit"){let i=er(e);if(i)return i}return er(t?.fontFamily??"")||zo}function Qi(e,t){let o=Ce(e);return o&&o!=="inherit"?e.trim():(t?.fontSize??"").trim()||bo}function Zi(e,t){let o=Ce(e);return o&&o!=="normal"?e.trim():(t?.lineHeight??"").trim()||Bo}function el(e,t){if(!e)return null;let o=Zn(e);return o?t.find(i=>Ce(i.value)===o?true:Zn(i.fontFamily)===o)?.value??null:null}function tl(e,t){if(!e)return null;let o=Ce(e),n=t.find(l=>Ce(String(l.value))===o?true:Ce(String(l.fontSize))===o);if(n)return String(n.value);let i=vo(e);if(i==null)return null;let r=null;for(let l of t){let s=vo(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 ol(e,t,o){if(!e)return null;let n=Ce(e),i=o.find(m=>Ce(m.value)===n?true:Ce(m.lineHeight)===n);if(i)return i.value;let r=t?vo(t):null,l=vo(e),s=null;if(l!=null&&r!=null&&r>0)s=l/r;else {let m=Number(e);Number.isFinite(m)&&(s=m);}if(s==null)return null;let u=null;for(let m of o){let C=Number(m.lineHeight);if(!Number.isFinite(C))continue;let v=Math.abs(C-s);(!u||v<u.distance)&&(u={value:m.value,distance:v});}return u?.value??null}function tr({title:e,value:t,options:o,recentColors:n,active:i,fallbackColor:r,highlight:l,onChange:s,onClear:u,onAddRecent:m}){let C=useRef(null),v=useRef(null),y=useRef(null),f=useRef(null),h=useRef(null),[d,E]=useState(false),[T,I]=useState(void 0),[W,D]=useState(null),A=Gi(t,o,r),ne=useMemo(()=>Ki,[]),ie=useMemo(()=>{let x=[...n].slice(0,Po);for(;x.length<Po;)x.push("");return x},[n]);useEffect(()=>()=>{f.current&&window.cancelAnimationFrame(f.current);},[]);let L=useCallback(x=>{h.current=x,!f.current&&(f.current=window.requestAnimationFrame(()=>{f.current=null,h.current&&(s(h.current),h.current=null);}));},[s]),ae=useCallback(x=>{let F=C.current;if(!F)return;let S=F.getBoundingClientRect(),N=v.current?.getBoundingClientRect(),P=pt(F);D(P);let Q=ve({anchorRect:S,overlay:{width:N?.width??248,height:N?.height??340},portalContainer:P,gap:6,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});I({...Q,visibility:x?"visible":"hidden",...De(F)});},[]);return useLayoutEffect(()=>{if(!d)return;ae(false);let x=window.requestAnimationFrame(()=>{ae(true);});return ()=>{window.cancelAnimationFrame(x);}},[d,ae]),useEffect(()=>{if(!d)return;let x=N=>{let P=N.target;C.current?.contains(P)||v.current?.contains(P)||E(false);},F=N=>{N.key==="Escape"&&E(false);},S=()=>ae(true);return window.addEventListener("resize",S),window.addEventListener("scroll",S,true),document.addEventListener("mousedown",x),document.addEventListener("keydown",F),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,true),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",F),D(null);}},[d,ae]),jsxs(Fragment,{children:[jsxs("button",{ref:C,type:"button",className:`luthor-toolbar-button luthor-color-button${i?" active":""}${l?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>E(x=>!x),children:[l?jsx(gn,{size:15,className:"luthor-color-button-highlighter"}):jsx("span",{className:"luthor-color-button-letter",children:"A"}),jsx("span",{className:"luthor-color-button-indicator",style:{backgroundColor:A}})]}),d&&typeof document<"u"&&createPortal(jsxs("div",{ref:v,className:"luthor-color-picker",style:T,children:[jsx("div",{className:"luthor-color-picker-header",children:jsx("span",{className:"luthor-color-picker-title",children:e})}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Colors"}),jsx("div",{className:"luthor-color-swatch-grid",children:ne.map(x=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:x},"aria-label":`Use color ${x}`,onClick:()=>{s(x),m(x),E(false);}},x))})]}),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:ie.map((x,F)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:x||"transparent"},"aria-label":x?`Use recent color ${x}`:"Empty recent color slot",disabled:!x,onClick:()=>{x&&(s(x),m(x),E(false));}},`${x||"empty"}-${F}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{u(),E(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>y.current?.click(),children:[jsx(fn,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:y,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Wi(A,r),onInput:x=>{L(x.target.value);},onChange:x=>{let F=x.target.value;s(F),m(F);}})]})]}),W??document.body)]})}function nl(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 rl(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 il(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 ll(e,t,o){return il(e,t)?o?.[e]!==false:false}function al(e,t,o){return {sections:e.sections.map(n=>({...n,items:n.items.filter(i=>ll(i,t,o))})).filter(n=>n.items.length>0)}}function or({commands:e,hasExtension:t,activeStates:o,isDark:n,toggleTheme:i,onCommandPaletteOpen:r,imageUploadHandler:l,classNames:s,toolbarStyleVars:u,layout:m,toolbarVisibility:C,headingOptions:v,paragraphLabel:y}){let{handlers:f,fileInputRef:h,gifInputRef:d}=nl(e,l),E=rl(e),T=t("iframeEmbed")||t("youtubeEmbed"),I=o.isIframeEmbedSelected||o.isYouTubeEmbedSelected,[W,D]=useState(false),[A,ne]=useState(false),[ie,L]=useState(false),[ae,x]=useState(false),[F,S]=useState(false),[N,P]=useState(false),[Q,se]=useState(false),[O,fe]=useState(false),[le,X]=useState("default"),[xe,ge]=useState([{value:"default",label:zo}]),[He,Ee]=useState("default"),[Ue,Ke]=useState([{value:"default",label:bo}]),[he,ke]=useState("default"),[be,Ve]=useState([{value:"default",label:Bo}]),[_e,H]=useState("default"),[_,ue]=useState([{value:"default",label:"Default",color:"inherit"}]),[Ge,Z]=useState([]),[Re,Le]=useState("default"),[ct,je]=useState([{value:"default",label:"Default",color:"transparent"}]),[Ae,$e]=useState([]),[we,Pe]=useState(0),[pe,We]=useState({rows:3,columns:3,includeHeaders:false}),J=useRef(null),Te=useRef("");useEffect(()=>{if(typeof document>"u")return;let b=()=>{J.current===null&&(J.current=window.requestAnimationFrame(()=>{J.current=null;let p=window.getSelection();if(!p||p.rangeCount===0||!p.getRangeAt(0).collapsed)return;let B=yt();if(!B)return;let U=`${B.fontFamily}|${B.fontSize}|${B.lineHeight}`;U!==Te.current&&(Te.current=U,Pe(j=>j+1));}));};return document.addEventListener("selectionchange",b),()=>{document.removeEventListener("selectionchange",b),J.current!==null&&(cancelAnimationFrame(J.current),J.current=null);}},[]);let tt=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 b=yt()??Ao(),p=e.getFontFamilyOptions().map(U=>({value:U.value,label:Ce(U.value)==="default"?Xi(U.fontFamily,b):U.label})),B=p.length>0?p:[{value:"default",label:zo}];ge(B),X(U=>B.some(j=>j.value===U)?U:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let b=e.getFontFamilyOptions;if(typeof b!="function")return;let p=false;return e.getCurrentFontFamily().then(B=>{if(p)return;if(B&&B!=="default"){X(B);return}let U=yt(),j=el(U?.fontFamily,b());X(j??"default");}),()=>{p=true;}},[o,e,t,we]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let b=yt()??Ao(),p=e.getFontSizeOptions().map(j=>({value:String(j.value).trim(),label:Ce(String(j.value))==="default"?Qi(String(j.fontSize),b):String(j.label).trim()})).filter(j=>j.value.length>0&&j.label.length>0),B=p.some(j=>Ce(j.value)==="default"),U=p.length===0?[{value:"default",label:bo}]:B?p:[{value:"default",label:bo},...p];Ke(U),Ee(j=>U.some(g=>g.value===j)?j:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let b=e.getFontSizeOptions;if(typeof b!="function")return;let p=false;return e.getCurrentFontSize().then(B=>{if(p)return;if(B&&B!=="default"){Ee(B);return}let U=yt(),j=tl(U?.fontSize,b());Ee(j??"default");}),()=>{p=true;}},[o,e,t,we]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let b=yt()??Ao(),p=e.getLineHeightOptions().map(U=>({value:U.value,label:Ce(U.value)==="default"?Zi(U.lineHeight,b):U.label})),B=p.length>0?p:[{value:"default",label:Bo}];Ve(B);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let b=e.getLineHeightOptions;if(typeof b!="function")return;let p=false;return e.getCurrentLineHeight().then(B=>{if(p)return;if(B){ke(B);return}let U=yt(),j=ol(U?.lineHeight,U?.fontSize,b());ke(j??"default");}),()=>{p=true;}},[o,e,t,we]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let b=e.getTextColorOptions().map(p=>({value:p.value,label:p.label,color:p.color}));b.length>0&&ue(b);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let b=false;return e.getCurrentTextColor().then(p=>{b||H(p??"default");}),()=>{b=true;}},[o,e,t,we]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let b=e.getTextHighlightOptions().map(p=>({value:p.value,label:p.label,color:p.backgroundColor}));b.length>0&&je(b);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let b=false;return e.getCurrentTextHighlight().then(p=>{b||Le(p??"default");}),()=>{b=true;}},[o,e,t,we]);let ye=useMemo(()=>{if(!v||v.length===0)return [...Be];let b=new Set,p=[];for(let B of v)!Be.includes(B)||b.has(B)||(b.add(B),p.push(B));return p.length>0?p:[...Be]},[v]),ot=y?.trim()||"Paragraph",kt=useMemo(()=>{let b=ye.map(p=>({value:p,label:`Heading ${p.slice(1)}`}));return [{value:"p",label:ot},...b]},[ye,ot]),Ie=o.isH1?"h1":o.isH2?"h2":o.isH3?"h3":o.isH4?"h4":o.isH5?"h5":o.isH6?"h6":"p",dt=kt.some(b=>b.value===Ie)?Ie:"p",Lt=b=>{b==="p"?e.toggleParagraph():b.startsWith("h")&&ye.includes(b)&&e.toggleHeading(b);},wt=b=>{b==="default"?e.clearFontFamily?.():e.setFontFamily?.(b),X(b);},Xe=b=>{b==="default"?e.clearFontSize?.():e.setFontSize?.(b),Ee(b);},nt=b=>{e.setLineHeight?.(b),ke(b);},rt=(b,p)=>{b(B=>{let U=yo(p),j=B.filter(g=>yo(g)!==U);return [p,...j].slice(0,Po)});},qe=b=>{if(b==="default"){e.clearTextColor?.(),H("default");return}e.setTextColor?.(b),H(b);},ze=b=>{if(b==="default"){e.clearTextHighlight?.(),Le("default");return}e.setTextHighlight?.(b),Le(b);},it=b=>{if(typeof e.setOrderedListPattern=="function"){e.setOrderedListPattern(b);return}e.toggleOrderedList();},mt=b=>{if(typeof e.setUnorderedListPattern=="function"){e.setUnorderedListPattern(b);return}e.toggleUnorderedList();},Tt=b=>{if(typeof e.setCheckListVariant=="function"){e.setCheckListVariant(b);return}e.toggleCheckList();},Wt=b=>{switch(b){case "fontFamily":return t("fontFamily")?jsx(Vt,{value:le,onValueChange:wt,options:xe,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(Vt,{value:He,onValueChange:Xe,options:Ue,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(Vt,{value:he,onValueChange:nt,options:be,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(tr,{title:"Text Color",value:_e,options:_,recentColors:Ge,active:o.hasCustomTextColor,fallbackColor:"#0f172a",onChange:qe,onClear:()=>qe("default"),onAddRecent:p=>rt(Z,p)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(tr,{title:"Text Highlight",value:Re,options:ct,recentColors:Ae,active:o.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:ze,onClear:()=>ze("default"),onAddRecent:p=>rt($e,p)},"textHighlight"):null;case "bold":return jsx(R,{onClick:()=>e.toggleBold(),active:o.bold,title:"Bold (Ctrl+B)",children:jsx(Zt,{size:16})},"bold");case "italic":return jsx(R,{onClick:()=>e.toggleItalic(),active:o.italic,title:"Italic (Ctrl+I)",children:jsx(eo,{size:16})},"italic");case "underline":return jsx(R,{onClick:()=>e.toggleUnderline(),active:o.underline,title:"Underline (Ctrl+U)",children:jsx(to,{size:16})},"underline");case "strikethrough":return jsx(R,{onClick:()=>e.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(oo,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(R,{onClick:()=>e.toggleSubscript?.(),active:o.subscript,title:"Subscript",children:jsx(En,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(R,{onClick:()=>e.toggleSuperscript?.(),active:o.superscript,title:"Superscript",children:jsx(kn,{size:16})},"superscript"):null;case "code":return jsx(R,{onClick:()=>e.formatText("code"),active:o.code,title:"Inline Code",children:jsx(no,{size:16})},"code");case "link":return jsx(R,{onClick:()=>o.isLink?e.removeLink():e.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(ft,{size:16}):jsx(xt,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(Vt,{value:dt,onValueChange:Lt,options:kt,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(R,{onClick:()=>e.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(so,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("left"),active:o.isTextAlignedLeft,title:"Align Left",children:jsx(It,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("center"),active:o.isTextAlignedCenter,title:"Align Center",children:jsx(ht,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("right"),active:o.isTextAlignedRight,title:"Align Right",children:jsx(Ft,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("justify"),active:o.isTextAlignedJustify,title:"Justify",children:jsx(un,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(R,{onClick:()=>e.toggleCodeBlock(),active:o.isInCodeBlock,title:"Code Block",children:jsx(ln,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(ro,{size:16})}),jsx(lt,{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(Mt,{size:12})}),isOpen:F,onOpenChange:S,children:jsx("div",{className:"luthor-unordered-variant-grid",children:_i.map(p=>jsx("button",{className:"luthor-unordered-variant-option",type:"button",title:p.title,"aria-label":p.title,onClick:()=>{mt(p.pattern),S(false);},children:jsx(qi,{pattern:p.pattern})},p.pattern))})})]},"unorderedList"):null;case "orderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(lo,{size:16})}),jsx(lt,{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(Mt,{size:12})}),isOpen:N,onOpenChange:P,children:jsx("div",{className:"luthor-ordered-variant-grid",children:Vi.map(p=>jsx("button",{className:"luthor-ordered-variant-option",type:"button",title:p.title,"aria-label":p.title,onClick:()=>{it(p.pattern),P(false);},children:jsx(Yi,{pattern:p.pattern})},p.pattern))})})]},"orderedList"):null;case "checkList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(io,{size:16})}),jsx(lt,{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(Mt,{size:12})}),isOpen:Q,onOpenChange:se,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:()=>{Tt("strikethrough"),se(false);},children:jsx(Qn,{variant:"strikethrough"})}),jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Keep text","aria-label":"Checked = Keep text",onClick:()=>{Tt("plain"),se(false);},children:jsx(Qn,{variant:"plain"})})]})})]},"checkList"):null;case "indentList":return t("list")?jsx(R,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(pn,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(R,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(bn,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(R,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(cn,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(R,{onClick:()=>fe(true),title:"Insert Table",children:jsx(dn,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(lt,{trigger:jsx("button",{className:`luthor-toolbar-button ${o.imageSelected?"active":""}`,title:"Insert Image",children:jsx(So,{size:16})}),isOpen:W,onOpenChange:D,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromUrl(),D(false);},children:[jsx(xt,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertFromFile(),D(false);},children:[jsx(xo,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromUrl(),D(false);},children:[jsx(Io,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.insertGifFromFile(),D(false);},children:[jsx(xo,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),o.imageSelected&&jsxs(lt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(ht,{size:16})}),isOpen:ie,onOpenChange:L,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("left"),L(false);},children:[jsx(It,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("center"),L(false);},children:[jsx(ht,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setAlignment("right"),L(false);},children:[jsx(Ft,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{f.setCaption(),L(false);},children:[jsx(hn,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||tt.length===0?null:jsx(lt,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Io,{size:16})}),isOpen:A,onOpenChange:ne,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:tt.map(p=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:p.shortcodes[0]?`${p.label} (:${p.shortcodes[0]}:)`:p.label,onClick:()=>{e.insertEmoji?.(p.emoji),ne(false);},children:p.emoji},`${p.emoji}-${p.label}`))})},"emoji");case "embed":return T?jsxs(lt,{trigger:jsx("button",{className:`luthor-toolbar-button ${I?"active":""}`,title:"Insert Embed",children:jsx(mn,{size:16})}),isOpen:ae,onOpenChange:x,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{E.insertIframe(),x(false);},children:[jsx(xt,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{E.insertYouTube(),x(false);},children:[jsx(So,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(R,{onClick:()=>e.undo(),disabled:!o.canUndo,title:"Undo (Ctrl+Z)",children:jsx(an,{size:16})},"undo"):null;case "redo":return t("history")?jsx(R,{onClick:()=>e.redo(),disabled:!o.canRedo,title:"Redo (Ctrl+Y)",children:jsx(sn,{size:16})},"redo"):null;case "commandPalette":return jsx(R,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(ao,{size:16})},"commandPalette");case "themeToggle":return jsx(R,{onClick:i,title:n?"Light Mode":"Dark Mode",children:n?jsx(yn,{size:16}):jsx(vn,{size:16})},"themeToggle");default:return null}},gt=m??Xt,St=useMemo(()=>al(gt,t,C),[gt,t,C]);return jsxs(Fragment,{children:[jsx("div",{className:s?.toolbar??"luthor-toolbar",style:u,children:St.sections.map((b,p)=>{let B=b.items.map((U,j)=>{let g=Wt(U);return g?Array.isArray(g)?g.map((k,Y)=>k&&typeof k=="object"&&"key"in k&&k.key!=null?k:jsx("span",{children:k},`toolbar-item-${p}-${j}-${Y}`)):g.type===Bi.Fragment?jsx("span",{children:g},`toolbar-item-${p}-${j}`):g&&typeof g=="object"&&"key"in g&&g.key!=null?g:jsx("span",{children:g},`toolbar-item-${p}-${j}`):null}).flat().filter(U=>U!==null);return B.length===0?null:jsx("div",{className:s?.section??"luthor-toolbar-section",children:B},p)})}),jsx("input",{ref:h,type:"file",accept:"image/*",onChange:f.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:d,type:"file",accept:"image/gif",onChange:f.handleGifUpload,className:"luthor-file-input"}),jsx(An,{isOpen:O,onClose:()=>fe(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:pe.rows,onChange:b=>We(p=>({...p,rows:parseInt(b.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:pe.columns,onChange:b=>We(p=>({...p,columns:parseInt(b.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:pe.includeHeaders||false,onChange:b=>We(p=>({...p,includeHeaders:b.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(Oo,{variant:"secondary",onClick:()=>fe(false),children:"Cancel"}),jsx(Oo,{variant:"primary",onClick:()=>{e.insertTable(pe),fe(false);},children:"Insert Table"})]})]})})]})}var $o=["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"],ur={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 qt(e){let t={...ur};if(!e)return t;for(let o of $o)typeof e[o]=="boolean"&&(t[o]=e[o]);return t}function cr(e,t){return e[t]!==false}var ir=8,lr=[{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"}],zl={value:"default",label:"Default",fontFamily:"inherit"},ar=[{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"}],Bl={value:"default",label:"Default",fontSize:"inherit"},sr=[{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"}],Dl={value:"default",label:"Default",lineHeight:"1.5"},$t="1.5",Ul=1;function vt(e){return e.trim().toLowerCase()}function dr(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function Kl(e){return vt(e)==="default"?true:Eo(e)!==null}function Vl(e){let t=e??lr,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||!dr(l))continue;let m=vt(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontFamily:u,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return n.length===0?lr:n.some(r=>vt(r.value)==="default")?n:[zl,...n]}function _l(e){let t=e??ar,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||!dr(l))continue;let m=vt(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontSize:u}));}return n.length===0?ar:n.some(r=>vt(r.value)==="default")?n:[Bl,...n]}function Eo(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let o=Number(t);return !Number.isFinite(o)||o<Ul?null:o.toString()}function jl(e){if(!Number.isFinite(e))return ir;let t=Math.floor(e);return t>=0?t:ir}function $l(e){return typeof e=="number"?Number.isFinite(e)?Eo(e.toString())??$t:$t:typeof e=="string"?Eo(e)??$t:$t}function ql(e,t=$t){let o=e??sr,n=new Set,i=[];for(let l of o){let s=String(l.value).trim(),u=String(l.label).trim();if(!s||!u||!Kl(s))continue;let m=vt(s);if(n.has(m))continue;if(m==="default"){n.add(m),i.push({value:s,label:u,lineHeight:t});continue}let C=Eo(String(l.lineHeight));C&&(n.add(m),i.push({value:s,label:u,lineHeight:C}));}return i.length===0?sr:i.some(l=>vt(l.value)==="default")?i:[{...Dl,lineHeight:t},...i]}function ut({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 Yl=()=>jsxs(ut,{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"})]}),Jl=()=>jsxs(ut,{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"})]}),Gl=()=>jsxs(ut,{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"})]}),Wl=()=>jsxs(ut,{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"})]}),Xl=()=>jsxs(ut,{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"})]}),Ql=()=>jsxs(ut,{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"})]}),Zl=()=>jsxs(ut,{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"})]}),ea=()=>jsxs(ut,{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"})]}),ko=new ImageExtension;ko.config={...ko.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var Do=new TableExtension;Do.config={...Do.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(Yl,{})}),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(Jl,{})}),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(Gl,{})}),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(Wl,{})}),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(Xl,{})}),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(Ql,{})}),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(ea,{})})}),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(Zl,{})})]})};var Uo=new IframeEmbedExtension;Uo.config={...Uo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var Ko=new YouTubeEmbedExtension;Ko.config={...Ko.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var ta=zn(),Vo=new ContextMenuExtension;Vo.config={...Vo.config,preventDefault:true};var oa=new CommandPaletteExtension,na=new SlashCommandExtension,ra=new EmojiExtension,_o=new DraggableBlockExtension;_o.config={..._o.config,buttonStackPosition:"left"};var jo=new LinkExtension;jo.config={...jo.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var ia=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"}]}),la=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:aa}=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 mr({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:o,minimumDefaultLineHeight:n,featureFlags:i,isDraggableBoxEnabled:r,scaleByRatio:l,syntaxHighlighting:s,codeHighlightProvider:u,loadCodeHighlightProvider:m,maxAutoDetectCodeLength:C,isCopyAllowed:v,languageOptions:y,maxListIndentation:f}={}){let h=qt(i),d=ae=>cr(h,ae),E=(r??true)&&d("draggableBlock"),T=$l(n),I=jl(f),W=new FontFamilyExtension().configure({options:Vl(e),cssLoadStrategy:"on-demand"}),D=new FontSizeExtension().configure({options:_l(t)}),A=new LineHeightExtension().configure({options:ql(o,T),defaultLineHeight:T});ko.configure({scaleByRatio:l??false}),codeExtension.configure({syntaxHighlighting:s??"auto",provider:u??void 0,loadProvider:m}),codeIntelligenceExtension.configure({provider:u??void 0,loadProvider:m,maxAutoDetectLength:C,isCopyAllowed:v??true,languageOptions:y});let ne=new ListExtension({maxDepth:I+1}),ie=new TabIndentExtension({maxListDepth:I+1}),L=[];return d("bold")&&L.push(boldExtension),d("italic")&&L.push(italicExtension),d("underline")&&L.push(underlineExtension),d("strikethrough")&&L.push(strikethroughExtension),d("fontFamily")&&L.push(W),d("fontSize")&&L.push(D),d("lineHeight")&&L.push(A),d("textColor")&&L.push(ia),d("textHighlight")&&L.push(la),d("subscript")&&L.push(subscriptExtension),d("superscript")&&L.push(superscriptExtension),d("link")&&L.push(jo),d("horizontalRule")&&L.push(horizontalRuleExtension),d("table")&&L.push(Do),d("list")&&L.push(ne),d("history")&&L.push(historyExtension),d("image")&&L.push(ko),d("blockFormat")&&L.push(blockFormatExtension),d("code")&&L.push(codeExtension),d("codeIntelligence")&&L.push(codeIntelligenceExtension),d("codeFormat")&&L.push(codeFormatExtension),d("tabIndent")&&L.push(ie),d("enterKeyBehavior")&&L.push(enterKeyBehaviorExtension),d("iframeEmbed")&&L.push(Uo),d("youTubeEmbed")&&L.push(Ko),d("floatingToolbar")&&L.push(ta),d("contextMenu")&&L.push(Vo),d("commandPalette")&&L.push(oa),d("slashCommand")&&L.push(na),d("emoji")&&L.push(ra),E&&L.push(_o),d("customNode")&&L.push(aa),L}function Yt(e){return mr(e)}var qo=mr();function gr(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 fr(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 hr(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 pr(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 br(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 yr(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 vr(e){return new Set(e)}function Yo(e,t){e.clear();for(let o of t)e.add(o);}function Cr(e,t){return e.has(t)}function Er(e,t){e.add(t);}var{Provider:Ea,useEditor:ka}=createEditorSystem(),kr="Write anything...",Lr="Enter JSON document content...",wr="Enter Markdown content...",Tr="Enter HTML content...",Fr=new Set(["auto","scroll","overlay"]),La={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"};function Gt(e){return e==="visual"?"visual-editor":e}function re(e){return Gt(e)==="visual-editor"}function Wo(e,t){return e.some(o=>Gt(o)===t)}function Jo(e){return e==="json"||e==="markdown"||e==="html"}function Mr(e){let t=e.overflowY;return t&&t!=="visible"?t:e.overflow||t||"visible"}function wa(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 Ta(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=Mr(window.getComputedStyle(n));Fr.has(i)&&o(n),n=n.parentElement;}}t.forEach(n=>{wa(n);});}function Sa(e){if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e());});return}globalThis.setTimeout(e,0);}function Sr(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=Mr(n);if(!Fr.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 xa(e){if(typeof window>"u")return ()=>{};let t=Sr(e),o=()=>{t(),t=Sr(e);};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),t();}}function Xo(e){let o=e.replace(/\r\n?/g,`
6
+ `).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 Jt=Xo("");function xr(e,t,o){return o<=t?t:Math.min(o,Math.max(t,e))}function Ia(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 Fa(e,t,o){let r=Array.from(e.children).filter(C=>C instanceof HTMLElement).reduce((C,v)=>{let y=v.getBoundingClientRect(),f=y.top+y.height/2;if(!C)return v;let h=C.getBoundingClientRect(),d=h.top+h.height/2;return Math.abs(f-o)<Math.abs(d-o)?v:C},null)??e.firstElementChild??e,l=e.getBoundingClientRect(),s=r.getBoundingClientRect(),u=xr(t,l.left+1,l.right-1),m=xr(o,s.top+1,s.bottom-1);Ia(u,m);}function Ma(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(Xo(e))}}function Et(e,t){let o=t??Jt;return e==="json"?Jn(JSON.stringify(o)):e==="markdown"?Gn(jsonToMarkdown(o)):Wn(jsonToHTML(o))}function Oa(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 Na(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 Ha(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 Ra(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 Aa(e){if(!Number.isFinite(e))return "8";let t=Math.floor(e);return t<0?"8":t.toString()}function Go(e){return gr(e)}function Pa(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 za(e){return fr(e)}function Ba(e){let t=qt(e);return JSON.stringify($o.map(o=>[o,t[o]]))}function Ir(e){return hr(e)}var Da=[{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 Ua(e,t){return pr(e,t)}function Ka(e,t,o){return yr(e,t,o)}var Va={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 _a(e,t){return br(e,t,Va)}function ja(e){if(!e||e.length===0)return [...Be];let t=new Set,o=[];for(let n of e)!Be.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Be]}function $a(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,l=[];for(let s of e)for(let[u,m]of Object.entries(s)){let C=u.trim();!m||!C||r.has(C)||(r.add(C),l.push(C));}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 m=u.trim();!m||l.has(m)||(l.add(m),s.push(m));}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 qa(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 Ya(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 Ja(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 m=`${s.key}:${s.ctrlKey?1:0}:${s.metaKey?1:0}:${s.shiftKey?1:0}:${s.altKey?1:0}`,C=`${u.key}:${u.ctrlKey?1:0}:${u.metaKey?1:0}:${u.shiftKey?1:0}:${u.altKey?1:0}`;return m.localeCompare(C)});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 Ga({isDark:e,toggleTheme:t,visualPlaceholder:o,jsonPlaceholder:n,markdownPlaceholder:i,htmlPlaceholder:r,initialMode:l,availableModes:s,onReady:u,toolbarLayout:m,toolbarVisibility:C,toolbarPosition:v,toolbarAlignment:y,toolbarClassName:f,toolbarStyleVars:h,isToolbarEnabled:d,isToolbarPinned:E,isEditorViewTabsVisible:T,headingOptions:I,paragraphLabel:W,syncHeadingOptionsWithCommands:D,slashCommandVisibility:A,shortcutConfig:ne,commandPaletteShortcutOnly:ie,featureFlags:L,editOnClick:ae}){let{commands:x,hasExtension:F,activeStates:S,lexical:N,extensions:P,export:Q,import:se}=ka(),[O,fe]=useState(l),[le,X]=useState({json:"",markdown:"",html:""}),[xe,ge]=useState(null),[He,Ee]=useState(null),[Ue,Ke]=useState({isOpen:false,commands:[]}),[he,ke]=useState({isOpen:false,query:"",position:null,commands:[]}),[be,Ve]=useState({isOpen:false,query:"",position:null,suggestions:[]}),_e=useRef(false),H=useMemo(()=>ja(I),[I]),_=D?H:void 0,ue=D?W:void 0,Ge=S.isInCodeBlock===true,Z=useMemo(()=>Ka(x,L,Ge),[x,L,Ge]),Re=useMemo(()=>g=>Object.prototype.hasOwnProperty.call(L,g)?L[g]!==false:true,[L]),Le=useMemo(()=>g=>re(O)&&Re(g),[O,Re]),ct=useMemo(()=>_a(C,L),[C,L]),je=L.draggableBlock!==false,Ae=$a(A),$e=useRef(A),we=useRef(Ae),Pe=Ja(ne),pe=useRef(ne),We=useRef(Pe),J=useMemo(()=>qa(ne?.disabledCommandIds),[ne?.disabledCommandIds]),Te=useMemo(()=>new Set(J),[J]),tt=useMemo(()=>Te.size===0?[]:To({headingOptions:_,paragraphLabel:ue,isFeatureEnabled:Re}).filter(g=>Te.has(g.id)).flatMap(g=>g.shortcuts??[]),[Te,_,ue,Re]);we.current!==Ae&&(we.current=Ae,$e.current=A),We.current!==Pe&&(We.current=Pe,pe.current=ne);let ye=useRef(vr(["visual-editor"])),ot=useRef({json:false,markdown:false,html:false}),kt=useRef(0),Ie=useRef(null);useEffect(()=>{No(Z,S,e?"dark":"light",Le);},[Z,S,e,Le]);let dt=useMemo(()=>({injectJSON:V=>{setTimeout(()=>{try{let me=JSON.parse(V);se.fromJSON(me);}catch(me){console.error("Failed to inject JSON:",me);return}},100);},getJSON:()=>Et("json",Q.toJSON()),getMarkdown:()=>Et("markdown",Q.toJSON()),getHTML:()=>Et("html",Q.toJSON())}),[Q,se]);useEffect(()=>{if(!N||!Z)return;let g=Z,k=tn(g,{headingOptions:_,paragraphLabel:ue,isFeatureEnabled:Le,shortcutConfig:pe.current,commandPaletteShortcutOnly:ie});typeof g.registerCommand=="function"&&k.forEach(V=>g.registerCommand(V));let Y=on(g,{headingOptions:_,paragraphLabel:ue,slashCommandVisibility:$e.current,isFeatureEnabled:Le,shortcutConfig:pe.current});typeof g.setSlashCommands=="function"?g.setSlashCommands(Y):Y.forEach(V=>g.registerSlashCommand?.(V));let G=rn(g,document.body,{headingOptions:_,paragraphLabel:ue,isFeatureEnabled:Le,shortcutConfig:pe.current,scope:()=>N.getRootElement()});return _e.current||(_e.current=true,u?.(dt)),()=>{G(),typeof g.unregisterCommand=="function"&&k.forEach(V=>g.unregisterCommand(V.id)),typeof g.setSlashCommands=="function"?g.setSlashCommands([]):Y.forEach(V=>g.unregisterSlashCommand?.(V.id));}},[N,Z,dt,u,_,ue,Ae,Pe,Le,ie]),useEffect(()=>{let g=()=>N?.getRootElement(),k=Da.filter(G=>L[G.feature]===false);if(k.length===0)return;let Y=G=>{let V=g();V&&G.target instanceof Node&&!V.contains(G.target)||!Ir(G.target)||!k.some(Hr=>Ua(G,Hr))||(G.preventDefault(),G.stopPropagation());};return document.addEventListener("keydown",Y,true),()=>{document.removeEventListener("keydown",Y,true);}},[N,L]),useEffect(()=>{let g=P.find(k=>k.name==="commandPalette");if(!(!g||!g.subscribe))return g.subscribe((k,Y)=>{let G=Y.filter(V=>Te.has(V.id)?false:ie?typeof V.shortcut=="string"&&V.shortcut.trim().length>0:true);Ke({isOpen:re(O)?k:false,commands:G});})},[P,Te,ie,O]),useEffect(()=>{if(tt.length===0)return;let g=()=>N?.getRootElement(),k=Y=>{let G=g();G&&Y.target instanceof Node&&!G.contains(Y.target)||!Ir(Y.target)||!tt.some(me=>Ya(Y,me))||(Y.preventDefault(),Y.stopPropagation());};return document.addEventListener("keydown",k,true),()=>{document.removeEventListener("keydown",k,true);}},[N,tt]),useEffect(()=>{let g=P.find(k=>k.name==="slashCommand");if(!(!g||!g.subscribe))return g.subscribe(k=>{ke({isOpen:re(O)?k.isOpen:false,query:re(O)?k.query:"",position:re(O)?k.position:null,commands:re(O)?k.commands:[]});})},[P,O]),useEffect(()=>{let g=P.find(k=>k.name==="emoji");if(!(!g||!g.subscribe))return g.subscribe(k=>{Ve({isOpen:re(O)?k.isOpen:false,query:re(O)?k.query:"",position:re(O)?k.position:null,suggestions:re(O)?k.suggestions:[]});})},[P,O]),useEffect(()=>{re(O)||(Ke(g=>g.isOpen?{...g,isOpen:false}:g),ke(g=>g.isOpen||g.query.length>0||g.position!==null||g.commands.length>0?{isOpen:false,query:"",position:null,commands:[]}:g),Ve(g=>g.isOpen||g.query.length>0||g.position!==null||g.suggestions.length>0?{isOpen:false,query:"",position:null,suggestions:[]}:g),Z.hideCommandPalette?.(),Z.closeSlashMenu?.(),Z.closeEmojiSuggestions?.());},[O,Z]),useEffect(()=>!N||!Q?void 0:N.registerUpdateListener(()=>{kt.current+=1,Yo(ye.current,["visual-editor"]);}),[N,Q]);let Lt=g=>{let k=le[g];if(g==="json"){if(!k.trim()){se.fromJSON(Xo(""));return}let Y=JSON.parse(k);se.fromJSON(Y);return}g==="markdown"?se.fromJSON(markdownToJSON(k)):se.fromJSON(htmlToJSON(k)),ot.current[g]=false,Yo(ye.current,["visual-editor"]);},wt=g=>{let k=Q.toJSON()??Jt;return Et(g,k)},Xe=(g,k,Y)=>{X(G=>({...G,[g]:k})),ot.current[g]=Y?.dirty===true;},nt=async g=>{let k=Gt(g);if(k===O||!Wo(s,k))return;let Y=O,G=null;try{if(Ee(null),Jo(Y)){let V=Y;ot.current[V]&&(G=V,Lt(V),await new Promise(me=>setTimeout(me,50)),G=null);}if(re(Y)&&!re(k)&&(N&&clearLexicalSelection(N),N?.getRootElement()?.blur()),fe(k),Jo(k)){let V=k;if(!Cr(ye.current,V)){ge(V),await new Promise(me=>setTimeout(me,50));try{G=V;let me=wt(V);Xe(V,me),Er(ye.current,V),G=null;}finally{ge(null);}}}re(k)&&(Y==="visual-only"&&Ie.current!==null?setTimeout(()=>N?.focus(),100):Sa(()=>{let me=N?.getRootElement();me&&Ta(me);}));}catch(V){let me=V instanceof Error?V.message:"Invalid format - could not parse content";G&&Ee({mode:G,error:me});}},rt=g=>{!ae||O!=="visual-only"||!Wo(s,"visual-editor")||(Ie.current=g,nt("visual-editor"));};useEffect(()=>{if(!re(O))return;let g=Ie.current;if(!g)return;Ie.current=null;let k=()=>{let G=N?.getRootElement();G&&Fa(G,g.clientX,g.clientY);};if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(()=>k());return}let Y=globalThis.setTimeout(k,0);return ()=>{globalThis.clearTimeout(Y);}},[N,O]);let qe=d?jsx(or,{commands:Z,hasExtension:g=>F(g),activeStates:S,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{re(O)&&L.commandPalette!==false&&Z.showCommandPalette();},imageUploadHandler:g=>P.find(k=>k.name==="image")?.config?.uploadHandler?.(g)??Promise.resolve(URL.createObjectURL(g)),layout:m??Xt,toolbarVisibility:ct,toolbarStyleVars:h,headingOptions:H,paragraphLabel:W,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${y}${f?` ${f}`:""}`}}):null,ze=T,it=re(O)&&d&&v==="top",Tt=["luthor-editor-top-region",E&&v==="top"&&ze?"luthor-editor-top-region--pinned":""].filter(Boolean).join(" "),gt=["luthor-editor-toolbar-slot","luthor-editor-toolbar-slot--top",it&&(E&&v==="top"&&!ze)?"luthor-editor-toolbar-slot--pinned":""].filter(Boolean).join(" "),St=re(O)&&d&&v==="bottom",b=N?.getRootElement()?.closest(".luthor-editor-wrapper")??null,p=Jo(O)?O:null,B=O==="visual-only",U=re(O)||B,j=!je||!re(O);return jsxs(Fragment,{children:[jsxs("div",{className:`luthor-editor${j?" luthor-editor--draggable-disabled":""}`,"data-mode":O,children:[(ze||it)&&jsxs("div",{className:Tt,children:[ze&&jsx("div",{className:"luthor-editor-header",children:jsx(_n,{mode:O,onModeChange:nt,availableModes:s,isConverting:xe})}),it&&jsx("div",{className:gt,children:qe})]}),jsxs("div",{className:`luthor-editor-visual-shell${U?"":" is-hidden"}${j?" luthor-editor-visual-shell--no-gutter":""}`,"aria-hidden":!U,children:[!j&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:o,nonEditableVisualMode:B,onEditIntent:B?rt: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"}})]}),p&&jsxs("div",{className:"luthor-source-panel",children:[He&&He.mode===p&&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:La[p]}),jsx("p",{children:He.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),p==="json"&&jsx(go,{value:le.json,onChange:g=>Xe("json",g,{dirty:true}),placeholder:n}),p==="markdown"&&jsx(go,{value:le.markdown,onChange:g=>Xe("markdown",g,{dirty:true}),placeholder:i,className:"luthor-source-view--wrapped",wrap:"soft"}),p==="html"&&jsx(go,{value:le.html,onChange:g=>Xe("html",g,{dirty:true}),placeholder:r,className:"luthor-source-view--wrapped",wrap:"soft"})]})]}),jsx(Vn,{editor:N,commands:Z,editorTheme:e?"dark":"light",disabled:!re(O)}),St&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:qe}),re(O)&&jsx(Sn,{isOpen:Ue.isOpen,onClose:()=>Z.hideCommandPalette(),commands:Ue.commands}),re(O)&&jsx(Nn,{isOpen:he.isOpen,query:he.query,position:he.position,portalContainer:b,commands:he.commands,onClose:()=>Z.closeSlashMenu?.(),onExecute:g=>{Z.executeSlashCommand?.(g);}}),re(O)&&jsx(Fn,{isOpen:be.isOpen,query:be.query,position:be.position,portalContainer:b,suggestions:be.suggestions,onClose:()=>Z.closeEmojiSuggestions?.(),onExecute:g=>{Z.executeEmojiSuggestion?.(g);}})]})}var Lo=forwardRef(({className:e,onReady:t,initialTheme:o="light",onThemeChange:n,theme:i,defaultContent:r,showDefaultContent:l=true,placeholder:s=kr,defaultEditorView:u,initialMode:m="visual-editor",isEditorViewTabsVisible:C,isEditorViewsTabVisible:v,availableModes:y=["visual-editor","visual-only","json","markdown","html"],variantClassName:f,toolbarLayout:h,toolbarVisibility:d,toolbarPosition:E="top",toolbarAlignment:T="left",toolbarClassName:I,toolbarStyleVars:W,quoteClassName:D,quoteStyleVars:A,defaultSettings:ne,editorThemeOverrides:ie,isToolbarEnabled:L=true,isToolbarPinned:ae=false,fontFamilyOptions:x,fontSizeOptions:F,lineHeightOptions:S,minimumDefaultLineHeight:N=1.5,scaleByRatio:P=false,headingOptions:Q,paragraphLabel:se,syncHeadingOptionsWithCommands:O=true,slashCommandVisibility:fe,shortcutConfig:le,commandPaletteShortcutOnly:X=false,editOnClick:xe=true,isDraggableBoxEnabled:ge,featureFlags:He,syntaxHighlighting:Ee,codeHighlightProvider:Ue,loadCodeHighlightProvider:Ke,maxAutoDetectCodeLength:he,isCopyAllowed:ke=true,languageOptions:be,maxListIndentation:Ve=8},_e)=>{let[H,_]=useState(o),ue=useRef(null),Ge=H==="dark",Z=Gt(u??m),Re=Wo(y,Z)?Z:Gt(y[0]??"visual-editor"),Le=C??v??true,ct=()=>_(Ge?"light":"dark"),je=useMemo(()=>typeof s=="string"?{visual:s,json:Lr,markdown:wr,html:Tr}:{visual:s.visual??kr,json:s.json??Lr,markdown:s.markdown??wr,html:s.html??Tr},[s]);useEffect(()=>{_(o);},[o]),useEffect(()=>{n?.(H);},[H,n]),useEffect(()=>{if(!ae||E!=="top")return;let k=ue.current;if(k)return xa(k)},[ae,E]);let Ae=useMemo(()=>Oa(x),[x]),$e=useMemo(()=>Na(F),[F]),we=useMemo(()=>Ha(S),[S]),Pe=useMemo(()=>Ra(N),[N]),pe=useMemo(()=>Aa(Ve),[Ve]),We=Ee??"unset",J=typeof he=="number"?he.toString():"unset",Te=useMemo(()=>Pa(be),[be]),tt=ke?"copy-on":"copy-off",ye=useMemo(()=>typeof ge!="boolean"?He:{...He??{},draggableBlock:ge},[He,ge]),ot=useMemo(()=>Ba(ye),[ye]),kt=useMemo(()=>qt(ye),[ye]),Ie=`${Ae}::${$e}::${we}::${Pe}::${pe}::${P?"ratio-on":"ratio-off"}::${We}::${J}::${tt}::${Te}::${ot}`,dt=useRef(x),Lt=useRef(F),wt=useRef(S),Xe=useRef(N),nt=useRef(ye),rt=useRef(be),qe=useRef(Ue),ze=useRef(Ke),it=useRef(Ie);(it.current!==Ie||qe.current!==Ue||ze.current!==Ke)&&(it.current=Ie,dt.current=x,Lt.current=F,wt.current=S,Xe.current=N,nt.current=ye,rt.current=be,qe.current=Ue,ze.current=Ke);let mt=useRef(null);if(!mt.current||mt.current.key!==Ie){let k={fontFamilyOptions:dt.current,fontSizeOptions:Lt.current,lineHeightOptions:wt.current,minimumDefaultLineHeight:Xe.current,maxListIndentation:Number(pe),scaleByRatio:P,...Ee!==void 0?{syntaxHighlighting:Ee}:{},...qe.current!==void 0?{codeHighlightProvider:qe.current}:{},...ze.current!==void 0?{loadCodeHighlightProvider:ze.current}:{},...he!==void 0?{maxAutoDetectCodeLength:he}:{},isCopyAllowed:ke,...rt.current!==void 0?{languageOptions:rt.current}:{},...typeof ge=="boolean"?{isDraggableBoxEnabled:ge}:{},...nt.current?{featureFlags:nt.current}:{}};mt.current={key:Ie,value:Yt(k)};}let Tt=mt.current.value,Wt=useMemo(()=>{let k=mergeThemes(defaultLuthorTheme,i??{});return D?{...k,quote:`${k.quote??""} ${D}`.trim()}:k},[i,D]),gt=useMemo(()=>Go(ie),[ie]),St=useMemo(()=>Go(A),[A]),b=useMemo(()=>za(ne),[ne]),p=useMemo(()=>Go(b),[b]),B=useMemo(()=>{let k=b,Y=createEditorThemeStyleVars(ie),G=A,V={"--luthor-default-line-height":Pe};return !k&&!Y&&!G?V:{...k??{},...Y,...G??{},...V}},[Pe,b,ie,A,p,gt,St]),[U,j]=useState(null);useImperativeHandle(_e,()=>U??{injectJSON:()=>{},getJSON:()=>Et("json",Jt),getMarkdown:()=>Et("markdown",Jt),getHTML:()=>Et("html",Jt)},[U]);let g=k=>{j(k),r&&k.injectJSON(Ma(r)),t?.(k);};return jsx("div",{ref:ue,className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper${ae?" luthor-editor-wrapper--toolbar-pinned":""} ${f||""} ${e||""}`.trim(),"data-editor-theme":H,style:B,children:jsx(Ea,{extensions:Tt,config:{theme:Wt},children:jsx(Ga,{isDark:Ge,toggleTheme:ct,visualPlaceholder:je.visual,jsonPlaceholder:je.json,markdownPlaceholder:je.markdown,htmlPlaceholder:je.html,initialMode:Re,availableModes:y,onReady:g,toolbarLayout:h,toolbarVisibility:d,toolbarPosition:E,toolbarAlignment:T,toolbarClassName:I,toolbarStyleVars:W,isToolbarEnabled:L,isToolbarPinned:ae,isEditorViewTabsVisible:Le,headingOptions:Q,paragraphLabel:se,syncHeadingOptionsWithCommands:O,slashCommandVisibility:fe,shortcutConfig:le,commandPaletteShortcutOnly:X,featureFlags:kt,editOnClick:xe})})})});Lo.displayName="ExtensiveEditor";var Or=["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"],Nr={id:"extensive",label:"Extensive Editor",description:"Complete editing preset with all core features enabled.",extensions:[...qo],components:{Editor:Lo},toolbar:[...Or],config:jn("extensive","Write anything..."),css:"extensive/styles.css"};function Xa(e={}){return {...Nr,extensions:[...Yt({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,maxListIndentation:e.maxListIndentation,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}export{lt as $,xo as A,vr as Aa,cn as B,Yo as Ba,dn as C,Cr as Ca,mn as D,Er as Da,is as E,Lo as Ea,gn as F,Or as Fa,ls as G,Nr as Ga,ao as H,Xa as Ha,fn as I,hn as J,so as K,pn as L,bn as M,yn as N,vn as O,Cn as P,Io as Q,En as R,kn as S,Mt as T,Ln as U,Sn as V,Fn as W,Nn as X,R as Y,Oo as Z,Vt as _,Qa as a,An as aa,Be as b,Pn as ba,es as c,No as ca,Xt as d,zn as da,To as e,Vn as ea,tn as f,_n as fa,on as g,go as ga,rn as h,jn as ha,Zt as i,Jn as ia,eo as j,Gn as ja,to as k,Wn as ka,oo as l,il as la,no as m,ll as ma,ln as n,al as na,xt as o,or as oa,ft as p,ur as pa,ro as q,qt as qa,io as r,cr as ra,lo as s,Yt as sa,an as t,qo as ta,sn as u,gr as ua,So as v,fr as va,It as w,hr as wa,ht as x,pr as xa,un as y,br as ya,Ft as z,yr as za};
@@ -1 +1 @@
1
- import {a,b as b$1}from'./chunk-KORFS25D.js';import {Ea,ha,sa}from'./chunk-G4AWPZBL.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,codeFormat:true,image:false,table:false,iframeEmbed:false,youTubeEmbed:false,emoji:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false},b=new a(E),o=forwardRef(({className:m,variantClassName:d,compactToolbar:t=false,toolbarClassName:p,featureFlags:f,...c},n)=>jsx("div",{className:b$1("luthor-preset-compose",m),children:jsx(Ea,{ref:n,...c,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","json"],featureFlags:b.resolve(f)})}));o.displayName="ComposeEditor";var g={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,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,g as b};
1
+ import {a,b as b$1}from'./chunk-MNY5WN6Z.js';import {Ea,ha,sa}from'./chunk-GL7DJO7R.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,codeFormat:true,image:false,table:false,iframeEmbed:false,youTubeEmbed:false,emoji:false,floatingToolbar:false,contextMenu:false,commandPalette:false,slashCommand:false,draggableBlock:false,customNode:false},b=new a(E),o=forwardRef(({className:m,variantClassName:d,compactToolbar:t=false,toolbarClassName:p,featureFlags:f,...c},n)=>jsx("div",{className:b$1("luthor-preset-compose",m),children:jsx(Ea,{ref:n,...c,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","json"],featureFlags:b.resolve(f)})}));o.displayName="ComposeEditor";var g={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,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,g as b};
@@ -1 +1 @@
1
- import {a}from'./chunk-G4AWPZBL.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-GL7DJO7R.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-BYUGKIJC.js';import {b}from'./chunk-KORFS25D.js';import {ha,sa}from'./chunk-G4AWPZBL.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var a=d,f=e,t=forwardRef(({className:E,variantClassName:m,toolbarClassName:p,toolbarLayout:c,initialMode:n="visual",defaultEditorView:l,...M},D)=>jsx(f$1,{ref:D,...M,className:b("luthor-preset-md-editor",E),variantClassName:b("luthor-preset-md-editor__variant",m),toolbarClassName:b("luthor-preset-md-editor__toolbar",p),sourceFormat:"markdown",initialMode:n,defaultEditorView:l,toolbarLayout:c??f}));t.displayName="MDEditor";var u={id:"md-editor",label:"MD Editor",description:"Markdown-native feature set with visual, JSON, and MD source views.",extensions:sa({featureFlags:a}),components:{Editor:t},toolbar:["undo","redo","blockFormat","quote","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule"],config:ha("md-editor","Write markdown..."),css:"md-editor/styles.css"};export{t as a,u as b};
1
+ import {f as f$1,e,d}from'./chunk-QR4BVSTW.js';import {b}from'./chunk-MNY5WN6Z.js';import {ha,sa}from'./chunk-GL7DJO7R.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var a=d,f=e,t=forwardRef(({className:E,variantClassName:m,toolbarClassName:p,toolbarLayout:c,initialMode:n="visual",defaultEditorView:l,...M},D)=>jsx(f$1,{ref:D,...M,className:b("luthor-preset-md-editor",E),variantClassName:b("luthor-preset-md-editor__variant",m),toolbarClassName:b("luthor-preset-md-editor__toolbar",p),sourceFormat:"markdown",initialMode:n,defaultEditorView:l,toolbarLayout:c??f}));t.displayName="MDEditor";var u={id:"md-editor",label:"MD Editor",description:"Markdown-native feature set with visual, JSON, and MD source views.",extensions:sa({featureFlags:a}),components:{Editor:t},toolbar:["undo","redo","blockFormat","quote","bold","italic","strikethrough","code","codeBlock","link","unorderedList","orderedList","checkList","horizontalRule"],config:ha("md-editor","Write markdown..."),css:"md-editor/styles.css"};export{t as a,u as b};
@@ -1 +1 @@
1
- import {a,b as b$1}from'./chunk-KORFS25D.js';import {Ea,ha,sa}from'./chunk-G4AWPZBL.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var n=["visual","json","markdown"],E=["visual","json","html"],m=["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:false,list:true,history:true,image:false,blockFormat:true,code:true,codeIntelligence:false,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},b={draggableBlock:false,table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false,emoji:false,commandPalette:false,slashCommand:false,themeToggle:false},M=new a(o,b),u={sections:[{items:["undo","redo"]},{items:["blockFormat","quote"]},{items:["bold","italic","strikethrough","code","link"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["codeBlock","horizontalRule"]}]};function O(e){return e==="both"?m:e==="html"?E:n}var r=forwardRef(({className:e,variantClassName:f,toolbarClassName:L,toolbarLayout:_,sourceFormat:h="both",initialMode:R="visual",defaultEditorView:g,featureFlags:y,...p},C)=>{let a=O(h),i=g??R,F=a.includes(i)?i:"visual";return jsx(Ea,{ref:C,...p,className:b$1("luthor-preset-legacy-rich",e),variantClassName:b$1("luthor-preset-legacy-rich__variant",f),toolbarClassName:b$1("luthor-preset-legacy-rich__toolbar",L),availableModes:a,initialMode:F,toolbarLayout:_??u,featureFlags:M.resolve(y)})});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","bold","italic","strikethrough","code","link","unorderedList","orderedList","checkList","indentList","outdentList","codeBlock","horizontalRule"],config:ha("legacy-rich","Write metadata-free content...")};export{n as a,E as b,m as c,o as d,u as e,r as f,x as g};
1
+ import {a,b as b$1}from'./chunk-MNY5WN6Z.js';import {Ea,ha,sa}from'./chunk-GL7DJO7R.js';import {forwardRef}from'react';import {jsx}from'react/jsx-runtime';var n=["visual","json","markdown"],E=["visual","json","html"],m=["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:false,list:true,history:true,image:false,blockFormat:true,code:true,codeIntelligence:false,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},b={draggableBlock:false,table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false,emoji:false,commandPalette:false,slashCommand:false,themeToggle:false},M=new a(o,b),u={sections:[{items:["undo","redo"]},{items:["blockFormat","quote"]},{items:["bold","italic","strikethrough","code","link"]},{items:["unorderedList","orderedList","checkList","indentList","outdentList"]},{items:["codeBlock","horizontalRule"]}]};function O(e){return e==="both"?m:e==="html"?E:n}var r=forwardRef(({className:e,variantClassName:f,toolbarClassName:L,toolbarLayout:_,sourceFormat:h="both",initialMode:R="visual",defaultEditorView:g,featureFlags:y,...p},C)=>{let a=O(h),i=g??R,F=a.includes(i)?i:"visual";return jsx(Ea,{ref:C,...p,className:b$1("luthor-preset-legacy-rich",e),variantClassName:b$1("luthor-preset-legacy-rich__variant",f),toolbarClassName:b$1("luthor-preset-legacy-rich__toolbar",L),availableModes:a,initialMode:F,toolbarLayout:_??u,featureFlags:M.resolve(y)})});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","bold","italic","strikethrough","code","link","unorderedList","orderedList","checkList","indentList","outdentList","codeBlock","horizontalRule"],config:ha("legacy-rich","Write metadata-free content...")};export{n as a,E as b,m as c,o as d,u as e,r as f,x as g};
@@ -1 +1 @@
1
- import {ha,sa,Ea,ja}from'./chunk-G4AWPZBL.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"],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-GL7DJO7R.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"],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};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {b as b$1}from'./chunk-QCT2LCGA.js';export{a as SlashEditor,b as slashEditorPreset}from'./chunk-QCT2LCGA.js';import {b as b$5}from'./chunk-AQITWSLU.js';export{a as ComposeEditor,b as composePreset}from'./chunk-AQITWSLU.js';import {b}from'./chunk-UE3C2U7K.js';export{a as HeadlessEditorPreset,b as headlessEditorPreset}from'./chunk-UE3C2U7K.js';import {b as b$2}from'./chunk-TEICP7IP.js';export{a as HTMLEditor,b as htmlEditorPreset}from'./chunk-TEICP7IP.js';import {b as b$3}from'./chunk-BGKRPQL5.js';export{a as MDEditor,b as mdEditorPreset}from'./chunk-BGKRPQL5.js';import {g}from'./chunk-BYUGKIJC.js';export{f as LegacyRichEditor,g as legacyRichPreset}from'./chunk-BYUGKIJC.js';export{a as PresetFeaturePolicy,b as joinClassNames}from'./chunk-KORFS25D.js';import {b as b$4}from'./chunk-6JECGXED.js';export{a as SimpleEditor,b as simpleEditorPreset}from'./chunk-6JECGXED.js';import {Ga}from'./chunk-G4AWPZBL.js';export{x as AlignCenterIcon,y as AlignJustifyIcon,w as AlignLeftIcon,z as AlignRightIcon,b as BLOCK_HEADING_LEVELS,i as BoldIcon,Z as Button,T as ChevronDownIcon,U as CloseIcon,n as CodeBlockIcon,m as CodeIcon,H as CommandIcon,V as CommandPalette,c as DEFAULT_TOOLBAR_LAYOUT,aa as Dialog,$ as Dropdown,Q as EmojiIcon,W as EmojiSuggestionMenu,Ea as ExtensiveEditor,E as EyeIcon,D as FileCodeIcon,ba as FloatingToolbar,F as HighlighterIcon,Y as IconButton,v as ImageIcon,L as IndentIcon,j as ItalicIcon,ea as LinkHoverBubble,o as LinkIcon,r as ListCheckIcon,q as ListIcon,s as ListOrderedIcon,B as MinusIcon,fa as ModeTabs,O as MoonIcon,M as OutdentIcon,I as PaletteIcon,G as PencilIcon,K as QuoteIcon,u as RedoIcon,P as SearchIcon,_ as Select,X as SlashCommandMenu,ga as SourceView,l as StrikethroughIcon,R as SubscriptIcon,N as SunIcon,S as SuperscriptIcon,d as TRADITIONAL_TOOLBAR_LAYOUT,C as TableIcon,oa as Toolbar,J as TypeIcon,k as UnderlineIcon,t as UndoIcon,p as UnlinkIcon,A as UploadIcon,f as commandsToCommandPaletteItems,g as commandsToSlashCommandItems,va as createDefaultSettingsStyleVarRecord,sa as createExtensiveExtensions,Ha as createExtensivePreset,za as createFeatureGuardedCommands,da as createFloatingToolbarExtension,Aa as createModeCache,ha as createPresetEditorConfig,ta as extensiveExtensions,Ga as extensivePreset,na as filterToolbarLayout,ka as formatHTMLSource,ia as formatJSONSource,ja as formatMarkdownSource,e as generateCommands,Ba as invalidateModeCache,wa as isEditableCommandTarget,Ca as isModeCached,xa as isShortcutMatch,la as isToolbarItemSupported,ma as isToolbarItemVisible,Da as markModeCached,ya as mergeToolbarVisibilityWithFeatures,ua as normalizeStyleVarsKey,h as registerKeyboardShortcuts,ca as setFloatingToolbarContext}from'./chunk-G4AWPZBL.js';import*as luthorHeadless from'@lyfie/luthor-headless';export{luthorHeadless as headless };export{CodeIntelligenceExtension,codeIntelligenceExtension}from'@lyfie/luthor-headless';var st={extensive:Ga,compose:b$5,"simple-editor":b$4,"legacy-rich":g,"md-editor":b$3,"html-editor":b$2,"slash-editor":b$1,"headless-editor":b};export{st as presetRegistry};
1
+ import {b as b$1}from'./chunk-AQHHUIQ3.js';export{a as SlashEditor,b as slashEditorPreset}from'./chunk-AQHHUIQ3.js';import {b as b$5}from'./chunk-KUSWVTGG.js';export{a as ComposeEditor,b as composePreset}from'./chunk-KUSWVTGG.js';import {b}from'./chunk-CJUAF2ZJ.js';export{a as HeadlessEditorPreset,b as headlessEditorPreset}from'./chunk-CJUAF2ZJ.js';import {b as b$2}from'./chunk-GGNCG4TZ.js';export{a as HTMLEditor,b as htmlEditorPreset}from'./chunk-GGNCG4TZ.js';import {b as b$3}from'./chunk-OYU7EEHU.js';export{a as MDEditor,b as mdEditorPreset}from'./chunk-OYU7EEHU.js';import {g}from'./chunk-QR4BVSTW.js';export{f as LegacyRichEditor,g as legacyRichPreset}from'./chunk-QR4BVSTW.js';export{a as PresetFeaturePolicy,b as joinClassNames}from'./chunk-MNY5WN6Z.js';import {b as b$4}from'./chunk-UHC7J3PD.js';export{a as SimpleEditor,b as simpleEditorPreset}from'./chunk-UHC7J3PD.js';import {Ga}from'./chunk-GL7DJO7R.js';export{x as AlignCenterIcon,y as AlignJustifyIcon,w as AlignLeftIcon,z as AlignRightIcon,b as BLOCK_HEADING_LEVELS,i as BoldIcon,Z as Button,T as ChevronDownIcon,U as CloseIcon,n as CodeBlockIcon,m as CodeIcon,H as CommandIcon,V as CommandPalette,c as DEFAULT_TOOLBAR_LAYOUT,aa as Dialog,$ as Dropdown,Q as EmojiIcon,W as EmojiSuggestionMenu,Ea as ExtensiveEditor,E as EyeIcon,D as FileCodeIcon,ba as FloatingToolbar,F as HighlighterIcon,Y as IconButton,v as ImageIcon,L as IndentIcon,j as ItalicIcon,ea as LinkHoverBubble,o as LinkIcon,r as ListCheckIcon,q as ListIcon,s as ListOrderedIcon,B as MinusIcon,fa as ModeTabs,O as MoonIcon,M as OutdentIcon,I as PaletteIcon,G as PencilIcon,K as QuoteIcon,u as RedoIcon,P as SearchIcon,_ as Select,X as SlashCommandMenu,ga as SourceView,l as StrikethroughIcon,R as SubscriptIcon,N as SunIcon,S as SuperscriptIcon,d as TRADITIONAL_TOOLBAR_LAYOUT,C as TableIcon,oa as Toolbar,J as TypeIcon,k as UnderlineIcon,t as UndoIcon,p as UnlinkIcon,A as UploadIcon,f as commandsToCommandPaletteItems,g as commandsToSlashCommandItems,va as createDefaultSettingsStyleVarRecord,sa as createExtensiveExtensions,Ha as createExtensivePreset,za as createFeatureGuardedCommands,da as createFloatingToolbarExtension,Aa as createModeCache,ha as createPresetEditorConfig,ta as extensiveExtensions,Ga as extensivePreset,na as filterToolbarLayout,ka as formatHTMLSource,ia as formatJSONSource,ja as formatMarkdownSource,e as generateCommands,Ba as invalidateModeCache,wa as isEditableCommandTarget,Ca as isModeCached,xa as isShortcutMatch,la as isToolbarItemSupported,ma as isToolbarItemVisible,Da as markModeCached,ya as mergeToolbarVisibilityWithFeatures,ua as normalizeStyleVarsKey,h as registerKeyboardShortcuts,ca as setFloatingToolbarContext}from'./chunk-GL7DJO7R.js';import*as luthorHeadless from'@lyfie/luthor-headless';export{luthorHeadless as headless };export{CodeIntelligenceExtension,codeIntelligenceExtension}from'@lyfie/luthor-headless';var st={extensive:Ga,compose:b$5,"simple-editor":b$4,"legacy-rich":g,"md-editor":b$3,"html-editor":b$2,"slash-editor":b$1,"headless-editor":b};export{st as presetRegistry};
@@ -1 +1 @@
1
- export{a as ComposeEditor,b as composePreset}from'../../chunk-AQITWSLU.js';import'../../chunk-KORFS25D.js';import'../../chunk-G4AWPZBL.js';
1
+ export{a as ComposeEditor,b as composePreset}from'../../chunk-KUSWVTGG.js';import'../../chunk-MNY5WN6Z.js';import'../../chunk-GL7DJO7R.js';
@@ -1 +1 @@
1
- export{pa as DEFAULT_FEATURE_FLAGS,Ea as ExtensiveEditor,sa as createExtensiveExtensions,Ha as createExtensivePreset,ta as extensiveExtensions,Ga as extensivePreset,Fa as extensiveToolbar,ra as isFeatureEnabled,qa as resolveFeatureFlags}from'../../chunk-G4AWPZBL.js';
1
+ export{pa as DEFAULT_FEATURE_FLAGS,Ea as ExtensiveEditor,sa as createExtensiveExtensions,Ha as createExtensivePreset,ta as extensiveExtensions,Ga as extensivePreset,Fa as extensiveToolbar,ra as isFeatureEnabled,qa as resolveFeatureFlags}from'../../chunk-GL7DJO7R.js';
@@ -1 +1 @@
1
- export{a as HeadlessEditorPreset,b as headlessEditorPreset}from'../../chunk-UE3C2U7K.js';import'../../chunk-KORFS25D.js';import'../../chunk-G4AWPZBL.js';
1
+ export{a as HeadlessEditorPreset,b as headlessEditorPreset}from'../../chunk-CJUAF2ZJ.js';import'../../chunk-MNY5WN6Z.js';import'../../chunk-GL7DJO7R.js';
@@ -1 +1 @@
1
- export{a as HTMLEditor,b as htmlEditorPreset}from'../../chunk-TEICP7IP.js';import'../../chunk-BYUGKIJC.js';import'../../chunk-KORFS25D.js';import'../../chunk-G4AWPZBL.js';
1
+ export{a as HTMLEditor,b as htmlEditorPreset}from'../../chunk-GGNCG4TZ.js';import'../../chunk-QR4BVSTW.js';import'../../chunk-MNY5WN6Z.js';import'../../chunk-GL7DJO7R.js';
@@ -1 +1 @@
1
- export{d as LEGACY_RICH_DEFAULT_FEATURE_FLAGS,c as LEGACY_RICH_DUAL_SOURCE_MODES,b as LEGACY_RICH_HTML_MODES,a as LEGACY_RICH_MARKDOWN_MODES,e as LEGACY_RICH_TOOLBAR_LAYOUT,f as LegacyRichEditor,g as legacyRichPreset}from'../../chunk-BYUGKIJC.js';import'../../chunk-KORFS25D.js';import'../../chunk-G4AWPZBL.js';
1
+ export{d as LEGACY_RICH_DEFAULT_FEATURE_FLAGS,c as LEGACY_RICH_DUAL_SOURCE_MODES,b as LEGACY_RICH_HTML_MODES,a as LEGACY_RICH_MARKDOWN_MODES,e as LEGACY_RICH_TOOLBAR_LAYOUT,f as LegacyRichEditor,g as legacyRichPreset}from'../../chunk-QR4BVSTW.js';import'../../chunk-MNY5WN6Z.js';import'../../chunk-GL7DJO7R.js';
@@ -1 +1 @@
1
- export{a as MDEditor,b as mdEditorPreset}from'../../chunk-BGKRPQL5.js';import'../../chunk-BYUGKIJC.js';import'../../chunk-KORFS25D.js';import'../../chunk-G4AWPZBL.js';
1
+ export{a as MDEditor,b as mdEditorPreset}from'../../chunk-OYU7EEHU.js';import'../../chunk-QR4BVSTW.js';import'../../chunk-MNY5WN6Z.js';import'../../chunk-GL7DJO7R.js';
@@ -1 +1 @@
1
- export{a as SimpleEditor,b as simpleEditorPreset}from'../../chunk-6JECGXED.js';import'../../chunk-G4AWPZBL.js';
1
+ export{a as SimpleEditor,b as simpleEditorPreset}from'../../chunk-UHC7J3PD.js';import'../../chunk-GL7DJO7R.js';
@@ -1 +1 @@
1
- export{a as SlashEditor,b as slashEditorPreset}from'../../chunk-QCT2LCGA.js';import'../../chunk-KORFS25D.js';import'../../chunk-G4AWPZBL.js';
1
+ export{a as SlashEditor,b as slashEditorPreset}from'../../chunk-AQHHUIQ3.js';import'../../chunk-MNY5WN6Z.js';import'../../chunk-GL7DJO7R.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyfie/luthor",
3
- "version": "2.6.4",
3
+ "version": "2.6.5",
4
4
  "description": "Luthor presets and plug-and-play configuration for the headless editor",
5
5
  "type": "module",
6
6
  "private": false,
@@ -58,7 +58,7 @@
58
58
  "@lexical/table": "^0.40.0",
59
59
  "@lexical/utils": "^0.40.0",
60
60
  "lexical": "^0.40.0",
61
- "@lyfie/luthor-headless": "2.6.4"
61
+ "@lyfie/luthor-headless": "2.6.5"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/node": "^20.19.33",
@@ -1,6 +0,0 @@
1
- import {ImageExtension,TableExtension,IframeEmbedExtension,YouTubeEmbedExtension,ContextMenuExtension,CommandPaletteExtension,SlashCommandExtension,EmojiExtension,DraggableBlockExtension,LinkExtension,textColorExtension,textHighlightExtension,createCustomNodeExtension,createEditorSystem,mergeThemes,defaultLuthorTheme,createEditorThemeStyleVars,FloatingToolbarExtension,FontFamilyExtension,FontSizeExtension,LineHeightExtension,codeExtension,codeIntelligenceExtension,ListExtension,TabIndentExtension,boldExtension,italicExtension,underlineExtension,strikethroughExtension,subscriptExtension,superscriptExtension,horizontalRuleExtension,historyExtension,blockFormatExtension,codeFormatExtension,enterKeyBehaviorExtension,jsonToMarkdown,jsonToHTML,RichText,clearLexicalSelection,markdownToJSON,htmlToJSON,resolveLinkNodeKeyFromAnchor}from'@lyfie/luthor-headless';import Ki,{forwardRef,useState,useRef,useMemo,useEffect,useImperativeHandle,createElement,useLayoutEffect,useCallback}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var zr=Object.defineProperty;var Br=(e,t,o)=>t in e?zr(e,t,{enumerable:true,configurable:true,writable:true,value:o}):e[t]=o;var ts=(e,t,o)=>Br(e,typeof t!="symbol"?t+"":t,o);var Ue=["h1","h2","h3","h4","h5","h6"],ns={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"]}]},Zt={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 Dr(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 Ur(e,t){return Dr(e.target)?on(t):false}function on(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 Kr(e){return typeof e.toggleSubscript=="function"}function Vr(e){return typeof e.toggleSuperscript=="function"}function _r(e){return typeof e.insertIframeEmbed=="function"}function jr(e){return typeof e.insertYouTubeEmbed=="function"}function qr(e){return typeof e.insertEmoji=="function"}function $r(e){return e.slice(1)}function Yr(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 Jr(e){if(!e||e.length===0)return [...Ue];let t=new Set,o=[];for(let n of e)!Ue.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Ue]}function xo(e,t){return Qr(So(t),t?.shortcutConfig).filter(n=>!n.condition||n.condition(e))}function te(e,t){return typeof e[t]=="function"}function eo(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 Gr(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:eo(o),denylist:new Set}}let t=e;return {allowlist:eo(t.allowlist),denylist:eo(t.denylist)}}function nn(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 Wr(e){if(e===false||e===null)return [];let t=Array.isArray(e)?e:[e],o=[];for(let n of t){let i=nn(n);i&&o.push(i);}return o}function Xr(e){return [e.key.toLowerCase(),e.ctrlKey?"ctrl":"",e.metaKey?"meta":"",e.shiftKey?"shift":"",e.altKey?"alt":""].join(":")}function Qr(e,t){if(!t)return [...e];let o=eo(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 m=u.shortcuts?[...u.shortcuts]:void 0;if(!!n&&Object.prototype.hasOwnProperty.call(n,u.id)&&n){let v=n[u.id],y=v===void 0?[]:Wr(v);m=y.length>0?y:void 0;}if(m&&m.length>0){let v=[];for(let y of m){let h=nn(y);if(!h||i&&on(h))continue;let f=Xr(h);r&&l.has(f)||(l.add(f),v.push(h));}m=v.length>0?v:void 0;}return {...u,shortcuts:m}})}function So(e){let t=e?.isFeatureEnabled??(()=>true),o=Jr(e?.headingOptions),n=e?.paragraphLabel?.trim()||"Paragraph",i=o.map(r=>{let l=$r(r);return {id:`block.heading${l}`,label:`Heading ${l}`,description:Yr(r),category:"Block",action:s=>s.toggleHeading?.(r),shortcuts:[{key:l,ctrlKey:true,altKey:true}],keywords:["heading",r],condition:s=>t("blockFormat")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&Kr(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")&&Vr(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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")&&te(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 m=r.resolveEmojiShortcode(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}else if(typeof r.getEmojiSuggestions=="function"){let[m]=r.getEmojiSuggestions(u);if(m?.emoji){r.insertEmoji(m.emoji);return}}}r.insertEmoji(l);},keywords:["emoji","reaction","symbol","smile"],condition:r=>t("emoji")&&qr(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")&&te(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")&&_r(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")&&jr(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")&&te(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")&&te(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")&&te(r,"showCommandPalette")}]}function rn(e,t){let o=t?.commandPaletteShortcutOnly===true;return xo(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]?an(n.shortcuts[0]):void 0}))}function ln(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}=Gr(t?.slashCommandVisibility),l=i.size>0;return xo(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]?an(s.shortcuts[0]):void 0}))}function an(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 sn(e,t=document.body,o){let n=xo(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 m of u.shortcuts)if(!(o?.shortcutConfig?.preventNativeConflicts!==false&&Ur(l,m))&&i(l,m)&&!!l.ctrlKey==!!m.ctrlKey&&!!l.metaKey==!!m.metaKey&&!!l.shiftKey==!!m.shiftKey&&!!l.altKey==!!m.altKey){m.preventDefault!==false&&l.preventDefault(),(!u.condition||u.condition(e))&&u.action(e);return}}}};return t.addEventListener("keydown",r),()=>t.removeEventListener("keydown",r)}function z(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 to=z("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"})),oo=z("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"})]})),no=z("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"})]})),ro=z("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"})]})),io=z("CodeIcon",jsxs(Fragment,{children:[jsx("path",{d:"m16 18 6-6-6-6"}),jsx("path",{d:"m8 6-6 6 6 6"})]})),un=z("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"})]})),Ft=z("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"})]})),pt=z("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"})]})),lo=z("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"})]})),ao=z("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"})]})),so=z("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"})]})),cn=z("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"})]})),dn=z("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"})]})),Io=z("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"})]})),Mt=z("AlignLeftIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M15 12H3"}),jsx("path",{d:"M17 19H3"})]})),bt=z("AlignCenterIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M17 12H7"}),jsx("path",{d:"M19 19H5"})]})),mn=z("AlignJustifyIcon",jsxs(Fragment,{children:[jsx("path",{d:"M3 5h18"}),jsx("path",{d:"M3 12h18"}),jsx("path",{d:"M3 19h18"})]})),Ot=z("AlignRightIcon",jsxs(Fragment,{children:[jsx("path",{d:"M21 5H3"}),jsx("path",{d:"M21 12H9"}),jsx("path",{d:"M21 19H7"})]})),Fo=z("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"})]})),gn=z("MinusIcon",jsx("path",{d:"M5 12h14"})),hn=z("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"})]})),fn=z("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"})]})),ss=z("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"})]})),pn=z("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"})]})),us=z("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"})]})),uo=z("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"})),bn=z("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"})]})),yn=z("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"})]})),co=z("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=z("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"})]})),Cn=z("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"})]})),En=z("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"})]})),kn=z("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"})),Ln=z("SearchIcon",jsxs(Fragment,{children:[jsx("path",{d:"m21 21-4.34-4.34"}),jsx("circle",{cx:"11",cy:"11",r:"8"})]})),Mo=z("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"})]})),wn=z("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"})]})),Tn=z("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"})]})),Nt=z("ChevronDownIcon",jsx("path",{d:"m6 9 6 6 6-6"})),xn=z("CloseIcon",jsxs(Fragment,{children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]}));function Fn({isOpen:e,onClose:t,commands:o}){let[n,i]=useState(""),[r,l]=useState(0),s=useRef(null),u=useRef(null),m=o.filter(y=>`${y.label} ${y.description||""} ${y.keywords?.join(" ")||""}`.toLowerCase().includes(n.toLowerCase())),C=m.reduce((y,h)=>{let f=h.category||"Other";return y[f]||(y[f]=[]),y[f].push(h),y},{}),v=m;return useEffect(()=>{l(0);},[n]),useEffect(()=>{e&&s.current&&(s.current.focus({preventScroll:true}),i(""),l(0));},[e]),useEffect(()=>{if(!e)return;let y=u.current;if(!y)return;y.querySelector(".luthor-command-palette-item.selected")?.scrollIntoView({block:"nearest"});},[e,r,n]),useEffect(()=>{let y=h=>{if(e)switch(h.key){case "Escape":h.preventDefault(),h.stopPropagation(),t();break;case "ArrowDown":h.preventDefault(),h.stopPropagation(),l(f=>Math.min(f+1,v.length-1));break;case "ArrowUp":h.preventDefault(),h.stopPropagation(),l(f=>Math.max(f-1,0));break;case "Enter":h.preventDefault(),h.stopPropagation(),v[r]&&(v[r].action(),t());break}};return document.addEventListener("keydown",y,true),()=>document.removeEventListener("keydown",y,true)},[e,r,v,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:y=>y.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(Ln,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:s,type:"text",placeholder:"Type a command or search...",value:n,onChange:y=>i(y.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(C).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(C).map(([y,h])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:y}),h.map(f=>{let d=v.indexOf(f);return jsxs("div",{className:`luthor-command-palette-item ${d===r?"selected":""}`,onClick:()=>{f.action(),t();},onMouseEnter:()=>l(d),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)})]},y))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(uo,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var ei={"--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 ti(e){return e?e.closest(".luthor-editor-wrapper"):null}function oi(e){return e?ti(e)??e:null}function ni(e){if(typeof window>"u"||!e)return {};let t=window.getComputedStyle(e),o={};for(let[n,i]of Object.entries(ei)){let r=t.getPropertyValue(n).trim()||i;o[n]=r;}return o}function Ke(e){return ni(oi(e))}function Rt(){if(typeof window>"u")return {};let t=window.getSelection()?.anchorNode;if(!t)return {};let o=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;return Ke(o)}function yt(e){return e?e.closest(".luthor-editor-wrapper")??null:null}function Mn(e,t,o){return e<t?t:e>o?o:e}function ri(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 ii(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,m=o.left+n,C=Math.max(m,o.right-t-n);if(r){let v=u<m||u>C,y=s>=m&&s<=C;v&&y&&(u=s);}return Mn(u,m,C)}function li(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,m=s,C=o.top+i,v=Math.max(C,o.bottom-t-i);if(l){let y=m<C||m>v,h=u>=C&&u<=v;y&&h&&(m=u);}return Mn(m,C,v)}function Ce({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 m=ri(o),C=Math.max(0,m.width-i*2),v=Math.max(0,m.height-i*2),y=Math.max(0,Math.min(t.width,C)),h=Math.max(0,Math.min(t.height,v)),f=ii(e,y,m,i,r,s),d=li(e,h,m,n,i,l,u);if(o){let E=o.getBoundingClientRect();return {position:"absolute",left:f-E.left+o.scrollLeft,top:d-E.top+o.scrollTop,maxWidth:C>0?C:void 0,maxHeight:v>0?v:void 0}}return {position:"fixed",left:f,top:d,maxWidth:C>0?C:void 0,maxHeight:v>0?v:void 0}}function go(e,t){return {x:e,y:t,width:1,height:1,left:e,right:e+1,top:t,bottom:t+1,toJSON:()=>({})}}function Nn({isOpen:e,query:t,position:o,portalContainer:n,suggestions:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[C,v]=useState(void 0);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let f=d=>{let E=i.length>0;switch(d.key){case "Escape":d.preventDefault(),d.stopPropagation(),r();break;case "ArrowDown":if(!E)return;d.preventDefault(),d.stopPropagation(),u(T=>Math.min(T+1,Math.max(i.length-1,0)));break;case "ArrowUp":if(!E)return;d.preventDefault(),d.stopPropagation(),u(T=>Math.max(T-1,0));break;case "Enter":case "Tab":if(!E||!i[s])return;d.preventDefault(),d.stopPropagation(),l(i[s].emoji);break}};return document.addEventListener("keydown",f,true),()=>document.removeEventListener("keydown",f,true)},[e,r,l,s,i]);let y=useCallback(f=>{if(!o)return;let d=m.current?.getBoundingClientRect(),E=Ce({anchorRect:go(o.x,o.y),overlay:{width:d?.width??320,height:d?.height??280},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});v({...E,visibility:f?"visible":"hidden",...Rt()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;y(false);let f=window.requestAnimationFrame(()=>y(true));return ()=>window.cancelAnimationFrame(f)},[e,o,y]),useEffect(()=>{if(!e||!o)return;let f=()=>y(true);return window.addEventListener("resize",f),window.addEventListener("scroll",f,true),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,true);}},[e,o,y]),!e||!o)return null;let h=jsxs("div",{className:"luthor-emoji-menu",ref:m,style:C,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,d)=>{let E=d===s,T=f.shortcodes[0]?`:${f.shortcodes[0]}:`:"";return jsxs("button",{type:"button",className:`luthor-emoji-menu-item ${E?"selected":""}`,onMouseEnter:()=>u(d),onMouseDown:I=>{I.preventDefault(),I.stopPropagation();},onClick:I=>{I.preventDefault(),I.stopPropagation(),l(f.emoji);},children:[jsx("span",{className:"luthor-emoji-menu-item-symbol","aria-hidden":"true",children:f.emoji}),jsxs("span",{className:"luthor-emoji-menu-item-content",children:[jsx("span",{className:"luthor-emoji-menu-item-title",children:f.label}),T&&jsx("span",{className:"luthor-emoji-menu-item-shortcode",children:T})]})]},`${f.emoji}-${f.label}`)})})]});return typeof document>"u"?h:createPortal(h,n??document.body)}function An({isOpen:e,query:t,position:o,portalContainer:n,commands:i,onClose:r,onExecute:l}){let[s,u]=useState(0),m=useRef(null),[C,v]=useState(void 0),y=useMemo(()=>{let E=t.trim().toLowerCase();return E?i.filter(T=>`${T.label} ${T.description||""} ${T.keywords?.join(" ")||""}`.toLowerCase().includes(E)):i},[i,t]),h=useMemo(()=>y.reduce((E,T)=>{let I=T.category||"Other";return E[I]||(E[I]=[]),E[I].push(T),E},{}),[y]);useEffect(()=>{u(0);},[t,e]),useEffect(()=>{if(!e)return;let E=T=>{let I=y.length>0;switch(T.key){case "Escape":T.preventDefault(),T.stopPropagation(),r();break;case "ArrowDown":if(!I)return;T.preventDefault(),T.stopPropagation(),u(X=>Math.min(X+1,Math.max(y.length-1,0)));break;case "ArrowUp":if(!I)return;T.preventDefault(),T.stopPropagation(),u(X=>Math.max(X-1,0));break;case "Enter":case "Tab":if(!I||!y[s])return;T.preventDefault(),T.stopPropagation(),l(y[s].id);break}};return document.addEventListener("keydown",E,true),()=>document.removeEventListener("keydown",E,true)},[y,e,r,l,s]);let f=useCallback(E=>{if(!o)return;let T=m.current?.getBoundingClientRect(),I=Ce({anchorRect:go(o.x,o.y),overlay:{width:T?.width??420,height:T?.height??360},portalContainer:n??null,gap:6,margin:12,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});v({...I,visibility:E?"visible":"hidden",...Rt()});},[n,o]);if(useLayoutEffect(()=>{if(!e||!o)return;f(false);let E=window.requestAnimationFrame(()=>f(true));return ()=>window.cancelAnimationFrame(E)},[e,o,f]),useEffect(()=>{if(!e||!o)return;let E=()=>f(true);return window.addEventListener("resize",E),window.addEventListener("scroll",E,true),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,true);}},[e,o,f]),!e||!o)return null;let d=jsxs("div",{className:"luthor-slash-menu",ref:m,style:C,onPointerDown:E=>{E.stopPropagation();},onMouseDown:E=>{E.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:y.length===0?jsx("div",{className:"luthor-slash-menu-empty",children:"No matching commands"}):Object.entries(h).map(([E,T])=>jsxs("div",{className:"luthor-slash-menu-group",children:[jsx("div",{className:"luthor-slash-menu-group-title",children:E}),T.map(I=>{let X=y.indexOf(I);return jsxs("button",{type:"button",className:`luthor-slash-menu-item ${X===s?"selected":""}`,onMouseEnter:()=>u(X),onMouseDown:A=>{A.preventDefault(),A.stopPropagation();},onClick:A=>{A.preventDefault(),A.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)})]},E))})]});return typeof document>"u"?d:createPortal(d,n??document.body)}function R({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 Ho({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 jt({value:e,onValueChange:t,options:o,placeholder:n="Select..."}){let[i,r]=useState(false),[l,s]=useState(void 0),[u,m]=useState(null),C=useRef(null),v=useRef(null);useEffect(()=>{if(!i)return;let h=()=>{let d=C.current?.querySelector(".luthor-select-trigger");if(!d)return;let E=d.getBoundingClientRect(),T=v.current?.getBoundingClientRect(),I=Math.max(T?.width??0,v.current?.scrollWidth??0),X=yt(d);m(X);let D=Math.max(E.width,I),A=T?.height??220,re=Ce({anchorRect:E,overlay:{width:D,height:A},portalContainer:X,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});s({...re,width:D,...Ke(d)});};h();let f=()=>h();return window.addEventListener("resize",f),window.addEventListener("scroll",f,true),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,true),m(null);}},[i]),useLayoutEffect(()=>{if(!i)return;let h=C.current?.querySelector(".luthor-select-trigger");if(!h)return;let f=h.getBoundingClientRect(),d=yt(h);m(d);let E=Ce({anchorRect:f,overlay:{width:f.width,height:220},portalContainer:d,gap:4,margin:8});s({...E,width:f.width,...Ke(h)});let T=window.requestAnimationFrame(()=>{let I=v.current?.getBoundingClientRect(),X=Math.max(I?.width??0,v.current?.scrollWidth??0),D=Math.max(f.width,X),A=Ce({anchorRect:f,overlay:{width:D,height:I?.height??220},portalContainer:d,gap:4,margin:8});s({...A,width:D,...Ke(h)});});return ()=>window.cancelAnimationFrame(T)},[i]),useEffect(()=>{function h(f){let d=f.target;C.current?.contains(d)||v.current?.contains(d)||r(false);}return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);let y=o.find(h=>h.value===e);return jsxs("div",{className:"luthor-select",ref:C,children:[jsxs("button",{className:`luthor-select-trigger ${i?"open":""}`,onClick:()=>r(!i),type:"button",children:[jsx("span",{children:y?.label||n}),jsx(Nt,{size:14})]}),i&&typeof document<"u"&&createPortal(jsx("div",{ref:v,className:"luthor-select-dropdown",style:l,children:o.map(h=>jsx("button",{className:`luthor-select-option ${e===h.value?"selected":""}`,onClick:()=>{t(h.value),r(false);},type:"button",children:h.label},h.value))}),u??document.body)]})}function st({trigger:e,children:t,isOpen:o,onOpenChange:n}){let i=useRef(null),r=useRef(null),l=useRef(null),[s,u]=useState(void 0),[m,C]=useState(null);return useEffect(()=>{if(!o)return;let v=()=>{let h=r.current;if(!h)return;let f=h.getBoundingClientRect(),d=l.current?.getBoundingClientRect(),E=yt(h);C(E);let T=Ce({anchorRect:f,overlay:{width:d?.width??220,height:d?.height??200},portalContainer:E,gap:4,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});u({...T,...Ke(h)});},y=()=>v();return window.addEventListener("resize",y),window.addEventListener("scroll",y,true),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",y,true),C(null);}},[o]),useLayoutEffect(()=>{if(!o)return;let v=r.current;if(!v)return;let y=v.getBoundingClientRect(),h=yt(v);C(h);let f=Ce({anchorRect:y,overlay:{width:220,height:200},portalContainer:h,gap:4,margin:8});u({...f,...Ke(v)});let d=window.requestAnimationFrame(()=>{let E=l.current?.getBoundingClientRect(),T=Ce({anchorRect:y,overlay:{width:E?.width??220,height:E?.height??200},portalContainer:h,gap:4,margin:8});u({...T,...Ke(v)});});return ()=>window.cancelAnimationFrame(d)},[o]),useEffect(()=>{function v(y){let h=y.target;i.current?.contains(h)||l.current?.contains(h)||n(false);}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[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}),m??document.body)]})}function Bn({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(xn,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:n})]})}):null}function Dn({isVisible:e,selectionRect:t,commands:o,activeStates:n,editorTheme:i="light",hide:r,isFeatureEnabled:l=()=>true}){let u=useRef(null),[m,C]=useState(""),[v,y]=useState(""),[h,f]=useState(""),[d,E]=useState(""),[T,I]=useState(""),[X,D]=useState(""),[A,re]=useState(null),[le,L]=useState(null),[se,S]=useState(null),F=!!n.isIframeEmbedSelected,x=!!n.isYouTubeEmbedSelected,N=l("iframeEmbed"),P=l("youTubeEmbed"),Z=l("image"),ue=N&&F||P&&x;if(useEffect(()=>{if(!e)return;let H=j=>{let ce=j.target;ce&&(u.current?.contains(ce)||r?.());};return document.addEventListener("mousedown",H,true),document.addEventListener("touchstart",H,true),()=>{document.removeEventListener("mousedown",H,true),document.removeEventListener("touchstart",H,true);}},[e,r]),useEffect(()=>{if(!e||!F)return;let H=false;return typeof o.getIframeEmbedCaption=="function"&&o.getIframeEmbedCaption().then(j=>{H||y(j??"");}),typeof o.getIframeEmbedUrl=="function"&&o.getIframeEmbedUrl().then(j=>{H||C(j??"");}),re(null),()=>{H=true;}},[o,F,e]),useEffect(()=>{if(!e||!n.imageSelected)return;let H=false;return typeof o.getImageCaption=="function"&&o.getImageCaption().then(j=>{H||f(j??"");}),()=>{H=true;}},[n.imageSelected,o,e]),useEffect(()=>{if(!e||!x)return;let H=false;return typeof o.getYouTubeEmbedCaption=="function"&&o.getYouTubeEmbedCaption().then(j=>{H||E(j??"");}),typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(j=>{H||I(j??"");}),L(null),()=>{H=true;}},[o,e,x]),useEffect(()=>{if(!e||!n.isLink)return;let H=false;return typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(j=>{!H&&j&&D(j.url??"");}),S(null),()=>{H=true;}},[n.isLink,o,e]),!e||!t)return null;let O={...Rt(),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(ue){let H=G=>{if(F){o.setIframeEmbedAlignment?.(G);return}x&&o.setYouTubeEmbedAlignment?.(G);},j=F?n.isIframeEmbedAlignedLeft:n.isYouTubeEmbedAlignedLeft,ce=F?n.isIframeEmbedAlignedCenter:n.isYouTubeEmbedAlignedCenter,Xe=F?n.isIframeEmbedAlignedRight:n.isYouTubeEmbedAlignedRight,ee=F?typeof o.setIframeEmbedCaption=="function":typeof o.setYouTubeEmbedCaption=="function",Pe=F?typeof o.updateIframeEmbedUrl=="function":typeof o.updateYouTubeEmbedUrl=="function",we=F?v:d,mt=F?y:E,$e=F?m:T,ze=F?A:le,Ye=()=>{if(ee){if(F){o.setIframeEmbedCaption?.(v);return}o.setYouTubeEmbedCaption?.(d);}},Te=G=>{F?re(G):L(G);},Be=G=>{F?C(G):I(G);},be=()=>{if(!Pe)return;if(!(F?o.updateIframeEmbedUrl?.(m)??false:o.updateYouTubeEmbedUrl?.(T)??false)){Te(F?"Enter a valid http(s) URL":"Enter a valid YouTube URL"),F&&typeof o.getIframeEmbedUrl=="function"?o.getIframeEmbedUrl().then(xe=>C(xe??"")):!F&&typeof o.getYouTubeEmbedUrl=="function"&&o.getYouTubeEmbedUrl().then(xe=>I(xe??""));return}Te(null);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:O,children:[jsx(R,{onClick:()=>H("left"),active:j,title:"Align Left",children:jsx(Mt,{size:14})}),jsx(R,{onClick:()=>H("center"),active:ce,title:"Align Center",children:jsx(bt,{size:14})}),jsx(R,{onClick:()=>H("right"),active:Xe,title:"Align Right",children:jsx(Ot,{size:14})}),ee||Pe?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-fields",children:[Pe?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:$e,className:`luthor-floating-toolbar-input${ze?" is-error":""}`,placeholder:F?"https://example.com/embed":"https://youtube.com/watch?v=...","aria-label":F?"Iframe URL":"YouTube URL","aria-invalid":ze?true:void 0,onChange:G=>{Be(G.target.value),ze&&Te(null);},onBlur:be,onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),be());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:be,children:"Update URL"})]}):null,ee?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:we,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":F?"Iframe caption":"YouTube caption",onChange:G=>mt(G.target.value),onBlur:Ye,onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),Ye());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:Ye,children:"Update Caption"})]}):null]})]}):null]})}if(Z&&n.imageSelected){let H=typeof o.setImageCaption=="function",j=()=>{H&&o.setImageCaption(h);};return jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:O,children:[jsx(R,{onClick:()=>o.setImageAlignment("left"),active:n.isImageAlignedLeft,title:"Align Left",children:jsx(Mt,{size:14})}),jsx(R,{onClick:()=>o.setImageAlignment("center"),active:n.isImageAlignedCenter,title:"Align Center",children:jsx(bt,{size:14})}),jsx(R,{onClick:()=>o.setImageAlignment("right"),active:n.isImageAlignedRight,title:"Align Right",children:jsx(Ot,{size:14})}),H?jsxs(Fragment,{children:[jsx("div",{className:"luthor-floating-toolbar-separator"}),jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"text",value:h,className:"luthor-floating-toolbar-input",placeholder:"Add caption","aria-label":"Image caption",onChange:ce=>f(ce.target.value),onBlur:j,onKeyDown:ce=>{ce.key==="Enter"&&(ce.preventDefault(),j());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action",onClick:j,children:"Update Caption"})]})]}):null]})}let fe=l("bold"),ae=l("italic"),Q=l("underline"),Fe=l("strikethrough"),he=l("codeFormat"),Ae=!!(n.unorderedList||n.orderedList||n.checkList),ke=l("blockFormat")&&!Ae,Ve=l("link"),_e=l("list")&&!Ae,pe=fe||ae||Q||Fe,Le=he||ke||Ve,ye=_e,je=!!n.isLink&&typeof o.updateLink=="function"&&typeof o.removeLink=="function",qe=()=>{if(!je)return;if(!(o.updateLink?.(X)??false)){S("Enter a valid URL"),typeof o.getCurrentLink=="function"&&o.getCurrentLink().then(j=>{D(j?.url??"");});return}S(null);};return !pe&&!Le&&!ye?null:jsxs("div",{className:"luthor-floating-toolbar","data-theme":i,ref:u,style:O,children:[pe?jsxs(Fragment,{children:[fe?jsx(R,{onClick:()=>o.toggleBold(),active:n.bold,title:"Bold",children:jsx(to,{size:14})}):null,ae?jsx(R,{onClick:()=>o.toggleItalic(),active:n.italic,title:"Italic",children:jsx(oo,{size:14})}):null,Q?jsx(R,{onClick:()=>o.toggleUnderline(),active:n.underline,title:"Underline",children:jsx(no,{size:14})}):null,Fe?jsx(R,{onClick:()=>o.toggleStrikethrough(),active:n.strikethrough,title:"Strikethrough",children:jsx(ro,{size:14})}):null]}):null,pe&&Le?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,Le?jsxs(Fragment,{children:[he?jsx(R,{onClick:()=>o.formatText("code"),active:n.code,title:"Inline Code",children:jsx(io,{size:14})}):null,ke?jsx(R,{onClick:()=>o.toggleQuote(),active:n.isQuote,title:"Quote",children:jsx(co,{size:14})}):null,Ve?jsxs(Fragment,{children:[jsx(R,{onClick:()=>n.isLink?o.removeLink():o.insertLink(),active:n.isLink,title:n.isLink?"Remove Link":"Insert Link",children:n.isLink?jsx(pt,{size:14}):jsx(Ft,{size:14})}),je?jsxs("div",{className:"luthor-floating-toolbar-field-row",children:[jsx("input",{type:"url",value:X,className:`luthor-floating-toolbar-input${se?" is-error":""}`,placeholder:"https://example.com","aria-label":"Link URL","aria-invalid":se?true:void 0,onChange:H=>{D(H.target.value),se&&S(null);},onBlur:qe,onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),qe());}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-floating-toolbar-action luthor-floating-toolbar-action-primary",onClick:qe,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(pt,{size:13})})]}):null]}):null]}):null,(pe||Le)&&ye?jsx("div",{className:"luthor-floating-toolbar-separator"}):null,ye?jsxs(Fragment,{children:[jsx(R,{onClick:()=>o.toggleUnorderedList(),active:n.unorderedList,title:"Bullet List",children:jsx(lo,{size:14})}),jsx(R,{onClick:()=>o.toggleOrderedList(),active:n.orderedList,title:"Numbered List",children:jsx(so,{size:14})}),jsx(R,{onClick:()=>o.toggleCheckList(),active:n.checkList,title:"Checklist",children:jsx(ao,{size:14})})]}):null]})}var Ge={commands:{},activeStates:{},editorTheme:"light",isFeatureEnabled:()=>true};function Ro(e,t,o,n=()=>true){Ge.commands=e,Ge.activeStates=t,Ge.editorTheme=o,Ge.isFeatureEnabled=n;}function Un(){let e=Dn,t=new FloatingToolbarExtension;return t.config={...t.config,render:o=>createElement(e,{...o,commands:Ge.commands,activeStates:Ge.activeStates,editorTheme:Ge.editorTheme,isFeatureEnabled:Ge.isFeatureEnabled}),getCommands:()=>Ge.commands,getActiveStates:()=>Ge.activeStates},t}var Li=120,wi=58;function Ti(e,t=wi){return e.length<=t?e:`${e.slice(0,t-3)}...`}function Kn(){let e=window.getSelection();return !e||e.rangeCount===0?false:!e.getRangeAt(0).collapsed}function Vn(e,t){if(!(e instanceof Element))return null;let o=e.closest("a");return !(o instanceof HTMLAnchorElement)||!t.contains(o)?null:o}function qn({editor:e,commands:t,editorTheme:o="light",disabled:n=false}){let i=useRef(null),r=useRef(null),l=useRef(null),s=useRef(null),[u,m]=useState(null),[C,v]=useState(false),[y,h]=useState(""),[f,d]=useState(null),[E,T]=useState(null),[I,X]=useState(null),D=useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null);},[]),A=useCallback(()=>{D(),m(null),v(false),h(""),d(null),T(null);},[D]),re=useCallback(()=>{D(),s.current=window.setTimeout(()=>{A();},Li);},[D,A]),le=useCallback((x,N)=>{let P=x.getBoundingClientRect(),Z=i.current?.getBoundingClientRect(),ue=Ce({anchorRect:P,overlay:{width:Z?.width??340,height:Z?.height??48},portalContainer:N,gap:8,margin:10,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});T({top:typeof ue.top=="number"?ue.top:0,left:typeof ue.left=="number"?ue.left:0});},[]),L=useCallback((x,N)=>{if(typeof t.getLinkByKey!="function"){m(P=>!P||P.nodeKey!==x?P:{...P,url:N});return}t.getLinkByKey(x).then(P=>{if(!P){A();return}m(Z=>!Z||Z.nodeKey!==x?Z:{...Z,url:P.url});});},[t,A]);useEffect(()=>{if(!e||n||typeof window>"u"){A(),X(null),r.current=null;return}let x=e.getRootElement();if(!x){A(),X(null),r.current=null;return}let N=x.closest(".luthor-editor-wrapper")??null;X(N),r.current=N;let P=ae=>{let Q=Vn(ae.target,x);if(!Q)return;if(Kn()){A();return}D();let Fe=resolveLinkNodeKeyFromAnchor(e,Q);if(!Fe)return;let he=Q.getAttribute("href")??Q.href;m({nodeKey:Fe,url:he,anchorEl:Q}),le(Q,r.current),d(null),C||h(he),L(Fe,he);},Z=ae=>{if(!u)return;let Q=ae.relatedTarget;Q&&i.current?.contains(Q)||Vn(Q,x)||re();},ue=()=>{Kn()&&A();},O=()=>{m(ae=>{if(!ae)return ae;let Q=ae.anchorEl.isConnected&&x.contains(ae.anchorEl)?ae.anchorEl:x.querySelector(`a[data-lexical-node-key="${ae.nodeKey}"]`);return Q?(le(Q,r.current),{...ae,anchorEl:Q,url:Q.getAttribute("href")??Q.href}):(A(),null)});},fe=()=>{l.current===null&&(l.current=window.requestAnimationFrame(()=>{l.current=null,O();}));};return x.addEventListener("mouseover",P),x.addEventListener("mouseout",Z),document.addEventListener("selectionchange",ue),window.addEventListener("scroll",fe,true),window.addEventListener("resize",fe),()=>{x.removeEventListener("mouseover",P),x.removeEventListener("mouseout",Z),document.removeEventListener("selectionchange",ue),window.removeEventListener("scroll",fe,true),window.removeEventListener("resize",fe),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),D();}},[t,n,e,u,C,A,re,L,le,D]),useLayoutEffect(()=>{u&&le(u.anchorEl,r.current);},[u,C,le]);let se=useMemo(()=>{if(!(!u||!E))return {...Ke(u.anchorEl),position:I?"absolute":"fixed",top:E.top,left:E.left,zIndex:"var(--luthor-z-menu, 460)"}},[u,E,I]);if(!u||!E||typeof document>"u")return null;let S=()=>{(t.removeLinkByKey?.(u.nodeKey)??false)&&A();},F=()=>{let x=y.trim();if(!(t.updateLinkByKey?.(u.nodeKey,x)??false)){d("Enter a valid URL"),L(u.nodeKey,u.url);return}m(P=>!P||P.nodeKey!==u.nodeKey?P:{...P,url:x}),d(null),v(false),queueMicrotask(()=>{L(u.nodeKey,x);});};return createPortal(jsx("div",{ref:i,className:"luthor-floating-toolbar luthor-link-hover-bubble","data-theme":o,style:se,onMouseEnter:D,onMouseLeave:re,children:C?jsxs(Fragment,{children:[jsx("input",{type:"url",value:y,className:`luthor-link-hover-bubble-input${f?" is-error":""}`,placeholder:"https://example.com","aria-label":"Edit link URL","aria-invalid":f?true:void 0,onChange:x=>{h(x.target.value),f&&d(null);},onKeyDown:x=>{if(x.key==="Enter"){x.preventDefault(),F();return}x.key==="Escape"&&(x.preventDefault(),v(false),h(u.url),d(null));}}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-primary",onClick:F,children:"Update"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{v(false),h(u.url),d(null);},children:"Cancel"})]}):jsxs(Fragment,{children:[jsx("span",{className:"luthor-link-hover-bubble-url",title:u.url,children:Ti(u.url)}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button",onClick:()=>{h(u.url),v(true),d(null);},children:"Edit"}),jsx("button",{type:"button",className:"luthor-toolbar-button luthor-link-hover-bubble-button luthor-link-hover-bubble-button-danger",onClick:S,"aria-label":"Unlink",children:jsx(pt,{size:13})})]})}),I??document.body)}var Ii=400;function $n({mode:e,onModeChange:t,labels:o,availableModes:n,isConverting:i}){let r=d=>d==="visual"?"visual-editor":d,l=(n??[]).includes("visual-editor")?"visual-editor":"visual",s=d=>d==="visual-editor"?l:d,u=["visual-only","visual-editor","json","markdown","html"],m=n??["visual-only","visual-editor","json","markdown","html"],C=new Set(m.map(r)),v=u.filter(d=>C.has(d)),y=r(e),h=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:v.map(d=>jsxs("button",{className:`luthor-mode-tab ${y===d?"active":""}`,onClick:()=>t(s(d)),children:[f[d],h===d&&jsx("span",{className:"luthor-tab-converting-spinner"})]},d))})}function fo({value:e,onChange:t,placeholder:o,className:n,wrap:i}){let r=useRef(null);return useLayoutEffect(()=>{let l=r.current;if(!l)return;l.style.height="auto";let s=Math.max(0,l.offsetHeight-l.clientHeight),u=Math.max(l.scrollHeight+s+1,Ii);l.style.height=`${u}px`;},[e]),jsx("textarea",{ref:r,className:`luthor-source-view${n?` ${n}`:""}`,value:e,onChange:l=>t(l.target.value),placeholder:o,spellCheck:false,wrap:i??"off"})}function Yn(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 bo(e){return e.replace(/\r\n?/g,`
2
- `)}function Mi(e){return e.replace(/&#(9|10|13|32|160);/g,(t,o)=>{switch(o){case "9":return " ";case "10":return `
3
- `;case "13":return "\r";case "32":return " ";case "160":return " ";default:return t}})}function Oi(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 Ni(e){return ["***","**","~~","*"].reduce((o,n)=>Oi(o,n),e)}var Hi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ri=new Set(["pre","script","style","textarea"]),Ai=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"]),Pi=1,yo=3,zi=8;function Jn(e){return e.nodeType===Pi}function Po(e){return e.nodeType===yo&&(e.textContent??"").trim().length>0}function po(e){return e.tagName.toLowerCase()}function Gn(e){return Array.from(e.childNodes).filter(t=>t.nodeType!==yo?true:Po(t))}function Bi(e){let t=e.outerHTML,o=t.indexOf(">");return o===-1?`<${po(e)}>`:t.slice(0,o+1)}function Di(e){let t=po(e);if(Hi.has(t)||Ri.has(t))return false;let o=Gn(e);if(o.length===0||o.some(Po))return false;let n=o.filter(Jn);return n.length===0?false:n.every(i=>Ai.has(po(i)))}function Wn(e,t){let o=" ".repeat(Math.max(t,0));if(e.nodeType===zi)return `${o}<!--${e.data}-->`;if(e.nodeType===yo){let r=bo(e.textContent??"");return r.trim()?`${o}${r.trim()}`:null}if(!Jn(e))return null;if(!Di(e))return `${o}${e.outerHTML}`;let n=po(e),i=[`${o}${Bi(e)}`];for(let r of Gn(e)){let l=Wn(r,t+1);l&&i.push(l);}return i.push(`${o}</${n}>`),i.join(`
4
- `)}function Ui(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!==yo?true:Po(i)).map(i=>Wn(i,0)).filter(i=>typeof i=="string"&&i.length>0);return n.length===0?t.body.innerHTML.trim()||e:n.join(`
5
- `)}function Xn(e){let t=bo(e).trim();if(!t)return "";try{let o=JSON.parse(t);return JSON.stringify(o,null,2)}catch{return t}}function Qn(e){return Ni(Mi(bo(e))).trim()}function Zn(e){let t=bo(e).trim();if(!t)return "";try{return Ui(t)}catch{return t}}var Bo=6,ji=["#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"],qi=[{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"}],$i=[{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 Yi(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 Ji({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 Gi({pattern:e}){let t=Yi(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,m=24+s*12,C=57-s*10;return jsxs("g",{children:[jsx("g",{transform:`translate(${u-16}, 0)`,children:jsx(Ji,{type:i[l]??t[0],cy:r})}),jsx("rect",{x:m,y:r-2.5,width:C,height:"5",rx:"2.5",className:"luthor-unordered-variant-line"})]},`${e}-row-${l}`)})]})}function tr({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 Wi({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,m=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:m,height:"5",rx:"2.5",className:"luthor-ordered-variant-line"})]},`${e}-ordered-row-${r}`)})]})}function Co(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function Xi(e,t){let o=Co(t);for(let n of e)if(Co(n.value)===o)return n.color;return null}function Qi(e,t,o){if(!e||e==="default")return o;let n=Xi(t,e);return n||e}function Zi(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 Do="Inherited",vo="16px",Uo="1.5";function Ee(e){return e.trim().toLowerCase().replace(/\s+/g,"")}function or(e){let t=e.split(",")[0]??"";return Ee(t.replace(/["']/g,""))}function Eo(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 Ct(){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 zo(){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 nr(e){return (e.split(",")[0]?.trim()??"").replace(/^['"]|['"]$/g,"").trim()}function el(e,t){let o=Ee(e);if(o&&o!=="inherit"){let i=nr(e);if(i)return i}return nr(t?.fontFamily??"")||Do}function tl(e,t){let o=Ee(e);return o&&o!=="inherit"?e.trim():(t?.fontSize??"").trim()||vo}function ol(e,t){let o=Ee(e);return o&&o!=="normal"?e.trim():(t?.lineHeight??"").trim()||Uo}function nl(e,t){if(!e)return null;let o=or(e);return o?t.find(i=>Ee(i.value)===o?true:or(i.fontFamily)===o)?.value??null:null}function rl(e,t){if(!e)return null;let o=Ee(e),n=t.find(l=>Ee(String(l.value))===o?true:Ee(String(l.fontSize))===o);if(n)return String(n.value);let i=Eo(e);if(i==null)return null;let r=null;for(let l of t){let s=Eo(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 il(e,t,o){if(!e)return null;let n=Ee(e),i=o.find(m=>Ee(m.value)===n?true:Ee(m.lineHeight)===n);if(i)return i.value;let r=t?Eo(t):null,l=Eo(e),s=null;if(l!=null&&r!=null&&r>0)s=l/r;else {let m=Number(e);Number.isFinite(m)&&(s=m);}if(s==null)return null;let u=null;for(let m of o){let C=Number(m.lineHeight);if(!Number.isFinite(C))continue;let v=Math.abs(C-s);(!u||v<u.distance)&&(u={value:m.value,distance:v});}return u?.value??null}function rr({title:e,value:t,options:o,recentColors:n,active:i,fallbackColor:r,highlight:l,onChange:s,onClear:u,onAddRecent:m}){let C=useRef(null),v=useRef(null),y=useRef(null),h=useRef(null),f=useRef(null),[d,E]=useState(false),[T,I]=useState(void 0),[X,D]=useState(null),A=Qi(t,o,r),re=useMemo(()=>ji,[]),le=useMemo(()=>{let S=[...n].slice(0,Bo);for(;S.length<Bo;)S.push("");return S},[n]);useEffect(()=>()=>{h.current&&window.cancelAnimationFrame(h.current);},[]);let L=useCallback(S=>{f.current=S,!h.current&&(h.current=window.requestAnimationFrame(()=>{h.current=null,f.current&&(s(f.current),f.current=null);}));},[s]),se=useCallback(S=>{let F=C.current;if(!F)return;let x=F.getBoundingClientRect(),N=v.current?.getBoundingClientRect(),P=yt(F);D(P);let Z=Ce({anchorRect:x,overlay:{width:N?.width??248,height:N?.height??340},portalContainer:P,gap:6,margin:8,preferredX:"start",preferredY:"bottom",flipX:true,flipY:true});I({...Z,visibility:S?"visible":"hidden",...Ke(F)});},[]);return useLayoutEffect(()=>{if(!d)return;se(false);let S=window.requestAnimationFrame(()=>{se(true);});return ()=>{window.cancelAnimationFrame(S);}},[d,se]),useEffect(()=>{if(!d)return;let S=N=>{let P=N.target;C.current?.contains(P)||v.current?.contains(P)||E(false);},F=N=>{N.key==="Escape"&&E(false);},x=()=>se(true);return window.addEventListener("resize",x),window.addEventListener("scroll",x,true),document.addEventListener("mousedown",S),document.addEventListener("keydown",F),()=>{window.removeEventListener("resize",x),window.removeEventListener("scroll",x,true),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",F),D(null);}},[d,se]),jsxs(Fragment,{children:[jsxs("button",{ref:C,type:"button",className:`luthor-toolbar-button luthor-color-button${i?" active":""}${l?" is-highlight":""}`,title:e,"aria-label":e,onClick:()=>E(S=>!S),children:[l?jsx(pn,{size:15,className:"luthor-color-button-highlighter"}):jsx("span",{className:"luthor-color-button-letter",children:"A"}),jsx("span",{className:"luthor-color-button-indicator",style:{backgroundColor:A}})]}),d&&typeof document<"u"&&createPortal(jsxs("div",{ref:v,className:"luthor-color-picker",style:T,children:[jsx("div",{className:"luthor-color-picker-header",children:jsx("span",{className:"luthor-color-picker-title",children:e})}),jsxs("div",{className:"luthor-color-picker-section",children:[jsx("p",{className:"luthor-color-picker-label",children:"Colors"}),jsx("div",{className:"luthor-color-swatch-grid",children:re.map(S=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:S},"aria-label":`Use color ${S}`,onClick:()=>{s(S),m(S),E(false);}},S))})]}),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((S,F)=>jsx("button",{type:"button",className:"luthor-color-swatch",style:{backgroundColor:S||"transparent"},"aria-label":S?`Use recent color ${S}`:"Empty recent color slot",disabled:!S,onClick:()=>{S&&(s(S),m(S),E(false));}},`${S||"empty"}-${F}`))})]}),jsxs("div",{className:"luthor-color-picker-footer",children:[jsx("button",{type:"button",className:"luthor-color-picker-clear",onClick:()=>{u(),E(false);},children:"Reset to Default"}),jsxs("button",{type:"button",className:"luthor-color-picker-custom",onClick:()=>y.current?.click(),children:[jsx(bn,{size:14}),jsx("span",{children:"Custom Color"})]}),jsx("input",{ref:y,type:"color",className:"luthor-color-picker-native luthor-color-picker-native-hidden",value:Zi(A,r),onInput:S=>{L(S.target.value);},onChange:S=>{let F=S.target.value;s(F),m(F);}})]})]}),X??document.body)]})}function ll(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 al(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 sl(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 ul(e,t,o){return sl(e,t)?o?.[e]!==false:false}function cl(e,t,o){return {sections:e.sections.map(n=>({...n,items:n.items.filter(i=>ul(i,t,o))})).filter(n=>n.items.length>0)}}function ir({commands:e,hasExtension:t,activeStates:o,isDark:n,toggleTheme:i,onCommandPaletteOpen:r,imageUploadHandler:l,classNames:s,toolbarStyleVars:u,layout:m,toolbarVisibility:C,headingOptions:v,paragraphLabel:y}){let{handlers:h,fileInputRef:f,gifInputRef:d}=ll(e,l),E=al(e),T=t("iframeEmbed")||t("youtubeEmbed"),I=o.isIframeEmbedSelected||o.isYouTubeEmbedSelected,[X,D]=useState(false),[A,re]=useState(false),[le,L]=useState(false),[se,S]=useState(false),[F,x]=useState(false),[N,P]=useState(false),[Z,ue]=useState(false),[O,fe]=useState(false),[ae,Q]=useState("default"),[Fe,he]=useState([{value:"default",label:Do}]),[Ae,ke]=useState("default"),[Ve,_e]=useState([{value:"default",label:vo}]),[pe,Le]=useState("default"),[ye,je]=useState([{value:"default",label:Uo}]),[qe,H]=useState("default"),[j,ce]=useState([{value:"default",label:"Default",color:"inherit"}]),[Xe,ee]=useState([]),[Pe,we]=useState("default"),[mt,$e]=useState([{value:"default",label:"Default",color:"transparent"}]),[ze,Ye]=useState([]),[Te,Be]=useState(0),[be,Qe]=useState({rows:3,columns:3,includeHeaders:false}),G=useRef(null),xe=useRef("");useEffect(()=>{if(typeof document>"u")return;let b=()=>{G.current===null&&(G.current=window.requestAnimationFrame(()=>{G.current=null;let p=window.getSelection();if(!p||p.rangeCount===0||!p.getRangeAt(0).collapsed)return;let B=Ct();if(!B)return;let U=`${B.fontFamily}|${B.fontSize}|${B.lineHeight}`;U!==xe.current&&(xe.current=U,Be(q=>q+1));}));};return document.addEventListener("selectionchange",b),()=>{document.removeEventListener("selectionchange",b),G.current!==null&&(cancelAnimationFrame(G.current),G.current=null);}},[]);let nt=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 b=Ct()??zo(),p=e.getFontFamilyOptions().map(U=>({value:U.value,label:Ee(U.value)==="default"?el(U.fontFamily,b):U.label})),B=p.length>0?p:[{value:"default",label:Do}];he(B),Q(U=>B.some(q=>q.value===U)?U:"default");},[e,t]),useEffect(()=>{if(!t("fontFamily")||typeof e.getCurrentFontFamily!="function")return;let b=e.getFontFamilyOptions;if(typeof b!="function")return;let p=false;return e.getCurrentFontFamily().then(B=>{if(p)return;if(B&&B!=="default"){Q(B);return}let U=Ct(),q=nl(U?.fontFamily,b());Q(q??"default");}),()=>{p=true;}},[o,e,t,Te]),useEffect(()=>{if(!t("fontSize")||typeof e.getFontSizeOptions!="function")return;let b=Ct()??zo(),p=e.getFontSizeOptions().map(q=>({value:String(q.value).trim(),label:Ee(String(q.value))==="default"?tl(String(q.fontSize),b):String(q.label).trim()})).filter(q=>q.value.length>0&&q.label.length>0),B=p.some(q=>Ee(q.value)==="default"),U=p.length===0?[{value:"default",label:vo}]:B?p:[{value:"default",label:vo},...p];_e(U),ke(q=>U.some(g=>g.value===q)?q:"default");},[e,t]),useEffect(()=>{if(!t("fontSize")||typeof e.getCurrentFontSize!="function")return;let b=e.getFontSizeOptions;if(typeof b!="function")return;let p=false;return e.getCurrentFontSize().then(B=>{if(p)return;if(B&&B!=="default"){ke(B);return}let U=Ct(),q=rl(U?.fontSize,b());ke(q??"default");}),()=>{p=true;}},[o,e,t,Te]),useEffect(()=>{if(!t("lineHeight")||typeof e.getLineHeightOptions!="function")return;let b=Ct()??zo(),p=e.getLineHeightOptions().map(U=>({value:U.value,label:Ee(U.value)==="default"?ol(U.lineHeight,b):U.label})),B=p.length>0?p:[{value:"default",label:Uo}];je(B);},[e,t]),useEffect(()=>{if(!t("lineHeight")||typeof e.getCurrentLineHeight!="function")return;let b=e.getLineHeightOptions;if(typeof b!="function")return;let p=false;return e.getCurrentLineHeight().then(B=>{if(p)return;if(B){Le(B);return}let U=Ct(),q=il(U?.lineHeight,U?.fontSize,b());Le(q??"default");}),()=>{p=true;}},[o,e,t,Te]),useEffect(()=>{if(!t("textColor")||typeof e.getTextColorOptions!="function")return;let b=e.getTextColorOptions().map(p=>({value:p.value,label:p.label,color:p.color}));b.length>0&&ce(b);},[e,t]),useEffect(()=>{if(!t("textColor")||typeof e.getCurrentTextColor!="function")return;let b=false;return e.getCurrentTextColor().then(p=>{b||H(p??"default");}),()=>{b=true;}},[o,e,t,Te]),useEffect(()=>{if(!t("textHighlight")||typeof e.getTextHighlightOptions!="function")return;let b=e.getTextHighlightOptions().map(p=>({value:p.value,label:p.label,color:p.backgroundColor}));b.length>0&&$e(b);},[e,t]),useEffect(()=>{if(!t("textHighlight")||typeof e.getCurrentTextHighlight!="function")return;let b=false;return e.getCurrentTextHighlight().then(p=>{b||we(p??"default");}),()=>{b=true;}},[o,e,t,Te]);let ve=useMemo(()=>{if(!v||v.length===0)return [...Ue];let b=new Set,p=[];for(let B of v)!Ue.includes(B)||b.has(B)||(b.add(B),p.push(B));return p.length>0?p:[...Ue]},[v]),rt=y?.trim()||"Paragraph",wt=useMemo(()=>{let b=ve.map(p=>({value:p,label:`Heading ${p.slice(1)}`}));return [{value:"p",label:rt},...b]},[ve,rt]),Me=o.isH1?"h1":o.isH2?"h2":o.isH3?"h3":o.isH4?"h4":o.isH5?"h5":o.isH6?"h6":"p",gt=wt.some(b=>b.value===Me)?Me:"p",Tt=b=>{b==="p"?e.toggleParagraph():b.startsWith("h")&&ve.includes(b)&&e.toggleHeading(b);},xt=b=>{b==="default"?e.clearFontFamily?.():e.setFontFamily?.(b),Q(b);},Ze=b=>{b==="default"?e.clearFontSize?.():e.setFontSize?.(b),ke(b);},it=b=>{e.setLineHeight?.(b),Le(b);},lt=(b,p)=>{b(B=>{let U=Co(p),q=B.filter(g=>Co(g)!==U);return [p,...q].slice(0,Bo)});},Je=b=>{if(b==="default"){e.clearTextColor?.(),H("default");return}e.setTextColor?.(b),H(b);},De=b=>{if(b==="default"){e.clearTextHighlight?.(),we("default");return}e.setTextHighlight?.(b),we(b);},at=b=>{if(typeof e.setOrderedListPattern=="function"){e.setOrderedListPattern(b);return}e.toggleOrderedList();},ht=b=>{if(typeof e.setUnorderedListPattern=="function"){e.setUnorderedListPattern(b);return}e.toggleUnorderedList();},St=b=>{if(typeof e.setCheckListVariant=="function"){e.setCheckListVariant(b);return}e.toggleCheckList();},Qt=b=>{switch(b){case "fontFamily":return t("fontFamily")?jsx(jt,{value:ae,onValueChange:xt,options:Fe,placeholder:"Font"},"fontFamily"):null;case "fontSize":return t("fontSize")?jsx(jt,{value:Ae,onValueChange:Ze,options:Ve,placeholder:"Size"},"fontSize"):null;case "lineHeight":return t("lineHeight")?jsx(jt,{value:pe,onValueChange:it,options:ye,placeholder:"Line"},"lineHeight"):null;case "textColor":return t("textColor")?jsx(rr,{title:"Text Color",value:qe,options:j,recentColors:Xe,active:o.hasCustomTextColor,fallbackColor:"#0f172a",onChange:Je,onClear:()=>Je("default"),onAddRecent:p=>lt(ee,p)},"textColor"):null;case "textHighlight":return t("textHighlight")?jsx(rr,{title:"Text Highlight",value:Pe,options:mt,recentColors:ze,active:o.hasTextHighlight,fallbackColor:"#fef08a",highlight:true,onChange:De,onClear:()=>De("default"),onAddRecent:p=>lt(Ye,p)},"textHighlight"):null;case "bold":return jsx(R,{onClick:()=>e.toggleBold(),active:o.bold,title:"Bold (Ctrl+B)",children:jsx(to,{size:16})},"bold");case "italic":return jsx(R,{onClick:()=>e.toggleItalic(),active:o.italic,title:"Italic (Ctrl+I)",children:jsx(oo,{size:16})},"italic");case "underline":return jsx(R,{onClick:()=>e.toggleUnderline(),active:o.underline,title:"Underline (Ctrl+U)",children:jsx(no,{size:16})},"underline");case "strikethrough":return jsx(R,{onClick:()=>e.toggleStrikethrough(),active:o.strikethrough,title:"Strikethrough",children:jsx(ro,{size:16})},"strikethrough");case "subscript":return t("subscript")?jsx(R,{onClick:()=>e.toggleSubscript?.(),active:o.subscript,title:"Subscript",children:jsx(wn,{size:16})},"subscript"):null;case "superscript":return t("superscript")?jsx(R,{onClick:()=>e.toggleSuperscript?.(),active:o.superscript,title:"Superscript",children:jsx(Tn,{size:16})},"superscript"):null;case "code":return jsx(R,{onClick:()=>e.formatText("code"),active:o.code,title:"Inline Code",children:jsx(io,{size:16})},"code");case "link":return jsx(R,{onClick:()=>o.isLink?e.removeLink():e.insertLink(),active:o.isLink,title:o.isLink?"Remove Link":"Insert Link",children:o.isLink?jsx(pt,{size:16}):jsx(Ft,{size:16})},"link");case "blockFormat":return t("blockFormat")?jsx(jt,{value:gt,onValueChange:Tt,options:wt,placeholder:"Format"},"blockFormat"):null;case "quote":return t("blockFormat")?jsx(R,{onClick:()=>e.toggleQuote(),active:o.isQuote,title:"Quote",children:jsx(co,{size:16})},"quote"):null;case "alignLeft":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("left"),active:o.isTextAlignedLeft,title:"Align Left",children:jsx(Mt,{size:16})},"alignLeft"):null;case "alignCenter":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("center"),active:o.isTextAlignedCenter,title:"Align Center",children:jsx(bt,{size:16})},"alignCenter"):null;case "alignRight":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("right"),active:o.isTextAlignedRight,title:"Align Right",children:jsx(Ot,{size:16})},"alignRight"):null;case "alignJustify":return t("blockFormat")?jsx(R,{onClick:()=>e.setTextAlignment("justify"),active:o.isTextAlignedJustify,title:"Justify",children:jsx(mn,{size:16})},"alignJustify"):null;case "codeBlock":return t("code")?jsx(R,{onClick:()=>e.toggleCodeBlock(),active:o.isInCodeBlock,title:"Code Block",children:jsx(un,{size:16})},"codeBlock"):null;case "unorderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleUnorderedList(),active:o.unorderedList,title:"Bullet List",children:jsx(lo,{size:16})}),jsx(st,{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(Nt,{size:12})}),isOpen:F,onOpenChange:x,children:jsx("div",{className:"luthor-unordered-variant-grid",children:$i.map(p=>jsx("button",{className:"luthor-unordered-variant-option",type:"button",title:p.title,"aria-label":p.title,onClick:()=>{ht(p.pattern),x(false);},children:jsx(Gi,{pattern:p.pattern})},p.pattern))})})]},"unorderedList"):null;case "orderedList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleOrderedList(),active:o.orderedList,title:"Numbered List",children:jsx(so,{size:16})}),jsx(st,{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(Nt,{size:12})}),isOpen:N,onOpenChange:P,children:jsx("div",{className:"luthor-ordered-variant-grid",children:qi.map(p=>jsx("button",{className:"luthor-ordered-variant-option",type:"button",title:p.title,"aria-label":p.title,onClick:()=>{at(p.pattern),P(false);},children:jsx(Wi,{pattern:p.pattern})},p.pattern))})})]},"orderedList"):null;case "checkList":return t("list")?jsxs("div",{className:"luthor-toolbar-split-button",children:[jsx(R,{onClick:()=>e.toggleCheckList(),active:o.checkList,title:"Checklist",children:jsx(ao,{size:16})}),jsx(st,{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(Nt,{size:12})}),isOpen:Z,onOpenChange:ue,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"),ue(false);},children:jsx(tr,{variant:"strikethrough"})}),jsx("button",{className:"luthor-checklist-variant-option",type:"button",title:"Checked = Keep text","aria-label":"Checked = Keep text",onClick:()=>{St("plain"),ue(false);},children:jsx(tr,{variant:"plain"})})]})})]},"checkList"):null;case "indentList":return t("list")?jsx(R,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(vn,{size:14})},"indentList"):null;case "outdentList":return t("list")?jsx(R,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(Cn,{size:14})},"outdentList"):null;case "horizontalRule":return t("horizontalRule")?jsx(R,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(gn,{size:16})},"horizontalRule"):null;case "table":return t("table")?jsx(R,{onClick:()=>fe(true),title:"Insert Table",children:jsx(hn,{size:16})},"table"):null;case "image":return t("image")?jsxs(Fragment,{children:[jsxs(st,{trigger:jsx("button",{className:`luthor-toolbar-button ${o.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Io,{size:16})}),isOpen:X,onOpenChange:D,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.insertFromUrl(),D(false);},children:[jsx(Ft,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.insertFromFile(),D(false);},children:[jsx(Fo,{size:16}),jsx("span",{children:"Upload File"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.insertGifFromUrl(),D(false);},children:[jsx(Mo,{size:16}),jsx("span",{children:"Insert GIF URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.insertGifFromFile(),D(false);},children:[jsx(Fo,{size:16}),jsx("span",{children:"Upload GIF"})]})]},"image"),o.imageSelected&&jsxs(st,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(bt,{size:16})}),isOpen:le,onOpenChange:L,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.setAlignment("left"),L(false);},children:[jsx(Mt,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.setAlignment("center"),L(false);},children:[jsx(bt,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.setAlignment("right"),L(false);},children:[jsx(Ot,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{h.setCaption(),L(false);},children:[jsx(yn,{size:16}),jsx("span",{children:"Set Caption"})]})]},"imageAlign")]}):null;case "emoji":return !t("emoji")||nt.length===0?null:jsx(st,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Insert Emoji",children:jsx(Mo,{size:16})}),isOpen:A,onOpenChange:re,children:jsx("div",{className:"luthor-emoji-picker-grid",role:"listbox","aria-label":"Emoji picker",children:nt.map(p=>jsx("button",{type:"button",className:"luthor-emoji-picker-item",title:p.shortcodes[0]?`${p.label} (:${p.shortcodes[0]}:)`:p.label,onClick:()=>{e.insertEmoji?.(p.emoji),re(false);},children:p.emoji},`${p.emoji}-${p.label}`))})},"emoji");case "embed":return T?jsxs(st,{trigger:jsx("button",{className:`luthor-toolbar-button ${I?"active":""}`,title:"Insert Embed",children:jsx(fn,{size:16})}),isOpen:se,onOpenChange:S,children:[t("iframeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{E.insertIframe(),S(false);},children:[jsx(Ft,{size:16}),jsx("span",{children:"Embed iframe"})]}):null,t("youtubeEmbed")?jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{E.insertYouTube(),S(false);},children:[jsx(Io,{size:16}),jsx("span",{children:"Embed YouTube Video"})]}):null]},"embed"):null;case "undo":return t("history")?jsx(R,{onClick:()=>e.undo(),disabled:!o.canUndo,title:"Undo (Ctrl+Z)",children:jsx(cn,{size:16})},"undo"):null;case "redo":return t("history")?jsx(R,{onClick:()=>e.redo(),disabled:!o.canRedo,title:"Redo (Ctrl+Y)",children:jsx(dn,{size:16})},"redo"):null;case "commandPalette":return jsx(R,{onClick:()=>r?.(),title:"Command Palette (Ctrl+Shift+P)",children:jsx(uo,{size:16})},"commandPalette");case "themeToggle":return jsx(R,{onClick:i,title:n?"Light Mode":"Dark Mode",children:n?jsx(En,{size:16}):jsx(kn,{size:16})},"themeToggle");default:return null}},ft=m??Zt,It=useMemo(()=>cl(ft,t,C),[ft,t,C]);return jsxs(Fragment,{children:[jsx("div",{className:s?.toolbar??"luthor-toolbar",style:u,children:It.sections.map((b,p)=>{let B=b.items.map((U,q)=>{let g=Qt(U);return g?Array.isArray(g)?g.map((k,J)=>k&&typeof k=="object"&&"key"in k&&k.key!=null?k:jsx("span",{children:k},`toolbar-item-${p}-${q}-${J}`)):g.type===Ki.Fragment?jsx("span",{children:g},`toolbar-item-${p}-${q}`):g&&typeof g=="object"&&"key"in g&&g.key!=null?g:jsx("span",{children:g},`toolbar-item-${p}-${q}`):null}).flat().filter(U=>U!==null);return B.length===0?null:jsx("div",{className:s?.section??"luthor-toolbar-section",children:B},p)})}),jsx("input",{ref:f,type:"file",accept:"image/*",onChange:h.handleUpload,className:"luthor-file-input"}),jsx("input",{ref:d,type:"file",accept:"image/gif",onChange:h.handleGifUpload,className:"luthor-file-input"}),jsx(Bn,{isOpen:O,onClose:()=>fe(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:be.rows,onChange:b=>Qe(p=>({...p,rows:parseInt(b.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:be.columns,onChange:b=>Qe(p=>({...p,columns:parseInt(b.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:be.includeHeaders||false,onChange:b=>Qe(p=>({...p,includeHeaders:b.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(Ho,{variant:"secondary",onClick:()=>fe(false),children:"Cancel"}),jsx(Ho,{variant:"primary",onClick:()=>{e.insertTable(be),fe(false);},children:"Insert Table"})]})]})})]})}var Yo=["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"],mr={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 Jt(e){let t={...mr};if(!e)return t;for(let o of Yo)typeof e[o]=="boolean"&&(t[o]=e[o]);return t}function gr(e,t){return e[t]!==false}var sr=8,ur=[{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"}],Ul={value:"default",label:"Default",fontFamily:"inherit"},cr=[{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"}],Kl={value:"default",label:"Default",fontSize:"inherit"},dr=[{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"}],Vl={value:"default",label:"Default",lineHeight:"1.5"},Yt="1.5",_l=1;function Et(e){return e.trim().toLowerCase()}function hr(e){return /^[a-z0-9][a-z0-9-]*$/i.test(e)}function jl(e){return Et(e)==="default"?true:Lo(e)!==null}function ql(e){let t=e??ur,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||!hr(l))continue;let m=Et(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontFamily:u,cssImportUrl:r.cssImportUrl?.trim()||void 0}));}return n.length===0?ur:n.some(r=>Et(r.value)==="default")?n:[Ul,...n]}function $l(e){let t=e??cr,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||!hr(l))continue;let m=Et(l);o.has(m)||(o.add(m),n.push({value:l,label:s,fontSize:u}));}return n.length===0?cr:n.some(r=>Et(r.value)==="default")?n:[Kl,...n]}function Lo(e){let t=e.trim();if(!/^\d*\.?\d+$/.test(t))return null;let o=Number(t);return !Number.isFinite(o)||o<_l?null:o.toString()}function Yl(e){if(!Number.isFinite(e))return sr;let t=Math.floor(e);return t>=0?t:sr}function Jl(e){return typeof e=="number"?Number.isFinite(e)?Lo(e.toString())??Yt:Yt:typeof e=="string"?Lo(e)??Yt:Yt}function Gl(e,t=Yt){let o=e??dr,n=new Set,i=[];for(let l of o){let s=String(l.value).trim(),u=String(l.label).trim();if(!s||!u||!jl(s))continue;let m=Et(s);if(n.has(m))continue;if(m==="default"){n.add(m),i.push({value:s,label:u,lineHeight:t});continue}let C=Lo(String(l.lineHeight));C&&(n.add(m),i.push({value:s,label:u,lineHeight:C}));}return i.length===0?dr:i.some(l=>Et(l.value)==="default")?i:[{...Vl,lineHeight:t},...i]}function dt({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 Wl=()=>jsxs(dt,{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"})]}),Xl=()=>jsxs(dt,{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"})]}),Ql=()=>jsxs(dt,{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"})]}),Zl=()=>jsxs(dt,{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"})]}),ea=()=>jsxs(dt,{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"})]}),ta=()=>jsxs(dt,{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"})]}),oa=()=>jsxs(dt,{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"})]}),na=()=>jsxs(dt,{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"})]}),wo=new ImageExtension;wo.config={...wo.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var Ko=new TableExtension;Ko.config={...Ko.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(Wl,{})}),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(Xl,{})}),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(Ql,{})}),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(Zl,{})}),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(ea,{})}),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(ta,{})}),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(na,{})})}),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(oa,{})})]})};var Vo=new IframeEmbedExtension;Vo.config={...Vo.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center"};var _o=new YouTubeEmbedExtension;_o.config={..._o.config,defaultWidth:720,defaultHeight:405,defaultAlignment:"center",nocookie:true,controls:true,rel:1};var ra=Un(),jo=new ContextMenuExtension;jo.config={...jo.config,preventDefault:true};var ia=new CommandPaletteExtension,la=new SlashCommandExtension,aa=new EmojiExtension,qo=new DraggableBlockExtension;qo.config={...qo.config,buttonStackPosition:"left"};var $o=new LinkExtension;$o.config={...$o.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var sa=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"}]}),ua=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:ca}=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 fr({fontFamilyOptions:e,fontSizeOptions:t,lineHeightOptions:o,minimumDefaultLineHeight:n,featureFlags:i,isDraggableBoxEnabled:r,scaleByRatio:l,syntaxHighlighting:s,codeHighlightProvider:u,loadCodeHighlightProvider:m,maxAutoDetectCodeLength:C,isCopyAllowed:v,languageOptions:y,maxListIndentation:h}={}){let f=Jt(i),d=se=>gr(f,se),E=(r??true)&&d("draggableBlock"),T=Jl(n),I=Yl(h),X=new FontFamilyExtension().configure({options:ql(e),cssLoadStrategy:"on-demand"}),D=new FontSizeExtension().configure({options:$l(t)}),A=new LineHeightExtension().configure({options:Gl(o,T),defaultLineHeight:T});wo.configure({scaleByRatio:l??false}),codeExtension.configure({syntaxHighlighting:s??"auto",provider:u??void 0,loadProvider:m}),codeIntelligenceExtension.configure({provider:u??void 0,loadProvider:m,maxAutoDetectLength:C,isCopyAllowed:v??true,languageOptions:y});let re=new ListExtension({maxDepth:I+1}),le=new TabIndentExtension({maxListDepth:I+1}),L=[];return d("bold")&&L.push(boldExtension),d("italic")&&L.push(italicExtension),d("underline")&&L.push(underlineExtension),d("strikethrough")&&L.push(strikethroughExtension),d("fontFamily")&&L.push(X),d("fontSize")&&L.push(D),d("lineHeight")&&L.push(A),d("textColor")&&L.push(sa),d("textHighlight")&&L.push(ua),d("subscript")&&L.push(subscriptExtension),d("superscript")&&L.push(superscriptExtension),d("link")&&L.push($o),d("horizontalRule")&&L.push(horizontalRuleExtension),d("table")&&L.push(Ko),d("list")&&L.push(re),d("history")&&L.push(historyExtension),d("image")&&L.push(wo),d("blockFormat")&&L.push(blockFormatExtension),d("code")&&L.push(codeExtension),d("codeIntelligence")&&L.push(codeIntelligenceExtension),d("codeFormat")&&L.push(codeFormatExtension),d("tabIndent")&&L.push(le),d("enterKeyBehavior")&&L.push(enterKeyBehaviorExtension),d("iframeEmbed")&&L.push(Vo),d("youTubeEmbed")&&L.push(_o),d("floatingToolbar")&&L.push(ra),d("contextMenu")&&L.push(jo),d("commandPalette")&&L.push(ia),d("slashCommand")&&L.push(la),d("emoji")&&L.push(aa),E&&L.push(qo),d("customNode")&&L.push(ca),L}function Gt(e){return fr(e)}var Jo=fr();function pr(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 br(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 yr(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 vr(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 Cr(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 Er(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 kr(e){return new Set(e)}function Go(e,t){e.clear();for(let o of t)e.add(o);}function Lr(e,t){return e.has(t)}function wr(e,t){e.add(t);}var K=(e,t=0,o="")=>({type:"text",version:1,text:e,detail:0,format:t,mode:"normal",style:o}),Ie=(e,t="",o=0)=>({type:"paragraph",version:1,format:t,indent:o,direction:null,children:e}),Wo={root:{type:"root",version:1,format:"",indent:0,direction:null,children:[{type:"heading",version:1,tag:"h1",format:"",indent:0,direction:null,children:[K("Extensive Preset: JSON-First Feature Showcase")]},Ie([K("This starter content is now a native "),K("JSON",1),K(" document that demonstrates visual editing without Markdown conversion.")]),{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[K("Inline formatting + typography")]},Ie([K("Bold",1),K(" \u2022 "),K("Italic",2),K(" \u2022 "),K("Underline",8),K(" \u2022 "),K("Strikethrough",4),K(" \u2022 "),K("Inline Code",16),K(" \u2022 "),K("Subscript",32),K(" \u2022 "),K("Superscript",64)]),Ie([K("Font family + size + color + highlight + line-height can be combined in one sentence.",0,"font-family: 'Inter', 'Segoe UI', Arial, sans-serif; font-size: 18px; line-height: 1.75; color: #2563eb; background-color: #bfdbfe;")]),{type:"paragraph",version:1,format:"center",indent:0,direction:null,children:[K("Centered paragraph with custom style",0,"font-size: 20px; color: #7c3aed;")]},{type:"paragraph",version:1,format:"right",indent:0,direction:null,children:[K("Right-aligned paragraph with highlight",128,"background-color: #fef08a;")]},{type:"quote",version:1,format:"",indent:0,direction:null,children:[K("\u201CEverything in this demo is persisted in JSON and can round-trip via visual mode.\u201D")]},{type:"paragraph",version:1,format:"",indent:0,direction:null,children:[{type:"link",version:1,rel:"noreferrer",target:"_blank",title:"Luthor documentation",url:"https://github.com/facebook/lexical",format:"",indent:0,direction:null,children:[K("Example link node")]},K(" with regular sibling text and emoji support \u{1F389}\u{1F525}\u2705.")]},{type:"heading",version:1,tag:"h2",format:"",indent:0,direction:null,children:[K("Lists")]},{type:"list",version:1,listType:"bullet",start:1,tag:"ul",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,format:"",indent:0,direction:null,children:[Ie([K("Bullet item with styled text",0,"color: #16a34a;")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[Ie([K("Nested formatting in lists",1),K(" works great.")])]}]},{type:"list",version:1,listType:"number",start:1,tag:"ol",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,format:"",indent:0,direction:null,children:[Ie([K("Numbered item 1")])]},{type:"listitem",version:1,value:2,format:"",indent:0,direction:null,children:[Ie([K("Numbered item 2")])]}]},{type:"list",version:1,listType:"check",start:1,tag:"ul",format:"",indent:0,direction:null,children:[{type:"listitem",version:1,value:1,checked:true,format:"",indent:0,direction:null,children:[Ie([K("Checked task item")])]},{type:"listitem",version:1,value:2,checked:false,format:"",indent:0,direction:null,children:[Ie([K("Unchecked task item")])]}]},{children:[{detail:0,format:0,mode:"normal",style:"",text:"const",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"=",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" exportApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"toJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"await",type:"code-highlight",version:1,highlightType:"keyword"},{detail:0,format:0,mode:"normal",style:"",text:" ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"saveToDatabase",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"{",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:" json",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:":",type:"code-highlight",version:1,highlightType:"operator"},{detail:0,format:0,mode:"normal",style:"",text:" content ",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:"}",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"},{type:"linebreak",version:1},{detail:0,format:0,mode:"normal",style:"",text:"importApi",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:".",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"fromJSON",type:"code-highlight",version:1,highlightType:"function"},{detail:0,format:0,mode:"normal",style:"",text:"(",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:"content",type:"code-highlight",version:1},{detail:0,format:0,mode:"normal",style:"",text:")",type:"code-highlight",version:1,highlightType:"punctuation"},{detail:0,format:0,mode:"normal",style:"",text:";",type:"code-highlight",version:1,highlightType:"punctuation"}],direction:null,format:"",indent:0,type:"code",version:1,language:"typescript"},{type:"horizontalrule",version:1},{type:"featureCard",version:1,payload:{title:"AI Draft: Weekly Product Update",description:"This structured block can hold AI-generated draft content that reviewers can quickly edit and approve.",tag:"AI Draft"},format:"",indent:0,direction:null,children:[]},{type:"image",version:1,src:"https://images.unsplash.com/photo-1461749280684-dccba630e2f6?auto=format&fit=crop&w=1200&q=80",alt:"Code editor on a laptop",caption:"Image node with caption, center alignment, and persisted dimensions.",alignment:"center",width:780,height:420},{type:"youtube-embed",version:1,src:"https://www.youtube.com/embed/dQw4w9WgXcQ",width:720,height:405,alignment:"center",start:0},{type:"iframe-embed",version:1,src:"https://example.com",width:720,height:405,alignment:"center",title:"Iframe embed example"},{type:"table",version:1,format:"",indent:0,direction:null,children:[{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[Ie([K("Feature")])]},{type:"tablecell",version:1,headerState:3,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[Ie([K("Status")])]}]},{type:"tablerow",version:1,children:[{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:240,backgroundColor:null,children:[Ie([K("Visual \u2194 JSON switching")])]},{type:"tablecell",version:1,headerState:0,colSpan:1,rowSpan:1,width:320,backgroundColor:null,children:[Ie([K("Round-trip ready \u2705")])]}]}]},Ie([K("Use the toolbar, floating toolbar, slash commands (/), and command palette (Ctrl/Cmd+Shift+P) to explore the full preset.")])]}};JSON.stringify(Wo);var{Provider:wa,useEditor:Ta}=createEditorSystem(),Tr="Write anything...",xr="Enter JSON document content...",Sr="Enter Markdown content...",Ir="Enter HTML content...",Nr=new Set(["auto","scroll","overlay"]),xa={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"};function Xt(e){return e==="visual"?"visual-editor":e}function ie(e){return Xt(e)==="visual-editor"}function Zo(e,t){return e.some(o=>Xt(o)===t)}function Xo(e){return e==="json"||e==="markdown"||e==="html"}function Hr(e){let t=e.overflowY;return t&&t!=="visible"?t:e.overflow||t||"visible"}function Sa(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 Ia(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=Hr(window.getComputedStyle(n));Nr.has(i)&&o(n),n=n.parentElement;}}t.forEach(n=>{Sa(n);});}function Fa(e){if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e());});return}globalThis.setTimeout(e,0);}function Fr(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=Hr(n);if(!Nr.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 Ma(e){if(typeof window>"u")return ()=>{};let t=Fr(e),o=()=>{t(),t=Fr(e);};return window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o),t();}}function en(e){let o=e.replace(/\r\n?/g,`
6
- `).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 Wt=en("");function Mr(e,t,o){return o<=t?t:Math.min(o,Math.max(t,e))}function Oa(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 Na(e,t,o){let r=Array.from(e.children).filter(C=>C instanceof HTMLElement).reduce((C,v)=>{let y=v.getBoundingClientRect(),h=y.top+y.height/2;if(!C)return v;let f=C.getBoundingClientRect(),d=f.top+f.height/2;return Math.abs(h-o)<Math.abs(d-o)?v:C},null)??e.firstElementChild??e,l=e.getBoundingClientRect(),s=r.getBoundingClientRect(),u=Mr(t,l.left+1,l.right-1),m=Mr(o,s.top+1,s.bottom-1);Oa(u,m);}function Ha(e){try{let t=JSON.parse(e);return JSON.stringify(t)}catch{return JSON.stringify(en(e))}}function Lt(e,t){let o=t??Wt;return e==="json"?Xn(JSON.stringify(o)):e==="markdown"?Qn(jsonToMarkdown(o)):Zn(jsonToHTML(o))}function Ra(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 Aa(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 Pa(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 za(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 Ba(e){if(!Number.isFinite(e))return "8";let t=Math.floor(e);return t<0?"8":t.toString()}function Qo(e){return pr(e)}function Da(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 Ua(e){return br(e)}function Ka(e){let t=Jt(e);return JSON.stringify(Yo.map(o=>[o,t[o]]))}function Or(e){return yr(e)}var Va=[{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 _a(e,t){return vr(e,t)}function ja(e,t,o){return Er(e,t,o)}var qa={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 $a(e,t){return Cr(e,t,qa)}function Ya(e){if(!e||e.length===0)return [...Ue];let t=new Set,o=[];for(let n of e)!Ue.includes(n)||t.has(n)||(t.add(n),o.push(n));return o.length>0?o:[...Ue]}function Ja(e){if(!e)return "__default__";if(Array.isArray(e)){let r=new Set,l=[];for(let s of e)for(let[u,m]of Object.entries(s)){let C=u.trim();!m||!C||r.has(C)||(r.add(C),l.push(C));}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 m=u.trim();!m||l.has(m)||(l.add(m),s.push(m));}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 Ga(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 Wa(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 Xa(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 m=`${s.key}:${s.ctrlKey?1:0}:${s.metaKey?1:0}:${s.shiftKey?1:0}:${s.altKey?1:0}`,C=`${u.key}:${u.ctrlKey?1:0}:${u.metaKey?1:0}:${u.shiftKey?1:0}:${u.altKey?1:0}`;return m.localeCompare(C)});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 Qa({isDark:e,toggleTheme:t,visualPlaceholder:o,jsonPlaceholder:n,markdownPlaceholder:i,htmlPlaceholder:r,initialMode:l,availableModes:s,onReady:u,toolbarLayout:m,toolbarVisibility:C,toolbarPosition:v,toolbarAlignment:y,toolbarClassName:h,toolbarStyleVars:f,isToolbarEnabled:d,isToolbarPinned:E,isEditorViewTabsVisible:T,headingOptions:I,paragraphLabel:X,syncHeadingOptionsWithCommands:D,slashCommandVisibility:A,shortcutConfig:re,commandPaletteShortcutOnly:le,featureFlags:L,editOnClick:se}){let{commands:S,hasExtension:F,activeStates:x,lexical:N,extensions:P,export:Z,import:ue}=Ta(),[O,fe]=useState(l),[ae,Q]=useState({json:"",markdown:"",html:""}),[Fe,he]=useState(null),[Ae,ke]=useState(null),[Ve,_e]=useState({isOpen:false,commands:[]}),[pe,Le]=useState({isOpen:false,query:"",position:null,commands:[]}),[ye,je]=useState({isOpen:false,query:"",position:null,suggestions:[]}),qe=useRef(false),H=useMemo(()=>Ya(I),[I]),j=D?H:void 0,ce=D?X:void 0,Xe=x.isInCodeBlock===true,ee=useMemo(()=>ja(S,L,Xe),[S,L,Xe]),Pe=useMemo(()=>g=>Object.prototype.hasOwnProperty.call(L,g)?L[g]!==false:true,[L]),we=useMemo(()=>g=>ie(O)&&Pe(g),[O,Pe]),mt=useMemo(()=>$a(C,L),[C,L]),$e=L.draggableBlock!==false,ze=Ja(A),Ye=useRef(A),Te=useRef(ze),Be=Xa(re),be=useRef(re),Qe=useRef(Be),G=useMemo(()=>Ga(re?.disabledCommandIds),[re?.disabledCommandIds]),xe=useMemo(()=>new Set(G),[G]),nt=useMemo(()=>xe.size===0?[]:So({headingOptions:j,paragraphLabel:ce,isFeatureEnabled:Pe}).filter(g=>xe.has(g.id)).flatMap(g=>g.shortcuts??[]),[xe,j,ce,Pe]);Te.current!==ze&&(Te.current=ze,Ye.current=A),Qe.current!==Be&&(Qe.current=Be,be.current=re);let ve=useRef(kr(["visual-editor"])),rt=useRef({json:false,markdown:false,html:false}),wt=useRef(0),Me=useRef(null);useEffect(()=>{Ro(ee,x,e?"dark":"light",we);},[ee,x,e,we]);let gt=useMemo(()=>({injectJSON:_=>{setTimeout(()=>{try{let ge=JSON.parse(_);ue.fromJSON(ge);}catch(ge){console.error("Failed to inject JSON:",ge);return}},100);},getJSON:()=>Lt("json",Z.toJSON()),getMarkdown:()=>Lt("markdown",Z.toJSON()),getHTML:()=>Lt("html",Z.toJSON())}),[Z,ue]);useEffect(()=>{if(!N||!ee)return;let g=ee,k=rn(g,{headingOptions:j,paragraphLabel:ce,isFeatureEnabled:we,shortcutConfig:be.current,commandPaletteShortcutOnly:le});typeof g.registerCommand=="function"&&k.forEach(_=>g.registerCommand(_));let J=ln(g,{headingOptions:j,paragraphLabel:ce,slashCommandVisibility:Ye.current,isFeatureEnabled:we,shortcutConfig:be.current});typeof g.setSlashCommands=="function"?g.setSlashCommands(J):J.forEach(_=>g.registerSlashCommand?.(_));let W=sn(g,document.body,{headingOptions:j,paragraphLabel:ce,isFeatureEnabled:we,shortcutConfig:be.current,scope:()=>N.getRootElement()});return qe.current||(qe.current=true,u?.(gt)),()=>{W(),typeof g.unregisterCommand=="function"&&k.forEach(_=>g.unregisterCommand(_.id)),typeof g.setSlashCommands=="function"?g.setSlashCommands([]):J.forEach(_=>g.unregisterSlashCommand?.(_.id));}},[N,ee,gt,u,j,ce,ze,Be,we,le]),useEffect(()=>{let g=()=>N?.getRootElement(),k=Va.filter(W=>L[W.feature]===false);if(k.length===0)return;let J=W=>{let _=g();_&&W.target instanceof Node&&!_.contains(W.target)||!Or(W.target)||!k.some(Pr=>_a(W,Pr))||(W.preventDefault(),W.stopPropagation());};return document.addEventListener("keydown",J,true),()=>{document.removeEventListener("keydown",J,true);}},[N,L]),useEffect(()=>{let g=P.find(k=>k.name==="commandPalette");if(!(!g||!g.subscribe))return g.subscribe((k,J)=>{let W=J.filter(_=>xe.has(_.id)?false:le?typeof _.shortcut=="string"&&_.shortcut.trim().length>0:true);_e({isOpen:ie(O)?k:false,commands:W});})},[P,xe,le,O]),useEffect(()=>{if(nt.length===0)return;let g=()=>N?.getRootElement(),k=J=>{let W=g();W&&J.target instanceof Node&&!W.contains(J.target)||!Or(J.target)||!nt.some(ge=>Wa(J,ge))||(J.preventDefault(),J.stopPropagation());};return document.addEventListener("keydown",k,true),()=>{document.removeEventListener("keydown",k,true);}},[N,nt]),useEffect(()=>{let g=P.find(k=>k.name==="slashCommand");if(!(!g||!g.subscribe))return g.subscribe(k=>{Le({isOpen:ie(O)?k.isOpen:false,query:ie(O)?k.query:"",position:ie(O)?k.position:null,commands:ie(O)?k.commands:[]});})},[P,O]),useEffect(()=>{let g=P.find(k=>k.name==="emoji");if(!(!g||!g.subscribe))return g.subscribe(k=>{je({isOpen:ie(O)?k.isOpen:false,query:ie(O)?k.query:"",position:ie(O)?k.position:null,suggestions:ie(O)?k.suggestions:[]});})},[P,O]),useEffect(()=>{ie(O)||(_e(g=>g.isOpen?{...g,isOpen:false}:g),Le(g=>g.isOpen||g.query.length>0||g.position!==null||g.commands.length>0?{isOpen:false,query:"",position:null,commands:[]}:g),je(g=>g.isOpen||g.query.length>0||g.position!==null||g.suggestions.length>0?{isOpen:false,query:"",position:null,suggestions:[]}:g),ee.hideCommandPalette?.(),ee.closeSlashMenu?.(),ee.closeEmojiSuggestions?.());},[O,ee]),useEffect(()=>!N||!Z?void 0:N.registerUpdateListener(()=>{wt.current+=1,Go(ve.current,["visual-editor"]);}),[N,Z]);let Tt=g=>{let k=ae[g];if(g==="json"){if(!k.trim()){ue.fromJSON(en(""));return}let J=JSON.parse(k);ue.fromJSON(J);return}g==="markdown"?ue.fromJSON(markdownToJSON(k)):ue.fromJSON(htmlToJSON(k)),rt.current[g]=false,Go(ve.current,["visual-editor"]);},xt=g=>{let k=Z.toJSON()??Wt;return Lt(g,k)},Ze=(g,k,J)=>{Q(W=>({...W,[g]:k})),rt.current[g]=J?.dirty===true;},it=async g=>{let k=Xt(g);if(k===O||!Zo(s,k))return;let J=O,W=null;try{if(ke(null),Xo(J)){let _=J;rt.current[_]&&(W=_,Tt(_),await new Promise(ge=>setTimeout(ge,50)),W=null);}if(ie(J)&&!ie(k)&&(N&&clearLexicalSelection(N),N?.getRootElement()?.blur()),fe(k),Xo(k)){let _=k;if(!Lr(ve.current,_)){he(_),await new Promise(ge=>setTimeout(ge,50));try{W=_;let ge=xt(_);Ze(_,ge),wr(ve.current,_),W=null;}finally{he(null);}}}ie(k)&&(J==="visual-only"&&Me.current!==null?setTimeout(()=>N?.focus(),100):Fa(()=>{let ge=N?.getRootElement();ge&&Ia(ge);}));}catch(_){let ge=_ instanceof Error?_.message:"Invalid format - could not parse content";W&&ke({mode:W,error:ge});}},lt=g=>{!se||O!=="visual-only"||!Zo(s,"visual-editor")||(Me.current=g,it("visual-editor"));};useEffect(()=>{if(!ie(O))return;let g=Me.current;if(!g)return;Me.current=null;let k=()=>{let W=N?.getRootElement();W&&Na(W,g.clientX,g.clientY);};if(typeof window<"u"&&typeof window.requestAnimationFrame=="function"){window.requestAnimationFrame(()=>k());return}let J=globalThis.setTimeout(k,0);return ()=>{globalThis.clearTimeout(J);}},[N,O]);let Je=d?jsx(ir,{commands:ee,hasExtension:g=>F(g),activeStates:x,isDark:e,toggleTheme:t,onCommandPaletteOpen:()=>{ie(O)&&L.commandPalette!==false&&ee.showCommandPalette();},imageUploadHandler:g=>P.find(k=>k.name==="image")?.config?.uploadHandler?.(g)??Promise.resolve(URL.createObjectURL(g)),layout:m??Zt,toolbarVisibility:mt,toolbarStyleVars:f,headingOptions:H,paragraphLabel:X,classNames:{toolbar:`luthor-toolbar luthor-toolbar--align-${y}${h?` ${h}`:""}`}}):null,De=T,at=ie(O)&&d&&v==="top",St=["luthor-editor-top-region",E&&v==="top"&&De?"luthor-editor-top-region--pinned":""].filter(Boolean).join(" "),ft=["luthor-editor-toolbar-slot","luthor-editor-toolbar-slot--top",at&&(E&&v==="top"&&!De)?"luthor-editor-toolbar-slot--pinned":""].filter(Boolean).join(" "),It=ie(O)&&d&&v==="bottom",b=N?.getRootElement()?.closest(".luthor-editor-wrapper")??null,p=Xo(O)?O:null,B=O==="visual-only",U=ie(O)||B,q=!$e||!ie(O);return jsxs(Fragment,{children:[jsxs("div",{className:`luthor-editor${q?" luthor-editor--draggable-disabled":""}`,"data-mode":O,children:[(De||at)&&jsxs("div",{className:St,children:[De&&jsx("div",{className:"luthor-editor-header",children:jsx($n,{mode:O,onModeChange:it,availableModes:s,isConverting:Fe})}),at&&jsx("div",{className:ft,children:Je})]}),jsxs("div",{className:`luthor-editor-visual-shell${U?"":" is-hidden"}${q?" luthor-editor-visual-shell--no-gutter":""}`,"aria-hidden":!U,children:[!q&&jsx("div",{className:"luthor-editor-visual-gutter","aria-hidden":"true"}),jsx(RichText,{placeholder:o,nonEditableVisualMode:B,onEditIntent:B?lt: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"}})]}),p&&jsxs("div",{className:"luthor-source-panel",children:[Ae&&Ae.mode===p&&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:xa[p]}),jsx("p",{children:Ae.error}),jsx("small",{children:"Fix the errors above and try switching modes again"})]})]}),p==="json"&&jsx(fo,{value:ae.json,onChange:g=>Ze("json",g,{dirty:true}),placeholder:n}),p==="markdown"&&jsx(fo,{value:ae.markdown,onChange:g=>Ze("markdown",g,{dirty:true}),placeholder:i,className:"luthor-source-view--wrapped",wrap:"soft"}),p==="html"&&jsx(fo,{value:ae.html,onChange:g=>Ze("html",g,{dirty:true}),placeholder:r,className:"luthor-source-view--wrapped",wrap:"soft"})]})]}),jsx(qn,{editor:N,commands:ee,editorTheme:e?"dark":"light",disabled:!ie(O)}),It&&jsx("div",{className:"luthor-editor-toolbar-slot luthor-editor-toolbar-slot--bottom",children:Je}),ie(O)&&jsx(Fn,{isOpen:Ve.isOpen,onClose:()=>ee.hideCommandPalette(),commands:Ve.commands}),ie(O)&&jsx(An,{isOpen:pe.isOpen,query:pe.query,position:pe.position,portalContainer:b,commands:pe.commands,onClose:()=>ee.closeSlashMenu?.(),onExecute:g=>{ee.executeSlashCommand?.(g);}}),ie(O)&&jsx(Nn,{isOpen:ye.isOpen,query:ye.query,position:ye.position,portalContainer:b,suggestions:ye.suggestions,onClose:()=>ee.closeEmojiSuggestions?.(),onExecute:g=>{ee.executeEmojiSuggestion?.(g);}})]})}var To=forwardRef(({className:e,onReady:t,initialTheme:o="light",onThemeChange:n,theme:i,defaultContent:r,showDefaultContent:l=true,placeholder:s=Tr,defaultEditorView:u,initialMode:m="visual-editor",isEditorViewTabsVisible:C,isEditorViewsTabVisible:v,availableModes:y=["visual-editor","visual-only","json","markdown","html"],variantClassName:h,toolbarLayout:f,toolbarVisibility:d,toolbarPosition:E="top",toolbarAlignment:T="left",toolbarClassName:I,toolbarStyleVars:X,quoteClassName:D,quoteStyleVars:A,defaultSettings:re,editorThemeOverrides:le,isToolbarEnabled:L=true,isToolbarPinned:se=false,fontFamilyOptions:S,fontSizeOptions:F,lineHeightOptions:x,minimumDefaultLineHeight:N=1.5,scaleByRatio:P=false,headingOptions:Z,paragraphLabel:ue,syncHeadingOptionsWithCommands:O=true,slashCommandVisibility:fe,shortcutConfig:ae,commandPaletteShortcutOnly:Q=false,editOnClick:Fe=true,isDraggableBoxEnabled:he,featureFlags:Ae,syntaxHighlighting:ke,codeHighlightProvider:Ve,loadCodeHighlightProvider:_e,maxAutoDetectCodeLength:pe,isCopyAllowed:Le=true,languageOptions:ye,maxListIndentation:je=8},qe)=>{let[H,j]=useState(o),ce=useRef(null),Xe=H==="dark",ee=Xt(u??m),Pe=Zo(y,ee)?ee:Xt(y[0]??"visual-editor"),we=C??v??true,mt=()=>j(Xe?"light":"dark"),$e=useMemo(()=>typeof s=="string"?{visual:s,json:xr,markdown:Sr,html:Ir}:{visual:s.visual??Tr,json:s.json??xr,markdown:s.markdown??Sr,html:s.html??Ir},[s]);useEffect(()=>{j(o);},[o]),useEffect(()=>{n?.(H);},[H,n]),useEffect(()=>{if(!se||E!=="top")return;let k=ce.current;if(k)return Ma(k)},[se,E]);let ze=useMemo(()=>Ra(S),[S]),Ye=useMemo(()=>Aa(F),[F]),Te=useMemo(()=>Pa(x),[x]),Be=useMemo(()=>za(N),[N]),be=useMemo(()=>Ba(je),[je]),Qe=ke??"unset",G=typeof pe=="number"?pe.toString():"unset",xe=useMemo(()=>Da(ye),[ye]),nt=Le?"copy-on":"copy-off",ve=useMemo(()=>typeof he!="boolean"?Ae:{...Ae??{},draggableBlock:he},[Ae,he]),rt=useMemo(()=>Ka(ve),[ve]),wt=useMemo(()=>Jt(ve),[ve]),Me=`${ze}::${Ye}::${Te}::${Be}::${be}::${P?"ratio-on":"ratio-off"}::${Qe}::${G}::${nt}::${xe}::${rt}`,gt=useRef(S),Tt=useRef(F),xt=useRef(x),Ze=useRef(N),it=useRef(ve),lt=useRef(ye),Je=useRef(Ve),De=useRef(_e),at=useRef(Me);(at.current!==Me||Je.current!==Ve||De.current!==_e)&&(at.current=Me,gt.current=S,Tt.current=F,xt.current=x,Ze.current=N,it.current=ve,lt.current=ye,Je.current=Ve,De.current=_e);let ht=useRef(null);if(!ht.current||ht.current.key!==Me){let k={fontFamilyOptions:gt.current,fontSizeOptions:Tt.current,lineHeightOptions:xt.current,minimumDefaultLineHeight:Ze.current,maxListIndentation:Number(be),scaleByRatio:P,...ke!==void 0?{syntaxHighlighting:ke}:{},...Je.current!==void 0?{codeHighlightProvider:Je.current}:{},...De.current!==void 0?{loadCodeHighlightProvider:De.current}:{},...pe!==void 0?{maxAutoDetectCodeLength:pe}:{},isCopyAllowed:Le,...lt.current!==void 0?{languageOptions:lt.current}:{},...typeof he=="boolean"?{isDraggableBoxEnabled:he}:{},...it.current?{featureFlags:it.current}:{}};ht.current={key:Me,value:Gt(k)};}let St=ht.current.value,Qt=useMemo(()=>{let k=mergeThemes(defaultLuthorTheme,i??{});return D?{...k,quote:`${k.quote??""} ${D}`.trim()}:k},[i,D]),ft=useMemo(()=>Qo(le),[le]),It=useMemo(()=>Qo(A),[A]),b=useMemo(()=>Ua(re),[re]),p=useMemo(()=>Qo(b),[b]),B=useMemo(()=>{let k=b,J=createEditorThemeStyleVars(le),W=A,_={"--luthor-default-line-height":Be};return !k&&!J&&!W?_:{...k??{},...J,...W??{},..._}},[Be,b,le,A,p,ft,It]),[U,q]=useState(null);useImperativeHandle(qe,()=>U??{injectJSON:()=>{},getJSON:()=>Lt("json",Wt),getMarkdown:()=>Lt("markdown",Wt),getHTML:()=>Lt("html",Wt)},[U]);let g=k=>{q(k),l&&r===void 0?k.injectJSON(JSON.stringify(Wo)):r&&k.injectJSON(Ha(r)),t?.(k);};return jsx("div",{ref:ce,className:`luthor-preset luthor-preset-extensive luthor-editor-wrapper${se?" luthor-editor-wrapper--toolbar-pinned":""} ${h||""} ${e||""}`.trim(),"data-editor-theme":H,style:B,children:jsx(wa,{extensions:St,config:{theme:Qt},children:jsx(Qa,{isDark:Xe,toggleTheme:mt,visualPlaceholder:$e.visual,jsonPlaceholder:$e.json,markdownPlaceholder:$e.markdown,htmlPlaceholder:$e.html,initialMode:Pe,availableModes:y,onReady:g,toolbarLayout:f,toolbarVisibility:d,toolbarPosition:E,toolbarAlignment:T,toolbarClassName:I,toolbarStyleVars:X,isToolbarEnabled:L,isToolbarPinned:se,isEditorViewTabsVisible:we,headingOptions:Z,paragraphLabel:ue,syncHeadingOptionsWithCommands:O,slashCommandVisibility:fe,shortcutConfig:ae,commandPaletteShortcutOnly:Q,featureFlags:wt,editOnClick:Fe})})})});To.displayName="ExtensiveEditor";var Rr=["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"],Ar={id:"extensive",label:"Extensive Editor",description:"Complete editing preset with all core features enabled.",extensions:[...Jo],components:{Editor:To},toolbar:[...Rr],config:Yn("extensive","Write anything..."),css:"extensive/styles.css"};function es(e={}){return {...Ar,extensions:[...Gt({fontFamilyOptions:e.fontFamilyOptions,fontSizeOptions:e.fontSizeOptions,lineHeightOptions:e.lineHeightOptions,minimumDefaultLineHeight:e.minimumDefaultLineHeight,maxListIndentation:e.maxListIndentation,isCopyAllowed:e.isCopyAllowed,languageOptions:e.languageOptions})]}}export{st as $,Fo as A,kr as Aa,gn as B,Go as Ba,hn as C,Lr as Ca,fn as D,wr as Da,ss as E,To as Ea,pn as F,Rr as Fa,us as G,Ar as Ga,uo as H,es as Ha,bn as I,yn as J,co as K,vn as L,Cn as M,En as N,kn as O,Ln as P,Mo as Q,wn as R,Tn as S,Nt as T,xn as U,Fn as V,Nn as W,An as X,R as Y,Ho as Z,jt as _,ts as a,Bn as aa,Ue as b,Dn as ba,ns as c,Ro as ca,Zt as d,Un as da,So as e,qn as ea,rn as f,$n as fa,ln as g,fo as ga,sn as h,Yn as ha,to as i,Xn as ia,oo as j,Qn as ja,no as k,Zn as ka,ro as l,sl as la,io as m,ul as ma,un as n,cl as na,Ft as o,ir as oa,pt as p,mr as pa,lo as q,Jt as qa,ao as r,gr as ra,so as s,Gt as sa,cn as t,Jo as ta,dn as u,pr as ua,Io as v,br as va,Mt as w,yr as wa,bt as x,vr as xa,mn as y,Cr as ya,Ot as z,Er as za};
@@ -1,13 +0,0 @@
1
- import {a,b}from'./chunk-KORFS25D.js';import {sa,ha,ka,ja,ia,fa,ga}from'./chunk-G4AWPZBL.js';import {forwardRef,useState,useMemo,useRef,useEffect,useImperativeHandle,useCallback}from'react';import {createEditorSystem,markdownToJSON,jsonToHTML,jsonToMarkdown,RichText,htmlToJSON}from'@lyfie/luthor-headless';import {jsx,jsxs}from'react/jsx-runtime';var{Provider:ue,useEditor:ce}=createEditorSystem(),X=["visual","json","markdown","html"],he={visual:"Visual",json:"JSON",markdown:"MD",html:"HTML"},me={json:"Invalid JSON",markdown:"Invalid Markdown",html:"Invalid HTML"},Q="Start writing...",q="Enter JSON document content...",G="Enter Markdown content...",K="Enter HTML content...",be=`## Hi there,
2
-
3
- this is a *basic* example of **Luthor Headless**. It covers simple text styles and lists:
4
-
5
- - That's a bullet list with one item.
6
- - ... and one more item.
7
-
8
- Try a code block next:
9
-
10
- \`\`\`
11
- console.log("hello from luthor");
12
- \`\`\`
13
- `,pe=markdownToJSON(be),y={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:""}]}]}},J={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:false,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},Ee={draggableBlock:false,themeToggle:false,table:false,image:false,iframeEmbed:false,youTubeEmbed:false,customNode:false,slashCommand:false,commandPalette:false,contextMenu:false,floatingToolbar:false},ge=new a(J,Ee);function x(a){return a instanceof Error&&a.message.trim()?a.message.trim():"Unable to process the current source content."}function Z(a){return a&&typeof a=="object"?a:y}function ee(a){let l=a.trim();return l?JSON.parse(l):y}function fe(a,l){switch(a){case "json":return ee(l);case "markdown":return markdownToJSON(l);case "html":return htmlToJSON(l)}}function c(a,l){let d=Z(l);switch(a){case "json":return ia(JSON.stringify(d));case "markdown":return ja(jsonToMarkdown(d));case "html":return ka(jsonToHTML(d))}}function ve(a){return typeof a=="string"||typeof a>"u"?{visual:a??Q,json:q,markdown:G,html:K}:{visual:a.visual??Q,json:a.json??q,markdown:a.markdown??G,html:a.html??K}}function Se({initialMode:a,placeholders:l,onReady:d}){let{activeStates:O,commands:e,export:h,import:b}=ce(),[n,S]=useState(a),[E,p]=useState({json:"",markdown:"",html:""}),[H,m]=useState(null),v=useRef(false),t=O,g=useCallback(()=>{let s=Z(h.toJSON()),i={json:c("json",s),markdown:c("markdown",s),html:c("html",s)};return p(i),i},[h]),L=useCallback((s,i)=>{let u=fe(s,i);return b.fromJSON(u),u},[b]),T=useMemo(()=>({injectJSON:s=>{try{let i=ee(s);b.fromJSON(i),m(null),g();}catch(i){m({mode:"json",error:x(i)});}},getJSON:()=>c("json",h.toJSON()),getMarkdown:()=>c("markdown",h.toJSON()),getHTML:()=>c("html",h.toJSON())}),[h,b,g]);useEffect(()=>{!d||v.current||(v.current=true,d(T));},[T,d]);let M=useCallback(s=>{if(s!==n){if(n==="visual"){if(s!=="visual")try{g(),m(null);}catch(i){m({mode:s,error:x(i)});return}S(s);return}try{let i=E[n],u=L(n,i);if(s==="visual"){m(null),S("visual");return}let te=c(s,u);p(oe=>({...oe,[s]:te})),m(null),S(s);}catch(i){m({mode:n,error:x(i)});}}},[n,L,E,g]),C=useCallback(()=>{n==="visual"&&(t.bold&&e.toggleBold?.(),t.italic&&e.toggleItalic?.(),t.strikethrough&&e.toggleStrikethrough?.(),t.code&&e.formatText?.("code"),e.removeLink?.());},[e,n,t.bold,t.code,t.italic,t.strikethrough]),D=useCallback(()=>{n==="visual"&&(t.unorderedList&&e.toggleUnorderedList?.(),t.orderedList&&e.toggleOrderedList?.(),t.isQuote&&e.toggleQuote?.(),t.isInCodeBlock&&e.toggleCodeBlock?.(),e.toggleParagraph?.());},[e,n,t.isInCodeBlock,t.isQuote,t.orderedList,t.unorderedList]),w=useCallback(()=>{n==="visual"&&e.insertHardBreak?.();},[e,n]),r=n==="visual";return jsxs("div",{className:"luthor-editor","data-mode":n,children:[jsx("div",{className:"luthor-editor-header",children:jsx(fa,{mode:n,onModeChange:s=>M(s),availableModes:X,labels:he})}),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${t.bold?" is-active":""}`,onClick:()=>e.toggleBold?.(),disabled:!r,children:"Bold"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.italic?" is-active":""}`,onClick:()=>e.toggleItalic?.(),disabled:!r,children:"Italic"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.strikethrough?" is-active":""}`,onClick:()=>e.toggleStrikethrough?.(),disabled:!r,children:"Strike"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.code?" is-active":""}`,onClick:()=>e.formatText?.("code"),disabled:!r,children:"Code"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:C,disabled:!r,children:"Clear marks"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:D,disabled:!r,children:"Clear nodes"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isParagraph?" is-active":""}`,onClick:()=>e.toggleParagraph?.(),disabled:!r,children:"Paragraph"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH1?" is-active":""}`,onClick:()=>e.toggleHeading?.("h1"),disabled:!r,children:"H1"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH2?" is-active":""}`,onClick:()=>e.toggleHeading?.("h2"),disabled:!r,children:"H2"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH3?" is-active":""}`,onClick:()=>e.toggleHeading?.("h3"),disabled:!r,children:"H3"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH4?" is-active":""}`,onClick:()=>e.toggleHeading?.("h4"),disabled:!r,children:"H4"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH5?" is-active":""}`,onClick:()=>e.toggleHeading?.("h5"),disabled:!r,children:"H5"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isH6?" is-active":""}`,onClick:()=>e.toggleHeading?.("h6"),disabled:!r,children:"H6"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.unorderedList?" is-active":""}`,onClick:()=>e.toggleUnorderedList?.(),disabled:!r,children:"Bullet list"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.orderedList?" is-active":""}`,onClick:()=>e.toggleOrderedList?.(),disabled:!r,children:"Ordered list"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isInCodeBlock?" is-active":""}`,onClick:()=>e.toggleCodeBlock?.(),disabled:!r,children:"Code block"}),jsx("button",{type:"button",className:`luthor-preset-headless-editor__button${t.isQuote?" is-active":""}`,onClick:()=>e.toggleQuote?.(),disabled:!r,children:"Blockquote"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>e.insertHorizontalRule?.(),disabled:!r,children:"Horizontal rule"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:w,disabled:!r,children:"Hard break"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>e.undo?.(),disabled:!r||!t.canUndo,children:"Undo"}),jsx("button",{type:"button",className:"luthor-preset-headless-editor__button",onClick:()=>e.redo?.(),disabled:!r||!t.canRedo,children:"Redo"})]}),jsx("div",{className:`luthor-preset-headless-editor__visual-shell${r?"":" is-hidden"}`,"aria-hidden":!r,children:jsx(RichText,{placeholder:l.visual,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"}})}),!r&&jsxs("div",{className:"luthor-source-panel",children:[H&&H.mode===n&&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:me[n]}),jsx("p",{children:H.error}),jsx("small",{children:"Fix the source input and try again."})]})]}),n==="json"&&jsx(ga,{value:E.json,onChange:s=>{p(i=>({...i,json:s}));},placeholder:l.json}),n==="markdown"&&jsx(ga,{value:E.markdown,onChange:s=>{p(i=>({...i,markdown:s}));},placeholder:l.markdown,className:"luthor-source-view--wrapped",wrap:"soft"}),n==="html"&&jsx(ga,{value:E.html,onChange:s=>{p(i=>({...i,html:s}));},placeholder:l.html,className:"luthor-source-view--wrapped",wrap:"soft"})]})]})}var A=forwardRef(({className:a,variantClassName:l,initialTheme:d="light",onThemeChange:O,placeholder:e,onReady:h,defaultContent:b$1,showDefaultContent:n=true,initialMode:S="visual",defaultEditorView:E,featureFlags:p,...H},m)=>{let[v,t]=useState(d),g=E??S,L=X.includes(g)?g:"visual",T=useMemo(()=>ve(e),[e]),M=useMemo(()=>ge.resolve(p),[p]),C=useMemo(()=>JSON.stringify(M),[M]),D=useMemo(()=>{let u=JSON.parse(C);return sa({featureFlags:u})},[C]),[w,r]=useState(null),s=useRef(false);useEffect(()=>{t(d);},[d]),useEffect(()=>{O?.(v);},[v,O]),useImperativeHandle(m,()=>w??{injectJSON:()=>{},getJSON:()=>c("json",y),getMarkdown:()=>c("markdown",y),getHTML:()=>c("html",y)},[w]);let i=useCallback(u=>{r(u),s.current||(b$1?u.injectJSON(b$1):n&&u.injectJSON(c("json",pe)),s.current=true),h?.(u);},[b$1,h,n]);return jsx("div",{className:b("luthor-preset","luthor-preset-headless-editor","luthor-editor-wrapper","luthor-preset-headless-editor__variant",l,a),"data-editor-theme":v,children:jsx(ue,{extensions:D,children:jsx(Se,{initialMode:L,placeholders:T,onReady:i})})})});A.displayName="HeadlessEditorPreset";var He={id:"headless-editor",label:"Headless Editor",description:"Headless-style rich editor with text toolbar pills and source tabs.",extensions:sa({featureFlags:J}),components:{Editor:A},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{A as a,He as b};