import { useState } from "react";
import { twMerge } from "tailwind-merge";
import Modal from "@moduletrace/twui/elements/Modal";
import Button from "@moduletrace/twui/layout/Button";
import H2 from "@moduletrace/twui/layout/H2";
import Span from "@moduletrace/twui/layout/Span";
import Stack from "@moduletrace/twui/layout/Stack";
import { KeyRound } from "lucide-react";
import useSecretRequest from "../(hooks)/use-secret-request";
import SecretRequestCard from "./secret-request-card";
type Props = {
request_id: number;
};
const StatusLabels = {
pending: "waiting for you",
saved: "saved",
declined: "declined",
} as const;
/**
* A secret a bot asked for (`secretRequestRef`): a chip naming its key and
* where it stands, which opens the card the user types it into. Anyone it
* wasn't asked of sees its number only.
*/
export default function SecretRequestRefChip({ request_id }: Props) {
const { view, loading, setView } = useSecretRequest({ request_id });
const [open, setOpen] = useState(false);
if (!view) {
return (
{loading ? `secret request ${request_id}` : `secret request ${request_id} (not available)`}
);
}
const status = StatusLabels[view.status];
return (
{`${view.key} ยท ${status}`}
}
targetWrapperProps={{ className: "inline-flex max-w-full align-middle" }}
open={open}
setOpen={setOpen}
className="max-w-xl bg-paper p-6"
>
{`${view.bot_name} asks for ${view.key}`}
{`Type it here rather than in the chat: what you write in the chat goes to the bot's model provider, this never does.`}
setOpen(false)} />
);
}