'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-9c866aeb.js');
const utils = require('./utils-806dad60.js');

const ScFormatNumber = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    /** The number to format. */
    this.value = 0;
    /** The formatting style to use. */
    this.type = 'decimal';
    /** Turns off grouping separators. */
    this.noGrouping = false;
    /** The currency to use when formatting. Must be an ISO 4217 currency code such as `USD` or `EUR`. */
    this.currency = 'USD';
    /** How to display the currency. */
    this.currencyDisplay = 'symbol';
  }
  render() {
    var _a;
    if (isNaN(this.value)) {
      return '';
    }
    const lang = navigator.language || ((_a = navigator) === null || _a === void 0 ? void 0 : _a.browserLanguage) || (navigator.languages || ['en'])[0];
    return new Intl.NumberFormat(this.locale || lang, {
      style: this.type,
      currency: this.currency.toUpperCase(),
      currencyDisplay: this.currencyDisplay,
      useGrouping: !this.noGrouping,
      minimumIntegerDigits: this.minimumIntegerDigits,
      minimumFractionDigits: this.minimumFractionDigits,
      maximumFractionDigits: this.maximumFractionDigits,
      minimumSignificantDigits: this.minimumSignificantDigits,
      maximumSignificantDigits: this.maximumSignificantDigits,
    }).format(this.noConvert ? this.value : utils.maybeConvertAmount(this.value, this.currency.toUpperCase()));
  }
};

exports.sc_format_number = ScFormatNumber;
