import { getDefaultOptions as p } from "./index-defaultOptions.js";
import w from "./index-toDate.js";
import c from "./index-toInteger.js";
import k from "./index-requiredArgs.js";
function D(O, e) {
  var l, r, a, n, i, d, v, u;
  k(1, arguments);
  var s = p(), o = c((l = (r = (a = (n = e == null ? void 0 : e.weekStartsOn) !== null && n !== void 0 ? n : e == null || (i = e.locale) === null || i === void 0 || (d = i.options) === null || d === void 0 ? void 0 : d.weekStartsOn) !== null && a !== void 0 ? a : s.weekStartsOn) !== null && r !== void 0 ? r : (v = s.locale) === null || v === void 0 || (u = v.options) === null || u === void 0 ? void 0 : u.weekStartsOn) !== null && l !== void 0 ? l : 0);
  if (!(o >= 0 && o <= 6))
    throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
  var t = w(O), f = t.getDay(), m = (f < o ? -7 : 0) + 6 - (f - o);
  return t.setDate(t.getDate() + m), t.setHours(23, 59, 59, 999), t;
}
export {
  D as default
};
