import { addDays as D } from "./addDays.js";
import { toDate as k } from "./toDate.js";
import { getDefaultOptions as w } from "./_lib/defaultOptions.js";
function y(m, e, t) {
  var s, f, d, l;
  const a = w(), o = (t == null ? void 0 : t.weekStartsOn) ?? ((f = (s = t == null ? void 0 : t.locale) == null ? void 0 : s.options) == null ? void 0 : f.weekStartsOn) ?? a.weekStartsOn ?? ((l = (d = a.locale) == null ? void 0 : d.options) == null ? void 0 : l.weekStartsOn) ?? 0, n = k(m), c = n.getDay(), O = (e % 7 + 7) % 7, r = 7 - o, u = e < 0 || e > 6 ? e - (c + r) % 7 : (O + r) % 7 - (c + r) % 7;
  return D(n, u);
}
export {
  y as default,
  y as setDay
};
