import { useState } from "react"; import { InfoIcon, LoaderIcon, SearchIcon } from "@chopin/icons"; import { ReferencePicker } from "../chat/reference-picker"; import { ReferenceErrorIcon } from "./reference-status-icon"; import type { ComponentProps } from "react"; export function ReferenceMenu( { active, id, onActive, onSelect, state }: ComponentProps, ) { let [animate] = useState(() => document.documentElement.dataset.motionInput === "pointer"); let empty = state.status === "ready" && state.options.length === 0; let status = ["loading", "limit", "error"].includes(state.status) || empty; let message = state.status === "loading" ? "Loading documents..." : state.status === "limit" ? "A message can include up to 10 references." : state.status === "error" ? state.error instanceof Error ? state.error.message : "Could not load references." : state.status === "ready" && state.truncated ? "No matches in the available documents." : "No matching documents."; return (
{status && state.options.length === 0 ? (

{state.status === "loading" ? : state.status === "error" ? : state.status === "limit" ? : } {message}

{state.status === "ready" && state.truncated && (

Some documents are not shown.

)}
) : ( )}
); }