@brainfish-ai/components 0.23.11 → 0.23.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,21 +1,26 @@
1
1
  import './global.css';/* empty css */
2
2
  export { BrainfishColors } from './colors.js';
3
3
  export { C as ChatSearch, a as ChatSearchProvider, u as useChatSearch, b as useIsChatSearchDirty } from './chunks/ChatSearch.CVOKmj3k.js';
4
- export { C as CodeBlock, F as FormattedMessage, M as MemoizedReactMarkdown, Z as ZoomableImage, a as addPopupWidgetUtm, b as addUtmParameters } from './chunks/FormattedMessage.Br7XTLD2.js';
4
+ import { F as FormattedMessage } from './chunks/FormattedMessage.Br7XTLD2.js';
5
+ export { C as CodeBlock, M as MemoizedReactMarkdown, Z as ZoomableImage, a as addPopupWidgetUtm, b as addUtmParameters } from './chunks/FormattedMessage.Br7XTLD2.js';
5
6
  export { MermaidDiagram } from './chunks/MermaidDiagram.xQ0CVFOI.js';
6
7
  export { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage } from './components/ui/avatar.js';
7
8
  import { Button } from './components/ui/button.js';
8
9
  export { buttonVariants } from './components/ui/button.js';
9
10
  export { Collapsible, CollapsibleContent, CollapsibleTrigger } from './components/ui/collapsible.js';
10
- export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from './components/ui/dropdown-menu.js';
11
+ import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './components/ui/dropdown-menu.js';
12
+ export { DropdownMenuCheckboxItem, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger } from './components/ui/dropdown-menu.js';
11
13
  export { Switch } from './components/ui/switch.js';
12
- export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './components/ui/tooltip.js';
14
+ import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from './components/ui/tooltip.js';
13
15
  import { Textarea } from './components/ui/textarea.js';
14
- export { ScrollArea, ScrollBar } from './components/ui/scroll-area.js';
16
+ import { ScrollArea } from './components/ui/scroll-area.js';
17
+ export { ScrollBar } from './components/ui/scroll-area.js';
15
18
  export { Label } from './components/ui/label.js';
16
19
  export { Input } from './components/ui/input.js';
17
- export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from './components/ui/popover.js';
18
- export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from './components/ui/command.js';
20
+ import { Popover, PopoverTrigger, PopoverContent } from './components/ui/popover.js';
21
+ export { PopoverAnchor } from './components/ui/popover.js';
22
+ import { Command, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem } from './components/ui/command.js';
23
+ export { CommandDialog, CommandSeparator, CommandShortcut } from './components/ui/command.js';
19
24
  export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from './components/ui/dialog.js';
20
25
  export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './components/ui/card.js';
21
26
  export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from './components/ui/table.js';
@@ -40,17 +45,830 @@ export { T as TwoLevelCombobox } from './chunks/two-level-combobox.DsWPDcI6.js';
40
45
  export { F as Filter, a as Filters, O as Operator } from './chunks/filters.Be4KPvMA.js';
41
46
  export { F as FileUpload, a as FileUploadStatus, f as formatFileSize } from './chunks/file-upload-status.Vw0Zxmir.js';
42
47
  export { D as DataTable } from './chunks/data-table.DbcAYxMY.js';
43
- export { L as Logo } from './chunks/logo.BXk28Fqo.js';
48
+ import { L as Logo } from './chunks/logo.BXk28Fqo.js';
44
49
  export { T as Trend, a as TrendValue } from './chunks/trend-value.COSukPwk.js';
45
50
  export { F as FontPicker, a as FontPickerItem, c as clearFontCache, g as getCachedFonts, l as loadFont, s as setCachedFonts, u as useFontOptions } from './chunks/font-picker.DX1mER3H.js';
46
51
  export { H as HEADER_NAV_HEIGHT, a as HeaderNav } from './chunks/header-nav.CCJ9OYeY.js';
47
- export { S as Sidebar, u as useSidebar } from './chunks/sidebar.rkD1Uw3Z.js';
48
- export { F as FullLayout, a as FullLayoutLeftSidebar, b as FullLayoutNavStateContext, c as FullLayoutProvider, d as FullLayoutRightSidebar, u as useFullLayoutContext, e as useRightSidebar } from './chunks/layout.DQxWg92F.js';
52
+ export { S as Sidebar, u as useSidebar } from './chunks/sidebar.BFzx4WQ0.js';
53
+ export { F as FullLayout, a as FullLayoutLeftSidebar, b as FullLayoutNavStateContext, c as FullLayoutProvider, d as FullLayoutRightSidebar, u as useFullLayoutContext, e as useRightSidebar } from './chunks/layout.DxPhNLks.js';
49
54
  import * as React from 'react';
50
- import React__default from 'react';
55
+ import React__default, { useMemo, useContext, createContext, useCallback, useRef, useEffect, useLayoutEffect, useState, Suspense, forwardRef, Component, createElement, useImperativeHandle } from 'react';
56
+ import { Sparkle, ThumbsUp, ThumbsDown, Copy, DotsThreeVertical, X as X$1, Plus, CaretRight, Stop, ArrowUp } from '@phosphor-icons/react';
51
57
  import { c as cn } from './chunks/utils.Cwtlq8dh.js';
52
- import { Plus } from '@phosphor-icons/react';
53
- export { R as ReviewList, a as ReviewListItem, b as ReviewsSelectionProvider, u as useReviewsSelection } from './chunks/review-list.BJ-4eNKh.js';
58
+ import { createEditor, $getRoot, $createParagraphNode, $getSelection, HISTORY_MERGE_TAG, $caretFromPoint, $isExtendableTextPointCaret, $extendCaretToRange, $isChildCaret, $isElementNode, $isDecoratorNode, $isRootNode, $getEditor, $isTokenOrSegmented, $getCharacterOffsets, $cloneWithPropertiesEphemeral, $isRangeSelection, $findMatchingParent, mergeRegister, DecoratorNode, addClassNamesToElement, shallowMergeConfig, $create, defineExtension, safeCast, createState, FORMAT_TEXT_COMMAND, $isNodeSelection, COMMAND_PRIORITY_LOW, RootNode, TextNode, LineBreakNode, TabNode, ParagraphNode, $isEditorState, createCommand, CLICK_COMMAND, isDOMNode, $getNodeFromDOMNode, $createNodeSelection, $setSelection, $getState, toggleTextFormatType, TEXT_TYPE_TO_FORMAT, $setState, $getNodeByKey, removeClassNamesFromElement, CLEAR_EDITOR_COMMAND, COMMAND_PRIORITY_EDITOR, KEY_TAB_COMMAND, $isBlockElementNode, $createRangeSelection, $normalizeSelection__EXPERIMENTAL, OUTDENT_CONTENT_COMMAND, INDENT_CONTENT_COMMAND, INSERT_TAB_COMMAND, COMMAND_PRIORITY_CRITICAL, $isParagraphNode, $isTextNode, isDOMDocumentNode, ArtificialNode__DO_NOT_USE, $createLineBreakNode, $isRootOrShadowRoot, isBlockDomNode, isInlineDomNode, getRegisteredNode, isHTMLElement, isDocumentFragment, $createTabNode, getDOMSelection, COPY_COMMAND, SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, $isTextPointCaret, $getCaretRange, $getChildCaret, $parseSerializedNode, isSelectionWithinEditor, DELETE_CHARACTER_COMMAND, DELETE_WORD_COMMAND, DELETE_LINE_COMMAND, CONTROLLED_TEXT_INSERTION_COMMAND, REMOVE_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, $insertNodes, KEY_ARROW_UP_COMMAND, $getAdjacentNode, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, DROP_COMMAND, $getNearestNodeFromDOMNode, DRAGSTART_COMMAND, DRAGOVER_COMMAND, SELECT_ALL_COMMAND, $selectAll, CUT_COMMAND, PASTE_COMMAND, isSelectionCapturedInDecoratorInput, PASTE_TAG, KEY_SPACE_COMMAND, ElementNode, setNodeIndentFromDOM, $applyNodeReplacement, COMMAND_PRIORITY_HIGH } from 'lexical';
59
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
60
+ import { flushSync, createPortal } from 'react-dom';
61
+ import { createEmptyHistoryState, registerHistory } from '@lexical/history';
62
+ import { ListNode, ListItemNode, registerList, registerListStrictIndentTransform, $isListItemNode } from '@lexical/list';
63
+ import { LinkNode, registerLink, AutoLinkNode } from '@lexical/link';
64
+ import { registerMarkdownShortcuts, TRANSFORMERS, ORDERED_LIST, UNORDERED_LIST, LINK, INLINE_CODE, CODE, $convertToMarkdownString, $convertFromMarkdownString } from '@lexical/markdown';
65
+ import { CodeNode, CodeHighlightNode, $isCodeNode } from '@lexical/code';
66
+ export { a as ReviewList, b as ReviewListItem, R as ReviewsSelectionProvider, u as useReviewsSelection } from './chunks/review-list.Bn2wFxYA.js';
67
+
68
+ const ConversationContext = createContext(null);
69
+ function useConversation() {
70
+ const ctx = useContext(ConversationContext);
71
+ if (!ctx) {
72
+ throw new Error("useConversation must be used within a <Conversation> provider");
73
+ }
74
+ return ctx;
75
+ }
76
+ function ConversationProvider({ messages, callbacks, children }) {
77
+ const isStreaming = messages.some((m) => m.status === "streaming");
78
+ const value = useMemo(() => ({ messages, callbacks, isStreaming }), [messages, callbacks, isStreaming]);
79
+ return /* @__PURE__ */ React__default.createElement(ConversationContext.Provider, { value }, children);
80
+ }
81
+
82
+ const TextBlock = ({ part, isStreaming }) => {
83
+ return /* @__PURE__ */ React__default.createElement(FormattedMessage, { message: { content: part.text }, isStreaming });
84
+ };
85
+
86
+ const CitationBlock = ({ part, onCitationClick }) => {
87
+ return /* @__PURE__ */ React__default.createElement("span", { className: "inline-flex flex-wrap gap-1" }, part.citations.map((citation) => /* @__PURE__ */ React__default.createElement(CitationBadge, { key: citation.id, citation, onClick: onCitationClick })));
88
+ };
89
+ const CitationBadge = ({ citation, onClick }) => {
90
+ return /* @__PURE__ */ React__default.createElement(Tooltip, null, /* @__PURE__ */ React__default.createElement(TooltipTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
91
+ "button",
92
+ {
93
+ type: "button",
94
+ className: "inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary hover:bg-primary/20 transition-colors",
95
+ onClick: () => onClick?.(citation)
96
+ },
97
+ citation.index
98
+ )), /* @__PURE__ */ React__default.createElement(TooltipContent, { side: "top", className: "max-w-xs" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-sm font-medium" }, citation.title), /* @__PURE__ */ React__default.createElement("p", { className: "text-xs text-muted-foreground truncate" }, citation.url)));
99
+ };
100
+
101
+ const ImageBlock = ({ part }) => {
102
+ return /* @__PURE__ */ React__default.createElement("div", { className: "my-2" }, /* @__PURE__ */ React__default.createElement("img", { src: part.url, alt: part.alt ?? "", className: "max-w-full rounded-lg", loading: "lazy" }));
103
+ };
104
+
105
+ const ToolCallBlock = ({ part }) => {
106
+ return /* @__PURE__ */ React__default.createElement("div", { className: "my-2 rounded-lg border border-border bg-muted/50 p-3 text-sm" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React__default.createElement("span", { className: "font-medium" }, part.toolName), /* @__PURE__ */ React__default.createElement("span", { className: "text-xs text-muted-foreground capitalize" }, "(", part.status, ")")), part.result && /* @__PURE__ */ React__default.createElement("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground" }, part.result));
107
+ };
108
+
109
+ const ThinkingBlock = ({ part }) => {
110
+ return /* @__PURE__ */ React__default.createElement("div", { className: "my-2 rounded-lg border border-dashed border-border bg-muted/30 p-3 text-sm italic text-muted-foreground" }, part.text);
111
+ };
112
+
113
+ const BlockRenderer = ({ part, isStreaming, onCitationClick }) => {
114
+ switch (part.type) {
115
+ case "text":
116
+ return /* @__PURE__ */ React__default.createElement(TextBlock, { part, isStreaming });
117
+ case "citation":
118
+ return /* @__PURE__ */ React__default.createElement(CitationBlock, { part, onCitationClick });
119
+ case "image":
120
+ return /* @__PURE__ */ React__default.createElement(ImageBlock, { part });
121
+ case "tool-call":
122
+ return /* @__PURE__ */ React__default.createElement(ToolCallBlock, { part });
123
+ case "thinking":
124
+ return /* @__PURE__ */ React__default.createElement(ThinkingBlock, { part });
125
+ case "action-buttons":
126
+ return null;
127
+ default:
128
+ return null;
129
+ }
130
+ };
131
+
132
+ const ConversationLoading = ({ className }) => {
133
+ return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex gap-3 py-4", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "flex-shrink-0 mt-1" }, /* @__PURE__ */ React__default.createElement(Sparkle, { className: "h-5 w-5 text-primary animate-pulse", weight: "fill" })), /* @__PURE__ */ React__default.createElement("div", { className: "flex-1 space-y-3" }, /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-3/4 animate-pulse rounded bg-muted" }), /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-full animate-pulse rounded bg-muted" }), /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-5/6 animate-pulse rounded bg-muted" }), /* @__PURE__ */ React__default.createElement("div", { className: "h-3 w-2/3 animate-pulse rounded bg-muted" })));
134
+ };
135
+
136
+ const ConversationMessageAssistant = ({ message, className }) => {
137
+ const { callbacks } = useConversation();
138
+ const isStreaming = message.status === "streaming";
139
+ const isPending = message.status === "pending";
140
+ const isCompleted = message.status === "completed";
141
+ const actionButtonsParts = message.parts.filter((p) => p.type === "action-buttons");
142
+ const contentParts = message.parts.filter((p) => p.type !== "action-buttons");
143
+ const handleCopy = useCallback(() => {
144
+ const textContent = message.parts.filter((p) => p.type === "text").map((p) => p.text).join("\n");
145
+ callbacks.onCopy?.(message.id, textContent);
146
+ }, [message, callbacks]);
147
+ if (isPending && contentParts.length === 0) {
148
+ return /* @__PURE__ */ React__default.createElement(ConversationLoading, { className });
149
+ }
150
+ return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex gap-3 p-4 bg-surface rounded", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "flex-1 min-w-0" }, /* @__PURE__ */ React__default.createElement("div", { className: "space-y-1" }, contentParts.map((part, i) => /* @__PURE__ */ React__default.createElement(BlockRenderer, { key: i, part, isStreaming, onCitationClick: callbacks.onCitationClick }))), isCompleted && /* @__PURE__ */ React__default.createElement("div", { className: "mt-3 flex items-center gap-1" }, /* @__PURE__ */ React__default.createElement(
151
+ ActionBarButton,
152
+ {
153
+ tooltip: "Helpful",
154
+ active: message.feedback === "positive",
155
+ onClick: () => callbacks.onFeedback?.(message.id, "positive")
156
+ },
157
+ /* @__PURE__ */ React__default.createElement(ThumbsUp, { className: "h-4 w-4", weight: message.feedback === "positive" ? "fill" : "regular" })
158
+ ), /* @__PURE__ */ React__default.createElement(
159
+ ActionBarButton,
160
+ {
161
+ tooltip: "Not helpful",
162
+ active: message.feedback === "negative",
163
+ onClick: () => callbacks.onFeedback?.(message.id, "negative")
164
+ },
165
+ /* @__PURE__ */ React__default.createElement(ThumbsDown, { className: "h-4 w-4", weight: message.feedback === "negative" ? "fill" : "regular" })
166
+ ), /* @__PURE__ */ React__default.createElement(ActionBarButton, { tooltip: "Copy", onClick: handleCopy }, /* @__PURE__ */ React__default.createElement(Copy, { className: "h-4 w-4" })), /* @__PURE__ */ React__default.createElement(ActionBarButton, { tooltip: "More" }, /* @__PURE__ */ React__default.createElement(DotsThreeVertical, { className: "h-4 w-4" })), actionButtonsParts.map(
167
+ (part) => part.type === "action-buttons" ? part.actions.map((action) => /* @__PURE__ */ React__default.createElement(
168
+ "button",
169
+ {
170
+ key: action.id,
171
+ type: "button",
172
+ className: "ml-2 inline-flex items-center gap-1.5 rounded-full border border-border px-3 py-1 text-xs text-muted-foreground hover:bg-muted transition-colors",
173
+ onClick: () => callbacks.onActionClick?.(action, message.id)
174
+ },
175
+ action.label
176
+ )) : null
177
+ ))));
178
+ };
179
+ const ActionBarButton = ({ children, tooltip, active, onClick }) => {
180
+ return /* @__PURE__ */ React__default.createElement(Tooltip, null, /* @__PURE__ */ React__default.createElement(TooltipTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
181
+ "button",
182
+ {
183
+ type: "button",
184
+ className: cn(
185
+ "inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
186
+ active && "text-primary"
187
+ ),
188
+ onClick
189
+ },
190
+ children
191
+ )), /* @__PURE__ */ React__default.createElement(TooltipContent, { side: "bottom" }, /* @__PURE__ */ React__default.createElement("p", { className: "text-xs" }, tooltip)));
192
+ };
193
+
194
+ const ConversationMessageUser = ({ message, className }) => {
195
+ const textContent = message.parts.filter((p) => p.type === "text").map((p) => p.text).join("\n");
196
+ return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex justify-end py-4", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "max-w-[85%] rounded bg-surface px-4 py-2.5 text-primary-foreground" }, /* @__PURE__ */ React__default.createElement("p", { className: "whitespace-pre-wrap" }, textContent)));
197
+ };
198
+
199
+ const ConversationMessage = ({ message, className }) => {
200
+ switch (message.role) {
201
+ case "assistant":
202
+ return /* @__PURE__ */ React__default.createElement(ConversationMessageAssistant, { message, className });
203
+ case "user":
204
+ return /* @__PURE__ */ React__default.createElement(ConversationMessageUser, { message, className });
205
+ default:
206
+ return null;
207
+ }
208
+ };
209
+
210
+ const ConversationMessages = ({ className, bottomPadding = 0, onContentBehind }) => {
211
+ const { messages } = useConversation();
212
+ const viewportRef = useRef(null);
213
+ const sentinelRef = useRef(null);
214
+ useEffect(() => {
215
+ const viewport = viewportRef.current;
216
+ if (viewport) {
217
+ viewport.scrollTop = viewport.scrollHeight;
218
+ }
219
+ }, [messages]);
220
+ useEffect(() => {
221
+ const sentinel = sentinelRef.current;
222
+ const viewport = viewportRef.current;
223
+ if (!sentinel || !viewport || !onContentBehind) return;
224
+ const observer = new IntersectionObserver(
225
+ ([entry]) => {
226
+ if (entry) onContentBehind(!entry.isIntersecting);
227
+ },
228
+ { root: viewport, threshold: 0, rootMargin: `0px 0px -${bottomPadding}px 0px` }
229
+ );
230
+ observer.observe(sentinel);
231
+ return () => observer.disconnect();
232
+ }, [onContentBehind, bottomPadding]);
233
+ return /* @__PURE__ */ React__default.createElement(ScrollArea, { ref: viewportRef, className: cn("h-full", className) }, /* @__PURE__ */ React__default.createElement("div", { className: "px-4" }, messages.map((message) => /* @__PURE__ */ React__default.createElement(ConversationMessage, { key: message.id, message })), /* @__PURE__ */ React__default.createElement("div", { ref: sentinelRef, className: "h-px" })), /* @__PURE__ */ React__default.createElement("div", { style: { height: bottomPadding + 8 } }));
234
+ };
235
+
236
+ /**
237
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
238
+ *
239
+ * This source code is licensed under the MIT license found in the
240
+ * LICENSE file in the root directory of this source tree.
241
+ *
242
+ */
243
+
244
+ const r$2=createContext(null);function t(n,e){return {getTheme:function(){return null!=e?e:null}}}function o(){const n=useContext(r$2);return null==n&&function(n,...e){const r=new URL("https://lexical.dev/docs/error"),t=new URLSearchParams;t.append("code",n);for(const n of e)t.append("v",n);throw r.search=t.toString(),Error(`Minified Lexical error #${n}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(8),n}
245
+
246
+ /**
247
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
248
+ *
249
+ * This source code is licensed under the MIT license found in the
250
+ * LICENSE file in the root directory of this source tree.
251
+ *
252
+ */
253
+
254
+ const m$3="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,u$3=m$3?useLayoutEffect:useEffect,p$2={tag:HISTORY_MERGE_TAG};function f$3({initialConfig:a,children:c}){const l=useMemo(()=>{const{theme:t$1,namespace:c,nodes:l,onError:d,editorState:s,html:u}=a,f=t(null,t$1),E=createEditor({editable:a.editable,html:u,namespace:c,nodes:l,onError:e=>d(e,E),theme:t$1});return function(e,t){if(null===t)return;if(void 0===t)e.update(()=>{const t=$getRoot();if(t.isEmpty()){const o=$createParagraphNode();t.append(o);const n=m$3?document.activeElement:null;(null!==$getSelection()||null!==n&&n===e.getRootElement())&&o.select();}},p$2);else if(null!==t)switch(typeof t){case "string":{const o=e.parseEditorState(t);e.setEditorState(o,p$2);break}case "object":e.setEditorState(t,p$2);break;case "function":e.update(()=>{$getRoot().isEmpty()&&t(e);},p$2);}}(E,s),[E,f]},[]);return u$3(()=>{const e=a.editable,[t]=l;t.setEditable(void 0===e||e);},[]),jsx(r$2.Provider,{value:l,children:c})}
255
+
256
+ /**
257
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
258
+ *
259
+ * This source code is licensed under the MIT license found in the
260
+ * LICENSE file in the root directory of this source tree.
261
+ *
262
+ */
263
+
264
+ const c$2="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function u$2(e){return {initialValueFn:()=>e.isEditable(),subscribe:n=>e.registerEditableListener(n)}}function a$2(){return function(n){const[t]=o(),u=useMemo(()=>n(t),[t,n]),[a,l]=useState(()=>u.initialValueFn()),d=useRef(a);return c$2(()=>{const{initialValueFn:e,subscribe:n}=u,t=e();return d.current!==t&&(d.current=t,l(t)),n(e=>{d.current=e,l(e);})},[u,n]),a}(u$2)}
265
+
266
+ /**
267
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
268
+ *
269
+ * This source code is licensed under the MIT license found in the
270
+ * LICENSE file in the root directory of this source tree.
271
+ *
272
+ */
273
+
274
+ const E$2=new Map;function F$1(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function z(e){const n=$getEditor().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function O$1(e){return z($isRootNode(e)?e:e.getParentOrThrow())}function A$1(e){const t=O$1(e);return null!==t&&"rtl"===t.direction}function M$1(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!$isTokenOrSegmented(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[o,l]=$getCharacterOffsets(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(f){p=s?l:o,d=void 0;}else if(u){p=0,d=s?o:l;}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=$cloneWithPropertiesEphemeral(t)),t.__text=h);}}return t}function $(e){const t=e.getStyle(),n=F$1(t);E$2.set(t,n);}function Q$1(e){const t=Y$1(e);return null!==t&&"vertical-rl"===t.writingMode}function Y$1(e){const t=e.anchor.getNode();return $isElementNode(t)?z(t):O$1(t)}function Z$1(e,t){let n=Q$1(e)?!t:t;te$1(e)&&(n=!n);const l=$caretFromPoint(e.focus,n?"previous":"next");if($isExtendableTextPointCaret(l))return false;for(const e of $extendCaretToRange(l)){if($isChildCaret(e))return !e.origin.isInline();if(!$isElementNode(e.origin)){if($isDecoratorNode(e.origin))return true;break}}return false}function ee$1(e,t,n,o){e.modify(t?"extend":"move",n,o);}function te$1(e){const t=Y$1(e);return null!==t&&"rtl"===t.direction}function ne$1(e,t,n){const o=te$1(e);let l;l=Q$1(e)||o?!n:n,ee$1(e,t,l,"character");}
275
+
276
+ /**
277
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
278
+ *
279
+ * This source code is licensed under the MIT license found in the
280
+ * LICENSE file in the root directory of this source tree.
281
+ *
282
+ */
283
+
284
+ function T(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const B$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,_$1=B$1&&"documentMode"in document?document.documentMode:null;!(!B$1||!("InputEvent"in window)||_$1)&&"getTargetRanges"in new window.InputEvent("input");function yt$1(t){const e=$findMatchingParent(t,t=>$isElementNode(t)&&!t.isInline());return $isElementNode(e)||T(4,t.__key),e}function At$2(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function bt$2(t){const e=$getSelection();if(!$isRangeSelection(e))return false;const i=new Set,l=e.getNodes();for(let e=0;e<l.length;e++){const n=l[e],o=n.getKey();if(i.has(o))continue;const s=$findMatchingParent(n,t=>$isElementNode(t)&&!t.isInline());if(null===s)continue;const u=s.getKey();s.canIndent()&&!i.has(u)&&(i.add(u),t(s));}return i.size>0}
285
+
286
+ /**
287
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
288
+ *
289
+ * This source code is licensed under the MIT license found in the
290
+ * LICENSE file in the root directory of this source tree.
291
+ *
292
+ */
293
+
294
+ const Z=Symbol.for("preact-signals");function J$1(){if(Y>1)return void Y--;let t,e=false;for(;void 0!==Q;){let n=Q;for(Q=void 0,tt++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&st(n))try{n.c();}catch(n){e||(t=n,e=true);}n=i;}}if(tt=0,Y--,e)throw t}function H(t){if(Y>0)return t();Y++;try{return t()}finally{J$1();}}let q,Q;function X(t){const e=q;q=void 0;try{return t()}finally{q=e;}}let Y=0,tt=0,et=0;function nt(t){if(void 0===q)return;let e=t.n;return void 0===e||e.t!==q?(e={i:0,S:t,p:q.s,n:void 0,t:q,e:void 0,x:void 0,r:e},void 0!==q.s&&(q.s.n=e),q.s=e,t.n=e,32&q.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=q.s,e.n=void 0,q.s.n=e,q.s=e),e):void 0}function it(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function ot(t,e){return new it(t,e)}function st(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function rt(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}function ct(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t;}t.s=e;}function at(t,e){it.call(this,void 0),this.x=t,this.s=void 0,this.g=et-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function dt(t,e){return new at(t,e)}function ut(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Y++;const n=q;q=void 0;try{e();}catch(e){throw t.f&=-2,t.f|=8,ft(t),e}finally{q=n,J$1();}}}function ft(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ut(t);}function ht$1(t){if(q!==this)throw new Error("Out-of-order effect");ct(this),q=t,this.f&=-2,8&this.f&&ft(this),J$1();}function lt(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name;}function gt(t,e){const n=new lt(t,e);try{n.c();}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function pt$1(t,e={}){const n={};for(const i in t){const o=e[i],s=ot(void 0===o?t[i]:o);n[i]=s;}return n}it.prototype.brand=Z,it.prototype.h=function(){return true},it.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:X(()=>{var t;null==(t=this.W)||t.call(this);}));},it.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&X(()=>{var t;null==(t=this.Z)||t.call(this);}));}},it.prototype.subscribe=function(t){return gt(()=>{const e=this.value,n=q;q=void 0;try{t(e);}finally{q=n;}},{name:"sub"})},it.prototype.valueOf=function(){return this.value},it.prototype.toString=function(){return this.value+""},it.prototype.toJSON=function(){return this.value},it.prototype.peek=function(){const t=q;q=void 0;try{return this.value}finally{q=t;}},Object.defineProperty(it.prototype,"value",{get(){const t=nt(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(tt>100)throw new Error("Cycle detected");this.v=t,this.i++,et++,Y++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N();}finally{J$1();}}}}),at.prototype=new it,at.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if(32==(36&this.f))return true;if(this.f&=-5,this.g===et)return true;if(this.g=et,this.f|=1,this.i>0&&!st(this))return this.f&=-2,true;const t=q;try{rt(this),q=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++);}catch(t){this.v=t,this.f|=16,this.i++;}return q=t,ct(this),this.f&=-2,true},at.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t);}it.prototype.S.call(this,t);},at.prototype.U=function(t){if(void 0!==this.t&&(it.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t);}},at.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N();}},Object.defineProperty(at.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=nt(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),lt.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t);}finally{t();}},lt.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ut(this),rt(this),Y++;const t=q;return q=this,ht$1.bind(this,t)},lt.prototype.N=function(){2&this.f||(this.f|=2,this.o=Q,Q=this);},lt.prototype.d=function(){this.f|=8,1&this.f||ft(this);},lt.prototype.dispose=function(){this.d();};defineExtension({build:(t,e,n)=>pt$1(e),config:safeCast({defaultSelection:"rootEnd",disabled:false}),name:"@lexical/extension/AutoFocus",register(t,e,n){const i=n.getOutput();return gt(()=>i.disabled.value?void 0:t.registerRootListener(e=>{t.focus(()=>{const t=document.activeElement;null===e||null!==t&&e.contains(t)||e.focus({preventScroll:true});},{defaultSelection:i.defaultSelection.peek()});}))}});function vt$1(){const t=$getRoot(),e=$getSelection(),n=$createParagraphNode();t.clear(),t.append(n),null!==e&&n.select(),$isRangeSelection(e)&&(e.format=0);}function xt$1(t,e=vt$1){return t.registerCommand(CLEAR_EDITOR_COMMAND,n=>(t.update(e),true),COMMAND_PRIORITY_EDITOR)}defineExtension({build:(t,e,n)=>pt$1(e),config:safeCast({$onClear:vt$1}),name:"@lexical/extension/ClearEditor",register(t,e,n){const{$onClear:i}=n.getOutput();return gt(()=>xt$1(t,i.value))}});function Et$1(t){return ("function"==typeof t.nodes?t.nodes():t.nodes)||[]}const bt$1=createState("format",{parse:t=>"number"==typeof t?t:0});let wt$1 = class wt extends DecoratorNode{$config(){return this.config("decorator-text",{extends:DecoratorNode,stateConfigs:[{flat:true,stateConfig:bt$1}]})}getFormat(){return $getState(this,bt$1)}getFormatFlags(t,e){return toggleTextFormatType(this.getFormat(),t,e)}hasFormat(t){const e=TEXT_TYPE_TO_FORMAT[t];return 0!==(this.getFormat()&e)}setFormat(t){return $setState(this,bt$1,t)}toggleFormat(t){const e=this.getFormat(),n=toggleTextFormatType(e,t,null);return this.setFormat(n)}isInline(){return true}createDOM(){return document.createElement("span")}updateDOM(){return false}};function Nt$1(t){return t instanceof wt$1}defineExtension({name:"@lexical/extension/DecoratorText",nodes:()=>[wt$1],register:(t,e,n)=>t.registerCommand(FORMAT_TEXT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)||$isRangeSelection(e))for(const n of e.getNodes())Nt$1(n)&&n.toggleFormat(t);return false},COMMAND_PRIORITY_LOW)});function Ft$1(t,e){let n;return ot(t(),{unwatched(){n&&(n(),n=void 0);},watched(){this.value=t(),n=e(this);}})}const It=defineExtension({build:t=>Ft$1(()=>t.getEditorState(),e=>t.registerUpdateListener(t=>{e.value=t.editorState;})),name:"@lexical/extension/EditorState"});function _t$1(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function jt(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=jt(n[t],i[t]);return t}return e}const At$1=0,kt$1=1,Pt=2,Kt$1=3,$t=4,zt=5,Ut=6,Lt=7;function Tt$1(t){return t.id===At$1}function Bt(t){return t.id===Pt}function Wt(t){return function(t){return t.id===kt$1}(t)||_t$1(305,String(t.id),String(kt$1)),Object.assign(t,{id:Pt})}const Gt=new Set;class Vt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:At$1};}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):shallowMergeConfig;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Bt(e)||_t$1(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:Kt$1,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:$t,initResult:e,registerState:n})}(o,s,i);}build(t){const e=this.state;let n;e.id!==$t&&_t$1(307,String(e.id),String(zt)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:zt,output:e,registerState:n})}(e,n,i);}register(t,e){this._signal=e;const n=this.state;n.id!==zt&&_t$1(308,String(n.id),String(zt));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Ut})}(n),()=>{const t=this.state;t.id!==Lt&&_t$1(309,String(n.id),String(Lt)),this.state=function(t){return Object.assign(t,{id:zt})}(t),i&&i();}}afterRegistration(t){const e=this.state;let n;return e.id!==Ut&&_t$1(310,String(e.id),String(Ut)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Lt})}(e),n}getSignal(){return void 0===this._signal&&_t$1(311),this._signal}getInitResult(){ void 0===this.extension.init&&_t$1(312,this.extension.name);const t=this.state;return function(t){return t.id>=$t}(t)||_t$1(313,String(t.id),String($t)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=Kt$1}(t)||_t$1(314,String(t.id),String(Kt$1)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&_t$1(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&_t$1(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Lt}(t)||_t$1(316,String(t.id),String(Lt)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||Gt}getPeerNameSet(){let t=this._peerNameSet;return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;((function(t){return t.id>=zt}))(t)||_t$1(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output};}return this._dependency}}const Zt={tag:HISTORY_MERGE_TAG};function Jt$1(){const t=$getRoot();t.isEmpty()&&t.append($createParagraphNode());}const Ht=defineExtension({config:safeCast({setOptions:Zt,updateOptions:Zt}),init:({$initialEditorState:t=Jt$1})=>({$initialEditorState:t,initialized:false}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=true;const{$initialEditorState:i}=o;if($isEditorState(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t);},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[RootNode,TextNode,LineBreakNode,TabNode,ParagraphNode]}),qt=Symbol.for("@lexical/extension/LexicalBuilder");function Xt(){}function Yt(t){throw t}function te(t){return Array.isArray(t)?t:[t]}const ee="0.41.0+prod.esm";class ne{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=ee,this.roots=t;for(const e of t)this.addExtension(e);}static fromExtensions(t){const e=[te(Ht)];for(const n of t)e.push(te(n));return new ne(e)}static maybeFromEditor(t){const e=t[qt];return e&&(e.PACKAGE_VERSION!==ee&&_t$1(292,e.PACKAGE_VERSION,ee),e instanceof ne||_t$1(293)),e}static fromEditor(t){const e=ne.maybeFromEditor(t);return void 0===e&&_t$1(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign(createEditor({...n,...e?{onError:t=>{e(t,i);}}:{}}),{[qt]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=Xt;function e(){try{t();}finally{t=Xt;}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});return t=mergeRegister(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&_t$1(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]));}addExtension(t){ void 0!==this._sortedExtensionReps&&_t$1(296);const e=te(t),[n]=e;"string"!=typeof n.name&&_t$1(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&_t$1(298,n.name),!i){i=new Vt(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&_t$1(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&_t$1(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=te(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e);}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Bt(o))return;const s=n.extension.name;var r;Tt$1(o)||_t$1(300,s,i||"[unknown]"),Tt$1(r=o)||_t$1(304,String(r.id),String(At$1)),o=Object.assign(r,{id:kt$1}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s);}o=Wt(o),n.state=o,t.push(n);};for(const t of this.extensionNameMap.values())Tt$1(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t);}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&_t$1(301,t.name);for(const t of e)n.configs.add(t);}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e);}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e);}return mergeRegister(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of Et$1(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&_t$1(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c);}e.add(t);}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import);}r.theme&&jt(s,r.theme);}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,a=i.size>0;(c||a)&&(t.html={},c&&(t.html.import=o),a&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=Yt),t}}const re=new Set,ce=defineExtension({build(t,e,n){const i=n.getDependency(It).output,o=ot({watchedNodeKeys:new Map}),r=Ft$1(()=>{},()=>gt(()=>{const t=r.peek(),{watchedNodeKeys:e}=o.value;let n,c=false;i.value.read(()=>{if($getSelection())for(const[i,o]of e.entries()){if(0===o.size){e.delete(i);continue}const s=$getNodeByKey(i),r=s&&s.isSelected()||false;c=c||r!==(!!t&&t.has(i)),r&&(n=n||new Set,n.add(i));}}),!c&&n&&t&&n.size===t.size||(r.value=n);}));return {watchNodeKey:function(t){const e=dt(()=>(r.value||re).has(t)),{watchedNodeKeys:n}=o.peek();let i=n.get(t);const s=void 0!==i;return i=i||new Set,i.add(e),s||(n.set(t,i),o.value={watchedNodeKeys:n}),e}}},dependencies:[It],name:"@lexical/extension/NodeSelection"});createCommand("INSERT_HORIZONTAL_RULE_COMMAND");class de extends DecoratorNode{static getType(){return "horizontalrule"}static clone(t){return new de(t.__key)}static importJSON(t){return fe().updateFromJSON(t)}static importDOM(){return {hr:()=>({conversion:ue,priority:0})}}exportDOM(){return {element:document.createElement("hr")}}createDOM(t){const e=document.createElement("hr");return addClassNamesToElement(e,t.theme.hr),e}getTextContent(){return "\n"}isInline(){return false}updateDOM(){return false}}function ue(){return {node:fe()}}function fe(){return $create(de)}function he(t){return t instanceof de}defineExtension({dependencies:[It,ce],name:"@lexical/extension/HorizontalRule",nodes:()=>[de],register(t,e,n){const{watchNodeKey:i}=n.getDependency(ce).output,o=ot({nodeSelections:new Map}),r=t._config.theme.hrSelected??"selected";return mergeRegister(t.registerCommand(CLICK_COMMAND,t=>{if(isDOMNode(t.target)){const e=$getNodeFromDOMNode(t.target);if(he(e))return function(t,e=false){const n=$getSelection(),i=t.isSelected(),o=t.getKey();let r;e&&$isNodeSelection(n)?r=n:(r=$createNodeSelection(),$setSelection(r)),i?r.delete(o):r.add(o);}(e,t.shiftKey),true}return false},COMMAND_PRIORITY_LOW),t.registerMutationListener(de,(e,n)=>{H(()=>{let n=!1;const{nodeSelections:s}=o.peek();for(const[o,r]of e.entries())if("destroyed"===r)s.delete(o),n=!0;else {const e=s.get(o),r=t.getElementByKey(o);e?e.domNode.value=r:(n=!0,s.set(o,{domNode:ot(r),selectedSignal:i(o)}));}n&&(o.value={nodeSelections:s});});}),gt(()=>{const t=[];for(const{domNode:e,selectedSignal:n}of o.value.nodeSelections.values())t.push(gt(()=>{const t=e.value;if(t){n.value?addClassNamesToElement(t,r):removeClassNamesFromElement(t,r);}}));return mergeRegister(...t)}))}});function ge(t){return t.canBeEmpty()}function pe(t,e,n=ge){return mergeRegister(t.registerCommand(KEY_TAB_COMMAND,e=>{const n=$getSelection();if(!$isRangeSelection(n))return false;e.preventDefault();const i=function(t){if(t.getNodes().filter(t=>$isBlockElementNode(t)&&t.canIndent()).length>0)return true;const e=t.anchor,n=t.focus,i=n.isBefore(e)?n:e,o=i.getNode(),s=yt$1(o);if(s.canIndent()){const t=s.getKey();let e=$createRangeSelection();if(e.anchor.set(t,0,"element"),e.focus.set(t,0,"element"),e=$normalizeSelection__EXPERIMENTAL(e),e.anchor.is(i))return true}return false}(n)?e.shiftKey?OUTDENT_CONTENT_COMMAND:INDENT_CONTENT_COMMAND:INSERT_TAB_COMMAND;return t.dispatchCommand(i,void 0)},COMMAND_PRIORITY_EDITOR),t.registerCommand(INDENT_CONTENT_COMMAND,()=>{const t="number"==typeof e?e:e?e.peek():null,i=$getSelection();if(!$isRangeSelection(i))return false;const o="function"==typeof n?n:n.peek();return bt$2(e=>{if(o(e)){const n=e.getIndent()+1;(!t||n<t)&&e.setIndent(n);}})},COMMAND_PRIORITY_CRITICAL))}defineExtension({build:(t,e,n)=>pt$1(e),config:safeCast({$canIndent:ge,disabled:false,maxIndent:null}),name:"@lexical/extension/TabIndentation",register(t,e,n){const{disabled:i,maxIndent:o,$canIndent:s}=n.getOutput();return gt(()=>{if(!i.value)return pe(t,o,s)})}});
295
+
296
+ /**
297
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
298
+ *
299
+ * This source code is licensed under the MIT license found in the
300
+ * LICENSE file in the root directory of this source tree.
301
+ *
302
+ */
303
+
304
+ const r$1=defineExtension({name:"@lexical/react/ReactProvider"});
305
+
306
+ /**
307
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
308
+ *
309
+ * This source code is licensed under the MIT license found in the
310
+ * LICENSE file in the root directory of this source tree.
311
+ *
312
+ */
313
+
314
+ function s$1(){return $getRoot().getTextContent()}function f$2(t,e=true){if(t)return false;let n=s$1();return e&&(n=n.trim()),""===n}function c$1(o){if(!f$2(o,false))return false;const l=$getRoot().getChildren(),s=l.length;if(s>1)return false;for(let t=0;t<s;t++){const o=l[t];if($isDecoratorNode(o))return false;if($isElementNode(o)){if(!$isParagraphNode(o))return false;if(0!==o.__indent)return false;const e=o.getChildren(),n=e.length;for(let r=0;r<n;r++){const n=e[t];if(!$isTextNode(n))return false}}}return true}function g$2(t){return ()=>c$1(t)}
315
+
316
+ /**
317
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
318
+ *
319
+ * This source code is licensed under the MIT license found in the
320
+ * LICENSE file in the root directory of this source tree.
321
+ *
322
+ */
323
+
324
+ function s(e){const t=window.location.origin,n=n=>{if(n.origin!==t)return;const o=e.getRootElement();if(document.activeElement!==o)return;const s=n.data;if("string"==typeof s){let t;try{t=JSON.parse(s);}catch(e){return}if(t&&"nuanria_messaging"===t.protocol&&"request"===t.type){const o=t.payload;if(o&&"makeChanges"===o.functionId){const t=o.args;if(t){const[o,s,d,c,g]=t;e.update(()=>{const e=$getSelection();if($isRangeSelection(e)){const t=e.anchor;let i=t.getNode(),a=0,l=0;if($isTextNode(i)&&o>=0&&s>=0&&(a=o,l=o+s,e.setTextNodeRange(i,a,i,l)),a===l&&""===d||(e.insertRawText(d),i=t.getNode()),$isTextNode(i)){a=c,l=c+g;const t=i.getTextContentSize();a=a>t?t:a,l=l>t?t:l,e.setTextNodeRange(i,a,i,l);}n.stopImmediatePropagation();}});}}}}};return window.addEventListener("message",n,true),()=>{window.removeEventListener("message",n,true);}}const d$1=defineExtension({build:(e,n,o)=>pt$1(n),config:safeCast({disabled:"undefined"==typeof window}),name:"@lexical/dragon",register:(t,n,o)=>gt(()=>o.getOutput().disabled.value?void 0:s(t))});
325
+
326
+ /**
327
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
328
+ *
329
+ * This source code is licensed under the MIT license found in the
330
+ * LICENSE file in the root directory of this source tree.
331
+ *
332
+ */
333
+
334
+ function m$2(e,n){const t=isDOMDocumentNode(n)?n.body.childNodes:n.childNodes;let l=[];const r=[];for(const n of t)if(!w$1.has(n.nodeName)){const t=y$1(n,e,r,false);null!==t&&(l=l.concat(t));}return function(e){for(const n of e)n.getNextSibling()instanceof ArtificialNode__DO_NOT_USE&&n.insertAfter($createLineBreakNode());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(r),l}function g$1(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),o=$getRoot().getChildren();for(let l=0;l<o.length;l++){x$2(e,o[l],t,n);}return t.innerHTML}function x$2(t,o,l,u=null){let f=null===u||o.isSelected(u);const a=$isElementNode(o)&&o.excludeFromCopy("html");let d=o;null!==u&&$isTextNode(o)&&(d=M$1(u,o,"clone"));const p=$isElementNode(d)?d.getChildren():[],h=getRegisteredNode(t,d.getType());let m;m=h&&void 0!==h.exportDOM?h.exportDOM(t,d):d.exportDOM(t);const{element:g,after:w}=m;if(!g)return false;const y=document.createDocumentFragment();for(let e=0;e<p.length;e++){const n=p[e],l=x$2(t,n,y,u);!f&&$isElementNode(o)&&l&&o.extractWithChild(n,u,"html")&&(f=true);}if(f&&!a){if((isHTMLElement(g)||isDocumentFragment(g))&&g.append(y),l.append(g),w){const e=w.call(d,g);e&&(isDocumentFragment(g)?g.replaceChildren(e):g.replaceWith(e));}}else l.append(y);return f}const w$1=new Set(["STYLE","SCRIPT"]);function y$1(e,n,o,l,i=new Map,s){let c=[];if(w$1.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let b=null;if(null!==x){b=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m]);}null!=x.forChild&&i.set(e.nodeName,x.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!$isRootOrShadowRoot(m))&&(null!=m&&$isBlockElementNode(m)||l);for(let e=0;e<S.length;e++)v.push(...y$1(S[e],n,o,N,new Map(i),m));return null!=b&&(v=b(v)),isBlockDomNode(e)&&(v=C$1(e,v,N?()=>{const e=new ArtificialNode__DO_NOT_USE;return o.push(e),e}:$createParagraphNode)),null==m?v.length>0?c=c.concat(v):isBlockDomNode(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return false;return isInlineDomNode(e.nextSibling)&&isInlineDomNode(e.previousSibling)}(e)&&(c=c.concat($createLineBreakNode())):$isElementNode(m)&&m.append(...v),c}function C$1(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if($isBlockElementNode(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&$isBlockElementNode(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l}
335
+
336
+ /**
337
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
338
+ *
339
+ * This source code is licensed under the MIT license found in the
340
+ * LICENSE file in the root directory of this source tree.
341
+ *
342
+ */
343
+
344
+ function v$2(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function D(e,n=$getSelection()){return null==n&&v$2(166),$isRangeSelection(n)&&n.isCollapsed()||0===n.getNodes().length?"":g$1(e,n)}function S(t,e=$getSelection()){return null==e&&v$2(166),$isRangeSelection(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(E$1(t,e))}function R(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return A(o,L$1(t.nodes),n)}}catch(t){console.error(t);}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return A(o,m$2(o,t),n)}catch(t){console.error(t);}const u=a||t.getData("text/uri-list");if(null!=u)if($isRangeSelection(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=$getSelection();if($isRangeSelection(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([$createTabNode()]):n.insertText(o);}}}else n.insertRawText(u);}function A(t,e,n){t.dispatchCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,{nodes:e,selection:n})||(n.insertNodes(e),function(t){if($isRangeSelection(t)&&t.isCollapsed()){const e=t.anchor;let n=null;const o=$caretFromPoint(e,"previous");if(o)if($isTextPointCaret(o))n=o.origin;else {const t=$getCaretRange(o,$getChildCaret($getRoot(),"next").getFlipped());for(const e of t){if($isTextNode(e.origin)){n=e.origin;break}if($isElementNode(e.origin)&&!e.origin.isInline())break}}if(n&&$isTextNode(n)){const e=n.getFormat(),o=n.getStyle();t.format===e&&t.style===o||(t.format=e,t.style=o,t.dirty=true);}}}(n));}function P(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=$isElementNode(n)&&n.excludeFromCopy("html");let s=n;null!==e&&$isTextNode(s)&&(s=M$1(e,s,"clone"));const c=$isElementNode(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&v$2(58,n.name),$isElementNode(t)){const t=e.children;Array.isArray(t)||v$2(59,n.name);}return e}(s);$isTextNode(s)&&0===s.getTextContentSize()&&(i=false);for(let o=0;o<c.length;o++){const r=c[o],l=P(t,e,r,a.children);!i&&$isElementNode(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=true);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function E$1(t,e){const n=[],o=$getRoot().getChildren();for(let r=0;r<o.length;r++){P(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function L$1(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=$parseSerializedNode(r);$isTextNode(i)&&$(i),e.push(i);}return e}let b$2=null;async function F(t,e,n){if(null!==b$2)return false;if(null!==e)return new Promise((o,r)=>{t.update(()=>{o(M(t,e,n));});});const o=t.getRootElement(),i=t._window||window,l=i.document,s=getDOMSelection(i);if(null===o||null===s)return false;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise((e,o)=>{const s=t.registerCommand(COPY_COMMAND,o=>(At$2(o,ClipboardEvent)&&(s(),null!==b$2&&(i.clearTimeout(b$2),b$2=null),e(M(t,o,n))),true),COMMAND_PRIORITY_CRITICAL);b$2=i.setTimeout(()=>{s(),b$2=null,e(false);},50),l.execCommand("copy"),c.remove();})}function M(t,e,n){if(void 0===n){const e=getDOMSelection(t._window),o=$getSelection();if(!o||o.isCollapsed())return false;if(!e)return false;const r=e.anchorNode,l=e.focusNode;if(null!==r&&null!==l&&!isSelectionWithinEditor(t,r,l))return false;n=_(o);}e.preventDefault();const o=e.clipboardData;return null!==o&&(J(o,n),true)}const O=[["text/html",D],["application/x-lexical-editor",S]];function _(t=$getSelection()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=$getEditor();for(const[o,r]of O){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function J(t,e){for(const[n]of O) void 0===e[n]&&t.setData(n,"");for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}}
345
+
346
+ /**
347
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
348
+ *
349
+ * This source code is licensed under the MIT license found in the
350
+ * LICENSE file in the root directory of this source tree.
351
+ *
352
+ */
353
+
354
+ function pt(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const ht="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,vt=ht&&"documentMode"in document?document.documentMode:null,Ct=ht&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),yt=!(!ht||!("InputEvent"in window)||vt)&&"getTargetRanges"in new window.InputEvent("input"),xt=ht&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Dt=ht&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Nt=ht&&/^(?=.*Chrome).*/i.test(navigator.userAgent),wt=ht&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Ct&&!Nt,Et=createCommand("DRAG_DROP_PASTE_FILE");class _t extends ElementNode{static getType(){return "quote"}static clone(t){return new _t(t.__key)}createDOM(t){const e=document.createElement("blockquote");return addClassNamesToElement(e,t.theme.quote),e}updateDOM(t,e){return false}static importDOM(){return {blockquote:t=>({conversion:St,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return Ot().updateFromJSON(t)}insertNewAfter(t,e){const n=$createParagraphNode(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=$createParagraphNode();return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}canMergeWhenEmpty(){return true}}function Ot(){return $applyNodeReplacement(new _t)}class Tt extends ElementNode{__tag;static getType(){return "heading"}static clone(t){return new Tt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}setTag(t){const e=this.getWritable();return this.__tag=t,e}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];addClassNamesToElement(n,t);}return n}updateDOM(t,e,n){return t.__tag!==this.__tag}static importDOM(){return {h1:t=>({conversion:At,priority:0}),h2:t=>({conversion:At,priority:0}),h3:t=>({conversion:At,priority:0}),h4:t=>({conversion:At,priority:0}),h5:t=>({conversion:At,priority:0}),h6:t=>({conversion:At,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Ft(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Ft(t)?{conversion:t=>({node:Mt("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(isHTMLElement(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return Mt(t.tag).updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTag(t.tag)}exportJSON(){return {...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=true){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?$createParagraphNode():Mt(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=$createParagraphNode();t.select(),this.replace(t,true);}return o}collapseAtStart(){const t=this.isEmpty()?$createParagraphNode():Mt(this.getTag());return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}extractWithChild(){return true}}function Ft(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function At(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=Mt(e),null!==t.style&&(setNodeIndentFromDOM(t,n),n.setFormat(t.style.textAlign))),{node:n}}function St(t){const e=Ot();return null!==t.style&&(e.setFormat(t.style.textAlign),setNodeIndentFromDOM(t,e)),{node:e}}function Mt(t="h1"){return $applyNodeReplacement(new Tt(t))}function bt(t){let e=null;if(At$2(t,DragEvent)?e=t.dataTransfer:At$2(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return [false,[],false];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return [r,Array.from(e.files),o]}function Kt(t){const e=$getNearestNodeFromDOMNode(t);return $isDecoratorNode(e)}function kt(t){for(const e of ["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e);}function Jt(n){return mergeRegister(n.registerCommand(CLICK_COMMAND,t=>{const e=$getSelection();return !!$isNodeSelection(e)&&(e.clear(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_CHARACTER_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)?(e.deleteCharacter(t),true):!!$isNodeSelection(e)&&(e.deleteNodes(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_WORD_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.deleteWord(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DELETE_LINE_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.deleteLine(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND,e=>{const r=$getSelection();if("string"==typeof e)null!==r&&r.insertText(e);else {if(null===r)return false;const o=e.dataTransfer;if(null!=o)R(o,r,n);else if($isRangeSelection(r)){const t=e.data;return t&&r.insertText(t),true}}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(REMOVE_TEXT_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(t.removeText(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(FORMAT_TEXT_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.formatText(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(FORMAT_ELEMENT_COMMAND,t=>{const e=$getSelection();if(!$isRangeSelection(e)&&!$isNodeSelection(e))return false;const n=e.getNodes();for(const e of n){const n=$findMatchingParent(e,t=>$isElementNode(t)&&!t.isInline());null!==n&&n.setFormat(t);}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_LINE_BREAK_COMMAND,t=>{const e=$getSelection();return !!$isRangeSelection(e)&&(e.insertLineBreak(t),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_PARAGRAPH_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(t.insertParagraph(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(INSERT_TAB_COMMAND,()=>{const t=$createTabNode(),e=$getSelection();return $isRangeSelection(e)&&(t.setFormat(e.format),t.setStyle(e.style)),$insertNodes([t]),true},COMMAND_PRIORITY_EDITOR),n.registerCommand(INDENT_CONTENT_COMMAND,()=>bt$2(t=>{const e=t.getIndent();t.setIndent(e+1);}),COMMAND_PRIORITY_EDITOR),n.registerCommand(OUTDENT_CONTENT_COMMAND,()=>bt$2(t=>{const e=t.getIndent();e>0&&t.setIndent(Math.max(0,e-1));}),COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_UP_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),true}else if($isRangeSelection(e)){const n=$getAdjacentNode(e.focus,true);if(!t.shiftKey&&$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_DOWN_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),true}else if($isRangeSelection(e)){if(function(t){const e=t.focus;return "root"===e.key&&e.offset===$getRoot().getChildrenSize()}(e))return t.preventDefault(),true;const n=$getAdjacentNode(e.focus,false);if(!t.shiftKey&&$isDecoratorNode(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_LEFT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$1(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),true}if(!$isRangeSelection(e))return false;if(Z$1(e,true)){const n=t.shiftKey;return t.preventDefault(),ne$1(e,n,true),true}return false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ARROW_RIGHT_COMMAND,t=>{const e=$getSelection();if($isNodeSelection(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$1(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),true}if(!$isRangeSelection(e))return false;const n=t.shiftKey;return !!Z$1(e,false)&&(t.preventDefault(),ne$1(e,n,false),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_BACKSPACE_COMMAND,t=>{if(Kt(t.target))return false;const e=$getSelection();if($isRangeSelection(e)){if(function(t){if(!t.isCollapsed())return false;const{anchor:e}=t;if(0!==e.offset)return false;const n=e.getNode();if($isRootNode(n))return false;const r=yt$1(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(e))return t.preventDefault(),n.dispatchCommand(OUTDENT_CONTENT_COMMAND,void 0);if(Dt&&"ko-KR"===navigator.language)return false}else if(!$isNodeSelection(e))return false;return t.preventDefault(),n.dispatchCommand(DELETE_CHARACTER_COMMAND,true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_DELETE_COMMAND,t=>{if(Kt(t.target))return false;const e=$getSelection();return !(!$isRangeSelection(e)&&!$isNodeSelection(e))&&(t.preventDefault(),n.dispatchCommand(DELETE_CHARACTER_COMMAND,false))},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ENTER_COMMAND,t=>{const e=$getSelection();if(!$isRangeSelection(e))return false;if(kt(e),null!==t){if((Dt||xt||wt)&&yt)return false;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(INSERT_LINE_BREAK_COMMAND,false)}return n.dispatchCommand(INSERT_PARAGRAPH_COMMAND,void 0)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_ESCAPE_COMMAND,()=>{const t=$getSelection();return !!$isRangeSelection(t)&&(n.blur(),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DROP_COMMAND,t=>{const[,e]=bt(t);if(e.length>0){const r=pt(t.clientX,t.clientY);if(null!==r){const{offset:t,node:o}=r,i=$getNearestNodeFromDOMNode(o);if(null!==i){const e=$createRangeSelection();if($isTextNode(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else {const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element");}const n=$normalizeSelection__EXPERIMENTAL(e);$setSelection(n);}n.dispatchCommand(Et,e);}return t.preventDefault(),true}const r=$getSelection();return !!$isRangeSelection(r)},COMMAND_PRIORITY_EDITOR),n.registerCommand(DRAGSTART_COMMAND,t=>{const[e]=bt(t),n=$getSelection();return !(e&&!$isRangeSelection(n))},COMMAND_PRIORITY_EDITOR),n.registerCommand(DRAGOVER_COMMAND,t=>{const[e]=bt(t),n=$getSelection();if(e&&!$isRangeSelection(n))return false;const r=pt(t.clientX,t.clientY);if(null!==r){const e=$getNearestNodeFromDOMNode(r.node);$isDecoratorNode(e)&&t.preventDefault();}return true},COMMAND_PRIORITY_EDITOR),n.registerCommand(SELECT_ALL_COMMAND,()=>($selectAll(),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(COPY_COMMAND,t=>(F(n,At$2(t,ClipboardEvent)?t:null),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(CUT_COMMAND,t=>(async function(t,n){await F(n,At$2(t,ClipboardEvent)?t:null),n.update(()=>{const t=$getSelection();$isRangeSelection(t)?t.removeText():$isNodeSelection(t)&&t.getNodes().forEach(t=>t.remove());});}(t,n),true),COMMAND_PRIORITY_EDITOR),n.registerCommand(PASTE_COMMAND,e=>{const[,r,o]=bt(e);if(r.length>0&&!o)return n.dispatchCommand(Et,r),true;if(isDOMNode(e.target)&&isSelectionCapturedInDecoratorInput(e.target))return false;return null!==$getSelection()&&(function(e,n){e.preventDefault(),n.update(()=>{const r=$getSelection(),o=At$2(e,InputEvent)||At$2(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&R(o,r,n);},{tag:PASTE_TAG});}(e,n),true)},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_SPACE_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)&&kt(e),false},COMMAND_PRIORITY_EDITOR),n.registerCommand(KEY_TAB_COMMAND,t=>{const e=$getSelection();return $isRangeSelection(e)&&kt(e),false},COMMAND_PRIORITY_EDITOR))}defineExtension({conflictsWith:["@lexical/plain-text"],dependencies:[d$1],name:"@lexical/rich-text",nodes:()=>[Tt,_t],register:Jt});
355
+
356
+ /**
357
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
358
+ *
359
+ * This source code is licensed under the MIT license found in the
360
+ * LICENSE file in the root directory of this source tree.
361
+ *
362
+ */
363
+
364
+ function g(r,...e){const t=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",r);for(const r of e)o.append("v",r);throw t.search=o.toString(),Error(`Minified Lexical error #${r}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function w({editor:r,ErrorBoundary:e}){return function(r,e){const[t,o]=useState(()=>r.getDecorators());return y(()=>r.registerDecoratorListener(r=>{flushSync(()=>{o(r);});}),[r]),useEffect(()=>{o(r.getDecorators());},[r]),useMemo(()=>{const o=[],n=Object.keys(t);for(let i=0;i<n.length;i++){const c=n[i],a=jsx(e,{onError:e=>r._onError(e),children:jsx(Suspense,{fallback:null,children:t[c]})}),s=r.getElementByKey(c);null!==s&&o.push(createPortal(a,s,c));}return o},[e,t,r])}(r,e)}function v$1({editor:r,ErrorBoundary:e}){return function(r){const e=ne.maybeFromEditor(r);if(e&&e.hasExtensionByName(r$1.name)){for(const r of ["@lexical/plain-text","@lexical/rich-text"])e.hasExtensionByName(r)&&g(320,r);return true}return false}(r)?null:jsx(w,{editor:r,ErrorBoundary:e})}function B(r){return r.getEditorState().read(g$2(r.isComposing()))}function L({contentEditable:e,placeholder:t=null,ErrorBoundary:o$1}){const[n]=o();return function(r){y(()=>mergeRegister(Jt(r),s(r)),[r]);}(n),jsxs(Fragment,{children:[e,jsx(b$1,{content:t}),jsx(v$1,{editor:n,ErrorBoundary:o$1})]})}function b$1({content:t}){const[o$1]=o(),n=function(r){const[e,t]=useState(()=>B(r));return y(()=>{function e(){const e=B(r);t(e);}return e(),mergeRegister(r.registerUpdateListener(()=>{e();}),r.registerEditableListener(()=>{e();}))},[r]),e}(o$1),i=a$2();return n?"function"==typeof t?t(i):t:null}
365
+
366
+ /**
367
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
368
+ *
369
+ * This source code is licensed under the MIT license found in the
370
+ * LICENSE file in the root directory of this source tree.
371
+ *
372
+ */
373
+
374
+ const m$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function f$1({editor:e,ariaActiveDescendant:t,ariaAutoComplete:i,ariaControls:a,ariaDescribedBy:d,ariaErrorMessage:c,ariaExpanded:s,ariaInvalid:u,ariaLabel:f,ariaLabelledBy:b,ariaMultiline:p,ariaOwns:x,ariaRequired:E,autoCapitalize:v,className:w,id:y,role:C="textbox",spellCheck:g=true,style:L,tabIndex:h,"data-testid":D,...I},R){const[k,q]=useState(e.isEditable()),z=useCallback(t=>{t&&t.ownerDocument&&t.ownerDocument.defaultView?e.setRootElement(t):e.setRootElement(null);},[e]),A=useMemo(()=>function(...e){return t=>{for(const i of e)"function"==typeof i?i(t):null!=i&&(i.current=t);}}(R,z),[z,R]);return m$1(()=>(q(e.isEditable()),e.registerEditableListener(e=>{q(e);})),[e]),jsx("div",{"aria-activedescendant":k?t:void 0,"aria-autocomplete":k?i:"none","aria-controls":k?a:void 0,"aria-describedby":d,...null!=c?{"aria-errormessage":c}:{},"aria-expanded":k&&"combobox"===C?!!s:void 0,...null!=u?{"aria-invalid":u}:{},"aria-label":f,"aria-labelledby":b,"aria-multiline":p,"aria-owns":k?x:void 0,"aria-readonly":!k||void 0,"aria-required":E,autoCapitalize:v,className:w,contentEditable:k,"data-testid":D,id:y,ref:A,role:C,spellCheck:g,style:L,tabIndex:h,...I})}const b=forwardRef(f$1);function p$1(e){return e.getEditorState().read(g$2(e.isComposing()))}const x$1=forwardRef(E);function E(t,i){const{placeholder:a,...r}=t,[n]=o();return jsxs(Fragment,{children:[jsx(b,{editor:n,...r,ref:i}),null!=a&&jsx(v,{editor:n,content:a})]})}function v({content:e,editor:i}){const a=function(e){const[t,i]=useState(()=>p$1(e));return m$1(()=>{function t(){const t=p$1(e);i(t);}return t(),mergeRegister(e.registerUpdateListener(()=>{t();}),e.registerEditableListener(()=>{t();}))},[e]),t}(i),[n,o]=useState(i.isEditable());if(useLayoutEffect(()=>(o(i.isEditable()),i.registerEditableListener(e=>{o(e);})),[i]),!a)return null;let d=null;return "function"==typeof e?d=e(n):null!==e&&(d=e),null===d?null:jsx("div",{"aria-hidden":true,children:d})}
375
+
376
+ /**
377
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
378
+ *
379
+ * This source code is licensed under the MIT license found in the
380
+ * LICENSE file in the root directory of this source tree.
381
+ *
382
+ */
383
+
384
+ function a$1({delay:a,externalHistoryState:c}){const[l]=o();return function(t,a,c=1e3){const l=useMemo(()=>a||createEmptyHistoryState(),[a]);useEffect(()=>registerHistory(t,l,c),[c,t,l]);}(l,c,a),null}
385
+
386
+ /**
387
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
388
+ *
389
+ * This source code is licensed under the MIT license found in the
390
+ * LICENSE file in the root directory of this source tree.
391
+ *
392
+ */
393
+
394
+ function l$1({hasStrictIndent:l=false,shouldPreserveNumbering:m=false}){const[c]=o();return useEffect(()=>{if(!c.hasNodes([ListNode,ListItemNode]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[c]),useEffect(()=>mergeRegister(registerList(c,{restoreNumbering:m}),l?registerListStrictIndentTransform(c):()=>{}),[c,l,m]),function(e){useEffect(()=>registerList(e),[e]);}(c),null}
395
+
396
+ /**
397
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
398
+ *
399
+ * This source code is licensed under the MIT license found in the
400
+ * LICENSE file in the root directory of this source tree.
401
+ *
402
+ */
403
+
404
+ function l({validateUrl:l,attributes:n}){const[a]=o();return useEffect(()=>{if(!a.hasNodes([LinkNode]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),useEffect(()=>registerLink(a,pt$1({attributes:n,validateUrl:l})),[a,l,n]),null}
405
+
406
+ /**
407
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
408
+ *
409
+ * This source code is licensed under the MIT license found in the
410
+ * LICENSE file in the root directory of this source tree.
411
+ *
412
+ */
413
+
414
+ const r="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?useLayoutEffect:useEffect;function n$1({ignoreHistoryMergeTagChange:o$1=true,ignoreSelectionChange:i=false,onChange:n}){const[a]=o();return r(()=>{if(n)return a.registerUpdateListener(({editorState:e,dirtyElements:r,dirtyLeaves:d,prevEditorState:s,tags:c})=>{i&&0===r.size&&0===d.size||o$1&&c.has(HISTORY_MERGE_TAG)||s.isEmpty()||n(e,a,c);})},[a,o$1,i,n]),null}
415
+
416
+ /**
417
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
418
+ *
419
+ * This source code is licensed under the MIT license found in the
420
+ * LICENSE file in the root directory of this source tree.
421
+ *
422
+ */
423
+
424
+ function d(e,t){return e.getEditorState().read(()=>{const e=$getNodeByKey(t);return null!==e&&e.isSelected()})}function u$1(c){const[u]=o(),[p,s]=useState(()=>d(u,c));useEffect(()=>{let e=true;const t=u.registerUpdateListener(()=>{e&&s(d(u,c));});return ()=>{e=false,t();}},[u,c]);return [p,useCallback(e=>{u.update(()=>{let a=$getSelection();$isNodeSelection(a)||(a=$createNodeSelection(),$setSelection(a)),$isNodeSelection(a)&&(e?a.add(c):a.delete(c));});},[u,c]),useCallback(()=>{u.update(()=>{const e=$getSelection();$isNodeSelection(e)&&e.clear();});},[u])]}
425
+
426
+ /**
427
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
428
+ *
429
+ * This source code is licensed under the MIT license found in the
430
+ * LICENSE file in the root directory of this source tree.
431
+ *
432
+ */
433
+
434
+ function u({nodeKey:e}){const[l]=o(),[s,u,p]=u$1(e);return useEffect(()=>mergeRegister(l.registerCommand(CLICK_COMMAND,t=>{const r=l.getElementByKey(e);return t.target===r&&(t.shiftKey||p(),u(!s),true)},COMMAND_PRIORITY_LOW)),[p,l,s,e,u]),useEffect(()=>{const t=l.getElementByKey(e),r=l._config.theme.hrSelected??"selected";null!==t&&(s?addClassNamesToElement(t,r):removeClassNamesFromElement(t,r));},[l,s,e]),null}class p extends de{static getType(){return "horizontalrule"}static clone(e){return new p(e.__key)}static importJSON(e){return f().updateFromJSON(e)}static importDOM(){return {hr:()=>({conversion:x,priority:0})}}decorate(){return jsx(u,{nodeKey:this.__key})}}function x(){return {node:f()}}function f(){return $applyNodeReplacement(new p)}
435
+
436
+ /**
437
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
438
+ *
439
+ * This source code is licensed under the MIT license found in the
440
+ * LICENSE file in the root directory of this source tree.
441
+ *
442
+ */
443
+
444
+ const i=[{dependencies:[p],export:e=>he(e)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(e,r,t,o)=>{const n=f();o||null!=e.getNextSibling()?e.replace(n):e.insertBefore(n),n.selectNext();},type:"element"},...TRANSFORMERS];function a({transformers:e=i}){const[o$1]=o();return useEffect(()=>registerMarkdownShortcuts(o$1,e),[o$1,e]),null}
445
+
446
+ const h = createContext(null), c = {
447
+ didCatch: false,
448
+ error: null
449
+ };
450
+ class m extends Component {
451
+ constructor(e) {
452
+ super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = c;
453
+ }
454
+ static getDerivedStateFromError(e) {
455
+ return { didCatch: true, error: e };
456
+ }
457
+ resetErrorBoundary(...e) {
458
+ const { error: t } = this.state;
459
+ t !== null && (this.props.onReset?.({
460
+ args: e,
461
+ reason: "imperative-api"
462
+ }), this.setState(c));
463
+ }
464
+ componentDidCatch(e, t) {
465
+ this.props.onError?.(e, t);
466
+ }
467
+ componentDidUpdate(e, t) {
468
+ const { didCatch: o } = this.state, { resetKeys: s } = this.props;
469
+ o && t.error !== null && C(e.resetKeys, s) && (this.props.onReset?.({
470
+ next: s,
471
+ prev: e.resetKeys,
472
+ reason: "keys"
473
+ }), this.setState(c));
474
+ }
475
+ render() {
476
+ const { children: e, fallbackRender: t, FallbackComponent: o, fallback: s } = this.props, { didCatch: n, error: a } = this.state;
477
+ let i = e;
478
+ if (n) {
479
+ const u = {
480
+ error: a,
481
+ resetErrorBoundary: this.resetErrorBoundary
482
+ };
483
+ if (typeof t == "function")
484
+ i = t(u);
485
+ else if (o)
486
+ i = createElement(o, u);
487
+ else if (s !== void 0)
488
+ i = s;
489
+ else
490
+ throw a;
491
+ }
492
+ return createElement(
493
+ h.Provider,
494
+ {
495
+ value: {
496
+ didCatch: n,
497
+ error: a,
498
+ resetErrorBoundary: this.resetErrorBoundary
499
+ }
500
+ },
501
+ i
502
+ );
503
+ }
504
+ }
505
+ function C(r = [], e = []) {
506
+ return r.length !== e.length || r.some((t, o) => !Object.is(t, e[o]));
507
+ }
508
+
509
+ /**
510
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
511
+ *
512
+ * This source code is licensed under the MIT license found in the
513
+ * LICENSE file in the root directory of this source tree.
514
+ *
515
+ */
516
+
517
+ function n({children:n,onError:e}){return jsx(m,{fallback:jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:n})}
518
+
519
+ const CHAT_TRANSFORMERS = [ORDERED_LIST, UNORDERED_LIST, LINK, INLINE_CODE, CODE];
520
+ function EditorRefPlugin({ editorRef }) {
521
+ const [editor] = o();
522
+ useEffect(() => {
523
+ editorRef.current = editor;
524
+ return () => {
525
+ editorRef.current = null;
526
+ };
527
+ }, [editor, editorRef]);
528
+ return null;
529
+ }
530
+ function SubmitPlugin({ onSubmit }) {
531
+ const [editor] = o();
532
+ useEffect(() => {
533
+ return editor.registerCommand(
534
+ KEY_ENTER_COMMAND,
535
+ (event) => {
536
+ if (event.shiftKey) return false;
537
+ const selection = $getSelection();
538
+ if ($isRangeSelection(selection)) {
539
+ const node = selection.anchor.getNode();
540
+ if ($isListItemNode(node) || $isListItemNode(node.getParent())) return false;
541
+ if ($isCodeNode(node) || $isCodeNode(node.getParent())) return false;
542
+ }
543
+ event.preventDefault();
544
+ editor.read(() => {
545
+ onSubmit?.($convertToMarkdownString(CHAT_TRANSFORMERS));
546
+ });
547
+ return true;
548
+ },
549
+ COMMAND_PRIORITY_HIGH
550
+ );
551
+ }, [editor, onSubmit]);
552
+ return null;
553
+ }
554
+ function LexicalEditor({
555
+ defaultValue,
556
+ onChange,
557
+ onSubmit,
558
+ placeholder,
559
+ disabled,
560
+ className,
561
+ autoFocus,
562
+ forwardedRef
563
+ }) {
564
+ const editorRef = useRef(null);
565
+ useImperativeHandle(forwardedRef, () => ({
566
+ clear() {
567
+ editorRef.current?.update(() => {
568
+ const root = $getRoot();
569
+ root.clear();
570
+ root.append($createParagraphNode());
571
+ });
572
+ },
573
+ focus() {
574
+ editorRef.current?.focus();
575
+ }
576
+ }));
577
+ const initialConfig = {
578
+ namespace: "RichTextInput",
579
+ nodes: [ListNode, ListItemNode, LinkNode, AutoLinkNode, CodeNode, CodeHighlightNode],
580
+ editable: !disabled,
581
+ editorState: defaultValue ? () => $convertFromMarkdownString(defaultValue, CHAT_TRANSFORMERS) : void 0,
582
+ onError: (error) => console.error("[RichTextInput]", error)
583
+ };
584
+ return /* @__PURE__ */ React__default.createElement(f$3, { initialConfig }, /* @__PURE__ */ React__default.createElement("div", { className }, /* @__PURE__ */ React__default.createElement("div", { className: "relative" }, /* @__PURE__ */ React__default.createElement(
585
+ L,
586
+ {
587
+ contentEditable: /* @__PURE__ */ React__default.createElement(
588
+ x$1,
589
+ {
590
+ autoFocus,
591
+ className: "outline-none w-full max-h-[7.5rem] overflow-y-auto [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5"
592
+ }
593
+ ),
594
+ placeholder: placeholder ? /* @__PURE__ */ React__default.createElement("div", { className: "pointer-events-none absolute top-0 left-0 select-none text-muted-foreground" }, placeholder) : null,
595
+ ErrorBoundary: n
596
+ }
597
+ ))), /* @__PURE__ */ React__default.createElement(a$1, null), /* @__PURE__ */ React__default.createElement(l$1, null), /* @__PURE__ */ React__default.createElement(l, null), /* @__PURE__ */ React__default.createElement(a, { transformers: CHAT_TRANSFORMERS }), onChange && /* @__PURE__ */ React__default.createElement(
598
+ n$1,
599
+ {
600
+ onChange: (editorState) => {
601
+ editorState.read(() => {
602
+ onChange($convertToMarkdownString(CHAT_TRANSFORMERS));
603
+ });
604
+ }
605
+ }
606
+ ), /* @__PURE__ */ React__default.createElement(SubmitPlugin, { onSubmit }), /* @__PURE__ */ React__default.createElement(EditorRefPlugin, { editorRef }));
607
+ }
608
+
609
+ const RichTextInput = forwardRef((props, ref) => /* @__PURE__ */ React__default.createElement(LexicalEditor, { ...props, forwardedRef: ref }));
610
+ RichTextInput.displayName = "RichTextInput";
611
+
612
+ const ContextPillBadge = ({ pill, onRemove }) => {
613
+ return /* @__PURE__ */ React__default.createElement("span", { className: "inline-flex items-center gap-0.5 rounded-full bg-muted px-2 py-1 text-xs text-muted-foreground" }, pill.label, onRemove && /* @__PURE__ */ React__default.createElement(
614
+ "button",
615
+ {
616
+ type: "button",
617
+ className: "ml-0.5 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full hover:bg-muted-foreground/20",
618
+ onClick: () => onRemove(pill)
619
+ },
620
+ /* @__PURE__ */ React__default.createElement(X$1, { className: "h-2.5 w-2.5" })
621
+ ));
622
+ };
623
+
624
+ const COLLECTION_SEARCH_THRESHOLD = 5;
625
+ const ConversationInput = ({
626
+ placeholder = "What can we help with today?",
627
+ attachments = [],
628
+ collections = [],
629
+ contextPills = [],
630
+ disabled = false,
631
+ isElevated = false,
632
+ className
633
+ }) => {
634
+ const { callbacks, isStreaming } = useConversation();
635
+ const [hasText, setHasText] = useState(false);
636
+ const latestMarkdown = useRef("");
637
+ const editorRef = useRef(null);
638
+ const [menuOpen, setMenuOpen] = useState(false);
639
+ const [collectionPickerOpen, setCollectionPickerOpen] = useState(false);
640
+ const collectionCloseTimer = useRef(null);
641
+ const collectionHasFocus = useRef(false);
642
+ const openCollectionPicker = useCallback(() => {
643
+ if (collectionCloseTimer.current) {
644
+ clearTimeout(collectionCloseTimer.current);
645
+ collectionCloseTimer.current = null;
646
+ }
647
+ setCollectionPickerOpen(true);
648
+ }, []);
649
+ const scheduleCollectionPickerClose = useCallback(() => {
650
+ collectionCloseTimer.current = setTimeout(() => {
651
+ if (!collectionHasFocus.current) {
652
+ setCollectionPickerOpen(false);
653
+ }
654
+ }, 150);
655
+ }, []);
656
+ const isDisabled = disabled;
657
+ const handleSend = useCallback(
658
+ (markdown) => {
659
+ const trimmed = (markdown ?? latestMarkdown.current).trim();
660
+ if (!trimmed || isDisabled || isStreaming) return;
661
+ callbacks.onSend?.(trimmed, attachments.length > 0 ? attachments : void 0);
662
+ editorRef.current?.clear();
663
+ editorRef.current?.focus();
664
+ },
665
+ [isDisabled, isStreaming, callbacks, attachments]
666
+ );
667
+ const handleStop = useCallback(() => {
668
+ callbacks.onStop?.();
669
+ }, [callbacks]);
670
+ const handleAttachmentAction = useCallback(
671
+ (action) => {
672
+ callbacks.onAttachmentAction?.(action);
673
+ },
674
+ [callbacks]
675
+ );
676
+ const handleCollectionSelect = useCallback(
677
+ (collection) => {
678
+ setCollectionPickerOpen(false);
679
+ setMenuOpen(false);
680
+ handleAttachmentAction({ type: "select-collection", collection });
681
+ },
682
+ [handleAttachmentAction]
683
+ );
684
+ return /* @__PURE__ */ React__default.createElement("div", { className: cn("px-2", className) }, /* @__PURE__ */ React__default.createElement(
685
+ "div",
686
+ {
687
+ className: cn(
688
+ "relative rounded-t-2xl rounded-b-lg bg-gradient-yellowfin p-2 transition-shadow duration-300",
689
+ isElevated && "shadow-[0_-20px_25px_-5px_rgba(0,0,0,0.1),0_-8px_10px_-6px_rgba(0,0,0,0.1)]"
690
+ )
691
+ },
692
+ /* @__PURE__ */ React__default.createElement("div", { className: "rounded-t-lg rounded-b bg-surface shadow-md" }, contextPills.length > 0 && /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-wrap gap-1.5 px-3 pt-3" }, contextPills.map((pill) => /* @__PURE__ */ React__default.createElement(ContextPillBadge, { key: pill.id, pill, onRemove: callbacks.onContextPillRemove }))), /* @__PURE__ */ React__default.createElement(
693
+ RichTextInput,
694
+ {
695
+ ref: editorRef,
696
+ placeholder,
697
+ disabled,
698
+ autoFocus: true,
699
+ className: "w-full bg-transparent p-4 text-sm disabled:cursor-not-allowed disabled:opacity-50",
700
+ onChange: (markdown) => {
701
+ latestMarkdown.current = markdown;
702
+ setHasText(markdown.trim().length > 0);
703
+ },
704
+ onSubmit: handleSend
705
+ }
706
+ ), /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center justify-between px-2 pb-2" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center gap-1" }, /* @__PURE__ */ React__default.createElement(DropdownMenu, { open: menuOpen, onOpenChange: setMenuOpen }, /* @__PURE__ */ React__default.createElement(DropdownMenuTrigger, { asChild: true, disabled: disabled || isStreaming }, /* @__PURE__ */ React__default.createElement(
707
+ "button",
708
+ {
709
+ type: "button",
710
+ className: cn(
711
+ "inline-flex h-6 w-6 items-center justify-center rounded text-default hover:bg-muted transition-all",
712
+ menuOpen && "shadow-md dark:shadow-md"
713
+ ),
714
+ disabled: disabled || isStreaming
715
+ },
716
+ /* @__PURE__ */ React__default.createElement(Plus, { className: cn("h-4 w-4 transition-transform duration-200", menuOpen && "-rotate-45") })
717
+ )), /* @__PURE__ */ React__default.createElement(
718
+ DropdownMenuContent,
719
+ {
720
+ align: "end",
721
+ side: "right",
722
+ className: "rounded border-none shadow-md bg-surface p-2 min-w-[200px] dark:border-none dark:shadow-md"
723
+ },
724
+ collections.length > 0 && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(Popover, { open: collectionPickerOpen, onOpenChange: setCollectionPickerOpen }, /* @__PURE__ */ React__default.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
725
+ DropdownMenuItem,
726
+ {
727
+ className: "p-2",
728
+ onSelect: (e) => e.preventDefault(),
729
+ onMouseEnter: openCollectionPicker,
730
+ onMouseLeave: scheduleCollectionPickerClose,
731
+ onFocus: openCollectionPicker
732
+ },
733
+ "Collection",
734
+ /* @__PURE__ */ React__default.createElement(CaretRight, { className: "ml-auto h-4 w-4" })
735
+ )), /* @__PURE__ */ React__default.createElement(
736
+ PopoverContent,
737
+ {
738
+ className: "w-[200px] rounded border-none p-0 shadow-md dark:border-none dark:shadow-md",
739
+ side: "right",
740
+ align: "start",
741
+ onMouseEnter: openCollectionPicker,
742
+ onMouseLeave: scheduleCollectionPickerClose,
743
+ onFocusCapture: () => {
744
+ collectionHasFocus.current = true;
745
+ },
746
+ onBlurCapture: () => {
747
+ collectionHasFocus.current = false;
748
+ scheduleCollectionPickerClose();
749
+ }
750
+ },
751
+ /* @__PURE__ */ React__default.createElement(Command, null, collections.length > COLLECTION_SEARCH_THRESHOLD && /* @__PURE__ */ React__default.createElement(CommandInput, { placeholder: "Search collections..." }), /* @__PURE__ */ React__default.createElement(CommandList, null, /* @__PURE__ */ React__default.createElement(CommandEmpty, null, "No collections found."), /* @__PURE__ */ React__default.createElement(CommandGroup, null, collections.map((collection) => /* @__PURE__ */ React__default.createElement(
752
+ CommandItem,
753
+ {
754
+ key: collection.id,
755
+ value: collection.label,
756
+ onSelect: () => handleCollectionSelect(collection)
757
+ },
758
+ collection.label
759
+ )))))
760
+ )), /* @__PURE__ */ React__default.createElement(DropdownMenuSeparator, null)),
761
+ /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "attach-tab" }) }, "Attach tab"),
762
+ /* @__PURE__ */ React__default.createElement(DropdownMenuSeparator, null),
763
+ /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "screenshot" }) }, "Take a screenshot"),
764
+ /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "record-video" }) }, "Record a video"),
765
+ /* @__PURE__ */ React__default.createElement(DropdownMenuItem, { className: "p-2", onSelect: () => handleAttachmentAction({ type: "add-file" }) }, "Add image or file")
766
+ ))), isStreaming ? /* @__PURE__ */ React__default.createElement(
767
+ "button",
768
+ {
769
+ type: "button",
770
+ className: "inline-flex h-6 w-6 items-center justify-center rounded transition-colors bg-input text-primary-foreground hover:bg-input/90",
771
+ onClick: handleStop,
772
+ disabled
773
+ },
774
+ /* @__PURE__ */ React__default.createElement(Stop, { className: "h-4 w-4", weight: "fill" })
775
+ ) : /* @__PURE__ */ React__default.createElement(
776
+ "button",
777
+ {
778
+ type: "button",
779
+ className: cn(
780
+ "inline-flex h-6 w-6 items-center justify-center rounded transition-colors",
781
+ hasText ? "bg-input text-primary-foreground hover:bg-input/90" : "bg-muted text-muted-foreground"
782
+ ),
783
+ onClick: () => handleSend(),
784
+ disabled: isDisabled || !hasText
785
+ },
786
+ /* @__PURE__ */ React__default.createElement(ArrowUp, { className: "h-4 w-4", weight: "bold" })
787
+ )))
788
+ ));
789
+ };
790
+
791
+ const ConversationSuggestions = ({ items, className }) => {
792
+ const { callbacks } = useConversation();
793
+ if (items.length === 0) return null;
794
+ return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex flex-wrap justify-end gap-2 px-4 py-2", className) }, items.map((suggestion) => /* @__PURE__ */ React__default.createElement(
795
+ "button",
796
+ {
797
+ key: suggestion.id,
798
+ type: "button",
799
+ className: "rounded-full border border-border px-4 py-2 text-sm text-foreground hover:bg-muted transition-colors",
800
+ onClick: () => callbacks.onSuggestionClick?.(suggestion)
801
+ },
802
+ suggestion.text
803
+ )));
804
+ };
805
+
806
+ const ConversationActions = ({ actions, onActionClick, className }) => {
807
+ if (actions.length === 0) return null;
808
+ return /* @__PURE__ */ React__default.createElement("div", { className: cn("flex flex-wrap gap-2 px-4 py-2", className) }, actions.map((action) => /* @__PURE__ */ React__default.createElement(
809
+ "button",
810
+ {
811
+ key: action.id,
812
+ type: "button",
813
+ className: "inline-flex items-center gap-2 rounded-full border border-border px-4 py-2 text-sm text-foreground hover:bg-muted transition-colors",
814
+ onClick: () => onActionClick?.(action)
815
+ },
816
+ action.label,
817
+ action.description && /* @__PURE__ */ React__default.createElement("span", { className: "text-muted-foreground" }, action.description)
818
+ )));
819
+ };
820
+
821
+ const ConversationRoot = ({
822
+ messages,
823
+ callbacks,
824
+ children,
825
+ suggestions = [],
826
+ actions = [],
827
+ placeholder,
828
+ attachments,
829
+ collections,
830
+ contextPills,
831
+ showBranding = false,
832
+ className
833
+ }) => {
834
+ const isCompound = !!children;
835
+ const bottomRef = useRef(null);
836
+ const [bottomHeight, setBottomHeight] = useState(0);
837
+ const [hasContentBehind, setContentBehind] = useState(false);
838
+ useEffect(() => {
839
+ const el = bottomRef.current;
840
+ if (!el) return;
841
+ const observer = new ResizeObserver(([entry]) => {
842
+ if (entry) setBottomHeight(entry.borderBoxSize[0]?.blockSize ?? entry.contentRect.height);
843
+ });
844
+ observer.observe(el);
845
+ return () => observer.disconnect();
846
+ }, []);
847
+ return /* @__PURE__ */ React__default.createElement(TooltipProvider, null, /* @__PURE__ */ React__default.createElement(ConversationProvider, { messages, callbacks }, /* @__PURE__ */ React__default.createElement("div", { className: cn("flex h-full flex-col", className) }, isCompound ? children : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: "relative min-h-0 flex-1 grid grid-rows-[1fr] grid-cols-[1fr] pb-2" }, /* @__PURE__ */ React__default.createElement("div", { className: "row-start-1 col-start-1 min-h-0" }, /* @__PURE__ */ React__default.createElement(ConversationMessages, { bottomPadding: bottomHeight, onContentBehind: setContentBehind })), /* @__PURE__ */ React__default.createElement("div", { ref: bottomRef, className: "row-start-1 col-start-1 self-end z-10 pointer-events-none" }, /* @__PURE__ */ React__default.createElement("div", { className: "pointer-events-auto" }, suggestions.length > 0 && /* @__PURE__ */ React__default.createElement(ConversationSuggestions, { items: suggestions }), actions.length > 0 && /* @__PURE__ */ React__default.createElement(
848
+ ConversationActions,
849
+ {
850
+ actions,
851
+ onActionClick: (action) => callbacks.onActionClick?.(action, "")
852
+ }
853
+ ), /* @__PURE__ */ React__default.createElement(
854
+ ConversationInput,
855
+ {
856
+ placeholder,
857
+ attachments,
858
+ collections,
859
+ contextPills,
860
+ isElevated: hasContentBehind
861
+ }
862
+ )))), showBranding && /* @__PURE__ */ React__default.createElement("div", { className: "relative z-10 pb-2" }, /* @__PURE__ */ React__default.createElement(Branding, null))))));
863
+ };
864
+ const Branding = () => /* @__PURE__ */ React__default.createElement("div", { className: "flex items-center justify-center gap-1 text-[0.625rem] text-subtle" }, /* @__PURE__ */ React__default.createElement("span", null, "Powered by"), /* @__PURE__ */ React__default.createElement(Logo, { variant: "full", color: "outline", className: "h-2.5 w-auto" }));
865
+ const Conversation = Object.assign(ConversationRoot, {
866
+ Messages: ConversationMessages,
867
+ Input: ConversationInput,
868
+ Suggestions: ConversationSuggestions,
869
+ Actions: ConversationActions,
870
+ Loading: ConversationLoading
871
+ });
54
872
 
55
873
  function InputWithTags({
56
874
  title,
@@ -199,5 +1017,5 @@ const FullLayoutHeader = React__default.forwardRef(
199
1017
  );
200
1018
  FullLayoutHeader.displayName = "FullLayoutHeader";
201
1019
 
202
- export { Button, FullLayoutHeader, InputWithTags, Textarea };
1020
+ export { Button, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, ContextPillBadge, Conversation, ConversationActions, ConversationInput, ConversationLoading, ConversationMessageAssistant, ConversationMessageUser, ConversationMessages, ConversationProvider, ConversationSuggestions, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, FormattedMessage, FullLayoutHeader, InputWithTags, Logo, Popover, PopoverContent, PopoverTrigger, ScrollArea, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, useConversation };
203
1021
  //# sourceMappingURL=index.js.map