let u = /* @__PURE__ */ new Map(), f = !1;
try {
  f = new Intl.NumberFormat("de-DE", {
    signDisplay: "exceptZero"
  }).resolvedOptions().signDisplay === "exceptZero";
} catch {
}
let l = !1;
try {
  l = new Intl.NumberFormat("de-DE", {
    style: "unit",
    unit: "degree"
  }).resolvedOptions().style === "unit";
} catch {
}
const c = {
  degree: {
    narrow: {
      default: "°",
      "ja-JP": " 度",
      "zh-TW": "度",
      "sl-SI": " °"
    }
  }
};
class d {
  /** Formats a number value as a string, according to the locale and options provided to the constructor. */
  format(t) {
    let e = "";
    if (!f && this.options.signDisplay != null ? e = m(this.numberFormatter, this.options.signDisplay, t) : e = this.numberFormatter.format(t), this.options.style === "unit" && !l) {
      var i;
      let { unit: a, unitDisplay: s = "short", locale: n } = this.resolvedOptions();
      if (!a) return e;
      let o = (i = c[a]) === null || i === void 0 ? void 0 : i[s];
      e += o[n] || o.default;
    }
    return e;
  }
  /** Formats a number to an array of parts such as separators, digits, punctuation, and more. */
  formatToParts(t) {
    return this.numberFormatter.formatToParts(t);
  }
  /** Formats a number range as a string. */
  formatRange(t, e) {
    if (typeof this.numberFormatter.formatRange == "function") return this.numberFormatter.formatRange(t, e);
    if (e < t) throw new RangeError("End date must be >= start date");
    return `${this.format(t)} – ${this.format(e)}`;
  }
  /** Formats a number range as an array of parts. */
  formatRangeToParts(t, e) {
    if (typeof this.numberFormatter.formatRangeToParts == "function") return this.numberFormatter.formatRangeToParts(t, e);
    if (e < t) throw new RangeError("End date must be >= start date");
    let i = this.numberFormatter.formatToParts(t), a = this.numberFormatter.formatToParts(e);
    return [
      ...i.map((s) => ({
        ...s,
        source: "startRange"
      })),
      {
        type: "literal",
        value: " – ",
        source: "shared"
      },
      ...a.map((s) => ({
        ...s,
        source: "endRange"
      }))
    ];
  }
  /** Returns the resolved formatting options based on the values passed to the constructor. */
  resolvedOptions() {
    let t = this.numberFormatter.resolvedOptions();
    return !f && this.options.signDisplay != null && (t = {
      ...t,
      signDisplay: this.options.signDisplay
    }), !l && this.options.style === "unit" && (t = {
      ...t,
      style: "unit",
      unit: this.options.unit,
      unitDisplay: this.options.unitDisplay
    }), t;
  }
  constructor(t, e = {}) {
    this.numberFormatter = p(t, e), this.options = e;
  }
}
function p(r, t = {}) {
  let { numberingSystem: e } = t;
  if (e && r.includes("-nu-") && (r.includes("-u-") || (r += "-u-"), r += `-nu-${e}`), t.style === "unit" && !l) {
    var i;
    let { unit: n, unitDisplay: o = "short" } = t;
    if (!n) throw new Error('unit option must be provided with style: "unit"');
    if (!(!((i = c[n]) === null || i === void 0) && i[o])) throw new Error(`Unsupported unit ${n} with unitDisplay = ${o}`);
    t = {
      ...t,
      style: "decimal"
    };
  }
  let a = r + (t ? Object.entries(t).sort((n, o) => n[0] < o[0] ? -1 : 1).join() : "");
  if (u.has(a)) return u.get(a);
  let s = new Intl.NumberFormat(r, t);
  return u.set(a, s), s;
}
function m(r, t, e) {
  if (t === "auto") return r.format(e);
  if (t === "never") return r.format(Math.abs(e));
  {
    let i = !1;
    if (t === "always" ? i = e > 0 || Object.is(e, 0) : t === "exceptZero" && (Object.is(e, -0) || Object.is(e, 0) ? e = Math.abs(e) : i = e > 0), i) {
      let a = r.format(-e), s = r.format(e), n = a.replace(s, "").replace(/\u200e|\u061C/, "");
      return [
        ...n
      ].length !== 1 && console.warn("@react-aria/i18n polyfill for NumberFormat signDisplay: Unsupported case"), a.replace(s, "!!!").replace(n, "+").replace("!!!", s);
    } else return r.format(e);
  }
}
export {
  d as $
};
//# sourceMappingURL=NumberFormatter-DgOUVrge.es.js.map
