import { Type } from "typebox";
import { LABELS_BY_KIND, ROW_INTENT_META } from "../state/row-intent.js";
export const MAX_QUESTIONS = 4;
export const MIN_OPTIONS = 2;
export const MAX_OPTIONS = 4;
export const MAX_HEADER_LENGTH = 16;
export const MAX_LABEL_LENGTH = 60;
/**
 * User-facing labels for the three runtime sentinel rows, keyed by their
 * `WrappingSelectItem.kind` discriminator. Sourced from
 * `ROW_INTENT_META` via `LABELS_BY_KIND` (`row-intent.ts`) — single source of
 * truth. Adding a new sentinel requires extending the `WrappingSelectItem`
 * union AND adding an entry to `ROW_INTENT_META`; this map then auto-extends.
 */
export const SENTINEL_LABELS = LABELS_BY_KIND;
/**
 * Labels reserved for Pi-internal sentinels — authoring an option with any
 * of these labels triggers the `reserved_label` runtime guard. Three of the
 * four come from `ROW_INTENT_META` (the runtime kinds); `"Other"` is
 * reserved for CC parity only (the model is conditioned to reach for
 * "Other" in CC; we reject it so the runtime sentinel is the single source
 * of truth) and has no runtime kind.
 *
 * Reserved unconditionally — multiSelect questions also reject these labels
 * even though the runtime sentinel is suppressed there.
 *
 * Order is pinned by `types.test.ts:292` — keep the explicit
 * `["Other", other, chat, next]` literal so consumers using
 * `RESERVED_LABELS[i]` indexing or `Set` membership see no behavior change.
 */
export const RESERVED_LABELS = [
    "Other",
    ROW_INTENT_META.other.label,
    ROW_INTENT_META.chat.label,
    ROW_INTENT_META.next.label,
];
export const OptionSchema = Type.Object({
    label: Type.String({
        maxLength: MAX_LABEL_LENGTH,
        description: `MAX ${MAX_LABEL_LENGTH} CHARACTERS — hard limit, requests over the limit are rejected. The display text for this option that the user will see and select. Should be concise (1-5 words) and clearly describe the choice.`,
    }),
    description: Type.String({
        description: "Explanation of what this option means or what will happen if chosen. Useful for providing context about trade-offs or implications.",
    }),
    preview: Type.Optional(Type.String({
        description: "Optional preview content rendered when this option is focused. Use for mockups, code snippets, or visual comparisons that help users compare options. See the tool description for the expected content format.",
    })),
});
export const QuestionSchema = Type.Object({
    question: Type.String({
        description: 'The complete question to ask the user. Should be clear, specific, and end with a question mark. Example: "Which library should we use for date formatting?" If multiSelect is true, phrase it accordingly, e.g. "Which features do you want to enable?"',
    }),
    header: Type.String({
        maxLength: MAX_HEADER_LENGTH,
        description: `MAX ${MAX_HEADER_LENGTH} CHARACTERS — hard limit, requests over the limit are rejected. Very short chip/tag shown next to the question. Examples: "Auth method", "Library", "Approach".`,
    }),
    options: Type.Array(OptionSchema, {
        minItems: MIN_OPTIONS,
        maxItems: MAX_OPTIONS,
        description: "The available choices for this question. Must have 2-4 options. Each option should be a distinct, mutually exclusive choice (unless multiSelect is enabled). The 'Type something.' row is appended automatically — do NOT author it.",
    }),
    multiSelect: Type.Optional(Type.Boolean({
        default: false,
        description: "Set to true to allow the user to select multiple options instead of just one. Use when choices are not mutually exclusive.",
    })),
});
export const QuestionsSchema = Type.Array(QuestionSchema, {
    minItems: 1,
    maxItems: MAX_QUESTIONS,
    description: "Questions to ask the user (1-4 questions)",
});
export const QuestionParamsSchema = Type.Object({
    questions: QuestionsSchema,
});
export function isQuestionnaireResult(value) {
    if (!value || typeof value !== "object")
        return false;
    const v = value;
    return Array.isArray(v.answers) && typeof v.cancelled === "boolean";
}
//# sourceMappingURL=types.js.map