/** * Pure state machine for the rich questionnaire form. * * Keeping keyboard intent and answer collection separate from PI's TUI makes the interaction contract * directly testable: a multi-page form completes only from its final Submit page, and Space toggles a * checkbox without leaving the current question. */ import type { Question, Questionnaire, QuestionOption } from "../flow/questionnaire.ts"; import { type RawSelection } from "./answer-assembly.ts"; export type FormEvent = { kind: "key-up"; } | { kind: "key-down"; } | { kind: "navigate"; delta: -1 | 1; text?: string; } | { kind: "key-enter"; } | { kind: "key-escape"; } | { kind: "key-space"; } | { kind: "editor-submit"; value: string; }; export type FormEffect = { kind: "render"; } | { kind: "editor-set-text"; text: string; } | { kind: "done"; cancelled: boolean; }; export interface FormState { readonly questionnaire: Questionnaire; readonly currentPage: number; readonly optionIndex: number; readonly inputMode: boolean; readonly answers: ReadonlyMap; } export interface FormTransition { readonly state: FormState; readonly effects: FormEffect[]; } type RenderOption = QuestionOption & { readonly isOther?: boolean; }; export declare function initialFormState(questionnaire: Questionnaire): FormState; export declare function currentFormQuestion(state: FormState): Question | undefined; export declare function currentFormOptions(state: FormState): RenderOption[]; export declare function isSubmitPage(state: FormState): boolean; export declare function allQuestionsAnswered(state: FormState): boolean; export declare function formAnswers(state: FormState): Record; export declare function reduceForm(state: FormState, event: FormEvent): FormTransition; export {}; //# sourceMappingURL=questionnaire-form-state.d.ts.map