import { constructFrom as u } from "./constructFrom.js";
import { startOfWeek as k } from "./startOfWeek.js";
import { toDate as g } from "./toDate.js";
import { getDefaultOptions as D } from "./_lib/defaultOptions.js";
function x(r, e) {
  var l, o, c, m;
  const a = g(r), t = a.getFullYear(), i = D(), n = (e == null ? void 0 : e.firstWeekContainsDate) ?? ((o = (l = e == null ? void 0 : e.locale) == null ? void 0 : l.options) == null ? void 0 : o.firstWeekContainsDate) ?? i.firstWeekContainsDate ?? ((m = (c = i.locale) == null ? void 0 : c.options) == null ? void 0 : m.firstWeekContainsDate) ?? 1, s = u(r, 0);
  s.setFullYear(t + 1, 0, n), s.setHours(0, 0, 0, 0);
  const W = k(s, e), f = u(r, 0);
  f.setFullYear(t, 0, n), f.setHours(0, 0, 0, 0);
  const Y = k(f, e);
  return a.getTime() >= W.getTime() ? t + 1 : a.getTime() >= Y.getTime() ? t : t - 1;
}
export {
  x as default,
  x as getWeekYear
};
