// Generated by bynkc — do not edit by hand.
// commons fitness.units

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "./runtime.js";

export type Metres = number & { readonly __brand: "Metres" };

export const Metres = {
  of(value: number): Result<Metres, ValidationError> {
    if (!Number.isInteger(value)) {
      return Err({ field: "Metres", message: "must be an integer", value });
    }
    if (!(value >= 0)) {
      return Err({ field: "Metres", message: "must be non-negative", value });
    }
    return Ok(value as Metres);
  },
  unsafe(value: number): Metres {
    return value as Metres;
  },
};

export type Reps = number & { readonly __brand: "Reps" };

export const Reps = {
  of(value: number): Result<Reps, ValidationError> {
    if (!Number.isInteger(value)) {
      return Err({ field: "Reps", message: "must be an integer", value });
    }
    if (!(value >= 1 && value <= 100)) {
      return Err({ field: "Reps", message: "must be in range [1, 100]", value });
    }
    return Ok(value as Reps);
  },
  unsafe(value: number): Reps {
    return value as Reps;
  },
};

export type Sets = number & { readonly __brand: "Sets" };

export const Sets = {
  of(value: number): Result<Sets, ValidationError> {
    if (!Number.isInteger(value)) {
      return Err({ field: "Sets", message: "must be an integer", value });
    }
    if (!(value >= 1 && value <= 20)) {
      return Err({ field: "Sets", message: "must be in range [1, 20]", value });
    }
    return Ok(value as Sets);
  },
  unsafe(value: number): Sets {
    return value as Sets;
  },
};

export function totalReps(sets: Sets, reps: Reps): number {
  return sets * reps;
}

