import y from "./index-classCallCheck.js";
import T from "./index-createClass.js";
import m from "./index-assertThisInitialized.js";
import v from "./index-inherits.js";
import Y from "./index-createSuper.js";
import c from "./index-defineProperty.js";
import { Parser as C } from "./index-Parser4.js";
import { mapValue as n, parseNDigits as p, normalizeTwoDigitYear as h } from "./index-utils12.js";
var k = /* @__PURE__ */ (function(f) {
  v(t, f);
  var u = Y(t);
  function t() {
    var i;
    y(this, t);
    for (var r = arguments.length, e = new Array(r), a = 0; a < r; a++)
      e[a] = arguments[a];
    return i = u.call.apply(u, [this].concat(e)), c(m(i), "priority", 130), c(m(i), "incompatibleTokens", ["Y", "R", "u", "w", "I", "i", "e", "c", "t", "T"]), i;
  }
  return T(t, [{
    key: "parse",
    value: function(r, e, a) {
      var o = function(s) {
        return {
          year: s,
          isTwoDigitYear: e === "yy"
        };
      };
      switch (e) {
        case "y":
          return n(p(4, r), o);
        case "yo":
          return n(a.ordinalNumber(r, {
            unit: "year"
          }), o);
        default:
          return n(p(e.length, r), o);
      }
    }
  }, {
    key: "validate",
    value: function(r, e) {
      return e.isTwoDigitYear || e.year > 0;
    }
  }, {
    key: "set",
    value: function(r, e, a) {
      var o = r.getUTCFullYear();
      if (a.isTwoDigitYear) {
        var l = h(a.year, o);
        return r.setUTCFullYear(l, 0, 1), r.setUTCHours(0, 0, 0, 0), r;
      }
      var s = !("era" in e) || e.era === 1 ? a.year : 1 - a.year;
      return r.setUTCFullYear(s, 0, 1), r.setUTCHours(0, 0, 0, 0), r;
    }
  }]), t;
})(C);
export {
  k as YearParser
};
