import D from "./index-toDate.js";
import p from "./index-requiredArgs.js";
import T from "./index-startOfUTCWeek.js";
import O from "./index-toInteger.js";
import { getDefaultOptions as c } from "./index-defaultOptions.js";
function h(g, e) {
  var a, i, o, l, n, s, f, u;
  p(1, arguments);
  var v = D(g), t = v.getUTCFullYear(), C = c(), r = O((a = (i = (o = (l = e == null ? void 0 : e.firstWeekContainsDate) !== null && l !== void 0 ? l : e == null || (n = e.locale) === null || n === void 0 || (s = n.options) === null || s === void 0 ? void 0 : s.firstWeekContainsDate) !== null && o !== void 0 ? o : C.firstWeekContainsDate) !== null && i !== void 0 ? i : (f = C.locale) === null || f === void 0 || (u = f.options) === null || u === void 0 ? void 0 : u.firstWeekContainsDate) !== null && a !== void 0 ? a : 1);
  if (!(r >= 1 && r <= 7))
    throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");
  var d = /* @__PURE__ */ new Date(0);
  d.setUTCFullYear(t + 1, 0, r), d.setUTCHours(0, 0, 0, 0);
  var k = T(d, e), m = /* @__PURE__ */ new Date(0);
  m.setUTCFullYear(t, 0, r), m.setUTCHours(0, 0, 0, 0);
  var W = T(m, e);
  return v.getTime() >= k.getTime() ? t + 1 : v.getTime() >= W.getTime() ? t : t - 1;
}
export {
  h as default
};
