const fileName_1 = "(@effect/core) _src/io/Schedule/operations/minuteOfHour.ts";
import * as tsplus_module_1 from "@effect/core/io/Cause/errors";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/die";
import * as tsplus_module_3 from "@effect/core/io/Schedule/Interval";
import * as tsplus_module_4 from "@effect/core/io/Schedule/Decision";
import * as tsplus_module_5 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/succeedNow";
import { makeWithState } from "@effect/core/io/Schedule/operations/_internal/makeWithState";
import { beginningOfMinute, endOfMinute, nextMinute } from "@effect/core/io/Schedule/operations/_internal/time";
/**
 * Cron-like schedule that recurs every specified `minute` of each hour. It
 * triggers at zero second of the minute. Producing a count of repeats: 0, 1,
 * 2.
 *
 * NOTE: `minute` parameter is validated lazily. Must be in range 0...59.
 *
 * @tsplus static ets/Schedule minuteOfHour
 */

export function minuteOfHour(minute) {
  return makeWithState(0, (now, _, state) => {
    if (!Number.isInteger(minute) || minute < 0 || 59 < minute) {
      return tsplus_module_2.die(() => new tsplus_module_1.IllegalArgumentException(`Invalid argument in: minuteOfHour(${minute}). Must be in range 0...59`), fileName_1 + ":20:24");
    }

    const min = nextMinute(now, minute);
    const start = Math.max(beginningOfMinute(min), now);
    const end = endOfMinute(min);
    const interval = tsplus_module_3.fromStartEndMillis(start, end);
    return tsplus_module_6.succeedNow(tsplus_module_5.make(state + 1, state, tsplus_module_4._continue(interval)), fileName_1 + ":30:29");
  });
}
//# sourceMappingURL=minuteOfHour.mjs.map