function scopeAnswers(q) {
    if (q.includes('primary goal') || q.includes('problem does it solve')) {
        return [
            'Improve user productivity by automating a manual workflow',
            'Provide a new self-service capability for end users',
            'Reduce errors in an existing process by adding validation',
        ];
    }
    if (q.includes('target users') || q.includes('user roles')) {
        return [
            'All authenticated users with standard permissions',
            'Admin users only — restricted access',
            'Multiple roles: admins can configure, regular users can use',
        ];
    }
    if (q.includes('must-have') || q.includes('p0') || q.includes('nice-to-have')) {
        return [
            'P0: core CRUD operations and basic validation. P1: advanced filters and exports',
            'P0: happy path for primary use case. P2: edge cases and bulk operations',
            'P0: backend API + basic UI. P1: analytics and notifications',
        ];
    }
    if (q.includes('"done"') || q.includes('ideal') || q.includes('happy-path')) {
        return [
            'User completes the action without errors; data is persisted and visible immediately',
            'Feature works end-to-end for the primary use case; no regressions in existing flows',
            'All defined acceptance criteria pass; automated tests are green',
        ];
    }
    return null;
}
function resolveDbLabel(database) {
    return database && database !== 'unknown' ? database : 'the database';
}
function techAnswers(q, ctx) {
    if (q.includes('performance') || q.includes('response time') || q.includes('throughput')) {
        return [
            'No strict SLA — typical web response times (<2s) are acceptable',
            'P95 < 500ms; up to 1000 concurrent users',
            'Batch operations can be async; interactive operations < 1s',
        ];
    }
    if (q.includes('database') || q.includes('table') || q.includes('schema')) {
        const db = resolveDbLabel(ctx.database);
        return [
            `Yes, a new ${db} table is needed for this entity`,
            `No new tables — extends an existing schema with new columns`,
            `Undecided — needs design review before committing to a schema`,
        ];
    }
    if (q.includes('authentication') || q.includes('authorization') || q.includes('permission')) {
        return [
            'Standard session/JWT authentication; no special permissions needed',
            'Role-based: admin can manage, viewer can read-only',
            'Same auth as the rest of the app — no new auth work required',
        ];
    }
    // Dependency check before API to avoid matching "APIs" in "external APIs" dependency questions
    if (q.includes('depend') || q.includes('external service')) {
        return [
            'No external dependencies — fully self-contained',
            'Depends on [specify service] — integration needed',
            'Depends on SPEC-XXX being completed first',
        ];
    }
    if (q.includes('endpoint') || q.includes('request') || q.includes('response shape')) {
        return [
            'Standard REST CRUD: GET /resources, POST /resources, PUT /resources/:id, DELETE /resources/:id',
            'Follows existing API contract — no new endpoints needed, extend current ones',
            'New endpoints needed — design TBD during spec review',
        ];
    }
    if (q.includes('patterns') || q.includes('components') || q.includes('reused')) {
        const fw = ctx.framework ?? 'the framework';
        return [
            `Yes — reuse existing ${fw} components and follow established patterns`,
            'Mostly new — this is a greenfield area with no existing patterns',
            'Partially reuse existing patterns; some new components needed',
        ];
    }
    return null;
}
function processAnswers(q) {
    if (q.includes('deadline') || q.includes('timeline')) {
        return [
            'No hard deadline — can be scheduled in next sprint',
            'Needed before next release — high urgency',
            'Blocking another team — must ship within 2 weeks',
        ];
    }
    if (q.includes('mockup') || q.includes('wireframe') || q.includes('design')) {
        return [
            'Yes — designs are ready in Figma, link: [to be provided]',
            'No formal designs — follow existing UI patterns and component library',
            'Rough wireframe exists — needs UX review before final design',
        ];
    }
    if (q.includes('rank') || q.includes('blocking')) {
        return [
            'High priority — blocking other work or a release',
            'Medium priority — important but not urgent',
            'Low priority — can be deferred to a later sprint',
        ];
    }
    return null;
}
/** Generate 2-3 context-aware suggested answers for a clarification question. */
export function generateSuggestedAnswers(question, ctx) {
    const q = question.question.toLowerCase();
    return (scopeAnswers(q) ??
        techAnswers(q, ctx) ??
        processAnswers(q) ?? [
        'To be confirmed with the product team',
        'No specific requirement at this time',
        'Needs further investigation before committing to an answer',
    ]);
}
/** Enrich a list of questions with context-aware suggested answers. */
export function enrichQuestionsWithSuggestedAnswers(questions, ctx) {
    return questions.map((q) => ({
        ...q,
        suggestedAnswers: generateSuggestedAnswers(q, ctx),
    }));
}
//# sourceMappingURL=questions.js.map