nextext-editor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 NaveenChand
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface CodeBlockModalProps {
3
+ onInsert: (code: string, language: string) => void;
4
+ onClose: () => void;
5
+ }
6
+ export declare const CodeBlockModal: React.FC<CodeBlockModalProps>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ interface ColorPickerProps {
3
+ type: 'text' | 'highlight';
4
+ onColorSelect: (color: string) => void;
5
+ currentColor?: string;
6
+ }
7
+ export declare const ColorPicker: React.FC<ColorPickerProps>;
8
+ export {};
@@ -0,0 +1,38 @@
1
+ import { default as React } from 'react';
2
+ import { editorTokens } from '../lib/tokens';
3
+ export interface EditorProps {
4
+ /**
5
+ * Initial content (HTML string)
6
+ */
7
+ initialContent?: string;
8
+ /**
9
+ * Show preview panel
10
+ */
11
+ showPreview?: boolean;
12
+ /**
13
+ * Show toolbar
14
+ */
15
+ showToolbar?: boolean;
16
+ /**
17
+ * External content control (for controlled component)
18
+ */
19
+ externalContent?: string;
20
+ /**
21
+ * Content change handler (for controlled component)
22
+ */
23
+ onContentChange?: (content: string) => void;
24
+ /**
25
+ * Custom class name for container
26
+ */
27
+ className?: string;
28
+ /**
29
+ * Placeholder text
30
+ */
31
+ placeholder?: string;
32
+ /**
33
+ * Custom design tokens
34
+ */
35
+ tokens?: typeof editorTokens;
36
+ }
37
+ export declare const Editor: React.NamedExoticComponent<EditorProps>;
38
+ export default Editor;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ interface HeadingSelectorProps {
3
+ onSelect: (heading: 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6') => void;
4
+ currentHeading?: string;
5
+ }
6
+ export declare const HeadingSelector: React.FC<HeadingSelectorProps>;
7
+ export {};
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { MentionUser } from '../types/editor';
3
+ interface MentionDropdownProps {
4
+ users: MentionUser[];
5
+ selectedIndex: number;
6
+ onSelect: (user: MentionUser) => void;
7
+ position: {
8
+ top: number;
9
+ left: number;
10
+ };
11
+ query: string;
12
+ }
13
+ export declare const MentionDropdown: React.FC<MentionDropdownProps>;
14
+ export {};
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ import { PreviewMode } from '../types/editor';
3
+ interface PreviewProps {
4
+ content: string;
5
+ mode: PreviewMode;
6
+ onModeChange: (mode: PreviewMode) => void;
7
+ }
8
+ export declare const Preview: React.NamedExoticComponent<PreviewProps>;
9
+ export {};
@@ -0,0 +1,21 @@
1
+ import { default as React } from 'react';
2
+ export interface SlashCommand {
3
+ id: string;
4
+ label: string;
5
+ icon: React.ReactNode;
6
+ keywords: string[];
7
+ action: string;
8
+ }
9
+ interface SlashCommandMenuProps {
10
+ commands: SlashCommand[];
11
+ selectedIndex: number;
12
+ onSelect: (command: SlashCommand) => void;
13
+ position: {
14
+ top: number;
15
+ left: number;
16
+ };
17
+ query: string;
18
+ }
19
+ export declare const SlashCommandMenu: React.FC<SlashCommandMenuProps>;
20
+ export declare const defaultSlashCommands: SlashCommand[];
21
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { ToolbarAction, TextFormat } from '../types/editor';
3
+ import { editorTokens } from '../lib/tokens';
4
+ interface ToolbarProps {
5
+ onAction: (action: ToolbarAction, value?: string) => void;
6
+ currentFormat: TextFormat;
7
+ tokens?: typeof editorTokens;
8
+ }
9
+ export declare const Toolbar: React.NamedExoticComponent<ToolbarProps>;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { editorTokens } from '../../lib/tokens';
3
+ export interface EditorBlockProps {
4
+ content: string;
5
+ onContentChange: (content: string) => void;
6
+ placeholder?: string;
7
+ className?: string;
8
+ tokens?: typeof editorTokens;
9
+ }
10
+ export declare const EditorBlock: React.FC<EditorBlockProps>;
@@ -0,0 +1,2 @@
1
+ export { EditorBlock } from './EditorBlock';
2
+ export type { EditorBlockProps } from './EditorBlock';
@@ -0,0 +1,13 @@
1
+ import { Loro } from 'loro-crdt';
2
+ import { TextFormat } from '../types/editor';
3
+ export declare const useLoroEditor: () => {
4
+ content: string;
5
+ format: TextFormat;
6
+ updateContent: (newContent: string) => void;
7
+ insertText: (text: string, position?: number) => void;
8
+ deleteText: (start: number, length: number) => void;
9
+ applyFormat: (_start: number, _end: number, formatUpdate: TextFormat) => void;
10
+ getSnapshot: () => Uint8Array<ArrayBufferLike> | undefined;
11
+ loadSnapshot: (snapshot: Uint8Array) => void;
12
+ loroDoc: Loro | null;
13
+ };
@@ -0,0 +1,12 @@
1
+ export { Editor } from './components/Editor';
2
+ export { EditorBlock } from './components/block';
3
+ export type { EditorBlockProps } from './components/block';
4
+ export { Toolbar } from './components/Toolbar';
5
+ export { Preview } from './components/Preview';
6
+ export { ColorPicker } from './components/ColorPicker';
7
+ export { HeadingSelector } from './components/HeadingSelector';
8
+ export { useLoroEditor } from './hooks/useLoroEditor';
9
+ export type { TextFormat, EditorState, ToolbarAction, PreviewMode, } from './types/editor';
10
+ export { editorTokens } from './lib/tokens';
11
+ export type { EditorTokens } from './lib/tokens';
12
+ export { cn } from './lib/utils';
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import{jsxs as R,jsx as w}from"react/jsx-runtime";import at,{forwardRef as it,createElement as Ne,useState as Z,useRef as V,useEffect as le,memo as _e,useMemo as ce,useCallback as de}from"react";import{i as Y,_ as Po,a as lt,r as Fo,L as Me,E as Ho,A as Bo,U as Do,c as ct,__tla as Wo}from"./loro_wasm_bg-CrmHo0n8.js";let ue,dt,Ae,Se,ze,Re,Q,me,Te,Go=Promise.all([(()=>{try{return Wo}catch{}})()]).then(async()=>{const ut=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mt=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,o,r)=>r?r.toUpperCase():o.toLowerCase()),Ee=e=>{const t=mt(e);return t.charAt(0).toUpperCase()+t.slice(1)},je=(...e)=>e.filter((t,o,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===o).join(" ").trim(),pt=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var gt={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ft=it(({color:e="currentColor",size:t=24,strokeWidth:o=2,absoluteStrokeWidth:r,className:a="",children:s,iconNode:n,...i},l)=>Ne("svg",{ref:l,...gt,width:t,height:t,stroke:e,strokeWidth:r?Number(o)*24/Number(t):o,className:je("lucide",a),...!s&&!pt(i)&&{"aria-hidden":"true"},...i},[...n.map(([g,y])=>Ne(g,y)),...Array.isArray(s)?s:[s]])),C=(e,t)=>{const o=it(({className:r,...a},s)=>Ne(ft,{ref:s,iconNode:t,className:je(`lucide-${ut(Ee(e))}`,`lucide-${e}`,r),...a}));return o.displayName=Ee(e),o},bt=C("bold",[["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",key:"mg9rjx"}]]),ht=C("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),yt=C("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),xt=C("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),wt=C("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]),kt=C("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),vt=C("eye",[["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",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Ct=C("file-braces",[["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",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]]),Nt=C("file-code",[["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",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]),_t=C("file-text",[["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",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),Mt=C("highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["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",key:"14a9rk"}]]),At=C("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),St=C("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]),zt=C("list-ordered",[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["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",key:"xtkcd5"}]]),Rt=C("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]),Tt=C("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),Et=C("palette",[["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",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]),jt=C("quote",[["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",key:"rib7q0"}],["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",key:"1ymkrd"}]]),$t=C("redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]),Lt=C("remove-formatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]),Ot=C("strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]),It=C("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),Pt=C("text-align-center",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]]),Ft=C("text-align-end",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]]),Ht=C("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]),Bt=C("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]),Dt=C("undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]),Wt=["#000000","#FF0000","#00FF00","#0000FF","#FFFF00","#FF00FF","#00FFFF","#FFA500","#800080","#FFC0CB","#A52A2A","#808080","#FFFFFF","#FFD700","#4B0082","#00CED1"];ue=({type:e,onColorSelect:t,currentColor:o})=>{const[r,a]=Z(!1),[s,n]=Z("#000000"),i=V(null);le(()=>{const m=p=>{i.current&&!i.current.contains(p.target)&&a(!1)};return r&&document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[r]);const l=m=>{t(m),a(!1)},g=m=>{const p=m.target.value;n(p),t(p)};return R("div",{className:"relative",ref:i,children:[w("button",{type:"button",className:"flex items-center justify-center w-8 h-8 rounded transition-all duration-150 ease-in-out border border-transparent bg-transparent text-gray-700 hover:bg-gray-200 hover:border-gray-300 active:bg-blue-100 active:border-blue-400",onMouseDown:m=>{m.preventDefault(),a(!r)},title:e==="text"?"Text color":"Highlight color",children:w(e==="text"?Et:Mt,{size:16})}),r&&R("div",{className:"absolute top-full left-0 mt-1 bg-white rounded-lg shadow-lg border border-gray-200 p-3 z-50 w-64",children:[R("div",{className:"mb-3",children:[w("label",{className:"block text-xs font-semibold text-gray-700 mb-2",children:e==="text"?"Text Color":"Highlight Color"}),w("div",{className:"grid grid-cols-8 gap-2",children:Wt.map(m=>w("button",{type:"button",className:`w-6 h-6 rounded border-2 transition-all ${o===m?"border-blue-500 scale-110":"border-gray-300"}`,style:{backgroundColor:m},onMouseDown:p=>{p.preventDefault(),l(m)},title:m},m))})]}),R("div",{className:"border-t border-gray-200 pt-3",children:[w("label",{className:"block text-xs font-semibold text-gray-700 mb-2",children:"Custom Color"}),R("div",{className:"flex items-center gap-2",children:[w("input",{type:"color",value:s,onChange:g,className:"w-12 h-8 rounded border border-gray-300 cursor-pointer"}),w("input",{type:"text",value:s,onChange:m=>{const p=m.target.value;/^#[0-9A-Fa-f]{0,6}$/.test(p)&&(n(p),p.length===7&&t(p))},className:"flex-1 px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"#000000"})]})]}),e==="highlight"&&w("div",{className:"border-t border-gray-200 pt-3 mt-3",children:w("button",{type:"button",className:"w-full px-3 py-1.5 text-sm bg-gray-100 hover:bg-gray-200 rounded transition-colors",onMouseDown:m=>{m.preventDefault(),l("transparent")},children:"Remove Highlight"})})]})]})};const pe=[{value:"p",label:"Normal text",preview:"Paragraph",fontSize:"1em"},{value:"h1",label:"Heading 1",preview:"Heading 1",fontSize:"2em"},{value:"h2",label:"Heading 2",preview:"Heading 2",fontSize:"1.5em"},{value:"h3",label:"Heading 3",preview:"Heading 3",fontSize:"1.17em"},{value:"h4",label:"Heading 4",preview:"Heading 4",fontSize:"1em"},{value:"h5",label:"Heading 5",preview:"Heading 5",fontSize:"0.83em"},{value:"h6",label:"Heading 6",preview:"Heading 6",fontSize:"0.67em"}];Se=({onSelect:e,currentHeading:t="p"})=>{const[o,r]=Z(!1),a=V(null);le(()=>{const i=l=>{a.current&&!a.current.contains(l.target)&&r(!1)};return o&&document.addEventListener("mousedown",i),()=>{document.removeEventListener("mousedown",i)}},[o]);const s=i=>{e(i),r(!1)},n=pe.find(i=>i.value===t)||pe[0];return R("div",{className:"relative",ref:a,children:[R("button",{type:"button",className:"flex items-center gap-1 px-3 py-1.5 rounded transition-all duration-150 ease-in-out border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 hover:border-gray-400 min-w-[140px] justify-between",onMouseDown:i=>{i.preventDefault(),r(!o)},title:"Select text style",children:[w("span",{className:"text-sm font-medium",children:n.label}),w(ht,{size:14,className:`transition-transform ${o?"rotate-180":""}`})]}),o&&w("div",{className:"absolute top-full left-0 mt-1 bg-white rounded-lg shadow-lg border border-gray-200 py-1 z-50 min-w-[220px]",children:pe.map(i=>w("button",{type:"button",className:`w-full text-left px-4 py-2 transition-colors hover:bg-blue-50 ${t===i.value?"bg-blue-100":""}`,onMouseDown:l=>{l.preventDefault(),s(i.value)},children:R("div",{className:"flex items-baseline gap-3",children:[w("span",{className:"font-semibold",style:{fontSize:i.fontSize,lineHeight:"1.2"},children:i.preview}),w("span",{className:"text-xs text-gray-500 ml-auto",children:i.label})]})},i.value))})]})},Re=_e(({onAction:e,currentFormat:t})=>{const o=[{action:"undo",icon:Dt,title:"Undo (Ctrl+Z)"},{action:"redo",icon:$t,title:"Redo (Ctrl+Y)"},{divider:!0},{action:"bold",icon:bt,title:"Bold (Ctrl+B)",isActive:t.bold},{action:"italic",icon:St,title:"Italic (Ctrl+I)",isActive:t.italic},{action:"underline",icon:Bt,title:"Underline (Ctrl+U)",isActive:t.underline},{action:"strikethrough",icon:Ot,title:"Strikethrough",isActive:t.strikethrough},{action:"code",icon:xt,title:"Inline code"},{divider:!0},{action:"clearMarks",icon:kt,title:"Clear formatting"},{action:"clearNodes",icon:Lt,title:"Clear nodes"},{divider:!0},{action:"alignLeft",icon:Ht,title:"Align left"},{action:"alignCenter",icon:Pt,title:"Align center"},{action:"alignRight",icon:Ft,title:"Align right"},{divider:!0},{action:"bulletList",icon:Rt,title:"Bulleted list"},{action:"numberedList",icon:zt,title:"Numbered list"},{action:"codeBlock",icon:Nt,title:"Code block"},{action:"blockquote",icon:jt,title:"Blockquote"},{divider:!0},{action:"horizontalRule",icon:Tt,title:"Horizontal rule"},{action:"hardBreak",icon:wt,title:"Hard break"},{action:"image",icon:At,title:"Insert image"},{action:"table",icon:It,title:"Insert table"}],r=ce(()=>o.map((s,n)=>{if("divider"in s)return w("div",{className:"w-px h-6 bg-gray-300 mx-1"},`divider-${n}`);const i=s.icon;return w("button",{type:"button",className:`
2
+ flex items-center justify-center w-8 h-8 rounded
3
+ transition-all duration-150 ease-in-out
4
+ border border-transparent
5
+ ${s.isActive?"bg-blue-100 border-blue-400 text-blue-700":"bg-transparent text-gray-700 hover:bg-gray-200 hover:border-gray-300 active:bg-blue-100 active:border-blue-400"}
6
+ `,onMouseDown:l=>{l.preventDefault(),e(s.action)},title:s.title,children:w(i,{size:16})},s.action)}),[o,e]),a=s=>{e(s==="p"?"paragraph":s)};return R("div",{className:"flex items-center gap-1 px-3 py-2 bg-gray-50 border-b border-gray-200 rounded-t-lg flex-wrap shadow-sm",children:[r.slice(0,7),w(ue,{type:"text",onColorSelect:s=>e("textColor",s),currentColor:t.color}),w(ue,{type:"highlight",onColorSelect:s=>e("highlight",s),currentColor:t.backgroundColor}),w("div",{className:"w-px h-6 bg-gray-300 mx-1"}),w(Se,{onSelect:a}),r.slice(7)]})}),me={container:{base:"w-full bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden",focused:"ring-2 ring-blue-500/20 ring-offset-2"},editor:{container:"max-h-[600px] overflow-y-auto scroll-smooth",base:"min-h-[500px] p-8 focus:outline-none prose prose-base max-w-none text-gray-900 leading-relaxed",placeholder:"text-gray-400"},toolbar:{base:"flex flex-wrap items-center gap-1 px-4 py-3 border-b border-gray-200 bg-gray-50/50 backdrop-blur-sm",group:"flex items-center gap-1 px-1",separator:"w-px h-5 bg-gray-300 mx-2"},button:{base:"inline-flex items-center justify-center rounded-lg text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 disabled:pointer-events-none disabled:opacity-40",default:"h-9 px-3 bg-white hover:bg-blue-50 hover:text-blue-600 border border-gray-200",icon:"h-9 w-9 hover:bg-blue-50 hover:text-blue-600 text-gray-600",active:"bg-blue-100 text-blue-700 border-blue-200"},dropdown:{trigger:"inline-flex items-center justify-center rounded-lg text-sm font-medium h-9 px-3 hover:bg-blue-50 hover:text-blue-600 text-gray-700",content:"z-50 min-w-[10rem] overflow-hidden rounded-xl border border-gray-200 bg-white p-2 shadow-lg",item:"relative flex cursor-pointer select-none items-center rounded-lg px-3 py-2 text-sm outline-none transition-colors hover:bg-blue-50 hover:text-blue-600 text-gray-700"},colorPicker:{trigger:"h-9 w-9 rounded-lg border-2 border-gray-200 cursor-pointer hover:ring-2 hover:ring-blue-500/50 transition-all",popover:"rounded-xl border border-gray-200 bg-white p-4 shadow-lg",grid:"grid grid-cols-5 gap-2",swatch:"h-8 w-8 rounded-lg cursor-pointer hover:ring-2 hover:ring-blue-500/50 transition-all hover:scale-110"},stats:{container:"px-6 py-3 bg-gray-50/80 border-t border-gray-200 text-sm text-gray-600",item:"inline-flex items-center gap-1.5 font-medium"}};function $e(e){var t,o,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(o=$e(e[t]))&&(r&&(r+=" "),r+=o)}else for(o in e)e[o]&&(r&&(r+=" "),r+=o);return r}function Gt(){for(var e,t,o=0,r="",a=arguments.length;o<a;o++)(e=arguments[o])&&(t=$e(e))&&(r&&(r+=" "),r+=t);return r}const Vt=(e,t)=>{const o=new Array(e.length+t.length);for(let r=0;r<e.length;r++)o[r]=e[r];for(let r=0;r<t.length;r++)o[e.length+r]=t[r];return o},Ut=(e,t)=>({classGroupId:e,validator:t}),Le=(e=new Map,t=null,o)=>({nextPart:e,validators:t,classGroupId:o}),ee="-",Oe=[],qt="arbitrary..",Xt=e=>{const t=Yt(e),{conflictingClassGroups:o,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:n=>{if(n.startsWith("[")&&n.endsWith("]"))return Jt(n);const i=n.split(ee),l=i[0]===""&&i.length>1?1:0;return Ie(i,l,t)},getConflictingClassGroupIds:(n,i)=>{if(i){const l=r[n],g=o[n];return l?g?Vt(g,l):l:g||Oe}return o[n]||Oe}}},Ie=(e,t,o)=>{if(e.length-t===0)return o.classGroupId;const a=e[t],s=o.nextPart.get(a);if(s){const g=Ie(e,t+1,s);if(g)return g}const n=o.validators;if(n===null)return;const i=t===0?e.join(ee):e.slice(t).join(ee),l=n.length;for(let g=0;g<l;g++){const y=n[g];if(y.validator(i))return y.classGroupId}},Jt=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),o=t.indexOf(":"),r=t.slice(0,o);return r?qt+r:void 0})(),Yt=e=>{const{theme:t,classGroups:o}=e;return Kt(o,t)},Kt=(e,t)=>{const o=Le();for(const r in e){const a=e[r];ge(a,o,r,t)}return o},ge=(e,t,o,r)=>{const a=e.length;for(let s=0;s<a;s++){const n=e[s];Zt(n,t,o,r)}},Zt=(e,t,o,r)=>{if(typeof e=="string"){Qt(e,t,o);return}if(typeof e=="function"){eo(e,t,o,r);return}to(e,t,o,r)},Qt=(e,t,o)=>{const r=e===""?t:Pe(t,e);r.classGroupId=o},eo=(e,t,o,r)=>{if(oo(e)){ge(e(r),t,o,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ut(o,e))},to=(e,t,o,r)=>{const a=Object.entries(e),s=a.length;for(let n=0;n<s;n++){const[i,l]=a[n];ge(l,Pe(t,i),o,r)}},Pe=(e,t)=>{let o=e;const r=t.split(ee),a=r.length;for(let s=0;s<a;s++){const n=r[s];let i=o.nextPart.get(n);i||(i=Le(),o.nextPart.set(n,i)),o=i}return o},oo=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,ro=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,o=Object.create(null),r=Object.create(null);const a=(s,n)=>{o[s]=n,t++,t>e&&(t=0,r=o,o=Object.create(null))};return{get(s){let n=o[s];if(n!==void 0)return n;if((n=r[s])!==void 0)return a(s,n),n},set(s,n){s in o?o[s]=n:a(s,n)}}},fe="!",Fe=":",no=[],He=(e,t,o,r,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:o,maybePostfixModifierPosition:r,isExternal:a}),so=e=>{const{prefix:t,experimentalParseClassName:o}=e;let r=a=>{const s=[];let n=0,i=0,l=0,g;const y=a.length;for(let k=0;k<y;k++){const v=a[k];if(n===0&&i===0){if(v===Fe){s.push(a.slice(l,k)),l=k+1;continue}if(v==="/"){g=k;continue}}v==="["?n++:v==="]"?n--:v==="("?i++:v===")"&&i--}const b=s.length===0?a:a.slice(l);let m=b,p=!1;b.endsWith(fe)?(m=b.slice(0,-1),p=!0):b.startsWith(fe)&&(m=b.slice(1),p=!0);const N=g&&g>l?g-l:void 0;return He(s,p,m,N)};if(t){const a=t+Fe,s=r;r=n=>n.startsWith(a)?s(n.slice(a.length)):He(no,!1,n,void 0,!0)}if(o){const a=r;r=s=>o({className:s,parseClassName:a})}return r},ao=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((o,r)=>{t.set(o,1e6+r)}),o=>{const r=[];let a=[];for(let s=0;s<o.length;s++){const n=o[s],i=n[0]==="[",l=t.has(n);i||l?(a.length>0&&(a.sort(),r.push(...a),a=[]),r.push(n)):a.push(n)}return a.length>0&&(a.sort(),r.push(...a)),r}},io=e=>({cache:ro(e.cacheSize),parseClassName:so(e),sortModifiers:ao(e),...Xt(e)}),lo=/\s+/,co=(e,t)=>{const{parseClassName:o,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:s}=t,n=[],i=e.trim().split(lo);let l="";for(let g=i.length-1;g>=0;g-=1){const y=i[g],{isExternal:b,modifiers:m,hasImportantModifier:p,baseClassName:N,maybePostfixModifierPosition:k}=o(y);if(b){l=y+(l.length>0?" "+l:l);continue}let v=!!k,_=r(v?N.substring(0,k):N);if(!_){if(!v){l=y+(l.length>0?" "+l:l);continue}if(_=r(N),!_){l=y+(l.length>0?" "+l:l);continue}v=!1}const A=m.length===0?"":m.length===1?m[0]:s(m).join(":"),O=p?A+fe:A,j=O+_;if(n.indexOf(j)>-1)continue;n.push(j);const x=a(_,v);for(let M=0;M<x.length;++M){const z=x[M];n.push(O+z)}l=y+(l.length>0?" "+l:l)}return l},uo=(...e)=>{let t=0,o,r,a="";for(;t<e.length;)(o=e[t++])&&(r=Be(o))&&(a&&(a+=" "),a+=r);return a},Be=e=>{if(typeof e=="string")return e;let t,o="";for(let r=0;r<e.length;r++)e[r]&&(t=Be(e[r]))&&(o&&(o+=" "),o+=t);return o},mo=(e,...t)=>{let o,r,a,s;const n=l=>{const g=t.reduce((y,b)=>b(y),e());return o=io(g),r=o.cache.get,a=o.cache.set,s=i,i(l)},i=l=>{const g=r(l);if(g)return g;const y=co(l,o);return a(l,y),y};return s=n,(...l)=>s(uo(...l))},po=[],T=e=>{const t=o=>o[e]||po;return t.isThemeGetter=!0,t},De=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,We=/^\((?:(\w[\w-]*):)?(.+)\)$/i,go=/^\d+\/\d+$/,fo=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bo=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ho=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,yo=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,xo=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,U=e=>go.test(e),h=e=>!!e&&!Number.isNaN(Number(e)),H=e=>!!e&&Number.isInteger(Number(e)),be=e=>e.endsWith("%")&&h(e.slice(0,-1)),P=e=>fo.test(e),wo=()=>!0,ko=e=>bo.test(e)&&!ho.test(e),Ge=()=>!1,vo=e=>yo.test(e),Co=e=>xo.test(e),No=e=>!c(e)&&!d(e),_o=e=>q(e,Je,Ge),c=e=>De.test(e),W=e=>q(e,Ye,ko),he=e=>q(e,Ro,h),Ve=e=>q(e,qe,Ge),Mo=e=>q(e,Xe,Co),te=e=>q(e,Ke,vo),d=e=>We.test(e),K=e=>X(e,Ye),Ao=e=>X(e,To),Ue=e=>X(e,qe),So=e=>X(e,Je),zo=e=>X(e,Xe),oe=e=>X(e,Ke,!0),q=(e,t,o)=>{const r=De.exec(e);return r?r[1]?t(r[1]):o(r[2]):!1},X=(e,t,o=!1)=>{const r=We.exec(e);return r?r[1]?t(r[1]):o:!1},qe=e=>e==="position"||e==="percentage",Xe=e=>e==="image"||e==="url",Je=e=>e==="length"||e==="size"||e==="bg-size",Ye=e=>e==="length",Ro=e=>e==="number",To=e=>e==="family-name",Ke=e=>e==="shadow",Eo=mo(()=>{const e=T("color"),t=T("font"),o=T("text"),r=T("font-weight"),a=T("tracking"),s=T("leading"),n=T("breakpoint"),i=T("container"),l=T("spacing"),g=T("radius"),y=T("shadow"),b=T("inset-shadow"),m=T("text-shadow"),p=T("drop-shadow"),N=T("blur"),k=T("perspective"),v=T("aspect"),_=T("ease"),A=T("animate"),O=()=>["auto","avoid","all","avoid-page","page","left","right","column"],j=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],x=()=>[...j(),d,c],M=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto","contain","none"],u=()=>[d,c,l],S=()=>[U,"full","auto",...u()],D=()=>[H,"none","subgrid",d,c],L=()=>["auto",{span:["full",H,d,c]},H,d,c],re=()=>[H,"auto",d,c],et=()=>["auto","min","max","fr",d,c],ke=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],F=()=>["auto",...u()],G=()=>[U,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...u()],f=()=>[e,d,c],tt=()=>[...j(),Ue,Ve,{position:[d,c]}],ot=()=>["no-repeat",{repeat:["","x","y","space","round"]}],rt=()=>["auto","cover","contain",So,_o,{size:[d,c]}],ve=()=>[be,K,W],$=()=>["","none","full",g,d,c],I=()=>["",h,K,W],ne=()=>["solid","dashed","dotted","double"],nt=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],E=()=>[h,be,Ue,Ve],st=()=>["","none",N,d,c],se=()=>["none",h,d,c],ae=()=>["none",h,d,c],Ce=()=>[h,d,c],ie=()=>[U,"full",...u()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[P],breakpoint:[P],color:[wo],container:[P],"drop-shadow":[P],ease:["in","out","in-out"],font:[No],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[P],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[P],shadow:[P],spacing:["px",h],text:[P],"text-shadow":[P],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",U,c,d,v]}],container:["container"],columns:[{columns:[h,c,d,i]}],"break-after":[{"break-after":O()}],"break-before":[{"break-before":O()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:x()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:z()}],"overscroll-x":[{"overscroll-x":z()}],"overscroll-y":[{"overscroll-y":z()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:S()}],"inset-x":[{"inset-x":S()}],"inset-y":[{"inset-y":S()}],start:[{start:S()}],end:[{end:S()}],top:[{top:S()}],right:[{right:S()}],bottom:[{bottom:S()}],left:[{left:S()}],visibility:["visible","invisible","collapse"],z:[{z:[H,"auto",d,c]}],basis:[{basis:[U,"full","auto",i,...u()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[h,U,"auto","initial","none",c]}],grow:[{grow:["",h,d,c]}],shrink:[{shrink:["",h,d,c]}],order:[{order:[H,"first","last","none",d,c]}],"grid-cols":[{"grid-cols":D()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":re()}],"col-end":[{"col-end":re()}],"grid-rows":[{"grid-rows":D()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":re()}],"row-end":[{"row-end":re()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":et()}],"auto-rows":[{"auto-rows":et()}],gap:[{gap:u()}],"gap-x":[{"gap-x":u()}],"gap-y":[{"gap-y":u()}],"justify-content":[{justify:[...ke(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...ke()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":ke()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:u()}],px:[{px:u()}],py:[{py:u()}],ps:[{ps:u()}],pe:[{pe:u()}],pt:[{pt:u()}],pr:[{pr:u()}],pb:[{pb:u()}],pl:[{pl:u()}],m:[{m:F()}],mx:[{mx:F()}],my:[{my:F()}],ms:[{ms:F()}],me:[{me:F()}],mt:[{mt:F()}],mr:[{mr:F()}],mb:[{mb:F()}],ml:[{ml:F()}],"space-x":[{"space-x":u()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":u()}],"space-y-reverse":["space-y-reverse"],size:[{size:G()}],w:[{w:[i,"screen",...G()]}],"min-w":[{"min-w":[i,"screen","none",...G()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[n]},...G()]}],h:[{h:["screen","lh",...G()]}],"min-h":[{"min-h":["screen","lh","none",...G()]}],"max-h":[{"max-h":["screen","lh",...G()]}],"font-size":[{text:["base",o,K,W]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,d,he]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",be,c]}],"font-family":[{font:[Ao,c,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,d,c]}],"line-clamp":[{"line-clamp":[h,"none",d,he]}],leading:[{leading:[s,...u()]}],"list-image":[{"list-image":["none",d,c]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",d,c]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:f()}],"text-color":[{text:f()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:[h,"from-font","auto",d,W]}],"text-decoration-color":[{decoration:f()}],"underline-offset":[{"underline-offset":[h,"auto",d,c]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:u()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",d,c]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",d,c]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:tt()}],"bg-repeat":[{bg:ot()}],"bg-size":[{bg:rt()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},H,d,c],radial:["",d,c],conic:[H,d,c]},zo,Mo]}],"bg-color":[{bg:f()}],"gradient-from-pos":[{from:ve()}],"gradient-via-pos":[{via:ve()}],"gradient-to-pos":[{to:ve()}],"gradient-from":[{from:f()}],"gradient-via":[{via:f()}],"gradient-to":[{to:f()}],rounded:[{rounded:$()}],"rounded-s":[{"rounded-s":$()}],"rounded-e":[{"rounded-e":$()}],"rounded-t":[{"rounded-t":$()}],"rounded-r":[{"rounded-r":$()}],"rounded-b":[{"rounded-b":$()}],"rounded-l":[{"rounded-l":$()}],"rounded-ss":[{"rounded-ss":$()}],"rounded-se":[{"rounded-se":$()}],"rounded-ee":[{"rounded-ee":$()}],"rounded-es":[{"rounded-es":$()}],"rounded-tl":[{"rounded-tl":$()}],"rounded-tr":[{"rounded-tr":$()}],"rounded-br":[{"rounded-br":$()}],"rounded-bl":[{"rounded-bl":$()}],"border-w":[{border:I()}],"border-w-x":[{"border-x":I()}],"border-w-y":[{"border-y":I()}],"border-w-s":[{"border-s":I()}],"border-w-e":[{"border-e":I()}],"border-w-t":[{"border-t":I()}],"border-w-r":[{"border-r":I()}],"border-w-b":[{"border-b":I()}],"border-w-l":[{"border-l":I()}],"divide-x":[{"divide-x":I()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":I()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ne(),"hidden","none"]}],"divide-style":[{divide:[...ne(),"hidden","none"]}],"border-color":[{border:f()}],"border-color-x":[{"border-x":f()}],"border-color-y":[{"border-y":f()}],"border-color-s":[{"border-s":f()}],"border-color-e":[{"border-e":f()}],"border-color-t":[{"border-t":f()}],"border-color-r":[{"border-r":f()}],"border-color-b":[{"border-b":f()}],"border-color-l":[{"border-l":f()}],"divide-color":[{divide:f()}],"outline-style":[{outline:[...ne(),"none","hidden"]}],"outline-offset":[{"outline-offset":[h,d,c]}],"outline-w":[{outline:["",h,K,W]}],"outline-color":[{outline:f()}],shadow:[{shadow:["","none",y,oe,te]}],"shadow-color":[{shadow:f()}],"inset-shadow":[{"inset-shadow":["none",b,oe,te]}],"inset-shadow-color":[{"inset-shadow":f()}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:f()}],"ring-offset-w":[{"ring-offset":[h,W]}],"ring-offset-color":[{"ring-offset":f()}],"inset-ring-w":[{"inset-ring":I()}],"inset-ring-color":[{"inset-ring":f()}],"text-shadow":[{"text-shadow":["none",m,oe,te]}],"text-shadow-color":[{"text-shadow":f()}],opacity:[{opacity:[h,d,c]}],"mix-blend":[{"mix-blend":[...nt(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":nt()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[h]}],"mask-image-linear-from-pos":[{"mask-linear-from":E()}],"mask-image-linear-to-pos":[{"mask-linear-to":E()}],"mask-image-linear-from-color":[{"mask-linear-from":f()}],"mask-image-linear-to-color":[{"mask-linear-to":f()}],"mask-image-t-from-pos":[{"mask-t-from":E()}],"mask-image-t-to-pos":[{"mask-t-to":E()}],"mask-image-t-from-color":[{"mask-t-from":f()}],"mask-image-t-to-color":[{"mask-t-to":f()}],"mask-image-r-from-pos":[{"mask-r-from":E()}],"mask-image-r-to-pos":[{"mask-r-to":E()}],"mask-image-r-from-color":[{"mask-r-from":f()}],"mask-image-r-to-color":[{"mask-r-to":f()}],"mask-image-b-from-pos":[{"mask-b-from":E()}],"mask-image-b-to-pos":[{"mask-b-to":E()}],"mask-image-b-from-color":[{"mask-b-from":f()}],"mask-image-b-to-color":[{"mask-b-to":f()}],"mask-image-l-from-pos":[{"mask-l-from":E()}],"mask-image-l-to-pos":[{"mask-l-to":E()}],"mask-image-l-from-color":[{"mask-l-from":f()}],"mask-image-l-to-color":[{"mask-l-to":f()}],"mask-image-x-from-pos":[{"mask-x-from":E()}],"mask-image-x-to-pos":[{"mask-x-to":E()}],"mask-image-x-from-color":[{"mask-x-from":f()}],"mask-image-x-to-color":[{"mask-x-to":f()}],"mask-image-y-from-pos":[{"mask-y-from":E()}],"mask-image-y-to-pos":[{"mask-y-to":E()}],"mask-image-y-from-color":[{"mask-y-from":f()}],"mask-image-y-to-color":[{"mask-y-to":f()}],"mask-image-radial":[{"mask-radial":[d,c]}],"mask-image-radial-from-pos":[{"mask-radial-from":E()}],"mask-image-radial-to-pos":[{"mask-radial-to":E()}],"mask-image-radial-from-color":[{"mask-radial-from":f()}],"mask-image-radial-to-color":[{"mask-radial-to":f()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":j()}],"mask-image-conic-pos":[{"mask-conic":[h]}],"mask-image-conic-from-pos":[{"mask-conic-from":E()}],"mask-image-conic-to-pos":[{"mask-conic-to":E()}],"mask-image-conic-from-color":[{"mask-conic-from":f()}],"mask-image-conic-to-color":[{"mask-conic-to":f()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:tt()}],"mask-repeat":[{mask:ot()}],"mask-size":[{mask:rt()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",d,c]}],filter:[{filter:["","none",d,c]}],blur:[{blur:st()}],brightness:[{brightness:[h,d,c]}],contrast:[{contrast:[h,d,c]}],"drop-shadow":[{"drop-shadow":["","none",p,oe,te]}],"drop-shadow-color":[{"drop-shadow":f()}],grayscale:[{grayscale:["",h,d,c]}],"hue-rotate":[{"hue-rotate":[h,d,c]}],invert:[{invert:["",h,d,c]}],saturate:[{saturate:[h,d,c]}],sepia:[{sepia:["",h,d,c]}],"backdrop-filter":[{"backdrop-filter":["","none",d,c]}],"backdrop-blur":[{"backdrop-blur":st()}],"backdrop-brightness":[{"backdrop-brightness":[h,d,c]}],"backdrop-contrast":[{"backdrop-contrast":[h,d,c]}],"backdrop-grayscale":[{"backdrop-grayscale":["",h,d,c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h,d,c]}],"backdrop-invert":[{"backdrop-invert":["",h,d,c]}],"backdrop-opacity":[{"backdrop-opacity":[h,d,c]}],"backdrop-saturate":[{"backdrop-saturate":[h,d,c]}],"backdrop-sepia":[{"backdrop-sepia":["",h,d,c]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":u()}],"border-spacing-x":[{"border-spacing-x":u()}],"border-spacing-y":[{"border-spacing-y":u()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",d,c]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[h,"initial",d,c]}],ease:[{ease:["linear","initial",_,d,c]}],delay:[{delay:[h,d,c]}],animate:[{animate:["none",A,d,c]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,d,c]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:se()}],"rotate-x":[{"rotate-x":se()}],"rotate-y":[{"rotate-y":se()}],"rotate-z":[{"rotate-z":se()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[d,c,"","none","gpu","cpu"]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":["translate-none"],accent:[{accent:f()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:f()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",d,c]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":u()}],"scroll-mx":[{"scroll-mx":u()}],"scroll-my":[{"scroll-my":u()}],"scroll-ms":[{"scroll-ms":u()}],"scroll-me":[{"scroll-me":u()}],"scroll-mt":[{"scroll-mt":u()}],"scroll-mr":[{"scroll-mr":u()}],"scroll-mb":[{"scroll-mb":u()}],"scroll-ml":[{"scroll-ml":u()}],"scroll-p":[{"scroll-p":u()}],"scroll-px":[{"scroll-px":u()}],"scroll-py":[{"scroll-py":u()}],"scroll-ps":[{"scroll-ps":u()}],"scroll-pe":[{"scroll-pe":u()}],"scroll-pt":[{"scroll-pt":u()}],"scroll-pr":[{"scroll-pr":u()}],"scroll-pb":[{"scroll-pb":u()}],"scroll-pl":[{"scroll-pl":u()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",d,c]}],fill:[{fill:["none",...f()]}],"stroke-w":[{stroke:[h,K,W,he]}],stroke:[{stroke:["none",...f()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});Q=function(...e){return Eo(Gt(e))},Ae=({content:e,onContentChange:t,placeholder:o="Start typing...",className:r,tokens:a=me})=>{const s=V(null),n=V(!1),i=de(()=>{const b=window.getSelection();if(!b||!s.current||b.rangeCount===0)return null;try{const m=b.getRangeAt(0),p=m.cloneRange();return p.selectNodeContents(s.current),p.setEnd(m.endContainer,m.endOffset),p.toString().length}catch{return null}},[]),l=de(b=>{if(!s.current||b===null)return;const m=window.getSelection();if(!m)return;const p=(k,v)=>{if(v.count===0){const _=document.createRange();return _.setStart(k,0),_.setEnd(k,0),_}if(k.nodeType===Node.TEXT_NODE){const _=k;if(_.length>=v.count){const A=document.createRange();return A.setStart(k,v.count),A.setEnd(k,v.count),A}else v.count-=_.length}else for(let _=0;_<k.childNodes.length;_++){const A=p(k.childNodes[_],v);if(A)return A}return null},N=p(s.current,{count:b});N&&(m.removeAllRanges(),m.addRange(N))},[]),g=de(()=>{if(!s.current)return;n.current=!0;const b=s.current.innerHTML||"";t(b),setTimeout(()=>{n.current=!1},0)},[t]),y=de(b=>{var v,_,A,O;const m=window.getSelection();if(!m||m.rangeCount===0)return;const p=m.getRangeAt(0);let N=p.startContainer;N.nodeType===Node.TEXT_NODE&&(N=N.parentNode);let k=N;for(;k&&k!==s.current;){if(k.nodeName==="CODE"){const j=k;if(b.key==="ArrowRight"&&p.endOffset===(((v=p.endContainer.textContent)==null?void 0:v.length)||0)){b.preventDefault();const x=document.createRange();if(j.nextSibling)x.setStart(j.nextSibling,0);else{const M=document.createTextNode("\u200B");(_=j.parentNode)==null||_.insertBefore(M,j.nextSibling),x.setStart(M,0)}x.collapse(!0),m.removeAllRanges(),m.addRange(x);return}if(b.key==="ArrowLeft"&&p.startOffset===0){b.preventDefault();const x=document.createRange();if(j.previousSibling){const M=j.previousSibling;x.setStart(M,((A=M.textContent)==null?void 0:A.length)||0)}else{const M=document.createTextNode("\u200B");(O=j.parentNode)==null||O.insertBefore(M,j),x.setStart(M,0)}x.collapse(!0),m.removeAllRanges(),m.addRange(x);return}break}k=k.parentNode}},[]);return le(()=>{if(!s.current||n.current)return;const b=i();s.current.innerHTML!==e&&(s.current.innerHTML=e,b!==null&&l(b))},[e,i,l]),w("div",{className:Q(a.editor.container,"editor-scroll-container"),"data-editor-scroll-container":!0,children:w("div",{ref:s,contentEditable:!0,onInput:g,onKeyDown:y,className:Q(a.editor.base,r),suppressContentEditableWarning:!0,spellCheck:!0,"data-placeholder":o})})},ze=_e(({content:e,mode:t,onModeChange:o})=>{const r=ce(()=>{const n=document.createElement("div");return n.innerHTML=e,n.textContent||""},[e]),a=ce(()=>{const n=document.createElement("div");n.innerHTML=e;const i=g=>{if(g.nodeType===Node.TEXT_NODE)return{type:"text",content:g.textContent};if(g.nodeType===Node.ELEMENT_NODE){const y=g,b=Array.from(y.childNodes).map(i);return{type:"element",tag:y.tagName.toLowerCase(),attributes:Array.from(y.attributes).reduce((m,p)=>(m[p.name]=p.value,m),{}),children:b.length>0?b:void 0}}return null},l=Array.from(n.childNodes).map(i).filter(Boolean);return JSON.stringify(l,null,2)},[e]),s=ce(()=>{switch(t){case"html":return e;case"text":return r;case"json":return a;default:return e}},[t,e,r,a]);return R("div",{className:"w-full bg-white rounded-lg shadow-lg border border-gray-200 mt-8",children:[R("div",{className:"flex items-center gap-2 px-4 py-3 bg-gray-50 border-b border-gray-200 rounded-t-lg",children:[w(vt,{size:18,className:"text-gray-600"}),w("span",{className:"font-semibold text-gray-700",children:"Preview"}),R("div",{className:"ml-auto flex gap-2",children:[R("button",{onClick:()=>o("html"),className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm transition-all ${t==="html"?"bg-blue-500 text-white":"bg-white text-gray-600 hover:bg-gray-100 border border-gray-300"}`,children:[w(yt,{size:14}),"HTML"]}),R("button",{onClick:()=>o("text"),className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm transition-all ${t==="text"?"bg-blue-500 text-white":"bg-white text-gray-600 hover:bg-gray-100 border border-gray-300"}`,children:[w(_t,{size:14}),"Text"]}),R("button",{onClick:()=>o("json"),className:`flex items-center gap-1 px-3 py-1.5 rounded text-sm transition-all ${t==="json"?"bg-blue-500 text-white":"bg-white text-gray-600 hover:bg-gray-100 border border-gray-300"}`,children:[w(Ct,{size:14}),"JSON"]})]})]}),w("div",{className:"p-4",children:w("pre",{className:"bg-gray-50 p-4 rounded-md border border-gray-200 overflow-x-auto text-sm font-mono whitespace-pre-wrap break-words max-h-96 overflow-y-auto",children:s})})]})});const B=(e=>!e||e instanceof WebAssembly.Module?e:typeof e=="object"&&"default"in e?e.default??e:e)(Fo),ye=e=>{Po(e),typeof lt=="function"&&lt(),jo(Y)};function jo(e){typeof e.__wbindgen_start=="function"&&e.__wbindgen_start()}if(B&&B.__wbindgen_start)ye(B);else if("Bun"in globalThis){let e;if(B instanceof WebAssembly.Module)({instance:e}=await WebAssembly.instantiate(B,{"./loro_wasm_bg.js":Y}));else{const t=Bun.pathToFileURL(B);({instance:e}=await WebAssembly.instantiateStreaming(fetch(t),{"./loro_wasm_bg.js":Y}))}ye(e.exports)}else{const e=B instanceof WebAssembly.Module?B:await import("./loro_wasm_bg-CrmHo0n8.js").then(async r=>(await r.__tla,r)).then(r=>r.r),t=e instanceof WebAssembly.Module?e:e&&e.default||e;let o;if(t instanceof WebAssembly.Instance)o=t;else if(t instanceof WebAssembly.Module)o=await WebAssembly.instantiate(t,{"./loro_wasm_bg.js":Y});else if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){const{instance:r}=await WebAssembly.instantiate(t,{"./loro_wasm_bg.js":Y});o=r}else if(typeof t=="string"||t instanceof URL){const r=await fetch(t),{instance:a}=await WebAssembly.instantiateStreaming(r,{"./loro_wasm_bg.js":Y});o=a}else throw console.error("Unsupported wasm import type:",t),new Error("Unsupported wasm import type: "+typeof t);ye(o.exports??o)}class $o extends Me{}const Lo=["Map","Text","List","Tree","MovableList","Counter"];function Oo(e){return e.startsWith("cid:")}function Ze(e){if(typeof e!="object"||e==null)return!1;const t=Object.getPrototypeOf(e);return t==null||typeof t!="object"||typeof t.kind!="function"?!1:Lo.includes(e.kind())}Me.prototype.toJsonWithReplacer=function(e){const t=new Set,o=this,r=(n,i)=>{if(typeof i=="string"&&Oo(i)&&!t.has(i)){t.add(i);const g=o.getContainerById(i);if(g==null)throw new Error(`ContainerID not found: ${i}`);const y=e(n,g);if(y===g){const b=g.getShallowValue();return typeof b=="object"?a(b):b}if(Ze(y))throw new Error("Using new container is not allowed in toJsonWithReplacer");return typeof y=="object"&&y!=null?a(y):y}if(typeof i=="object"&&i!=null)return a(i);const l=e(n,i);if(Ze(l))throw new Error("Using new container is not allowed in toJsonWithReplacer");return l},a=n=>{if(Array.isArray(n))return n.map((l,g)=>r(g,l)).filter(l=>l!==void 0);const i={};for(const[l,g]of Object.entries(n)){const y=r(l,g);y!==void 0&&(i[l]=y)}return i},s=o.getShallowValue();return a(s)};const Qe=Symbol("loro.callPendingEventsWrapped");function xe(e,t){const o=Object.getOwnPropertyDescriptor(e,t);if(!o||typeof o.value!="function")return;const r=o.value;if(r[Qe])return;const a=function(...s){let n;try{return n=r.apply(this,s),n}finally{n&&typeof n.then=="function"?n.finally(()=>{ct()}):ct()}};a[Qe]=!0,Object.defineProperty(e,t,{...o,value:a})}function Io(e,t){for(const o of t)xe(e,o)}function we(e){const t=new Set;let o=e;for(;o&&o!==Object.prototype&&o!==Function.prototype;){for(const r of Object.getOwnPropertyNames(o))r==="constructor"||t.has(r)||(t.add(r),xe(o,r));for(const r of Object.getOwnPropertySymbols(o))t.has(r)||(t.add(r),xe(o,r));o=Object.getPrototypeOf(o)}}we(Me.prototype),we(Ho.prototype),we(Bo.prototype),Io(Do.prototype,["undo","redo"]),Te=()=>{const e=V(null),t=V(null),[o,r]=Z(""),[a,s]=Z({}),n=V(!1);return le(()=>{e.current=new $o,t.current=e.current.getText("content");const p=e.current.subscribe(()=>{t.current&&!n.current&&r(t.current.toString())});return()=>{p()}},[]),{content:o,format:a,updateContent:p=>{if(!t.current||!e.current)return;n.current=!0;const N=t.current.length;N>0&&t.current.delete(0,N),p&&t.current.insert(0,p),e.current.commit(),r(p),n.current=!1},insertText:(p,N)=>{var v;if(!t.current)return;const k=N??t.current.length;t.current.insert(k,p),(v=e.current)==null||v.commit()},deleteText:(p,N)=>{var k;t.current&&(t.current.delete(p,N),(k=e.current)==null||k.commit())},applyFormat:(p,N,k)=>{s(v=>({...v,...k}))},getSnapshot:()=>{var p;return(p=e.current)==null?void 0:p.export({mode:"snapshot"})},loadSnapshot:p=>{e.current&&e.current.import(p)},loroDoc:e.current}},dt=_e(({showPreview:e=!1,showToolbar:t=!0,externalContent:o,onContentChange:r,className:a,placeholder:s="Start typing...",tokens:n=me})=>{const i=Te(),[l,g]=at.useState("html"),[y,b]=at.useState({}),m=o!==void 0?o:i.content,p=r!==void 0?r:i.updateContent,N=(k,v)=>{var _;switch(k){case"bold":document.execCommand("bold"),b(x=>({...x,bold:!x.bold}));break;case"italic":document.execCommand("italic"),b(x=>({...x,italic:!x.italic}));break;case"underline":document.execCommand("underline"),b(x=>({...x,underline:!x.underline}));break;case"strikethrough":document.execCommand("strikeThrough"),b(x=>({...x,strikethrough:!x.strikethrough}));break;case"code":const A=window.getSelection();if(A&&A.rangeCount>0){const x=A.getRangeAt(0),M=x.toString();if(M){const z=document.createElement("code");z.className="px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono text-sm",z.textContent=M,x.deleteContents(),x.insertNode(z);const u=document.createTextNode("\u200B");(_=z.parentNode)==null||_.insertBefore(u,z.nextSibling);const S=document.createRange();S.setStartAfter(z),S.collapse(!0),A.removeAllRanges(),A.addRange(S)}else{let z=x.startContainer;z.nodeType===Node.TEXT_NODE&&(z=z.parentNode);let u=null,S=z;for(;S&&S!==document.body;){if(S.nodeName==="CODE"){u=S;break}S=S.parentNode}if(u&&u.parentNode){const D=document.createTextNode(u.textContent||"");u.parentNode.replaceChild(D,u);const L=document.createRange();L.setStartAfter(D),L.collapse(!0),A.removeAllRanges(),A.addRange(L)}}}break;case"textColor":v&&(document.execCommand("foreColor",!1,v),b(x=>({...x,color:v})));break;case"highlight":v&&(document.execCommand("hiliteColor",!1,v),b(x=>({...x,backgroundColor:v})));break;case"clearMarks":document.execCommand("removeFormat"),b({});break;case"clearNodes":document.execCommand("formatBlock",!1,"p");break;case"paragraph":document.execCommand("formatBlock",!1,"p");break;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":document.execCommand("formatBlock",!1,k);break;case"bulletList":document.execCommand("insertUnorderedList");break;case"numberedList":document.execCommand("insertOrderedList");break;case"codeBlock":document.execCommand("formatBlock",!1,"pre");break;case"blockquote":document.execCommand("formatBlock",!1,"blockquote");break;case"horizontalRule":document.execCommand("insertHorizontalRule");break;case"hardBreak":document.execCommand("insertLineBreak");break;case"image":const O=document.createElement("input");O.type="file",O.accept="image/png,image/jpeg,image/gif,image/webp,image/svg+xml",O.onchange=async x=>{var z;const M=(z=x.target.files)==null?void 0:z[0];if(M){if(M.size>5*1024*1024){alert("Image size must be less than 5MB");return}try{const u=new FileReader;u.onloadend=()=>{const S=u.result;document.execCommand("insertImage",!1,S),setTimeout(()=>{const D=document.querySelectorAll(".hyper-editor [contenteditable] img"),L=D[D.length-1];L&&!L.classList.contains("editor-image")&&(L.classList.add("editor-image"),L.style.maxWidth="100%",L.style.height="auto",L.style.borderRadius="0.5rem",L.style.margin="1rem 0")},10)},u.onerror=()=>{alert("Failed to read image file")},u.readAsDataURL(M)}catch(u){console.error("Image upload failed:",u),alert("Failed to upload image")}}},O.click();break;case"table":const j=`
7
+ <table style="border-collapse: collapse; width: 100%; margin: 1em 0;">
8
+ <tbody>
9
+ <tr>
10
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem; min-width: 100px;">Cell 1</td>
11
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem; min-width: 100px;">Cell 2</td>
12
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem; min-width: 100px;">Cell 3</td>
13
+ </tr>
14
+ <tr>
15
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem;">Cell 4</td>
16
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem;">Cell 5</td>
17
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem;">Cell 6</td>
18
+ </tr>
19
+ <tr>
20
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem;">Cell 7</td>
21
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem;">Cell 8</td>
22
+ <td style="border: 1px solid #e5e7eb; padding: 0.5rem;">Cell 9</td>
23
+ </tr>
24
+ </tbody>
25
+ </table>
26
+ <p><br></p>
27
+ `.trim();document.execCommand("insertHTML",!1,j);break;case"undo":document.execCommand("undo");break;case"redo":document.execCommand("redo");break}};return R("div",{className:Q("hyper-editor",a),children:[R("div",{className:n.container.base,children:[t&&w(Re,{onAction:N,currentFormat:y,tokens:n}),w(Ae,{content:m,onContentChange:p,placeholder:s,tokens:n}),w("div",{className:n.stats.container,children:w("div",{className:"flex justify-between items-center",children:R("div",{className:"flex gap-4",children:[R("span",{className:n.stats.item,children:["Characters: ",m.replace(/<[^>]*>/g,"").length]}),R("span",{className:n.stats.item,children:["Words: ",m.replace(/<[^>]*>/g,"").trim().split(/\s+/).filter(Boolean).length]})]})})})]}),e&&w("div",{className:"mt-8",children:w(ze,{content:m,mode:l,onModeChange:g})})]})})});export{ue as ColorPicker,dt as Editor,Ae as EditorBlock,Se as HeadingSelector,ze as Preview,Re as Toolbar,Go as __tla,Q as cn,me as editorTokens,Te as useLoroEditor};