if (typeof CSS !== 'undefined' && 'paintWorklet' in CSS) {
  CSS.paintWorklet.addModule(
    "https://www.unpkg.com/css-houdini-squircle@0.1.3/squircle.min.js"
  );
}

class ITFSettings {
  options = {
    firstDayOfWeek: 'Monday',
    defaultLocale: 'en_US',
    defaultDisplayDateFormat: 'MM/dd/yyyy',
    // defaultDisplayDateFormat: 'dd.MM.yyyy',
    currencies: [],
    moneyDisplayFormat: '{symbol}{value}',
    moneyThousandSeparator: ',',
    moneyDecimalSeparator: '.',
    supportLanguages: [
      { shortCode: 'en', locale: 'en_US', name: 'English', dateFormat: 'MM/dd/yyyy', moneyDisplayFormat: '{symbol}{value}', moneyThousandSeparator: ',', moneyDecimalSeparator: '.' },
      { shortCode: 'uk', locale: 'uk_UA', name: 'Українська (Ukrainian)', dateFormat: 'dd.MM.yyyy', moneyDisplayFormat: '{value}\xA0{symbol}', moneyThousandSeparator: '\xA0', moneyDecimalSeparator: ',' },
    ]
  };

  get moneyDisplayFormat() {
    return this.options.moneyDisplayFormat;
  }

  get moneyThousandSeparator() {
    return this.options.moneyThousandSeparator;
  }

  get moneyDecimalSeparator() {
    return this.options.moneyDecimalSeparator;
  }

  get defaultLocale() {
    return this.options.defaultLocale;
  }

  set defaultLocale(val) {
    let lang = this.options.supportLanguages.find((l) => l.shortCode === val || l.locale === val);
    if (!lang) {
      lang = this.options.supportLanguages[0];
    }
    this.options.defaultLocale = lang.locale;
    this.options.moneyDisplayFormat = lang.moneyDisplayFormat;
    this.options.moneyDecimalSeparator = lang.moneyDecimalSeparator;
    this.options.moneyThousandSeparator = lang.moneyThousandSeparator;
  }

  get currencies() {
    return this.options.currencies;
  }

  set currencies(val) {
    this.options.currencies = val;
  }

  get supportLanguages() {
    return this.options.supportLanguages;
  }

  get firstDayOfWeek() {
    return this.options.firstDayOfWeek;
  }

  set firstDayOfWeek(val) {
    this.options.firstDayOfWeek = val;
  }

  get defaultDisplayDateFormat() {
    return this.options.defaultDisplayDateFormat;
  }

  set defaultDisplayDateFormat(val) {
    this.options.defaultDisplayDateFormat = val;
  }

  get theme() {
    return this.options.theme;
  }

  set theme(val) {
    this.options.theme = val;
  }
}

const settings = new ITFSettings();

export default settings;
