using System.Collections.Generic;

namespace LLM.Editor.Analysis
{
    /// <summary>
    /// A static registry that holds all the available "tools" (Context Providers)
    /// that the LLM can use to query the project.
    /// </summary>
    public static class ContextProviderRegistry
    {
        private static readonly Dictionary<string, IContextProvider> _providers = new();

        // This static constructor will be used in the next phase to register all our tools.
        static ContextProviderRegistry()
        {
            RegisterProvider("ComponentData", new ComponentDataProvider());
            RegisterProvider("SourceCode", new SourceCodeProvider());
            RegisterProvider("PackageManager", new PackageManagerProvider());
            RegisterProvider("TagsAndLayers", new TagsAndLayersProvider());
            RegisterProvider("FindAssets", new FindAssetsProvider());
            RegisterProvider("FindInScene", new FindInSceneProvider());
            RegisterProvider("Selection", new SelectionProvider());
            RegisterProvider("EditorState", new EditorStateProvider());
            RegisterProvider("ActiveScene", new ActiveSceneProvider());
            RegisterProvider("ConsoleLog", new ConsoleLogProvider());
            RegisterProvider("DependencyGraph", new DependencyGraphProvider());
            RegisterProvider("GetContextualMap", new GetContextualMapProvider());
            RegisterProvider("GetDataFromPath", new GetDataFromPathProvider());
            RegisterProvider("FindReferences", new FindReferencesProvider());
            RegisterProvider("DirectoryStructure", new DirectoryStructureProvider());
            RegisterProvider("GetComponentSchema", new GetComponentSchemaProvider());
        }

        private static void RegisterProvider(string dataType, IContextProvider provider)
        {
            if (string.IsNullOrEmpty(dataType) || provider == null) return;
            _providers[dataType] = provider;
        }

        public static IContextProvider GetProvider(string dataType)
        {
            _providers.TryGetValue(dataType, out var provider);
            return provider;
        }
    }
}