import type { MyGak } from './myGakState' import { createContext, use } from 'react' export type SharePayload = { title: string; slides: HTMLElement[] } type CommentsState = { type: 'comments'; postId: number; draft?: string } export type SheetState = | { type: 'gak'; indexId: number } | { type: 'article'; articleId: number } | { type: 'share'; share: SharePayload } | CommentsState | { type: 'seasonWeek' } | { type: 'login'; then?: CommentsState } | { type: 'me' } | { type: 'region' } | { type: 'mix'; shared?: MyGak } | null export type SheetApi = { open: (s: Exclude) => void; close: () => void } export const SheetContext = createContext(null) export function useSheet() { const ctx = use(SheetContext) if (!ctx) throw new Error('useSheet must be used inside SheetProvider') return ctx }