import { VegaIconManager } from './icon-manager';
/**
 * Internal icon manager
 */
class InternalIconManager {
  /**
   * Get the internal icon key by name
   *
   * @param {string} name - The name of the icon
   * @returns {string} returns the internal icon key
   */
  getIconKey(name) {
    return this.generateIconKeyWithNamespace(name, InternalIconManager.INTERNAL_ICON_NAMESPACE);
  }
  /**
   *  Check if the internal icon manager has an icon by name
   *
   * @param {string} name - The name of the icon
   * @returns {boolean} returns true if the icon exists
   * @vegaVersion 2.46.0
   */
  hasIcon(name) {
    return VegaIconManager.hasIcon(this.getIconKey(name));
  }
  /**
   * Register internal icons
   *
   * @param {Record<string, IconPayload>} icons - The icons to register
   */
  register(icons) {
    const iconsWithNamespace = Object.entries(icons).reduce((icons, [name, value]) => {
      const newKey = this.generateIconKeyWithNamespace(name, InternalIconManager.INTERNAL_ICON_NAMESPACE);
      icons[newKey] = value;
      return icons;
    }, {});
    VegaIconManager.register(iconsWithNamespace);
  }
  /**
   * Generate the icon key with the namespace
   *
   * @param {string} name - The name of the icon
   * @param {string} namespace - The namespace of the icon
   * @returns {string} returns the key with the namespace
   */
  generateIconKeyWithNamespace(name, namespace) {
    return [namespace, name].join(' ');
  }
}
InternalIconManager.INTERNAL_ICON_NAMESPACE = 'v-internal-icon';
export const VegaInternalIconManager = new InternalIconManager();
