'use strict';

let registry = [];
let watchedIcons = [];
function getIconLibrary(name) {
  return registry.filter(lib => lib.name === name)[0];
}
function registerIconLibrary(name, options) {
  unregisterIconLibrary(name);
  registry.push({
    name,
    resolver: options.resolver,
    mutator: options.mutator,
  });
  // Redraw watched icons
  watchedIcons.map(icon => {
    if (icon.library === name) {
      icon.redraw();
    }
  });
}
function unregisterIconLibrary(name) {
  registry = registry.filter(lib => lib.name !== name);
}
window.ceRegisterIconLibrary = registerIconLibrary;

exports.getIconLibrary = getIconLibrary;
exports.registerIconLibrary = registerIconLibrary;
