{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rich-text-editor",
  "type": "registry:ui",
  "title": "Rich Text Editor",
  "description": "A Tiptap chat editor: Enter sends, shortcuts format.",
  "categories": [
    "forms"
  ],
  "dependencies": [
    "@hugeicons/core-free-icons@4.4.0",
    "@hugeicons/react@1.1.10",
    "@tiptap/core@3.35.0",
    "@tiptap/extension-placeholder@3.35.0",
    "@tiptap/pm@3.35.0",
    "@tiptap/react@3.35.0",
    "@tiptap/starter-kit@3.35.0"
  ],
  "registryDependencies": [
    "https://sprout.tulipfarm.ai/r/sprout-base.json",
    "https://sprout.tulipfarm.ai/r/spinner.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/rich-text-editor.tsx",
      "type": "registry:ui",
      "target": "components/ui/rich-text-editor.tsx",
      "content": "'use client';\n\nimport {\n  useEffect,\n  useId,\n  useImperativeHandle,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n  type CSSProperties,\n  type KeyboardEvent as ReactKeyboardEvent,\n  type ReactNode,\n  type Ref,\n} from 'react';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport { Extension, InputRule, type Editor, type Extensions, type JSONContent } from '@tiptap/core';\nimport { Fragment, Slice, type Node as ProseMirrorNode, type Schema } from '@tiptap/pm/model';\nimport { Plugin, PluginKey, TextSelection, type EditorState } from '@tiptap/pm/state';\nimport { canSplit } from '@tiptap/pm/transform';\nimport { Decoration, DecorationSet } from '@tiptap/pm/view';\nimport StarterKit from '@tiptap/starter-kit';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport { CheckIcon } from '@/lib/sprout/icons/check-icon';\nimport { LinkOffIcon } from '@/lib/sprout/icons/link-off-icon';\nimport { cn } from '@/lib/sprout/classes';\nimport { KeywordHintBody } from '@/lib/sprout/keyword-hint';\nimport {\n  accountLabel,\n  hasHint,\n  keywordPattern,\n  objectReplacement,\n  scanText,\n  type KeywordHit,\n  type KeywordPattern,\n} from '@/lib/sprout/keywords';\nimport { Spinner } from '@/components/ui/spinner';\n\nexport const richTextEditorSizeNames = ['md', 'sm'] as const;\n\nexport type RichTextEditorSize = (typeof richTextEditorSizeNames)[number];\nexport type RichTextValue = JSONContent;\nexport type RichTextEditorHandle = {\n  focus: () => void;\n  editor: () => Editor | null;\n  setContent: (content: RichTextValue) => void;\n};\n\nexport interface RichTextKeywordAccount {\n  id: string;\n  label: string;\n}\n\nexport interface RichTextKeyword {\n  id: string;\n  label: string;\n  match?: readonly string[] | undefined;\n  icon?: ReactNode;\n  color?: string | undefined;\n  connected?: boolean | undefined;\n  account?: string | undefined;\n  accounts?: readonly RichTextKeywordAccount[] | undefined;\n}\n\nexport interface RichTextEditorProps {\n  ref?: Ref<RichTextEditorHandle> | undefined;\n  size?: RichTextEditorSize | null | undefined;\n  condensed?: boolean | undefined;\n  minRows?: number | undefined;\n  value: RichTextValue;\n  onChange: (value: RichTextValue) => void;\n  onSend: () => void;\n  extensions?: Extensions | undefined;\n  keywords?: readonly RichTextKeyword[] | undefined;\n  onKeywordConnect?: ((keyword: RichTextKeyword) => void) | undefined;\n  onKeywordAccountChange?: ((keyword: RichTextKeyword, accountId: string) => void | Promise<unknown>) | undefined;\n  placeholder?: string | undefined;\n  disabled?: boolean | undefined;\n  ariaLabel?: string | undefined;\n  ariaInvalid?: boolean | undefined;\n  ariaDescribedBy?: string | undefined;\n  ariaExpanded?: boolean | undefined;\n  ariaControls?: string | undefined;\n  ariaActiveDescendant?: string | undefined;\n  toolbarAddon?: ReactNode | undefined;\n  className?: string | undefined;\n}\n\nconst fenceLanguage = /^[\\w+#.-]{1,32}$/;\nconst typedFence = /```([\\w+#.-]{1,32})?\\s$/;\nconst fenceOnly = /^```([\\w+#.-]{1,32})?$/;\nconst openingFence = /^ {0,3}(?:(`{3,})([^`]*)|(~{3,})(.*))$/;\n\nfunction isFenceLine(state: EditorState) {\n  const { $from, empty } = state.selection;\n  if (!empty || $from.parent.type.name !== 'paragraph' || $from.parentOffset !== $from.parent.content.size)\n    return false;\n  return fenceOnly.test($from.parent.textBetween(0, $from.parentOffset, undefined, '\\n').split('\\n').at(-1) ?? '');\n}\n\nfunction markdownBlocks(schema: Schema, text: string) {\n  const blocks: ProseMirrorNode[] = [];\n  const lines = text.replace(/\\r\\n?/g, '\\n').split('\\n');\n  while (lines.length) {\n    const line = lines.shift()!;\n    const open = openingFence.exec(line);\n    if (!open) {\n      if (line.trim()) blocks.push(schema.nodes.paragraph!.create(null, schema.text(line)));\n      continue;\n    }\n    const fence = open[1] ?? open[3]!;\n    const info = (open[2] ?? open[4]!).trim().split(/\\s/)[0]!;\n    const closing = new RegExp(`^ {0,3}${fence[0]}{${fence.length},}\\\\s*$`);\n    const end = lines.findIndex(candidate => closing.test(candidate));\n    const code = (end === -1 ? lines.splice(0) : lines.splice(0, end + 1).slice(0, -1)).join('\\n');\n    blocks.push(\n      schema.nodes.codeBlock!.create(\n        { language: fenceLanguage.test(info) ? info : null },\n        code ? schema.text(code) : null,\n      ),\n    );\n  }\n  return blocks;\n}\n\nconst MarkdownCodeFence = Extension.create({\n  name: 'markdownCodeFence',\n  priority: 1000,\n  addInputRules() {\n    return [\n      new InputRule({\n        find: typedFence,\n        handler: ({ state, range, match }) => {\n          const { tr, schema } = state;\n          const codeBlock = schema.nodes.codeBlock!;\n          const $from = tr.doc.resolve(range.from);\n          if ($from.parent.type.name !== 'paragraph' || range.to !== $from.end()) return null;\n          const before = $from.nodeBefore;\n          const attrs = { language: match[1] ?? null };\n          if (!before) {\n            if (!$from.node(-1).canReplaceWith($from.index(-1), $from.indexAfter(-1), codeBlock)) return null;\n            tr.delete(range.from, range.to).setBlockType(range.from, range.from, codeBlock, attrs);\n            return;\n          }\n          if (before.type.name !== 'hardBreak') return null;\n          const splitAt = range.from - before.nodeSize;\n          tr.delete(splitAt, range.to);\n          if (!canSplit(tr.doc, splitAt, 1, [{ type: codeBlock, attrs }])) return null;\n          tr.split(splitAt, 1, [{ type: codeBlock, attrs }]);\n          tr.setSelection(TextSelection.create(tr.doc, splitAt + 2));\n        },\n      }),\n    ];\n  },\n  addProseMirrorPlugins() {\n    return [\n      new Plugin({\n        key: new PluginKey('markdownCodeFencePaste'),\n        props: {\n          handlePaste: (view, event) => {\n            const text = event.clipboardData?.getData('text/plain') ?? '';\n            if (\n              view.state.selection.$from.parent.type.spec.code ||\n              !text.split(/\\r\\n?|\\n/).some(line => openingFence.test(line))\n            )\n              return false;\n            const blocks = markdownBlocks(view.state.schema, text);\n            const slice = new Slice(\n              Fragment.from(blocks),\n              blocks[0]?.type.name === 'paragraph' ? 1 : 0,\n              blocks.at(-1)?.type.name === 'paragraph' ? 1 : 0,\n            );\n            view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView().setMeta('paste', true));\n            return true;\n          },\n        },\n      }),\n    ];\n  },\n});\n\nconst MessageFormatting = Extension.create({\n  name: 'messageFormatting',\n  extendMarkSchema(extension) {\n    if (extension.name === 'link') return { inclusive: false };\n    return {};\n  },\n  addProseMirrorPlugins() {\n    return [\n      new Plugin({\n        key: new PluginKey('clearDeletedLink'),\n        appendTransaction(transactions, oldState, state) {\n          const link = state.schema.marks.link;\n          if (\n            !link ||\n            !transactions.some(transaction => transaction.docChanged) ||\n            state.doc.content.size >= oldState.doc.content.size ||\n            !state.selection.empty ||\n            !state.storedMarks?.some(mark => mark.type === link)\n          )\n            return null;\n          if (\n            state.selection.$from.parent.content.size &&\n            state.selection.$from.marks().some(mark => mark.type === link)\n          )\n            return null;\n          return state.tr.removeStoredMark(link);\n        },\n      }),\n    ];\n  },\n});\n\nfunction within(state: EditorState, name: string) {\n  const { $from } = state.selection;\n  for (let depth = $from.depth; depth > 0; depth -= 1) if ($from.node(depth).type.name === name) return true;\n  return false;\n}\n\ntype KeywordSource = {\n  pattern: KeywordPattern | null;\n  signature: string;\n  revision: number;\n  focused: boolean;\n  glyph: (id: string) => Element | null;\n  connect: (id: string) => void;\n};\ntype KeywordState = { all: KeywordHit[]; hits: KeywordHit[]; pending: number | null; decorations: DecorationSet };\n\nconst statusTemplate = 'sprout-status';\nconst keywordKey = new PluginKey<KeywordState>('richTextKeywords');\n\nfunction docKeywords(doc: ProseMirrorNode, pattern: KeywordPattern | null) {\n  const hits: KeywordHit[] = [];\n  if (!pattern) return hits;\n  doc.descendants((node, pos) => {\n    if (!node.isTextblock) return true;\n    if (node.type.spec.code) return false;\n    let text = '';\n    node.forEach(child => {\n      text +=\n        child.isText && !child.marks.some(mark => mark.type.spec.code || mark.type.name === 'link')\n          ? child.text!\n          : objectReplacement.repeat(child.nodeSize);\n    });\n    scanText(text, pattern, pos + 1, hits);\n    return false;\n  });\n  return hits;\n}\n\nexport function findKeywords(value: RichTextValue, keywords: readonly RichTextKeyword[]): RichTextKeyword[] {\n  const pattern = keywordPattern(keywords);\n  if (!pattern) return [];\n  const hits: KeywordHit[] = [];\n  const visit = (node: JSONContent) => {\n    if (node.type === 'codeBlock' || !node.content) return;\n    if (!node.content.some(child => child.type === 'text')) return node.content.forEach(visit);\n    const text = node.content\n      .map(child =>\n        child.type === 'text' && !child.marks?.some(mark => mark.type === 'code' || mark.type === 'link')\n          ? (child.text ?? '')\n          : objectReplacement,\n      )\n      .join('');\n    scanText(text, pattern, 0, hits);\n  };\n  visit(value);\n  return [...new Set(hits.map(hit => hit.keyword))];\n}\n\nexport function keywordAccounts(value: RichTextValue, keywords: readonly RichTextKeyword[]): Record<string, string> {\n  return Object.fromEntries(\n    findKeywords(value, keywords)\n      .filter(keyword => keyword.connected !== false && keyword.account)\n      .map(keyword => [keyword.id, keyword.account!]),\n  );\n}\n\nfunction keywordWidget(kind: 'icon' | 'status', keyword: RichTextKeyword, glyph: Element | null) {\n  const widget = document.createElement('span');\n  widget.className = `sprout-rich-text-keyword-${kind}`;\n  widget.contentEditable = 'false';\n  widget.setAttribute('aria-hidden', 'true');\n  widget.dataset.keyword = keyword.id;\n  widget.dataset.connected = String(keyword.connected !== false);\n  const box = document.createElement('span');\n  box.className = 'sprout-rich-text-keyword-glyph';\n  if (glyph) box.append(glyph.cloneNode(true));\n  widget.append(box);\n  return widget;\n}\n\nfunction keywordDecorations(doc: ProseMirrorNode, hits: KeywordHit[], source: KeywordSource) {\n  const seen = new Map<string, number>();\n  const decorations: Decoration[] = [];\n  for (const { keyword, from, to } of hits) {\n    const index = seen.get(keyword.id) ?? 0;\n    seen.set(keyword.id, index + 1);\n    const key = `${keyword.id}:${index}:${source.revision}`;\n    const connected = keyword.connected !== false;\n    const icon = keyword.icon != null ? source.glyph(keyword.id) : null;\n    decorations.push(\n      Decoration.inline(from, to, {\n        class: 'sprout-rich-text-keyword',\n        'data-keyword': keyword.id,\n        'data-connected': String(connected),\n        ...(icon && { 'data-icon': '' }),\n        ...(keyword.color && { 'data-tinted': '', style: `--sprout-rich-text-keyword-color: ${keyword.color}` }),\n      }),\n    );\n    if (icon)\n      decorations.push(\n        Decoration.widget(from, () => keywordWidget('icon', keyword, icon), { side: -1, key: `${key}:icon` }),\n      );\n    if (!connected)\n      decorations.push(\n        Decoration.widget(\n          to,\n          () => {\n            const widget = keywordWidget('status', keyword, source.glyph(statusTemplate));\n            widget.addEventListener('mousedown', event => {\n              event.preventDefault();\n              source.connect(keyword.id);\n            });\n            return widget;\n          },\n          { side: 1, key: `${key}:status`, stopEvent: () => true },\n        ),\n      );\n  }\n  return DecorationSet.create(doc, decorations);\n}\n\nfunction stillTyping(state: EditorState, hit: KeywordHit) {\n  const { $from, empty, from } = state.selection;\n  if (!empty || from <= hit.from || $from.start() !== state.doc.resolve(hit.from).start()) return false;\n  return from <= hit.to || /^\\S*$/.test(state.doc.textBetween(hit.to, from, '\\n', objectReplacement));\n}\n\nfunction keywordExtension(source: KeywordSource) {\n  const build = (state: EditorState, all: KeywordHit[], typed: boolean, previous?: KeywordState, settle = false) => {\n    const candidates = settle ? [] : typed ? all : all.filter(hit => hit.from === previous?.pending);\n    const pending = candidates.find(hit => stillTyping(state, hit));\n    if (previous && previous.all === all && previous.pending === (pending?.from ?? null)) return previous;\n    const hits = pending ? all.filter(hit => hit !== pending) : all;\n    return { all, hits, pending: pending?.from ?? null, decorations: keywordDecorations(state.doc, hits, source) };\n  };\n  return Extension.create({\n    name: 'richTextKeywords',\n    addProseMirrorPlugins() {\n      return [\n        new Plugin<KeywordState>({\n          key: keywordKey,\n          state: {\n            init: (_, state): KeywordState => build(state, docKeywords(state.doc, source.pattern), false),\n            apply: (tr, previous, _, state) => {\n              if (tr.getMeta(keywordKey) === 'settle') return build(state, previous.all, false, previous, true);\n              const rescan = tr.docChanged || tr.getMeta(keywordKey);\n              const all = rescan ? docKeywords(state.doc, source.pattern) : previous.all;\n              return build(state, all, tr.docChanged && source.focused, previous);\n            },\n          },\n          props: { decorations: state => keywordKey.getState(state)?.decorations },\n        }),\n      ];\n    },\n  });\n}\n\ntype KeywordHint = { keyword: RichTextKeyword; left: number; top: number; bottom: number; below: boolean };\n\nconst noKeywords: readonly RichTextKeyword[] = [];\n\nconst allowedProtocols = ['http:', 'https:', 'mailto:'];\n\nconst baseExtensions: Extensions = [\n  StarterKit.configure({\n    heading: { levels: [1, 2, 3] },\n    horizontalRule: false,\n    underline: false,\n    link: {\n      openOnClick: false,\n      isAllowedUri: (url, context) => {\n        const protocol = /^[a-z][a-z\\d+.-]*:/i.exec(url)?.[0].toLowerCase();\n        return context.defaultValidate(url) && (!protocol || allowedProtocols.includes(protocol));\n      },\n    },\n  }),\n  MarkdownCodeFence,\n  MessageFormatting,\n];\n\nexport function RichTextEditor({\n  ref,\n  size,\n  condensed = false,\n  minRows,\n  value,\n  onChange,\n  onSend,\n  extensions = [],\n  keywords,\n  onKeywordConnect,\n  onKeywordAccountChange,\n  placeholder = 'Ask anything…',\n  disabled = false,\n  ariaLabel = 'Message',\n  ariaInvalid = false,\n  ariaDescribedBy,\n  ariaExpanded,\n  ariaControls,\n  ariaActiveDescendant,\n  toolbarAddon,\n  className,\n}: RichTextEditorProps) {\n  const scale = size ?? 'md';\n  const inline = condensed || scale === 'sm';\n  const rows = minRows === undefined ? undefined : Math.max(1, Math.round(minRows));\n  const onSendRef = useRef(onSend);\n  const onChangeRef = useRef(onChange);\n  const placeholderRef = useRef(placeholder);\n  const suggestionOpenRef = useRef(ariaExpanded ?? false);\n  onSendRef.current = onSend;\n  onChangeRef.current = onChange;\n  placeholderRef.current = placeholder;\n  suggestionOpenRef.current = ariaExpanded ?? false;\n  const keywordList = keywords ?? noKeywords;\n  const keywordById = useRef(new Map<string, RichTextKeyword>());\n  keywordById.current = new Map(keywordList.map(keyword => [keyword.id, keyword]));\n  const onKeywordConnectRef = useRef(onKeywordConnect);\n  onKeywordConnectRef.current = onKeywordConnect;\n  const root = useRef<HTMLDivElement>(null);\n  const templates = useRef<HTMLSpanElement>(null);\n  const bubble = useRef<HTMLDivElement>(null);\n  const hovered = useRef<number | null>(null);\n  const bubbleFocused = useRef(false);\n  const [menuOpen, setMenuOpen] = useState(false);\n  const menuId = useId();\n  const menuOpenRef = useRef(false);\n  menuOpenRef.current = menuOpen;\n  const [menuSide, setMenuSide] = useState<'top' | 'bottom' | null>(null);\n  const [pending, setPending] = useState<string | null>(null);\n  const [failed, setFailed] = useState(false);\n  const pendingToken = useRef<symbol | null>(null);\n  const caretChip = useRef<string | null>(null);\n  const hoverTimer = useRef<ReturnType<typeof setTimeout>>(undefined);\n  const announced = useRef(new Set<string>());\n  const [hint, setHint] = useState<KeywordHint | null>(null);\n  const [announcement, setAnnouncement] = useState('');\n  const template = (id: string) =>\n    [...(templates.current?.children ?? [])].find(el => (el as HTMLElement).dataset.keywordTemplate === id);\n  const source = useMemo<KeywordSource>(\n    () => ({\n      pattern: null,\n      signature: '',\n      revision: 0,\n      focused: false,\n      glyph: id => template(id)?.firstElementChild ?? null,\n      connect: id => {\n        const keyword = keywordById.current.get(id);\n        if (keyword) onKeywordConnectRef.current?.(keyword);\n      },\n    }),\n    [],\n  );\n  const keywordPlugin = useMemo(() => keywordExtension(source), [source]);\n  const configured = useMemo(\n    () => [\n      ...baseExtensions,\n      Placeholder.configure({ placeholder: () => placeholderRef.current }),\n      keywordPlugin,\n      ...extensions,\n    ],\n    [extensions, keywordPlugin],\n  );\n  const editor = useEditor({\n    immediatelyRender: false,\n    extensions: configured,\n    content: value,\n    editable: !disabled,\n    editorProps: {\n      attributes: {\n        'data-slot': 'input-group-control',\n        role: 'textbox',\n        'aria-label': ariaLabel,\n        'aria-disabled': String(disabled),\n        'aria-multiline': 'true',\n        'aria-autocomplete': 'list',\n        'aria-invalid': ariaInvalid ? 'true' : 'false',\n        ...(ariaDescribedBy && { 'aria-describedby': ariaDescribedBy }),\n        ...(ariaControls && { 'aria-controls': ariaControls }),\n        ...(ariaActiveDescendant && {\n          'aria-activedescendant': ariaActiveDescendant,\n        }),\n        class: 'sprout-rich-text-editor-content',\n      },\n      handleKeyDown: (view, event) => {\n        if (event.isComposing) return false;\n        if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n          event.preventDefault();\n          onSendRef.current();\n          return true;\n        }\n        if (event.key === 'Enter' && suggestionOpenRef.current) return false;\n        if (event.key === 'Enter' && isFenceLine(view.state)) return false;\n        if (\n          event.key === 'Enter' &&\n          !event.shiftKey &&\n          !within(view.state, 'listItem') &&\n          !within(view.state, 'codeBlock')\n        ) {\n          event.preventDefault();\n          onSendRef.current();\n          return true;\n        }\n        return false;\n      },\n    },\n    onUpdate: ({ editor: current }) => onChangeRef.current(current.getJSON()),\n  });\n\n  useImperativeHandle(\n    ref,\n    () => ({\n      focus: () => editor?.commands.focus(),\n      editor: () => editor,\n      setContent: content => editor?.commands.setContent(content, { emitUpdate: true }),\n    }),\n    [editor],\n  );\n\n  useLayoutEffect(() => {\n    const signature = JSON.stringify(\n      keywordList.map(keyword => [\n        keyword.id,\n        keyword.label,\n        keyword.match,\n        keyword.color,\n        keyword.connected !== false,\n        keyword.account,\n        keyword.accounts,\n        template(keyword.id)?.innerHTML ?? '',\n      ]),\n    );\n    if (signature === source.signature) return;\n    source.signature = signature;\n    source.revision += 1;\n    source.pattern = keywordPattern(keywordList);\n    if (editor && !editor.isDestroyed) editor.view.dispatch(editor.state.tr.setMeta(keywordKey, true));\n  });\n\n  const canSwitch = (keyword: RichTextKeyword) =>\n    keyword.connected !== false && (keyword.accounts?.length ?? 0) > 1 && !!onKeywordAccountChange && !disabled;\n  const describeHint = (keyword: RichTextKeyword) =>\n    keyword.connected === false\n      ? `${keyword.label} isn't connected.${onKeywordConnect && !disabled ? ' Press Tab to connect it.' : ''}`\n      : `${keyword.label} uses ${accountLabel(keyword)}.${canSwitch(keyword) ? ' Press Tab to change it.' : ''}`;\n\n  const updateHint = () => {\n    if (!editor || editor.isDestroyed || !root.current) return setHint(null);\n    const hits = keywordKey.getState(editor.state)?.hits ?? [];\n    const { from, empty } = editor.state.selection;\n    const hinted = hits.filter(hit => hasHint(hit.keyword));\n    const atCaret =\n      (editor.isFocused || bubbleFocused.current) && empty\n        ? hinted.find(hit => from > hit.from && from < hit.to)\n        : undefined;\n    if ((atCaret?.keyword.id ?? null) !== caretChip.current) {\n      caretChip.current = atCaret?.keyword.id ?? null;\n      if (atCaret && editor.isFocused) setAnnouncement(describeHint(atCaret.keyword));\n    }\n    const pick = (hovered.current !== null && hinted.find(hit => hit.from === hovered.current)) || atCaret;\n    if (!pick) return setHint(null);\n    const view = editor.view;\n    const start = view.coordsAtPos(pick.from, 1);\n    const end = view.coordsAtPos(pick.to, -1);\n    const frame = view.dom.getBoundingClientRect();\n    if (start.bottom < frame.top || start.top > frame.bottom) return setHint(null);\n    const box = root.current.getBoundingClientRect();\n    const below = start.top < 48;\n    setHint({\n      keyword: pick.keyword,\n      left: (start.left + end.right) / 2 - box.left,\n      top: start.top - box.top - 6,\n      bottom: end.bottom - box.top + 6,\n      below,\n    });\n  };\n  const updateHintRef = useRef(updateHint);\n  updateHintRef.current = updateHint;\n\n  useEffect(() => {\n    if (!editor) return;\n    source.focused = editor.isFocused;\n    const onTransaction = ({ transaction }: { transaction: { docChanged: boolean } }) => {\n      if (transaction.docChanged) {\n        hovered.current = null;\n        const hits = keywordKey.getState(editor.state)?.hits ?? [];\n        const offline = [...new Set(hits.filter(hit => hit.keyword.connected === false).map(hit => hit.keyword))];\n        for (const id of announced.current)\n          if (!offline.some(keyword => keyword.id === id)) announced.current.delete(id);\n        const fresh = offline.filter(keyword => !announced.current.has(keyword.id));\n        fresh.forEach(keyword => announced.current.add(keyword.id));\n        if (fresh.length)\n          setAnnouncement(\n            `${fresh.map(keyword => keyword.label).join(', ')} ${fresh.length > 1 ? \"aren't\" : \"isn't\"} connected.`,\n          );\n      }\n      updateHintRef.current();\n    };\n    const onBlur = ({ event }: { event: FocusEvent }) => {\n      if (bubble.current?.contains(event.relatedTarget as Node | null)) bubbleFocused.current = true;\n      source.focused = false;\n      if (!editor.isDestroyed) editor.view.dispatch(editor.state.tr.setMeta(keywordKey, 'settle'));\n      updateHintRef.current();\n    };\n    const onFocus = () => {\n      source.focused = true;\n      updateHintRef.current();\n    };\n    const onScroll = () => updateHintRef.current();\n    editor.on('transaction', onTransaction);\n    editor.on('focus', onFocus);\n    editor.on('blur', onBlur);\n    const scroller = editor.isDestroyed ? null : editor.view.dom;\n    scroller?.addEventListener('scroll', onScroll);\n    window.addEventListener('resize', onScroll);\n    return () => {\n      editor.off('transaction', onTransaction);\n      editor.off('focus', onFocus);\n      editor.off('blur', onBlur);\n      scroller?.removeEventListener('scroll', onScroll);\n      window.removeEventListener('resize', onScroll);\n    };\n  }, [editor]);\n  useEffect(() => () => clearTimeout(hoverTimer.current), []);\n\n  useLayoutEffect(() => {\n    const el = bubble.current;\n    const frame = root.current?.getBoundingClientRect();\n    const width = root.current?.clientWidth;\n    if (!hint || !el || !frame || !width) return;\n    const half = el.offsetWidth / 2;\n    el.style.left = `${Math.min(Math.max(hint.left, half), Math.max(half, width - half))}px`;\n    if (!menuOpen) {\n      el.style.removeProperty('--sprout-rich-text-keyword-menu-height');\n      if (!hint.below && el.getBoundingClientRect().top < 8) setHint({ ...hint, below: true });\n      return;\n    }\n    const menu = el.querySelector<HTMLElement>('[role=\"menu\"]');\n    if (!menu) return;\n    const space = {\n      top: frame.top + hint.top - 8,\n      bottom: window.innerHeight - (frame.top + hint.bottom) - 8,\n    };\n    if (!menuSide) {\n      const preferred = hint.below ? 'bottom' : 'top';\n      const other = preferred === 'top' ? 'bottom' : 'top';\n      setMenuSide(el.offsetHeight > space[preferred] && space[other] > space[preferred] ? other : preferred);\n      return;\n    }\n    const header = el.offsetHeight - menu.offsetHeight;\n    el.style.setProperty('--sprout-rich-text-keyword-menu-height', `${Math.max(80, space[menuSide] - header)}px`);\n  }, [hint, menuOpen, menuSide]);\n\n  const hintId = hint?.keyword.id;\n  useEffect(() => setMenuOpen(false), [hintId]);\n  useEffect(() => {\n    if (menuOpen) return;\n    pendingToken.current = null;\n    setPending(null);\n    setFailed(false);\n  }, [menuOpen]);\n  useLayoutEffect(() => {\n    if (!menuOpen) return;\n    const items = [...(bubble.current?.querySelectorAll<HTMLElement>('[role=\"menuitemradio\"]') ?? [])];\n    (items.find(item => item.getAttribute('aria-checked') === 'true') ?? items[0])?.focus({ preventScroll: true });\n    const close = (event: PointerEvent) => {\n      if (bubble.current?.contains(event.target as Node)) return;\n      setMenuOpen(false);\n      hovered.current = null;\n      updateHintRef.current();\n    };\n    document.addEventListener('pointerdown', close);\n    return () => document.removeEventListener('pointerdown', close);\n  }, [menuOpen]);\n\n  const closeMenu = () => {\n    setMenuOpen(false);\n    bubble.current?.querySelector<HTMLElement>('[aria-haspopup=\"menu\"]')?.focus();\n  };\n  const pickAccount = (keyword: RichTextKeyword, accountId: string) => {\n    if (pending) return;\n    if (accountId === keyword.account || !onKeywordAccountChange) return closeMenu();\n    const result = onKeywordAccountChange(keyword, accountId);\n    if (!result || typeof (result as Promise<unknown>).then !== 'function') return closeMenu();\n    const token = Symbol();\n    pendingToken.current = token;\n    setPending(accountId);\n    setFailed(false);\n    Promise.resolve(result).then(\n      () => {\n        if (pendingToken.current === token) closeMenu();\n      },\n      () => {\n        if (pendingToken.current !== token) return;\n        pendingToken.current = null;\n        setPending(null);\n        setFailed(true);\n        setAnnouncement(`Couldn't switch the ${keyword.label} account.`);\n      },\n    );\n  };\n  const menuKeys = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n    const items = [...event.currentTarget.querySelectorAll<HTMLElement>('[role=\"menuitemradio\"]')];\n    const index = items.indexOf(document.activeElement as HTMLElement);\n    const move = (next: number) => {\n      event.preventDefault();\n      items[(next + items.length) % items.length]?.focus();\n    };\n    if (event.key === 'ArrowDown') move(index + 1);\n    else if (event.key === 'ArrowUp') move(index - 1);\n    else if (event.key === 'Home') move(0);\n    else if (event.key === 'End') move(items.length - 1);\n    else if (event.key === 'Escape') {\n      event.preventDefault();\n      event.stopPropagation();\n      closeMenu();\n    } else if (event.key === 'Tab') setMenuOpen(false);\n  };\n\n  const hover = (target: EventTarget | null) => {\n    if (!editor || editor.isDestroyed) return;\n    const chip = (target as Element | null)?.closest?.(\n      '.sprout-rich-text-keyword, .sprout-rich-text-keyword-icon, .sprout-rich-text-keyword-status',\n    );\n    clearTimeout(hoverTimer.current);\n    if (chip) {\n      const pos = editor.view.posAtDOM(chip, 0);\n      const hit = keywordKey\n        .getState(editor.state)\n        ?.hits.find(candidate => hasHint(candidate.keyword) && pos >= candidate.from && pos <= candidate.to);\n      hovered.current = hit?.from ?? null;\n      updateHint();\n    } else if (hovered.current !== null && !menuOpenRef.current) {\n      hoverTimer.current = setTimeout(() => {\n        hovered.current = null;\n        updateHintRef.current();\n      }, 150);\n    }\n  };\n\n  useEffect(() => {\n    editor?.setEditable(!disabled, false);\n  }, [disabled, editor]);\n  useEffect(() => {\n    if (editor && !editor.isDestroyed) editor.view.dispatch(editor.state.tr);\n  }, [editor, placeholder]);\n  useEffect(() => {\n    if (editor && !editor.state.doc.eq(editor.schema.nodeFromJSON(value)))\n      editor.commands.setContent(value, { emitUpdate: false });\n  }, [editor, value]);\n\n  return (\n    <div\n      ref={root}\n      data-slot=\"rich-text-editor\"\n      data-size={scale}\n      data-condensed={condensed || undefined}\n      data-min-rows={rows}\n      data-disabled={disabled || undefined}\n      style={rows === undefined ? undefined : ({ '--sprout-rich-text-editor-min-rows': rows } as CSSProperties)}\n      className={cn(\n        'sprout-rich-text-editor',\n        `sprout-rich-text-editor-size-${scale}`,\n        condensed && 'sprout-rich-text-editor-condensed',\n        className,\n      )}\n    >\n      <div\n        className=\"sprout-rich-text-editor-body\"\n        onPointerOver={keywordList.length ? event => hover(event.target) : undefined}\n        onPointerLeave={keywordList.length ? () => hover(null) : undefined}\n      >\n        <EditorContent editor={editor} />\n      </div>\n      {keywordList.length > 0 && (\n        <>\n          <span ref={templates} hidden>\n            {keywordList.map(keyword =>\n              keyword.icon != null ? (\n                <span key={keyword.id} data-keyword-template={keyword.id}>\n                  {keyword.icon}\n                </span>\n              ) : null,\n            )}\n            <span data-keyword-template={statusTemplate}>\n              <LinkOffIcon aria-hidden=\"true\" />\n            </span>\n          </span>\n          <span className=\"sprout-rich-text-editor-sr-only\" role=\"status\" aria-live=\"polite\">\n            {announcement}\n          </span>\n        </>\n      )}\n      {hint && (\n        <div\n          ref={bubble}\n          data-slot=\"rich-text-keyword-hint\"\n          data-side={(menuOpen && menuSide ? menuSide === 'bottom' : hint.below) ? 'bottom' : 'top'}\n          data-menu={menuOpen || undefined}\n          className=\"sprout-rich-text-keyword-hint\"\n          style={{\n            left: hint.left,\n            top: (menuOpen && menuSide ? menuSide === 'bottom' : hint.below) ? hint.bottom : hint.top,\n          }}\n          onPointerEnter={() => clearTimeout(hoverTimer.current)}\n          onPointerLeave={() => hover(null)}\n          onFocus={() => {\n            bubbleFocused.current = true;\n          }}\n          onBlur={event => {\n            if (event.currentTarget.contains(event.relatedTarget)) return;\n            bubbleFocused.current = false;\n            updateHint();\n          }}\n          onKeyDown={event => {\n            if (event.key !== 'Escape') return;\n            event.preventDefault();\n            bubbleFocused.current = false;\n            hovered.current = null;\n            editor?.commands.focus();\n          }}\n        >\n          <KeywordHintBody keyword={hint.keyword} />\n          {canSwitch(hint.keyword) && (\n            <>\n              <button\n                type=\"button\"\n                className=\"sprout-rich-text-keyword-connect\"\n                aria-label={`Switch ${hint.keyword.label} account`}\n                aria-haspopup=\"menu\"\n                aria-expanded={menuOpen}\n                aria-controls={menuOpen ? menuId : undefined}\n                onMouseDown={event => event.preventDefault()}\n                onClick={() => {\n                  setMenuSide(null);\n                  setMenuOpen(open => !open);\n                }}\n              >\n                Switch\n              </button>\n              {menuOpen && (\n                <div\n                  id={menuId}\n                  role=\"menu\"\n                  aria-label={`${hint.keyword.label} accounts`}\n                  aria-busy={pending !== null || undefined}\n                  className=\"sprout-rich-text-keyword-menu\"\n                  onKeyDown={menuKeys}\n                >\n                  {hint.keyword.accounts!.map(account => {\n                    const current = account.id === hint.keyword.account;\n                    return (\n                      <button\n                        key={account.id}\n                        type=\"button\"\n                        role=\"menuitemradio\"\n                        aria-checked={current}\n                        aria-disabled={(pending !== null && pending !== account.id) || undefined}\n                        data-pending={pending === account.id || undefined}\n                        tabIndex={-1}\n                        className=\"sprout-rich-text-keyword-menu-item\"\n                        onPointerMove={event => {\n                          if (event.pointerType === 'mouse') event.currentTarget.focus();\n                        }}\n                        onClick={() => pickAccount(hint.keyword, account.id)}\n                      >\n                        <span>{account.label}</span>\n                        <span className=\"sprout-rich-text-keyword-menu-mark\" aria-hidden=\"true\">\n                          {pending === account.id ? (\n                            <Spinner size=\"sm\" aria-hidden=\"true\" />\n                          ) : (\n                            current && <CheckIcon size=\"sm\" aria-hidden=\"true\" />\n                          )}\n                        </span>\n                      </button>\n                    );\n                  })}\n                  {failed && (\n                    <span aria-hidden=\"true\" className=\"sprout-rich-text-keyword-menu-error\">\n                      Couldn't switch. Try again.\n                    </span>\n                  )}\n                </div>\n              )}\n            </>\n          )}\n          {hint.keyword.connected === false && onKeywordConnect && !disabled && (\n            <button\n              type=\"button\"\n              className=\"sprout-rich-text-keyword-connect\"\n              aria-label={`Connect ${hint.keyword.label}`}\n              onMouseDown={event => event.preventDefault()}\n              onClick={() => {\n                hovered.current = null;\n                onKeywordConnect(hint.keyword);\n              }}\n            >\n              Connect\n            </button>\n          )}\n        </div>\n      )}\n      {toolbarAddon && (\n        <div\n          data-slot=\"rich-text-editor-toolbar\"\n          className={cn('sprout-rich-text-editor-toolbar', inline && 'sprout-rich-text-editor-toolbar-inline')}\n        >\n          {toolbarAddon}\n        </div>\n      )}\n    </div>\n  );\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/check-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/check-icon.tsx",
      "content": "import { Tick02Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const CheckIcon = /* @__PURE__ */ createIcon(glyph, 'CheckIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/create-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/create-icon.tsx",
      "content": "import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react';\nimport type { ReactElement, Ref, SVGProps } from 'react';\n\nexport const iconSizes = {\n  xs: 12,\n  sm: 14,\n  md: 16,\n  lg: 18,\n  xl: 20,\n  '2xl': 24,\n} as const;\n\nexport type IconSize = keyof typeof iconSizes;\n\nexport const iconStrokeWidth = 1.5;\n\nexport type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {\n  size?: IconSize | number;\n  ref?: Ref<SVGSVGElement>;\n};\n\nexport type IconComponent = (props: IconProps) => ReactElement;\n\nexport function createIcon(glyph: IconSvgElement, name: string): IconComponent {\n  const Icon = ({ size = '2xl', strokeWidth = iconStrokeWidth, ...props }: IconProps) => (\n    <HugeiconsIcon\n      icon={glyph}\n      size={typeof size === 'number' ? size : iconSizes[size]}\n      strokeWidth={Number(strokeWidth)}\n      {...props}\n    />\n  );\n  Icon.displayName = name;\n  return Icon;\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/link-off-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/link-off-icon.tsx",
      "content": "import { Unlink01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const LinkOffIcon = /* @__PURE__ */ createIcon(glyph, 'LinkOffIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/keyword-hint.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/keyword-hint.tsx",
      "content": "import { LinkOffIcon } from '@/lib/sprout/icons/link-off-icon';\nimport type { RichTextKeyword } from '@/components/ui/rich-text-editor';\nimport { accountLabel } from '@/lib/sprout/keywords';\n\nexport function KeywordHintBody({ keyword }: { keyword: RichTextKeyword }) {\n  if (keyword.connected === false)\n    return (\n      <>\n        <LinkOffIcon size=\"sm\" aria-hidden=\"true\" />\n        <span>{keyword.label} isn't connected</span>\n      </>\n    );\n  return (\n    <>\n      {keyword.icon != null && (\n        <span className=\"sprout-rich-text-keyword-hint-icon\" aria-hidden=\"true\">\n          {keyword.icon}\n        </span>\n      )}\n      <span className=\"sprout-rich-text-keyword-hint-label\">{keyword.label}</span>\n      <span className=\"sprout-rich-text-keyword-hint-account\">{accountLabel(keyword)}</span>\n    </>\n  );\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/keywords.ts",
      "type": "registry:lib",
      "target": "lib/sprout/keywords.ts",
      "content": "import type { RichTextKeyword } from '@/components/ui/rich-text-editor';\n\nexport type KeywordHit = { keyword: RichTextKeyword; from: number; to: number };\nexport type KeywordPattern = { regex: RegExp; terms: Map<string, RichTextKeyword> };\n\nexport const objectReplacement = '\\ufffc';\n\nexport const accountLabel = (keyword: RichTextKeyword) =>\n  keyword.accounts?.find(account => account.id === keyword.account)?.label ?? keyword.account;\n\nexport const hasHint = (keyword: RichTextKeyword) => keyword.connected === false || !!keyword.account;\n\nconst normalizeTerm = (term: string) => term.trim().toLowerCase().replace(/\\s+/g, ' ');\n\nexport function keywordPattern(keywords: readonly RichTextKeyword[]): KeywordPattern | null {\n  const terms = new Map<string, RichTextKeyword>();\n  for (const keyword of keywords)\n    for (const term of keyword.match?.length ? keyword.match : [keyword.label]) {\n      const key = normalizeTerm(term);\n      if (key && !terms.has(key)) terms.set(key, keyword);\n    }\n  if (!terms.size) return null;\n  const alternatives = [...terms.keys()]\n    .sort((a, b) => b.length - a.length)\n    .map(term => term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/ /g, '\\\\s+'));\n  const word = '[\\\\p{L}\\\\p{N}_]';\n  const joiner = '[-./\\\\\\\\@:#~+=&?%]';\n  return {\n    regex: new RegExp(`(?<!${word}|${joiner})(?:${alternatives.join('|')})(?!${word}|${joiner}${word})`, 'giu'),\n    terms,\n  };\n}\n\nexport function scanText(text: string, pattern: KeywordPattern, offset: number, hits: KeywordHit[]) {\n  for (const match of text.matchAll(pattern.regex)) {\n    const keyword = pattern.terms.get(normalizeTerm(match[0]));\n    if (keyword) hits.push({ keyword, from: offset + match.index, to: offset + match.index + match[0].length });\n  }\n}\n"
    }
  ],
  "css": {
    "@layer components": {
      ".sprout-rich-text-editor": {
        "box-sizing": "border-box",
        "width": "100%",
        "min-width": "0",
        "color": "var(--sprout-text)",
        "position": "relative"
      },
      ".sprout-rich-text-editor-size-sm, .sprout-rich-text-editor-condensed": {
        "align-items": "flex-end",
        "display": "flex"
      },
      ".sprout-rich-text-editor[data-disabled]": {
        "cursor": "not-allowed",
        "opacity": ".6"
      },
      ".sprout-rich-text-editor-body": {
        "flex": "1",
        "min-width": "0",
        "min-height": "5rem"
      },
      ".sprout-rich-text-editor-size-sm > .sprout-rich-text-editor-body, .sprout-rich-text-editor-condensed > .sprout-rich-text-editor-body": {
        "min-height": "2.5rem"
      },
      ".sprout-rich-text-editor-content": {
        "box-sizing": "border-box",
        "border-radius": "var(--sprout-radius-control)",
        "min-height": "5rem",
        "max-height": "16rem",
        "color": "var(--sprout-text)",
        "font-family": "inherit",
        "font-size": "var(--sprout-text-base)",
        "overflow-wrap": "anywhere",
        "outline-offset": "0",
        "outline": "0 solid #0000",
        "padding": "8px 12px",
        "line-height": "1.5",
        "overflow-y": "auto"
      },
      ".sprout-rich-text-editor-size-sm .sprout-rich-text-editor-content": {
        "min-height": "2.5rem",
        "max-height": "8rem",
        "font-size": "var(--sprout-text-sm)",
        "line-height": "20px"
      },
      ".sprout-rich-text-editor-condensed .sprout-rich-text-editor-content": {
        "min-height": "2.5rem",
        "max-height": "8rem"
      },
      ".sprout-rich-text-editor[data-min-rows] > .sprout-rich-text-editor-body": {
        "min-height": "calc(var(--sprout-rich-text-editor-min-rows) * 1.5 * var(--sprout-text-base) + 16px)"
      },
      ".sprout-rich-text-editor-size-sm[data-min-rows] > .sprout-rich-text-editor-body": {
        "min-height": "calc(var(--sprout-rich-text-editor-min-rows) * 20px + 16px)"
      },
      ".sprout-rich-text-editor[data-min-rows] .sprout-rich-text-editor-content": {
        "min-height": "calc(var(--sprout-rich-text-editor-min-rows) * 1lh + 16px)"
      },
      ".sprout-rich-text-editor-content:focus-visible, .sprout-input-group .sprout-rich-text-editor-content:focus-visible": {
        "outline": "0 solid #0000"
      },
      ".sprout-rich-text-editor[data-disabled] .sprout-rich-text-editor-content": {
        "cursor": "not-allowed"
      },
      ".sprout-rich-text-editor-content .is-editor-empty:first-child:before": {
        "content": "attr(data-placeholder)",
        "float": "left",
        "height": "0",
        "color": "var(--sprout-muted)",
        "pointer-events": "none"
      },
      ".sprout-rich-text-editor-content :where(p, h1, h2, h3, blockquote, pre, ul, ol)": {
        "margin": "0"
      },
      ".sprout-rich-text-editor-content :where(h1, h2, h3)": {
        "font-weight": "600",
        "line-height": "1.4"
      },
      ".sprout-rich-text-editor-content h1": {
        "font-size": "1.25rem"
      },
      ".sprout-rich-text-editor-content h2": {
        "font-size": "1.125rem"
      },
      ".sprout-rich-text-editor-content h3": {
        "font-size": "1rem"
      },
      ".sprout-rich-text-editor-content :where(ul, ol)": {
        "padding-left": "24px"
      },
      ".sprout-rich-text-editor-content ul": {
        "list-style": "outside"
      },
      ".sprout-rich-text-editor-content ol": {
        "list-style": "decimal"
      },
      ".sprout-rich-text-editor-content li > p": {
        "margin": "0"
      },
      ".sprout-rich-text-editor-content blockquote": {
        "border-left": "2px solid var(--sprout-line)",
        "color": "var(--sprout-muted)",
        "padding-left": "12px"
      },
      ".sprout-rich-text-editor-content code": {
        "background-color": "var(--sprout-hover)",
        "border-radius": "4px",
        "padding": "0 4px",
        "font-family": "ui-monospace, SFMono-Regular, Menlo, monospace",
        "font-size": ".875em"
      },
      ".sprout-rich-text-editor-content pre": {
        "border-radius": "var(--sprout-radius-control)",
        "background-color": "var(--sprout-hover)",
        "padding": "12px",
        "overflow-x": "auto"
      },
      ".sprout-rich-text-editor-content pre code": {
        "white-space": "pre",
        "background-color": "#0000",
        "padding": "0"
      },
      ".sprout-rich-text-editor-content a": {
        "color": "var(--sprout-primary)",
        "text-underline-offset": "2px",
        "text-decoration": "underline"
      },
      ".sprout-rich-text-keyword": {
        "padding": "0 var(--sprout-rich-text-keyword-pad)",
        "border-radius": "var(--sprout-radius-control)",
        "background-color": "color-mix(in oklab, var(--sprout-text) 8%, transparent)",
        "color": "var(--sprout-text)",
        "white-space": "nowrap",
        "-webkit-box-decoration-break": "clone",
        "box-decoration-break": "clone",
        "font-weight": "500"
      },
      ".sprout-rich-text-keyword[data-icon]": {
        "padding-inline-start": "calc(var(--sprout-rich-text-keyword-pad) + var(--sprout-rich-text-keyword-icon) + var(--sprout-rich-text-keyword-gap))"
      },
      ".sprout-rich-text-keyword[data-tinted]": {
        "background-color": "color-mix(in oklab, var(--sprout-rich-text-keyword-color) 14%, transparent)",
        "color": "color-mix(in oklab, var(--sprout-rich-text-keyword-color) 62%, var(--sprout-text))"
      },
      ".sprout-rich-text-keyword[data-connected=\"false\"]": {
        "background-color": "color-mix(in oklab, var(--sprout-text) 8%, transparent)",
        "color": "var(--sprout-muted)",
        "padding-inline-end": "calc(var(--sprout-rich-text-keyword-pad) + var(--sprout-rich-text-keyword-mark) + var(--sprout-rich-text-keyword-gap))"
      },
      ".sprout-rich-text-keyword-icon, .sprout-rich-text-keyword-status": {
        "user-select": "none"
      },
      ".sprout-rich-text-keyword-glyph": {
        "position": "relative"
      },
      ".sprout-rich-text-keyword-glyph > *": {
        "width": "var(--sprout-rich-text-keyword-icon)",
        "height": "var(--sprout-rich-text-keyword-icon)",
        "place-items": "center",
        "display": "grid",
        "position": "absolute",
        "top": "50%",
        "translate": "0 -50%"
      },
      ".sprout-rich-text-keyword-glyph > * > svg, .sprout-rich-text-keyword-glyph > svg": {
        "width": "100%",
        "height": "100%",
        "display": "block"
      },
      ".sprout-rich-text-keyword-icon .sprout-rich-text-keyword-glyph > *": {
        "left": "var(--sprout-rich-text-keyword-pad)"
      },
      ".sprout-rich-text-editor-content, .sprout-message-rich-text": {
        "--sprout-rich-text-keyword-pad": ".4375em",
        "--sprout-rich-text-keyword-gap": ".5em",
        "--sprout-rich-text-keyword-icon": "1em",
        "--sprout-rich-text-keyword-mark": ".875em"
      },
      ".sprout-rich-text-keyword-status": {
        "cursor": "pointer"
      },
      ".sprout-rich-text-keyword-status .sprout-rich-text-keyword-glyph > *": {
        "right": "var(--sprout-rich-text-keyword-pad)",
        "width": "var(--sprout-rich-text-keyword-mark)",
        "height": "var(--sprout-rich-text-keyword-mark)",
        "color": "var(--sprout-muted)"
      },
      ".sprout-rich-text-keyword-icon[data-connected=\"false\"] .sprout-rich-text-keyword-glyph": {
        "filter": "grayscale()",
        "opacity": ".7"
      },
      ".sprout-rich-text-keyword-hint": {
        "z-index": "5",
        "box-sizing": "border-box",
        "border": "1px solid var(--sprout-line)",
        "border-radius": "var(--sprout-radius-panel)",
        "background": "var(--sprout-popover)",
        "width": "max-content",
        "max-width": "min(20rem, 100%)",
        "color": "var(--sprout-text)",
        "box-shadow": "var(--sprout-shadow-overlay)",
        "font-family": "var(--sprout-font)",
        "font-size": "var(--sprout-text-xs)",
        "white-space": "nowrap",
        "align-items": "center",
        "gap": "6px",
        "padding": "4px 4px 4px 10px",
        "font-weight": "400",
        "line-height": "1rem",
        "display": "flex",
        "position": "absolute",
        "translate": "-50% -100%"
      },
      ".sprout-rich-text-keyword-hint[data-side=\"bottom\"]": {
        "translate": "-50%"
      },
      ".sprout-rich-text-keyword-hint:not(:has(button))": {
        "padding-inline-end": "10px"
      },
      ":is(.sprout-rich-text-keyword-hint, .sprout-message-rich-text-hint) > svg": {
        "color": "var(--sprout-muted)",
        "flex-shrink": "0"
      },
      ".sprout-rich-text-keyword-hint-icon": {
        "flex-shrink": "0",
        "width": "14px",
        "height": "14px",
        "display": "grid"
      },
      ":is(.sprout-rich-text-keyword-hint, .sprout-message-rich-text-hint) .sprout-rich-text-keyword-hint-icon[aria-hidden] > *, :is(.sprout-rich-text-keyword-hint, .sprout-message-rich-text-hint) .sprout-rich-text-keyword-hint-icon[aria-hidden] svg": {
        "width": "100%",
        "height": "100%",
        "display": "block"
      },
      ".sprout-rich-text-keyword-hint-label": {
        "flex-shrink": "0",
        "font-weight": "500"
      },
      ".sprout-rich-text-keyword-hint[data-menu]": {
        "flex-wrap": "wrap",
        "min-width": "14rem",
        "padding": "4px",
        "padding-inline-start": "10px"
      },
      ".sprout-rich-text-keyword-hint[data-menu] .sprout-rich-text-keyword-hint-account": {
        "display": "none"
      },
      ".sprout-rich-text-keyword-hint[data-menu] .sprout-rich-text-keyword-hint-label": {
        "flex": "1"
      },
      ".sprout-rich-text-keyword-menu": {
        "max-height": "min(16rem, var(--sprout-rich-text-keyword-menu-height, 16rem))",
        "overscroll-behavior": "contain",
        "border-top": "1px solid var(--sprout-line)",
        "flex-direction": "column",
        "flex-basis": "100%",
        "gap": "1px",
        "margin-inline-start": "-6px",
        "padding-top": "4px",
        "display": "flex",
        "overflow-y": "auto"
      },
      ".sprout-rich-text-keyword-menu-item": {
        "border-radius": "var(--sprout-radius-control)",
        "min-height": "28px",
        "color": "var(--sprout-text)",
        "font": "inherit",
        "text-align": "start",
        "cursor": "pointer",
        "background": "none",
        "border": "0",
        "flex-shrink": "0",
        "justify-content": "space-between",
        "align-items": "center",
        "gap": "8px",
        "padding": "0 6px",
        "display": "flex",
        "position": "relative"
      },
      ".sprout-rich-text-keyword-menu-item > span:first-child": {
        "text-overflow": "ellipsis",
        "min-width": "0",
        "overflow": "hidden"
      },
      ".sprout-rich-text-keyword-menu-mark": {
        "flex-shrink": "0",
        "place-items": "center",
        "width": "14px",
        "height": "14px",
        "display": "grid"
      },
      ".sprout-rich-text-keyword-menu-item:focus": {
        "background": "var(--sprout-hover)",
        "outline": "0"
      },
      ".sprout-rich-text-keyword-menu-item[aria-disabled=\"true\"]": {
        "opacity": ".5",
        "cursor": "default"
      },
      ".sprout-rich-text-keyword-menu-item[data-pending]": {
        "cursor": "progress"
      },
      ".sprout-rich-text-keyword-menu-error": {
        "color": "var(--sprout-danger)",
        "padding": "4px 6px 2px"
      },
      "@media (pointer: coarse)": {
        ".sprout-rich-text-keyword-menu-item": {
          "min-height": "44px"
        },
        ".sprout-rich-text-keyword-connect:after": {
          "content": "\"\"",
          "position": "absolute",
          "inset": "-12px -4px"
        }
      },
      ".sprout-rich-text-keyword-hint-account": {
        "min-width": "0",
        "color": "var(--sprout-muted)",
        "text-overflow": "ellipsis",
        "overflow": "hidden"
      },
      ".sprout-rich-text-keyword-connect": {
        "border-radius": "var(--sprout-radius-control)",
        "background": "var(--sprout-secondary)",
        "height": "20px",
        "color": "var(--sprout-text)",
        "font": "inherit",
        "cursor": "pointer",
        "border": "0",
        "padding": "0 6px",
        "font-weight": "500",
        "position": "relative"
      },
      ".sprout-rich-text-keyword-connect:active": {
        "background": "var(--sprout-active)"
      },
      ".sprout-rich-text-keyword-connect:focus-visible": {
        "outline": "var(--sprout-focus-width) solid var(--sprout-focus-ring)",
        "outline-offset": "1px"
      },
      "@media (hover: hover) and (pointer: fine)": {
        ".sprout-rich-text-keyword-connect:hover": {
          "background": "var(--sprout-hover)"
        }
      },
      ".sprout-rich-text-editor-sr-only": {
        "clip-path": "inset(50%)",
        "white-space": "nowrap",
        "width": "1px",
        "height": "1px",
        "position": "absolute",
        "overflow": "hidden"
      },
      ".sprout-rich-text-editor-toolbar": {
        "box-sizing": "border-box",
        "border-top": "1px solid var(--sprout-line)",
        "flex-wrap": "wrap",
        "align-items": "center",
        "gap": "4px",
        "min-height": "32px",
        "padding": "4px 8px",
        "display": "flex"
      },
      ".sprout-rich-text-editor-toolbar-inline": {
        "border-top": "0",
        "flex-wrap": "nowrap",
        "flex-shrink": "0",
        "min-height": "0",
        "padding": "4px"
      },
      "@media (prefers-reduced-motion: no-preference)": {
        ".sprout-rich-text-editor": {
          "transition": "opacity var(--sprout-motion-fast, .12s) ease-out"
        },
        ".sprout-rich-text-editor-content": {
          "transition": "outline-color var(--sprout-motion-fast, .12s) ease-out"
        },
        ".sprout-rich-text-keyword": {
          "animation": "sprout-rich-text-keyword-fill var(--sprout-motion-fast, .12s) ease-out"
        },
        ".sprout-rich-text-keyword-glyph > *, .sprout-rich-text-keyword-menu": {
          "animation": "sprout-rich-text-keyword-fade var(--sprout-motion-fast, .12s) ease-out"
        },
        ".sprout-rich-text-keyword-hint": {
          "transform-origin": "bottom",
          "animation": "sprout-rich-text-keyword-pop var(--sprout-motion-fast, .12s) var(--sprout-motion-ease, ease-out)"
        },
        ".sprout-rich-text-keyword-hint[data-side=\"bottom\"]": {
          "transform-origin": "top"
        },
        ".sprout-status-mark": {
          "animation": "sprout-status-enter .28s var(--sprout-motion-ease) backwards",
          "transition": "transform var(--sprout-motion-normal) var(--sprout-motion-ease)"
        },
        ".sprout-status-glyph": {
          "animation": "sprout-status-draw .3s var(--sprout-motion-ease) 90ms backwards"
        },
        ".sprout-status-dot": {
          "animation": "sprout-status-pop .22s var(--sprout-motion-ease) .16s backwards"
        },
        ".sprout-status-ring": {
          "transition": "stroke var(--sprout-motion-normal) ease"
        },
        ".sprout-status-segment": {
          "transition": "stroke var(--sprout-motion-normal) var(--sprout-motion-ease)"
        },
        ".sprout-status-segment[data-segment=\"active\"]": {
          "animation": "1.4s ease-in-out infinite alternate sprout-status-fade-cycle"
        },
        ".sprout-status-spin": {
          "animation": "1s linear infinite sprout-status-spin"
        },
        "@media (hover: hover) and (pointer: fine)": {
          ".sprout-status:hover .sprout-status-mark": {
            "transform": "scale(1.15)"
          },
          ".sprout-status:hover .sprout-status-ring": {
            "stroke": "currentColor"
          }
        }
      },
      "@keyframes sprout-rich-text-keyword-fill": {
        "from": {
          "background-color": "#0000"
        }
      },
      "@keyframes sprout-rich-text-keyword-fade": {
        "from": {
          "opacity": "0"
        }
      },
      "@keyframes sprout-rich-text-keyword-pop": {
        "from": {
          "opacity": "0",
          "scale": ".97"
        }
      },
      "@media (forced-colors: active)": {
        ".sprout-rich-text-editor-content:focus-visible": {
          "outline-color": "highlight"
        },
        ".sprout-rich-text-editor-toolbar": {
          "border-top-color": "canvastext"
        },
        ".sprout-rich-text-editor-toolbar-inline": {
          "border-top": "0"
        },
        ".sprout-rich-text-keyword": {
          "border": "1px solid canvastext"
        },
        ".sprout-status": {
          "--sprout-status-color": "CanvasText"
        },
        ".sprout-status[data-state=\"running\"]": {
          "--sprout-status-color": "Highlight"
        },
        ".sprout-status-ring, .sprout-status-track, .sprout-status-segment[data-segment=\"todo\"]": {
          "stroke": "graytext"
        },
        ".sprout-status-glyph": {
          "stroke": "canvas"
        },
        ".sprout-status-dot": {
          "fill": "canvas"
        }
      },
      ".sprout-status": {
        "--sprout-status-color": "var(--sprout-muted)",
        "width": "16px",
        "height": "16px",
        "color": "var(--sprout-status-color)",
        "vertical-align": "-.1875em",
        "flex-shrink": "0",
        "display": "inline-flex"
      },
      ".sprout-status-size-sm": {
        "width": "12px",
        "height": "12px"
      },
      ".sprout-status-size-lg": {
        "width": "20px",
        "height": "20px"
      },
      ".sprout-status[data-state=\"running\"]": {
        "--sprout-status-color": "var(--sprout-info)"
      },
      ".sprout-status[data-state=\"running\"][data-determinate], .sprout-status[data-state=\"success\"]": {
        "--sprout-status-color": "var(--sprout-success)"
      },
      ".sprout-status[data-state=\"warning\"]": {
        "--sprout-status-color": "var(--sprout-warning)"
      },
      ".sprout-status[data-state=\"error\"]": {
        "--sprout-status-color": "var(--sprout-danger)"
      },
      ".sprout-status-mark": {
        "transform-origin": "center",
        "width": "100%",
        "height": "100%",
        "display": "block",
        "overflow": "visible"
      },
      ".sprout-status-ring, .sprout-status-track, .sprout-status-arc, .sprout-status-segment": {
        "stroke-width": "2px"
      },
      ".sprout-status-ring": {
        "stroke": "color-mix(in oklab, currentColor 72%, transparent)"
      },
      ".sprout-status-track": {
        "stroke": "color-mix(in oklab, currentColor 22%, transparent)"
      },
      ".sprout-status-arc, .sprout-status-segment": {
        "stroke": "currentColor",
        "stroke-linecap": "round"
      },
      ".sprout-status-segment[data-segment=\"todo\"]": {
        "stroke": "color-mix(in oklab, var(--sprout-muted) 30%, transparent)"
      },
      ".sprout-status-segments, .sprout-status-spin": {
        "transform-box": "view-box",
        "transform-origin": "50%",
        "transform": "rotate(-90deg)"
      },
      ".sprout-status-fill": {
        "fill": "currentColor"
      },
      ".sprout-status-glyph": {
        "stroke": "var(--sprout-surface)",
        "stroke-width": "2px",
        "stroke-linecap": "round",
        "stroke-linejoin": "round",
        "stroke-dasharray": "1"
      },
      ".sprout-status-mark[data-mark=\"paused\"] .sprout-status-glyph, .sprout-status-mark[data-mark=\"skipped\"] .sprout-status-glyph": {
        "stroke": "currentColor"
      },
      ".sprout-status-dot": {
        "fill": "var(--sprout-surface)",
        "transform-box": "fill-box",
        "transform-origin": "center"
      },
      "@media (prefers-reduced-motion: reduce)": {
        ".sprout-status-mark": {
          "animation": ".16s ease-out backwards sprout-status-fade"
        },
        ".sprout-status-segment[data-segment=\"active\"]": {
          "opacity": ".55"
        }
      },
      "@keyframes sprout-status-enter": {
        "from": {
          "opacity": "0",
          "transform": "scale(.6)"
        }
      },
      "@keyframes sprout-status-draw": {
        "from": {
          "stroke-dashoffset": "1px"
        }
      },
      "@keyframes sprout-status-pop": {
        "from": {
          "opacity": "0",
          "transform": "scale(.4)"
        }
      },
      "@keyframes sprout-status-fade": {
        "from": {
          "opacity": "0"
        }
      },
      "@keyframes sprout-status-fade-cycle": {
        "from": {
          "opacity": ".25"
        },
        "to": {
          "opacity": "1"
        }
      },
      "@keyframes sprout-status-spin": {
        "from": {
          "transform": "rotate(-90deg)"
        },
        "to": {
          "transform": "rotate(270deg)"
        }
      }
    }
  },
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/rich-text-editor/",
  "meta": {
    "source": "packages/sprout/src/components/rich-text-editor.tsx"
  }
}
