import { createContext, useContext } from 'react' import type { SystemId } from '@/lib/types' import type { useChat } from './useChat' /** What ChatProvider shares with the pages: the conversation (useChat) and the box's * settings. In its own file: a file that exports a component should export only * components (Vite fast refresh). */ export type ChatState = ReturnType & { system: SystemId setSystem: (s: SystemId) => void day: string | null setDay: (d: string | null) => void } export const ChatContext = createContext(null) export function useChatContext(): ChatState { const state = useContext(ChatContext) if (!state) throw new Error('useChatContext needs a ChatProvider above it') return state }