// Auto-generated by scripts/build-engines.mjs for slug "hrv-deload-trigger".
// Schema: https://aifithub.io/contracts/hrv-deload-trigger.json

/** Deload recommendation (no / maybe / yes) from the last 7 daily HRV values (RMSSD or a readiness score) against a 30-day baseline, using a rolling mean and a smallest-worthwhile-change band of 0.5 × the baseline SD (after Plews et al.). */
export interface Input {
  /** Last days of HRV, oldest first, ideally 7: comma- or space-separated numbers (\"55, 57, 52\") or a JSON array. Up to 31 values. Default: "55,57,52,48,46,47,45". */
  daily?: string;
  /** Your 30-day average of the same measure. Range: 0.01 to ∞. Default: 56. */
  baseline_30_day?: number;
  /** Day-to-day standard deviation of the 30-day baseline; omit or 0 to assume 7% of the baseline. Range: 0 to ∞. Default: 0. */
  baseline_std_dev?: number;
}

export interface Output {
  /** Notes when the series is not 7 days or the SD is assumed. */
  warnings?: Array<string>;
  baseline30Day?: number;
  /** Mean of the daily values. */
  rollingMean7Day?: number;
  /** Mean vs baseline, percent (−10.7 = 10.7% below). */
  rollingDeviationPct?: number;
  /** SWC = 0.5 × baseline SD, same unit as the inputs. */
  smallestWorthwhileChange?: number;
  /** Days more than one SWC below baseline. */
  daysBelowSwcInLastWeek?: number;
  /** Longest run of consecutive days below the band. */
  longestConsecutiveBelowSwc?: number;
  /** no, maybe or yes. */
  recommendation?: "yes" | "maybe" | "no";
  /** Array of { index, value, deviationFromBaseline, deviationPct, belowSwc }. */
  detail?: Array<{ "index"?: number; "value"?: number; "deviationFromBaseline"?: number; "deviationPct"?: number; "belowSwc"?: boolean }>;
  [key: string]: unknown;
}

/** Throws an Error naming the field when an input is unknown, mistyped or out of range. */
export declare function compute(input?: Input): Output;
