@pstdio/ui 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/MermaidComponent-CatfVUxA.js +60 -0
  2. package/dist/MermaidComponent-CatfVUxA.js.map +1 -0
  3. package/dist/chat-ui.js +1220 -1144
  4. package/dist/chat-ui.js.map +1 -1
  5. package/dist/components/chat-ui/components/chat-input-attachments.d.ts +12 -0
  6. package/dist/components/chat-ui/components/chat-input.d.ts +3 -0
  7. package/dist/components/chat-ui/components/chat-panel.d.ts +2 -0
  8. package/dist/components/chat-ui/components/message-parts-renderer.d.ts +1 -1
  9. package/dist/components/chat-ui/components/message-types.d.ts +90 -3
  10. package/dist/components/chat-ui/index.d.ts +2 -2
  11. package/dist/components/chat-ui/mocks/library/index.d.ts +2 -2
  12. package/dist/components/chat-ui/performance/chat-performance-fixtures.d.ts +1 -1
  13. package/dist/components/chat-ui/performance/chat-performance-story-utils.d.ts +1 -1
  14. package/dist/components/chat-ui/tool-rendering/build-timeline.d.ts +3 -3
  15. package/dist/components/chat-ui/tool-rendering/question-renderer.d.ts +1 -1
  16. package/dist/components/chat-ui/tool-rendering/shared.d.ts +2 -2
  17. package/dist/components/chat-ui/tool-rendering/todowrite-renderer.d.ts +1 -1
  18. package/dist/components/chat-ui/tool-rendering/types.d.ts +1 -1
  19. package/dist/components/data-renderer/data-renderer-board-column-header.d.ts +8 -0
  20. package/dist/components/data-renderer/data-renderer-board-group-section.d.ts +17 -0
  21. package/dist/components/data-renderer/data-renderer-board-move.d.ts +21 -0
  22. package/dist/components/data-renderer/data-renderer-board.d.ts +3 -2
  23. package/dist/components/data-renderer/data-renderer-content.d.ts +7 -2
  24. package/dist/components/data-renderer/data-renderer.d.ts +2 -2
  25. package/dist/components/diff-viewer/diff-card-body.d.ts +16 -0
  26. package/dist/components/diff-viewer/diff-card.d.ts +1 -0
  27. package/dist/components/diff-viewer/diff-size.d.ts +1 -1
  28. package/dist/components/mermaid-renderer/download-png.d.ts +7 -0
  29. package/dist/components/mermaid-renderer/index.d.ts +2 -0
  30. package/dist/components/mermaid-renderer/mermaid-error-state.d.ts +6 -0
  31. package/dist/components/mermaid-renderer/mermaid-fixtures.d.ts +9 -0
  32. package/dist/components/mermaid-renderer/mermaid-fullscreen.d.ts +10 -0
  33. package/dist/components/mermaid-renderer/mermaid-renderer.d.ts +8 -0
  34. package/dist/components/mermaid-renderer/mermaid-svg-view.d.ts +12 -0
  35. package/dist/components/mermaid-renderer/mermaid-toolbar.d.ts +12 -0
  36. package/dist/components/mermaid-renderer/mermaid-zoom.d.ts +6 -0
  37. package/dist/components/mermaid-renderer/svg-data-url.d.ts +6 -0
  38. package/dist/components/mermaid-renderer/use-mermaid-render.d.ts +5 -0
  39. package/dist/components/palette-shortcut.d.ts +8 -0
  40. package/dist/index.d.ts +3 -0
  41. package/dist/index.js +3393 -3221
  42. package/dist/index.js.map +1 -1
  43. package/dist/mermaid-renderer-DYEiYmYQ.js +411 -0
  44. package/dist/mermaid-renderer-DYEiYmYQ.js.map +1 -0
  45. package/dist/resource-badge-D33IFv74.js +188 -0
  46. package/dist/resource-badge-D33IFv74.js.map +1 -0
  47. package/dist/{rich-message-CEOSsdR2.js → rich-message-BFtvH9H7.js} +430 -518
  48. package/dist/rich-message-BFtvH9H7.js.map +1 -0
  49. package/dist/rich-text.js +3 -3
  50. package/dist/{theme-D2LYEa0j.js → theme-C5qHTCU9.js} +3 -3
  51. package/dist/{theme-D2LYEa0j.js.map → theme-C5qHTCU9.js.map} +1 -1
  52. package/dist/theme.js +1 -1
  53. package/package.json +3 -2
  54. package/dist/MermaidComponent-Cz_Iob5U.js +0 -127
  55. package/dist/MermaidComponent-Cz_Iob5U.js.map +0 -1
  56. package/dist/components/chat-ui/agent-types.d.ts +0 -220
  57. package/dist/get-file-type-icon-ufFb0IkR.js +0 -102
  58. package/dist/get-file-type-icon-ufFb0IkR.js.map +0 -1
  59. package/dist/rich-message-CEOSsdR2.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-message-BFtvH9H7.js","sources":["../src/components/rich-text/shared/components/content-editable.tsx","../src/components/rich-text/markdown-editor/plugins/ReferenceLinkPlugin/ReferenceLinkNode.tsx","../src/components/rich-text/markdown-editor/plugins/ReferenceLinkPlugin/ReferenceLinkTransformer.ts","../src/components/rich-text/theme/rich-text-theme.tsx","../src/components/rich-text/shared/prism-global.ts","../src/components/rich-text/shared/components/default-rich-text-components.tsx","../src/components/rich-text/shared/nodes/DataTableNode.tsx","../src/components/rich-text/shared/plugins/EquationPlugin/EquationNode.tsx","../src/components/rich-text/shared/plugins/EquationPlugin/EquationPlugin.tsx","../src/components/rich-text/shared/plugins/HorizontalRulePlugin/HorizontalRuleNode.ts","../src/components/rich-text/shared/plugins/MermaidPlugin/MermaidNode.tsx","../src/components/rich-text/shared/plugins/HorizontalRulePlugin/horizontalRule.ts","../src/components/rich-text/shared/transformers/markdown-transformers.ts","../src/components/rich-text/shared/editor-config.ts","../src/components/rich-text/shared/plugins/CodePlugin/CodeBlockPlugin.tsx","../src/components/rich-text/shared/plugins/CodePlugin/CodeHighlightingPlugin.tsx","../src/components/rich-text/shared/plugins/LinkEditorPlugin/commands.ts","../src/components/rich-text/shared/plugins/ToggleEditablePlugin.tsx","../src/components/rich-text/shared/plugins/TreeViewPlugin/TreeViewPlugin.tsx","../src/components/rich-text/utils/markdown.ts","../src/components/rich-text/prompt-input/events.ts","../src/components/rich-text/prompt-input/commands.ts","../src/components/rich-text/prompt-input/plugins/CommentPlugin/nodes/CommentNode/CommentNode.tsx","../src/components/rich-text/prompt-input/plugins/CommentPlugin/hooks/useCommentCommands.ts","../src/components/rich-text/prompt-input/plugins/CommentPlugin/hooks/useCommentSchema.ts","../src/components/rich-text/prompt-input/plugins/CommentPlugin/CommentPlugin.tsx","../src/components/rich-text/prompt-input/utils.ts","../src/components/rich-text/prompt-input/plugins/ImperativeAPIPlugin.tsx","../src/components/rich-text/prompt-input/plugins/keyboard-shortcuts.ts","../src/components/rich-text/prompt-input/plugins/KeyboardShortcutPlugin.tsx","../src/components/rich-text/prompt-input/plugins/ReferenceMenuPlugin/constants.ts","../src/components/rich-text/prompt-input/plugins/ReferenceMenuPlugin/utils/getSortedMenuOptions.ts","../src/components/rich-text/prompt-input/plugins/ReferenceMenuPlugin/components/ReferenceMenu/ReferenceMenuItem.tsx","../src/components/rich-text/prompt-input/plugins/ReferenceMenuPlugin/components/ReferenceMenu/ReferenceMenu.tsx","../src/components/rich-text/prompt-input/plugins/ReferenceMenuPlugin/hooks/useContextLookup.tsx","../src/components/rich-text/prompt-input/plugins/ReferenceMenuPlugin/utils/checkForTriggers.ts","../src/components/rich-text/prompt-input/plugins/ReferenceMenuPlugin/ReferenceMenuPlugin.tsx","../src/components/rich-text/prompt-input/plugins/ReferencePlugin/nodes/ReferenceNode/ReferenceNode.tsx","../src/components/rich-text/prompt-input/plugins/ReferencePlugin/ReferencePlugin.tsx","../src/components/rich-text/prompt-input/theme/prompt-input-theme.ts","../src/components/rich-text/prompt-input/prompt-input.tsx","../src/components/rich-text/shared/plugins/StateUpdatePlugin.tsx","../src/components/rich-text/rich-message/plugins/ReferenceLinkPlugin/ReferenceLinkNode.tsx","../src/components/rich-text/rich-message/plugins/ReferenceLinkPlugin/ReferenceLinkTransformer.ts","../src/components/rich-text/rich-message/rich-message.tsx"],"sourcesContent":["import { Box, chakra } from \"@chakra-ui/react\";\nimport { ContentEditable as LexicalContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { ScrollArea } from \"@/components/scroll-area\";\n\nconst StyledEditable = chakra(LexicalContentEditable);\n\ninterface ContentEditableProps {\n onRef?: (elem: HTMLDivElement) => void;\n fullWidth?: boolean;\n padding?: string;\n isRichMessage?: boolean;\n scrollable?: boolean;\n}\n\nexport function ContentEditable({\n onRef,\n fullWidth = false,\n padding,\n isRichMessage = false,\n scrollable = true,\n}: ContentEditableProps) {\n const editor = (\n <Box ref={onRef} width=\"100%\" minH=\"100%\" padding={padding}>\n <StyledEditable\n data-testid=\"content-editable\"\n height=\"fit-content\"\n minH=\"100%\"\n width=\"100%\"\n maxWidth={fullWidth ? \"100%\" : \"720px\"}\n marginInline={fullWidth ? \"0\" : \"auto\"}\n textStyle=\"paragraph/M/regular\"\n fontSize=\"calc(var(--chakra-font-sizes-md) * var(--rich-text-font-scale))\"\n position=\"relative\"\n outline=\"none\"\n />\n </Box>\n );\n\n if (!scrollable) return editor;\n\n return (\n <ScrollArea\n className=\"rich-text\"\n data-rich-message={isRichMessage ? \"true\" : undefined}\n height=\"100%\"\n minH=\"0\"\n position=\"relative\"\n contentProps={{ width: \"100%\", minH: \"100%\" }}\n >\n {editor}\n </ScrollArea>\n );\n}\n","import { Box } from \"@chakra-ui/react\";\nimport {\n DecoratorNode,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n type NodeKey,\n type SerializedLexicalNode,\n type Spread,\n} from \"lexical\";\nimport type { ReactElement } from \"react\";\nimport { ResourceBadge } from \"../../../../resource-badge\";\n\nexport type SerializedReferenceLinkNode = Spread<\n {\n href: string;\n label?: string;\n },\n SerializedLexicalNode\n>;\n\nexport class ReferenceLinkNode extends DecoratorNode<ReactElement> {\n __href: string;\n __label?: string;\n\n static getType(): string {\n return \"reference-link\";\n }\n\n static clone(node: ReferenceLinkNode): ReferenceLinkNode {\n return new ReferenceLinkNode(node.__href, node.__label, node.__key);\n }\n\n constructor(href: string, label?: string, key?: NodeKey) {\n super(key);\n this.__href = href;\n this.__label = label;\n }\n\n createDOM(_config: EditorConfig, _editor: LexicalEditor): HTMLElement {\n return document.createElement(\"span\");\n }\n\n updateDOM(_prevNode: ReferenceLinkNode, _dom: HTMLElement, _config: EditorConfig): boolean {\n return false;\n }\n\n getTextContent(): string {\n const label = this.__label ?? this.__href;\n return `{{link('${label}')}}`;\n }\n\n exportJSON(): SerializedReferenceLinkNode {\n return {\n type: ReferenceLinkNode.getType(),\n version: 1,\n href: this.__href,\n label: this.__label,\n };\n }\n\n static importJSON(serializedNode: SerializedReferenceLinkNode): ReferenceLinkNode {\n return $createReferenceLinkNode(serializedNode.href, serializedNode.label);\n }\n\n decorate(_editor: LexicalEditor, _config: EditorConfig): ReactElement {\n const href = this.__href;\n const fileName = href.split(\"/\").pop();\n const label = fileName || \"unknown\";\n const isExternal = /^https?:\\/\\//i.test(href);\n const isProjectFile = /^#?\\$PROJECT\\//i.test(href);\n\n return (\n <Box width=\"fit-content\" display=\"inline-block\">\n <ResourceBadge\n fileName={label}\n onSelect={() => {\n if (isExternal) {\n window.open(href, \"_blank\", \"noopener,noreferrer\");\n } else if (isProjectFile) {\n const projectPath = href.replace(/^#?\\$PROJECT\\//i, \"\");\n const event = new CustomEvent(\"ui:open-project-file\", { detail: projectPath });\n window.dispatchEvent(event);\n } else {\n window.location.assign(href);\n }\n }}\n />\n </Box>\n );\n }\n}\n\nexport function $createReferenceLinkNode(href: string, label?: string): ReferenceLinkNode {\n return new ReferenceLinkNode(href, label);\n}\n\nexport function $isReferenceLinkNode(node: LexicalNode | null | undefined): node is ReferenceLinkNode {\n return node instanceof ReferenceLinkNode;\n}\n","import type { TextMatchTransformer } from \"@lexical/markdown\";\nimport { $createReferenceLinkNode, $isReferenceLinkNode, ReferenceLinkNode } from \"./ReferenceLinkNode\";\n\n// Matches {{link('xxx')}} or {{ link(\"xxx\") }}\nconst LINK_REGEXP = /\\{\\{\\s*link\\((['\"])([^'\"\\s]+)\\1\\)\\s*\\}\\}/;\n\nexport const REFERENCE_LINK_TRANSFORMER: TextMatchTransformer = {\n dependencies: [ReferenceLinkNode],\n export: (node) => {\n if ($isReferenceLinkNode(node)) {\n const href = (node as ReferenceLinkNode).__href;\n const label = (node as ReferenceLinkNode).__label ?? href;\n // Export back to token form so markdown roundtrips\n if (label) {\n return `{{link('${label}')}}`;\n }\n return `{{link('${href}')}}`;\n }\n return null;\n },\n regExp: LINK_REGEXP,\n importRegExp: LINK_REGEXP,\n replace: (textNode, match) => {\n const value = match[2];\n // For now we assume value is both label and href; if it looks like a URL, use as href.\n const looksLikeUrl = /^(https?:\\/\\/|\\/)/i.test(value);\n const href = looksLikeUrl ? value : `#${value}`;\n const label = value;\n textNode.replace($createReferenceLinkNode(href, label));\n },\n type: \"text-match\",\n};\n","import type { EditorThemeClasses } from \"lexical\";\n\nimport \"./rich-text-theme.css\";\n\nconst theme: EditorThemeClasses = {\n code: \"rich-text__code\",\n codeHighlight: {\n atrule: \"rich-text__tokenAttr\",\n attr: \"rich-text__tokenAttr\",\n boolean: \"rich-text__tokenProperty\",\n builtin: \"rich-text__tokenSelector\",\n cdata: \"rich-text__tokenComment\",\n char: \"rich-text__tokenSelector\",\n class: \"rich-text__tokenFunction\",\n \"class-name\": \"rich-text__tokenFunction\",\n comment: \"rich-text__tokenComment\",\n constant: \"rich-text__tokenProperty\",\n deleted: \"rich-text__tokenProperty\",\n doctype: \"rich-text__tokenComment\",\n entity: \"rich-text__tokenOperator\",\n function: \"rich-text__tokenFunction\",\n important: \"rich-text__tokenVariable\",\n inserted: \"rich-text__tokenSelector\",\n keyword: \"rich-text__tokenAttr\",\n namespace: \"rich-text__tokenVariable\",\n number: \"rich-text__tokenProperty\",\n operator: \"rich-text__tokenOperator\",\n prolog: \"rich-text__tokenComment\",\n property: \"rich-text__tokenProperty\",\n punctuation: \"rich-text__tokenPunctuation\",\n regex: \"rich-text__tokenVariable\",\n selector: \"rich-text__tokenSelector\",\n string: \"rich-text__tokenSelector\",\n symbol: \"rich-text__tokenProperty\",\n tag: \"rich-text__tokenProperty\",\n url: \"rich-text__tokenOperator\",\n variable: \"rich-text__tokenVariable\",\n },\n embedBlock: {\n base: \"rich-text__embedBlock\",\n focus: \"rich-text__embedBlockFocus\",\n },\n list: {\n checklist: \"rich-text__checklist\",\n listitem: \"rich-text__listItem\",\n listitemChecked: \"rich-text__listItemChecked\",\n listitemUnchecked: \"rich-text__listItemUnchecked\",\n nested: {\n listitem: \"rich-text__nestedListItem\",\n },\n olDepth: [\"rich-text__ol1\", \"rich-text__ol2\", \"rich-text__ol3\", \"rich-text__ol4\", \"rich-text__ol5\"],\n ol: \"rich-text__ol\",\n ul: \"rich-text__ul\",\n },\n heading: {\n h1: \"rich-text__h1\",\n h2: \"rich-text__h2\",\n h3: \"rich-text__h3\",\n },\n paragraph: \"rich-text__p\",\n text: {\n underline: \"rich-text__textUnderline\",\n italic: \"rich-text__textItalic\",\n code: \"rich-text__textCode\",\n },\n link: \"rich-text__link\",\n quote: \"rich-text__quote\",\n reference: \"rich-text__reference\",\n table: \"rich-text__table\",\n tableCell: \"rich-text__tableCell\",\n tableRow: \"rich-text__tableRow\",\n tableCellHeader: \"rich-text__tableCellHeader\",\n layoutContainer: \"rich-text__layoutContainer\",\n layoutItem: \"rich-text__layoutItem\",\n draggableBlockDemo: {\n row: \"rich-text__row\",\n content: \"rich-text__content\",\n },\n};\n\nexport default theme;\n","import Prism from \"prismjs\";\n\nconst globalScope = globalThis as typeof globalThis & { Prism?: unknown };\n\nglobalScope.Prism ??= Prism;\n\nexport { Prism };\n","import { Box, Table, Text, Textarea } from \"@chakra-ui/react\";\nimport { ScrollArea } from \"@/components/scroll-area\";\nimport type { CodeEditorProps, DataTableProps } from \"../types/rich-text-components\";\n\nconst scaledSmallFontSize = \"calc(var(--chakra-font-sizes-sm) * var(--rich-text-font-scale))\";\n\nconst formatValue = (value: unknown) => {\n if (value === null || value === undefined) return \"-\";\n if (typeof value === \"string\") return value.length ? value : \"-\";\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value).toUpperCase();\n if (value instanceof Date) return value.toISOString();\n return JSON.stringify(value);\n};\n\nexport const DefaultRichTextCodeEditor = (props: CodeEditorProps) => {\n const { defaultCode = \"\", isEditable = false, showLineNumbers = false, disableScroll = false } = props;\n\n if (isEditable) {\n return (\n <Textarea\n defaultValue={defaultCode}\n fontFamily=\"mono\"\n fontSize={scaledSmallFontSize}\n resize=\"vertical\"\n minHeight=\"100%\"\n />\n );\n }\n\n const lines = showLineNumbers ? defaultCode.split(\"\\n\") : [defaultCode];\n\n const codeBlock = (\n <Box\n as=\"pre\"\n margin={0}\n padding=\"sm\"\n fontFamily=\"mono\"\n fontSize={scaledSmallFontSize}\n lineHeight=\"1.5\"\n background=\"bg.code\"\n borderRadius=\"md\"\n width=\"100%\"\n overflowY={disableScroll ? \"hidden\" : undefined}\n >\n {showLineNumbers ? (\n <Box as=\"code\" display=\"grid\" gridTemplateColumns=\"auto 1fr\" columnGap=\"sm\">\n {lines.map((line, index) => (\n <Box as=\"span\" key={`${index}-${line}`} display=\"contents\">\n <Text as=\"span\" color=\"fg.muted\" textAlign=\"right\" fontSize=\"inherit\">\n {index + 1}\n </Text>\n <Text as=\"span\" fontSize=\"inherit\">\n {line.length ? line : \" \"}\n </Text>\n </Box>\n ))}\n </Box>\n ) : (\n <Box as=\"code\">{defaultCode}</Box>\n )}\n </Box>\n );\n\n if (disableScroll) return codeBlock;\n\n return (\n <ScrollArea width=\"100%\" background=\"bg.code\" borderRadius=\"md\" showHorizontalScrollbar>\n {codeBlock}\n </ScrollArea>\n );\n};\n\nexport const DefaultRichTextDataTable = (props: DataTableProps) => {\n const { data, fullWidth = false, noBorder = false, hiddenColumns = [] } = props;\n\n if (!data.length) {\n return (\n <Box padding=\"sm\" borderWidth={noBorder ? \"0\" : \"1px\"} borderColor=\"border.muted\">\n <Text textStyle=\"label/S/regular\" fontSize={scaledSmallFontSize} color=\"fg.muted\">\n No data\n </Text>\n </Box>\n );\n }\n\n const hiddenSet = new Set(hiddenColumns);\n const columns = Object.keys(data[0] ?? {}).filter((key) => !hiddenSet.has(key));\n\n return (\n <ScrollArea maxWidth=\"100%\" showHorizontalScrollbar showVerticalScrollbar={false}>\n <Table.Root\n size=\"sm\"\n width={fullWidth ? \"100%\" : \"fit-content\"}\n borderWidth={noBorder ? \"0\" : \"1px\"}\n borderColor=\"border.muted\"\n >\n <Table.Header>\n <Table.Row background=\"bg.muted\">\n {columns.map((column) => (\n <Table.ColumnHeader key={column} textTransform=\"none\" paddingX=\"xs\" paddingY=\"2xs\">\n <Text textStyle=\"label/S/medium\" fontSize={scaledSmallFontSize}>\n {column}\n </Text>\n </Table.ColumnHeader>\n ))}\n </Table.Row>\n </Table.Header>\n <Table.Body>\n {data.map((row, rowIndex) => (\n <Table.Row key={`${rowIndex}-${columns.join(\"-\")}`}>\n {columns.map((column) => (\n <Table.Cell key={`${rowIndex}-${column}`} paddingX=\"xs\" paddingY=\"2xs\">\n <Text textStyle=\"paragraph/S/regular\" fontSize={scaledSmallFontSize}>\n {formatValue(row[column])}\n </Text>\n </Table.Cell>\n ))}\n </Table.Row>\n ))}\n </Table.Body>\n </Table.Root>\n </ScrollArea>\n );\n};\n","import { DecoratorNode, type NodeKey, type SerializedLexicalNode, type Spread } from \"lexical\";\nimport type React from \"react\";\nimport { DefaultRichTextDataTable } from \"../components/default-rich-text-components\";\nimport type { RowData } from \"../types/rich-text-components\";\n\nexport type { RowData } from \"../types/rich-text-components\";\n\nexport class DataTableNode extends DecoratorNode<React.JSX.Element> {\n __data: RowData[];\n\n static getType() {\n return \"data_table\";\n }\n\n static clone(node: DataTableNode) {\n return new DataTableNode(node.__data, node.__key);\n }\n\n constructor(data: RowData[], key?: NodeKey) {\n super(key);\n this.__data = data;\n }\n\n getData(): RowData[] {\n return this.__data;\n }\n\n createDOM(): HTMLElement {\n return document.createElement(\"div\");\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n decorate() {\n return <DefaultRichTextDataTable fullWidth isReadOnly data={this.__data} />;\n }\n\n exportJSON(): SerializedDataTableNode {\n return {\n type: \"data_table\",\n version: 1,\n data: this.__data,\n };\n }\n\n static importJSON(json: SerializedDataTableNode) {\n return new DataTableNode(json.data);\n }\n\n getTextContent(): string {\n // Convert table data to a readable text representation\n if (!this.__data.length) return \"\";\n\n const headers = Object.keys(this.__data[0]);\n const headerRow = headers.join(\" | \");\n const separator = headers.map(() => \"---\").join(\" | \");\n const dataRows = this.__data.map((row) => headers.map((header) => String(row[header] || \"\")).join(\" | \"));\n\n return [headerRow, separator, ...dataRows].join(\"\\n\");\n }\n}\n\nexport type SerializedDataTableNode = Spread<{ data: RowData[] }, SerializedLexicalNode>;\n\nexport function $createDataTableNode(data: RowData[]) {\n return new DataTableNode(data);\n}\n\nexport function $isDataTableNode(node: unknown): node is DataTableNode {\n return node instanceof DataTableNode;\n}\n","import katex from \"katex\";\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n EditorConfig,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode, type DOMExportOutput } from \"lexical\";\nimport * as React from \"react\";\nimport { Suspense } from \"react\";\n\nconst EquationComponent = React.lazy(() => import(\"./EquationComponent\"));\n\nexport type SerializedEquationNode = Spread<\n {\n equation: string;\n inline: boolean;\n },\n SerializedLexicalNode\n>;\n\nfunction $convertEquationElement(domNode: HTMLElement): null | DOMConversionOutput {\n let equation = domNode.getAttribute(\"data-lexical-equation\");\n const inline = domNode.getAttribute(\"data-lexical-inline\") === \"true\";\n\n // Decode the equation from base64\n equation = atob(equation || \"\");\n\n if (equation) {\n const node = $createEquationNode(equation, inline);\n return { node };\n }\n\n return null;\n}\n\nexport class EquationNode extends DecoratorNode<React.ReactNode> {\n __equation: string;\n __inline: boolean;\n\n static getType(): string {\n return \"equation\";\n }\n\n static clone(node: EquationNode): EquationNode {\n return new EquationNode(node.__equation, node.__inline, node.__key);\n }\n\n constructor(equation: string, inline?: boolean, key?: NodeKey) {\n super(key);\n this.__equation = equation;\n this.__inline = inline ?? false;\n }\n\n static importJSON(serializedNode: SerializedEquationNode): EquationNode {\n return $createEquationNode(serializedNode.equation, serializedNode.inline);\n }\n\n exportJSON(): SerializedEquationNode {\n return {\n equation: this.getEquation(),\n inline: this.__inline,\n type: \"equation\",\n version: 1,\n };\n }\n\n createDOM(_config: EditorConfig): HTMLElement {\n const element = document.createElement(this.__inline ? \"span\" : \"div\");\n\n // EquationNodes should implement `user-action:none` in their CSS to avoid issues with deletion on Android.\n element.className = \"editor-equation\";\n return element;\n }\n\n exportDOM(): DOMExportOutput {\n const element = document.createElement(this.__inline ? \"span\" : \"div\");\n\n // Encode the equation as base64 to avoid issues with special characters\n const equation = btoa(this.__equation);\n element.setAttribute(\"data-lexical-equation\", equation);\n element.setAttribute(\"data-lexical-inline\", `${this.__inline}`);\n katex.render(this.__equation, element, {\n displayMode: !this.__inline, // true === block display //\n errorColor: \"#cc0000\",\n output: \"html\",\n strict: \"warn\",\n throwOnError: false,\n trust: false,\n });\n\n return { element };\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n div: (domNode: HTMLElement) => {\n if (!domNode.hasAttribute(\"data-lexical-equation\")) {\n return null;\n }\n\n return {\n conversion: $convertEquationElement,\n priority: 2,\n };\n },\n span: (domNode: HTMLElement) => {\n if (!domNode.hasAttribute(\"data-lexical-equation\")) {\n return null;\n }\n\n return {\n conversion: $convertEquationElement,\n priority: 1,\n };\n },\n };\n }\n\n updateDOM(prevNode: EquationNode): boolean {\n // If the inline property changes, replace the element\n return this.__inline !== prevNode.__inline;\n }\n\n getTextContent(): string {\n return this.__equation;\n }\n\n getEquation(): string {\n return this.__equation;\n }\n\n setEquation(equation: string): void {\n const writable = this.getWritable();\n writable.__equation = equation;\n }\n\n isInline(): boolean {\n return this.__inline;\n }\n\n decorate() {\n return (\n <Suspense fallback={null}>\n <EquationComponent equation={this.__equation} inline={this.__inline} />\n </Suspense>\n );\n }\n}\n\nexport function $createEquationNode(equation = \"\", inline = false): EquationNode {\n const equationNode = new EquationNode(equation, inline);\n return $applyNodeReplacement(equationNode);\n}\n\nexport function $isEquationNode(node: LexicalNode | null | undefined): node is EquationNode {\n return node instanceof EquationNode;\n}\n","import \"./EquationPlugin.css\";\n\nimport type { MultilineElementTransformer, TextMatchTransformer } from \"@lexical/markdown\";\nimport { $createEquationNode, $isEquationNode, EquationNode } from \"./EquationNode.tsx\";\n\nexport const EQUATION_INLINE: TextMatchTransformer = {\n dependencies: [EquationNode],\n export: (node) => {\n if ($isEquationNode(node) && node.isInline()) {\n return `\\\\( ${node.getEquation().trim()} \\\\)`;\n }\n return null;\n },\n importRegExp: /\\\\\\((.*?)\\\\\\)/,\n regExp: /\\\\\\((.*?)\\\\\\)/,\n replace: (textNode, match) => {\n const equationNode = $createEquationNode(match[1].trim(), true);\n textNode.replace(equationNode);\n },\n type: \"text-match\",\n};\n\nexport const EQUATION_MULTILINE: MultilineElementTransformer = {\n dependencies: [EquationNode],\n regExpStart: /\\\\\\[/,\n regExpEnd: /\\\\]/,\n export: (node) => {\n if ($isEquationNode(node) && !node.isInline()) {\n return `\\\\[ ${node.getEquation().trim()} \\\\]`;\n }\n return null;\n },\n replace: (rootNode, _children, _startMatch, _endMatch, linesInBetween) => {\n if (linesInBetween) {\n rootNode.append($createEquationNode(linesInBetween.join(\" \"), false));\n return true;\n }\n return false;\n },\n type: \"multiline-element\",\n};\n\nexport function EquationPlugin(): null {\n return null;\n}\n","import {\n type EditorConfig,\n ElementNode,\n type LexicalEditor,\n type LexicalNode,\n type SerializedElementNode,\n type Spread,\n} from \"lexical\";\n\nexport type SerializedHRNode = Spread<SerializedElementNode, SerializedElementNode>;\n\nexport class HRNode extends ElementNode {\n static getType() {\n return \"hr\";\n }\n\n static clone(node: HRNode) {\n return new HRNode(node?.__key);\n }\n\n static importJSON(_serializedNode: SerializedHRNode) {\n return $createHRNode();\n }\n\n exportJSON(): SerializedHRNode {\n return {\n ...super.exportJSON(),\n };\n }\n\n createDOM(_config: EditorConfig, _editor: LexicalEditor): HTMLElement {\n const element = document.createElement(\"hr\");\n element.style = \"margin: 2rem 0;\";\n return element;\n }\n\n updateDOM(_prevNode: unknown, _dom: HTMLElement, _config: EditorConfig): boolean {\n return false;\n }\n\n decorate(_editor: LexicalEditor) {\n return null;\n }\n}\n\nexport function $createHRNode(): HRNode {\n return new HRNode();\n}\n\nexport function $isHRNode(node: LexicalNode | null | undefined): node is HRNode {\n return node instanceof HRNode;\n}\n","import type { LexicalNode, NodeKey, SerializedLexicalNode } from \"lexical\";\nimport { $applyNodeReplacement, DecoratorNode } from \"lexical\";\nimport type { ReactNode } from \"react\";\nimport { lazy, Suspense } from \"react\";\n\nconst MermaidComponent = lazy(() => import(\"./MermaidComponent\"));\n\nexport interface SerializedMermaidNode extends SerializedLexicalNode {\n type: \"mermaid\";\n code: string;\n version: 1;\n}\n\nexport class MermaidNode extends DecoratorNode<ReactNode> {\n __code: string;\n\n static getType() {\n return \"mermaid\";\n }\n\n static clone(node: MermaidNode) {\n return new MermaidNode(node.__code, node.__key);\n }\n\n constructor(code: string, key?: NodeKey) {\n super(key);\n this.__code = code;\n }\n\n createDOM() {\n return document.createElement(\"div\");\n }\n\n updateDOM() {\n return false;\n }\n\n static importJSON(serializedNode: SerializedMermaidNode): MermaidNode {\n return new MermaidNode(serializedNode.code);\n }\n\n exportJSON(): SerializedMermaidNode {\n return {\n type: \"mermaid\",\n code: this.__code,\n version: 1,\n };\n }\n\n getTextContent() {\n return `\\`\\`\\`mermaid\\n${this.__code}\\n\\`\\`\\``;\n }\n\n getCode() {\n return this.__code;\n }\n\n setCode(code: string) {\n const writable = this.getWritable();\n writable.__code = code;\n }\n\n decorate() {\n return (\n <Suspense fallback={null}>\n <MermaidComponent code={this.__code} nodeKey={this.__key} />\n </Suspense>\n );\n }\n}\n\nexport function $createMermaidNode(code = \"\") {\n const mermaidNode = new MermaidNode(code);\n return $applyNodeReplacement(mermaidNode);\n}\n\nexport function $isMermaidNode(node: LexicalNode | null | undefined): node is MermaidNode {\n return node instanceof MermaidNode;\n}\n","import type { ElementTransformer } from \"@lexical/markdown\";\nimport type { LexicalNode } from \"lexical\";\nimport { $createHRNode, $isHRNode, HRNode } from \"./HorizontalRuleNode\";\n\nexport const HR: ElementTransformer = {\n dependencies: [HRNode],\n export: (node: LexicalNode) => {\n return $isHRNode(node) ? \"***\" : null;\n },\n regExp: /^(---|\\*\\*\\*|___)\\s?$/,\n replace: (parentNode) => {\n const line = $createHRNode();\n parentNode.replace(line);\n },\n type: \"element\",\n};\n","import {\n $createAutoLinkNode,\n $createLinkNode,\n $isAutoLinkNode,\n $isLinkNode,\n AutoLinkNode,\n LinkNode,\n} from \"@lexical/link\";\nimport type { ElementTransformer, TextMatchTransformer } from \"@lexical/markdown\";\nimport { $createTextNode, TextNode } from \"lexical\";\nimport { $createDataTableNode, $isDataTableNode, type RowData } from \"../nodes/DataTableNode\";\nimport { HR } from \"../plugins/HorizontalRulePlugin/horizontalRule\";\n\nexport const TABLE: ElementTransformer = {\n dependencies: [],\n export: (node, _traverseChildren) => {\n if ($isDataTableNode(node)) {\n const data = node.getData();\n\n if (!data.length) return \"\";\n\n const headers = Object.keys(data[0]);\n const headerRow = headers.join(\" | \");\n const separator = headers.map(() => \"---\").join(\" | \");\n const dataRows = data.map((row) => headers.map((header) => String(row[header] || \"\")).join(\" | \"));\n\n return [`| ${headerRow} |`, `| ${separator} |`, ...dataRows.map((row) => `| ${row} |`)].join(\"\\n\");\n }\n\n return null;\n },\n regExp: /^\\s*(\\|.+\\|)\\s*$/,\n replace: (parentNode, _children, match, _isImport) => {\n const previousNode = parentNode.getPreviousSibling();\n const isTableDelimiter = /^\\|?\\s*:?-{3,}:?\\s*(?:\\|\\s*:?-{3,}:?\\s*)*\\|?$/gm.test(match[0]);\n\n // if it is a delimiter, remove it\n if (isTableDelimiter) {\n parentNode.remove();\n return;\n }\n\n // Parse current row\n const cells = match[0]\n .split(\"|\")\n .slice(1, -1)\n .map((cell) => cell.trim());\n\n if (previousNode?.getType() === \"data_table\" && $isDataTableNode(previousNode)) {\n // Add row to existing table\n const existingData = previousNode.getData();\n const newRow: RowData = {};\n\n // Check if we have a placeholder row with empty values (created from headers)\n const isPlaceholderRow =\n existingData.length === 1 && Object.values(existingData[0]).every((value) => value === \"\");\n\n // Get headers from existing data structure\n const headers = existingData.length > 0 ? Object.keys(existingData[0]) : cells.map((_, index) => `col_${index}`);\n\n cells.forEach((cell, index) => {\n const header = headers[index] || `col_${index}`;\n newRow[header] = cell;\n });\n\n // If we had a placeholder row, replace it; otherwise append\n const newTableData = isPlaceholderRow ? [newRow] : [...existingData, newRow];\n const newTableNode = $createDataTableNode(newTableData);\n previousNode.replace(newTableNode);\n parentNode.remove();\n } else {\n // Create new table - treat first row as headers\n // Create a temporary empty row with these headers, which will be replaced when actual data comes\n const newRow: RowData = {};\n cells.forEach((cell, index) => {\n newRow[cell || `col_${index}`] = \"\";\n });\n\n const tableNode = $createDataTableNode([newRow]);\n parentNode.replace(tableNode);\n }\n },\n type: \"element\",\n};\n\nexport const UNDERLINE_INS_TAG: TextMatchTransformer = {\n dependencies: [TextNode],\n export: (node, _children) => {\n if (node instanceof TextNode) {\n let markdownText = node.getTextContent();\n\n if (node.hasFormat(\"bold\")) {\n markdownText = `**${markdownText}**`;\n } else if (node.hasFormat(\"italic\")) {\n markdownText = `*${markdownText}*`;\n } else if (node.hasFormat(\"underline\")) {\n markdownText = `<ins>${markdownText}</ins>`;\n } else {\n return null;\n }\n\n return markdownText;\n }\n return null;\n },\n regExp: /<ins>(.*)<\\/ins>/,\n importRegExp: /<ins>(.*)<\\/ins>/,\n replace: (node, match) => {\n const textNode = $createTextNode(match[1]);\n textNode.toggleFormat(\"underline\");\n node.replace(textNode);\n },\n type: \"text-match\",\n};\n\nexport const UNDERLINE_U_TAG: TextMatchTransformer = {\n dependencies: [TextNode],\n export: (_node, _children) => {\n return null;\n },\n regExp: /<u>(.*)<\\/u>/,\n importRegExp: /<u>(.*)<\\/u>/,\n replace: (node, match) => {\n const textNode = $createTextNode(match[1]);\n textNode.toggleFormat(\"underline\");\n node.replace(textNode);\n },\n type: \"text-match\",\n};\n\nconst BARE_URL_REGEXP = /https?:\\/\\/[^\\s<>\"']*[^\\s<>\"'.,:;\"')\\]}]/;\n\n// Strip markdown character escapes that may have leaked into a URL, e.g.\n// `https://example.com/foo\\_bar` -> `https://example.com/foo_bar`.\n// Without this, repeated save/reopen cycles would accumulate backslashes\n// because the URL is stored as both text content and href.\nconst unescapeUrl = (url: string) => url.replace(/\\\\([*_`~\\\\])/g, \"$1\");\n\nconst escapeLinkTitle = (title: string) => title.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n\nconst unescapeLinkTitle = (title: string | undefined) => title?.replace(/\\\\([\"\\\\])/g, \"$1\");\n\nconst normalizeEscapedUrlText = (textContent: string, href: string, exportedText: string) => {\n if (textContent !== href) {\n return exportedText;\n }\n\n const escapedHref = href.replace(/([*_`~\\\\])/g, \"\\\\$1\");\n\n return exportedText.replace(escapedHref, href);\n};\n\nexport const LINK: TextMatchTransformer = {\n dependencies: [LinkNode],\n export: (node, exportChildren) => {\n if (!$isLinkNode(node) || $isAutoLinkNode(node)) {\n return null;\n }\n\n const title = node.getTitle();\n const href = unescapeUrl(node.getURL());\n const textContent = normalizeEscapedUrlText(node.getTextContent(), href, exportChildren(node));\n\n return title != null ? `[${textContent}](${href} \"${escapeLinkTitle(title)}\")` : `[${textContent}](${href})`;\n },\n importRegExp: /(?:\\[(.+?)\\])(?:\\((?:([^()\\s]+)(?:\\s\"((?:[^\"]*\\\\\")*[^\"]*)\"\\s*)?)\\))/,\n regExp: /(?:\\[(.+?)\\])(?:\\((?:([^()\\s]+)(?:\\s\"((?:[^\"]*\\\\\")*[^\"]*)\"\\s*)?)\\))$/,\n replace: (textNode, match) => {\n const [, linkText, linkUrl, linkTitle] = match;\n const href = unescapeUrl(linkUrl);\n const linkNode = $createLinkNode(href, { title: unescapeLinkTitle(linkTitle) });\n const openBracketAmount = linkText.split(\"[\").length - 1;\n const closeBracketAmount = linkText.split(\"]\").length - 1;\n let parsedLinkText = linkText;\n let outsideLinkText = \"\";\n\n if (openBracketAmount < closeBracketAmount) {\n return;\n }\n\n if (openBracketAmount > closeBracketAmount) {\n const linkTextParts = linkText.split(\"[\");\n outsideLinkText = `[${linkTextParts[0]}`;\n parsedLinkText = linkTextParts.slice(1).join(\"[\");\n }\n\n const normalizedLinkText = unescapeUrl(parsedLinkText);\n const linkTextNode = $createTextNode(normalizedLinkText === href ? href : normalizedLinkText);\n\n linkTextNode.setFormat(textNode.getFormat());\n linkNode.append(linkTextNode);\n textNode.replace(linkNode);\n\n if (outsideLinkText) {\n linkNode.insertBefore($createTextNode(outsideLinkText));\n }\n\n return linkTextNode;\n },\n trigger: \")\",\n type: \"text-match\",\n};\n\nexport const BARE_URL: TextMatchTransformer = {\n dependencies: [AutoLinkNode],\n export: (node, exportChildren) => {\n if (!$isAutoLinkNode(node)) {\n return null;\n }\n\n const href = unescapeUrl(node.getURL());\n\n return normalizeEscapedUrlText(node.getTextContent(), href, exportChildren(node));\n },\n regExp: BARE_URL_REGEXP,\n importRegExp: BARE_URL_REGEXP,\n replace: (textNode, match) => {\n const href = unescapeUrl(match[0]);\n const autoLinkNode = $createAutoLinkNode(href);\n const linkTextNode = $createTextNode(href);\n\n linkTextNode.setFormat(textNode.getFormat());\n autoLinkNode.append(linkTextNode);\n textNode.replace(autoLinkNode);\n },\n type: \"text-match\",\n};\n\nexport const TRANSFORMERS_EXTENDED = [TABLE, HR, UNDERLINE_INS_TAG, UNDERLINE_U_TAG, LINK, BARE_URL];\n","import { AutoLinkNode, LinkNode } from \"@lexical/link\";\nimport { ListItemNode, ListNode } from \"@lexical/list\";\nimport { CHECK_LIST, LINK as LEXICAL_LINK, TRANSFORMERS } from \"@lexical/markdown\";\nimport { HeadingNode, QuoteNode } from \"@lexical/rich-text\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { REFERENCE_LINK_TRANSFORMER, ReferenceLinkNode } from \"../markdown-editor/plugins/ReferenceLinkPlugin\";\nimport theme from \"../theme/rich-text-theme\";\nimport { CodeHighlightNode, CodeNode } from \"./lexical-code\";\nimport { DataTableNode } from \"./nodes/DataTableNode\";\nimport { EquationNode } from \"./plugins/EquationPlugin/EquationNode\";\nimport { EQUATION_INLINE, EQUATION_MULTILINE } from \"./plugins/EquationPlugin/EquationPlugin\";\nimport { HRNode } from \"./plugins/HorizontalRulePlugin/HorizontalRuleNode\";\nimport { MermaidNode } from \"./plugins/MermaidPlugin/MermaidNode\";\nimport { TRANSFORMERS_EXTENDED } from \"./transformers/markdown-transformers\";\n\nexport const editorNodes: Array<Klass<LexicalNode>> = [\n QuoteNode,\n LinkNode,\n AutoLinkNode,\n DataTableNode,\n HeadingNode,\n ListNode,\n ListItemNode,\n CodeNode,\n CodeHighlightNode,\n MermaidNode,\n EquationNode,\n HRNode,\n ReferenceLinkNode,\n];\n\nexport const baseEditorTransformers = [\n CHECK_LIST,\n ...TRANSFORMERS.filter((transformer) => transformer !== LEXICAL_LINK),\n ...TRANSFORMERS_EXTENDED,\n EQUATION_INLINE,\n EQUATION_MULTILINE,\n];\n\nexport const editorTransformers = [...baseEditorTransformers, REFERENCE_LINK_TRANSFORMER];\n\nexport const editorTheme = theme;\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { $nodesOfType } from \"lexical\";\nimport { useEffect } from \"react\";\nimport { CodeNode } from \"../../lexical-code\";\nimport { MermaidNode } from \"../MermaidPlugin/MermaidNode\";\n\nfunction isMermaidLanguage(language: string) {\n return language.trim().toLowerCase() === \"mermaid\";\n}\n\nexport function replaceCodeNodeWithMermaidNode(node: CodeNode) {\n const language = node.getLanguage() ?? \"plaintext\";\n if (!isMermaidLanguage(language)) {\n return false;\n }\n\n node.replace(new MermaidNode(node.getTextContent()));\n return true;\n}\n\nexport function ImportCodeBlocksPlugin() {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n editor.update(() => {\n const codeNodes = $nodesOfType(CodeNode);\n for (const n of codeNodes) {\n replaceCodeNodeWithMermaidNode(n);\n }\n });\n }, [editor]);\n\n return null;\n}\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useEffect } from \"react\";\nimport { registerCodeHighlighting } from \"../../lexical-code\";\n\nexport function CodeHighlightingPlugin() {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n return registerCodeHighlighting(editor);\n }, [editor]);\n\n return null;\n}\n","import { createCommand, type LexicalCommand } from \"lexical\";\n\nexport const TOGGLE_LINK_EDIT_MODE_COMMAND: LexicalCommand<boolean> = createCommand(\"TOGGLE_LINK_EDIT_MODE_COMMAND\");\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useEffect } from \"react\";\n\nexport default function ToggleEditablePlugin({ isEditable }: { isEditable: boolean }) {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n editor.setEditable(isEditable);\n }, [isEditable, editor]);\n\n return null;\n}\n","import { Box } from \"@chakra-ui/react\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { TreeView } from \"@lexical/react/LexicalTreeView\";\n\nexport function TreeViewPlugin() {\n const [editor] = useLexicalComposerContext();\n return (\n <Box fontSize=\"xs\" color=\"fg.muted\" padding=\"4\">\n <TreeView\n treeTypeButtonClassName=\"debug-treetype-button\"\n timeTravelButtonClassName=\"debug-timetravel-button\"\n timeTravelPanelButtonClassName=\"debug-timetravel-button\"\n timeTravelPanelClassName=\"debug-timetravel-panel\"\n timeTravelPanelSliderClassName=\"debug-timetravel-slider\"\n viewClassName=\"tree-view-output\"\n editor={editor}\n />\n </Box>\n );\n}\n","const FRONTMATTER_PATTERN = /^---\\s*\\n([\\s\\S]*?)\\n---\\s*(?:\\n|$)/;\n\nconst FENCE_PATTERN = /^```/;\nconst LIST_ITEM_PATTERN = /^([ \\t]*)((?:[-*+])|(?:\\d+\\.))\\s+/;\nconst INDENTED_LINE_PATTERN = /^([ \\t]+)/;\n\ninterface ActiveListIndent {\n normalizedIndentWidth: number;\n sourceIndentWidth: number;\n}\n\ninterface MarkdownListState {\n isInCodeFence: boolean;\n activeListIndents: ActiveListIndent[];\n}\n\nfunction getExpandedIndentWidth(indent: string) {\n let width = 0;\n\n for (const char of indent) {\n width += char === \"\\t\" ? 4 : 1;\n }\n\n return width;\n}\n\nfunction findParentIndent(activeListIndents: ActiveListIndent[], sourceIndentWidth: number) {\n return [...activeListIndents].reverse().find((indent) => indent.sourceIndentWidth < sourceIndentWidth);\n}\n\nfunction toNormalizedIndent(indent: string, normalizedWidth: number, sourceWidth: number) {\n if (normalizedWidth === sourceWidth && !indent.includes(\"\\t\")) return indent;\n return \" \".repeat(normalizedWidth);\n}\n\nfunction normalizeIndentedContinuation(line: string, activeListIndents: ActiveListIndent[]) {\n const indentedLineMatch = line.match(INDENTED_LINE_PATTERN);\n if (!indentedLineMatch) {\n if (line.trim() !== \"\") {\n activeListIndents.length = 0;\n }\n\n return line;\n }\n\n const sourceIndentWidth = getExpandedIndentWidth(indentedLineMatch[1]);\n const parentLevel = findParentIndent(activeListIndents, sourceIndentWidth);\n if (!parentLevel) return line;\n\n const normalizedIndentWidth = sourceIndentWidth + (parentLevel.normalizedIndentWidth - parentLevel.sourceIndentWidth);\n const normalizedIndent = toNormalizedIndent(indentedLineMatch[1], normalizedIndentWidth, sourceIndentWidth);\n\n if (normalizedIndent === indentedLineMatch[1]) return line;\n\n return `${normalizedIndent}${line.slice(indentedLineMatch[1].length)}`;\n}\n\nfunction normalizeListItem(line: string, match: RegExpMatchArray, activeListIndents: ActiveListIndent[]) {\n const sourceIndentWidth = getExpandedIndentWidth(match[1]);\n\n while (activeListIndents.length && activeListIndents.at(-1)!.sourceIndentWidth > sourceIndentWidth) {\n activeListIndents.pop();\n }\n\n const currentLevel = activeListIndents.at(-1);\n if (currentLevel?.sourceIndentWidth === sourceIndentWidth) {\n return `${toNormalizedIndent(match[1], currentLevel.normalizedIndentWidth, sourceIndentWidth)}${line.slice(match[1].length)}`;\n }\n\n const parentLevel = activeListIndents.at(-1);\n const indentStep = sourceIndentWidth - (parentLevel?.sourceIndentWidth ?? 0);\n let normalizedIndentWidth = sourceIndentWidth;\n\n if (parentLevel && indentStep === 2 && !match[1].includes(\"\\t\")) {\n normalizedIndentWidth = parentLevel.normalizedIndentWidth + 4;\n }\n\n activeListIndents.push({ normalizedIndentWidth, sourceIndentWidth });\n\n return `${toNormalizedIndent(match[1], normalizedIndentWidth, sourceIndentWidth)}${line.slice(match[1].length)}`;\n}\n\nfunction normalizeMarkdownLine(line: string, state: MarkdownListState) {\n if (FENCE_PATTERN.test(line.trimStart())) {\n state.isInCodeFence = !state.isInCodeFence;\n return line;\n }\n\n if (state.isInCodeFence) return line;\n\n const match = line.match(LIST_ITEM_PATTERN);\n if (!match) return normalizeIndentedContinuation(line, state.activeListIndents);\n\n return normalizeListItem(line, match, state.activeListIndents);\n}\n\nexport function normalizeMarkdownListIndentation(content: string) {\n const lines = content.split(\"\\n\");\n const state: MarkdownListState = { isInCodeFence: false, activeListIndents: [] };\n\n return lines.map((line) => normalizeMarkdownLine(line, state)).join(\"\\n\");\n}\n\nexport function splitFrontmatter(content: string) {\n const match = content.match(FRONTMATTER_PATTERN);\n if (!match) {\n return { frontmatter: \"\", body: content };\n }\n return {\n frontmatter: match[0],\n body: content.slice(match[0].length),\n };\n}\n","export const FOCUS_EDITOR = \"FOCUS_EDITOR\";\nexport const UPLOAD_FILE = \"UPLOAD_FILE\";\nexport const OPEN_CONTEXT = \"OPEN_CONTEXT\";\nexport const DROP_EVENT = \"DROP_EVENT\";\n\n// prompt actions\nexport const RUN_PROMPT = \"RUN_PROMPT\";\nexport const UPDATE_FORMAT = \"UPDATE_FORMAT\";\nexport const UPDATE_BEHAVIOR = \"UPDATE_BEHAVIOR\";\nexport const INSERT_PROMPT = \"INSERT_PROMPT\";\nexport const RENAME_PROMPT = \"RENAME_PROMPT\";\nexport const DUPLICATE_PROMPT = \"DUPLICATE_PROMPT\";\nexport const DELETE_PROMPT = \"DELETE_PROMPT\";\n\n// reference actions\nexport const DELETE_REFERENCES = \"DELETE_REFERENCES\";\nexport const RENAME_REFERENCES = \"RENAME_REFERENCES\";\nexport const INSERT_REFERENCE = \"INSERT_REFERENCE\";\n\n// block actions\nexport const INSERT_BLOCK = \"INSERT_BLOCK\";\n","import { createCommand } from \"lexical\";\nimport {\n DELETE_PROMPT,\n DELETE_REFERENCES,\n DUPLICATE_PROMPT,\n INSERT_BLOCK,\n INSERT_PROMPT,\n INSERT_REFERENCE,\n OPEN_CONTEXT,\n RENAME_PROMPT,\n RENAME_REFERENCES,\n RUN_PROMPT,\n UPDATE_BEHAVIOR,\n UPDATE_FORMAT,\n UPLOAD_FILE,\n} from \"./events\";\n\nexport const UPLOAD_FILE_COMMAND = createCommand(UPLOAD_FILE);\nexport const OPEN_CONTEXT_COMMAND = createCommand(OPEN_CONTEXT);\n\n// prompt actions\nexport const RUN_PROMPT_COMMAND = createCommand(RUN_PROMPT);\nexport const UPDATE_FORMAT_COMMAND = createCommand(UPDATE_FORMAT);\nexport const UPDATE_BEHAVIOR_COMMAND = createCommand(UPDATE_BEHAVIOR);\nexport const INSERT_PROMPT_COMMAND = createCommand(INSERT_PROMPT);\nexport const RENAME_PROMPT_COMMAND = createCommand(RENAME_PROMPT);\nexport const DUPLICATE_PROMPT_COMMAND = createCommand(DUPLICATE_PROMPT);\nexport const DELETE_PROMPT_COMMAND = createCommand(DELETE_PROMPT);\n\n// reference actions\nexport const DELETE_REFERENCES_COMMAND = createCommand(DELETE_REFERENCES);\nexport const RENAME_REFERENCES_COMMAND = createCommand(RENAME_REFERENCES);\nexport const INSERT_REFERENCE_COMMAND = createCommand(INSERT_REFERENCE);\n\n// block actions\nexport const INSERT_BLOCK_COMMAND = createCommand(INSERT_BLOCK);\n\n// placeholder actions\nexport const INSERT_NEW_FILE_PLACEHOLDER = \"INSERT_NEW_FILE_PLACEHOLDER\";\nexport const INSERT_NEW_TEXT_PLACEHOLDER = \"INSERT_NEW_TEXT_PLACEHOLDER\";\nexport const INSERT_PLACEHOLDER_REFERENCE = \"INSERT_PLACEHOLDER_REFERENCE\";\nexport const INSERT_NEW_FILE_PLACEHOLDER_COMMAND = createCommand(INSERT_NEW_FILE_PLACEHOLDER);\nexport const INSERT_NEW_TEXT_PLACEHOLDER_COMMAND = createCommand(INSERT_NEW_TEXT_PLACEHOLDER);\nexport const INSERT_PLACEHOLDER_REFERENCE_COMMAND = createCommand(INSERT_PLACEHOLDER_REFERENCE);\n","import { addClassNamesToElement } from \"@lexical/utils\";\nimport {\n $createParagraphNode,\n type DOMConversionMap,\n type DOMConversionOutput,\n type DOMExportOutput,\n type EditorConfig,\n type ElementFormatType,\n ElementNode,\n isHTMLElement,\n type LexicalEditor,\n type LexicalNode,\n type ParagraphNode,\n type RangeSelection,\n type SerializedElementNode,\n} from \"lexical\";\n\nexport type SerializedCommentNode = SerializedElementNode;\n\nfunction convertCommentElement(element: HTMLElement): DOMConversionOutput {\n const node = $createCommentNode();\n if (element.style !== null) {\n node.setFormat(element.style.textAlign as ElementFormatType);\n }\n return { node };\n}\n\nexport class CommentNode extends ElementNode {\n static getType(): string {\n return \"comment\";\n }\n\n static clone(node: CommentNode): CommentNode {\n return new CommentNode(node.__key);\n }\n\n createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement(\"blockquote\");\n addClassNamesToElement(element, config.theme.comment);\n return element;\n }\n\n updateDOM(): boolean {\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n blockquote: () => ({\n conversion: convertCommentElement,\n priority: 0,\n }),\n };\n }\n\n exportDOM(editor: LexicalEditor): DOMExportOutput {\n const { element } = super.exportDOM(editor);\n\n if (element && isHTMLElement(element)) {\n if (this.isEmpty()) {\n element.append(document.createElement(\"br\"));\n }\n\n const formatType = this.getFormatType();\n element.style.textAlign = formatType;\n\n const direction = this.getDirection();\n if (direction) {\n element.dir = direction;\n }\n }\n\n return {\n element,\n };\n }\n\n static importJSON(serializedNode: SerializedCommentNode): CommentNode {\n const node = $createCommentNode();\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n return node;\n }\n\n exportJSON(): SerializedElementNode {\n return {\n ...super.exportJSON(),\n type: \"comment\",\n };\n }\n\n getTextContent(): string {\n const originalText = super.getTextContent();\n // escape { and } symbols\n const withEscapedReferences = originalText.replace(/([{}])/g, \"\\\\$1\");\n return `{{! ${withEscapedReferences} }}`;\n }\n\n // mutation\n\n insertNewAfter(_: RangeSelection, restoreSelection?: boolean): ParagraphNode {\n const newBlock = $createParagraphNode();\n const direction = this.getDirection();\n newBlock.setDirection(direction);\n this.insertAfter(newBlock, restoreSelection);\n return newBlock;\n }\n\n collapseAtStart(): true {\n const paragraph = $createParagraphNode();\n const children = this.getChildren();\n children.forEach((child) => {\n paragraph.append(child);\n });\n this.replace(paragraph);\n return true;\n }\n}\n\nexport function $createCommentNode(): CommentNode {\n return new CommentNode();\n}\n\nexport function $isCommentNode(node: LexicalNode | null | undefined): node is CommentNode {\n return node instanceof CommentNode;\n}\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { $setBlocksType } from \"@lexical/selection\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW, type TextNode } from \"lexical\";\nimport { useEffect } from \"react\";\nimport { INSERT_BLOCK_COMMAND } from \"../../../commands\";\nimport { $createCommentNode } from \"../nodes/CommentNode/CommentNode\";\n\nexport const insertCommentBlock = (_blockType: string, nodeToReplace?: TextNode) => {\n const selection = $getSelection();\n const commentNode = $createCommentNode();\n\n if (nodeToReplace) {\n const nodeParent = nodeToReplace.getParent();\n nodeParent?.replace(commentNode, true);\n nodeToReplace.remove();\n commentNode.selectEnd();\n return;\n }\n\n if ($isRangeSelection(selection)) {\n $setBlocksType(selection, $createCommentNode);\n }\n};\n\ntype InsertBlockEvent = {\n optionId: string;\n nodeToReplace?: TextNode;\n};\n\nexport function useCommentCommands(): null {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n INSERT_BLOCK_COMMAND,\n (event: InsertBlockEvent) => {\n const { optionId, nodeToReplace } = event;\n insertCommentBlock(optionId, nodeToReplace);\n return false;\n },\n COMMAND_PRIORITY_LOW,\n ),\n );\n }, [editor]);\n\n return null;\n}\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { $createParagraphNode } from \"lexical\";\nimport { useEffect } from \"react\";\nimport { CommentNode } from \"../nodes/CommentNode/CommentNode\";\n\nexport const useCommentSchema = () => {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n return mergeRegister(\n editor.registerNodeTransform(CommentNode, (node) => {\n const children = node.getChildren();\n\n /**\n * Comment nodes cannot have other comments as children\n */\n const invalidChildren = children.filter((child) => child.getType() === \"comment\");\n\n if (invalidChildren.length > 0) {\n editor.update(() => {\n invalidChildren.forEach((child) => {\n child.replace($createParagraphNode(), true);\n });\n });\n }\n }),\n );\n }, [editor]);\n};\n","import { useCommentCommands } from \"./hooks/useCommentCommands\";\nimport { useCommentSchema } from \"./hooks/useCommentSchema\";\n\nexport function CommentPlugin(): null {\n useCommentSchema();\n useCommentCommands();\n return null;\n}\n","import { $getRoot, $isElementNode, ElementNode, type Klass, type LexicalNode, type RootNode } from \"lexical\";\n\nexport function $getAllNodesOfType<T extends LexicalNode>(nodeType: Klass<T>) {\n const root = $getRoot();\n const nodesOfType: T[] = [];\n\n const traverse = (node: LexicalNode) => {\n if (node instanceof nodeType) {\n nodesOfType.push(node as T);\n }\n if (node instanceof ElementNode) {\n node.getChildren?.().forEach(traverse);\n }\n };\n\n traverse(root);\n return nodesOfType;\n}\n\nexport const $getTextContent = (root: RootNode) => {\n let textContent = \"\";\n const children = root.getChildren();\n const childrenLength = children.length;\n for (let i = 0; i < childrenLength; i++) {\n const child = children[i];\n textContent += child.getTextContent();\n if ($isElementNode(child) && i !== childrenLength - 1 && !child.isInline()) {\n textContent += \"\\n\";\n }\n }\n return textContent;\n};\n\ntype SerializedNode = {\n type?: string;\n text?: string;\n name?: string;\n referenceId?: string;\n children?: SerializedNode[];\n};\n\ntype SerializedRoot = {\n root?: SerializedNode;\n};\n\nconst getReferenceMarker = (node: SerializedNode) => {\n if (node.type !== \"reference\") return null;\n return `#${node.name ?? node.referenceId ?? \"\"}`;\n};\n\nconst shouldAppendParagraphBreak = (node: SerializedNode) => {\n return node.type === \"paragraph\" && Boolean(node.children?.length);\n};\n\nconst traverseSerializedNode = (node: SerializedNode): string => {\n if (node.type === \"comment\") {\n return \"\";\n }\n\n const referenceMarker = getReferenceMarker(node);\n if (referenceMarker !== null) {\n return referenceMarker;\n }\n\n let text = typeof node.text === \"string\" ? node.text : \"\";\n const children = node.children;\n if (!Array.isArray(children)) return text;\n\n const childrenLength = children.length;\n for (let i = 0; i < childrenLength; i += 1) {\n const child = children[i];\n if (child.type === \"comment\") {\n if (i !== childrenLength - 1) {\n text += \"\\n\";\n }\n continue;\n }\n\n text += traverseSerializedNode(child);\n if (shouldAppendParagraphBreak(child)) {\n text += \"\\n\";\n }\n }\n\n return text;\n};\n\nexport const getTextFromSerializedEditorState = (state: string): string => {\n try {\n const parsed = JSON.parse(state) as SerializedRoot;\n return traverseSerializedNode(parsed.root ?? {});\n } catch {\n return \"\";\n }\n};\n\nexport const emptyEditorState = {\n root: {\n direction: \"ltr\",\n format: \"\",\n indent: 0,\n type: \"root\",\n version: 1,\n children: [\n {\n type: \"paragraph\",\n version: 1,\n format: \"\",\n indent: 0,\n textFormat: undefined,\n direction: null,\n children: [],\n },\n ],\n },\n};\n\nexport function generateEditorStateFromString(input = \"\") {\n if (!input.trim()) {\n return JSON.parse(JSON.stringify(emptyEditorState));\n }\n\n // Split on line breaks → one paragraph per line\n const paragraphs = input.split(/\\r?\\n/);\n\n const children = paragraphs.map((line) => ({\n type: \"paragraph\",\n version: 1,\n format: \"\",\n indent: 0,\n textFormat: undefined,\n direction: null,\n children: line\n ? [\n {\n type: \"text\",\n version: 1,\n text: line,\n format: \"\",\n detail: 0,\n mode: \"normal\",\n style: \"\",\n },\n ]\n : [],\n }));\n\n return {\n root: {\n direction: \"ltr\",\n format: \"\",\n indent: 0,\n type: \"root\",\n version: 1,\n children,\n },\n };\n}\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useImperativeHandle } from \"react\";\nimport { generateEditorStateFromString, getTextFromSerializedEditorState } from \"../utils\";\n\nexport interface PromptEditorRef {\n setEditorValue: (value: string) => void;\n}\n\nexport function ImperativeAPIPlugin({\n editorRef,\n previousTextRef,\n}: {\n editorRef: React.ForwardedRef<PromptEditorRef>;\n previousTextRef: React.MutableRefObject<string>;\n}) {\n const [editor] = useLexicalComposerContext();\n\n useImperativeHandle(\n editorRef,\n () => ({\n setEditorValue: (value: string) => {\n const state = editor.parseEditorState(JSON.stringify(generateEditorStateFromString(value)));\n editor.setEditorState(state);\n previousTextRef.current = getTextFromSerializedEditorState(value);\n editor.focus(undefined, { defaultSelection: \"rootEnd\" });\n },\n }),\n [editor, previousTextRef],\n );\n\n return null;\n}\n","type KeyDownLikeEvent = {\n key: string;\n ctrlKey: boolean;\n metaKey: boolean;\n shiftKey: boolean;\n altKey: boolean;\n};\n\nexport const shouldSubmitOnEnter = (event: KeyDownLikeEvent) => {\n if (event.key !== \"Enter\") return false;\n\n return !event.ctrlKey && !event.metaKey && !event.shiftKey && !event.altKey;\n};\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { COMMAND_PRIORITY_HIGH, KEY_DOWN_COMMAND } from \"lexical\";\nimport { useEffect } from \"react\";\nimport { shouldSubmitOnEnter } from \"./keyboard-shortcuts\";\n\nexport interface KeyboardShortcutPluginProps {\n onSubmit?: () => void;\n}\n\nexport function KeyboardShortcutPlugin({ onSubmit }: KeyboardShortcutPluginProps) {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n return editor.registerCommand(\n KEY_DOWN_COMMAND,\n (event: KeyboardEvent) => {\n if (shouldSubmitOnEnter(event)) {\n event.preventDefault();\n onSubmit?.();\n return true;\n }\n\n return false;\n },\n COMMAND_PRIORITY_HIGH,\n );\n }, [editor, onSubmit]);\n\n return null;\n}\n","import type { MenuOptionGroup } from \"./ReferenceMenuOption\";\n\nexport const menuSortOrder: MenuOptionGroup[] = [\"table\", \"connector\"];\n","import { menuSortOrder } from \"../constants\";\nimport type { MenuOptionGroup, ReferenceMenuOption } from \"../ReferenceMenuOption\";\n\nexport const getSortedMenuOptions = (options: ReferenceMenuOption[]) => {\n const sortedOptions = options\n .sort((a, b) => menuSortOrder.indexOf(a.group) - menuSortOrder.indexOf(b.group))\n .map((option, index) => ({ ...option, index }) as ReferenceMenuOption);\n\n const groupedOptions = sortedOptions.reduce(\n (acc, option) => {\n const bucket = acc[option.group] ?? [];\n bucket.push(option);\n acc[option.group] = bucket;\n return acc;\n },\n {} as Record<MenuOptionGroup, ReferenceMenuOption[]>,\n );\n\n return groupedOptions;\n};\n","import { Flex, Text, Tooltip } from \"@chakra-ui/react\";\n\ninterface ReferenceMenuItemProps {\n id: string;\n isSelected: boolean;\n onClick: () => void;\n onMouseEnter: () => void;\n primaryLabel: string;\n secondaryLabel?: string;\n setRefElement: (element: HTMLDivElement) => void;\n tabIndex: number;\n}\n\nexport function ReferenceMenuItem(props: ReferenceMenuItemProps) {\n const { id, isSelected, onClick, onMouseEnter, setRefElement, secondaryLabel, primaryLabel, tabIndex = -1 } = props;\n\n return (\n <Flex\n direction=\"column\"\n cursor=\"pointer\"\n gap=\"2xs\"\n padding=\"2xs\"\n paddingX=\"sm\"\n bg={isSelected ? \"bg.active\" : \"transparent\"}\n _hover={{ bg: isSelected ? \"bg.active\" : \"bg.hover\" }}\n tabIndex={tabIndex}\n ref={setRefElement}\n role=\"option\"\n aria-selected={isSelected}\n id={id}\n onMouseEnter={onMouseEnter}\n onClick={onClick}\n >\n <Tooltip.Root>\n <Tooltip.Trigger>\n <Text mt=\"1px\" lineClamp={1} textOverflow=\"ellipsis\" textStyle=\"label/M/regular\">\n {primaryLabel}\n </Text>\n </Tooltip.Trigger>\n <Tooltip.Positioner>\n <Tooltip.Content>{primaryLabel}</Tooltip.Content>\n </Tooltip.Positioner>\n </Tooltip.Root>\n {secondaryLabel && (\n <Text lineClamp={2} textOverflow=\"ellipsis\" textStyle=\"label/S/regular\" color=\"fg.muted\">\n {secondaryLabel}\n </Text>\n )}\n </Flex>\n );\n}\n","import { Box, Text } from \"@chakra-ui/react\";\nimport { useEffect } from \"react\";\nimport { ScrollArea } from \"@/components/scroll-area\";\nimport type { ReferenceMenuOption } from \"../../ReferenceMenuOption\";\nimport { getSortedMenuOptions } from \"../../utils/getSortedMenuOptions\";\nimport { ReferenceMenuItem } from \"./ReferenceMenuItem\";\n\ninterface ReferenceMenuProps {\n options: ReferenceMenuOption[];\n selectedIndex: number | null;\n onSelectItem: (option: ReferenceMenuOption, index: number) => void;\n onMouseEnterItem: (index: number) => void;\n}\n\nexport const ReferenceMenu = (props: ReferenceMenuProps) => {\n const { options, selectedIndex, onSelectItem, onMouseEnterItem } = props;\n const { table = [], connector = [] } = getSortedMenuOptions(options);\n\n const hasResults = [...table, ...connector].length;\n\n /** scroll to the selected item if necessary */\n useEffect(() => {\n document\n .getElementById(`typeahead-item-${selectedIndex}`)\n ?.scrollIntoView({ behavior: \"instant\", block: \"nearest\" });\n }, [selectedIndex]);\n\n return (\n <ScrollArea\n zIndex=\"1000\"\n position=\"absolute\"\n layerStyle=\"modal\"\n maxHeight={\"24rem\"}\n showHorizontalScrollbar={false}\n minWidth={{\n base: \"100vw\",\n md: \"264px\",\n }}\n >\n {!hasResults && <Text>No results</Text>}\n {!!table.length && (\n <>\n <Text paddingTop=\"xs\" paddingBottom=\"2xs\" paddingX=\"sm\" color=\"fg.muted\" textStyle=\"label/S/medium\">\n Tables\n </Text>\n <Box>\n {table.map((option) => {\n return (\n <ReferenceMenuItem\n id={`typeahead-item-${option.index}`}\n isSelected={selectedIndex === option.index}\n onClick={() => onSelectItem(option, option.index)}\n onMouseEnter={() => onMouseEnterItem(option.index)}\n key={option.id}\n primaryLabel={option.name}\n secondaryLabel={option.description}\n setRefElement={option.setRefElement}\n tabIndex={-1}\n />\n );\n })}\n </Box>\n </>\n )}\n {!!connector.length && (\n <>\n <Text paddingTop=\"xs\" paddingBottom=\"2xs\" paddingX=\"sm\" color=\"fg.muted\" textStyle=\"label/S/medium\">\n Data Sources\n </Text>\n <Box>\n {connector.map((option) => {\n return (\n <ReferenceMenuItem\n id={`typeahead-item-${option.index}`}\n isSelected={selectedIndex === option.index}\n onClick={() => onSelectItem(option, option.index)}\n onMouseEnter={() => onMouseEnterItem(option.index)}\n key={option.id}\n primaryLabel={option.name}\n secondaryLabel={option.description}\n setRefElement={option.setRefElement}\n tabIndex={-1}\n />\n );\n })}\n </Box>\n </>\n )}\n </ScrollArea>\n );\n};\n","import type { ReferenceMenuOption } from \"../ReferenceMenuOption\";\n\nconst localFilter = (data: ReferenceMenuOption[], q: string) =>\n data.filter((m) => m.name.replace(/ /g, \"_\").toLowerCase().includes(q.toLowerCase()));\n\n/**\n * Search across all resources and menu options\n *\n * @param queryString\n * @returns\n */\nexport function useContextLookup(\n queryString: string | null,\n items: {\n resourceId: string;\n resourceType: \"table\" | \"connector\";\n name: string;\n description?: string;\n }[] = [],\n) {\n const baseOptions: ReferenceMenuOption[] = items.map(\n (res, index): ReferenceMenuOption => ({\n id: res.resourceId,\n key: res.resourceId,\n index,\n group: res.resourceType,\n name: res.name,\n description: res.description,\n setRefElement: () => {},\n }),\n );\n\n if (queryString == null || queryString === \"\") {\n return baseOptions;\n }\n\n return localFilter(baseOptions, queryString);\n}\n","import type { MenuTextMatch } from \"@lexical/react/LexicalTypeaheadMenuPlugin\";\n\nconst VALID_PUNCTUATION = \"\\\\.\\\\-<>_:\";\nconst TRIGGERS = [\"#\"].join(\"\");\n\nconst VALID_CHARS = `[^${TRIGGERS}${VALID_PUNCTUATION}\\\\s]`;\nconst VALID_JOINS = `(?:[${VALID_PUNCTUATION}]|)`;\n\nconst LENGTH_LIMIT = 75;\n\nconst TriggerRegex = new RegExp(`(^|\\\\s|\\\\()([${TRIGGERS}]((?:${VALID_CHARS}${VALID_JOINS}){0,${LENGTH_LIMIT}}))$`);\n\nconst AliasRegex = new RegExp(`(^|\\\\s|\\\\()([${TRIGGERS}]((?:${VALID_CHARS}){0,${LENGTH_LIMIT}}))$`);\n\n/**\n * lexical will run this function on text nodes\n *\n * @param text\n * @param minMatchLength\n * @returns\n */\nexport function checkForTriggers(text: string, minMatchLength: number): MenuTextMatch | null {\n let match = TriggerRegex.exec(text);\n\n if (match === null) {\n match = AliasRegex.exec(text);\n }\n\n if (match !== null) {\n // The strategy ignores leading whitespace but we need to know it's\n // length to add it to the leadOffset\n const maybeLeadingWhitespace = match[1];\n const matchingString = match[3];\n\n if (matchingString.length >= minMatchLength) {\n return {\n leadOffset: match.index + maybeLeadingWhitespace.length,\n matchingString,\n replaceableString: match[2],\n };\n }\n }\n\n return null;\n}\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { LexicalTypeaheadMenuPlugin } from \"@lexical/react/LexicalTypeaheadMenuPlugin\";\nimport type { TextNode } from \"lexical\";\nimport { useState } from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { INSERT_REFERENCE_COMMAND } from \"../../commands\";\nimport { ReferenceMenu } from \"./components/ReferenceMenu/ReferenceMenu\";\nimport { useContextLookup } from \"./hooks/useContextLookup\";\nimport type { ReferenceMenuOption } from \"./ReferenceMenuOption\";\nimport { checkForTriggers } from \"./utils/checkForTriggers\";\n\nconst SUGGESTION_LIST_LENGTH_LIMIT = 20;\n\ntype Props = {\n items?: Array<{\n resourceId: string;\n resourceType: \"table\" | \"connector\";\n name: string;\n description?: string;\n }>;\n};\n\nexport function ReferenceMenuPlugin({ items = [] }: Props) {\n const [queryString, setQueryString] = useState<string | null>(null);\n const [editor] = useLexicalComposerContext();\n const searchResults = useContextLookup(queryString, items);\n\n /**\n * triggers when the user selects an option in the context menu\n */\n const onSelectOption = (\n selectedOption: ReferenceMenuOption,\n nodeToReplace: TextNode | null,\n closeMenu: () => void,\n ) => {\n editor.update(() => {\n if (!nodeToReplace) return;\n\n editor.dispatchCommand(INSERT_REFERENCE_COMMAND, {\n resourceId: selectedOption.id,\n resourceType: selectedOption.group,\n name: selectedOption.name,\n nodeToReplace,\n });\n\n closeMenu();\n });\n };\n\n /**\n * checks text nodes and return nodes matching the trigger\n */\n const checkForTrigger = (text: string) => {\n return checkForTriggers(text, 0);\n };\n\n /**\n * define the options to display in the context menu\n */\n const menuOptions = searchResults.slice(0, SUGGESTION_LIST_LENGTH_LIMIT);\n\n return (\n <LexicalTypeaheadMenuPlugin<ReferenceMenuOption>\n onQueryChange={setQueryString}\n onSelectOption={onSelectOption}\n triggerFn={checkForTrigger}\n options={menuOptions}\n menuRenderFn={(anchorElementRef, { options, selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {\n if (!anchorElementRef.current) return null;\n return ReactDOM.createPortal(\n <ReferenceMenu\n options={options}\n selectedIndex={selectedIndex}\n onSelectItem={(option, i) => {\n setHighlightedIndex(i);\n selectOptionAndCleanUp(option);\n }}\n onMouseEnterItem={(i) => {\n setHighlightedIndex(i);\n }}\n />,\n anchorElementRef.current,\n );\n }}\n />\n );\n}\n","import { addClassNamesToElement } from \"@lexical/utils\";\nimport {\n type DOMConversionMap,\n type DOMConversionOutput,\n type DOMExportOutput,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n type NodeKey,\n type SerializedTextNode,\n type Spread,\n TextNode,\n} from \"lexical\";\n\ntype SerializedReferenceNode = Spread<\n {\n referenceId: string;\n name: string;\n },\n SerializedTextNode\n>;\n\nexport class ReferenceNode extends TextNode {\n __referenceId: string;\n __name: string;\n\n static getType(): string {\n return \"reference\";\n }\n\n static clone(node: ReferenceNode): ReferenceNode {\n return new ReferenceNode(node.__referenceId, node.__name, node.__key);\n }\n\n constructor(referenceId: string, name: string, key?: NodeKey) {\n super(name, key);\n this.__referenceId = referenceId;\n this.__name = name;\n }\n\n isKeyboardSelectable(): boolean {\n return false;\n }\n\n canBeEmpty(): boolean {\n return false;\n }\n\n canInsertTextAfter(): boolean {\n return false;\n }\n\n canInsertTextBefore(): boolean {\n return false;\n }\n\n createDOM(config: EditorConfig): HTMLElement {\n const span = document.createElement(\"span\");\n addClassNamesToElement(span, config.theme.reference);\n span.setAttribute(\"data-reference-id\", this.__referenceId);\n span.setAttribute(\"data-name\", this.__name);\n span.textContent = `#${this.__name}`;\n return span;\n }\n\n updateDOM(prevNode: ReferenceNode, dom: HTMLElement): boolean {\n if (prevNode.__name !== this.__name || prevNode.__referenceId !== this.__referenceId) {\n dom.setAttribute(\"data-reference-id\", this.__referenceId);\n dom.setAttribute(\"data-name\", this.__name);\n dom.textContent = `#${this.__name}`;\n }\n\n return false;\n }\n\n exportDOM(_editor: LexicalEditor): DOMExportOutput {\n const el = document.createElement(\"span\");\n el.setAttribute(\"data-reference-id\", this.__referenceId);\n el.setAttribute(\"data-name\", this.__name);\n el.textContent = `#${this.__name}`;\n return { element: el };\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n span: (domNode: HTMLElement) => {\n if (!domNode.hasAttribute(\"data-reference-id\") || !domNode.hasAttribute(\"data-name\")) {\n return null;\n }\n return {\n conversion: $convertReferenceElement,\n priority: 1,\n };\n },\n };\n }\n\n static importJSON(serializedNode: SerializedReferenceNode): ReferenceNode {\n const node = new ReferenceNode(serializedNode.referenceId, serializedNode.name);\n return node;\n }\n\n exportJSON(): SerializedReferenceNode {\n return {\n ...super.exportJSON(),\n type: \"reference\",\n referenceId: this.__referenceId,\n name: this.__name,\n };\n }\n\n getTextContent(): string {\n return `#${this.__name}`;\n }\n}\n\nfunction $convertReferenceElement(domNode: HTMLElement): DOMConversionOutput | null {\n const referenceId = domNode.getAttribute(\"data-reference-id\");\n const name = domNode.getAttribute(\"data-name\");\n if (!referenceId || !name) return null;\n return { node: $createReferenceNode(referenceId, name) };\n}\n\nexport function $createReferenceNode(referenceId: string, name: string): ReferenceNode {\n return new ReferenceNode(referenceId, name);\n}\n\nexport function $isReferenceNode(node: LexicalNode | null | undefined): node is ReferenceNode {\n return node instanceof ReferenceNode;\n}\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport { COMMAND_PRIORITY_LOW, type LexicalNode } from \"lexical\";\nimport { type PropsWithChildren, useEffect } from \"react\";\nimport { INSERT_REFERENCE_COMMAND } from \"../../commands\";\nimport { $createReferenceNode } from \"./nodes/ReferenceNode/ReferenceNode\";\n\nexport const $insertExistingReference = (nodeToReplace: LexicalNode, resourceId: string, name: string) => {\n const refNode = $createReferenceNode(resourceId, name);\n\n if (nodeToReplace) {\n nodeToReplace?.replace(refNode);\n nodeToReplace.remove();\n refNode.selectEnd();\n return;\n }\n};\n\nexport function ReferencePlugin(\n props: PropsWithChildren<{ onAddReference?: (resourceId: string, resourceType: \"table\" | \"connector\") => void }>,\n) {\n const { onAddReference } = props;\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n INSERT_REFERENCE_COMMAND,\n (event: {\n resourceId: string;\n resourceType: \"table\" | \"connector\";\n name: string;\n nodeToReplace: LexicalNode;\n }) => {\n const { resourceId, resourceType, name, nodeToReplace } = event;\n\n editor.update(() => {\n $insertExistingReference(nodeToReplace, resourceId, name);\n });\n\n onAddReference?.(resourceId, resourceType);\n return true;\n },\n COMMAND_PRIORITY_LOW,\n ),\n );\n }, [editor, onAddReference]);\n\n return null;\n}\n","import type { EditorThemeClasses } from \"lexical\";\nimport baseTheme from \"../../theme/rich-text-theme\";\nimport \"./prompt-input-theme.css\";\n\nconst promptInputTheme: EditorThemeClasses = {\n ...baseTheme,\n // Override paragraph class to remove margins specifically for prompt input\n paragraph: \"rich-text__p rich-text__p--no-margin\",\n};\n\nexport default promptInputTheme;\n","import { Flex, Kbd, Text } from \"@chakra-ui/react\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { $getRoot } from \"lexical\";\nimport type { ReactElement } from \"react\";\nimport { type ForwardRefRenderFunction, forwardRef, useRef } from \"react\";\nimport { ContentEditable } from \"../shared/components/content-editable\";\nimport ToggleEditablePlugin from \"../shared/plugins/ToggleEditablePlugin\";\nimport { TreeViewPlugin } from \"../shared/plugins/TreeViewPlugin/TreeViewPlugin\";\nimport { CommentPlugin } from \"./plugins/CommentPlugin/CommentPlugin\";\nimport { CommentNode } from \"./plugins/CommentPlugin/nodes/CommentNode/CommentNode\";\nimport { ImperativeAPIPlugin, type PromptEditorRef } from \"./plugins/ImperativeAPIPlugin\";\nimport { KeyboardShortcutPlugin } from \"./plugins/KeyboardShortcutPlugin\";\nimport { ReferenceMenuPlugin } from \"./plugins/ReferenceMenuPlugin/ReferenceMenuPlugin\";\nimport { ReferenceNode } from \"./plugins/ReferencePlugin/nodes/ReferenceNode/ReferenceNode\";\nimport { ReferencePlugin } from \"./plugins/ReferencePlugin/ReferencePlugin\";\nimport theme from \"./theme/prompt-input-theme\";\nimport { $getTextContent, getTextFromSerializedEditorState } from \"./utils\";\n\nexport type ReferenceItem = {\n resourceId: string;\n resourceType: \"table\" | \"connector\";\n name: string;\n description?: string;\n};\n\nexport interface PromptEditorProps {\n defaultState: string;\n debug?: boolean;\n isEditable?: boolean;\n placeholder?: ReactElement | ((isEditable: boolean) => ReactElement | null);\n onChange?: (text: string, state: object) => void;\n onError?: (error: Error) => void;\n onSubmit?: () => void;\n /** Dynamic list of references (tables, connectors) shown when typing # */\n references?: ReferenceItem[];\n /** Optional app callback when a reference is inserted */\n onAddReference?: (resourceId: string, resourceType: \"table\" | \"connector\") => void;\n}\n\nconst nodes = [CommentNode, MarkNode, ReferenceNode];\n\nexport const BasePromptEditor: ForwardRefRenderFunction<PromptEditorRef, PromptEditorProps> = (props, ref) => {\n const { defaultState, debug = false, isEditable = true, placeholder } = props;\n const { onChange, onError = () => {}, onSubmit, references = [], onAddReference } = props;\n\n const initialConfig = {\n namespace: \"PROMPT_EDITOR\",\n nodes,\n editorState: defaultState,\n editable: isEditable,\n onError,\n theme,\n };\n\n const previousTextRef = useRef<string>(getTextFromSerializedEditorState(defaultState));\n const placeholderNode: ReactElement | ((isEditable: boolean) => ReactElement | null) = placeholder ?? (\n <Text textStyle=\"label/M/regular\" color=\"fg.subtle\" pointerEvents=\"none\" position=\"absolute\" top=\"0\">\n Type your query here or press <Kbd color=\"fg.subtle\">#</Kbd> to add a reference.\n </Text>\n );\n\n return (\n <Flex direction=\"column\" justifyContent=\"space-between\" width=\"100%\" position=\"relative\">\n <LexicalComposer initialConfig={initialConfig}>\n <HistoryPlugin />\n <RichTextPlugin\n contentEditable={<ContentEditable fullWidth />}\n placeholder={placeholderNode}\n ErrorBoundary={LexicalErrorBoundary}\n />\n <OnChangePlugin\n ignoreSelectionChange\n ignoreHistoryMergeTagChange={false}\n onChange={(editorState) => {\n editorState.read(() => {\n // handle comment blocks properly\n const root = $getRoot();\n const rawText = $getTextContent(root);\n\n if (rawText !== previousTextRef.current) {\n previousTextRef.current = rawText;\n onChange?.(rawText, editorState.toJSON());\n }\n });\n }}\n />\n <ImperativeAPIPlugin editorRef={ref} previousTextRef={previousTextRef} />\n <ToggleEditablePlugin isEditable={isEditable} />\n <CommentPlugin />\n <KeyboardShortcutPlugin onSubmit={onSubmit} />\n <ReferenceMenuPlugin items={references} />\n <ReferencePlugin onAddReference={onAddReference} />\n {debug ? <TreeViewPlugin /> : \"\"}\n </LexicalComposer>\n </Flex>\n );\n};\n\nexport const PromptEditor = forwardRef(BasePromptEditor);\n\nexport type { PromptEditorRef } from \"./plugins/ImperativeAPIPlugin\";\n","import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { useEffect } from \"react\";\n\ntype StateUpdatePluginProps = {\n value: string;\n onUpdate: (value: string) => void;\n};\n\nexport default function StateUpdatePlugin({ value, onUpdate }: StateUpdatePluginProps) {\n const [editor] = useLexicalComposerContext();\n\n useEffect(() => {\n if (!editor) {\n return;\n }\n\n editor.update(() => onUpdate(value), { tag: \"history-merge\" });\n }, [value, editor, onUpdate]);\n\n return null;\n}\n","import { Box } from \"@chakra-ui/react\";\nimport {\n DecoratorNode,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n type NodeKey,\n type SerializedLexicalNode,\n type Spread,\n} from \"lexical\";\nimport type { ReactElement } from \"react\";\nimport { ResourceBadge } from \"../../../../resource-badge\";\n\nexport type SerializedReferenceLinkNode = Spread<\n {\n href: string;\n label?: string;\n },\n SerializedLexicalNode\n>;\n\nexport class ReferenceLinkNode extends DecoratorNode<ReactElement> {\n __href: string;\n __label?: string;\n\n static getType(): string {\n return \"reference-link\";\n }\n\n static clone(node: ReferenceLinkNode): ReferenceLinkNode {\n return new ReferenceLinkNode(node.__href, node.__label, node.__key);\n }\n\n constructor(href: string, label?: string, key?: NodeKey) {\n super(key);\n this.__href = href;\n this.__label = label;\n }\n\n createDOM(_config: EditorConfig, _editor: LexicalEditor): HTMLElement {\n return document.createElement(\"span\");\n }\n\n updateDOM(_prevNode: ReferenceLinkNode, _dom: HTMLElement, _config: EditorConfig): boolean {\n return false;\n }\n\n getTextContent(): string {\n const label = this.__label ?? this.__href;\n return `{{link('${label}')}}`;\n }\n\n exportJSON(): SerializedReferenceLinkNode {\n return {\n type: ReferenceLinkNode.getType(),\n version: 1,\n href: this.__href,\n label: this.__label,\n };\n }\n\n static importJSON(serializedNode: SerializedReferenceLinkNode): ReferenceLinkNode {\n return $createReferenceLinkNode(serializedNode.href, serializedNode.label);\n }\n\n decorate(_editor: LexicalEditor, _config: EditorConfig): ReactElement {\n const href = this.__href;\n const fileName = href.split(\"/\").pop();\n const label = fileName || \"unknown\";\n const isExternal = /^https?:\\/\\//i.test(href);\n const isProjectFile = /^#?\\$PROJECT\\//i.test(href);\n\n return (\n <Box width=\"fit-content\" display=\"inline-block\">\n <ResourceBadge\n fileName={label}\n onSelect={() => {\n if (isExternal) {\n window.open(href, \"_blank\", \"noopener,noreferrer\");\n } else if (isProjectFile) {\n const projectPath = href.replace(/^#?\\$PROJECT\\//i, \"\");\n const event = new CustomEvent(\"ui:open-project-file\", { detail: projectPath });\n window.dispatchEvent(event);\n } else {\n window.location.assign(href);\n }\n }}\n />\n </Box>\n );\n }\n}\n\nexport function $createReferenceLinkNode(href: string, label?: string): ReferenceLinkNode {\n return new ReferenceLinkNode(href, label);\n}\n\nexport function $isReferenceLinkNode(node: LexicalNode | null | undefined): node is ReferenceLinkNode {\n return node instanceof ReferenceLinkNode;\n}\n","import type { TextMatchTransformer } from \"@lexical/markdown\";\nimport { $createReferenceLinkNode, $isReferenceLinkNode, ReferenceLinkNode } from \"./ReferenceLinkNode\";\n\n// Matches {{link('xxx')}} or {{ link(\"xxx\") }}\nconst LINK_REGEXP = /\\{\\{\\s*link\\((['\"])([^'\"\\s]+)\\1\\)\\s*\\}\\}/;\n\nexport const REFERENCE_LINK_TRANSFORMER: TextMatchTransformer = {\n dependencies: [ReferenceLinkNode],\n export: (node) => {\n if ($isReferenceLinkNode(node)) {\n const href = (node as ReferenceLinkNode).__href;\n const label = (node as ReferenceLinkNode).__label ?? href;\n // Export back to token form so markdown roundtrips\n if (label) {\n return `{{link('${label}')}}`;\n }\n return `{{link('${href}')}}`;\n }\n return null;\n },\n regExp: LINK_REGEXP,\n importRegExp: LINK_REGEXP,\n replace: (textNode, match) => {\n const value = match[2];\n // For now we assume value is both label and href; if it looks like a URL, use as href.\n const looksLikeUrl = /^(https?:\\/\\/|\\/)/i.test(value);\n const href = looksLikeUrl ? value : `#${value}`;\n const label = value;\n textNode.replace($createReferenceLinkNode(href, label));\n },\n type: \"text-match\",\n};\n","import \"../theme/rich-text-theme.css\";\n\nimport { Flex } from \"@chakra-ui/react\";\nimport { AutoLinkNode, LinkNode } from \"@lexical/link\";\nimport { ListItemNode, ListNode } from \"@lexical/list\";\nimport { $convertFromMarkdownString, $convertToMarkdownString } from \"@lexical/markdown\";\nimport { ClickableLinkPlugin } from \"@lexical/react/LexicalClickableLinkPlugin\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { HorizontalRulePlugin } from \"@lexical/react/LexicalHorizontalRulePlugin\";\nimport { LinkPlugin } from \"@lexical/react/LexicalLinkPlugin\";\nimport { ListPlugin } from \"@lexical/react/LexicalListPlugin\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { TabIndentationPlugin } from \"@lexical/react/LexicalTabIndentationPlugin\";\nimport { HeadingNode, QuoteNode } from \"@lexical/rich-text\";\nimport { $getRoot } from \"lexical\";\nimport { ContentEditable } from \"../shared/components/content-editable\";\nimport { baseEditorTransformers } from \"../shared/editor-config\";\nimport { CodeHighlightNode, CodeNode } from \"../shared/lexical-code\";\nimport { DataTableNode } from \"../shared/nodes/DataTableNode\";\nimport { ImportCodeBlocksPlugin } from \"../shared/plugins/CodePlugin/CodeBlockPlugin\";\nimport { CodeHighlightingPlugin } from \"../shared/plugins/CodePlugin/CodeHighlightingPlugin\";\nimport { EquationNode } from \"../shared/plugins/EquationPlugin/EquationNode\";\nimport { EquationPlugin } from \"../shared/plugins/EquationPlugin/EquationPlugin\";\nimport { HRNode } from \"../shared/plugins/HorizontalRulePlugin/HorizontalRuleNode\";\nimport { MermaidNode } from \"../shared/plugins/MermaidPlugin/MermaidNode\";\nimport StateUpdatePlugin from \"../shared/plugins/StateUpdatePlugin\";\nimport ToggleEditablePlugin from \"../shared/plugins/ToggleEditablePlugin\";\nimport { TreeViewPlugin } from \"../shared/plugins/TreeViewPlugin/TreeViewPlugin\";\nimport theme from \"../theme/rich-text-theme\";\nimport { normalizeMarkdownListIndentation, splitFrontmatter } from \"../utils/markdown\";\nimport { REFERENCE_LINK_TRANSFORMER, ReferenceLinkNode } from \"./plugins/ReferenceLinkPlugin\";\n\nexport interface RichMessageProps {\n debug?: boolean;\n defaultState: string;\n fullWidth?: boolean;\n isEditable?: boolean;\n onChange?: (value: string) => void;\n}\n\nconst transformers = [...baseEditorTransformers, REFERENCE_LINK_TRANSFORMER];\n\nexport function RichMessage(props: RichMessageProps) {\n const { debug = false, defaultState = \"\", fullWidth = false, isEditable = false, onChange } = props;\n const { frontmatter, body } = splitFrontmatter(defaultState);\n const shouldTrackChanges = isEditable && Boolean(onChange);\n\n const initialConfig = {\n namespace: \"RICH_MESSAGE\",\n nodes: [\n QuoteNode,\n LinkNode,\n AutoLinkNode,\n DataTableNode,\n HeadingNode,\n ListNode,\n ListItemNode,\n CodeNode,\n CodeHighlightNode,\n MermaidNode,\n EquationNode,\n HRNode,\n ReferenceLinkNode,\n ],\n editorState: () => {\n return $convertFromMarkdownString(normalizeMarkdownListIndentation(body), transformers, undefined, false);\n },\n onError: (error: Error) => console.error(error),\n editable: isEditable,\n theme,\n };\n\n return (\n <Flex\n className=\"rich-text\"\n data-rich-message=\"true\"\n justifyContent=\"space-between\"\n width=\"100%\"\n maxWidth=\"100%\"\n height=\"100%\"\n position=\"relative\"\n direction=\"column\"\n overflow=\"hidden\"\n >\n <LexicalComposer initialConfig={initialConfig}>\n <StateUpdatePlugin\n value={body}\n onUpdate={(value: string) => {\n $convertFromMarkdownString(normalizeMarkdownListIndentation(value), transformers, undefined, false);\n }}\n />\n <LinkPlugin />\n <ClickableLinkPlugin newTab />\n <ListPlugin />\n {isEditable ? <TabIndentationPlugin maxIndent={7} /> : null}\n <HorizontalRulePlugin />\n <CodeHighlightingPlugin />\n <ImportCodeBlocksPlugin />\n <EquationPlugin />\n <RichTextPlugin\n contentEditable={<ContentEditable fullWidth={fullWidth} isRichMessage />}\n ErrorBoundary={LexicalErrorBoundary}\n />\n {shouldTrackChanges ? (\n <OnChangePlugin\n ignoreSelectionChange\n ignoreHistoryMergeTagChange={false}\n onChange={(editorState) => {\n editorState.read(() => {\n const root = $getRoot();\n const markdownBody = $convertToMarkdownString(transformers, root);\n onChange?.(frontmatter + markdownBody);\n });\n }}\n />\n ) : null}\n <ToggleEditablePlugin isEditable={isEditable} />\n {debug && <TreeViewPlugin />}\n </LexicalComposer>\n </Flex>\n );\n}\n"],"names":["StyledEditable","chakra","LexicalContentEditable","ContentEditable","t0","$","_c","onRef","fullWidth","t1","padding","isRichMessage","t2","scrollable","t3","undefined","t4","t5","t6","jsx","t7","Box","editor","t8","t9","Symbol","for","width","minH","t10","ScrollArea","ReferenceLinkNode","DecoratorNode","__href","__label","getType","clone","node","__key","constructor","href","label","key","createDOM","_config","_editor","document","createElement","updateDOM","_prevNode","_dom","getTextContent","exportJSON","type","version","importJSON","serializedNode","$createReferenceLinkNode","decorate","split","pop","isExternal","test","isProjectFile","ResourceBadge","window","open","projectPath","replace","event","CustomEvent","detail","dispatchEvent","location","assign","$isReferenceLinkNode","LINK_REGEXP","REFERENCE_LINK_TRANSFORMER","dependencies","export","regExp","importRegExp","textNode","match","value","theme","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","list","checklist","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ol","ul","heading","h1","h2","h3","paragraph","text","underline","italic","link","quote","reference","table","tableCell","tableRow","tableCellHeader","layoutContainer","layoutItem","draggableBlockDemo","row","content","globalScope","globalThis","Prism","scaledSmallFontSize","formatValue","length","String","toUpperCase","Date","toISOString","JSON","stringify","DefaultRichTextCodeEditor","props","defaultCode","isEditable","showLineNumbers","disableScroll","Textarea","lines","map","_temp","codeBlock","DefaultRichTextDataTable","data","noBorder","hiddenColumns","Text","Set","hiddenSet","Object","keys","filter","has","columns","Table","_temp2","t11","rowIndex","column_0","column","join","t12","jsxs","line","index","DataTableNode","__data","getData","json","headers","headerRow","separator","dataRows","header","$createDataTableNode","$isDataTableNode","EquationComponent","React","lazy","$convertEquationElement","domNode","equation","getAttribute","inline","atob","$createEquationNode","EquationNode","__equation","__inline","getEquation","element","className","exportDOM","btoa","setAttribute","katex","render","displayMode","errorColor","output","strict","throwOnError","trust","importDOM","div","hasAttribute","conversion","priority","span","prevNode","setEquation","writable","getWritable","isInline","Suspense","equationNode","$applyNodeReplacement","$isEquationNode","EQUATION_INLINE","trim","EQUATION_MULTILINE","regExpStart","regExpEnd","rootNode","_children","_startMatch","_endMatch","linesInBetween","append","EquationPlugin","HRNode","ElementNode","_serializedNode","$createHRNode","style","$isHRNode","MermaidComponent","MermaidNode","__code","getCode","setCode","$isMermaidNode","HR","parentNode","TABLE","_traverseChildren","_isImport","previousNode","getPreviousSibling","remove","cells","slice","cell","existingData","newRow","isPlaceholderRow","values","every","_","forEach","newTableData","newTableNode","tableNode","UNDERLINE_INS_TAG","TextNode","markdownText","hasFormat","$createTextNode","toggleFormat","UNDERLINE_U_TAG","_node","BARE_URL_REGEXP","unescapeUrl","escapeLinkTitle","title","unescapeLinkTitle","normalizeEscapedUrlText","textContent","exportedText","escapedHref","LINK","LinkNode","exportChildren","$isLinkNode","$isAutoLinkNode","getTitle","getURL","linkText","linkUrl","linkTitle","linkNode","$createLinkNode","openBracketAmount","closeBracketAmount","parsedLinkText","outsideLinkText","linkTextParts","normalizedLinkText","linkTextNode","setFormat","getFormat","insertBefore","trigger","BARE_URL","AutoLinkNode","autoLinkNode","$createAutoLinkNode","TRANSFORMERS_EXTENDED","editorNodes","QuoteNode","HeadingNode","ListNode","ListItemNode","CodeNode","CodeHighlightNode","baseEditorTransformers","CHECK_LIST","TRANSFORMERS","transformer","LEXICAL_LINK","editorTransformers","editorTheme","isMermaidLanguage","language","toLowerCase","replaceCodeNodeWithMermaidNode","getLanguage","ImportCodeBlocksPlugin","useLexicalComposerContext","update","useEffect","codeNodes","$nodesOfType","n","CodeHighlightingPlugin","registerCodeHighlighting","TOGGLE_LINK_EDIT_MODE_COMMAND","createCommand","ToggleEditablePlugin","setEditable","TreeViewPlugin","TreeView","FRONTMATTER_PATTERN","FENCE_PATTERN","LIST_ITEM_PATTERN","INDENTED_LINE_PATTERN","getExpandedIndentWidth","indent","findParentIndent","activeListIndents","sourceIndentWidth","reverse","find","toNormalizedIndent","normalizedWidth","sourceWidth","includes","repeat","normalizeIndentedContinuation","indentedLineMatch","parentLevel","normalizedIndentWidth","normalizedIndent","normalizeListItem","at","currentLevel","indentStep","push","normalizeMarkdownLine","state","trimStart","isInCodeFence","normalizeMarkdownListIndentation","splitFrontmatter","frontmatter","body","UPLOAD_FILE","OPEN_CONTEXT","RUN_PROMPT","UPDATE_FORMAT","UPDATE_BEHAVIOR","INSERT_PROMPT","RENAME_PROMPT","DUPLICATE_PROMPT","DELETE_PROMPT","DELETE_REFERENCES","RENAME_REFERENCES","INSERT_REFERENCE","INSERT_BLOCK","INSERT_REFERENCE_COMMAND","INSERT_BLOCK_COMMAND","INSERT_NEW_FILE_PLACEHOLDER","INSERT_NEW_TEXT_PLACEHOLDER","INSERT_PLACEHOLDER_REFERENCE","convertCommentElement","$createCommentNode","textAlign","CommentNode","config","addClassNamesToElement","blockquote","isHTMLElement","isEmpty","formatType","getFormatType","direction","getDirection","dir","format","setIndent","setDirection","insertNewAfter","restoreSelection","newBlock","$createParagraphNode","insertAfter","collapseAtStart","children","getChildren","child","insertCommentBlock","_blockType","nodeToReplace","selection","$getSelection","commentNode","nodeParent","getParent","selectEnd","$isRangeSelection","$setBlocksType","useCommentCommands","mergeRegister","registerCommand","COMMAND_PRIORITY_LOW","optionId","useCommentSchema","registerNodeTransform","invalidChildren","child_0","CommentPlugin","$getTextContent","root","childrenLength","i","$isElementNode","getReferenceMarker","name","referenceId","shouldAppendParagraphBreak","Boolean","traverseSerializedNode","referenceMarker","Array","isArray","getTextFromSerializedEditorState","parsed","parse","emptyEditorState","textFormat","generateEditorStateFromString","input","mode","ImperativeAPIPlugin","editorRef","previousTextRef","setEditorValue","parseEditorState","setEditorState","current","defaultSelection","useImperativeHandle","shouldSubmitOnEnter","ctrlKey","metaKey","shiftKey","altKey","KeyboardShortcutPlugin","onSubmit","KEY_DOWN_COMMAND","preventDefault","COMMAND_PRIORITY_HIGH","menuSortOrder","getSortedMenuOptions","options","sort","a","b","indexOf","group","option","reduce","acc","bucket","ReferenceMenuItem","id","isSelected","onClick","onMouseEnter","setRefElement","secondaryLabel","primaryLabel","tabIndex","bg","Tooltip","Flex","ReferenceMenu","selectedIndex","onSelectItem","onMouseEnterItem","connector","hasResults","getElementById","scrollIntoView","behavior","block","T0","md","Fragment","description","option_0","t13","localFilter","q","m","useContextLookup","queryString","items","baseOptions","res","resourceId","resourceType","VALID_PUNCTUATION","TRIGGERS","VALID_CHARS","VALID_JOINS","LENGTH_LIMIT","TriggerRegex","RegExp","AliasRegex","checkForTriggers","minMatchLength","exec","maybeLeadingWhitespace","matchingString","leadOffset","replaceableString","SUGGESTION_LIST_LENGTH_LIMIT","ReferenceMenuPlugin","setQueryString","useState","searchResults","selectedOption","closeMenu","dispatchCommand","onSelectOption","checkForTrigger","menuOptions","LexicalTypeaheadMenuPlugin","anchorElementRef","selectOptionAndCleanUp","setHighlightedIndex","ReactDOM","createPortal","i_0","ReferenceNode","__referenceId","__name","isKeyboardSelectable","canBeEmpty","canInsertTextAfter","canInsertTextBefore","dom","el","$convertReferenceElement","$createReferenceNode","$insertExistingReference","refNode","ReferencePlugin","onAddReference","promptInputTheme","baseTheme","nodes","MarkNode","BasePromptEditor","ref","defaultState","debug","placeholder","onChange","onError","references","editorState","editable","initialConfig","useRef","Kbd","placeholderNode","HistoryPlugin","RichTextPlugin","LexicalErrorBoundary","OnChangePlugin","read","$getRoot","rawText","toJSON","t14","t15","t16","t17","t18","t19","LexicalComposer","PromptEditor","forwardRef","StateUpdatePlugin","onUpdate","transformers","RichMessage","shouldTrackChanges","$convertFromMarkdownString","LinkPlugin","ClickableLinkPlugin","ListPlugin","TabIndentationPlugin","HorizontalRulePlugin","markdownBody","$convertToMarkdownString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sxs as ie, Fragment as ft } from "react/jsx-runtime";
2
2
  import { c as te } from "react/compiler-runtime";
3
- import { T as Ke, e as We, a as Ve, C as Ge, I as qe, E as Ye, b as Xe, s as mt, n as ut, c as He, d as pt, f as ht } from "./rich-message-CEOSsdR2.js";
4
- import { D as co, g as fo, R as mo, P as uo, R as po, h as ho, i as go } from "./rich-message-CEOSsdR2.js";
3
+ import { T as Ke, e as We, a as Ve, C as Ge, I as qe, E as Ye, b as Xe, s as mt, n as ut, c as He, d as pt, f as ht } from "./rich-message-BFtvH9H7.js";
4
+ import { D as co, g as fo, R as mo, P as uo, R as po, h as ho, i as go } from "./rich-message-BFtvH9H7.js";
5
5
  import { IconButton as F, Text as me, Stack as Pe, Box as $e, Flex as Ae, Input as gt, Link as bt } from "@chakra-ui/react";
6
6
  import { LexicalCollaboration as vt } from "@lexical/react/LexicalCollaborationContext";
7
7
  import { CollaborationPluginV2__EXPERIMENTAL as Ct } from "@lexical/react/LexicalCollaborationPlugin";
@@ -20,7 +20,7 @@ import { mergeRegister as Le, $findMatchingParent as Z } from "@lexical/utils";
20
20
  import { SELECTION_CHANGE_COMMAND as Se, COMMAND_PRIORITY_CRITICAL as Oe, $getSelection as ee, $isRangeSelection as Q, FORMAT_TEXT_COMMAND as Te, $isRootOrShadowRoot as Lt, CLICK_COMMAND as it, COMMAND_PRIORITY_HIGH as lt, $createParagraphNode as Fe, COMMAND_PRIORITY_LOW as Be, KEY_ESCAPE_COMMAND as St, $isLineBreakNode as yt, $setSelection as xt, $getRoot as Tt } from "lexical";
21
21
  import { Check as rt, Copy as Rt, Link as wt, Code2 as Nt, List as It, ListOrdered as Pt, ListTodo as At, X as Bt, Pencil as zt, Trash2 as Mt } from "lucide-react";
22
22
  import { createPortal as Ue } from "react-dom";
23
- import { T as j } from "./get-file-type-icon-ufFb0IkR.js";
23
+ import { T as j } from "./resource-badge-D33IFv74.js";
24
24
  import { $isCodeNode as Re, $createCodeNode as $t } from "@lexical/code";
25
25
  import { $isLinkNode as le, $isAutoLinkNode as pe, TOGGLE_LINK_COMMAND as ze, $createLinkNode as Dt } from "@lexical/link";
26
26
  import { $isListNode as we, REMOVE_LIST_COMMAND as Ot, INSERT_CHECK_LIST_COMMAND as Ut, INSERT_ORDERED_LIST_COMMAND as Ht, INSERT_UNORDERED_LIST_COMMAND as Ft } from "@lexical/list";
@@ -1578,8 +1578,8 @@ const S = {
1578
1578
  primary: {
1579
1579
  default: {
1580
1580
  value: {
1581
- _light: "{colors.blacks.200}",
1582
- _dark: "{colors.blacks.200}"
1581
+ _light: "{colors.blacks.800}",
1582
+ _dark: "{colors.blacks.800}"
1583
1583
  }
1584
1584
  },
1585
1585
  disabled: {
@@ -2505,4 +2505,4 @@ export {
2505
2505
  w as c,
2506
2506
  ze as t
2507
2507
  };
2508
- //# sourceMappingURL=theme-D2LYEa0j.js.map
2508
+ //# sourceMappingURL=theme-C5qHTCU9.js.map