import { toDate as u } from "./toDate.js";
import { getDefaultOptions as d } from "./_lib/defaultOptions.js";
function S(l, t) {
  var f, c, n, O;
  const a = d(), r = (t == null ? void 0 : t.weekStartsOn) ?? ((c = (f = t == null ? void 0 : t.locale) == null ? void 0 : f.options) == null ? void 0 : c.weekStartsOn) ?? a.weekStartsOn ?? ((O = (n = a.locale) == null ? void 0 : n.options) == null ? void 0 : O.weekStartsOn) ?? 0, e = u(l), s = e.getDay(), k = (s < r ? 7 : 0) + s - r;
  return e.setDate(e.getDate() - k), e.setHours(0, 0, 0, 0), e;
}
export {
  S as default,
  S as startOfWeek
};
