/**
 * Single source of truth for GRM / feedback timeliness.
 *
 * A case is judged ONLY by its first response timestamp against the due date — never by
 * the manual "resolved" status or by `resolvedAt`:
 *
 *   responded  && firstResponse <= due  -> "Yes"  (answered inside the 7 day SLA)
 *   responded  && firstResponse  > due  -> "No"   (answered late)
 *   no response && due already passed   -> "No"   (overdue already counts against the provider)
 *   no response && due still in future  -> "Pending" (still inside the SLA window)
 *
 * The headline rate mirrors the grievance indicator variables
 * (`grievances_resolved_within_7_days_count` / `grievances_total_registered_count`):
 *
 *   timely / (responded + overdue-unresponded)
 *
 * Undecided cases (no response yet, due date in the future) are excluded from the rate
 * because neither answer can be known yet.
 */
export type TimelinessVerdict = "Yes" | "No" | "Pending";
export type DerivedFeedbackStatus = "open" | "resolved";
export type FeedbackTimelinessInput = {
    dueAt: Date;
    firstTpResponseAt: Date | null;
    /**
     * Timestamp of the first provider / M&E reply. Used as a self-healing fallback for
     * rows created before `firstTpResponseAt` existed, so already-answered historical
     * cases still count as responded without requiring a data migration first.
     */
    firstStaffReplyAt?: Date | null;
};
/** The moment the case was actually answered (DB column, else first staff reply). */
export declare function responseAt(t: FeedbackTimelinessInput): Date | null;
/** Whether the provider (or M&E) has already answered the case. */
export declare function isResponded(t: FeedbackTimelinessInput): boolean;
export declare function timelinessVerdict(t: FeedbackTimelinessInput, now: Date): TimelinessVerdict;
/**
 * Status is derived from the response date so historical rows that were never
 * flipped through the old dropdown still read correctly.
 */
export declare function derivedStatus(t: FeedbackTimelinessInput): DerivedFeedbackStatus;
export type FeedbackMetricsBucket = {
    total: number;
    open: number;
    resolved: number;
    responded: number;
    timely: number;
    late: number;
    overdueUnresponded: number;
    pending: number;
    timelyPct: number;
};
export type FeedbackProviderMetrics = FeedbackMetricsBucket & {
    trainingProviderId: string;
    tpCode: string;
    name: string;
};
export type FeedbackMetrics = FeedbackMetricsBucket & {
    byProvider: FeedbackProviderMetrics[];
};
/** First provider / M&E reply found in a thread's messages (oldest first). */
export declare function resolveFirstStaffReply(messages: ReadonlyArray<{
    authorType: string;
    createdAt: Date;
}> | null | undefined): Date | null;
export type FeedbackMetricThread = FeedbackTimelinessInput & {
    trainingProviderId: bigint | string;
    trainingProvider?: {
        tpCode: string;
        name: string;
    } | null;
    /** Optional raw messages, used to self-heal a missing `firstTpResponseAt`. */
    messages?: ReadonlyArray<{
        authorType: string;
        createdAt: Date;
    }>;
};
/**
 * Shared shape for the per-provider timeliness table so the page, the PDF and the
 * CSV all show the same columns — importantly including **Late**, without which
 * `Responded` cannot be reconciled against `Timely`.
 */
export declare const PROVIDER_METRIC_HEADERS: string[];
/** Column widths as fractions of the available table width (PDF reports). */
export declare const PROVIDER_METRIC_WIDTHS: number[];
export declare function providerMetricCells(label: string, bucket: FeedbackMetricsBucket): string[];
export declare function providerMetricRows(data: {
    byProvider: ReadonlyArray<FeedbackProviderMetrics>;
    summary: FeedbackMetricsBucket;
}): string[][];
/**
 * Computes the project total plus a per-training-provider breakdown over EVERY
 * thread passed in (callers must not truncate the set).
 */
export declare function computeFeedbackMetrics(threads: readonly FeedbackMetricThread[], now?: Date): FeedbackMetrics;
//# sourceMappingURL=feedbackMetrics.d.ts.map