const IconProviderRegistryKey = Symbol.for('LMVZ__iconProviderRegistry');
const inMemoryRegistry = {};
function getRegistry() {
    if (typeof window === 'undefined') {
        return inMemoryRegistry;
    }
    return window[IconProviderRegistryKey] ?? (window[IconProviderRegistryKey] = {});
}
export function registerIconProvider(id, provider) {
    const registry = getRegistry();
    const providerName = id;
    if (Object.prototype.hasOwnProperty.call(registry, providerName)) {
        console.warn(`Icon provider with name "${providerName}" is already registered. Overwriting existing provider.`);
    }
    registry[providerName] = provider;
}
export function getRegisteredIconProvider(id) {
    const registry = getRegistry();
    if (id) {
        return registry[id];
    }
    const providerNames = Object.keys(registry);
    if (providerNames.length === 0) {
        return undefined;
    }
    if (providerNames.length > 1) {
        console.warn(`Multiple icon providers registered (${providerNames.join(', ')}). Using the first one: "${providerNames[0]}".`);
    }
    const firstProviderName = providerNames[0];
    if (!firstProviderName) {
        return undefined;
    }
    return registry[firstProviderName];
}
