import Util from '../../utils';
import { getAssetPath } from '@stencil/core';
//declare var sparkle: any;
export async function setupConfig(config) {
  if (!window) {
    return;
  }
  const win = window;
  const Sparkle = win.Sparkle;
  if (Sparkle && Sparkle.config && Sparkle.config.constructor.name !== 'Object') {
    console.error('Sparkle config was already initialized');
    return;
  }
  win.Sparkle = win.Sparkle || {};
  win.Sparkle.config = Object.assign(Object.assign({}, win.Sparkle.config), config);
  // sparkle.config = {
  //   ...config.sparkle
  // };
  return win.Sparkle.config;
}
export async function initSetupConfig(config) {
  await Util.loadScriptAsync(getAssetPath(`../assets/lib/sparkle.js`));
  await setupConfig(config);
}
