// Generated by bynkc — do not edit by hand.
// commons test

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

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 total(repCount: number, setCount: number): Result<number, ValidationError> {
  const __r0 = Reps.of(repCount);
  if (__r0.tag === "Err") return __r0;
  const r = __r0.value;
  const __r1 = Sets.of(setCount);
  if (__r1.tag === "Err") return __r1;
  const s = __r1.value;
  return Ok(r * s);
}

