async function handler(ctx) {
    const { projectId } = ctx;
    if (!projectId) {
        return;
    }
    try {
        const { listActuals, saveCalibration } = await import('../../../storage/actuals-store.js');
        const { computeCalibrationFactors } = await import('../../estimation-calibrator.js');
        const records = await listActuals(projectId);
        if (records.length >= 3) {
            const factors = computeCalibrationFactors(projectId, records, 3);
            await saveCalibration(projectId, factors);
        }
    }
    catch {
        /* best-effort — never throw */
    }
}
export const estimateCalibrationHook = {
    id: 'estimate-calibration',
    triggers: ['done'],
    requiresProjectPath: false,
    label: 'Auto-calibrate estimates on done (SPEC-506)',
    handler,
};
//# sourceMappingURL=estimate-calibration.hook.js.map