import g from "./index-getUTCDayOfYear.js";
import w from "./index-getUTCISOWeek.js";
import v from "./index-getUTCISOWeekYear.js";
import b from "./index-getUTCWeek.js";
import x from "./index-getUTCWeekYear.js";
import o from "./index-addLeadingZeros.js";
import c from "./index-lightFormatters.js";
var s = {
  midnight: "midnight",
  noon: "noon",
  morning: "morning",
  afternoon: "afternoon",
  evening: "evening",
  night: "night"
}, E = {
  // Era
  G: function(n, e, t) {
    var r = n.getUTCFullYear() > 0 ? 1 : 0;
    switch (e) {
      // AD, BC
      case "G":
      case "GG":
      case "GGG":
        return t.era(r, {
          width: "abbreviated"
        });
      // A, B
      case "GGGGG":
        return t.era(r, {
          width: "narrow"
        });
      // Anno Domini, Before Christ
      case "GGGG":
      default:
        return t.era(r, {
          width: "wide"
        });
    }
  },
  // Year
  y: function(n, e, t) {
    if (e === "yo") {
      var r = n.getUTCFullYear(), a = r > 0 ? r : 1 - r;
      return t.ordinalNumber(a, {
        unit: "year"
      });
    }
    return c.y(n, e);
  },
  // Local week-numbering year
  Y: function(n, e, t, r) {
    var a = x(n, r), u = a > 0 ? a : 1 - a;
    if (e === "YY") {
      var m = u % 100;
      return o(m, 2);
    }
    return e === "Yo" ? t.ordinalNumber(u, {
      unit: "year"
    }) : o(u, e.length);
  },
  // ISO week-numbering year
  R: function(n, e) {
    var t = v(n);
    return o(t, e.length);
  },
  // Extended year. This is a single number designating the year of this calendar system.
  // The main difference between `y` and `u` localizers are B.C. years:
  // | Year | `y` | `u` |
  // |------|-----|-----|
  // | AC 1 |   1 |   1 |
  // | BC 1 |   1 |   0 |
  // | BC 2 |   2 |  -1 |
  // Also `yy` always returns the last two digits of a year,
  // while `uu` pads single digit years to 2 characters and returns other years unchanged.
  u: function(n, e) {
    var t = n.getUTCFullYear();
    return o(t, e.length);
  },
  // Quarter
  Q: function(n, e, t) {
    var r = Math.ceil((n.getUTCMonth() + 1) / 3);
    switch (e) {
      // 1, 2, 3, 4
      case "Q":
        return String(r);
      // 01, 02, 03, 04
      case "QQ":
        return o(r, 2);
      // 1st, 2nd, 3rd, 4th
      case "Qo":
        return t.ordinalNumber(r, {
          unit: "quarter"
        });
      // Q1, Q2, Q3, Q4
      case "QQQ":
        return t.quarter(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "QQQQQ":
        return t.quarter(r, {
          width: "narrow",
          context: "formatting"
        });
      // 1st quarter, 2nd quarter, ...
      case "QQQQ":
      default:
        return t.quarter(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Stand-alone quarter
  q: function(n, e, t) {
    var r = Math.ceil((n.getUTCMonth() + 1) / 3);
    switch (e) {
      // 1, 2, 3, 4
      case "q":
        return String(r);
      // 01, 02, 03, 04
      case "qq":
        return o(r, 2);
      // 1st, 2nd, 3rd, 4th
      case "qo":
        return t.ordinalNumber(r, {
          unit: "quarter"
        });
      // Q1, Q2, Q3, Q4
      case "qqq":
        return t.quarter(r, {
          width: "abbreviated",
          context: "standalone"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "qqqqq":
        return t.quarter(r, {
          width: "narrow",
          context: "standalone"
        });
      // 1st quarter, 2nd quarter, ...
      case "qqqq":
      default:
        return t.quarter(r, {
          width: "wide",
          context: "standalone"
        });
    }
  },
  // Month
  M: function(n, e, t) {
    var r = n.getUTCMonth();
    switch (e) {
      case "M":
      case "MM":
        return c.M(n, e);
      // 1st, 2nd, ..., 12th
      case "Mo":
        return t.ordinalNumber(r + 1, {
          unit: "month"
        });
      // Jan, Feb, ..., Dec
      case "MMM":
        return t.month(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // J, F, ..., D
      case "MMMMM":
        return t.month(r, {
          width: "narrow",
          context: "formatting"
        });
      // January, February, ..., December
      case "MMMM":
      default:
        return t.month(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Stand-alone month
  L: function(n, e, t) {
    var r = n.getUTCMonth();
    switch (e) {
      // 1, 2, ..., 12
      case "L":
        return String(r + 1);
      // 01, 02, ..., 12
      case "LL":
        return o(r + 1, 2);
      // 1st, 2nd, ..., 12th
      case "Lo":
        return t.ordinalNumber(r + 1, {
          unit: "month"
        });
      // Jan, Feb, ..., Dec
      case "LLL":
        return t.month(r, {
          width: "abbreviated",
          context: "standalone"
        });
      // J, F, ..., D
      case "LLLLL":
        return t.month(r, {
          width: "narrow",
          context: "standalone"
        });
      // January, February, ..., December
      case "LLLL":
      default:
        return t.month(r, {
          width: "wide",
          context: "standalone"
        });
    }
  },
  // Local week of year
  w: function(n, e, t, r) {
    var a = b(n, r);
    return e === "wo" ? t.ordinalNumber(a, {
      unit: "week"
    }) : o(a, e.length);
  },
  // ISO week of year
  I: function(n, e, t) {
    var r = w(n);
    return e === "Io" ? t.ordinalNumber(r, {
      unit: "week"
    }) : o(r, e.length);
  },
  // Day of the month
  d: function(n, e, t) {
    return e === "do" ? t.ordinalNumber(n.getUTCDate(), {
      unit: "date"
    }) : c.d(n, e);
  },
  // Day of year
  D: function(n, e, t) {
    var r = g(n);
    return e === "Do" ? t.ordinalNumber(r, {
      unit: "dayOfYear"
    }) : o(r, e.length);
  },
  // Day of week
  E: function(n, e, t) {
    var r = n.getUTCDay();
    switch (e) {
      // Tue
      case "E":
      case "EE":
      case "EEE":
        return t.day(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "EEEEE":
        return t.day(r, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "EEEEEE":
        return t.day(r, {
          width: "short",
          context: "formatting"
        });
      // Tuesday
      case "EEEE":
      default:
        return t.day(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Local day of week
  e: function(n, e, t, r) {
    var a = n.getUTCDay(), u = (a - r.weekStartsOn + 8) % 7 || 7;
    switch (e) {
      // Numerical value (Nth day of week with current locale or weekStartsOn)
      case "e":
        return String(u);
      // Padded numerical value
      case "ee":
        return o(u, 2);
      // 1st, 2nd, ..., 7th
      case "eo":
        return t.ordinalNumber(u, {
          unit: "day"
        });
      case "eee":
        return t.day(a, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "eeeee":
        return t.day(a, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "eeeeee":
        return t.day(a, {
          width: "short",
          context: "formatting"
        });
      // Tuesday
      case "eeee":
      default:
        return t.day(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Stand-alone local day of week
  c: function(n, e, t, r) {
    var a = n.getUTCDay(), u = (a - r.weekStartsOn + 8) % 7 || 7;
    switch (e) {
      // Numerical value (same as in `e`)
      case "c":
        return String(u);
      // Padded numerical value
      case "cc":
        return o(u, e.length);
      // 1st, 2nd, ..., 7th
      case "co":
        return t.ordinalNumber(u, {
          unit: "day"
        });
      case "ccc":
        return t.day(a, {
          width: "abbreviated",
          context: "standalone"
        });
      // T
      case "ccccc":
        return t.day(a, {
          width: "narrow",
          context: "standalone"
        });
      // Tu
      case "cccccc":
        return t.day(a, {
          width: "short",
          context: "standalone"
        });
      // Tuesday
      case "cccc":
      default:
        return t.day(a, {
          width: "wide",
          context: "standalone"
        });
    }
  },
  // ISO day of week
  i: function(n, e, t) {
    var r = n.getUTCDay(), a = r === 0 ? 7 : r;
    switch (e) {
      // 2
      case "i":
        return String(a);
      // 02
      case "ii":
        return o(a, e.length);
      // 2nd
      case "io":
        return t.ordinalNumber(a, {
          unit: "day"
        });
      // Tue
      case "iii":
        return t.day(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "iiiii":
        return t.day(r, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "iiiiii":
        return t.day(r, {
          width: "short",
          context: "formatting"
        });
      // Tuesday
      case "iiii":
      default:
        return t.day(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // AM or PM
  a: function(n, e, t) {
    var r = n.getUTCHours(), a = r / 12 >= 1 ? "pm" : "am";
    switch (e) {
      case "a":
      case "aa":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "aaa":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        }).toLowerCase();
      case "aaaaa":
        return t.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      case "aaaa":
      default:
        return t.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // AM, PM, midnight, noon
  b: function(n, e, t) {
    var r = n.getUTCHours(), a;
    switch (r === 12 ? a = s.noon : r === 0 ? a = s.midnight : a = r / 12 >= 1 ? "pm" : "am", e) {
      case "b":
      case "bb":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "bbb":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        }).toLowerCase();
      case "bbbbb":
        return t.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      case "bbbb":
      default:
        return t.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // in the morning, in the afternoon, in the evening, at night
  B: function(n, e, t) {
    var r = n.getUTCHours(), a;
    switch (r >= 17 ? a = s.evening : r >= 12 ? a = s.afternoon : r >= 4 ? a = s.morning : a = s.night, e) {
      case "B":
      case "BB":
      case "BBB":
        return t.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "BBBBB":
        return t.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      case "BBBB":
      default:
        return t.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Hour [1-12]
  h: function(n, e, t) {
    if (e === "ho") {
      var r = n.getUTCHours() % 12;
      return r === 0 && (r = 12), t.ordinalNumber(r, {
        unit: "hour"
      });
    }
    return c.h(n, e);
  },
  // Hour [0-23]
  H: function(n, e, t) {
    return e === "Ho" ? t.ordinalNumber(n.getUTCHours(), {
      unit: "hour"
    }) : c.H(n, e);
  },
  // Hour [0-11]
  K: function(n, e, t) {
    var r = n.getUTCHours() % 12;
    return e === "Ko" ? t.ordinalNumber(r, {
      unit: "hour"
    }) : o(r, e.length);
  },
  // Hour [1-24]
  k: function(n, e, t) {
    var r = n.getUTCHours();
    return r === 0 && (r = 24), e === "ko" ? t.ordinalNumber(r, {
      unit: "hour"
    }) : o(r, e.length);
  },
  // Minute
  m: function(n, e, t) {
    return e === "mo" ? t.ordinalNumber(n.getUTCMinutes(), {
      unit: "minute"
    }) : c.m(n, e);
  },
  // Second
  s: function(n, e, t) {
    return e === "so" ? t.ordinalNumber(n.getUTCSeconds(), {
      unit: "second"
    }) : c.s(n, e);
  },
  // Fraction of second
  S: function(n, e) {
    return c.S(n, e);
  },
  // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
  X: function(n, e, t, r) {
    var a = r._originalDate || n, u = a.getTimezoneOffset();
    if (u === 0)
      return "Z";
    switch (e) {
      // Hours and optional minutes
      case "X":
        return h(u);
      // Hours, minutes and optional seconds without `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `XX`
      case "XXXX":
      case "XX":
        return d(u);
      // Hours, minutes and optional seconds with `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `XXX`
      case "XXXXX":
      case "XXX":
      // Hours and minutes with `:` delimiter
      default:
        return d(u, ":");
    }
  },
  // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
  x: function(n, e, t, r) {
    var a = r._originalDate || n, u = a.getTimezoneOffset();
    switch (e) {
      // Hours and optional minutes
      case "x":
        return h(u);
      // Hours, minutes and optional seconds without `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `xx`
      case "xxxx":
      case "xx":
        return d(u);
      // Hours, minutes and optional seconds with `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `xxx`
      case "xxxxx":
      case "xxx":
      // Hours and minutes with `:` delimiter
      default:
        return d(u, ":");
    }
  },
  // Timezone (GMT)
  O: function(n, e, t, r) {
    var a = r._originalDate || n, u = a.getTimezoneOffset();
    switch (e) {
      // Short
      case "O":
      case "OO":
      case "OOO":
        return "GMT" + f(u, ":");
      // Long
      case "OOOO":
      default:
        return "GMT" + d(u, ":");
    }
  },
  // Timezone (specific non-location)
  z: function(n, e, t, r) {
    var a = r._originalDate || n, u = a.getTimezoneOffset();
    switch (e) {
      // Short
      case "z":
      case "zz":
      case "zzz":
        return "GMT" + f(u, ":");
      // Long
      case "zzzz":
      default:
        return "GMT" + d(u, ":");
    }
  },
  // Seconds timestamp
  t: function(n, e, t, r) {
    var a = r._originalDate || n, u = Math.floor(a.getTime() / 1e3);
    return o(u, e.length);
  },
  // Milliseconds timestamp
  T: function(n, e, t, r) {
    var a = r._originalDate || n, u = a.getTime();
    return o(u, e.length);
  }
};
function f(i, n) {
  var e = i > 0 ? "-" : "+", t = Math.abs(i), r = Math.floor(t / 60), a = t % 60;
  if (a === 0)
    return e + String(r);
  var u = n;
  return e + String(r) + u + o(a, 2);
}
function h(i, n) {
  if (i % 60 === 0) {
    var e = i > 0 ? "-" : "+";
    return e + o(Math.abs(i) / 60, 2);
  }
  return d(i, n);
}
function d(i, n) {
  var e = n || "", t = i > 0 ? "-" : "+", r = Math.abs(i), a = o(Math.floor(r / 60), 2), u = o(r % 60, 2);
  return t + a + e + u;
}
export {
  E as default
};
