text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var direction_enum_1 = require("./direction.enum");
  var adjust_dst_1 = require("./adjust-dst");
  var clone_date_1 = require("./clone-date");
  /**
   * @hidden
   *
   * A function returning the next or previous date for a specific week day.
   * For example, `Day.Monday`.
   *
   * @param date - The date to calculate from.
   * @param weekDay - The `Day` enum specifying the desired week day.
   * @param direction - The `Direction` enum specifying the calculation direction.
   * @returns - A `Date` instance.
   *
   * @example
   * ```ts-no-run
   * dayOfWeek(new Date(2016, 0, 1), Day.Wednesday, Direction.Forward); // 2016-01-06, Wednesday
   * dayOfWeek(new Date(2016, 0, 1), Day.Wednesday, Direction.Backward); // 2015-12-30, Wednesday
   * ```
   */
  exports.dayOfWeek = function (date, weekDay, direction) {
      if (direction === void 0) { direction = direction_enum_1.Direction.Forward; }
      var newDate = clone_date_1.cloneDate(date);
      var newDay = ((weekDay - newDate.getDay()) + (7 * direction)) % 7;
      newDate.setDate(newDate.getDate() + newDay);
      return adjust_dst_1.adjustDST(newDate, date.getHours());
  };
  