/*! Copyright 2026 Fonticons, Inc. - https://webawesome.com/license */
import defaultLibrary from "./library.default.js";
import systemLibrary from "./library.system.js";
let defaultIconFamily = "classic";
let registry = [defaultLibrary, systemLibrary];
let watchedIcons = [];
function watchIcon(icon) {
  watchedIcons.push(icon);
}
function unwatchIcon(icon) {
  watchedIcons = watchedIcons.filter((el) => el !== icon);
}
function getIconLibrary(name) {
  return registry.find((lib) => lib.name === name);
}
function registerIconLibrary(name, options) {
  unregisterIconLibrary(name);
  registry.push({
    name,
    resolver: options.resolver,
    mutator: options.mutator,
    spriteSheet: options.spriteSheet
  });
  watchedIcons.forEach((icon) => {
    if (icon.library === name) {
      icon.setIcon();
    }
  });
}
function unregisterIconLibrary(name) {
  registry = registry.filter((lib) => lib.name !== name);
}
function setDefaultIconFamily(family) {
  defaultIconFamily = family;
  watchedIcons.forEach((icon) => icon.setIcon());
}
function getDefaultIconFamily() {
  return defaultIconFamily;
}
export {
  getDefaultIconFamily,
  getIconLibrary,
  registerIconLibrary,
  setDefaultIconFamily,
  unregisterIconLibrary,
  unwatchIcon,
  watchIcon
};
