eddyter 1.3.37 → 1.3.38

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.
Files changed (237) hide show
  1. package/README.md +483 -444
  2. package/dist/App.d.ts +3 -2
  3. package/dist/Provider/EditorProvider.d.ts +32 -26
  4. package/dist/Provider/LexicalProvider.d.ts +6 -5
  5. package/dist/api/ai/index.d.ts +32 -31
  6. package/dist/api/auth.d.ts +108 -108
  7. package/dist/api/config/axios.d.ts +2 -1
  8. package/dist/api/config/endpoints.d.ts +22 -22
  9. package/dist/api/featureSuggestion.d.ts +23 -23
  10. package/dist/api/linkPreview.d.ts +15 -15
  11. package/dist/api/transcript/index.d.ts +21 -21
  12. package/dist/assets/style.css +5284 -5362
  13. package/dist/{babel-d3085146.js → babel-d155920e.js} +3278 -3551
  14. package/dist/babel-d155920e.js.map +1 -0
  15. package/dist/components/AiPlugin/index.d.ts +6 -6
  16. package/dist/components/AlignMenu/AlignMenu.d.ts +9 -8
  17. package/dist/components/AlignMenu/AlignMenuDrop.d.ts +3 -2
  18. package/dist/components/AlignMenu/index.d.ts +1 -1
  19. package/dist/components/AutoExpandingDemo.d.ts +6 -5
  20. package/dist/components/BlockFormatMenu/BlockFormatMenu.d.ts +3 -2
  21. package/dist/components/BlockFormatMenu/constants.d.ts +14 -14
  22. package/dist/components/BlockFormatMenu/index.d.ts +1 -1
  23. package/dist/components/ChartEditDialog.d.ts +9 -8
  24. package/dist/components/ChartInsertDialog.d.ts +8 -7
  25. package/dist/components/CodeActionMenuPlugin/components/CopyButton/index.d.ts +7 -6
  26. package/dist/components/CodeActionMenuPlugin/components/PrettierButton/index.d.ts +9 -8
  27. package/dist/components/CodeActionMenuPlugin/index.d.ts +5 -4
  28. package/dist/components/CodeActionMenuPlugin/utils.d.ts +1 -1
  29. package/dist/components/ColorPicker/ColorPicker.d.ts +3 -2
  30. package/dist/components/ColorPicker/index.d.ts +1 -1
  31. package/dist/components/CommentSidebar/CommentSidebar.d.ts +8 -7
  32. package/dist/components/CommentSidebar/index.d.ts +1 -1
  33. package/dist/components/CommentToggle/CommentToggle.d.ts +8 -7
  34. package/dist/components/CommentToggle/index.d.ts +1 -1
  35. package/dist/components/CommentView/CommentView.d.ts +9 -8
  36. package/dist/components/CommentView/index.d.ts +1 -1
  37. package/dist/components/ConfigurableEditorWithAuth.d.ts +35 -22
  38. package/dist/components/ContentPreview/index.d.ts +38 -0
  39. package/dist/components/DatePicker/DatePickerWidget.d.ts +7 -6
  40. package/dist/components/EmojiPickerWidget/EmojiPickerWidget.d.ts +3 -2
  41. package/dist/components/EmojiPickerWidget/index.d.ts +1 -1
  42. package/dist/components/FeatureSuggestionDialog/index.d.ts +6 -6
  43. package/dist/components/FileUpload/InsertFileDialog.d.ts +7 -7
  44. package/dist/components/FileUpload/InsertFileUploadedDialogBody.d.ts +5 -4
  45. package/dist/components/FileView/index.d.ts +9 -8
  46. package/dist/components/FontFamilySelect/FontFamilyMenu.d.ts +7 -6
  47. package/dist/components/FontSizePicker/FontSizeControl.d.ts +3 -2
  48. package/dist/components/FormatTextMenu/FormatTextMenu.d.ts +3 -2
  49. package/dist/components/FormatTextMenu/FormatTextMenuDrop.d.ts +3 -2
  50. package/dist/components/FormatTextMenu/index.d.ts +1 -1
  51. package/dist/components/HighlightColorPicker/HighlightColorPicker.d.ts +7 -6
  52. package/dist/components/HtmlViewDisplay.d.ts +3 -2
  53. package/dist/components/ImageComparisonDialog/index.d.ts +11 -10
  54. package/dist/components/ImageGenerationDialog/ImageGenerationManager.d.ts +11 -10
  55. package/dist/components/ImageGenerationDialog/index.d.ts +11 -10
  56. package/dist/components/ImageInsertTest.d.ts +3 -2
  57. package/dist/components/ImageView/ImageDialog/ImageUploadDialogBody.d.ts +9 -8
  58. package/dist/components/ImageView/ImageDialog/index.d.ts +6 -5
  59. package/dist/components/ImageView/ImageResizer.d.ts +16 -15
  60. package/dist/components/ImageView/index.d.ts +17 -16
  61. package/dist/components/InsertMenu/InsertMenu.d.ts +9 -8
  62. package/dist/components/InsertMenu/InsertMenuDrop.d.ts +9 -8
  63. package/dist/components/InsertMenu/index.d.ts +1 -1
  64. package/dist/components/LanguageSelectorDialog/index.d.ts +8 -7
  65. package/dist/components/LinkPreviewHover/index.d.ts +40 -0
  66. package/dist/components/NotePanelMenu/NotePanelMenu.d.ts +6 -5
  67. package/dist/components/NotePanelMenu/index.d.ts +1 -1
  68. package/dist/components/NotePanelView/NotePanelView.d.ts +9 -8
  69. package/dist/components/NotePanelView/index.d.ts +1 -1
  70. package/dist/components/Placeholder/Placeholder.d.ts +3 -2
  71. package/dist/components/Placeholder/index.d.ts +1 -1
  72. package/dist/components/Placeholder/styles.d.ts +1 -1
  73. package/dist/components/ScopedEditor.d.ts +8 -8
  74. package/dist/components/SignatureCaption/index.d.ts +6 -5
  75. package/dist/components/TableColorPicker/index.d.ts +8 -7
  76. package/dist/components/TableModal/TableModal.d.ts +10 -9
  77. package/dist/components/TextEnhanceDialog/index.d.ts +10 -9
  78. package/dist/components/ToneAdjustDialog/index.d.ts +8 -7
  79. package/dist/components/Toolbar/Toolbar.d.ts +3 -2
  80. package/dist/components/Toolbar/index.d.ts +1 -1
  81. package/dist/components/Toolbar/styles.d.ts +6 -6
  82. package/dist/components/VoiceTranscriptIcon/VoiceTranscriptIcon.d.ts +2 -1
  83. package/dist/components/VoiceTranscriptIcon/index.d.ts +1 -1
  84. package/dist/components/ui/avatar.d.ts +6 -6
  85. package/dist/components/ui/badge.d.ts +9 -8
  86. package/dist/components/ui/button.d.ts +11 -10
  87. package/dist/components/ui/calendar.d.ts +8 -7
  88. package/dist/components/ui/card.d.ts +8 -8
  89. package/dist/components/ui/checkbox.d.ts +4 -4
  90. package/dist/components/ui/dialog.d.ts +19 -19
  91. package/dist/components/ui/dropdown-menu.d.ts +27 -27
  92. package/dist/components/ui/input.d.ts +3 -3
  93. package/dist/components/ui/label.d.ts +4 -4
  94. package/dist/components/ui/popover.d.ts +7 -7
  95. package/dist/components/ui/select.d.ts +13 -13
  96. package/dist/components/ui/separator.d.ts +4 -4
  97. package/dist/components/ui/sheet.d.ts +24 -24
  98. package/dist/components/ui/skeleton.d.ts +3 -3
  99. package/dist/components/ui/tabs.d.ts +7 -7
  100. package/dist/components/ui/textarea.d.ts +3 -3
  101. package/dist/components/ui/tooltip.d.ts +7 -7
  102. package/dist/constants.d.ts +22 -21
  103. package/dist/context/CommentContext.d.ts +43 -42
  104. package/dist/context/HtmlViewContext.d.ts +17 -16
  105. package/dist/context/ToolbarContext.d.ts +56 -55
  106. package/dist/editorConfig.d.ts +48 -48
  107. package/dist/{estree-164983f6.js → estree-b1fff53b.js} +1778 -1763
  108. package/dist/estree-b1fff53b.js.map +1 -0
  109. package/dist/hooks/useAutoExpandingHeight.d.ts +15 -15
  110. package/dist/hooks/useBlockFormat.d.ts +17 -16
  111. package/dist/hooks/useColorPicker.d.ts +6 -6
  112. package/dist/hooks/useCustomCommands.d.ts +3 -2
  113. package/dist/hooks/useDebounce.d.ts +1 -1
  114. package/dist/hooks/useEditorToolbar.d.ts +10 -9
  115. package/dist/hooks/useInsertMenu.d.ts +9 -9
  116. package/dist/hooks/useModal.d.ts +5 -5
  117. package/dist/hooks/useReactNativeBridge.d.ts +54 -54
  118. package/dist/hooks/useS3Uploader.d.ts +11 -11
  119. package/dist/hooks/useVoiceToText.d.ts +20 -20
  120. package/dist/{html-5586dbf6.js → html-f95ee5dc.js} +656 -701
  121. package/dist/html-f95ee5dc.js.map +1 -0
  122. package/dist/{html2pdf.bundle-d4225b87.js → html2pdf.bundle-d21122e4.js} +2 -2
  123. package/dist/html2pdf.bundle-d21122e4.js.map +1 -0
  124. package/dist/{html2pdf.bundle.min-4f1c3930.js → html2pdf.bundle.min-d6fba18e.js} +2 -2
  125. package/dist/html2pdf.bundle.min-d6fba18e.js.map +1 -0
  126. package/dist/{index-6717344b.js → index-0bc350db.js} +1475 -1537
  127. package/dist/index-0bc350db.js.map +1 -0
  128. package/dist/{index-35336e5d.js → index-39c10e00.js} +3 -3
  129. package/dist/index-39c10e00.js.map +1 -0
  130. package/dist/{index-da40f793.js → index-f51de846.js} +3 -3
  131. package/dist/index-f51de846.js.map +1 -0
  132. package/dist/index.d.ts +14 -10
  133. package/dist/index.js +7 -5
  134. package/dist/lib/utils.d.ts +2 -1
  135. package/dist/main.d.ts +1 -0
  136. package/dist/{markdown-d513479b.js → markdown-1d9e6c3f.js} +1789 -1836
  137. package/dist/markdown-1d9e6c3f.js.map +1 -0
  138. package/dist/nodes/ChartNode.d.ts +41 -40
  139. package/dist/nodes/CommentNode.d.ts +34 -33
  140. package/dist/nodes/CommentedTextNode.d.ts +29 -28
  141. package/dist/nodes/EmbedNode.d.ts +32 -31
  142. package/dist/nodes/FileNode.d.ts +32 -31
  143. package/dist/nodes/ImageNode.d.ts +65 -64
  144. package/dist/nodes/MentionNode.d.ts +75 -74
  145. package/dist/nodes/NotePanelNode.d.ts +31 -30
  146. package/dist/pages/ConfigurableEditor/ConfigurableEditor.d.ts +25 -24
  147. package/dist/pages/ConfigurableEditor/index.d.ts +2 -2
  148. package/dist/pages/NotFound.d.ts +2 -2
  149. package/dist/pages/RichTextEditor.d.ts +6 -6
  150. package/dist/pages/TextareaEditor.d.ts +6 -6
  151. package/dist/pages/styles.d.ts +5 -5
  152. package/dist/plugins/AIChatPlugin.d.ts +11 -10
  153. package/dist/plugins/AndroidKeyboardFixPlugin.d.ts +16 -16
  154. package/dist/plugins/AutocompletePlugin.d.ts +22 -22
  155. package/dist/plugins/CodeBlockNormalizerPlugin.d.ts +8 -8
  156. package/dist/plugins/CodeBlockSelectAllPlugin.d.ts +8 -8
  157. package/dist/plugins/CodeHighlightPlugin.d.ts +3 -2
  158. package/dist/plugins/CombinedAutocompletGrammarPlugin.d.ts +21 -20
  159. package/dist/plugins/CommentBubblePlugin.d.ts +3 -2
  160. package/dist/plugins/CommentPlugin.d.ts +7 -6
  161. package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRuleNode.d.ts +29 -28
  162. package/dist/plugins/CustomHorizontalRulePlugin/CustomHorizontalRulePlugin.d.ts +3 -3
  163. package/dist/plugins/CustomHorizontalRulePlugin/HorizontalRuleCustomizationDialog.d.ts +7 -6
  164. package/dist/plugins/CustomHorizontalRulePlugin/index.d.ts +3 -3
  165. package/dist/plugins/DragDropPastePlugin/index.d.ts +8 -8
  166. package/dist/plugins/EmbedPreviewPlugin/FloatingEmbedMenuPlugin.d.ts +4 -3
  167. package/dist/plugins/EmbedPreviewPlugin/index.d.ts +6 -5
  168. package/dist/plugins/FilePlugin.d.ts +8 -7
  169. package/dist/plugins/FloatingLinkEditorPlugin/index.d.ts +6 -5
  170. package/dist/plugins/FloatingTextFormatToolbarPlugin/index.d.ts +27 -26
  171. package/dist/plugins/GrammarCheckPlugin.d.ts +2 -1
  172. package/dist/plugins/HtmlCodeViewPlugin/index.d.ts +2 -2
  173. package/dist/plugins/HtmlImportPlugin.d.ts +5 -5
  174. package/dist/plugins/HtmlSyncPlugin.d.ts +3 -3
  175. package/dist/plugins/ImagePlugin.d.ts +7 -6
  176. package/dist/plugins/LinkPlugin/index.d.ts +6 -5
  177. package/dist/plugins/LinkPreviewPlugin/index.d.ts +4 -4
  178. package/dist/plugins/LocalStoragePlugin.d.ts +7 -6
  179. package/dist/plugins/MarkdownShortcutsPlugin/index.d.ts +20 -20
  180. package/dist/plugins/MentionsPlugin/index.d.ts +7 -6
  181. package/dist/plugins/NotePanelPlugin.d.ts +7 -6
  182. package/dist/plugins/PasteOptionsPlugin/index.d.ts +17 -17
  183. package/dist/plugins/RichTextPastePlugin/index.d.ts +6 -5
  184. package/dist/plugins/SignatureCanvasPlugin/SignatureCanvasDialog.d.ts +6 -5
  185. package/dist/plugins/SignatureCanvasPlugin/SignatureCanvasPlugin.d.ts +9 -9
  186. package/dist/plugins/SignatureCanvasPlugin/index.d.ts +2 -2
  187. package/dist/plugins/SlashCommandPlugin/index.d.ts +2 -2
  188. package/dist/plugins/TableActionMenuPlugin/index.d.ts +6 -5
  189. package/dist/plugins/TableCellResizer/index.d.ts +2 -1
  190. package/dist/plugins/TableHoverActionsPlugin/index.d.ts +4 -4
  191. package/dist/plugins/TablePlugin.d.ts +5 -4
  192. package/dist/plugins/Tableimageautoresizeplugin.d.ts +1 -1
  193. package/dist/plugins/TextEnhancePlugin.d.ts +6 -6
  194. package/dist/plugins/TreeViewPlugin.d.ts +3 -2
  195. package/dist/plugins/UsageTrackingPlugin.d.ts +15 -15
  196. package/dist/plugins/VoiceTranscriptPlugin.d.ts +22 -22
  197. package/dist/plugins/WordCountPlugin.d.ts +3 -2
  198. package/dist/{postcss-f084f74d.js → postcss-c2592f3f.js} +1357 -1378
  199. package/dist/postcss-c2592f3f.js.map +1 -0
  200. package/dist/services/chartService.d.ts +20 -0
  201. package/dist/standalone-bcc7f37a.js +2649 -0
  202. package/dist/standalone-bcc7f37a.js.map +1 -0
  203. package/dist/styles/PlaygroundEditorTheme.d.ts +3 -2
  204. package/dist/types.d.ts +150 -149
  205. package/dist/typescript-48c10f50.js +13601 -0
  206. package/dist/typescript-48c10f50.js.map +1 -0
  207. package/dist/ui/ColorPicker.d.ts +14 -13
  208. package/dist/ui/Icons.d.ts +48 -48
  209. package/dist/ui/TextInput.d.ts +11 -10
  210. package/dist/utils/dateFormats.d.ts +33 -33
  211. package/dist/utils/debounce.d.ts +6 -5
  212. package/dist/utils/editorStyleConverter.d.ts +17 -16
  213. package/dist/utils/export.d.ts +2 -1
  214. package/dist/utils/getDOMRangeRect.d.ts +13 -13
  215. package/dist/utils/getSelectedNode.d.ts +3 -2
  216. package/dist/utils/helper.d.ts +3 -3
  217. package/dist/utils/index.d.ts +4 -3
  218. package/dist/utils/invarient.d.ts +1 -1
  219. package/dist/utils/setFloatingElemPosition.d.ts +8 -8
  220. package/dist/utils/setFloatingElemPositionForLinkEditor.d.ts +1 -1
  221. package/dist/utils/url.d.ts +9 -9
  222. package/package.json +149 -149
  223. package/dist/babel-d3085146.js.map +0 -1
  224. package/dist/estree-164983f6.js.map +0 -1
  225. package/dist/html-5586dbf6.js.map +0 -1
  226. package/dist/html2pdf.bundle-d4225b87.js.map +0 -1
  227. package/dist/html2pdf.bundle.min-4f1c3930.js.map +0 -1
  228. package/dist/index-35336e5d.js.map +0 -1
  229. package/dist/index-6717344b.js.map +0 -1
  230. package/dist/index-da40f793.js.map +0 -1
  231. package/dist/markdown-d513479b.js.map +0 -1
  232. package/dist/plugins/FloatingEnhanceButton/index.d.ts +0 -4
  233. package/dist/postcss-f084f74d.js.map +0 -1
  234. package/dist/standalone-5a8c6b7e.js +0 -2518
  235. package/dist/standalone-5a8c6b7e.js.map +0 -1
  236. package/dist/typescript-b1005db4.js +0 -13705
  237. package/dist/typescript-b1005db4.js.map +0 -1
@@ -4,10 +4,12 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { jsx, Fragment, jsxs } from "react/jsx-runtime";
7
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
8
8
  import * as React$1 from "react";
9
- import React__default, { createContext, useContext, useState as useState$1, useRef, useCallback, useEffect as useEffect$1, Suspense, forwardRef, createElement, useImperativeHandle, useMemo, useLayoutEffect as useLayoutEffect$1, Component } from "react";
9
+ import React__default, { createContext, useContext, useState as useState$1, useRef, useEffect as useEffect$1, useCallback, Suspense, forwardRef, createElement, useImperativeHandle, useMemo, useLayoutEffect as useLayoutEffect$1, Component } from "react";
10
10
  import axios from "axios";
11
+ import * as ReactDOM from "react-dom";
12
+ import ReactDOM__default, { createPortal } from "react-dom";
11
13
  import styled from "@emotion/styled";
12
14
  import { $generateNodesFromDOM, $generateHtmlFromNodes } from "@lexical/html";
13
15
  import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
@@ -23,9 +25,7 @@ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
23
25
  import { TablePlugin } from "@lexical/react/LexicalTablePlugin";
24
26
  import { TableNode, TableCellNode, TableRowNode, $createTableNodeWithDimensions, $isTableRowNode, $isTableCellNode, TableCellHeaderStates, $isTableNode, $isTableSelection, $getTableCellNodeFromLexicalNode, $getTableNodeFromLexicalNodeOrThrow, getTableElement, getTableObserverFromTableElement, $getTableRowIndexFromTableCellNode, $getNodeTriplet, $insertTableRow__EXPERIMENTAL, $getTableColumnIndexFromTableCellNode, $insertTableColumn__EXPERIMENTAL, $deleteTableRow__EXPERIMENTAL, $deleteTableColumn__EXPERIMENTAL, $unmergeCell, $computeTableMapSkipCellCheck, getDOMCellFromTarget, $getTableAndElementByKey } from "@lexical/table";
25
27
  import { mergeRegister, $wrapNodeInElement, $findMatchingParent, $getNearestNodeOfType, $getNearestBlockElementAncestorOrThrow, $insertNodeToNearestRoot, $isEditorIsNestedEditor, mediaFileReader, isMimeType, calculateZoomLevel, CAN_USE_DOM } from "@lexical/utils";
26
- import { createCommand, DecoratorNode, createEditor, $applyNodeReplacement, $insertNodes, $isRootOrShadowRoot, $createParagraphNode, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection, $getNearestNodeFromDOMNode, isHTMLElement as isHTMLElement$1, TextNode, $getRoot, $createTextNode, $getNodeByKey, $isParagraphNode, $isTextNode, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, KEY_DOWN_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $isElementNode, SELECTION_CHANGE_COMMAND, UNDO_COMMAND, REDO_COMMAND, KEY_SPACE_COMMAND, $isLineBreakNode, $createRangeSelection, $setSelection, COMMAND_PRIORITY_HIGH, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $createNodeSelection, $isNodeSelection, PASTE_COMMAND, getDOMSelection, CLICK_COMMAND, KEY_BACKSPACE_COMMAND, ParagraphNode, $createLineBreakNode, isDOMNode } from "lexical";
27
- import * as ReactDOM from "react-dom";
28
- import ReactDOM__default, { createPortal } from "react-dom";
28
+ import { createCommand, DecoratorNode, createEditor, $applyNodeReplacement, $insertNodes, $isRootOrShadowRoot, $createParagraphNode, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_LOW, $getSelection, $isRangeSelection, $getNearestNodeFromDOMNode, isHTMLElement as isHTMLElement$1, TextNode, $getRoot, $createTextNode, $getNodeByKey, $isParagraphNode, $isTextNode, FORMAT_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, KEY_DOWN_COMMAND, COMMAND_PRIORITY_CRITICAL, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $isElementNode, SELECTION_CHANGE_COMMAND, UNDO_COMMAND, REDO_COMMAND, KEY_SPACE_COMMAND, $isLineBreakNode, $createRangeSelection, $setSelection, COMMAND_PRIORITY_HIGH, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, KEY_ENTER_COMMAND, $createNodeSelection, $isNodeSelection, PASTE_COMMAND, CLICK_COMMAND, getDOMSelection, KEY_BACKSPACE_COMMAND, ParagraphNode, $createLineBreakNode, isDOMNode } from "lexical";
29
29
  import { $isCodeNode, CodeNode, normalizeCodeLang, getLanguageFriendlyName, CodeHighlightNode, CODE_LANGUAGE_MAP, $createCodeNode, registerCodeHighlighting, $isCodeHighlightNode } from "@lexical/code";
30
30
  import { LinkNode, $isLinkNode, TOGGLE_LINK_COMMAND, $isAutoLinkNode, $createLinkNode } from "@lexical/link";
31
31
  import { ListNode, ListItemNode, $isListNode, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, $isListItemNode, $createListNode, $createListItemNode } from "@lexical/list";
@@ -104,6 +104,566 @@ const verifyApiKey = async (apiKey) => {
104
104
  throw new Error("Failed to verify API key");
105
105
  }
106
106
  };
107
+ const backendInstance = axios.create({
108
+ baseURL: "https://api.cteditor.com/",
109
+ headers: {
110
+ "Content-Type": "application/json"
111
+ }
112
+ });
113
+ const backendAPI = backendInstance;
114
+ const apiEndpoints = {
115
+ // School management endpoints
116
+ chat: {
117
+ stream: "/api/chat/stream",
118
+ json: "/api/chat/json",
119
+ textEnhance: "/api/chat/text-enhance",
120
+ textTransform: "/api/chat/text-transform",
121
+ imageCreation: "/api/chat/image-creation",
122
+ editorAction: "/api/chat/chat-action",
123
+ credits: "/api/chat/credits",
124
+ userInfo: "/api/chat/user-info"
125
+ },
126
+ project: {
127
+ fileUpload: "/api/files/upload"
128
+ },
129
+ transcript: {
130
+ voiceTranscript: "/api/transcript/get-assemblyai-token",
131
+ endSession: "/api/transcript/end-session"
132
+ },
133
+ linkPreview: {
134
+ getPreview: "/api/link-preview"
135
+ }
136
+ };
137
+ const cache = /* @__PURE__ */ new Map();
138
+ const CACHE_TTL = 30 * 60 * 1e3;
139
+ const MAX_CACHE_SIZE$1 = 100;
140
+ function getCached(url) {
141
+ const entry = cache.get(url);
142
+ if (!entry)
143
+ return null;
144
+ if (Date.now() - entry.timestamp > CACHE_TTL) {
145
+ cache.delete(url);
146
+ return null;
147
+ }
148
+ return entry.data;
149
+ }
150
+ function setCache(url, data) {
151
+ if (cache.size >= MAX_CACHE_SIZE$1) {
152
+ const oldestKey = cache.keys().next().value;
153
+ if (oldestKey)
154
+ cache.delete(oldestKey);
155
+ }
156
+ cache.set(url, { data, timestamp: Date.now() });
157
+ }
158
+ async function fetchLinkPreview({
159
+ url,
160
+ apiKey
161
+ }) {
162
+ const cached = getCached(url);
163
+ if (cached)
164
+ return cached;
165
+ try {
166
+ const response = await backendAPI.post(
167
+ apiEndpoints.linkPreview.getPreview,
168
+ { url },
169
+ apiKey ? { headers: { "X-API-Key": apiKey } } : void 0
170
+ );
171
+ if (response.data.success && response.data.data) {
172
+ setCache(url, response.data.data);
173
+ return response.data.data;
174
+ }
175
+ return null;
176
+ } catch (error) {
177
+ console.error("Error fetching link preview:", error);
178
+ return null;
179
+ }
180
+ }
181
+ function LinkPreviewHover({
182
+ containerRef,
183
+ children,
184
+ apiKey,
185
+ showDelay = 500,
186
+ hideDelay = 300,
187
+ enabled = true
188
+ }) {
189
+ const internalRef = useRef(null);
190
+ const [hoveredLink, setHoveredLink] = useState$1(null);
191
+ const effectiveRef = containerRef || internalRef;
192
+ useEffect$1(() => {
193
+ if (!enabled)
194
+ return;
195
+ const container = effectiveRef.current;
196
+ if (!container)
197
+ return;
198
+ let showTimeout = null;
199
+ let hideTimeout = null;
200
+ let isOverPreview = false;
201
+ const handleMouseOver = (event) => {
202
+ const target = event.target;
203
+ if (target.closest(".link-preview-card")) {
204
+ isOverPreview = true;
205
+ if (hideTimeout) {
206
+ clearTimeout(hideTimeout);
207
+ hideTimeout = null;
208
+ }
209
+ return;
210
+ }
211
+ const linkElement = target.closest("a");
212
+ if (linkElement && container.contains(linkElement)) {
213
+ const href = linkElement.getAttribute("href");
214
+ if (href && href !== "https://" && href !== "http://" && href !== "#" && !href.startsWith("javascript:")) {
215
+ if (showTimeout)
216
+ clearTimeout(showTimeout);
217
+ if (hideTimeout) {
218
+ clearTimeout(hideTimeout);
219
+ hideTimeout = null;
220
+ }
221
+ showTimeout = window.setTimeout(() => {
222
+ setHoveredLink({ url: href, rect: linkElement.getBoundingClientRect() });
223
+ }, showDelay);
224
+ }
225
+ }
226
+ };
227
+ const handleMouseOut = (event) => {
228
+ const target = event.target;
229
+ const relatedTarget = event.relatedTarget;
230
+ if (target.closest(".link-preview-card")) {
231
+ isOverPreview = false;
232
+ if (!(relatedTarget == null ? void 0 : relatedTarget.closest("a"))) {
233
+ hideTimeout = window.setTimeout(() => {
234
+ if (!isOverPreview)
235
+ setHoveredLink(null);
236
+ }, hideDelay);
237
+ }
238
+ return;
239
+ }
240
+ const linkElement = target.closest("a");
241
+ if (linkElement && container.contains(linkElement)) {
242
+ if (showTimeout) {
243
+ clearTimeout(showTimeout);
244
+ showTimeout = null;
245
+ }
246
+ if (!(relatedTarget == null ? void 0 : relatedTarget.closest(".link-preview-card"))) {
247
+ hideTimeout = window.setTimeout(() => {
248
+ if (!isOverPreview)
249
+ setHoveredLink(null);
250
+ }, hideDelay);
251
+ }
252
+ }
253
+ };
254
+ const handlePreviewMouseOver = (event) => {
255
+ if (event.target.closest(".link-preview-card")) {
256
+ isOverPreview = true;
257
+ if (hideTimeout) {
258
+ clearTimeout(hideTimeout);
259
+ hideTimeout = null;
260
+ }
261
+ }
262
+ };
263
+ const handlePreviewMouseOut = (event) => {
264
+ const target = event.target;
265
+ const relatedTarget = event.relatedTarget;
266
+ if (target.closest(".link-preview-card")) {
267
+ isOverPreview = false;
268
+ if (!(relatedTarget == null ? void 0 : relatedTarget.closest("a")) || !container.contains(relatedTarget)) {
269
+ hideTimeout = window.setTimeout(() => {
270
+ if (!isOverPreview)
271
+ setHoveredLink(null);
272
+ }, hideDelay);
273
+ }
274
+ }
275
+ };
276
+ container.addEventListener("mouseover", handleMouseOver);
277
+ container.addEventListener("mouseout", handleMouseOut);
278
+ document.body.addEventListener("mouseover", handlePreviewMouseOver);
279
+ document.body.addEventListener("mouseout", handlePreviewMouseOut);
280
+ return () => {
281
+ if (showTimeout)
282
+ clearTimeout(showTimeout);
283
+ if (hideTimeout)
284
+ clearTimeout(hideTimeout);
285
+ container.removeEventListener("mouseover", handleMouseOver);
286
+ container.removeEventListener("mouseout", handleMouseOut);
287
+ document.body.removeEventListener("mouseover", handlePreviewMouseOver);
288
+ document.body.removeEventListener("mouseout", handlePreviewMouseOut);
289
+ };
290
+ }, [effectiveRef, showDelay, hideDelay, enabled]);
291
+ if (children) {
292
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
293
+ /* @__PURE__ */ jsx("div", { ref: internalRef, children }),
294
+ hoveredLink && createPortal(
295
+ /* @__PURE__ */ jsx(
296
+ LinkPreviewCard,
297
+ {
298
+ url: hoveredLink.url,
299
+ rect: hoveredLink.rect,
300
+ apiKey,
301
+ onClose: () => setHoveredLink(null)
302
+ }
303
+ ),
304
+ document.body
305
+ )
306
+ ] });
307
+ }
308
+ return /* @__PURE__ */ jsx(Fragment, { children: hoveredLink && createPortal(
309
+ /* @__PURE__ */ jsx(
310
+ LinkPreviewCard,
311
+ {
312
+ url: hoveredLink.url,
313
+ rect: hoveredLink.rect,
314
+ apiKey,
315
+ onClose: () => setHoveredLink(null)
316
+ }
317
+ ),
318
+ document.body
319
+ ) });
320
+ }
321
+ const PREVIEW_WIDTH$1 = 320;
322
+ function LinkPreviewCard({ url, rect, apiKey, onClose }) {
323
+ const [position, setPosition] = useState$1({ top: 0, left: 0 });
324
+ const [previewData, setPreviewData] = useState$1(null);
325
+ const [isLoading, setIsLoading] = useState$1(true);
326
+ const [hasError, setHasError] = useState$1(false);
327
+ const fetchedRef = useRef(false);
328
+ useEffect$1(() => {
329
+ if (fetchedRef.current)
330
+ return;
331
+ fetchedRef.current = true;
332
+ setIsLoading(true);
333
+ setHasError(false);
334
+ fetchLinkPreview({ url, apiKey }).then((data) => {
335
+ if (data)
336
+ setPreviewData(data);
337
+ else
338
+ setHasError(true);
339
+ }).catch(() => setHasError(true)).finally(() => setIsLoading(false));
340
+ }, [url, apiKey]);
341
+ useEffect$1(() => {
342
+ const previewHeight = (previewData == null ? void 0 : previewData.image) ? 280 : 160;
343
+ let top = rect.top + window.scrollY - previewHeight - 10;
344
+ if (rect.top - previewHeight - 10 < 0) {
345
+ top = rect.bottom + window.scrollY + 10;
346
+ }
347
+ let left = rect.left + window.scrollX + rect.width / 2 - PREVIEW_WIDTH$1 / 2;
348
+ const viewportWidth = window.innerWidth;
349
+ if (left < 10)
350
+ left = 10;
351
+ else if (left + PREVIEW_WIDTH$1 > viewportWidth - 10)
352
+ left = viewportWidth - PREVIEW_WIDTH$1 - 10;
353
+ setPosition({ top, left });
354
+ }, [rect, previewData]);
355
+ const getDomain = useCallback((urlString) => {
356
+ try {
357
+ return new URL(urlString).hostname.replace("www.", "");
358
+ } catch {
359
+ return urlString;
360
+ }
361
+ }, []);
362
+ const domain = getDomain(url);
363
+ const cardStyle = {
364
+ position: "absolute",
365
+ top: `${position.top}px`,
366
+ left: `${position.left}px`,
367
+ zIndex: 1e4,
368
+ pointerEvents: "auto",
369
+ animation: "linkPreviewFadeIn 0.2s ease-out"
370
+ };
371
+ const containerStyle = {
372
+ width: `${PREVIEW_WIDTH$1}px`,
373
+ backgroundColor: "#1e1e1e",
374
+ borderRadius: "12px",
375
+ boxShadow: "0 10px 40px rgba(0, 0, 0, 0.4)",
376
+ overflow: "hidden",
377
+ position: "relative",
378
+ border: "1px solid #333"
379
+ };
380
+ const closeButtonStyle = {
381
+ position: "absolute",
382
+ top: "8px",
383
+ right: "8px",
384
+ width: "24px",
385
+ height: "24px",
386
+ borderRadius: "6px",
387
+ backgroundColor: "rgba(0,0,0,0.5)",
388
+ border: "none",
389
+ cursor: "pointer",
390
+ display: "flex",
391
+ alignItems: "center",
392
+ justifyContent: "center",
393
+ zIndex: 10
394
+ };
395
+ return /* @__PURE__ */ jsxs("div", { className: "link-preview-card", style: cardStyle, children: [
396
+ /* @__PURE__ */ jsxs("div", { style: containerStyle, children: [
397
+ /* @__PURE__ */ jsx(
398
+ "button",
399
+ {
400
+ onClick: (e) => {
401
+ e.preventDefault();
402
+ e.stopPropagation();
403
+ onClose();
404
+ },
405
+ style: closeButtonStyle,
406
+ onMouseEnter: (e) => {
407
+ e.currentTarget.style.backgroundColor = "rgba(0,0,0,0.7)";
408
+ },
409
+ onMouseLeave: (e) => {
410
+ e.currentTarget.style.backgroundColor = "rgba(0,0,0,0.5)";
411
+ },
412
+ title: "Close preview",
413
+ children: /* @__PURE__ */ jsx(
414
+ "svg",
415
+ {
416
+ style: { width: "14px", height: "14px", color: "#fff" },
417
+ fill: "none",
418
+ stroke: "currentColor",
419
+ viewBox: "0 0 24 24",
420
+ children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })
421
+ }
422
+ )
423
+ }
424
+ ),
425
+ isLoading && /* @__PURE__ */ jsxs("div", { style: { padding: "40px", textAlign: "center" }, children: [
426
+ /* @__PURE__ */ jsx(
427
+ "div",
428
+ {
429
+ style: {
430
+ width: "24px",
431
+ height: "24px",
432
+ border: "2px solid #444",
433
+ borderTopColor: "#fff",
434
+ borderRadius: "50%",
435
+ animation: "linkPreviewSpin 1s linear infinite",
436
+ margin: "0 auto 12px"
437
+ }
438
+ }
439
+ ),
440
+ /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: "#888" }, children: "Loading preview..." })
441
+ ] }),
442
+ !isLoading && hasError && /* @__PURE__ */ jsxs("div", { style: { padding: "16px" }, children: [
443
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "12px" }, children: [
444
+ /* @__PURE__ */ jsx(
445
+ "svg",
446
+ {
447
+ style: { width: "16px", height: "16px", color: "#fff" },
448
+ fill: "none",
449
+ stroke: "currentColor",
450
+ viewBox: "0 0 24 24",
451
+ children: /* @__PURE__ */ jsx(
452
+ "path",
453
+ {
454
+ strokeLinecap: "round",
455
+ strokeLinejoin: "round",
456
+ strokeWidth: 2,
457
+ d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
458
+ }
459
+ )
460
+ }
461
+ ),
462
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: "600", color: "#fff" }, children: domain })
463
+ ] }),
464
+ /* @__PURE__ */ jsx("div", { style: { backgroundColor: "#2a2a2a", padding: "10px", borderRadius: "6px" }, children: /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: "#ccc", wordBreak: "break-all", lineHeight: "1.5" }, children: url }) })
465
+ ] }),
466
+ !isLoading && !hasError && previewData && /* @__PURE__ */ jsxs(Fragment, { children: [
467
+ previewData.image && /* @__PURE__ */ jsx(
468
+ "div",
469
+ {
470
+ style: {
471
+ width: "100%",
472
+ height: "140px",
473
+ backgroundColor: "#2a2a2a",
474
+ backgroundImage: `url(${previewData.image})`,
475
+ backgroundSize: "cover",
476
+ backgroundPosition: "center"
477
+ }
478
+ }
479
+ ),
480
+ /* @__PURE__ */ jsxs("div", { style: { padding: "14px" }, children: [
481
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "10px" }, children: [
482
+ previewData.favicon ? /* @__PURE__ */ jsx(
483
+ "img",
484
+ {
485
+ src: previewData.favicon,
486
+ alt: "",
487
+ style: { width: "16px", height: "16px", borderRadius: "2px", objectFit: "contain" },
488
+ onError: (e) => {
489
+ e.currentTarget.style.display = "none";
490
+ }
491
+ }
492
+ ) : /* @__PURE__ */ jsx("span", { style: { color: "#888" }, children: /* @__PURE__ */ jsx(TypeIcon, { type: previewData.type }) }),
493
+ /* @__PURE__ */ jsx(
494
+ "span",
495
+ {
496
+ style: {
497
+ fontSize: "12px",
498
+ color: "#888",
499
+ flex: 1,
500
+ overflow: "hidden",
501
+ textOverflow: "ellipsis",
502
+ whiteSpace: "nowrap"
503
+ },
504
+ children: previewData.siteName || domain
505
+ }
506
+ ),
507
+ /* @__PURE__ */ jsx(
508
+ "span",
509
+ {
510
+ style: {
511
+ fontSize: "10px",
512
+ color: "#666",
513
+ padding: "2px 6px",
514
+ backgroundColor: "#333",
515
+ borderRadius: "4px",
516
+ textTransform: "uppercase"
517
+ },
518
+ children: previewData.type
519
+ }
520
+ )
521
+ ] }),
522
+ previewData.title && /* @__PURE__ */ jsx(
523
+ "h4",
524
+ {
525
+ style: {
526
+ fontSize: "14px",
527
+ fontWeight: "600",
528
+ color: "#fff",
529
+ marginBottom: "6px",
530
+ lineHeight: "1.4",
531
+ display: "-webkit-box",
532
+ WebkitLineClamp: 2,
533
+ WebkitBoxOrient: "vertical",
534
+ overflow: "hidden"
535
+ },
536
+ children: previewData.title
537
+ }
538
+ ),
539
+ previewData.description && /* @__PURE__ */ jsx(
540
+ "p",
541
+ {
542
+ style: {
543
+ fontSize: "12px",
544
+ color: "#999",
545
+ lineHeight: "1.5",
546
+ display: "-webkit-box",
547
+ WebkitLineClamp: 2,
548
+ WebkitBoxOrient: "vertical",
549
+ overflow: "hidden",
550
+ marginBottom: "10px"
551
+ },
552
+ children: previewData.description
553
+ }
554
+ ),
555
+ /* @__PURE__ */ jsxs(
556
+ "div",
557
+ {
558
+ style: {
559
+ display: "flex",
560
+ alignItems: "center",
561
+ gap: "6px",
562
+ padding: "8px 10px",
563
+ backgroundColor: "#252525",
564
+ borderRadius: "6px",
565
+ marginTop: "8px"
566
+ },
567
+ children: [
568
+ /* @__PURE__ */ jsx(
569
+ "svg",
570
+ {
571
+ style: { width: "12px", height: "12px", color: "#666", flexShrink: 0 },
572
+ fill: "none",
573
+ stroke: "currentColor",
574
+ viewBox: "0 0 24 24",
575
+ children: /* @__PURE__ */ jsx(
576
+ "path",
577
+ {
578
+ strokeLinecap: "round",
579
+ strokeLinejoin: "round",
580
+ strokeWidth: 2,
581
+ d: "M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
582
+ }
583
+ )
584
+ }
585
+ ),
586
+ /* @__PURE__ */ jsx(
587
+ "span",
588
+ {
589
+ style: {
590
+ fontSize: "11px",
591
+ color: "#888",
592
+ overflow: "hidden",
593
+ textOverflow: "ellipsis",
594
+ whiteSpace: "nowrap"
595
+ },
596
+ children: url
597
+ }
598
+ )
599
+ ]
600
+ }
601
+ )
602
+ ] })
603
+ ] })
604
+ ] }),
605
+ /* @__PURE__ */ jsx("style", { children: `
606
+ @keyframes linkPreviewFadeIn {
607
+ from { opacity: 0; transform: translateY(5px); }
608
+ to { opacity: 1; transform: translateY(0); }
609
+ }
610
+ @keyframes linkPreviewSpin {
611
+ from { transform: rotate(0deg); }
612
+ to { transform: rotate(360deg); }
613
+ }
614
+ ` })
615
+ ] });
616
+ }
617
+ function TypeIcon({ type }) {
618
+ const iconProps = {
619
+ style: { width: "14px", height: "14px" },
620
+ fill: "none",
621
+ stroke: "currentColor",
622
+ viewBox: "0 0 24 24"
623
+ };
624
+ const pathProps = {
625
+ strokeLinecap: "round",
626
+ strokeLinejoin: "round",
627
+ strokeWidth: 2
628
+ };
629
+ switch (type) {
630
+ case "image":
631
+ return /* @__PURE__ */ jsx("svg", { ...iconProps, children: /* @__PURE__ */ jsx(
632
+ "path",
633
+ {
634
+ ...pathProps,
635
+ d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"
636
+ }
637
+ ) });
638
+ case "video":
639
+ return /* @__PURE__ */ jsxs("svg", { ...iconProps, children: [
640
+ /* @__PURE__ */ jsx(
641
+ "path",
642
+ {
643
+ ...pathProps,
644
+ d: "M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"
645
+ }
646
+ ),
647
+ /* @__PURE__ */ jsx("path", { ...pathProps, d: "M21 12a9 9 0 11-18 0 9 9 0 0118 0z" })
648
+ ] });
649
+ case "pdf":
650
+ return /* @__PURE__ */ jsx("svg", { ...iconProps, children: /* @__PURE__ */ jsx(
651
+ "path",
652
+ {
653
+ ...pathProps,
654
+ d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
655
+ }
656
+ ) });
657
+ default:
658
+ return /* @__PURE__ */ jsx("svg", { ...iconProps, children: /* @__PURE__ */ jsx(
659
+ "path",
660
+ {
661
+ ...pathProps,
662
+ d: "M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"
663
+ }
664
+ ) });
665
+ }
666
+ }
107
667
  const convertToEditorConfigTypes = (config) => {
108
668
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
109
669
  return {
@@ -137,7 +697,9 @@ const EditorProvider = ({
137
697
  children,
138
698
  defaultFontFamilies = [],
139
699
  mentionUserList = [],
140
- currentUser
700
+ currentUser,
701
+ enableLinkPreview = true,
702
+ apiKey: initialApiKey
141
703
  }) => {
142
704
  const [isAuthenticated, setIsAuthenticated] = useState$1(false);
143
705
  const [isLoading, setIsLoading] = useState$1(false);
@@ -148,7 +710,14 @@ const EditorProvider = ({
148
710
  const [projectName, setProjectName] = useState$1(null);
149
711
  const [isPaidPlan, setIsPaidPlan] = useState$1(false);
150
712
  const [apiKey, setApiKey] = useState$1(null);
151
- const verifyKey = async (apiKey2) => {
713
+ const hasAutoAuthenticatedRef = useRef(false);
714
+ useEffect$1(() => {
715
+ if (initialApiKey && !isAuthenticated && !isLoading && !hasAutoAuthenticatedRef.current) {
716
+ hasAutoAuthenticatedRef.current = true;
717
+ verifyKeyInternal(initialApiKey);
718
+ }
719
+ }, [initialApiKey, isAuthenticated, isLoading]);
720
+ const verifyKeyInternal = async (key) => {
152
721
  var _a, _b;
153
722
  if (isAuthenticated || isLoading)
154
723
  return;
@@ -156,14 +725,14 @@ const EditorProvider = ({
156
725
  setIsLoading(true);
157
726
  setError(null);
158
727
  try {
159
- const response = await verifyApiKey(apiKey2);
728
+ const response = await verifyApiKey(key);
160
729
  console.log(response, "response form verifyKey");
161
730
  if (response.success) {
162
731
  setIsAuthenticated(true);
163
732
  setEditorConfig(convertToEditorConfigTypes(response.data));
164
733
  setProjectName(response.data.name);
165
734
  setIsPaidPlan(response.data.paidPlan);
166
- setApiKey(apiKey2);
735
+ setApiKey(key);
167
736
  } else {
168
737
  console.log(response.message, "response.message form verifyKey");
169
738
  setError(response.message);
@@ -176,6 +745,9 @@ const EditorProvider = ({
176
745
  setIsLoading(false);
177
746
  }
178
747
  };
748
+ const verifyKey = (key) => verifyKeyInternal(key);
749
+ const effectiveApiKey = apiKey || initialApiKey;
750
+ const wrappedChildren = enableLinkPreview && effectiveApiKey ? /* @__PURE__ */ jsx(LinkPreviewHover, { apiKey: effectiveApiKey, enabled: enableLinkPreview, children }) : children;
179
751
  return /* @__PURE__ */ jsx(
180
752
  EditorContext.Provider,
181
753
  {
@@ -190,7 +762,7 @@ const EditorProvider = ({
190
762
  currentUser: currentUser || null,
191
763
  verifyKey
192
764
  },
193
- children
765
+ children: wrappedChildren
194
766
  }
195
767
  );
196
768
  };
@@ -198,13 +770,6 @@ const globals = "";
198
770
  const EditorTheme = "";
199
771
  const PlaygroundEditorTheme = "";
200
772
  const AIChatPlugin$1 = "";
201
- const backendInstance = axios.create({
202
- baseURL: "https://api.cteditor.com/",
203
- headers: {
204
- "Content-Type": "application/json"
205
- }
206
- });
207
- const backendAPI = backendInstance;
208
773
  const editorConfig = {
209
774
  enableToolbar: true,
210
775
  toolbarOptions: {
@@ -1500,34 +2065,13 @@ const Toaster = /* @__PURE__ */ React__default.forwardRef(function Toaster2(prop
1500
2065
  }))
1501
2066
  );
1502
2067
  });
1503
- const apiEndpoints = {
1504
- // School management endpoints
1505
- chat: {
1506
- stream: "/api/chat/stream",
1507
- json: "/api/chat/json",
1508
- textEnhance: "/api/chat/text-enhance",
1509
- textTransform: "/api/chat/text-transform",
1510
- imageCreation: "/api/chat/image-creation",
1511
- editorAction: "/api/chat/chat-action",
1512
- credits: "/api/chat/credits",
1513
- userInfo: "/api/chat/user-info"
1514
- },
1515
- project: {
1516
- fileUpload: "/api/files/upload"
1517
- },
1518
- transcript: {
1519
- voiceTranscript: "/api/transcript/get-assemblyai-token",
1520
- endSession: "/api/transcript/end-session"
1521
- },
1522
- linkPreview: {
1523
- getPreview: "/api/link-preview"
1524
- }
1525
- };
1526
- const AiJsonResponse = async ({ content }) => {
2068
+ const AiJsonResponse = async ({ content, apiKey }) => {
1527
2069
  try {
1528
- const res = await backendAPI.post(apiEndpoints.chat.json, {
1529
- content
1530
- });
2070
+ const res = await backendAPI.post(
2071
+ apiEndpoints.chat.json,
2072
+ { content },
2073
+ apiKey ? { headers: { "X-API-Key": apiKey } } : void 0
2074
+ );
1531
2075
  return res.data;
1532
2076
  } catch (error) {
1533
2077
  console.error("Error in AiJsonResponse:", error);
@@ -1604,7 +2148,7 @@ const AiTextTransform = async ({ content, apiKey }) => {
1604
2148
  const AI_ACTION_COMMAND = createCommand(
1605
2149
  "AI_ACTION_COMMAND"
1606
2150
  );
1607
- const ImageView = React__default.lazy(() => import("./index-da40f793.js"));
2151
+ const ImageView = React__default.lazy(() => import("./index-f51de846.js"));
1608
2152
  function isGoogleDocCheckboxImg(img) {
1609
2153
  return img.parentElement != null && img.parentElement.tagName === "LI" && img.previousSibling === null && img.getAttribute("aria-roledescription") === "checkbox";
1610
2154
  }
@@ -1907,18 +2451,18 @@ const ImagePlugin = ({
1907
2451
  }, [captionsEnabled, editor]);
1908
2452
  return null;
1909
2453
  };
1910
- function setRef(ref, value) {
2454
+ function setRef$1(ref, value) {
1911
2455
  if (typeof ref === "function") {
1912
2456
  return ref(value);
1913
2457
  } else if (ref !== null && ref !== void 0) {
1914
2458
  ref.current = value;
1915
2459
  }
1916
2460
  }
1917
- function composeRefs(...refs) {
2461
+ function composeRefs$1(...refs) {
1918
2462
  return (node) => {
1919
2463
  let hasCleanup = false;
1920
2464
  const cleanups = refs.map((ref) => {
1921
- const cleanup = setRef(ref, node);
2465
+ const cleanup = setRef$1(ref, node);
1922
2466
  if (!hasCleanup && typeof cleanup == "function") {
1923
2467
  hasCleanup = true;
1924
2468
  }
@@ -1931,34 +2475,31 @@ function composeRefs(...refs) {
1931
2475
  if (typeof cleanup == "function") {
1932
2476
  cleanup();
1933
2477
  } else {
1934
- setRef(refs[i2], null);
2478
+ setRef$1(refs[i2], null);
1935
2479
  }
1936
2480
  }
1937
2481
  };
1938
2482
  }
1939
2483
  };
1940
2484
  }
1941
- function useComposedRefs(...refs) {
1942
- return React$1.useCallback(composeRefs(...refs), refs);
1943
- }
1944
- var REACT_LAZY_TYPE$3 = Symbol.for("react.lazy");
1945
- var use$3 = React$1[" use ".trim().toString()];
1946
- function isPromiseLike$3(value) {
2485
+ var REACT_LAZY_TYPE = Symbol.for("react.lazy");
2486
+ var use = React$1[" use ".trim().toString()];
2487
+ function isPromiseLike(value) {
1947
2488
  return typeof value === "object" && value !== null && "then" in value;
1948
2489
  }
1949
- function isLazyComponent$3(element) {
1950
- return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE$3 && "_payload" in element && isPromiseLike$3(element._payload);
2490
+ function isLazyComponent(element) {
2491
+ return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
1951
2492
  }
1952
2493
  // @__NO_SIDE_EFFECTS__
1953
- function createSlot$4(ownerName) {
1954
- const SlotClone = /* @__PURE__ */ createSlotClone$4(ownerName);
2494
+ function createSlot$1(ownerName) {
2495
+ const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
1955
2496
  const Slot2 = React$1.forwardRef((props, forwardedRef) => {
1956
2497
  let { children, ...slotProps } = props;
1957
- if (isLazyComponent$3(children) && typeof use$3 === "function") {
1958
- children = use$3(children._payload);
2498
+ if (isLazyComponent(children) && typeof use === "function") {
2499
+ children = use(children._payload);
1959
2500
  }
1960
2501
  const childrenArray = React$1.Children.toArray(children);
1961
- const slottable = childrenArray.find(isSlottable$4);
2502
+ const slottable = childrenArray.find(isSlottable$1);
1962
2503
  if (slottable) {
1963
2504
  const newElement = slottable.props.children;
1964
2505
  const newChildren = childrenArray.map((child) => {
@@ -1977,19 +2518,19 @@ function createSlot$4(ownerName) {
1977
2518
  Slot2.displayName = `${ownerName}.Slot`;
1978
2519
  return Slot2;
1979
2520
  }
1980
- var Slot$4 = /* @__PURE__ */ createSlot$4("Slot");
2521
+ var Slot$4 = /* @__PURE__ */ createSlot$1("Slot");
1981
2522
  // @__NO_SIDE_EFFECTS__
1982
- function createSlotClone$4(ownerName) {
2523
+ function createSlotClone$1(ownerName) {
1983
2524
  const SlotClone = React$1.forwardRef((props, forwardedRef) => {
1984
2525
  let { children, ...slotProps } = props;
1985
- if (isLazyComponent$3(children) && typeof use$3 === "function") {
1986
- children = use$3(children._payload);
2526
+ if (isLazyComponent(children) && typeof use === "function") {
2527
+ children = use(children._payload);
1987
2528
  }
1988
2529
  if (React$1.isValidElement(children)) {
1989
- const childrenRef = getElementRef$5(children);
1990
- const props2 = mergeProps$4(slotProps, children.props);
2530
+ const childrenRef = getElementRef$2(children);
2531
+ const props2 = mergeProps$1(slotProps, children.props);
1991
2532
  if (children.type !== React$1.Fragment) {
1992
- props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
2533
+ props2.ref = forwardedRef ? composeRefs$1(forwardedRef, childrenRef) : childrenRef;
1993
2534
  }
1994
2535
  return React$1.cloneElement(children, props2);
1995
2536
  }
@@ -1998,11 +2539,11 @@ function createSlotClone$4(ownerName) {
1998
2539
  SlotClone.displayName = `${ownerName}.SlotClone`;
1999
2540
  return SlotClone;
2000
2541
  }
2001
- var SLOTTABLE_IDENTIFIER$4 = Symbol("radix.slottable");
2002
- function isSlottable$4(child) {
2003
- return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$4;
2542
+ var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
2543
+ function isSlottable$1(child) {
2544
+ return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
2004
2545
  }
2005
- function mergeProps$4(slotProps, childProps) {
2546
+ function mergeProps$1(slotProps, childProps) {
2006
2547
  const overrideProps = { ...childProps };
2007
2548
  for (const propName in childProps) {
2008
2549
  const slotPropValue = slotProps[propName];
@@ -2026,7 +2567,7 @@ function mergeProps$4(slotProps, childProps) {
2026
2567
  }
2027
2568
  return { ...slotProps, ...overrideProps };
2028
2569
  }
2029
- function getElementRef$5(element) {
2570
+ function getElementRef$2(element) {
2030
2571
  var _a, _b;
2031
2572
  let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
2032
2573
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
@@ -2101,28 +2642,7 @@ const cva = (base, config) => (props) => {
2101
2642
  }, []);
2102
2643
  return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
2103
2644
  };
2104
- const concatArrays = (array1, array2) => {
2105
- const combinedArray = new Array(array1.length + array2.length);
2106
- for (let i2 = 0; i2 < array1.length; i2++) {
2107
- combinedArray[i2] = array1[i2];
2108
- }
2109
- for (let i2 = 0; i2 < array2.length; i2++) {
2110
- combinedArray[array1.length + i2] = array2[i2];
2111
- }
2112
- return combinedArray;
2113
- };
2114
- const createClassValidatorObject = (classGroupId, validator) => ({
2115
- classGroupId,
2116
- validator
2117
- });
2118
- const createClassPartObject = (nextPart = /* @__PURE__ */ new Map(), validators = null, classGroupId) => ({
2119
- nextPart,
2120
- validators,
2121
- classGroupId
2122
- });
2123
2645
  const CLASS_PART_SEPARATOR = "-";
2124
- const EMPTY_CONFLICTS = [];
2125
- const ARBITRARY_PROPERTY_PREFIX = "arbitrary..";
2126
2646
  const createClassGroupUtils = (config) => {
2127
2647
  const classMap = createClassMap(config);
2128
2648
  const {
@@ -2130,135 +2650,104 @@ const createClassGroupUtils = (config) => {
2130
2650
  conflictingClassGroupModifiers
2131
2651
  } = config;
2132
2652
  const getClassGroupId = (className) => {
2133
- if (className.startsWith("[") && className.endsWith("]")) {
2134
- return getGroupIdForArbitraryProperty(className);
2135
- }
2136
2653
  const classParts = className.split(CLASS_PART_SEPARATOR);
2137
- const startIndex = classParts[0] === "" && classParts.length > 1 ? 1 : 0;
2138
- return getGroupRecursive(classParts, startIndex, classMap);
2654
+ if (classParts[0] === "" && classParts.length !== 1) {
2655
+ classParts.shift();
2656
+ }
2657
+ return getGroupRecursive(classParts, classMap) || getGroupIdForArbitraryProperty(className);
2139
2658
  };
2140
2659
  const getConflictingClassGroupIds = (classGroupId, hasPostfixModifier) => {
2141
- if (hasPostfixModifier) {
2142
- const modifierConflicts = conflictingClassGroupModifiers[classGroupId];
2143
- const baseConflicts = conflictingClassGroups[classGroupId];
2144
- if (modifierConflicts) {
2145
- if (baseConflicts) {
2146
- return concatArrays(baseConflicts, modifierConflicts);
2147
- }
2148
- return modifierConflicts;
2149
- }
2150
- return baseConflicts || EMPTY_CONFLICTS;
2660
+ const conflicts = conflictingClassGroups[classGroupId] || [];
2661
+ if (hasPostfixModifier && conflictingClassGroupModifiers[classGroupId]) {
2662
+ return [...conflicts, ...conflictingClassGroupModifiers[classGroupId]];
2151
2663
  }
2152
- return conflictingClassGroups[classGroupId] || EMPTY_CONFLICTS;
2664
+ return conflicts;
2153
2665
  };
2154
2666
  return {
2155
2667
  getClassGroupId,
2156
2668
  getConflictingClassGroupIds
2157
2669
  };
2158
2670
  };
2159
- const getGroupRecursive = (classParts, startIndex, classPartObject) => {
2160
- const classPathsLength = classParts.length - startIndex;
2161
- if (classPathsLength === 0) {
2671
+ const getGroupRecursive = (classParts, classPartObject) => {
2672
+ var _a;
2673
+ if (classParts.length === 0) {
2162
2674
  return classPartObject.classGroupId;
2163
2675
  }
2164
- const currentClassPart = classParts[startIndex];
2676
+ const currentClassPart = classParts[0];
2165
2677
  const nextClassPartObject = classPartObject.nextPart.get(currentClassPart);
2166
- if (nextClassPartObject) {
2167
- const result = getGroupRecursive(classParts, startIndex + 1, nextClassPartObject);
2168
- if (result)
2169
- return result;
2678
+ const classGroupFromNextClassPart = nextClassPartObject ? getGroupRecursive(classParts.slice(1), nextClassPartObject) : void 0;
2679
+ if (classGroupFromNextClassPart) {
2680
+ return classGroupFromNextClassPart;
2170
2681
  }
2171
- const validators = classPartObject.validators;
2172
- if (validators === null) {
2682
+ if (classPartObject.validators.length === 0) {
2173
2683
  return void 0;
2174
2684
  }
2175
- const classRest = startIndex === 0 ? classParts.join(CLASS_PART_SEPARATOR) : classParts.slice(startIndex).join(CLASS_PART_SEPARATOR);
2176
- const validatorsLength = validators.length;
2177
- for (let i2 = 0; i2 < validatorsLength; i2++) {
2178
- const validatorObj = validators[i2];
2179
- if (validatorObj.validator(classRest)) {
2180
- return validatorObj.classGroupId;
2685
+ const classRest = classParts.join(CLASS_PART_SEPARATOR);
2686
+ return (_a = classPartObject.validators.find(({
2687
+ validator
2688
+ }) => validator(classRest))) == null ? void 0 : _a.classGroupId;
2689
+ };
2690
+ const arbitraryPropertyRegex = /^\[(.+)\]$/;
2691
+ const getGroupIdForArbitraryProperty = (className) => {
2692
+ if (arbitraryPropertyRegex.test(className)) {
2693
+ const arbitraryPropertyClassName = arbitraryPropertyRegex.exec(className)[1];
2694
+ const property = arbitraryPropertyClassName == null ? void 0 : arbitraryPropertyClassName.substring(0, arbitraryPropertyClassName.indexOf(":"));
2695
+ if (property) {
2696
+ return "arbitrary.." + property;
2181
2697
  }
2182
2698
  }
2183
- return void 0;
2184
2699
  };
2185
- const getGroupIdForArbitraryProperty = (className) => className.slice(1, -1).indexOf(":") === -1 ? void 0 : (() => {
2186
- const content = className.slice(1, -1);
2187
- const colonIndex = content.indexOf(":");
2188
- const property = content.slice(0, colonIndex);
2189
- return property ? ARBITRARY_PROPERTY_PREFIX + property : void 0;
2190
- })();
2191
2700
  const createClassMap = (config) => {
2192
2701
  const {
2193
2702
  theme: theme2,
2194
2703
  classGroups
2195
2704
  } = config;
2196
- return processClassGroups(classGroups, theme2);
2197
- };
2198
- const processClassGroups = (classGroups, theme2) => {
2199
- const classMap = createClassPartObject();
2705
+ const classMap = {
2706
+ nextPart: /* @__PURE__ */ new Map(),
2707
+ validators: []
2708
+ };
2200
2709
  for (const classGroupId in classGroups) {
2201
- const group = classGroups[classGroupId];
2202
- processClassesRecursively(group, classMap, classGroupId, theme2);
2710
+ processClassesRecursively(classGroups[classGroupId], classMap, classGroupId, theme2);
2203
2711
  }
2204
2712
  return classMap;
2205
2713
  };
2206
2714
  const processClassesRecursively = (classGroup, classPartObject, classGroupId, theme2) => {
2207
- const len = classGroup.length;
2208
- for (let i2 = 0; i2 < len; i2++) {
2209
- const classDefinition = classGroup[i2];
2210
- processClassDefinition(classDefinition, classPartObject, classGroupId, theme2);
2211
- }
2212
- };
2213
- const processClassDefinition = (classDefinition, classPartObject, classGroupId, theme2) => {
2214
- if (typeof classDefinition === "string") {
2215
- processStringDefinition(classDefinition, classPartObject, classGroupId);
2216
- return;
2217
- }
2218
- if (typeof classDefinition === "function") {
2219
- processFunctionDefinition(classDefinition, classPartObject, classGroupId, theme2);
2220
- return;
2221
- }
2222
- processObjectDefinition(classDefinition, classPartObject, classGroupId, theme2);
2223
- };
2224
- const processStringDefinition = (classDefinition, classPartObject, classGroupId) => {
2225
- const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
2226
- classPartObjectToEdit.classGroupId = classGroupId;
2227
- };
2228
- const processFunctionDefinition = (classDefinition, classPartObject, classGroupId, theme2) => {
2229
- if (isThemeGetter(classDefinition)) {
2230
- processClassesRecursively(classDefinition(theme2), classPartObject, classGroupId, theme2);
2231
- return;
2232
- }
2233
- if (classPartObject.validators === null) {
2234
- classPartObject.validators = [];
2235
- }
2236
- classPartObject.validators.push(createClassValidatorObject(classGroupId, classDefinition));
2237
- };
2238
- const processObjectDefinition = (classDefinition, classPartObject, classGroupId, theme2) => {
2239
- const entries = Object.entries(classDefinition);
2240
- const len = entries.length;
2241
- for (let i2 = 0; i2 < len; i2++) {
2242
- const [key, value] = entries[i2];
2243
- processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme2);
2244
- }
2715
+ classGroup.forEach((classDefinition) => {
2716
+ if (typeof classDefinition === "string") {
2717
+ const classPartObjectToEdit = classDefinition === "" ? classPartObject : getPart(classPartObject, classDefinition);
2718
+ classPartObjectToEdit.classGroupId = classGroupId;
2719
+ return;
2720
+ }
2721
+ if (typeof classDefinition === "function") {
2722
+ if (isThemeGetter(classDefinition)) {
2723
+ processClassesRecursively(classDefinition(theme2), classPartObject, classGroupId, theme2);
2724
+ return;
2725
+ }
2726
+ classPartObject.validators.push({
2727
+ validator: classDefinition,
2728
+ classGroupId
2729
+ });
2730
+ return;
2731
+ }
2732
+ Object.entries(classDefinition).forEach(([key, classGroup2]) => {
2733
+ processClassesRecursively(classGroup2, getPart(classPartObject, key), classGroupId, theme2);
2734
+ });
2735
+ });
2245
2736
  };
2246
2737
  const getPart = (classPartObject, path) => {
2247
- let current = classPartObject;
2248
- const parts = path.split(CLASS_PART_SEPARATOR);
2249
- const len = parts.length;
2250
- for (let i2 = 0; i2 < len; i2++) {
2251
- const part = parts[i2];
2252
- let next = current.nextPart.get(part);
2253
- if (!next) {
2254
- next = createClassPartObject();
2255
- current.nextPart.set(part, next);
2738
+ let currentClassPartObject = classPartObject;
2739
+ path.split(CLASS_PART_SEPARATOR).forEach((pathPart) => {
2740
+ if (!currentClassPartObject.nextPart.has(pathPart)) {
2741
+ currentClassPartObject.nextPart.set(pathPart, {
2742
+ nextPart: /* @__PURE__ */ new Map(),
2743
+ validators: []
2744
+ });
2256
2745
  }
2257
- current = next;
2258
- }
2259
- return current;
2746
+ currentClassPartObject = currentClassPartObject.nextPart.get(pathPart);
2747
+ });
2748
+ return currentClassPartObject;
2260
2749
  };
2261
- const isThemeGetter = (func) => "isThemeGetter" in func && func.isThemeGetter === true;
2750
+ const isThemeGetter = (func) => func.isThemeGetter;
2262
2751
  const createLruCache = (maxCacheSize) => {
2263
2752
  if (maxCacheSize < 1) {
2264
2753
  return {
@@ -2268,31 +2757,31 @@ const createLruCache = (maxCacheSize) => {
2268
2757
  };
2269
2758
  }
2270
2759
  let cacheSize = 0;
2271
- let cache2 = /* @__PURE__ */ Object.create(null);
2272
- let previousCache = /* @__PURE__ */ Object.create(null);
2760
+ let cache2 = /* @__PURE__ */ new Map();
2761
+ let previousCache = /* @__PURE__ */ new Map();
2273
2762
  const update = (key, value) => {
2274
- cache2[key] = value;
2763
+ cache2.set(key, value);
2275
2764
  cacheSize++;
2276
2765
  if (cacheSize > maxCacheSize) {
2277
2766
  cacheSize = 0;
2278
2767
  previousCache = cache2;
2279
- cache2 = /* @__PURE__ */ Object.create(null);
2768
+ cache2 = /* @__PURE__ */ new Map();
2280
2769
  }
2281
2770
  };
2282
2771
  return {
2283
2772
  get(key) {
2284
- let value = cache2[key];
2773
+ let value = cache2.get(key);
2285
2774
  if (value !== void 0) {
2286
2775
  return value;
2287
2776
  }
2288
- if ((value = previousCache[key]) !== void 0) {
2777
+ if ((value = previousCache.get(key)) !== void 0) {
2289
2778
  update(key, value);
2290
2779
  return value;
2291
2780
  }
2292
2781
  },
2293
2782
  set(key, value) {
2294
- if (key in cache2) {
2295
- cache2[key] = value;
2783
+ if (cache2.has(key)) {
2784
+ cache2.set(key, value);
2296
2785
  } else {
2297
2786
  update(key, value);
2298
2787
  }
@@ -2301,14 +2790,7 @@ const createLruCache = (maxCacheSize) => {
2301
2790
  };
2302
2791
  const IMPORTANT_MODIFIER = "!";
2303
2792
  const MODIFIER_SEPARATOR = ":";
2304
- const EMPTY_MODIFIERS = [];
2305
- const createResultObject = (modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition, isExternal) => ({
2306
- modifiers,
2307
- hasImportantModifier,
2308
- baseClassName,
2309
- maybePostfixModifierPosition,
2310
- isExternal
2311
- });
2793
+ const MODIFIER_SEPARATOR_LENGTH = MODIFIER_SEPARATOR.length;
2312
2794
  const createParseClassName = (config) => {
2313
2795
  const {
2314
2796
  prefix,
@@ -2320,13 +2802,12 @@ const createParseClassName = (config) => {
2320
2802
  let parenDepth = 0;
2321
2803
  let modifierStart = 0;
2322
2804
  let postfixModifierPosition;
2323
- const len = className.length;
2324
- for (let index2 = 0; index2 < len; index2++) {
2325
- const currentCharacter = className[index2];
2805
+ for (let index2 = 0; index2 < className.length; index2++) {
2806
+ let currentCharacter = className[index2];
2326
2807
  if (bracketDepth === 0 && parenDepth === 0) {
2327
2808
  if (currentCharacter === MODIFIER_SEPARATOR) {
2328
2809
  modifiers.push(className.slice(modifierStart, index2));
2329
- modifierStart = index2 + 1;
2810
+ modifierStart = index2 + MODIFIER_SEPARATOR_LENGTH;
2330
2811
  continue;
2331
2812
  }
2332
2813
  if (currentCharacter === "/") {
@@ -2334,38 +2815,37 @@ const createParseClassName = (config) => {
2334
2815
  continue;
2335
2816
  }
2336
2817
  }
2337
- if (currentCharacter === "[")
2818
+ if (currentCharacter === "[") {
2338
2819
  bracketDepth++;
2339
- else if (currentCharacter === "]")
2820
+ } else if (currentCharacter === "]") {
2340
2821
  bracketDepth--;
2341
- else if (currentCharacter === "(")
2822
+ } else if (currentCharacter === "(") {
2342
2823
  parenDepth++;
2343
- else if (currentCharacter === ")")
2824
+ } else if (currentCharacter === ")") {
2344
2825
  parenDepth--;
2826
+ }
2345
2827
  }
2346
- const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.slice(modifierStart);
2347
- let baseClassName = baseClassNameWithImportantModifier;
2348
- let hasImportantModifier = false;
2349
- if (baseClassNameWithImportantModifier.endsWith(IMPORTANT_MODIFIER)) {
2350
- baseClassName = baseClassNameWithImportantModifier.slice(0, -1);
2351
- hasImportantModifier = true;
2352
- } else if (
2353
- /**
2354
- * In Tailwind CSS v3 the important modifier was at the start of the base class name. This is still supported for legacy reasons.
2355
- * @see https://github.com/dcastil/tailwind-merge/issues/513#issuecomment-2614029864
2356
- */
2357
- baseClassNameWithImportantModifier.startsWith(IMPORTANT_MODIFIER)
2358
- ) {
2359
- baseClassName = baseClassNameWithImportantModifier.slice(1);
2360
- hasImportantModifier = true;
2361
- }
2828
+ const baseClassNameWithImportantModifier = modifiers.length === 0 ? className : className.substring(modifierStart);
2829
+ const baseClassName = stripImportantModifier(baseClassNameWithImportantModifier);
2830
+ const hasImportantModifier = baseClassName !== baseClassNameWithImportantModifier;
2362
2831
  const maybePostfixModifierPosition = postfixModifierPosition && postfixModifierPosition > modifierStart ? postfixModifierPosition - modifierStart : void 0;
2363
- return createResultObject(modifiers, hasImportantModifier, baseClassName, maybePostfixModifierPosition);
2832
+ return {
2833
+ modifiers,
2834
+ hasImportantModifier,
2835
+ baseClassName,
2836
+ maybePostfixModifierPosition
2837
+ };
2364
2838
  };
2365
2839
  if (prefix) {
2366
2840
  const fullPrefix = prefix + MODIFIER_SEPARATOR;
2367
2841
  const parseClassNameOriginal = parseClassName;
2368
- parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.slice(fullPrefix.length)) : createResultObject(EMPTY_MODIFIERS, false, className, void 0, true);
2842
+ parseClassName = (className) => className.startsWith(fullPrefix) ? parseClassNameOriginal(className.substring(fullPrefix.length)) : {
2843
+ isExternal: true,
2844
+ modifiers: [],
2845
+ hasImportantModifier: false,
2846
+ baseClassName: className,
2847
+ maybePostfixModifierPosition: void 0
2848
+ };
2369
2849
  }
2370
2850
  if (experimentalParseClassName) {
2371
2851
  const parseClassNameOriginal = parseClassName;
@@ -2376,35 +2856,36 @@ const createParseClassName = (config) => {
2376
2856
  }
2377
2857
  return parseClassName;
2378
2858
  };
2859
+ const stripImportantModifier = (baseClassName) => {
2860
+ if (baseClassName.endsWith(IMPORTANT_MODIFIER)) {
2861
+ return baseClassName.substring(0, baseClassName.length - 1);
2862
+ }
2863
+ if (baseClassName.startsWith(IMPORTANT_MODIFIER)) {
2864
+ return baseClassName.substring(1);
2865
+ }
2866
+ return baseClassName;
2867
+ };
2379
2868
  const createSortModifiers = (config) => {
2380
- const modifierWeights = /* @__PURE__ */ new Map();
2381
- config.orderSensitiveModifiers.forEach((mod, index2) => {
2382
- modifierWeights.set(mod, 1e6 + index2);
2383
- });
2384
- return (modifiers) => {
2385
- const result = [];
2386
- let currentSegment = [];
2387
- for (let i2 = 0; i2 < modifiers.length; i2++) {
2388
- const modifier = modifiers[i2];
2389
- const isArbitrary = modifier[0] === "[";
2390
- const isOrderSensitive = modifierWeights.has(modifier);
2391
- if (isArbitrary || isOrderSensitive) {
2392
- if (currentSegment.length > 0) {
2393
- currentSegment.sort();
2394
- result.push(...currentSegment);
2395
- currentSegment = [];
2396
- }
2397
- result.push(modifier);
2869
+ const orderSensitiveModifiers = Object.fromEntries(config.orderSensitiveModifiers.map((modifier) => [modifier, true]));
2870
+ const sortModifiers = (modifiers) => {
2871
+ if (modifiers.length <= 1) {
2872
+ return modifiers;
2873
+ }
2874
+ const sortedModifiers = [];
2875
+ let unsortedModifiers = [];
2876
+ modifiers.forEach((modifier) => {
2877
+ const isPositionSensitive = modifier[0] === "[" || orderSensitiveModifiers[modifier];
2878
+ if (isPositionSensitive) {
2879
+ sortedModifiers.push(...unsortedModifiers.sort(), modifier);
2880
+ unsortedModifiers = [];
2398
2881
  } else {
2399
- currentSegment.push(modifier);
2882
+ unsortedModifiers.push(modifier);
2400
2883
  }
2401
- }
2402
- if (currentSegment.length > 0) {
2403
- currentSegment.sort();
2404
- result.push(...currentSegment);
2405
- }
2406
- return result;
2884
+ });
2885
+ sortedModifiers.push(...unsortedModifiers.sort());
2886
+ return sortedModifiers;
2407
2887
  };
2888
+ return sortModifiers;
2408
2889
  };
2409
2890
  const createConfigUtils = (config) => ({
2410
2891
  cache: createLruCache(config.cacheSize),
@@ -2450,10 +2931,10 @@ const mergeClassList = (classList, configUtils) => {
2450
2931
  }
2451
2932
  hasPostfixModifier = false;
2452
2933
  }
2453
- const variantModifier = modifiers.length === 0 ? "" : modifiers.length === 1 ? modifiers[0] : sortModifiers(modifiers).join(":");
2934
+ const variantModifier = sortModifiers(modifiers).join(":");
2454
2935
  const modifierId = hasImportantModifier ? variantModifier + IMPORTANT_MODIFIER : variantModifier;
2455
2936
  const classId = modifierId + classGroupId;
2456
- if (classGroupsInConflict.indexOf(classId) > -1) {
2937
+ if (classGroupsInConflict.includes(classId)) {
2457
2938
  continue;
2458
2939
  }
2459
2940
  classGroupsInConflict.push(classId);
@@ -2466,13 +2947,13 @@ const mergeClassList = (classList, configUtils) => {
2466
2947
  }
2467
2948
  return result;
2468
2949
  };
2469
- const twJoin = (...classLists) => {
2950
+ function twJoin() {
2470
2951
  let index2 = 0;
2471
2952
  let argument;
2472
2953
  let resolvedValue;
2473
2954
  let string = "";
2474
- while (index2 < classLists.length) {
2475
- if (argument = classLists[index2++]) {
2955
+ while (index2 < arguments.length) {
2956
+ if (argument = arguments[index2++]) {
2476
2957
  if (resolvedValue = toValue(argument)) {
2477
2958
  string && (string += " ");
2478
2959
  string += resolvedValue;
@@ -2480,7 +2961,7 @@ const twJoin = (...classLists) => {
2480
2961
  }
2481
2962
  }
2482
2963
  return string;
2483
- };
2964
+ }
2484
2965
  const toValue = (mix) => {
2485
2966
  if (typeof mix === "string") {
2486
2967
  return mix;
@@ -2497,20 +2978,20 @@ const toValue = (mix) => {
2497
2978
  }
2498
2979
  return string;
2499
2980
  };
2500
- const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
2981
+ function createTailwindMerge(createConfigFirst, ...createConfigRest) {
2501
2982
  let configUtils;
2502
2983
  let cacheGet;
2503
2984
  let cacheSet;
2504
- let functionToCall;
2505
- const initTailwindMerge = (classList) => {
2985
+ let functionToCall = initTailwindMerge;
2986
+ function initTailwindMerge(classList) {
2506
2987
  const config = createConfigRest.reduce((previousConfig, createConfigCurrent) => createConfigCurrent(previousConfig), createConfigFirst());
2507
2988
  configUtils = createConfigUtils(config);
2508
2989
  cacheGet = configUtils.cache.get;
2509
2990
  cacheSet = configUtils.cache.set;
2510
2991
  functionToCall = tailwindMerge;
2511
2992
  return tailwindMerge(classList);
2512
- };
2513
- const tailwindMerge = (classList) => {
2993
+ }
2994
+ function tailwindMerge(classList) {
2514
2995
  const cachedResult = cacheGet(classList);
2515
2996
  if (cachedResult) {
2516
2997
  return cachedResult;
@@ -2518,13 +2999,13 @@ const createTailwindMerge = (createConfigFirst, ...createConfigRest) => {
2518
2999
  const result = mergeClassList(classList, configUtils);
2519
3000
  cacheSet(classList, result);
2520
3001
  return result;
3002
+ }
3003
+ return function callTailwindMerge() {
3004
+ return functionToCall(twJoin.apply(null, arguments));
2521
3005
  };
2522
- functionToCall = initTailwindMerge;
2523
- return (...args) => functionToCall(twJoin(...args));
2524
- };
2525
- const fallbackThemeArr = [];
3006
+ }
2526
3007
  const fromTheme = (key) => {
2527
- const themeGetter = (theme2) => theme2[key] || fallbackThemeArr;
3008
+ const themeGetter = (theme2) => theme2[key] || [];
2528
3009
  themeGetter.isThemeGetter = true;
2529
3010
  return themeGetter;
2530
3011
  };
@@ -5166,6 +5647,40 @@ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForD
5166
5647
  }
5167
5648
  };
5168
5649
  }
5650
+ function setRef(ref, value) {
5651
+ if (typeof ref === "function") {
5652
+ return ref(value);
5653
+ } else if (ref !== null && ref !== void 0) {
5654
+ ref.current = value;
5655
+ }
5656
+ }
5657
+ function composeRefs(...refs) {
5658
+ return (node) => {
5659
+ let hasCleanup = false;
5660
+ const cleanups = refs.map((ref) => {
5661
+ const cleanup = setRef(ref, node);
5662
+ if (!hasCleanup && typeof cleanup == "function") {
5663
+ hasCleanup = true;
5664
+ }
5665
+ return cleanup;
5666
+ });
5667
+ if (hasCleanup) {
5668
+ return () => {
5669
+ for (let i2 = 0; i2 < cleanups.length; i2++) {
5670
+ const cleanup = cleanups[i2];
5671
+ if (typeof cleanup == "function") {
5672
+ cleanup();
5673
+ } else {
5674
+ setRef(refs[i2], null);
5675
+ }
5676
+ }
5677
+ };
5678
+ }
5679
+ };
5680
+ }
5681
+ function useComposedRefs(...refs) {
5682
+ return React$1.useCallback(composeRefs(...refs), refs);
5683
+ }
5169
5684
  function createContext2(rootComponentName, defaultContext) {
5170
5685
  const Context2 = React$1.createContext(defaultContext);
5171
5686
  const Provider2 = (props) => {
@@ -5184,7 +5699,7 @@ function createContext2(rootComponentName, defaultContext) {
5184
5699
  }
5185
5700
  return [Provider2, useContext2];
5186
5701
  }
5187
- function createContextScope$1(scopeName, createContextScopeDeps = []) {
5702
+ function createContextScope(scopeName, createContextScopeDeps = []) {
5188
5703
  let defaultContexts = [];
5189
5704
  function createContext3(rootComponentName, defaultContext) {
5190
5705
  const BaseContext = React$1.createContext(defaultContext);
@@ -5223,9 +5738,9 @@ function createContextScope$1(scopeName, createContextScopeDeps = []) {
5223
5738
  };
5224
5739
  };
5225
5740
  createScope.scopeName = scopeName;
5226
- return [createContext3, composeContextScopes$1(createScope, ...createContextScopeDeps)];
5741
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
5227
5742
  }
5228
- function composeContextScopes$1(...scopes) {
5743
+ function composeContextScopes(...scopes) {
5229
5744
  const baseScope = scopes[0];
5230
5745
  if (scopes.length === 1)
5231
5746
  return baseScope;
@@ -5325,12 +5840,12 @@ function isFunction(value) {
5325
5840
  return typeof value === "function";
5326
5841
  }
5327
5842
  // @__NO_SIDE_EFFECTS__
5328
- function createSlot$3(ownerName) {
5329
- const SlotClone = /* @__PURE__ */ createSlotClone$3(ownerName);
5843
+ function createSlot(ownerName) {
5844
+ const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
5330
5845
  const Slot2 = React$1.forwardRef((props, forwardedRef) => {
5331
5846
  const { children, ...slotProps } = props;
5332
5847
  const childrenArray = React$1.Children.toArray(children);
5333
- const slottable = childrenArray.find(isSlottable$3);
5848
+ const slottable = childrenArray.find(isSlottable);
5334
5849
  if (slottable) {
5335
5850
  const newElement = slottable.props.children;
5336
5851
  const newChildren = childrenArray.map((child) => {
@@ -5350,12 +5865,12 @@ function createSlot$3(ownerName) {
5350
5865
  return Slot2;
5351
5866
  }
5352
5867
  // @__NO_SIDE_EFFECTS__
5353
- function createSlotClone$3(ownerName) {
5868
+ function createSlotClone(ownerName) {
5354
5869
  const SlotClone = React$1.forwardRef((props, forwardedRef) => {
5355
5870
  const { children, ...slotProps } = props;
5356
5871
  if (React$1.isValidElement(children)) {
5357
- const childrenRef = getElementRef$4(children);
5358
- const props2 = mergeProps$3(slotProps, children.props);
5872
+ const childrenRef = getElementRef$1(children);
5873
+ const props2 = mergeProps(slotProps, children.props);
5359
5874
  if (children.type !== React$1.Fragment) {
5360
5875
  props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
5361
5876
  }
@@ -5366,20 +5881,20 @@ function createSlotClone$3(ownerName) {
5366
5881
  SlotClone.displayName = `${ownerName}.SlotClone`;
5367
5882
  return SlotClone;
5368
5883
  }
5369
- var SLOTTABLE_IDENTIFIER$3 = Symbol("radix.slottable");
5884
+ var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
5370
5885
  // @__NO_SIDE_EFFECTS__
5371
5886
  function createSlottable(ownerName) {
5372
5887
  const Slottable2 = ({ children }) => {
5373
5888
  return /* @__PURE__ */ jsx(Fragment, { children });
5374
5889
  };
5375
5890
  Slottable2.displayName = `${ownerName}.Slottable`;
5376
- Slottable2.__radixId = SLOTTABLE_IDENTIFIER$3;
5891
+ Slottable2.__radixId = SLOTTABLE_IDENTIFIER;
5377
5892
  return Slottable2;
5378
5893
  }
5379
- function isSlottable$3(child) {
5380
- return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$3;
5894
+ function isSlottable(child) {
5895
+ return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
5381
5896
  }
5382
- function mergeProps$3(slotProps, childProps) {
5897
+ function mergeProps(slotProps, childProps) {
5383
5898
  const overrideProps = { ...childProps };
5384
5899
  for (const propName in childProps) {
5385
5900
  const slotPropValue = slotProps[propName];
@@ -5403,7 +5918,7 @@ function mergeProps$3(slotProps, childProps) {
5403
5918
  }
5404
5919
  return { ...slotProps, ...overrideProps };
5405
5920
  }
5406
- function getElementRef$4(element) {
5921
+ function getElementRef$1(element) {
5407
5922
  var _a, _b;
5408
5923
  let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
5409
5924
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
@@ -5417,7 +5932,7 @@ function getElementRef$4(element) {
5417
5932
  }
5418
5933
  return element.props.ref || element.ref;
5419
5934
  }
5420
- var NODES$3 = [
5935
+ var NODES = [
5421
5936
  "a",
5422
5937
  "button",
5423
5938
  "div",
@@ -5436,8 +5951,8 @@ var NODES$3 = [
5436
5951
  "svg",
5437
5952
  "ul"
5438
5953
  ];
5439
- var Primitive$3 = NODES$3.reduce((primitive, node) => {
5440
- const Slot2 = /* @__PURE__ */ createSlot$3(`Primitive.${node}`);
5954
+ var Primitive = NODES.reduce((primitive, node) => {
5955
+ const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
5441
5956
  const Node2 = React$1.forwardRef((props, forwardedRef) => {
5442
5957
  const { asChild, ...primitiveProps } = props;
5443
5958
  const Comp = asChild ? Slot2 : node;
@@ -5570,7 +6085,7 @@ var DismissableLayer = React$1.forwardRef(
5570
6085
  return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
5571
6086
  }, []);
5572
6087
  return /* @__PURE__ */ jsx(
5573
- Primitive$3.div,
6088
+ Primitive.div,
5574
6089
  {
5575
6090
  ...layerProps,
5576
6091
  ref: composedRefs,
@@ -5603,7 +6118,7 @@ var DismissableLayerBranch = React$1.forwardRef((props, forwardedRef) => {
5603
6118
  };
5604
6119
  }
5605
6120
  }, [context.branches]);
5606
- return /* @__PURE__ */ jsx(Primitive$3.div, { ...props, ref: composedRefs });
6121
+ return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
5607
6122
  });
5608
6123
  DismissableLayerBranch.displayName = BRANCH_NAME;
5609
6124
  function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
@@ -5812,7 +6327,7 @@ var FocusScope = React$1.forwardRef((props, forwardedRef) => {
5812
6327
  },
5813
6328
  [loop, trapped, focusScope.paused]
5814
6329
  );
5815
- return /* @__PURE__ */ jsx(Primitive$3.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
6330
+ return /* @__PURE__ */ jsx(Primitive.div, { tabIndex: -1, ...scopeProps, ref: composedRefs, onKeyDown: handleKeyDown });
5816
6331
  });
5817
6332
  FocusScope.displayName = FOCUS_SCOPE_NAME;
5818
6333
  function focusFirst$2(candidates, { select = false } = {}) {
@@ -5909,7 +6424,7 @@ var Portal$5 = React$1.forwardRef((props, forwardedRef) => {
5909
6424
  const [mounted, setMounted] = React$1.useState(false);
5910
6425
  useLayoutEffect2(() => setMounted(true), []);
5911
6426
  const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
5912
- return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive$3.div, { ...portalProps, ref: forwardedRef }), container) : null;
6427
+ return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
5913
6428
  });
5914
6429
  Portal$5.displayName = PORTAL_NAME$6;
5915
6430
  function useStateMachine(initialState, machine) {
@@ -5922,7 +6437,7 @@ var Presence = (props) => {
5922
6437
  const { present, children } = props;
5923
6438
  const presence = usePresence(present);
5924
6439
  const child = typeof children === "function" ? children({ present: presence.isPresent }) : React$1.Children.only(children);
5925
- const ref = useComposedRefs(presence.ref, getElementRef$3(child));
6440
+ const ref = useComposedRefs(presence.ref, getElementRef(child));
5926
6441
  const forceMount = typeof children === "function";
5927
6442
  return forceMount || presence.isPresent ? React$1.cloneElement(child, { ref }) : null;
5928
6443
  };
@@ -6021,7 +6536,7 @@ function usePresence(present) {
6021
6536
  function getAnimationName(styles) {
6022
6537
  return (styles == null ? void 0 : styles.animationName) || "none";
6023
6538
  }
6024
- function getElementRef$3(element) {
6539
+ function getElementRef(element) {
6025
6540
  var _a, _b;
6026
6541
  let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
6027
6542
  let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
@@ -6844,7 +7359,7 @@ var hideOthers = function(originalTarget, parentNode, markerName) {
6844
7359
  return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
6845
7360
  };
6846
7361
  var DIALOG_NAME = "Dialog";
6847
- var [createDialogContext, createDialogScope] = createContextScope$1(DIALOG_NAME);
7362
+ var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
6848
7363
  var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
6849
7364
  var Dialog$1 = (props) => {
6850
7365
  const {
@@ -6888,7 +7403,7 @@ var DialogTrigger = React$1.forwardRef(
6888
7403
  const context = useDialogContext(TRIGGER_NAME$5, __scopeDialog);
6889
7404
  const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
6890
7405
  return /* @__PURE__ */ jsx(
6891
- Primitive$3.button,
7406
+ Primitive.button,
6892
7407
  {
6893
7408
  type: "button",
6894
7409
  "aria-haspopup": "dialog",
@@ -6923,7 +7438,7 @@ var DialogOverlay$1 = React$1.forwardRef(
6923
7438
  }
6924
7439
  );
6925
7440
  DialogOverlay$1.displayName = OVERLAY_NAME;
6926
- var Slot$3 = /* @__PURE__ */ createSlot$3("DialogOverlay.RemoveScroll");
7441
+ var Slot$3 = /* @__PURE__ */ createSlot("DialogOverlay.RemoveScroll");
6927
7442
  var DialogOverlayImpl = React$1.forwardRef(
6928
7443
  (props, forwardedRef) => {
6929
7444
  const { __scopeDialog, ...overlayProps } = props;
@@ -6932,7 +7447,7 @@ var DialogOverlayImpl = React$1.forwardRef(
6932
7447
  // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
6933
7448
  // ie. when `Overlay` and `Content` are siblings
6934
7449
  /* @__PURE__ */ jsx(RemoveScroll, { as: Slot$3, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsx(
6935
- Primitive$3.div,
7450
+ Primitive.div,
6936
7451
  {
6937
7452
  "data-state": getState$1(context.open),
6938
7453
  ...overlayProps,
@@ -7077,7 +7592,7 @@ var DialogTitle$1 = React$1.forwardRef(
7077
7592
  (props, forwardedRef) => {
7078
7593
  const { __scopeDialog, ...titleProps } = props;
7079
7594
  const context = useDialogContext(TITLE_NAME, __scopeDialog);
7080
- return /* @__PURE__ */ jsx(Primitive$3.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
7595
+ return /* @__PURE__ */ jsx(Primitive.h2, { id: context.titleId, ...titleProps, ref: forwardedRef });
7081
7596
  }
7082
7597
  );
7083
7598
  DialogTitle$1.displayName = TITLE_NAME;
@@ -7086,7 +7601,7 @@ var DialogDescription$1 = React$1.forwardRef(
7086
7601
  (props, forwardedRef) => {
7087
7602
  const { __scopeDialog, ...descriptionProps } = props;
7088
7603
  const context = useDialogContext(DESCRIPTION_NAME, __scopeDialog);
7089
- return /* @__PURE__ */ jsx(Primitive$3.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
7604
+ return /* @__PURE__ */ jsx(Primitive.p, { id: context.descriptionId, ...descriptionProps, ref: forwardedRef });
7090
7605
  }
7091
7606
  );
7092
7607
  DialogDescription$1.displayName = DESCRIPTION_NAME;
@@ -7096,7 +7611,7 @@ var DialogClose = React$1.forwardRef(
7096
7611
  const { __scopeDialog, ...closeProps } = props;
7097
7612
  const context = useDialogContext(CLOSE_NAME$1, __scopeDialog);
7098
7613
  return /* @__PURE__ */ jsx(
7099
- Primitive$3.button,
7614
+ Primitive.button,
7100
7615
  {
7101
7616
  type: "button",
7102
7617
  ...closeProps,
@@ -7293,6 +7808,18 @@ const ArrowRight = createLucideIcon("ArrowRight", [
7293
7808
  ["path", { d: "M5 12h14", key: "1ays0h" }],
7294
7809
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
7295
7810
  ]);
7811
+ /**
7812
+ * @license lucide-react v0.344.0 - ISC
7813
+ *
7814
+ * This source code is licensed under the ISC license.
7815
+ * See the LICENSE file in the root directory of this source tree.
7816
+ */
7817
+ const BarChart3 = createLucideIcon("BarChart3", [
7818
+ ["path", { d: "M3 3v18h18", key: "1s2lah" }],
7819
+ ["path", { d: "M18 17V9", key: "2bz60n" }],
7820
+ ["path", { d: "M13 17V5", key: "1frdt8" }],
7821
+ ["path", { d: "M8 17v-3", key: "17ska0" }]
7822
+ ]);
7296
7823
  /**
7297
7824
  * @license lucide-react v0.344.0 - ISC
7298
7825
  *
@@ -7426,23 +7953,6 @@ const Download = createLucideIcon("Download", [
7426
7953
  ["polyline", { points: "7 10 12 15 17 10", key: "2ggqvy" }],
7427
7954
  ["line", { x1: "12", x2: "12", y1: "15", y2: "3", key: "1vk2je" }]
7428
7955
  ]);
7429
- /**
7430
- * @license lucide-react v0.344.0 - ISC
7431
- *
7432
- * This source code is licensed under the ISC license.
7433
- * See the LICENSE file in the root directory of this source tree.
7434
- */
7435
- const Eraser = createLucideIcon("Eraser", [
7436
- [
7437
- "path",
7438
- {
7439
- d: "m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",
7440
- key: "182aya"
7441
- }
7442
- ],
7443
- ["path", { d: "M22 21H7", key: "t4ddhn" }],
7444
- ["path", { d: "m5 11 9 9", key: "1mo9qw" }]
7445
- ]);
7446
7956
  /**
7447
7957
  * @license lucide-react v0.344.0 - ISC
7448
7958
  *
@@ -7820,6 +8330,18 @@ const PenLine = createLucideIcon("PenLine", [
7820
8330
  ["path", { d: "M12 20h9", key: "t2du7b" }],
7821
8331
  ["path", { d: "M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z", key: "ymcmye" }]
7822
8332
  ]);
8333
+ /**
8334
+ * @license lucide-react v0.344.0 - ISC
8335
+ *
8336
+ * This source code is licensed under the ISC license.
8337
+ * See the LICENSE file in the root directory of this source tree.
8338
+ */
8339
+ const PenTool = createLucideIcon("PenTool", [
8340
+ ["path", { d: "m12 19 7-7 3 3-7 7-3-3z", key: "rklqx2" }],
8341
+ ["path", { d: "m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z", key: "1et58u" }],
8342
+ ["path", { d: "m2 2 7.586 7.586", key: "etlp93" }],
8343
+ ["circle", { cx: "11", cy: "11", r: "2", key: "xmgehs" }]
8344
+ ]);
7823
8345
  /**
7824
8346
  * @license lucide-react v0.344.0 - ISC
7825
8347
  *
@@ -7933,6 +8455,17 @@ const Sparkles = createLucideIcon("Sparkles", [
7933
8455
  ["path", { d: "M3 5h4", key: "nem4j1" }],
7934
8456
  ["path", { d: "M17 19h4", key: "lbex7p" }]
7935
8457
  ]);
8458
+ /**
8459
+ * @license lucide-react v0.344.0 - ISC
8460
+ *
8461
+ * This source code is licensed under the ISC license.
8462
+ * See the LICENSE file in the root directory of this source tree.
8463
+ */
8464
+ const SpellCheck = createLucideIcon("SpellCheck", [
8465
+ ["path", { d: "m6 16 6-12 6 12", key: "1b4byz" }],
8466
+ ["path", { d: "M8 12h8", key: "1wcyev" }],
8467
+ ["path", { d: "m16 20 2 2 4-4", key: "13tcca" }]
8468
+ ]);
7936
8469
  /**
7937
8470
  * @license lucide-react v0.344.0 - ISC
7938
8471
  *
@@ -8126,7 +8659,7 @@ const DialogContent = React$1.forwardRef(({ className, children, ...props }, ref
8126
8659
  /* @__PURE__ */ jsxs(
8127
8660
  Close,
8128
8661
  {
8129
- className: "closeDialog cteditor-absolute cteditor-right-4 cteditor-top-4 cteditor-rounded-full cteditor-bg-secondary cteditor-p-1 cteditor-opacity-70 cteditor-transition-opacity focus:cteditor-outline-none cteditor-disabled:pointer-events-none data-[state=open]:cteditor-bg-accent data-[state=open]:cteditor-text-muted-foreground hover:cteditor-opacity-100\n",
8662
+ className: "closeDialog cteditor-absolute cteditor-right-4 cteditor-top-4 cteditor-rounded-full cteditor-bg-secondary cteditor-p-1 cteditor-opacity-70 cteditor-transition-opacity focus:cteditor-outline-none cteditor-disabled:pointer-events-none data-[state=open]:cteditor-bg-accent data-[state=open]:cteditor-text-muted-foreground hover:cteditor-opacity-100\r\n",
8130
8663
  children: [
8131
8664
  /* @__PURE__ */ jsx(X$1, { className: "cteditor-h-4 cteditor-w-4" }),
8132
8665
  /* @__PURE__ */ jsx("span", { className: "!cteditor-sr-only", children: "Close" })
@@ -8204,140 +8737,10 @@ const Input$1 = React$1.forwardRef(
8204
8737
  }
8205
8738
  );
8206
8739
  Input$1.displayName = "Input";
8207
- var REACT_LAZY_TYPE$2 = Symbol.for("react.lazy");
8208
- var use$2 = React$1[" use ".trim().toString()];
8209
- function isPromiseLike$2(value) {
8210
- return typeof value === "object" && value !== null && "then" in value;
8211
- }
8212
- function isLazyComponent$2(element) {
8213
- return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE$2 && "_payload" in element && isPromiseLike$2(element._payload);
8214
- }
8215
- // @__NO_SIDE_EFFECTS__
8216
- function createSlot$2(ownerName) {
8217
- const SlotClone = /* @__PURE__ */ createSlotClone$2(ownerName);
8218
- const Slot2 = React$1.forwardRef((props, forwardedRef) => {
8219
- let { children, ...slotProps } = props;
8220
- if (isLazyComponent$2(children) && typeof use$2 === "function") {
8221
- children = use$2(children._payload);
8222
- }
8223
- const childrenArray = React$1.Children.toArray(children);
8224
- const slottable = childrenArray.find(isSlottable$2);
8225
- if (slottable) {
8226
- const newElement = slottable.props.children;
8227
- const newChildren = childrenArray.map((child) => {
8228
- if (child === slottable) {
8229
- if (React$1.Children.count(newElement) > 1)
8230
- return React$1.Children.only(null);
8231
- return React$1.isValidElement(newElement) ? newElement.props.children : null;
8232
- } else {
8233
- return child;
8234
- }
8235
- });
8236
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React$1.isValidElement(newElement) ? React$1.cloneElement(newElement, void 0, newChildren) : null });
8237
- }
8238
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
8239
- });
8240
- Slot2.displayName = `${ownerName}.Slot`;
8241
- return Slot2;
8242
- }
8243
- // @__NO_SIDE_EFFECTS__
8244
- function createSlotClone$2(ownerName) {
8245
- const SlotClone = React$1.forwardRef((props, forwardedRef) => {
8246
- let { children, ...slotProps } = props;
8247
- if (isLazyComponent$2(children) && typeof use$2 === "function") {
8248
- children = use$2(children._payload);
8249
- }
8250
- if (React$1.isValidElement(children)) {
8251
- const childrenRef = getElementRef$2(children);
8252
- const props2 = mergeProps$2(slotProps, children.props);
8253
- if (children.type !== React$1.Fragment) {
8254
- props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
8255
- }
8256
- return React$1.cloneElement(children, props2);
8257
- }
8258
- return React$1.Children.count(children) > 1 ? React$1.Children.only(null) : null;
8259
- });
8260
- SlotClone.displayName = `${ownerName}.SlotClone`;
8261
- return SlotClone;
8262
- }
8263
- var SLOTTABLE_IDENTIFIER$2 = Symbol("radix.slottable");
8264
- function isSlottable$2(child) {
8265
- return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$2;
8266
- }
8267
- function mergeProps$2(slotProps, childProps) {
8268
- const overrideProps = { ...childProps };
8269
- for (const propName in childProps) {
8270
- const slotPropValue = slotProps[propName];
8271
- const childPropValue = childProps[propName];
8272
- const isHandler = /^on[A-Z]/.test(propName);
8273
- if (isHandler) {
8274
- if (slotPropValue && childPropValue) {
8275
- overrideProps[propName] = (...args) => {
8276
- const result = childPropValue(...args);
8277
- slotPropValue(...args);
8278
- return result;
8279
- };
8280
- } else if (slotPropValue) {
8281
- overrideProps[propName] = slotPropValue;
8282
- }
8283
- } else if (propName === "style") {
8284
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
8285
- } else if (propName === "className") {
8286
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
8287
- }
8288
- }
8289
- return { ...slotProps, ...overrideProps };
8290
- }
8291
- function getElementRef$2(element) {
8292
- var _a, _b;
8293
- let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
8294
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
8295
- if (mayWarn) {
8296
- return element.ref;
8297
- }
8298
- getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
8299
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
8300
- if (mayWarn) {
8301
- return element.props.ref;
8302
- }
8303
- return element.props.ref || element.ref;
8304
- }
8305
- var NODES$2 = [
8306
- "a",
8307
- "button",
8308
- "div",
8309
- "form",
8310
- "h2",
8311
- "h3",
8312
- "img",
8313
- "input",
8314
- "label",
8315
- "li",
8316
- "nav",
8317
- "ol",
8318
- "p",
8319
- "select",
8320
- "span",
8321
- "svg",
8322
- "ul"
8323
- ];
8324
- var Primitive$2 = NODES$2.reduce((primitive, node) => {
8325
- const Slot2 = /* @__PURE__ */ createSlot$2(`Primitive.${node}`);
8326
- const Node2 = React$1.forwardRef((props, forwardedRef) => {
8327
- const { asChild, ...primitiveProps } = props;
8328
- const Comp = asChild ? Slot2 : node;
8329
- if (typeof window !== "undefined") {
8330
- window[Symbol.for("radix-ui")] = true;
8331
- }
8332
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
8333
- });
8334
- Node2.displayName = `Primitive.${node}`;
8335
- return { ...primitive, [node]: Node2 };
8336
- }, {});
8337
8740
  var NAME$4 = "Label";
8338
8741
  var Label$3 = React$1.forwardRef((props, forwardedRef) => {
8339
8742
  return /* @__PURE__ */ jsx(
8340
- Primitive$2.label,
8743
+ Primitive.label,
8341
8744
  {
8342
8745
  ...props,
8343
8746
  ref: forwardedRef,
@@ -8856,7 +9259,7 @@ const AIRephrasePlugin = () => {
8856
9259
  duration: Infinity
8857
9260
  });
8858
9261
  try {
8859
- const response = type === "MAKE_LONGER" || type === "MAKE_SHORTER" ? await AiTextTransform({ content: prompt, apiKey: apiKey || void 0 }) : await AiJsonResponse({ content: prompt });
9262
+ const response = type === "MAKE_LONGER" || type === "MAKE_SHORTER" ? await AiTextTransform({ content: prompt, apiKey: apiKey || void 0 }) : await AiJsonResponse({ content: prompt, apiKey: apiKey || void 0 });
8860
9263
  if (!response.data) {
8861
9264
  console.warn("Empty response received");
8862
9265
  toast.dismiss(loadingToastId);
@@ -8898,7 +9301,7 @@ const AIRephrasePlugin = () => {
8898
9301
  const prompt = `Translate this text to ${targetLanguage}. Return ONLY the translated text without any markdown formatting, headers, or special symbols. Just the plain translated text:
8899
9302
 
8900
9303
  "${selectedTextForTranslation}"`;
8901
- const response = await AiJsonResponse({ content: prompt });
9304
+ const response = await AiJsonResponse({ content: prompt, apiKey: apiKey || void 0 });
8902
9305
  if (!response.data) {
8903
9306
  console.warn("Empty response received");
8904
9307
  toast.dismiss(loadingToastId);
@@ -9026,7 +9429,7 @@ const AIRephrasePlugin = () => {
9026
9429
  };
9027
9430
  const generateImageFromPrompt = async (promptText) => {
9028
9431
  try {
9029
- const response = await AiJsonResponse({ content: `Generate Image: ${promptText}` });
9432
+ const response = await AiJsonResponse({ content: `Generate Image: ${promptText}`, apiKey: apiKey || void 0 });
9030
9433
  const htmlString = response == null ? void 0 : response.data;
9031
9434
  if (!htmlString) {
9032
9435
  console.warn("No HTML returned from agent for image generation");
@@ -9181,7 +9584,7 @@ const AIRephrasePlugin = () => {
9181
9584
  )
9182
9585
  ] });
9183
9586
  };
9184
- const index$8 = "";
9587
+ const index$7 = "";
9185
9588
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
9186
9589
  const freeGlobal$1 = freeGlobal;
9187
9590
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
@@ -9409,18 +9812,18 @@ function CopyButton({ editor, getCodeDOMNode }) {
9409
9812
  }
9410
9813
  );
9411
9814
  }
9412
- const index$7 = "";
9815
+ const index$6 = "";
9413
9816
  const PRETTIER_PARSER_MODULES = {
9414
- css: [() => import("./postcss-f084f74d.js")],
9415
- html: [() => import("./html-5586dbf6.js")],
9817
+ css: [() => import("./postcss-c2592f3f.js")],
9818
+ html: [() => import("./html-f95ee5dc.js")],
9416
9819
  js: [
9417
- () => import("./babel-d3085146.js"),
9418
- () => import("./estree-164983f6.js")
9820
+ () => import("./babel-d155920e.js"),
9821
+ () => import("./estree-b1fff53b.js")
9419
9822
  ],
9420
- markdown: [() => import("./markdown-d513479b.js")],
9823
+ markdown: [() => import("./markdown-1d9e6c3f.js")],
9421
9824
  typescript: [
9422
- () => import("./typescript-b1005db4.js"),
9423
- () => import("./estree-164983f6.js")
9825
+ () => import("./typescript-48c10f50.js"),
9826
+ () => import("./estree-b1fff53b.js")
9424
9827
  ]
9425
9828
  };
9426
9829
  async function loadPrettierParserByLang(lang) {
@@ -9431,7 +9834,7 @@ async function loadPrettierParserByLang(lang) {
9431
9834
  return modules;
9432
9835
  }
9433
9836
  async function loadPrettierFormat() {
9434
- const { format } = await import("./standalone-5a8c6b7e.js");
9837
+ const { format } = await import("./standalone-bcc7f37a.js");
9435
9838
  return format;
9436
9839
  }
9437
9840
  const PRETTIER_OPTIONS_BY_LANG = {
@@ -9908,199 +10311,6 @@ function $createCommentedTextNode(text, commentId, commentText, commentAuthor, c
9908
10311
  function $isCommentedTextNode(node) {
9909
10312
  return node instanceof CommentedTextNode;
9910
10313
  }
9911
- function createContextScope(scopeName, createContextScopeDeps = []) {
9912
- let defaultContexts = [];
9913
- function createContext3(rootComponentName, defaultContext) {
9914
- const BaseContext = React$1.createContext(defaultContext);
9915
- BaseContext.displayName = rootComponentName + "Context";
9916
- const index2 = defaultContexts.length;
9917
- defaultContexts = [...defaultContexts, defaultContext];
9918
- const Provider2 = (props) => {
9919
- var _a;
9920
- const { scope, children, ...context } = props;
9921
- const Context2 = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index2]) || BaseContext;
9922
- const value = React$1.useMemo(() => context, Object.values(context));
9923
- return /* @__PURE__ */ jsx(Context2.Provider, { value, children });
9924
- };
9925
- Provider2.displayName = rootComponentName + "Provider";
9926
- function useContext2(consumerName, scope) {
9927
- var _a;
9928
- const Context2 = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index2]) || BaseContext;
9929
- const context = React$1.useContext(Context2);
9930
- if (context)
9931
- return context;
9932
- if (defaultContext !== void 0)
9933
- return defaultContext;
9934
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
9935
- }
9936
- return [Provider2, useContext2];
9937
- }
9938
- const createScope = () => {
9939
- const scopeContexts = defaultContexts.map((defaultContext) => {
9940
- return React$1.createContext(defaultContext);
9941
- });
9942
- return function useScope(scope) {
9943
- const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
9944
- return React$1.useMemo(
9945
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
9946
- [scope, contexts]
9947
- );
9948
- };
9949
- };
9950
- createScope.scopeName = scopeName;
9951
- return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
9952
- }
9953
- function composeContextScopes(...scopes) {
9954
- const baseScope = scopes[0];
9955
- if (scopes.length === 1)
9956
- return baseScope;
9957
- const createScope = () => {
9958
- const scopeHooks = scopes.map((createScope2) => ({
9959
- useScope: createScope2(),
9960
- scopeName: createScope2.scopeName
9961
- }));
9962
- return function useComposedScopes(overrideScopes) {
9963
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
9964
- const scopeProps = useScope(overrideScopes);
9965
- const currentScope = scopeProps[`__scope${scopeName}`];
9966
- return { ...nextScopes2, ...currentScope };
9967
- }, {});
9968
- return React$1.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
9969
- };
9970
- };
9971
- createScope.scopeName = baseScope.scopeName;
9972
- return createScope;
9973
- }
9974
- var REACT_LAZY_TYPE$1 = Symbol.for("react.lazy");
9975
- var use$1 = React$1[" use ".trim().toString()];
9976
- function isPromiseLike$1(value) {
9977
- return typeof value === "object" && value !== null && "then" in value;
9978
- }
9979
- function isLazyComponent$1(element) {
9980
- return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE$1 && "_payload" in element && isPromiseLike$1(element._payload);
9981
- }
9982
- // @__NO_SIDE_EFFECTS__
9983
- function createSlot$1(ownerName) {
9984
- const SlotClone = /* @__PURE__ */ createSlotClone$1(ownerName);
9985
- const Slot2 = React$1.forwardRef((props, forwardedRef) => {
9986
- let { children, ...slotProps } = props;
9987
- if (isLazyComponent$1(children) && typeof use$1 === "function") {
9988
- children = use$1(children._payload);
9989
- }
9990
- const childrenArray = React$1.Children.toArray(children);
9991
- const slottable = childrenArray.find(isSlottable$1);
9992
- if (slottable) {
9993
- const newElement = slottable.props.children;
9994
- const newChildren = childrenArray.map((child) => {
9995
- if (child === slottable) {
9996
- if (React$1.Children.count(newElement) > 1)
9997
- return React$1.Children.only(null);
9998
- return React$1.isValidElement(newElement) ? newElement.props.children : null;
9999
- } else {
10000
- return child;
10001
- }
10002
- });
10003
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React$1.isValidElement(newElement) ? React$1.cloneElement(newElement, void 0, newChildren) : null });
10004
- }
10005
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
10006
- });
10007
- Slot2.displayName = `${ownerName}.Slot`;
10008
- return Slot2;
10009
- }
10010
- // @__NO_SIDE_EFFECTS__
10011
- function createSlotClone$1(ownerName) {
10012
- const SlotClone = React$1.forwardRef((props, forwardedRef) => {
10013
- let { children, ...slotProps } = props;
10014
- if (isLazyComponent$1(children) && typeof use$1 === "function") {
10015
- children = use$1(children._payload);
10016
- }
10017
- if (React$1.isValidElement(children)) {
10018
- const childrenRef = getElementRef$1(children);
10019
- const props2 = mergeProps$1(slotProps, children.props);
10020
- if (children.type !== React$1.Fragment) {
10021
- props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
10022
- }
10023
- return React$1.cloneElement(children, props2);
10024
- }
10025
- return React$1.Children.count(children) > 1 ? React$1.Children.only(null) : null;
10026
- });
10027
- SlotClone.displayName = `${ownerName}.SlotClone`;
10028
- return SlotClone;
10029
- }
10030
- var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
10031
- function isSlottable$1(child) {
10032
- return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
10033
- }
10034
- function mergeProps$1(slotProps, childProps) {
10035
- const overrideProps = { ...childProps };
10036
- for (const propName in childProps) {
10037
- const slotPropValue = slotProps[propName];
10038
- const childPropValue = childProps[propName];
10039
- const isHandler = /^on[A-Z]/.test(propName);
10040
- if (isHandler) {
10041
- if (slotPropValue && childPropValue) {
10042
- overrideProps[propName] = (...args) => {
10043
- const result = childPropValue(...args);
10044
- slotPropValue(...args);
10045
- return result;
10046
- };
10047
- } else if (slotPropValue) {
10048
- overrideProps[propName] = slotPropValue;
10049
- }
10050
- } else if (propName === "style") {
10051
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
10052
- } else if (propName === "className") {
10053
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
10054
- }
10055
- }
10056
- return { ...slotProps, ...overrideProps };
10057
- }
10058
- function getElementRef$1(element) {
10059
- var _a, _b;
10060
- let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
10061
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
10062
- if (mayWarn) {
10063
- return element.ref;
10064
- }
10065
- getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
10066
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
10067
- if (mayWarn) {
10068
- return element.props.ref;
10069
- }
10070
- return element.props.ref || element.ref;
10071
- }
10072
- var NODES$1 = [
10073
- "a",
10074
- "button",
10075
- "div",
10076
- "form",
10077
- "h2",
10078
- "h3",
10079
- "img",
10080
- "input",
10081
- "label",
10082
- "li",
10083
- "nav",
10084
- "ol",
10085
- "p",
10086
- "select",
10087
- "span",
10088
- "svg",
10089
- "ul"
10090
- ];
10091
- var Primitive$1 = NODES$1.reduce((primitive, node) => {
10092
- const Slot2 = /* @__PURE__ */ createSlot$1(`Primitive.${node}`);
10093
- const Node2 = React$1.forwardRef((props, forwardedRef) => {
10094
- const { asChild, ...primitiveProps } = props;
10095
- const Comp = asChild ? Slot2 : node;
10096
- if (typeof window !== "undefined") {
10097
- window[Symbol.for("radix-ui")] = true;
10098
- }
10099
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
10100
- });
10101
- Node2.displayName = `Primitive.${node}`;
10102
- return { ...primitive, [node]: Node2 };
10103
- }, {});
10104
10314
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
10105
10315
  function getDefaultExportFromCjs(x2) {
10106
10316
  return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
@@ -10186,7 +10396,7 @@ var Avatar$1 = React$1.forwardRef(
10186
10396
  scope: __scopeAvatar,
10187
10397
  imageLoadingStatus,
10188
10398
  onImageLoadingStatusChange: setImageLoadingStatus,
10189
- children: /* @__PURE__ */ jsx(Primitive$1.span, { ...avatarProps, ref: forwardedRef })
10399
+ children: /* @__PURE__ */ jsx(Primitive.span, { ...avatarProps, ref: forwardedRef })
10190
10400
  }
10191
10401
  );
10192
10402
  }
@@ -10208,7 +10418,7 @@ var AvatarImage$1 = React$1.forwardRef(
10208
10418
  handleLoadingStatusChange(imageLoadingStatus);
10209
10419
  }
10210
10420
  }, [imageLoadingStatus, handleLoadingStatusChange]);
10211
- return imageLoadingStatus === "loaded" ? /* @__PURE__ */ jsx(Primitive$1.img, { ...imageProps, ref: forwardedRef, src }) : null;
10421
+ return imageLoadingStatus === "loaded" ? /* @__PURE__ */ jsx(Primitive.img, { ...imageProps, ref: forwardedRef, src }) : null;
10212
10422
  }
10213
10423
  );
10214
10424
  AvatarImage$1.displayName = IMAGE_NAME;
@@ -10224,7 +10434,7 @@ var AvatarFallback$1 = React$1.forwardRef(
10224
10434
  return () => window.clearTimeout(timerId);
10225
10435
  }
10226
10436
  }, [delayMs]);
10227
- return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ jsx(Primitive$1.span, { ...fallbackProps, ref: forwardedRef }) : null;
10437
+ return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ jsx(Primitive.span, { ...fallbackProps, ref: forwardedRef }) : null;
10228
10438
  }
10229
10439
  );
10230
10440
  AvatarFallback$1.displayName = FALLBACK_NAME;
@@ -10369,136 +10579,6 @@ const CardFooter = React$1.forwardRef(({ className, ...props }, ref) => /* @__PU
10369
10579
  }
10370
10580
  ));
10371
10581
  CardFooter.displayName = "CardFooter";
10372
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
10373
- var use = React$1[" use ".trim().toString()];
10374
- function isPromiseLike(value) {
10375
- return typeof value === "object" && value !== null && "then" in value;
10376
- }
10377
- function isLazyComponent(element) {
10378
- return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
10379
- }
10380
- // @__NO_SIDE_EFFECTS__
10381
- function createSlot(ownerName) {
10382
- const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
10383
- const Slot2 = React$1.forwardRef((props, forwardedRef) => {
10384
- let { children, ...slotProps } = props;
10385
- if (isLazyComponent(children) && typeof use === "function") {
10386
- children = use(children._payload);
10387
- }
10388
- const childrenArray = React$1.Children.toArray(children);
10389
- const slottable = childrenArray.find(isSlottable);
10390
- if (slottable) {
10391
- const newElement = slottable.props.children;
10392
- const newChildren = childrenArray.map((child) => {
10393
- if (child === slottable) {
10394
- if (React$1.Children.count(newElement) > 1)
10395
- return React$1.Children.only(null);
10396
- return React$1.isValidElement(newElement) ? newElement.props.children : null;
10397
- } else {
10398
- return child;
10399
- }
10400
- });
10401
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React$1.isValidElement(newElement) ? React$1.cloneElement(newElement, void 0, newChildren) : null });
10402
- }
10403
- return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
10404
- });
10405
- Slot2.displayName = `${ownerName}.Slot`;
10406
- return Slot2;
10407
- }
10408
- // @__NO_SIDE_EFFECTS__
10409
- function createSlotClone(ownerName) {
10410
- const SlotClone = React$1.forwardRef((props, forwardedRef) => {
10411
- let { children, ...slotProps } = props;
10412
- if (isLazyComponent(children) && typeof use === "function") {
10413
- children = use(children._payload);
10414
- }
10415
- if (React$1.isValidElement(children)) {
10416
- const childrenRef = getElementRef(children);
10417
- const props2 = mergeProps(slotProps, children.props);
10418
- if (children.type !== React$1.Fragment) {
10419
- props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
10420
- }
10421
- return React$1.cloneElement(children, props2);
10422
- }
10423
- return React$1.Children.count(children) > 1 ? React$1.Children.only(null) : null;
10424
- });
10425
- SlotClone.displayName = `${ownerName}.SlotClone`;
10426
- return SlotClone;
10427
- }
10428
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
10429
- function isSlottable(child) {
10430
- return React$1.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
10431
- }
10432
- function mergeProps(slotProps, childProps) {
10433
- const overrideProps = { ...childProps };
10434
- for (const propName in childProps) {
10435
- const slotPropValue = slotProps[propName];
10436
- const childPropValue = childProps[propName];
10437
- const isHandler = /^on[A-Z]/.test(propName);
10438
- if (isHandler) {
10439
- if (slotPropValue && childPropValue) {
10440
- overrideProps[propName] = (...args) => {
10441
- const result = childPropValue(...args);
10442
- slotPropValue(...args);
10443
- return result;
10444
- };
10445
- } else if (slotPropValue) {
10446
- overrideProps[propName] = slotPropValue;
10447
- }
10448
- } else if (propName === "style") {
10449
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
10450
- } else if (propName === "className") {
10451
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
10452
- }
10453
- }
10454
- return { ...slotProps, ...overrideProps };
10455
- }
10456
- function getElementRef(element) {
10457
- var _a, _b;
10458
- let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
10459
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
10460
- if (mayWarn) {
10461
- return element.ref;
10462
- }
10463
- getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
10464
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
10465
- if (mayWarn) {
10466
- return element.props.ref;
10467
- }
10468
- return element.props.ref || element.ref;
10469
- }
10470
- var NODES = [
10471
- "a",
10472
- "button",
10473
- "div",
10474
- "form",
10475
- "h2",
10476
- "h3",
10477
- "img",
10478
- "input",
10479
- "label",
10480
- "li",
10481
- "nav",
10482
- "ol",
10483
- "p",
10484
- "select",
10485
- "span",
10486
- "svg",
10487
- "ul"
10488
- ];
10489
- var Primitive = NODES.reduce((primitive, node) => {
10490
- const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
10491
- const Node2 = React$1.forwardRef((props, forwardedRef) => {
10492
- const { asChild, ...primitiveProps } = props;
10493
- const Comp = asChild ? Slot2 : node;
10494
- if (typeof window !== "undefined") {
10495
- window[Symbol.for("radix-ui")] = true;
10496
- }
10497
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
10498
- });
10499
- Node2.displayName = `Primitive.${node}`;
10500
- return { ...primitive, [node]: Node2 };
10501
- }, {});
10502
10582
  var NAME$3 = "Separator";
10503
10583
  var DEFAULT_ORIENTATION = "horizontal";
10504
10584
  var ORIENTATIONS = ["horizontal", "vertical"];
@@ -10625,7 +10705,7 @@ const SheetDescription = React$1.forwardRef(({ className, ...props }, ref) => /*
10625
10705
  SheetDescription.displayName = Description.displayName;
10626
10706
  function createCollection(name) {
10627
10707
  const PROVIDER_NAME2 = name + "CollectionProvider";
10628
- const [createCollectionContext, createCollectionScope2] = createContextScope$1(PROVIDER_NAME2);
10708
+ const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME2);
10629
10709
  const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
10630
10710
  PROVIDER_NAME2,
10631
10711
  { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
@@ -10638,7 +10718,7 @@ function createCollection(name) {
10638
10718
  };
10639
10719
  CollectionProvider.displayName = PROVIDER_NAME2;
10640
10720
  const COLLECTION_SLOT_NAME = name + "CollectionSlot";
10641
- const CollectionSlotImpl = /* @__PURE__ */ createSlot$3(COLLECTION_SLOT_NAME);
10721
+ const CollectionSlotImpl = /* @__PURE__ */ createSlot(COLLECTION_SLOT_NAME);
10642
10722
  const CollectionSlot = React__default.forwardRef(
10643
10723
  (props, forwardedRef) => {
10644
10724
  const { scope, children } = props;
@@ -10650,7 +10730,7 @@ function createCollection(name) {
10650
10730
  CollectionSlot.displayName = COLLECTION_SLOT_NAME;
10651
10731
  const ITEM_SLOT_NAME = name + "CollectionItemSlot";
10652
10732
  const ITEM_DATA_ATTR = "data-radix-collection-item";
10653
- const CollectionItemSlotImpl = /* @__PURE__ */ createSlot$3(ITEM_SLOT_NAME);
10733
+ const CollectionItemSlotImpl = /* @__PURE__ */ createSlot(ITEM_SLOT_NAME);
10654
10734
  const CollectionItemSlot = React__default.forwardRef(
10655
10735
  (props, forwardedRef) => {
10656
10736
  const { scope, children, ...itemData } = props;
@@ -10695,7 +10775,7 @@ var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
10695
10775
  var EVENT_OPTIONS = { bubbles: false, cancelable: true };
10696
10776
  var GROUP_NAME$3 = "RovingFocusGroup";
10697
10777
  var [Collection$2, useCollection$2, createCollectionScope$2] = createCollection(GROUP_NAME$3);
10698
- var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope$1(
10778
+ var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
10699
10779
  GROUP_NAME$3,
10700
10780
  [createCollectionScope$2]
10701
10781
  );
@@ -10762,7 +10842,7 @@ var RovingFocusGroupImpl = React$1.forwardRef((props, forwardedRef) => {
10762
10842
  []
10763
10843
  ),
10764
10844
  children: /* @__PURE__ */ jsx(
10765
- Primitive$3.div,
10845
+ Primitive.div,
10766
10846
  {
10767
10847
  tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
10768
10848
  "data-orientation": orientation,
@@ -10827,7 +10907,7 @@ var RovingFocusGroupItem = React$1.forwardRef(
10827
10907
  focusable,
10828
10908
  active,
10829
10909
  children: /* @__PURE__ */ jsx(
10830
- Primitive$3.span,
10910
+ Primitive.span,
10831
10911
  {
10832
10912
  tabIndex: isCurrentTabStop ? 0 : -1,
10833
10913
  "data-orientation": context.orientation,
@@ -10912,7 +10992,7 @@ function wrapArray$2(array, startIndex) {
10912
10992
  var Root$2 = RovingFocusGroup;
10913
10993
  var Item$1 = RovingFocusGroupItem;
10914
10994
  var TABS_NAME = "Tabs";
10915
- var [createTabsContext, createTabsScope] = createContextScope$1(TABS_NAME, [
10995
+ var [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [
10916
10996
  createRovingFocusGroupScope
10917
10997
  ]);
10918
10998
  var useRovingFocusGroupScope$1 = createRovingFocusGroupScope();
@@ -10947,7 +11027,7 @@ var Tabs$1 = React$1.forwardRef(
10947
11027
  dir: direction,
10948
11028
  activationMode,
10949
11029
  children: /* @__PURE__ */ jsx(
10950
- Primitive$3.div,
11030
+ Primitive.div,
10951
11031
  {
10952
11032
  dir: direction,
10953
11033
  "data-orientation": orientation,
@@ -10975,7 +11055,7 @@ var TabsList$1 = React$1.forwardRef(
10975
11055
  dir: context.dir,
10976
11056
  loop,
10977
11057
  children: /* @__PURE__ */ jsx(
10978
- Primitive$3.div,
11058
+ Primitive.div,
10979
11059
  {
10980
11060
  role: "tablist",
10981
11061
  "aria-orientation": context.orientation,
@@ -11005,7 +11085,7 @@ var TabsTrigger$1 = React$1.forwardRef(
11005
11085
  focusable: !disabled,
11006
11086
  active: isSelected,
11007
11087
  children: /* @__PURE__ */ jsx(
11008
- Primitive$3.button,
11088
+ Primitive.button,
11009
11089
  {
11010
11090
  type: "button",
11011
11091
  role: "tab",
@@ -11055,7 +11135,7 @@ var TabsContent$1 = React$1.forwardRef(
11055
11135
  return () => cancelAnimationFrame(rAF);
11056
11136
  }, []);
11057
11137
  return /* @__PURE__ */ jsx(Presence, { present: forceMount || isSelected, children: ({ present }) => /* @__PURE__ */ jsx(
11058
- Primitive$3.div,
11138
+ Primitive.div,
11059
11139
  {
11060
11140
  "data-state": isSelected ? "active" : "inactive",
11061
11141
  "data-orientation": context.orientation,
@@ -13194,7 +13274,7 @@ const computePosition = (reference, floating, options) => {
13194
13274
  var isClient = typeof document !== "undefined";
13195
13275
  var noop = function noop2() {
13196
13276
  };
13197
- var index$6 = isClient ? useLayoutEffect$1 : noop;
13277
+ var index$5 = isClient ? useLayoutEffect$1 : noop;
13198
13278
  function deepEqual(a, b2) {
13199
13279
  if (a === b2) {
13200
13280
  return true;
@@ -13256,7 +13336,7 @@ function roundByDPR(element, value) {
13256
13336
  }
13257
13337
  function useLatestRef(value) {
13258
13338
  const ref = React$1.useRef(value);
13259
- index$6(() => {
13339
+ index$5(() => {
13260
13340
  ref.current = value;
13261
13341
  });
13262
13342
  return ref;
@@ -13342,7 +13422,7 @@ function useFloating(options) {
13342
13422
  }
13343
13423
  });
13344
13424
  }, [latestMiddleware, placement, strategy, platformRef, openRef]);
13345
- index$6(() => {
13425
+ index$5(() => {
13346
13426
  if (open === false && dataRef.current.isPositioned) {
13347
13427
  dataRef.current.isPositioned = false;
13348
13428
  setData((data2) => ({
@@ -13352,13 +13432,13 @@ function useFloating(options) {
13352
13432
  }
13353
13433
  }, [open]);
13354
13434
  const isMountedRef = React$1.useRef(false);
13355
- index$6(() => {
13435
+ index$5(() => {
13356
13436
  isMountedRef.current = true;
13357
13437
  return () => {
13358
13438
  isMountedRef.current = false;
13359
13439
  };
13360
13440
  }, []);
13361
- index$6(() => {
13441
+ index$5(() => {
13362
13442
  if (referenceEl)
13363
13443
  referenceRef.current = referenceEl;
13364
13444
  if (floatingEl)
@@ -13477,7 +13557,7 @@ var NAME$2 = "Arrow";
13477
13557
  var Arrow$1 = React$1.forwardRef((props, forwardedRef) => {
13478
13558
  const { children, width = 10, height = 5, ...arrowProps } = props;
13479
13559
  return /* @__PURE__ */ jsx(
13480
- Primitive$3.svg,
13560
+ Primitive.svg,
13481
13561
  {
13482
13562
  ...arrowProps,
13483
13563
  ref: forwardedRef,
@@ -13526,7 +13606,7 @@ function useSize(element) {
13526
13606
  return size2;
13527
13607
  }
13528
13608
  var POPPER_NAME = "Popper";
13529
- var [createPopperContext, createPopperScope] = createContextScope$1(POPPER_NAME);
13609
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
13530
13610
  var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
13531
13611
  var Popper = (props) => {
13532
13612
  const { __scopePopper, children } = props;
@@ -13549,7 +13629,7 @@ var PopperAnchor = React$1.forwardRef(
13549
13629
  context.onAnchorChange(anchorRef.current);
13550
13630
  }
13551
13631
  });
13552
- return virtualRef ? null : /* @__PURE__ */ jsx(Primitive$3.div, { ...anchorProps, ref: composedRefs });
13632
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
13553
13633
  }
13554
13634
  );
13555
13635
  PopperAnchor.displayName = ANCHOR_NAME$2;
@@ -13678,7 +13758,7 @@ var PopperContent = React$1.forwardRef(
13678
13758
  arrowY,
13679
13759
  shouldHideArrow: cannotCenterArrow,
13680
13760
  children: /* @__PURE__ */ jsx(
13681
- Primitive$3.div,
13761
+ Primitive.div,
13682
13762
  {
13683
13763
  "data-side": placedSide,
13684
13764
  "data-align": placedAlign,
@@ -13814,7 +13894,7 @@ var NAME$1 = "VisuallyHidden";
13814
13894
  var VisuallyHidden = React$1.forwardRef(
13815
13895
  (props, forwardedRef) => {
13816
13896
  return /* @__PURE__ */ jsx(
13817
- Primitive$3.span,
13897
+ Primitive.span,
13818
13898
  {
13819
13899
  ...props,
13820
13900
  ref: forwardedRef,
@@ -13825,7 +13905,7 @@ var VisuallyHidden = React$1.forwardRef(
13825
13905
  );
13826
13906
  VisuallyHidden.displayName = NAME$1;
13827
13907
  var Root = VisuallyHidden;
13828
- var [createTooltipContext, createTooltipScope] = createContextScope$1("Tooltip", [
13908
+ var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
13829
13909
  createPopperScope
13830
13910
  ]);
13831
13911
  var usePopperScope$3 = createPopperScope();
@@ -13986,7 +14066,7 @@ var TooltipTrigger$1 = React$1.forwardRef(
13986
14066
  return () => document.removeEventListener("pointerup", handlePointerUp);
13987
14067
  }, [handlePointerUp]);
13988
14068
  return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
13989
- Primitive$3.button,
14069
+ Primitive.button,
13990
14070
  {
13991
14071
  "aria-describedby": context.open ? context.contentId : void 0,
13992
14072
  "data-state": context.stateAttribute,
@@ -14609,7 +14689,7 @@ const HtmlViewDisplay = () => {
14609
14689
  onBlur: handleTextareaBlur,
14610
14690
  onClick: handleTextareaClick,
14611
14691
  onKeyDown: handleTextareaKeyDown,
14612
- className: " cteditor-w-full cteditor-flex-1\n cteditor-font-mono cteditor-text-[13px] \n cteditor-p-3 \n cteditor-border cteditor-rounded-lg \n cteditor-resize-y cteditor-leading-[1.4] \n cteditor-outline-none cteditor-transition-colors cteditor-duration-200 \n cteditor-whitespace-pre-wrap cteditor-break-words\n dark:cteditor-text-background\n cteditor-text-foreground\n cteditor-bg-foreground/5\n",
14692
+ className: " cteditor-w-full cteditor-flex-1\r\n cteditor-font-mono cteditor-text-[13px] \r\n cteditor-p-3 \r\n cteditor-border cteditor-rounded-lg \r\n cteditor-resize-y cteditor-leading-[1.4] \r\n cteditor-outline-none cteditor-transition-colors cteditor-duration-200 \r\n cteditor-whitespace-pre-wrap cteditor-break-words\r\n dark:cteditor-text-background\r\n cteditor-text-foreground\r\n cteditor-bg-foreground/5\r\n",
14613
14693
  placeholder: "HTML content will appear here... Edit and click 'Sync to Editor' to apply changes."
14614
14694
  }
14615
14695
  )
@@ -15815,7 +15895,7 @@ const EmbedComponent = ({ url, displayType, alignment, width: initialWidth, heig
15815
15895
  }
15816
15896
  );
15817
15897
  };
15818
- const FileComponent = React$1.lazy(() => import("./index-35336e5d.js"));
15898
+ const FileComponent = React$1.lazy(() => import("./index-39c10e00.js"));
15819
15899
  function convertFileElement(domNode) {
15820
15900
  if (domNode instanceof HTMLDivElement) {
15821
15901
  const dataUrl = domNode.getAttribute("data-lexical-file-src");
@@ -16298,7 +16378,7 @@ var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
16298
16378
  var SELECTION_KEYS$1 = [" ", "Enter"];
16299
16379
  var SELECT_NAME = "Select";
16300
16380
  var [Collection$1, useCollection$1, createCollectionScope$1] = createCollection(SELECT_NAME);
16301
- var [createSelectContext, createSelectScope] = createContextScope$1(SELECT_NAME, [
16381
+ var [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
16302
16382
  createCollectionScope$1,
16303
16383
  createPopperScope
16304
16384
  ]);
@@ -16435,7 +16515,7 @@ var SelectTrigger$1 = React$1.forwardRef(
16435
16515
  }
16436
16516
  };
16437
16517
  return /* @__PURE__ */ jsx(Anchor, { asChild: true, ...popperScope, children: /* @__PURE__ */ jsx(
16438
- Primitive$3.button,
16518
+ Primitive.button,
16439
16519
  {
16440
16520
  type: "button",
16441
16521
  role: "combobox",
@@ -16496,7 +16576,7 @@ var SelectValue$1 = React$1.forwardRef(
16496
16576
  onValueNodeHasChildrenChange(hasChildren);
16497
16577
  }, [onValueNodeHasChildrenChange, hasChildren]);
16498
16578
  return /* @__PURE__ */ jsx(
16499
- Primitive$3.span,
16579
+ Primitive.span,
16500
16580
  {
16501
16581
  ...valueProps,
16502
16582
  ref: composedRefs,
@@ -16511,7 +16591,7 @@ var ICON_NAME = "SelectIcon";
16511
16591
  var SelectIcon = React$1.forwardRef(
16512
16592
  (props, forwardedRef) => {
16513
16593
  const { __scopeSelect, children, ...iconProps } = props;
16514
- return /* @__PURE__ */ jsx(Primitive$3.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "▼" });
16594
+ return /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...iconProps, ref: forwardedRef, children: children || "▼" });
16515
16595
  }
16516
16596
  );
16517
16597
  SelectIcon.displayName = ICON_NAME;
@@ -16542,7 +16622,7 @@ SelectContent$1.displayName = CONTENT_NAME$3;
16542
16622
  var CONTENT_MARGIN = 10;
16543
16623
  var [SelectContentProvider, useSelectContentContext] = createSelectContext(CONTENT_NAME$3);
16544
16624
  var CONTENT_IMPL_NAME = "SelectContentImpl";
16545
- var Slot$2 = /* @__PURE__ */ createSlot$3("SelectContent.RemoveScroll");
16625
+ var Slot$2 = /* @__PURE__ */ createSlot("SelectContent.RemoveScroll");
16546
16626
  var SelectContentImpl = React$1.forwardRef(
16547
16627
  (props, forwardedRef) => {
16548
16628
  const {
@@ -16931,7 +17011,7 @@ var SelectItemAlignedPosition = React$1.forwardRef((props, forwardedRef) => {
16931
17011
  zIndex: contentZIndex
16932
17012
  },
16933
17013
  children: /* @__PURE__ */ jsx(
16934
- Primitive$3.div,
17014
+ Primitive.div,
16935
17015
  {
16936
17016
  ...popperProps,
16937
17017
  ref: composedRefs,
@@ -17005,7 +17085,7 @@ var SelectViewport = React$1.forwardRef(
17005
17085
  }
17006
17086
  ),
17007
17087
  /* @__PURE__ */ jsx(Collection$1.Slot, { scope: __scopeSelect, children: /* @__PURE__ */ jsx(
17008
- Primitive$3.div,
17088
+ Primitive.div,
17009
17089
  {
17010
17090
  "data-radix-select-viewport": "",
17011
17091
  role: "presentation",
@@ -17060,7 +17140,7 @@ var SelectGroup = React$1.forwardRef(
17060
17140
  (props, forwardedRef) => {
17061
17141
  const { __scopeSelect, ...groupProps } = props;
17062
17142
  const groupId = useId();
17063
- return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive$3.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
17143
+ return /* @__PURE__ */ jsx(SelectGroupContextProvider, { scope: __scopeSelect, id: groupId, children: /* @__PURE__ */ jsx(Primitive.div, { role: "group", "aria-labelledby": groupId, ...groupProps, ref: forwardedRef }) });
17064
17144
  }
17065
17145
  );
17066
17146
  SelectGroup.displayName = GROUP_NAME$2;
@@ -17069,7 +17149,7 @@ var SelectLabel$1 = React$1.forwardRef(
17069
17149
  (props, forwardedRef) => {
17070
17150
  const { __scopeSelect, ...labelProps } = props;
17071
17151
  const groupContext = useSelectGroupContext(LABEL_NAME$2, __scopeSelect);
17072
- return /* @__PURE__ */ jsx(Primitive$3.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
17152
+ return /* @__PURE__ */ jsx(Primitive.div, { id: groupContext.id, ...labelProps, ref: forwardedRef });
17073
17153
  }
17074
17154
  );
17075
17155
  SelectLabel$1.displayName = LABEL_NAME$2;
@@ -17128,7 +17208,7 @@ var SelectItem$1 = React$1.forwardRef(
17128
17208
  disabled,
17129
17209
  textValue,
17130
17210
  children: /* @__PURE__ */ jsx(
17131
- Primitive$3.div,
17211
+ Primitive.div,
17132
17212
  {
17133
17213
  role: "option",
17134
17214
  "aria-labelledby": textId,
@@ -17216,7 +17296,7 @@ var SelectItemText = React$1.forwardRef(
17216
17296
  return () => onNativeOptionRemove(nativeOption);
17217
17297
  }, [onNativeOptionAdd, onNativeOptionRemove, nativeOption]);
17218
17298
  return /* @__PURE__ */ jsxs(Fragment, { children: [
17219
- /* @__PURE__ */ jsx(Primitive$3.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
17299
+ /* @__PURE__ */ jsx(Primitive.span, { id: itemContext.textId, ...itemTextProps, ref: composedRefs }),
17220
17300
  itemContext.isSelected && context.valueNode && !context.valueNodeHasChildren ? ReactDOM.createPortal(itemTextProps.children, context.valueNode) : null
17221
17301
  ] });
17222
17302
  }
@@ -17227,7 +17307,7 @@ var SelectItemIndicator = React$1.forwardRef(
17227
17307
  (props, forwardedRef) => {
17228
17308
  const { __scopeSelect, ...itemIndicatorProps } = props;
17229
17309
  const itemContext = useSelectItemContext(ITEM_INDICATOR_NAME$1, __scopeSelect);
17230
- return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive$3.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
17310
+ return itemContext.isSelected ? /* @__PURE__ */ jsx(Primitive.span, { "aria-hidden": true, ...itemIndicatorProps, ref: forwardedRef }) : null;
17231
17311
  }
17232
17312
  );
17233
17313
  SelectItemIndicator.displayName = ITEM_INDICATOR_NAME$1;
@@ -17318,7 +17398,7 @@ var SelectScrollButtonImpl = React$1.forwardRef((props, forwardedRef) => {
17318
17398
  (_a = activeItem == null ? void 0 : activeItem.ref.current) == null ? void 0 : _a.scrollIntoView({ block: "nearest" });
17319
17399
  }, [getItems]);
17320
17400
  return /* @__PURE__ */ jsx(
17321
- Primitive$3.div,
17401
+ Primitive.div,
17322
17402
  {
17323
17403
  "aria-hidden": true,
17324
17404
  ...scrollIndicatorProps,
@@ -17346,7 +17426,7 @@ var SEPARATOR_NAME$2 = "SelectSeparator";
17346
17426
  var SelectSeparator$1 = React$1.forwardRef(
17347
17427
  (props, forwardedRef) => {
17348
17428
  const { __scopeSelect, ...separatorProps } = props;
17349
- return /* @__PURE__ */ jsx(Primitive$3.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
17429
+ return /* @__PURE__ */ jsx(Primitive.div, { "aria-hidden": true, ...separatorProps, ref: forwardedRef });
17350
17430
  }
17351
17431
  );
17352
17432
  SelectSeparator$1.displayName = SEPARATOR_NAME$2;
@@ -17384,7 +17464,7 @@ var SelectBubbleInput = React$1.forwardRef(
17384
17464
  }
17385
17465
  }, [prevValue, value]);
17386
17466
  return /* @__PURE__ */ jsx(
17387
- Primitive$3.select,
17467
+ Primitive.select,
17388
17468
  {
17389
17469
  ...props,
17390
17470
  style: { ...VISUALLY_HIDDEN_STYLES, ...props.style },
@@ -20011,7 +20091,7 @@ function AIChatDialog({
20011
20091
  return imageKeywords.some((keyword) => lowerPrompt.includes(keyword));
20012
20092
  };
20013
20093
  const handleSubmit = async () => {
20014
- var _a, _b;
20094
+ var _a, _b, _c, _d;
20015
20095
  if (!inputValue.trim() || isLoading)
20016
20096
  return;
20017
20097
  setIsLoading(true);
@@ -20061,7 +20141,11 @@ Text to transform:
20061
20141
  setIsLoading(false);
20062
20142
  } catch (error) {
20063
20143
  console.error("Error processing AI action:", error);
20064
- const apiMessage = ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) ?? (error instanceof Error ? error.message : null);
20144
+ const errorCode = (_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.code;
20145
+ const errorCodeMessages = {
20146
+ "INSUFFICIENT_CREDITS": "You have insufficient credits. Please purchase more credits to continue using AI features."
20147
+ };
20148
+ const apiMessage = errorCodeMessages[errorCode] ?? ((_d = (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.message) ?? (error instanceof Error ? error.message : null);
20065
20149
  const safeMessage = apiMessage && !/^Request failed with status code \d+/.test(apiMessage) ? apiMessage : "Error processing your request. Please try again.";
20066
20150
  setErrorMessage(safeMessage);
20067
20151
  toast.error(safeMessage);
@@ -20373,29 +20457,28 @@ function InlineAIPrompt({
20373
20457
  return imageKeywords.some((keyword) => lowerPrompt.includes(keyword));
20374
20458
  };
20375
20459
  const handleSubmit = async () => {
20376
- var _a, _b;
20460
+ var _a, _b, _c, _d;
20377
20461
  if (!inputValue.trim() || isLoading)
20378
20462
  return;
20379
- const isImageRequest = isImageGenerationRequest(inputValue) || selectedText && isImageGenerationRequest(selectedText);
20380
- if (!isImageRequest && (!selectedText || selectedText.trim() === "")) {
20381
- toast.error("Please select some text first");
20382
- return;
20383
- }
20384
20463
  setIsLoading(true);
20464
+ const isImageRequest = isImageGenerationRequest(inputValue) || selectedText && isImageGenerationRequest(selectedText);
20465
+ const hasSelectedText2 = selectedText && selectedText.trim() !== "";
20385
20466
  let finalPrompt;
20386
20467
  if (isImageRequest) {
20387
- if (selectedText && selectedText.trim()) {
20468
+ if (hasSelectedText2) {
20388
20469
  finalPrompt = `${inputValue}: ${selectedText}`;
20389
20470
  } else {
20390
20471
  finalPrompt = inputValue;
20391
20472
  }
20392
- } else {
20473
+ } else if (hasSelectedText2) {
20393
20474
  finalPrompt = `${inputValue}
20394
20475
 
20395
20476
  IMPORTANT: Return ONLY the modified/transformed text. Do NOT include any labels, prefixes, explanations, or formatting like "Simplified:", "Result:", "Here is", etc. Just return the pure result text.
20396
20477
 
20397
20478
  Text to transform:
20398
20479
  "${selectedText}"`;
20480
+ } else {
20481
+ finalPrompt = inputValue;
20399
20482
  }
20400
20483
  try {
20401
20484
  const response = await AiEditorAction({ content: finalPrompt, provider, apiKey });
@@ -20431,7 +20514,11 @@ Text to transform:
20431
20514
  setShowMessage(true);
20432
20515
  } catch (error) {
20433
20516
  console.error("Error processing AI action:", error);
20434
- const apiMessage = ((_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) ?? (error instanceof Error ? error.message : null);
20517
+ const errorCode = (_b = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.data) == null ? void 0 : _b.code;
20518
+ const errorCodeMessages = {
20519
+ "INSUFFICIENT_CREDITS": "You have insufficient credits. Please purchase more credits to continue using AI features."
20520
+ };
20521
+ const apiMessage = errorCodeMessages[errorCode] ?? ((_d = (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.message) ?? (error instanceof Error ? error.message : null);
20435
20522
  const safeMessage = apiMessage && !/^Request failed with status code \d+/.test(apiMessage) ? apiMessage : "Error processing your request. Please try again.";
20436
20523
  toast.error(safeMessage);
20437
20524
  setStatus("error");
@@ -20450,10 +20537,9 @@ Text to transform:
20450
20537
  }
20451
20538
  };
20452
20539
  const hasSelectedText = selectedText && selectedText.trim() !== "";
20453
- const isCurrentInputImageRequest = isImageGenerationRequest(inputValue);
20454
20540
  const displayText = hasSelectedText ? selectedText.length > 50 ? selectedText.substring(0, 50) + "..." : selectedText : "";
20455
20541
  return /* @__PURE__ */ jsxs("div", { className: "cteditor-absolute cteditor-bottom-1 cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-flex cteditor-flex-col cteditor-gap-2 cteditor-bg-[#1a1a1a] cteditor-px-2 cteditor-py-2 cteditor-rounded-md cteditor-border cteditor-border-[#333] cteditor-shadow-[0_8px_24px_rgba(0,0,0,0.4)] cteditor-z-10 cteditor-max-w-[435px] cteditor-w-full", children: [
20456
- showMessage && /* @__PURE__ */ jsxs("div", { className: `cteditor-relative cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-pl-2.5 cteditor-pr-6 cteditor-py-1.5 cteditor-rounded-md cteditor-text-xs cteditor-text-[#999] ${status === "success" ? "cteditor-bg-[#1a2e1a] cteditor-border cteditor-border-[#3a5a3a]" : status === "error" ? "cteditor-bg-[#2e1a1a] cteditor-border cteditor-border-[#5a3a3a]" : hasSelectedText ? "cteditor-bg-[#2a2a2a]" : isCurrentInputImageRequest ? "cteditor-bg-[#2a3a2a] cteditor-border cteditor-border-[#3a5a3a]" : "cteditor-bg-[#3a2a2a] cteditor-border cteditor-border-[#5a3a3a]"}`, children: [
20542
+ showMessage && /* @__PURE__ */ jsxs("div", { className: `cteditor-relative cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-pl-2.5 cteditor-pr-6 cteditor-py-1.5 cteditor-rounded-md cteditor-text-xs cteditor-text-[#999] ${status === "success" ? "cteditor-bg-[#1a2e1a] cteditor-border cteditor-border-[#3a5a3a]" : status === "error" ? "cteditor-bg-[#2e1a1a] cteditor-border cteditor-border-[#5a3a3a]" : "cteditor-bg-[#2a2a2a]"}`, children: [
20457
20543
  status === "success" ? /* @__PURE__ */ jsx("span", { className: "cteditor-text-[#4ade80]", children: "✓ Content inserted! Select new text or enter another prompt" }) : status === "error" ? /* @__PURE__ */ jsx("span", { className: "cteditor-text-[#f87171]", children: "✗ Request failed. Try again or select different text" }) : hasSelectedText ? /* @__PURE__ */ jsxs(Fragment, { children: [
20458
20544
  /* @__PURE__ */ jsx("span", { className: "cteditor-text-[#666]", children: "Selected:" }),
20459
20545
  /* @__PURE__ */ jsxs("span", { className: "cteditor-text-[#ccc] cteditor-italic", children: [
@@ -20461,7 +20547,7 @@ Text to transform:
20461
20547
  displayText,
20462
20548
  '"'
20463
20549
  ] })
20464
- ] }) : isCurrentInputImageRequest ? /* @__PURE__ */ jsx("span", { className: "cteditor-text-[#4ade80]", children: "🖼️ Image generation mode - no text selection required" }) : /* @__PURE__ */ jsx("span", { className: "cteditor-text-[#f87171]", children: "⚠ Please select some text or enter an image generation prompt" }),
20550
+ ] }) : /* @__PURE__ */ jsx("span", { className: "cteditor-text-[#ccc]", children: "Ask AI anything or select text to transform" }),
20465
20551
  /* @__PURE__ */ jsx(
20466
20552
  "button",
20467
20553
  {
@@ -20495,7 +20581,7 @@ Text to transform:
20495
20581
  setShowMessage(true);
20496
20582
  },
20497
20583
  onKeyDown: handleKeyDown,
20498
- placeholder: hasSelectedText ? "What do you want to do with this text?" : "Generate image of... or select text",
20584
+ placeholder: hasSelectedText ? "What do you want to do with this text?" : "Ask AI anything...",
20499
20585
  disabled: isLoading,
20500
20586
  className: " cteditor-h-8 cteditor-px-2 cteditor-text-xs cteditor-w-full cteditor-border cteditor-border-[#444] cteditor-rounded-md cteditor-outline-none cteditor-bg-[#2a2a2a] cteditor-text-white md:cteditor-w-60"
20501
20587
  }
@@ -20614,6 +20700,47 @@ function AIChatPlugin({
20614
20700
  const [editor] = useLexicalComposerContext();
20615
20701
  return useAIChatToolbar(editor, apiKey);
20616
20702
  }
20703
+ const BACKEND_URL = "https://api.cteditor.com/";
20704
+ async function generateChart(metadata, apiKey) {
20705
+ try {
20706
+ const response = await fetch(`${BACKEND_URL}api/chat/regenerate`, {
20707
+ method: "POST",
20708
+ headers: {
20709
+ "Content-Type": "application/json",
20710
+ "x-api-key": apiKey || ""
20711
+ },
20712
+ body: JSON.stringify(metadata)
20713
+ });
20714
+ if (!response.ok) {
20715
+ const errorData = await response.json().catch(() => ({}));
20716
+ throw new Error(errorData.message || `Server error: ${response.status}`);
20717
+ }
20718
+ const data = await response.json();
20719
+ if (!data.success || !data.html) {
20720
+ throw new Error(data.message || "Failed to generate chart");
20721
+ }
20722
+ return {
20723
+ success: true,
20724
+ html: data.html
20725
+ };
20726
+ } catch (error) {
20727
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
20728
+ return {
20729
+ success: false,
20730
+ error: errorMessage
20731
+ };
20732
+ }
20733
+ }
20734
+ async function generateChartWithToast(metadata, apiKey) {
20735
+ const toastId = toast.loading("Generating chart...");
20736
+ const result = await generateChart(metadata, apiKey);
20737
+ if (result.success) {
20738
+ toast.success("Chart inserted successfully!", { id: toastId });
20739
+ } else {
20740
+ toast.error(`Failed to insert chart: ${result.error}`, { id: toastId });
20741
+ }
20742
+ return result;
20743
+ }
20617
20744
  const CREATE_TABLE_COMMAND = createCommand();
20618
20745
  function TableOptionPlugin({ isActive }) {
20619
20746
  const [editor] = useLexicalComposerContext();
@@ -20653,6 +20780,8 @@ function TableOptionPlugin({ isActive }) {
20653
20780
  if ($isTableCellNode(cellNode)) {
20654
20781
  cellNode.setHeaderStyles(TableCellHeaderStates.COLUMN);
20655
20782
  cellNode.setBackgroundColor(headerColor);
20783
+ const textNode = $createTextNode("​");
20784
+ cellNode.append(textNode);
20656
20785
  }
20657
20786
  }
20658
20787
  }
@@ -21346,10 +21475,10 @@ const PDF_CONFIG = {
21346
21475
  };
21347
21476
  const loadHtml2Pdf = async () => {
21348
21477
  try {
21349
- const mod = await import("./html2pdf.bundle.min-4f1c3930.js").then((n) => n.h);
21478
+ const mod = await import("./html2pdf.bundle.min-d6fba18e.js").then((n) => n.h);
21350
21479
  return (mod == null ? void 0 : mod.default) || mod;
21351
21480
  } catch {
21352
- const mod2 = await import("./html2pdf.bundle-d4225b87.js").then((n) => n.h);
21481
+ const mod2 = await import("./html2pdf.bundle-d21122e4.js").then((n) => n.h);
21353
21482
  return (mod2 == null ? void 0 : mod2.default) || mod2;
21354
21483
  }
21355
21484
  };
@@ -22101,7 +22230,7 @@ var SUB_CLOSE_KEYS = {
22101
22230
  };
22102
22231
  var MENU_NAME = "Menu";
22103
22232
  var [Collection, useCollection, createCollectionScope] = createCollection(MENU_NAME);
22104
- var [createMenuContext, createMenuScope] = createContextScope$1(MENU_NAME, [
22233
+ var [createMenuContext, createMenuScope] = createContextScope(MENU_NAME, [
22105
22234
  createCollectionScope,
22106
22235
  createPopperScope,
22107
22236
  createRovingFocusGroupScope
@@ -22226,7 +22355,7 @@ var MenuRootContentNonModal = React$1.forwardRef((props, forwardedRef) => {
22226
22355
  }
22227
22356
  );
22228
22357
  });
22229
- var Slot$1 = /* @__PURE__ */ createSlot$3("MenuContent.ScrollLock");
22358
+ var Slot$1 = /* @__PURE__ */ createSlot("MenuContent.ScrollLock");
22230
22359
  var MenuContentImpl = React$1.forwardRef(
22231
22360
  (props, forwardedRef) => {
22232
22361
  const {
@@ -22428,7 +22557,7 @@ var GROUP_NAME$1 = "MenuGroup";
22428
22557
  var MenuGroup = React$1.forwardRef(
22429
22558
  (props, forwardedRef) => {
22430
22559
  const { __scopeMenu, ...groupProps } = props;
22431
- return /* @__PURE__ */ jsx(Primitive$3.div, { role: "group", ...groupProps, ref: forwardedRef });
22560
+ return /* @__PURE__ */ jsx(Primitive.div, { role: "group", ...groupProps, ref: forwardedRef });
22432
22561
  }
22433
22562
  );
22434
22563
  MenuGroup.displayName = GROUP_NAME$1;
@@ -22436,7 +22565,7 @@ var LABEL_NAME$1 = "MenuLabel";
22436
22565
  var MenuLabel = React$1.forwardRef(
22437
22566
  (props, forwardedRef) => {
22438
22567
  const { __scopeMenu, ...labelProps } = props;
22439
- return /* @__PURE__ */ jsx(Primitive$3.div, { ...labelProps, ref: forwardedRef });
22568
+ return /* @__PURE__ */ jsx(Primitive.div, { ...labelProps, ref: forwardedRef });
22440
22569
  }
22441
22570
  );
22442
22571
  MenuLabel.displayName = LABEL_NAME$1;
@@ -22516,7 +22645,7 @@ var MenuItemImpl = React$1.forwardRef(
22516
22645
  disabled,
22517
22646
  textValue: textValue ?? textContent,
22518
22647
  children: /* @__PURE__ */ jsx(Item$1, { asChild: true, ...rovingFocusGroupScope, focusable: !disabled, children: /* @__PURE__ */ jsx(
22519
- Primitive$3.div,
22648
+ Primitive.div,
22520
22649
  {
22521
22650
  role: "menuitem",
22522
22651
  "data-highlighted": isFocused ? "" : void 0,
@@ -22627,7 +22756,7 @@ var MenuItemIndicator = React$1.forwardRef(
22627
22756
  {
22628
22757
  present: forceMount || isIndeterminate(indicatorContext.checked) || indicatorContext.checked === true,
22629
22758
  children: /* @__PURE__ */ jsx(
22630
- Primitive$3.span,
22759
+ Primitive.span,
22631
22760
  {
22632
22761
  ...itemIndicatorProps,
22633
22762
  ref: forwardedRef,
@@ -22644,7 +22773,7 @@ var MenuSeparator = React$1.forwardRef(
22644
22773
  (props, forwardedRef) => {
22645
22774
  const { __scopeMenu, ...separatorProps } = props;
22646
22775
  return /* @__PURE__ */ jsx(
22647
- Primitive$3.div,
22776
+ Primitive.div,
22648
22777
  {
22649
22778
  role: "separator",
22650
22779
  "aria-orientation": "horizontal",
@@ -22904,7 +23033,7 @@ var Arrow2 = MenuArrow;
22904
23033
  var SubTrigger = MenuSubTrigger;
22905
23034
  var SubContent = MenuSubContent;
22906
23035
  var DROPDOWN_MENU_NAME = "DropdownMenu";
22907
- var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope$1(
23036
+ var [createDropdownMenuContext, createDropdownMenuScope] = createContextScope(
22908
23037
  DROPDOWN_MENU_NAME,
22909
23038
  [createMenuScope]
22910
23039
  );
@@ -22951,7 +23080,7 @@ var DropdownMenuTrigger$1 = React$1.forwardRef(
22951
23080
  const context = useDropdownMenuContext(TRIGGER_NAME$1, __scopeDropdownMenu);
22952
23081
  const menuScope = useMenuScope(__scopeDropdownMenu);
22953
23082
  return /* @__PURE__ */ jsx(Anchor2, { asChild: true, ...menuScope, children: /* @__PURE__ */ jsx(
22954
- Primitive$3.button,
23083
+ Primitive.button,
22955
23084
  {
22956
23085
  type: "button",
22957
23086
  id: context.triggerId,
@@ -23290,13 +23419,13 @@ const AlignMenu = () => {
23290
23419
  {
23291
23420
  variant: "ghost",
23292
23421
  size: "sm",
23293
- className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-h-7 cteditor-rounded-sm cteditor-px-2\n",
23422
+ className: "cteditor-flex cteditor-items-center cteditor-gap-2 cteditor-h-7 cteditor-rounded-sm cteditor-px-2\r\n",
23294
23423
  children: [
23295
23424
  /* @__PURE__ */ jsx(AlignLeft, { className: "!cteditor-size-4" }),
23296
23425
  /* @__PURE__ */ jsx(
23297
23426
  ChevronDown,
23298
23427
  {
23299
- className: "!cteditor-size-4 cteditor-opacity-50\n"
23428
+ className: "!cteditor-size-4 cteditor-opacity-50\r\n"
23300
23429
  }
23301
23430
  )
23302
23431
  ]
@@ -23799,7 +23928,7 @@ var V = "undefined" != typeof window ? useLayoutEffect$1 : useEffect$1, $ = func
23799
23928
  return React__default.createElement(U, u({}, r2, { colorModel: W }));
23800
23929
  };
23801
23930
  var POPOVER_NAME = "Popover";
23802
- var [createPopoverContext, createPopoverScope] = createContextScope$1(POPOVER_NAME, [
23931
+ var [createPopoverContext, createPopoverScope] = createContextScope(POPOVER_NAME, [
23803
23932
  createPopperScope
23804
23933
  ]);
23805
23934
  var usePopperScope = createPopperScope();
@@ -23863,7 +23992,7 @@ var PopoverTrigger$1 = React$1.forwardRef(
23863
23992
  const popperScope = usePopperScope(__scopePopover);
23864
23993
  const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
23865
23994
  const trigger = /* @__PURE__ */ jsx(
23866
- Primitive$3.button,
23995
+ Primitive.button,
23867
23996
  {
23868
23997
  type: "button",
23869
23998
  "aria-haspopup": "dialog",
@@ -23899,7 +24028,7 @@ var PopoverContent$1 = React$1.forwardRef(
23899
24028
  }
23900
24029
  );
23901
24030
  PopoverContent$1.displayName = CONTENT_NAME;
23902
- var Slot = /* @__PURE__ */ createSlot$3("PopoverContent.RemoveScroll");
24031
+ var Slot = /* @__PURE__ */ createSlot("PopoverContent.RemoveScroll");
23903
24032
  var PopoverContentModal = React$1.forwardRef(
23904
24033
  (props, forwardedRef) => {
23905
24034
  const context = usePopoverContext(CONTENT_NAME, props.__scopePopover);
@@ -24056,7 +24185,7 @@ var PopoverClose = React$1.forwardRef(
24056
24185
  const { __scopePopover, ...closeProps } = props;
24057
24186
  const context = usePopoverContext(CLOSE_NAME, __scopePopover);
24058
24187
  return /* @__PURE__ */ jsx(
24059
- Primitive$3.button,
24188
+ Primitive.button,
24060
24189
  {
24061
24190
  type: "button",
24062
24191
  ...closeProps,
@@ -24271,7 +24400,7 @@ const ColorPicker$2 = ({
24271
24400
  {
24272
24401
  onMouseDown: (e) => e.preventDefault(),
24273
24402
  onClick: () => setShowAdvanced(!showAdvanced),
24274
- className: "cteditor-text-xs cteditor-text-primary/90 hover:cteditor-text-primary cteditor-transition-colors cteditor-flex cteditor-items-center cteditor-gap-2\n",
24403
+ className: "cteditor-text-xs cteditor-text-primary/90 hover:cteditor-text-primary cteditor-transition-colors cteditor-flex cteditor-items-center cteditor-gap-2\r\n",
24275
24404
  children: [
24276
24405
  /* @__PURE__ */ jsx("span", { className: "cteditor-text-xs", children: showAdvanced ? "▼" : "▶" }),
24277
24406
  showAdvanced ? "Hide Advanced" : "Show Advanced"
@@ -27354,29 +27483,10 @@ const Toolbar = ({
27354
27483
  }, []);
27355
27484
  const handleChartInsert = useCallback(
27356
27485
  async (metadata) => {
27357
- const toastId = toast.loading("Generating chart...");
27358
- try {
27359
- const backendUrl = "https://api.cteditor.com/".replace(/\/$/, "");
27360
- const response = await fetch(`${backendUrl}/api/chat/regenerate`, {
27361
- method: "POST",
27362
- headers: {
27363
- "Content-Type": "application/json",
27364
- "x-api-key": apiKey || ""
27365
- },
27366
- body: JSON.stringify(metadata)
27367
- });
27368
- if (!response.ok) {
27369
- const errorData = await response.json().catch(() => ({}));
27370
- throw new Error(
27371
- errorData.message || `Server error: ${response.status}`
27372
- );
27373
- }
27374
- const data = await response.json();
27375
- if (!data.success || !data.html) {
27376
- throw new Error(data.message || "Failed to generate chart");
27377
- }
27486
+ const result = await generateChartWithToast(metadata, apiKey);
27487
+ if (result.success) {
27378
27488
  editor.update(() => {
27379
- const chartNode = $createChartNode(data.html, metadata);
27489
+ const chartNode = $createChartNode(result.html, metadata);
27380
27490
  const selection = $getSelection();
27381
27491
  if (!selection) {
27382
27492
  const root2 = $getRoot();
@@ -27387,10 +27497,6 @@ const Toolbar = ({
27387
27497
  const paragraphNode = $createParagraphNode();
27388
27498
  chartNode.insertAfter(paragraphNode);
27389
27499
  });
27390
- toast.success("Chart inserted successfully!", { id: toastId });
27391
- } catch (error) {
27392
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
27393
- toast.error(`Failed to insert chart: ${errorMessage}`, { id: toastId });
27394
27500
  }
27395
27501
  },
27396
27502
  [editor, apiKey]
@@ -28814,7 +28920,7 @@ const STATIC_SUGGESTIONS = [
28814
28920
  "programming"
28815
28921
  ];
28816
28922
  const CACHE_MAX_AGE = 5 * 60 * 1e3;
28817
- const MAX_CACHE_SIZE$1 = 200;
28923
+ const MAX_CACHE_SIZE = 200;
28818
28924
  const REQUEST_TIMEOUT = 3e4;
28819
28925
  const MENU_CONFIG = { width: 320, height: 200, padding: 8 };
28820
28926
  const TOOLTIP_CONFIG = {
@@ -28986,7 +29092,7 @@ class GrammarAIService {
28986
29092
  errors,
28987
29093
  checkedAt: Date.now()
28988
29094
  });
28989
- if (this.sentenceCache.size > MAX_CACHE_SIZE$1) {
29095
+ if (this.sentenceCache.size > MAX_CACHE_SIZE) {
28990
29096
  const oldestKey = this.sentenceCache.keys().next().value;
28991
29097
  if (oldestKey)
28992
29098
  this.sentenceCache.delete(oldestKey);
@@ -30919,43 +31025,31 @@ const EmbedPreviewPlugin = ({
30919
31025
  if (!text.match(/^https?:\/\//)) {
30920
31026
  return false;
30921
31027
  }
30922
- const selection = $getSelection();
30923
- if (!$isRangeSelection(selection)) {
30924
- return false;
30925
- }
30926
- const anchorNode = selection.anchor.getNode();
30927
- let isInsideTableCell = false;
30928
- let currentNode = anchorNode;
30929
- while (currentNode) {
30930
- if ($isTableCellNode(currentNode)) {
30931
- isInsideTableCell = true;
30932
- break;
30933
- }
30934
- currentNode = currentNode.getParent();
30935
- }
30936
- if (isInsideTableCell) {
30937
- selection.insertText(text);
30938
- return true;
30939
- }
30940
31028
  const isVideoEmbed = VIDEO_EMBED_URLS.some(
30941
31029
  (domain) => text.includes(domain)
30942
31030
  );
30943
31031
  if (isVideoEmbed) {
30944
31032
  console.log("Detected video embed URL:", text);
30945
- const embedNode2 = $createEmbedNode(text);
30946
- embedNode2.setDisplayType("embed");
30947
- selection.insertNodes([embedNode2]);
30948
- console.log("Inserted video embed node");
31033
+ const selection2 = $getSelection();
31034
+ if ($isRangeSelection(selection2)) {
31035
+ const embedNode = $createEmbedNode(text);
31036
+ embedNode.setDisplayType("embed");
31037
+ selection2.insertNodes([embedNode]);
31038
+ console.log("Inserted video embed node");
31039
+ }
30949
31040
  return true;
30950
31041
  }
30951
- const embedNode = $createEmbedNode(text);
30952
- if (text.match(/\.(pdf|docx?|xlsx?|pptx?|zip|rar|txt)$/)) {
30953
- embedNode.setDisplayType("card");
30954
- } else {
30955
- embedNode.setDisplayType("url");
31042
+ const selection = $getSelection();
31043
+ if ($isRangeSelection(selection)) {
31044
+ const embedNode = $createEmbedNode(text);
31045
+ if (text.match(/\.(pdf|docx?|xlsx?|pptx?|zip|rar|txt)$/)) {
31046
+ embedNode.setDisplayType("card");
31047
+ } else {
31048
+ embedNode.setDisplayType("url");
31049
+ }
31050
+ selection.insertNodes([embedNode]);
31051
+ console.log("Inserted embed node with URL:", text);
30956
31052
  }
30957
- selection.insertNodes([embedNode]);
30958
- console.log("Inserted embed node with URL:", text);
30959
31053
  return true;
30960
31054
  },
30961
31055
  COMMAND_PRIORITY_HIGH
@@ -30963,416 +31057,6 @@ const EmbedPreviewPlugin = ({
30963
31057
  }, [editor]);
30964
31058
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(FloatingEmbedMenuPlugin, { anchorElem: floatingAnchorElem }) });
30965
31059
  };
30966
- const index$5 = "";
30967
- function getDOMRangeRect(nativeSelection, rootElement) {
30968
- const domRange = nativeSelection.getRangeAt(0);
30969
- let rect;
30970
- if (nativeSelection.anchorNode === rootElement) {
30971
- let inner = rootElement;
30972
- while (inner.firstElementChild != null) {
30973
- inner = inner.firstElementChild;
30974
- }
30975
- rect = inner.getBoundingClientRect();
30976
- } else {
30977
- rect = domRange.getBoundingClientRect();
30978
- }
30979
- return rect;
30980
- }
30981
- const TextEnhanceDialog = forwardRef(
30982
- ({ onEnhance }, ref) => {
30983
- const [isOpen, setIsOpen] = useState$1(false);
30984
- const [selectedText, setSelectedText] = useState$1("");
30985
- const [userPrompt, setUserPrompt] = useState$1("");
30986
- const [enhancedText, setEnhancedText] = useState$1("");
30987
- const [isLoading, setIsLoading] = useState$1(false);
30988
- const [showResult, setShowResult] = useState$1(false);
30989
- const [onInsertCallback, setOnInsertCallback] = useState$1(null);
30990
- useImperativeHandle(ref, () => ({
30991
- openDialog: (text, insertCallback) => {
30992
- setSelectedText(text);
30993
- setUserPrompt("");
30994
- setEnhancedText("");
30995
- setShowResult(false);
30996
- setOnInsertCallback(() => insertCallback);
30997
- setIsOpen(true);
30998
- },
30999
- closeDialog: () => {
31000
- setIsOpen(false);
31001
- setTimeout(() => {
31002
- setSelectedText("");
31003
- setUserPrompt("");
31004
- setEnhancedText("");
31005
- setShowResult(false);
31006
- setOnInsertCallback(null);
31007
- }, 300);
31008
- }
31009
- }));
31010
- const handleClose = () => {
31011
- setIsOpen(false);
31012
- setTimeout(() => {
31013
- setSelectedText("");
31014
- setUserPrompt("");
31015
- setEnhancedText("");
31016
- setShowResult(false);
31017
- setOnInsertCallback(null);
31018
- }, 300);
31019
- };
31020
- const handleEnhance = async () => {
31021
- if (!userPrompt.trim())
31022
- return;
31023
- setIsLoading(true);
31024
- try {
31025
- const result = await onEnhance(selectedText, userPrompt);
31026
- setEnhancedText(result);
31027
- setShowResult(true);
31028
- } catch (error) {
31029
- console.error("Enhancement error:", error);
31030
- } finally {
31031
- setIsLoading(false);
31032
- }
31033
- };
31034
- const handleInsert = () => {
31035
- if (onInsertCallback && enhancedText) {
31036
- onInsertCallback(enhancedText);
31037
- }
31038
- handleClose();
31039
- };
31040
- return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:cteditor-max-w-[500px] cteditor-max-h-[650px]", children: [
31041
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
31042
- /* @__PURE__ */ jsxs(DialogTitle, { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
31043
- /* @__PURE__ */ jsx(Sparkles, { className: "cteditor-size-5" }),
31044
- "Enhance Text"
31045
- ] }),
31046
- /* @__PURE__ */ jsx(DialogDescription, { children: "Enhance your selected text with AI assistance." })
31047
- ] }),
31048
- /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-4 cteditor-overflow-y-auto cteditor-max-h-[400px] cteditor-pr-2", children: [
31049
- /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-1.5", children: [
31050
- /* @__PURE__ */ jsx("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "Selected Text" }),
31051
- /* @__PURE__ */ jsx("div", { className: "cteditor-p-3 cteditor-bg-accent/50 cteditor-rounded-lg cteditor-border cteditor-border-border cteditor-max-h-24 cteditor-overflow-y-auto", children: /* @__PURE__ */ jsx("p", { className: "cteditor-text-sm cteditor-text-foreground cteditor-leading-relaxed", children: selectedText }) })
31052
- ] }),
31053
- !showResult && /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-1.5", children: [
31054
- /* @__PURE__ */ jsx("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "How to enhance?" }),
31055
- /* @__PURE__ */ jsx(
31056
- "textarea",
31057
- {
31058
- value: userPrompt,
31059
- onChange: (e) => setUserPrompt(e.target.value),
31060
- placeholder: "E.g., Make it professional, Add details, Simplify...",
31061
- className: "cteditor-w-full cteditor-h-20 cteditor-p-3 cteditor-bg-background cteditor-rounded-lg cteditor-border cteditor-border-border focus:cteditor-border-foreground cteditor-outline-none cteditor-text-sm cteditor-text-foreground cteditor-placeholder-muted-foreground cteditor-resize-none",
31062
- disabled: isLoading,
31063
- onKeyDown: (e) => {
31064
- if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
31065
- handleEnhance();
31066
- }
31067
- }
31068
- }
31069
- ),
31070
- /* @__PURE__ */ jsx("p", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: "Ctrl+Enter to enhance" })
31071
- ] }),
31072
- isLoading && /* @__PURE__ */ jsxs("div", { className: "cteditor-flex cteditor-flex-col cteditor-items-center cteditor-justify-center cteditor-py-0 cteditor-space-y-3", children: [
31073
- /* @__PURE__ */ jsxs("div", { className: "cteditor-relative cteditor-w-14 cteditor-h-14", children: [
31074
- /* @__PURE__ */ jsx(
31075
- "div",
31076
- {
31077
- className: "cteditor-absolute cteditor-inset-0 cteditor-rounded-full cteditor-opacity-75",
31078
- style: {
31079
- background: "linear-gradient(to right, #a855f7, #ec4899, #a855f7)",
31080
- animation: "spin 2s linear infinite",
31081
- padding: "2px",
31082
- WebkitMask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
31083
- WebkitMaskComposite: "xor",
31084
- maskComposite: "exclude"
31085
- }
31086
- }
31087
- ),
31088
- /* @__PURE__ */ jsx("div", { className: "cteditor-absolute cteditor-inset-0 cteditor-rounded-full cteditor-bg-background cteditor-flex cteditor-items-center cteditor-justify-center cteditor-m-[2px]", children: /* @__PURE__ */ jsx(Sparkles, { className: "cteditor-w-6 cteditor-h-6 cteditor-text-purple-500 cteditor-animate-pulse" }) })
31089
- ] }),
31090
- /* @__PURE__ */ jsx("div", { className: "cteditor-text-center", children: /* @__PURE__ */ jsx("p", { className: "cteditor-text-sm cteditor-font-medium cteditor-text-foreground", children: "Enhancing text..." }) })
31091
- ] }),
31092
- showResult && !isLoading && /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-1.5 cteditor-animate-in cteditor-fade-in cteditor-slide-in-from-bottom-4", children: [
31093
- /* @__PURE__ */ jsxs("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1.5", children: [
31094
- /* @__PURE__ */ jsx(Check, { className: "cteditor-w-3.5 cteditor-h-3.5 cteditor-text-green-500" }),
31095
- /* @__PURE__ */ jsx("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "Enhanced Text" })
31096
- ] }),
31097
- /* @__PURE__ */ jsx("div", { className: "cteditor-p-3 cteditor-bg-gradient-to-br cteditor-from-purple-500/5 cteditor-to-pink-500/5 cteditor-rounded-lg cteditor-border cteditor-border-purple-500/20 cteditor-max-h-48 cteditor-overflow-y-auto", children: /* @__PURE__ */ jsx("p", { className: "cteditor-text-sm cteditor-text-foreground cteditor-leading-relaxed", children: enhancedText }) })
31098
- ] })
31099
- ] }),
31100
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
31101
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: handleClose, children: "Cancel" }),
31102
- !showResult && /* @__PURE__ */ jsxs(
31103
- Button,
31104
- {
31105
- onClick: handleEnhance,
31106
- disabled: !userPrompt.trim() || isLoading,
31107
- className: "cteditor-gap-2",
31108
- children: [
31109
- /* @__PURE__ */ jsx(Sparkles, { className: "cteditor-size-5" }),
31110
- "Enhance"
31111
- ]
31112
- }
31113
- ),
31114
- showResult && /* @__PURE__ */ jsxs(
31115
- Button,
31116
- {
31117
- onClick: handleInsert,
31118
- className: "cteditor-gap-2",
31119
- children: [
31120
- "Insert",
31121
- /* @__PURE__ */ jsx(ArrowRight, { className: "cteditor-size-5" })
31122
- ]
31123
- }
31124
- )
31125
- ] })
31126
- ] }) });
31127
- }
31128
- );
31129
- TextEnhanceDialog.displayName = "TextEnhanceDialog";
31130
- const TEXT_ENHANCE_COMMAND = createCommand("TEXT_ENHANCE_COMMAND");
31131
- const TextEnhancePlugin = ({ apiKey }) => {
31132
- const [editor] = useLexicalComposerContext();
31133
- const enhanceDialogRef = useRef(null);
31134
- const handleTextEnhancement = async (selectedText, userPrompt) => {
31135
- try {
31136
- const prompt = `Enhance the following text based on this instruction: "${userPrompt}"
31137
-
31138
- Original text:
31139
- "${selectedText}"
31140
-
31141
- Provide only the enhanced text without any additional explanation.`;
31142
- const response = await AiTextEnhance({ content: prompt, apiKey });
31143
- if (!response.data) {
31144
- throw new Error("No response received from AI");
31145
- }
31146
- return response.data;
31147
- } catch (error) {
31148
- console.error("Error enhancing text:", error);
31149
- toast.error("Enhancement failed", {
31150
- description: error instanceof Error ? error.message : "An error occurred"
31151
- });
31152
- throw error;
31153
- }
31154
- };
31155
- const handleOpenDialog = (selectedText) => {
31156
- editor.getEditorState().read(() => {
31157
- var _a;
31158
- const selection = $getSelection();
31159
- if (!$isRangeSelection(selection))
31160
- return;
31161
- const text = selectedText || selection.getTextContent().trim();
31162
- if (!text) {
31163
- toast.error("No text selected", {
31164
- description: "Please select some text to enhance"
31165
- });
31166
- return;
31167
- }
31168
- (_a = enhanceDialogRef.current) == null ? void 0 : _a.openDialog(text, (enhancedText) => {
31169
- editor.update(() => {
31170
- const currentSelection = $getSelection();
31171
- if (!currentSelection || !$isRangeSelection(currentSelection))
31172
- return;
31173
- const parser = new DOMParser();
31174
- const dom = parser.parseFromString(enhancedText, "text/html");
31175
- const nodes = $generateNodesFromDOM(editor, dom);
31176
- currentSelection.insertText("");
31177
- $insertNodes(nodes);
31178
- });
31179
- toast.success("Text inserted successfully!");
31180
- });
31181
- });
31182
- return true;
31183
- };
31184
- useEffect$1(() => {
31185
- return editor.registerCommand(
31186
- TEXT_ENHANCE_COMMAND,
31187
- (selectedText) => {
31188
- handleOpenDialog(selectedText);
31189
- return true;
31190
- },
31191
- COMMAND_PRIORITY_LOW
31192
- );
31193
- }, [editor]);
31194
- return /* @__PURE__ */ jsx(
31195
- TextEnhanceDialog,
31196
- {
31197
- ref: enhanceDialogRef,
31198
- onEnhance: handleTextEnhancement
31199
- }
31200
- );
31201
- };
31202
- function FloatingEnhanceButton({
31203
- anchorElem
31204
- }) {
31205
- const [editor] = useLexicalComposerContext();
31206
- const enhanceButtonRef = useRef(null);
31207
- const [isVisible, setIsVisible] = useState$1(false);
31208
- const updateButtonPosition = useCallback(() => {
31209
- const selection = $getSelection();
31210
- const buttonElem = enhanceButtonRef.current;
31211
- const nativeSelection = getDOMSelection(editor._window);
31212
- if (buttonElem === null) {
31213
- return;
31214
- }
31215
- const rootElement = editor.getRootElement();
31216
- if (selection !== null && nativeSelection !== null && !nativeSelection.isCollapsed && rootElement !== null && rootElement.contains(nativeSelection.anchorNode)) {
31217
- const rangeRect = getDOMRangeRect(nativeSelection, rootElement);
31218
- if (rangeRect) {
31219
- const BUTTON_WIDTH = 32;
31220
- const BUTTON_HEIGHT = 32;
31221
- const SPACING = 8;
31222
- const TOOLBAR_HEIGHT = 40;
31223
- const viewportWidth = window.innerWidth;
31224
- const rightPosition = rangeRect.right + anchorElem.offsetLeft + SPACING;
31225
- const hasSpaceOnRight = rightPosition + BUTTON_WIDTH + 20 < viewportWidth;
31226
- let top;
31227
- let left;
31228
- if (hasSpaceOnRight) {
31229
- top = rangeRect.top + anchorElem.offsetTop + rangeRect.height / 2 - BUTTON_HEIGHT / 2;
31230
- left = rightPosition;
31231
- } else {
31232
- top = rangeRect.top + anchorElem.offsetTop - BUTTON_HEIGHT - SPACING - TOOLBAR_HEIGHT;
31233
- left = rangeRect.left + anchorElem.offsetLeft + rangeRect.width / 2 - BUTTON_WIDTH / 2;
31234
- if (left < 10) {
31235
- left = 10;
31236
- }
31237
- if (left + BUTTON_WIDTH > viewportWidth - 10) {
31238
- left = viewportWidth - BUTTON_WIDTH - 10;
31239
- }
31240
- if (top < 10) {
31241
- top = rangeRect.bottom + anchorElem.offsetTop + SPACING;
31242
- }
31243
- }
31244
- buttonElem.style.opacity = "1";
31245
- buttonElem.style.top = `${top}px`;
31246
- buttonElem.style.left = `${left}px`;
31247
- setIsVisible(true);
31248
- }
31249
- } else {
31250
- buttonElem.style.opacity = "0";
31251
- buttonElem.style.top = "-10000px";
31252
- buttonElem.style.left = "-10000px";
31253
- setIsVisible(false);
31254
- }
31255
- }, [editor, anchorElem]);
31256
- useEffect$1(() => {
31257
- const scrollerElem = anchorElem.parentElement;
31258
- const update = () => {
31259
- editor.getEditorState().read(() => {
31260
- updateButtonPosition();
31261
- });
31262
- };
31263
- window.addEventListener("resize", update);
31264
- if (scrollerElem) {
31265
- scrollerElem.addEventListener("scroll", update);
31266
- }
31267
- return () => {
31268
- window.removeEventListener("resize", update);
31269
- if (scrollerElem) {
31270
- scrollerElem.removeEventListener("scroll", update);
31271
- }
31272
- };
31273
- }, [editor, updateButtonPosition, anchorElem]);
31274
- useEffect$1(() => {
31275
- editor.getEditorState().read(() => {
31276
- updateButtonPosition();
31277
- });
31278
- return mergeRegister(
31279
- editor.registerUpdateListener(({ editorState }) => {
31280
- editorState.read(() => {
31281
- updateButtonPosition();
31282
- });
31283
- }),
31284
- editor.registerCommand(
31285
- SELECTION_CHANGE_COMMAND,
31286
- () => {
31287
- updateButtonPosition();
31288
- return false;
31289
- },
31290
- COMMAND_PRIORITY_LOW
31291
- )
31292
- );
31293
- }, [editor, updateButtonPosition]);
31294
- const handleClick = () => {
31295
- editor.dispatchCommand(TEXT_ENHANCE_COMMAND, void 0);
31296
- };
31297
- return /* @__PURE__ */ jsxs(
31298
- "button",
31299
- {
31300
- ref: enhanceButtonRef,
31301
- className: "floating-enhance-button",
31302
- onClick: handleClick,
31303
- title: "Enhance Text with AI",
31304
- "aria-label": "Enhance Text with AI",
31305
- children: [
31306
- /* @__PURE__ */ jsx(SparkleIcon, {}),
31307
- /* @__PURE__ */ jsx("span", { className: "floating-enhance-button-tooltip", children: "Enhance with AI" })
31308
- ]
31309
- }
31310
- );
31311
- }
31312
- function FloatingEnhanceButtonPlugin({
31313
- anchorElem = document.body
31314
- }) {
31315
- const [editor] = useLexicalComposerContext();
31316
- const [isText, setIsText] = useState$1(false);
31317
- useEffect$1(() => {
31318
- const updateTextSelection = () => {
31319
- editor.getEditorState().read(() => {
31320
- if (editor.isComposing()) {
31321
- return;
31322
- }
31323
- const selection = $getSelection();
31324
- const nativeSelection = getDOMSelection(editor._window);
31325
- const rootElement = editor.getRootElement();
31326
- if (nativeSelection !== null && (!$isRangeSelection(selection) || rootElement === null || !rootElement.contains(nativeSelection.anchorNode))) {
31327
- setIsText(false);
31328
- return;
31329
- }
31330
- if (!$isRangeSelection(selection)) {
31331
- return;
31332
- }
31333
- const textContent = selection.getTextContent();
31334
- if (!selection.isCollapsed() && textContent.trim() !== "") {
31335
- setIsText(true);
31336
- } else {
31337
- setIsText(false);
31338
- }
31339
- });
31340
- };
31341
- document.addEventListener("selectionchange", updateTextSelection);
31342
- return () => {
31343
- document.removeEventListener("selectionchange", updateTextSelection);
31344
- };
31345
- }, [editor]);
31346
- useEffect$1(() => {
31347
- return mergeRegister(
31348
- editor.registerUpdateListener(() => {
31349
- editor.getEditorState().read(() => {
31350
- const selection = $getSelection();
31351
- const nativeSelection = getDOMSelection(editor._window);
31352
- const rootElement = editor.getRootElement();
31353
- if (nativeSelection !== null && $isRangeSelection(selection) && rootElement !== null && rootElement.contains(nativeSelection.anchorNode)) {
31354
- const textContent = selection.getTextContent();
31355
- setIsText(!selection.isCollapsed() && textContent.trim() !== "");
31356
- } else {
31357
- setIsText(false);
31358
- }
31359
- });
31360
- }),
31361
- editor.registerRootListener(() => {
31362
- if (editor.getRootElement() === null) {
31363
- setIsText(false);
31364
- }
31365
- })
31366
- );
31367
- }, [editor]);
31368
- if (!isText) {
31369
- return null;
31370
- }
31371
- return createPortal(
31372
- /* @__PURE__ */ jsx(FloatingEnhanceButton, { anchorElem }),
31373
- anchorElem
31374
- );
31375
- }
31376
31060
  const index$4 = "";
31377
31061
  const VERTICAL_GAP$1 = 10;
31378
31062
  const HORIZONTAL_OFFSET$1 = 5;
@@ -31820,6 +31504,20 @@ function FloatingLinkEditorPlugin({
31820
31504
  );
31821
31505
  }
31822
31506
  const index$3 = "";
31507
+ function getDOMRangeRect(nativeSelection, rootElement) {
31508
+ const domRange = nativeSelection.getRangeAt(0);
31509
+ let rect;
31510
+ if (nativeSelection.anchorNode === rootElement) {
31511
+ let inner = rootElement;
31512
+ while (inner.firstElementChild != null) {
31513
+ inner = inner.firstElementChild;
31514
+ }
31515
+ rect = inner.getBoundingClientRect();
31516
+ } else {
31517
+ rect = domRange.getBoundingClientRect();
31518
+ }
31519
+ return rect;
31520
+ }
31823
31521
  const VERTICAL_GAP = 10;
31824
31522
  const HORIZONTAL_OFFSET = 5;
31825
31523
  function setFloatingElemPosition(targetRect, floatingElem, anchorElem, isLink = false, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET, isEmbed = false) {
@@ -31878,6 +31576,227 @@ function setFloatingElemPosition(targetRect, floatingElem, anchorElem, isLink =
31878
31576
  floatingElem.style.opacity = "1";
31879
31577
  floatingElem.style.transform = `translate(${left}px, ${top}px)`;
31880
31578
  }
31579
+ const TextEnhanceDialog = forwardRef(
31580
+ ({ onEnhance }, ref) => {
31581
+ const [isOpen, setIsOpen] = useState$1(false);
31582
+ const [selectedText, setSelectedText] = useState$1("");
31583
+ const [userPrompt, setUserPrompt] = useState$1("");
31584
+ const [enhancedText, setEnhancedText] = useState$1("");
31585
+ const [isLoading, setIsLoading] = useState$1(false);
31586
+ const [showResult, setShowResult] = useState$1(false);
31587
+ const [onInsertCallback, setOnInsertCallback] = useState$1(null);
31588
+ useImperativeHandle(ref, () => ({
31589
+ openDialog: (text, insertCallback) => {
31590
+ setSelectedText(text);
31591
+ setUserPrompt("");
31592
+ setEnhancedText("");
31593
+ setShowResult(false);
31594
+ setOnInsertCallback(() => insertCallback);
31595
+ setIsOpen(true);
31596
+ },
31597
+ closeDialog: () => {
31598
+ setIsOpen(false);
31599
+ setTimeout(() => {
31600
+ setSelectedText("");
31601
+ setUserPrompt("");
31602
+ setEnhancedText("");
31603
+ setShowResult(false);
31604
+ setOnInsertCallback(null);
31605
+ }, 300);
31606
+ }
31607
+ }));
31608
+ const handleClose = () => {
31609
+ setIsOpen(false);
31610
+ setTimeout(() => {
31611
+ setSelectedText("");
31612
+ setUserPrompt("");
31613
+ setEnhancedText("");
31614
+ setShowResult(false);
31615
+ setOnInsertCallback(null);
31616
+ }, 300);
31617
+ };
31618
+ const handleEnhance = async () => {
31619
+ if (!userPrompt.trim())
31620
+ return;
31621
+ setIsLoading(true);
31622
+ try {
31623
+ const result = await onEnhance(selectedText, userPrompt);
31624
+ setEnhancedText(result);
31625
+ setShowResult(true);
31626
+ } catch (error) {
31627
+ console.error("Enhancement error:", error);
31628
+ } finally {
31629
+ setIsLoading(false);
31630
+ }
31631
+ };
31632
+ const handleInsert = () => {
31633
+ if (onInsertCallback && enhancedText) {
31634
+ onInsertCallback(enhancedText);
31635
+ }
31636
+ handleClose();
31637
+ };
31638
+ return /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:cteditor-max-w-[500px] cteditor-max-h-[650px]", children: [
31639
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [
31640
+ /* @__PURE__ */ jsxs(DialogTitle, { className: "cteditor-flex cteditor-items-center cteditor-gap-2", children: [
31641
+ /* @__PURE__ */ jsx(Sparkles, { className: "cteditor-size-5" }),
31642
+ "Enhance Text"
31643
+ ] }),
31644
+ /* @__PURE__ */ jsx(DialogDescription, { children: "Enhance your selected text with AI assistance." })
31645
+ ] }),
31646
+ /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-4 cteditor-overflow-y-auto cteditor-max-h-[400px] cteditor-pr-2", children: [
31647
+ /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-1.5", children: [
31648
+ /* @__PURE__ */ jsx("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "Selected Text" }),
31649
+ /* @__PURE__ */ jsx("div", { className: "cteditor-p-3 cteditor-bg-accent/50 cteditor-rounded-lg cteditor-border cteditor-border-border cteditor-max-h-24 cteditor-overflow-y-auto", children: /* @__PURE__ */ jsx("p", { className: "cteditor-text-sm cteditor-text-foreground cteditor-leading-relaxed", children: selectedText }) })
31650
+ ] }),
31651
+ !showResult && /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-1.5", children: [
31652
+ /* @__PURE__ */ jsx("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "How to enhance?" }),
31653
+ /* @__PURE__ */ jsx(
31654
+ "textarea",
31655
+ {
31656
+ value: userPrompt,
31657
+ onChange: (e) => setUserPrompt(e.target.value),
31658
+ placeholder: "E.g., Make it professional, Add details, Simplify...",
31659
+ className: "cteditor-w-full cteditor-h-20 cteditor-p-3 cteditor-bg-background cteditor-rounded-lg cteditor-border cteditor-border-border focus:cteditor-border-foreground cteditor-outline-none cteditor-text-sm cteditor-text-foreground cteditor-placeholder-muted-foreground cteditor-resize-none",
31660
+ disabled: isLoading,
31661
+ onKeyDown: (e) => {
31662
+ if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
31663
+ handleEnhance();
31664
+ }
31665
+ }
31666
+ }
31667
+ ),
31668
+ /* @__PURE__ */ jsx("p", { className: "cteditor-text-xs cteditor-text-muted-foreground", children: "Ctrl+Enter to enhance" })
31669
+ ] }),
31670
+ isLoading && /* @__PURE__ */ jsxs("div", { className: "cteditor-flex cteditor-flex-col cteditor-items-center cteditor-justify-center cteditor-py-0 cteditor-space-y-3", children: [
31671
+ /* @__PURE__ */ jsxs("div", { className: "cteditor-relative cteditor-w-14 cteditor-h-14", children: [
31672
+ /* @__PURE__ */ jsx(
31673
+ "div",
31674
+ {
31675
+ className: "cteditor-absolute cteditor-inset-0 cteditor-rounded-full cteditor-opacity-75",
31676
+ style: {
31677
+ background: "linear-gradient(to right, #a855f7, #ec4899, #a855f7)",
31678
+ animation: "spin 2s linear infinite",
31679
+ padding: "2px",
31680
+ WebkitMask: "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
31681
+ WebkitMaskComposite: "xor",
31682
+ maskComposite: "exclude"
31683
+ }
31684
+ }
31685
+ ),
31686
+ /* @__PURE__ */ jsx("div", { className: "cteditor-absolute cteditor-inset-0 cteditor-rounded-full cteditor-bg-background cteditor-flex cteditor-items-center cteditor-justify-center cteditor-m-[2px]", children: /* @__PURE__ */ jsx(Sparkles, { className: "cteditor-w-6 cteditor-h-6 cteditor-text-purple-500 cteditor-animate-pulse" }) })
31687
+ ] }),
31688
+ /* @__PURE__ */ jsx("div", { className: "cteditor-text-center", children: /* @__PURE__ */ jsx("p", { className: "cteditor-text-sm cteditor-font-medium cteditor-text-foreground", children: "Enhancing text..." }) })
31689
+ ] }),
31690
+ showResult && !isLoading && /* @__PURE__ */ jsxs("div", { className: "cteditor-space-y-1.5 cteditor-animate-in cteditor-fade-in cteditor-slide-in-from-bottom-4", children: [
31691
+ /* @__PURE__ */ jsxs("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-1.5", children: [
31692
+ /* @__PURE__ */ jsx(Check, { className: "cteditor-w-3.5 cteditor-h-3.5 cteditor-text-green-500" }),
31693
+ /* @__PURE__ */ jsx("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "Enhanced Text" })
31694
+ ] }),
31695
+ /* @__PURE__ */ jsx("div", { className: "cteditor-p-3 cteditor-bg-gradient-to-br cteditor-from-purple-500/5 cteditor-to-pink-500/5 cteditor-rounded-lg cteditor-border cteditor-border-purple-500/20 cteditor-max-h-48 cteditor-overflow-y-auto", children: /* @__PURE__ */ jsx("p", { className: "cteditor-text-sm cteditor-text-foreground cteditor-leading-relaxed", children: enhancedText }) })
31696
+ ] })
31697
+ ] }),
31698
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
31699
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: handleClose, children: "Cancel" }),
31700
+ !showResult && /* @__PURE__ */ jsxs(
31701
+ Button,
31702
+ {
31703
+ onClick: handleEnhance,
31704
+ disabled: !userPrompt.trim() || isLoading,
31705
+ className: "cteditor-gap-2",
31706
+ children: [
31707
+ /* @__PURE__ */ jsx(Sparkles, { className: "cteditor-size-5" }),
31708
+ "Enhance"
31709
+ ]
31710
+ }
31711
+ ),
31712
+ showResult && /* @__PURE__ */ jsxs(
31713
+ Button,
31714
+ {
31715
+ onClick: handleInsert,
31716
+ className: "cteditor-gap-2",
31717
+ children: [
31718
+ "Insert",
31719
+ /* @__PURE__ */ jsx(ArrowRight, { className: "cteditor-size-5" })
31720
+ ]
31721
+ }
31722
+ )
31723
+ ] })
31724
+ ] }) });
31725
+ }
31726
+ );
31727
+ TextEnhanceDialog.displayName = "TextEnhanceDialog";
31728
+ const TEXT_ENHANCE_COMMAND = createCommand("TEXT_ENHANCE_COMMAND");
31729
+ const TextEnhancePlugin = ({ apiKey }) => {
31730
+ const [editor] = useLexicalComposerContext();
31731
+ const enhanceDialogRef = useRef(null);
31732
+ const handleTextEnhancement = async (selectedText, userPrompt) => {
31733
+ try {
31734
+ const prompt = `Enhance the following text based on this instruction: "${userPrompt}"
31735
+
31736
+ Original text:
31737
+ "${selectedText}"
31738
+
31739
+ Provide only the enhanced text without any additional explanation.`;
31740
+ const response = await AiTextEnhance({ content: prompt, apiKey });
31741
+ if (!response.data) {
31742
+ throw new Error("No response received from AI");
31743
+ }
31744
+ return response.data;
31745
+ } catch (error) {
31746
+ console.error("Error enhancing text:", error);
31747
+ toast.error("Enhancement failed", {
31748
+ description: error instanceof Error ? error.message : "An error occurred"
31749
+ });
31750
+ throw error;
31751
+ }
31752
+ };
31753
+ const handleOpenDialog = (selectedText) => {
31754
+ editor.getEditorState().read(() => {
31755
+ var _a;
31756
+ const selection = $getSelection();
31757
+ if (!$isRangeSelection(selection))
31758
+ return;
31759
+ const text = selectedText || selection.getTextContent().trim();
31760
+ if (!text) {
31761
+ toast.error("No text selected", {
31762
+ description: "Please select some text to enhance"
31763
+ });
31764
+ return;
31765
+ }
31766
+ (_a = enhanceDialogRef.current) == null ? void 0 : _a.openDialog(text, (enhancedText) => {
31767
+ editor.update(() => {
31768
+ const currentSelection = $getSelection();
31769
+ if (!currentSelection || !$isRangeSelection(currentSelection))
31770
+ return;
31771
+ const parser = new DOMParser();
31772
+ const dom = parser.parseFromString(enhancedText, "text/html");
31773
+ const nodes = $generateNodesFromDOM(editor, dom);
31774
+ currentSelection.insertText("");
31775
+ $insertNodes(nodes);
31776
+ });
31777
+ toast.success("Text inserted successfully!");
31778
+ });
31779
+ });
31780
+ return true;
31781
+ };
31782
+ useEffect$1(() => {
31783
+ return editor.registerCommand(
31784
+ TEXT_ENHANCE_COMMAND,
31785
+ (selectedText) => {
31786
+ handleOpenDialog(selectedText);
31787
+ return true;
31788
+ },
31789
+ COMMAND_PRIORITY_LOW
31790
+ );
31791
+ }, [editor]);
31792
+ return /* @__PURE__ */ jsx(
31793
+ TextEnhanceDialog,
31794
+ {
31795
+ ref: enhanceDialogRef,
31796
+ onEnhance: handleTextEnhancement
31797
+ }
31798
+ );
31799
+ };
31881
31800
  const DropdownMenu = ({ children, trigger }) => {
31882
31801
  const [isOpen, setIsOpen] = useState$1(false);
31883
31802
  const dropdownRef = useRef(null);
@@ -32147,6 +32066,26 @@ function TextFormatFloatingToolbar({
32147
32066
  ]
32148
32067
  }
32149
32068
  ),
32069
+ /* @__PURE__ */ jsxs(
32070
+ DropdownMenuItem,
32071
+ {
32072
+ onClick: () => {
32073
+ editor.getEditorState().read(() => {
32074
+ const selection = $getSelection();
32075
+ if ($isRangeSelection(selection)) {
32076
+ const selectedText = selection.getTextContent();
32077
+ editor.dispatchCommand(TEXT_ENHANCE_COMMAND, selectedText || void 0);
32078
+ } else {
32079
+ editor.dispatchCommand(TEXT_ENHANCE_COMMAND, void 0);
32080
+ }
32081
+ });
32082
+ },
32083
+ children: [
32084
+ /* @__PURE__ */ jsx("div", { className: "cteditor-w-5 cteditor-h-5 cteditor-flex cteditor-items-center cteditor-justify-center", children: /* @__PURE__ */ jsx(SparkleIcon, {}) }),
32085
+ /* @__PURE__ */ jsx("span", { children: "Enhance with AI" })
32086
+ ]
32087
+ }
32088
+ ),
32150
32089
  /* @__PURE__ */ jsxs(
32151
32090
  DropdownMenuItem,
32152
32091
  {
@@ -32573,50 +32512,6 @@ function LinkPlugin({
32573
32512
  }
32574
32513
  );
32575
32514
  }
32576
- const cache = /* @__PURE__ */ new Map();
32577
- const CACHE_TTL = 30 * 60 * 1e3;
32578
- const MAX_CACHE_SIZE = 100;
32579
- function getCached(url) {
32580
- const entry = cache.get(url);
32581
- if (!entry)
32582
- return null;
32583
- if (Date.now() - entry.timestamp > CACHE_TTL) {
32584
- cache.delete(url);
32585
- return null;
32586
- }
32587
- return entry.data;
32588
- }
32589
- function setCache(url, data) {
32590
- if (cache.size >= MAX_CACHE_SIZE) {
32591
- const oldestKey = cache.keys().next().value;
32592
- if (oldestKey)
32593
- cache.delete(oldestKey);
32594
- }
32595
- cache.set(url, { data, timestamp: Date.now() });
32596
- }
32597
- async function fetchLinkPreview({
32598
- url,
32599
- apiKey
32600
- }) {
32601
- const cached = getCached(url);
32602
- if (cached)
32603
- return cached;
32604
- try {
32605
- const response = await backendAPI.post(
32606
- apiEndpoints.linkPreview.getPreview,
32607
- { url },
32608
- apiKey ? { headers: { "X-API-Key": apiKey } } : void 0
32609
- );
32610
- if (response.data.success && response.data.data) {
32611
- setCache(url, response.data.data);
32612
- return response.data.data;
32613
- }
32614
- return null;
32615
- } catch (error) {
32616
- console.error("Error fetching link preview:", error);
32617
- return null;
32618
- }
32619
- }
32620
32515
  function LinkPreviewPlugin({ apiKey }) {
32621
32516
  const [editor] = useLexicalComposerContext();
32622
32517
  const [hoveredLink, setHoveredLink] = useState$1(null);
@@ -32774,7 +32669,7 @@ function LinkPreview({ url, rect, apiKey, onClose }) {
32774
32669
  }
32775
32670
  };
32776
32671
  const domain = getDomain(url);
32777
- const TypeIcon = ({ type }) => {
32672
+ const TypeIcon2 = ({ type }) => {
32778
32673
  const iconProps = { style: { width: "14px", height: "14px" }, fill: "none", stroke: "currentColor", viewBox: "0 0 24 24" };
32779
32674
  const pathProps = { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2 };
32780
32675
  switch (type) {
@@ -32884,7 +32779,7 @@ function LinkPreview({ url, rect, apiKey, onClose }) {
32884
32779
  e.currentTarget.style.display = "none";
32885
32780
  }
32886
32781
  }
32887
- ) : /* @__PURE__ */ jsx("span", { style: { color: "#888" }, children: /* @__PURE__ */ jsx(TypeIcon, { type: previewData.type }) }),
32782
+ ) : /* @__PURE__ */ jsx("span", { style: { color: "#888" }, children: /* @__PURE__ */ jsx(TypeIcon2, { type: previewData.type }) }),
32888
32783
  /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", color: "#888", flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: previewData.siteName || domain }),
32889
32784
  /* @__PURE__ */ jsx("span", { style: {
32890
32785
  fontSize: "10px",
@@ -35065,23 +34960,6 @@ function RichTextPastePlugin() {
35065
34960
  const selection = $getSelection();
35066
34961
  if (!$isRangeSelection(selection))
35067
34962
  return;
35068
- const anchorNode = selection.anchor.getNode();
35069
- let isInsideTableCell = false;
35070
- let currentNode = anchorNode;
35071
- while (currentNode) {
35072
- if ($isTableCellNode(currentNode)) {
35073
- isInsideTableCell = true;
35074
- break;
35075
- }
35076
- currentNode = currentNode.getParent();
35077
- }
35078
- if (isInsideTableCell) {
35079
- if (plainText) {
35080
- const cleanText = plainText.replace(/[\r\n]+/g, " ").trim();
35081
- selection.insertText(cleanText);
35082
- }
35083
- return;
35084
- }
35085
34963
  try {
35086
34964
  const nodes = convertHTMLToNodesWithStyles(htmlContent, editor);
35087
34965
  if (nodes.length > 0) {
@@ -35694,21 +35572,6 @@ function PasteOptionsPlugin() {
35694
35572
  const selection = $getSelection();
35695
35573
  if (!$isRangeSelection(selection))
35696
35574
  return;
35697
- const anchorNode = selection.anchor.getNode();
35698
- let isInsideTableCell = false;
35699
- let currentNode = anchorNode;
35700
- while (currentNode) {
35701
- if ($isTableCellNode(currentNode)) {
35702
- isInsideTableCell = true;
35703
- break;
35704
- }
35705
- currentNode = currentNode.getParent();
35706
- }
35707
- if (isInsideTableCell) {
35708
- const cleanText = pasteData.plain.replace(/[\r\n]+/g, " ").trim();
35709
- selection.insertText(cleanText);
35710
- return;
35711
- }
35712
35575
  let nodes = [];
35713
35576
  if (mode === "plain") {
35714
35577
  nodes = convertPlainTextToNodes(pasteData.plain);
@@ -35795,6 +35658,8 @@ function getOptionMeta(label) {
35795
35658
  return { icon: /* @__PURE__ */ jsx(Quote, { className: "cteditor-size-4" }), description: "Insert a quote block" };
35796
35659
  if (lower.includes("code block"))
35797
35660
  return { icon: /* @__PURE__ */ jsx(Code, { className: "cteditor-size-4" }), description: "Insert a code block" };
35661
+ if (lower.includes("horizontal") || lower.includes("divider"))
35662
+ return { icon: /* @__PURE__ */ jsx(Minus, { className: "cteditor-size-4" }), description: "Insert horizontal line" };
35798
35663
  if (lower.includes("bullet"))
35799
35664
  return { icon: /* @__PURE__ */ jsx(List$1, { className: "cteditor-size-4" }), description: "Create a bulleted list", shortcut: "•" };
35800
35665
  if (lower.includes("numbered"))
@@ -35807,6 +35672,8 @@ function getOptionMeta(label) {
35807
35672
  return { icon: /* @__PURE__ */ jsx(Video, { className: "cteditor-size-4" }), description: "Embed a video", shortcut: "Vid" };
35808
35673
  if (lower.includes("table"))
35809
35674
  return { icon: /* @__PURE__ */ jsx(Table, { className: "cteditor-size-4" }), description: "Insert a table" };
35675
+ if (lower.includes("chart"))
35676
+ return { icon: /* @__PURE__ */ jsx(BarChart3, { className: "cteditor-size-4" }), description: "Insert a chart" };
35810
35677
  if (lower.includes("bold"))
35811
35678
  return { icon: /* @__PURE__ */ jsx(Bold, { className: "cteditor-size-4" }), description: "Make text bold" };
35812
35679
  if (lower.includes("italic"))
@@ -35819,6 +35686,8 @@ function getOptionMeta(label) {
35819
35686
  return { icon: /* @__PURE__ */ jsx(Subscript, { className: "cteditor-size-4" }), description: "Format as subscript" };
35820
35687
  if (lower.includes("superscript"))
35821
35688
  return { icon: /* @__PURE__ */ jsx(Superscript, { className: "cteditor-size-4" }), description: "Format as superscript" };
35689
+ if (lower.includes("signature"))
35690
+ return { icon: /* @__PURE__ */ jsx(PenTool, { className: "cteditor-size-4" }), description: "Add your signature" };
35822
35691
  if (lower.includes("align left"))
35823
35692
  return { icon: /* @__PURE__ */ jsx(AlignLeft, { className: "cteditor-size-4" }), description: "Align text left" };
35824
35693
  if (lower.includes("align center"))
@@ -35827,30 +35696,26 @@ function getOptionMeta(label) {
35827
35696
  return { icon: /* @__PURE__ */ jsx(AlignRight, { className: "cteditor-size-4" }), description: "Align text right" };
35828
35697
  if (lower.includes("justify"))
35829
35698
  return { icon: /* @__PURE__ */ jsx(AlignJustify, { className: "cteditor-size-4" }), description: "Justify text" };
35830
- if (lower.includes("info"))
35699
+ if (lower.includes("info panel"))
35831
35700
  return { icon: /* @__PURE__ */ jsx(Info, { className: "cteditor-size-4" }), description: "Insert info panel" };
35832
- if (lower.includes("warning"))
35701
+ if (lower.includes("warning panel"))
35833
35702
  return { icon: /* @__PURE__ */ jsx(AlertTriangle, { className: "cteditor-size-4" }), description: "Insert warning panel" };
35834
- if (lower.includes("error"))
35703
+ if (lower.includes("error panel"))
35835
35704
  return { icon: /* @__PURE__ */ jsx(XCircle, { className: "cteditor-size-4" }), description: "Insert error panel" };
35836
- if (lower.includes("success"))
35705
+ if (lower.includes("success panel"))
35837
35706
  return { icon: /* @__PURE__ */ jsx(CheckCircle, { className: "cteditor-size-4" }), description: "Insert success panel" };
35838
35707
  if (lower.includes("undo"))
35839
35708
  return { icon: /* @__PURE__ */ jsx(Undo, { className: "cteditor-size-4" }), description: "Undo last action" };
35840
35709
  if (lower.includes("redo"))
35841
35710
  return { icon: /* @__PURE__ */ jsx(Redo, { className: "cteditor-size-4" }), description: "Redo last action" };
35842
- if (lower.includes("clear"))
35843
- return { icon: /* @__PURE__ */ jsx(Eraser, { className: "cteditor-size-4" }), description: "Clear formatting" };
35844
- if (lower.includes("comment"))
35845
- return { icon: /* @__PURE__ */ jsx(MessageSquare, { className: "cteditor-size-4" }), description: "Add a comment" };
35846
35711
  if (lower.includes("ai chat"))
35847
35712
  return { icon: /* @__PURE__ */ jsx(MessageCircle, { className: "cteditor-size-4" }), description: "Open AI chat" };
35848
35713
  if (lower.includes("ai") || lower.includes("improve"))
35849
35714
  return { icon: /* @__PURE__ */ jsx(Sparkles, { className: "cteditor-size-4" }), description: "AI improvements" };
35850
- if (lower.includes("html"))
35851
- return { icon: /* @__PURE__ */ jsx(FileCode2, { className: "cteditor-size-4" }), description: "Toggle HTML view" };
35852
- if (lower.includes("pdf") || lower.includes("export"))
35853
- return { icon: /* @__PURE__ */ jsx(Download, { className: "cteditor-size-4" }), description: "Export to PDF" };
35715
+ if (lower.includes("autocomplete") || lower.includes("grammar"))
35716
+ return { icon: /* @__PURE__ */ jsx(SpellCheck, { className: "cteditor-size-4" }), description: "Toggle grammar & autocomplete" };
35717
+ if (lower.includes("html") || lower.includes("source"))
35718
+ return { icon: /* @__PURE__ */ jsx(FileCode2, { className: "cteditor-size-4" }), description: "Switch to HTML view" };
35854
35719
  return { icon: /* @__PURE__ */ jsx(ParagraphIcon, {}) };
35855
35720
  }
35856
35721
  class SlashMenuOption extends MenuOption {
@@ -35896,6 +35761,9 @@ function SlashMenuItem({
35896
35761
  }
35897
35762
  function SlashCommandPlugin() {
35898
35763
  const [editor] = useLexicalComposerContext();
35764
+ const { toolbarState, updateToolbarState } = useToolbarState();
35765
+ const { isHtmlView, setIsHtmlView } = useHtmlView();
35766
+ const { apiKey } = useEditor();
35899
35767
  const [queryString, setQueryString] = useState$1(null);
35900
35768
  const [searchQuery, setSearchQuery] = useState$1("");
35901
35769
  const searchInputRef = useRef(null);
@@ -35904,6 +35772,8 @@ function SlashCommandPlugin() {
35904
35772
  const anchorRef = useRef(null);
35905
35773
  const [isMenuOpen, setIsMenuOpen] = useState$1(false);
35906
35774
  const [showImageDialog, setShowImageDialog] = useState$1(false);
35775
+ const [showSignatureDialog, setShowSignatureDialog] = useState$1(false);
35776
+ const [showChartDialog, setShowChartDialog] = useState$1(false);
35907
35777
  const triggerFn = useBasicTypeaheadTriggerMatch("/", { minLength: 0 });
35908
35778
  useEffect$1(() => {
35909
35779
  if (!isMenuOpen) {
@@ -35980,6 +35850,30 @@ function SlashCommandPlugin() {
35980
35850
  const insertTable = useCallback(() => {
35981
35851
  editor.dispatchCommand(CREATE_TABLE_COMMAND, void 0);
35982
35852
  }, [editor]);
35853
+ const insertHorizontalRule = useCallback(() => {
35854
+ editor.dispatchCommand(INSERT_CUSTOM_HORIZONTAL_RULE_COMMAND, {
35855
+ color: "#e5e7eb",
35856
+ strokeWidth: 1
35857
+ });
35858
+ }, [editor]);
35859
+ const insertSignature = useCallback(() => {
35860
+ setShowSignatureDialog(true);
35861
+ }, []);
35862
+ const insertInfoPanel = useCallback(() => {
35863
+ editor.dispatchCommand(INSERT_NOTE_PANEL_COMMAND, { type: "info" });
35864
+ }, [editor]);
35865
+ const insertWarningPanel = useCallback(() => {
35866
+ editor.dispatchCommand(INSERT_NOTE_PANEL_COMMAND, { type: "warning" });
35867
+ }, [editor]);
35868
+ const insertErrorPanel = useCallback(() => {
35869
+ editor.dispatchCommand(INSERT_NOTE_PANEL_COMMAND, { type: "error" });
35870
+ }, [editor]);
35871
+ const insertSuccessPanel = useCallback(() => {
35872
+ editor.dispatchCommand(INSERT_NOTE_PANEL_COMMAND, { type: "success" });
35873
+ }, [editor]);
35874
+ const alignJustify = useCallback(() => {
35875
+ editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "justify");
35876
+ }, [editor]);
35983
35877
  const formatBold = useCallback(() => {
35984
35878
  editor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold");
35985
35879
  }, [editor]);
@@ -35998,40 +35892,47 @@ function SlashCommandPlugin() {
35998
35892
  const formatSuperscript = useCallback(() => {
35999
35893
  editor.dispatchCommand(FORMAT_TEXT_COMMAND, "superscript");
36000
35894
  }, [editor]);
36001
- const alignJustify = useCallback(() => {
36002
- editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, "justify");
36003
- }, [editor]);
36004
35895
  const undo = useCallback(() => {
36005
35896
  editor.dispatchCommand(UNDO_COMMAND, void 0);
36006
35897
  }, [editor]);
36007
35898
  const redo = useCallback(() => {
36008
35899
  editor.dispatchCommand(REDO_COMMAND, void 0);
36009
35900
  }, [editor]);
36010
- const { clearFormatting } = useEditorToolbar();
36011
- const { clearEditorContent } = useCustomCommands();
36012
- const handleClearFormatting = useCallback(() => {
36013
- clearFormatting();
36014
- toast.success("Formatting cleared");
36015
- }, [clearFormatting]);
36016
- const handleClearContent = useCallback(() => {
36017
- toast.warning("Clear editor content?", {
36018
- description: "This will remove all content.",
36019
- action: {
36020
- label: "OK",
36021
- onClick: () => {
36022
- clearEditorContent();
36023
- toast.success("Editor cleared");
36024
- }
36025
- },
36026
- duration: 8e3
36027
- });
36028
- }, [clearEditorContent]);
36029
- const addComment = useCallback(() => {
36030
- editor.dispatchCommand(OPEN_COMMENT_MODAL_COMMAND, void 0);
36031
- }, [editor]);
36032
35901
  const openAIChat = useCallback(() => {
36033
35902
  editor.dispatchCommand(TOGGLE_AI_CHAT_COMMAND, void 0);
36034
35903
  }, [editor]);
35904
+ const insertChart = useCallback(() => {
35905
+ setShowChartDialog(true);
35906
+ }, []);
35907
+ const handleChartInsert = useCallback(
35908
+ async (metadata) => {
35909
+ const result = await generateChartWithToast(metadata, apiKey);
35910
+ if (result.success) {
35911
+ editor.update(() => {
35912
+ const chartNode = $createChartNode(result.html, metadata);
35913
+ const selection = $getSelection();
35914
+ if (!selection) {
35915
+ const root2 = $getRoot();
35916
+ root2.append(chartNode);
35917
+ } else {
35918
+ $insertNodes([chartNode]);
35919
+ }
35920
+ const paragraphNode = $createParagraphNode();
35921
+ chartNode.insertAfter(paragraphNode);
35922
+ });
35923
+ }
35924
+ },
35925
+ [editor, apiKey]
35926
+ );
35927
+ const toggleAutocomplete = useCallback(() => {
35928
+ updateToolbarState("isAutocompleteEnabled", !toolbarState.isAutocompleteEnabled);
35929
+ toast.success(
35930
+ toolbarState.isAutocompleteEnabled ? "Autocomplete & Grammar disabled" : "Autocomplete & Grammar enabled"
35931
+ );
35932
+ }, [toolbarState.isAutocompleteEnabled, updateToolbarState]);
35933
+ const switchToHtmlView = useCallback(() => {
35934
+ setIsHtmlView(!isHtmlView);
35935
+ }, [isHtmlView, setIsHtmlView]);
36035
35936
  const baseOptions = useMemo(() => {
36036
35937
  return [
36037
35938
  // Block types
@@ -36046,6 +35947,7 @@ function SlashCommandPlugin() {
36046
35947
  new SlashMenuOption("Heading 6", () => insertHeading("h6")),
36047
35948
  new SlashMenuOption("Quote", insertQuote),
36048
35949
  new SlashMenuOption("Code block", insertCodeBlock),
35950
+ new SlashMenuOption("Horizontal line", insertHorizontalRule),
36049
35951
  // Lists
36050
35952
  new SlashMenuOption("__label__LISTS", () => {
36051
35953
  }),
@@ -36058,6 +35960,22 @@ function SlashCommandPlugin() {
36058
35960
  new SlashMenuOption("Image", insertImage),
36059
35961
  new SlashMenuOption("Video", insertVideo),
36060
35962
  new SlashMenuOption("Table", insertTable),
35963
+ new SlashMenuOption("Chart", insertChart),
35964
+ new SlashMenuOption("Signature", insertSignature),
35965
+ // Note Panels
35966
+ new SlashMenuOption("__label__PANELS", () => {
35967
+ }),
35968
+ new SlashMenuOption("Info panel", insertInfoPanel),
35969
+ new SlashMenuOption("Warning panel", insertWarningPanel),
35970
+ new SlashMenuOption("Error panel", insertErrorPanel),
35971
+ new SlashMenuOption("Success panel", insertSuccessPanel),
35972
+ // Alignment
35973
+ new SlashMenuOption("__label__ALIGN", () => {
35974
+ }),
35975
+ new SlashMenuOption("Align left", () => align("left")),
35976
+ new SlashMenuOption("Align center", () => align("center")),
35977
+ new SlashMenuOption("Align right", () => align("right")),
35978
+ new SlashMenuOption("Justify", alignJustify),
36061
35979
  // Text formatting
36062
35980
  new SlashMenuOption("__label__FORMAT", () => {
36063
35981
  }),
@@ -36067,52 +35985,52 @@ function SlashCommandPlugin() {
36067
35985
  new SlashMenuOption("Strikethrough", formatStrikethrough),
36068
35986
  new SlashMenuOption("Subscript", formatSubscript),
36069
35987
  new SlashMenuOption("Superscript", formatSuperscript),
36070
- // Alignment
36071
- new SlashMenuOption("__label__ALIGN", () => {
36072
- }),
36073
- new SlashMenuOption("Align left", () => align("left")),
36074
- new SlashMenuOption("Align center", () => align("center")),
36075
- new SlashMenuOption("Align right", () => align("right")),
36076
- new SlashMenuOption("Justify", alignJustify),
36077
35988
  // Actions
36078
35989
  new SlashMenuOption("__label__ACTIONS", () => {
36079
35990
  }),
36080
35991
  new SlashMenuOption("Undo", undo),
36081
35992
  new SlashMenuOption("Redo", redo),
36082
- new SlashMenuOption("Clear formatting", handleClearFormatting),
36083
- new SlashMenuOption("Clear content", handleClearContent),
36084
- new SlashMenuOption("Add comment", addComment),
36085
35993
  // AI features
36086
35994
  new SlashMenuOption("__label__AI", () => {
36087
35995
  }),
36088
- new SlashMenuOption("AI Chat", openAIChat)
36089
- // new SlashMenuOption("AI Generate image", aiGenerateImage),
35996
+ new SlashMenuOption("AI Chat", openAIChat),
35997
+ // Tools
35998
+ new SlashMenuOption("__label__TOOLS", () => {
35999
+ }),
36000
+ new SlashMenuOption("Toggle Autocomplete", toggleAutocomplete),
36001
+ new SlashMenuOption("Switch to HTML View", switchToHtmlView)
36090
36002
  ];
36091
36003
  }, [
36092
36004
  insertParagraph,
36093
36005
  insertHeading,
36094
36006
  insertQuote,
36095
36007
  insertCodeBlock,
36008
+ insertHorizontalRule,
36096
36009
  toggleBullet,
36097
36010
  toggleNumber,
36098
36011
  toggleTodo,
36099
36012
  insertImage,
36100
36013
  insertVideo,
36101
36014
  insertTable,
36015
+ insertChart,
36016
+ insertSignature,
36017
+ insertInfoPanel,
36018
+ insertWarningPanel,
36019
+ insertErrorPanel,
36020
+ insertSuccessPanel,
36021
+ align,
36022
+ alignJustify,
36102
36023
  formatBold,
36103
36024
  formatItalic,
36104
36025
  formatUnderline,
36105
36026
  formatStrikethrough,
36106
36027
  formatSubscript,
36107
36028
  formatSuperscript,
36108
- align,
36109
- alignJustify,
36110
36029
  undo,
36111
36030
  redo,
36112
- handleClearFormatting,
36113
- handleClearContent,
36114
- addComment,
36115
- openAIChat
36031
+ openAIChat,
36032
+ toggleAutocomplete,
36033
+ switchToHtmlView
36116
36034
  ]);
36117
36035
  const options = useMemo(() => {
36118
36036
  const query = searchQuery || queryString || "";
@@ -36275,6 +36193,20 @@ function SlashCommandPlugin() {
36275
36193
  activeEditor: editor,
36276
36194
  onClose: () => setShowImageDialog(false)
36277
36195
  }
36196
+ ),
36197
+ showSignatureDialog && /* @__PURE__ */ jsx(
36198
+ SignatureCanvasDialog,
36199
+ {
36200
+ onClose: () => setShowSignatureDialog(false)
36201
+ }
36202
+ ),
36203
+ /* @__PURE__ */ jsx(
36204
+ ChartInsertDialog,
36205
+ {
36206
+ open: showChartDialog,
36207
+ onOpenChange: setShowChartDialog,
36208
+ onInsert: handleChartInsert
36209
+ }
36278
36210
  )
36279
36211
  ] });
36280
36212
  }
@@ -37096,7 +37028,15 @@ function TableActionMenu({
37096
37028
  }
37097
37029
  if (newHeaderCell.getChildrenSize() === 0) {
37098
37030
  const paragraph = $createParagraphNode();
37031
+ const textNode = $createTextNode("​");
37032
+ paragraph.append(textNode);
37099
37033
  newHeaderCell.append(paragraph);
37034
+ } else {
37035
+ const firstChild = newHeaderCell.getFirstChild();
37036
+ if ($isParagraphNode(firstChild) && firstChild.getTextContentSize() === 0) {
37037
+ const textNode = $createTextNode("​");
37038
+ firstChild.append(textNode);
37039
+ }
37100
37040
  }
37101
37041
  }
37102
37042
  }
@@ -37432,7 +37372,7 @@ function TableActionMenu({
37432
37372
  /* @__PURE__ */ jsxs(
37433
37373
  "div",
37434
37374
  {
37435
- className: "dropdown table-drop cteditor-z-[100]\n cteditor-flex\n cteditor-flex-col\n cteditor-fixed\n cteditor-min-h-[40px]\n cteditor-min-w-[200px]\n cteditor-p-[6px]\n cteditor-overflow-y-auto\n cteditor-overflow-x-hidden \n cteditor-shadow-xl\n cteditor-rounded-lg\n cteditor-border\n cteditor-border-border\n cteditor-bg-background \n cteditor-backdrop-blur-md\n cteditor-space-y-0.5\n ",
37375
+ className: "dropdown table-drop cteditor-z-[100]\r\n cteditor-flex\r\n cteditor-flex-col\r\n cteditor-fixed\r\n cteditor-min-h-[40px]\r\n cteditor-min-w-[200px]\r\n cteditor-p-[6px]\r\n cteditor-overflow-y-auto\r\n cteditor-overflow-x-hidden \r\n cteditor-shadow-xl\r\n cteditor-rounded-lg\r\n cteditor-border\r\n cteditor-border-border\r\n cteditor-bg-background \r\n cteditor-backdrop-blur-md\r\n cteditor-space-y-0.5\r\n ",
37436
37376
  ref: dropDownRef,
37437
37377
  onClick: (e) => {
37438
37378
  e.stopPropagation();
@@ -38736,7 +38676,15 @@ function TableHoverActionsContainer({
38736
38676
  }
38737
38677
  if (newHeaderCell.getChildrenSize() === 0) {
38738
38678
  const paragraph = $createParagraphNode();
38679
+ const textNode = $createTextNode("​");
38680
+ paragraph.append(textNode);
38739
38681
  newHeaderCell.append(paragraph);
38682
+ } else {
38683
+ const firstChild = newHeaderCell.getFirstChild();
38684
+ if ($isParagraphNode(firstChild) && firstChild.getTextContentSize() === 0) {
38685
+ const textNode = $createTextNode("​");
38686
+ firstChild.append(textNode);
38687
+ }
38740
38688
  }
38741
38689
  }
38742
38690
  }
@@ -39856,47 +39804,6 @@ const WordCountPlugin = () => {
39856
39804
  ] })
39857
39805
  ] });
39858
39806
  };
39859
- const NORMALIZED_CODE_BLOCK_COLORS = {
39860
- // Dark neutral background - works on both light and dark pages
39861
- backgroundColor: "#2d2d2d",
39862
- // Light text for readability on dark background
39863
- textColor: "#f8f8f2",
39864
- // Slightly lighter gutter background
39865
- gutterBackgroundColor: "#252525",
39866
- gutterTextColor: "#8c8c8c",
39867
- // Syntax highlighting token colors (inspired by popular dark themes like Monokai/One Dark)
39868
- tokenColors: {
39869
- comment: "#6a9955",
39870
- // Green for comments
39871
- punctuation: "#d4d4d4",
39872
- // Light gray for punctuation
39873
- property: "#e06c75",
39874
- // Red/pink for properties, numbers, tags
39875
- selector: "#98c379",
39876
- // Green for strings, selectors
39877
- operator: "#d19a66",
39878
- // Orange for operators
39879
- attr: "#61afef",
39880
- // Blue for keywords, attributes
39881
- variable: "#e5c07b",
39882
- // Yellow for variables, regex
39883
- function: "#c678dd"
39884
- // Purple for functions, class names
39885
- }
39886
- };
39887
- function getNormalizedTokenColor(tokenClass) {
39888
- const classToColor = {
39889
- "PlaygroundEditorTheme__tokenComment": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.comment,
39890
- "PlaygroundEditorTheme__tokenPunctuation": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.punctuation,
39891
- "PlaygroundEditorTheme__tokenProperty": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.property,
39892
- "PlaygroundEditorTheme__tokenSelector": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.selector,
39893
- "PlaygroundEditorTheme__tokenOperator": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.operator,
39894
- "PlaygroundEditorTheme__tokenAttr": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.attr,
39895
- "PlaygroundEditorTheme__tokenVariable": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.variable,
39896
- "PlaygroundEditorTheme__tokenFunction": NORMALIZED_CODE_BLOCK_COLORS.tokenColors.function
39897
- };
39898
- return classToColor[tokenClass] || NORMALIZED_CODE_BLOCK_COLORS.textColor;
39899
- }
39900
39807
  function exportEditorWithInlineStyle(editor) {
39901
39808
  const rootElement = editor.getRootElement();
39902
39809
  if (!rootElement)
@@ -40105,7 +40012,7 @@ function processHtmlForExport(html, tableStyleMap, codeBlockStyles) {
40105
40012
  });
40106
40013
  });
40107
40014
  cleanupHeaderCellStructure(doc.body);
40108
- applyCodeSyntaxHighlighting(doc.body);
40015
+ applyCodeSyntaxHighlighting(doc.body, codeBlockStyles);
40109
40016
  processCodeBlocks(doc.body, codeBlockStyles);
40110
40017
  applyGenericSafeStyles(doc.body, codeBlockStyles);
40111
40018
  cleanupClasses(doc.body);
@@ -40286,10 +40193,12 @@ function applyGenericSafeStyles(container, codeBlockStyles) {
40286
40193
  addStyle("ul, ol", "margin: 1em 0; padding-left: 40px;");
40287
40194
  addStyle("li", "margin: 0.5em 0;");
40288
40195
  addStyle("a", "color: #0066cc; text-decoration: underline;");
40196
+ const codeBlockBg = codeBlockStyles.backgroundColor || "#f5f5f5";
40197
+ const codeBlockText = codeBlockStyles.textColor || "#333";
40289
40198
  const codeBlockFont = codeBlockStyles.fontFamily || "Menlo, Consolas, Monaco, monospace";
40290
40199
  addStyle(
40291
40200
  "code:not(.code-line-numbers):not(.code-content):not([data-language]):not([data-highlight-language])",
40292
- `font-family: ${codeBlockFont}; background-color: ${NORMALIZED_CODE_BLOCK_COLORS.backgroundColor}; color: ${NORMALIZED_CODE_BLOCK_COLORS.textColor}; padding: 2px 6px; border-radius: 3px;`
40201
+ `font-family: ${codeBlockFont}; background-color: ${codeBlockBg}; color: ${codeBlockText}; padding: 2px 4px; border-radius: 3px;`
40293
40202
  );
40294
40203
  addStyle(
40295
40204
  "blockquote",
@@ -40301,18 +40210,15 @@ function applyGenericSafeStyles(container, codeBlockStyles) {
40301
40210
  }
40302
40211
  function applyCodeSyntaxHighlighting(container, codeBlockStyles) {
40303
40212
  const codeBlocks = container.querySelectorAll('code, pre[data-language], pre[data-highlight-language], pre[spellcheck="false"]');
40304
- codeBlocks.forEach((codeBlock) => {
40213
+ codeBlocks.forEach((codeBlock, codeBlockIndex) => {
40214
+ const capturedSpanColors = codeBlockStyles.spanColors.get(codeBlockIndex) || [];
40305
40215
  const spans = codeBlock.querySelectorAll("span");
40306
- spans.forEach((span) => {
40216
+ spans.forEach((span, spanIndex) => {
40307
40217
  const htmlSpan = span;
40308
- const classList = Array.from(htmlSpan.classList);
40309
- for (const className of classList) {
40310
- if (className.startsWith("PlaygroundEditorTheme__token")) {
40311
- const normalizedColor = getNormalizedTokenColor(className);
40312
- if (normalizedColor !== NORMALIZED_CODE_BLOCK_COLORS.textColor) {
40313
- htmlSpan.style.color = normalizedColor;
40314
- }
40315
- break;
40218
+ if (spanIndex < capturedSpanColors.length) {
40219
+ const { color } = capturedSpanColors[spanIndex];
40220
+ if (color && color !== codeBlockStyles.textColor) {
40221
+ htmlSpan.style.color = color;
40316
40222
  }
40317
40223
  }
40318
40224
  });
@@ -40348,8 +40254,8 @@ function processCodeBlocks(container, codeBlockStyles) {
40348
40254
  const fontFamily = codeBlockStyles.fontFamily || "Menlo, Consolas, Monaco, monospace";
40349
40255
  const fontSize = codeBlockStyles.fontSize || "13px";
40350
40256
  const lineHeight = codeBlockStyles.lineHeight || "1.53";
40351
- const gutterBg = NORMALIZED_CODE_BLOCK_COLORS.gutterBackgroundColor;
40352
- const gutterColor = NORMALIZED_CODE_BLOCK_COLORS.gutterTextColor;
40257
+ const gutterBg = codeBlockStyles.gutterBackgroundColor || "rgba(0, 0, 0, 0.1)";
40258
+ const gutterColor = codeBlockStyles.gutterTextColor || "rgba(0, 0, 0, 0.5)";
40353
40259
  gutter.style.cssText = [
40354
40260
  "display: table-cell",
40355
40261
  "vertical-align: top",
@@ -40362,7 +40268,7 @@ function processCodeBlocks(container, codeBlockStyles) {
40362
40268
  `font-family: ${fontFamily}`,
40363
40269
  `font-size: ${fontSize}`,
40364
40270
  `line-height: ${lineHeight}`,
40365
- "border-right: 1px solid #404040",
40271
+ "border-right: 1px solid rgba(128, 128, 128, 0.3)",
40366
40272
  "border-top-left-radius: 5px",
40367
40273
  "border-bottom-left-radius: 5px",
40368
40274
  "user-select: none",
@@ -40385,8 +40291,8 @@ function processCodeBlocks(container, codeBlockStyles) {
40385
40291
  while (htmlCodeBlock.firstChild) {
40386
40292
  codeContent.appendChild(htmlCodeBlock.firstChild);
40387
40293
  }
40388
- const codeBlockBg = NORMALIZED_CODE_BLOCK_COLORS.backgroundColor;
40389
- const codeBlockText = NORMALIZED_CODE_BLOCK_COLORS.textColor;
40294
+ const codeBlockBg = codeBlockStyles.backgroundColor || "#f5f5f5";
40295
+ const codeBlockText = codeBlockStyles.textColor || "#333";
40390
40296
  htmlCodeBlock.style.cssText = [
40391
40297
  "display: table",
40392
40298
  "table-layout: fixed",
@@ -41359,7 +41265,7 @@ const ConfigurableEditor = ({
41359
41265
  /* @__PURE__ */ jsx(LocalStoragePlugin$1, { namespace: initialConfig.namespace }),
41360
41266
  /* @__PURE__ */ jsx(ListPlugin, {}),
41361
41267
  /* @__PURE__ */ jsx(LinkPlugin, { hasLinkAttributes: false }),
41362
- /* @__PURE__ */ jsx(LinkPreviewPlugin, {}),
41268
+ /* @__PURE__ */ jsx(LinkPreviewPlugin, { apiKey }),
41363
41269
  /* @__PURE__ */ jsx(DragDropPaste, {}),
41364
41270
  /* @__PURE__ */ jsx(RichTextPastePlugin, {}),
41365
41271
  /* @__PURE__ */ jsx(PasteOptionsPlugin, {}),
@@ -41407,12 +41313,6 @@ const ConfigurableEditor = ({
41407
41313
  setIsLinkEditMode,
41408
41314
  features: config.floatingMenuOptions
41409
41315
  }
41410
- ),
41411
- /* @__PURE__ */ jsx(
41412
- FloatingEnhanceButtonPlugin,
41413
- {
41414
- anchorElem: floatingAnchorElem
41415
- }
41416
41316
  )
41417
41317
  ] })
41418
41318
  ] }) }),
@@ -41478,7 +41378,11 @@ const ConfigurableEditorWithAuth = ({
41478
41378
  onEditorReady,
41479
41379
  onFocus,
41480
41380
  onBlur,
41481
- onHeightChange
41381
+ onHeightChange,
41382
+ mode = "edit",
41383
+ previewClassName = "",
41384
+ previewStyle,
41385
+ onPreviewClick
41482
41386
  }) => {
41483
41387
  const { isAuthenticated, isLoading, error, editorConfig: editorConfig2, currentUser, verifyKey } = useEditor();
41484
41388
  const successRef = useRef(onAuthSuccess);
@@ -41560,6 +41464,19 @@ const ConfigurableEditorWithAuth = ({
41560
41464
  if (!isAuthenticated || !editorConfig2) {
41561
41465
  return /* @__PURE__ */ jsx(ScopedEditorWrapper, { children: /* @__PURE__ */ jsx(AuthMessage, { children: /* @__PURE__ */ jsx("span", { children: "Please provide a valid API key to access the editor" }) }) });
41562
41466
  }
41467
+ if (mode === "preview") {
41468
+ return /* @__PURE__ */ jsx(ScopedEditorWrapper, { children: /* @__PURE__ */ jsx(
41469
+ "div",
41470
+ {
41471
+ className: previewClassName,
41472
+ style: previewStyle,
41473
+ onClick: onPreviewClick,
41474
+ dangerouslySetInnerHTML: {
41475
+ __html: initialContent || ""
41476
+ }
41477
+ }
41478
+ ) });
41479
+ }
41563
41480
  return /* @__PURE__ */ jsx(ScopedEditorWrapper, { children: /* @__PURE__ */ jsx(
41564
41481
  ConfigurableEditor,
41565
41482
  {
@@ -41576,6 +41493,25 @@ const ConfigurableEditorWithAuth = ({
41576
41493
  }
41577
41494
  ) });
41578
41495
  };
41496
+ function ContentPreview({
41497
+ content,
41498
+ className = "",
41499
+ style,
41500
+ onClick
41501
+ }) {
41502
+ const defaultContent = "<p class='text-muted-foreground italic'>No content</p>";
41503
+ return /* @__PURE__ */ jsx(
41504
+ "div",
41505
+ {
41506
+ className,
41507
+ style,
41508
+ onClick,
41509
+ dangerouslySetInnerHTML: {
41510
+ __html: content || defaultContent
41511
+ }
41512
+ }
41513
+ );
41514
+ }
41579
41515
  export {
41580
41516
  $isFileNode as $,
41581
41517
  AlignLeft as A,
@@ -41606,11 +41542,13 @@ export {
41606
41542
  EditorProvider as p,
41607
41543
  useEditor as q,
41608
41544
  ConfigurableEditor as r,
41609
- isReactNativeWebView as s,
41545
+ LinkPreviewHover as s,
41610
41546
  toast as t,
41611
41547
  useHtmlView as u,
41612
41548
  verifyApiKey as v,
41613
- useReactNativeBridge as w,
41614
- editorConfig as x
41549
+ ContentPreview as w,
41550
+ isReactNativeWebView as x,
41551
+ useReactNativeBridge as y,
41552
+ editorConfig as z
41615
41553
  };
41616
- //# sourceMappingURL=index-6717344b.js.map
41554
+ //# sourceMappingURL=index-0bc350db.js.map