'use strict';

const environmentConfig_service = require('./environment-config.service-0e02b049.js');

class AssetsService {
  constructor() {
    this.assetsList = undefined;
  }
  static getInstance() {
    if (!AssetsService.instance) {
      AssetsService.instance = new AssetsService();
    }
    return AssetsService.instance;
  }
  async assets() {
    if (this.assetsList === undefined) {
      this.assetsList = await this.init();
    }
    return this.assetsList;
  }
  async init() {
    try {
      const config = environmentConfig_service.EnvironmentConfigService.getInstance().get('sparkle');
      const res = await fetch(`${config.globalAssetsUrl}/assets.json`);
      if (!res) {
        return undefined;
      }
      const assets = await res.json();
      return assets;
    }
    catch (err) {
      return undefined;
    }
  }
  async loadJsonFile(path) {
    try {
      const res = await fetch(`${path}`);
      if (!res) {
        return undefined;
      }
      const data = await res.json();
      return data;
    }
    catch (err) {
      return undefined;
    }
  }
}

exports.AssetsService = AssetsService;
