import { BaseEngine, IMetadataProvider, UserInfo } from "@memberjunction/core";
import { MJSearchProviderEntity, MJSearchScopeEntity, MJSearchScopeProviderEntity, MJSearchScopeExternalIndexEntity, MJSearchScopeEntityEntity, MJSearchScopeStorageAccountEntity, MJAIAgentSearchScopeEntity } from "../generated/entity_subclasses.js";
/**
 * SearchEngineBase provides cached access to SearchProvider + Search Scope metadata.
 *
 * Loads all `MJ: Search Providers`, `MJ: Search Scopes`, and the 5 Search Scope child
 * tables (`MJ: Search Scope Providers`, `MJ: Search Scope External Indexes`,
 * `MJ: Search Scope Entities`, `MJ: Search Scope Storage Accounts`, `MJ: AI Agent Search Scopes`)
 * via BaseEngine and provides typed getters and lookups for use anywhere
 * (client or server).
 *
 * The server-side SearchEngine class uses SearchEngineBase.Instance to access cached
 * provider metadata instead of loading directly via RunView. It also uses the scope
 * metadata getters to resolve `SearchScope` + children when a scoped search is requested.
 *
 * Uses BaseEngine for automatic caching and entity-event-based auto-refresh so that
 * provider/scope configuration changes are reflected without manual reload.
 *
 * Usage:
 * ```typescript
 * const base = SearchEngineBase.Instance;
 * await base.Config(false, contextUser);
 *
 * // Get all active providers
 * const activeProviders = base.ActiveProviders;
 *
 * // Find a provider by driver class
 * const vectorProvider = base.GetProviderByDriverClass('VectorSearchProvider');
 *
 * // Resolve an active scope by ID (respects Status + StartAt/EndAt)
 * const scope = base.GetActiveScopeByID('...');
 *
 * // Pull everything needed for a scoped search
 * const bundle = base.GetScopeBundle(scopeId);
 * // -> { Scope, Providers, ExternalIndexes, Entities, StorageAccounts }
 * ```
 */
export declare class SearchEngineBase extends BaseEngine<SearchEngineBase> {
    /**
     * Returns the global singleton instance.
     */
    static get Instance(): SearchEngineBase;
    private _providers;
    private _scopes;
    private _scopeProviders;
    private _scopeExternalIndexes;
    private _scopeEntities;
    private _scopeStorageAccounts;
    private _agentScopes;
    /**
     * Configures the engine by loading all search provider and scope records from the database.
     * @param forceRefresh - If true, forces a refresh from the database even if data is cached
     * @param contextUser - Optional user context for server-side operations
     * @param provider - Optional metadata provider
     */
    Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
    /** All search provider records (any status) */
    get Providers(): MJSearchProviderEntity[];
    /** Only active search providers, sorted by Priority ascending */
    get ActiveProviders(): MJSearchProviderEntity[];
    /** Active providers that support preview/autocomplete searches */
    get PreviewProviders(): MJSearchProviderEntity[];
    /** All scope records (any status). */
    get Scopes(): MJSearchScopeEntity[];
    /**
     * Scopes that are currently active AND within their optional StartAt/EndAt time window.
     * Callers should prefer this over `Scopes` when resolving runtime search requests.
     */
    get ActiveScopes(): MJSearchScopeEntity[];
    /** All scope-provider join rows. */
    get ScopeProviders(): MJSearchScopeProviderEntity[];
    /** All scope-external-index rows. */
    get ScopeExternalIndexes(): MJSearchScopeExternalIndexEntity[];
    /** All scope-entity rows. */
    get ScopeEntities(): MJSearchScopeEntityEntity[];
    /** All scope-storage-account rows. */
    get ScopeStorageAccounts(): MJSearchScopeStorageAccountEntity[];
    /** All agent-scope assignment rows. */
    get AgentScopes(): MJAIAgentSearchScopeEntity[];
    /**
     * Find a provider by its DriverClass key.
     * @param driverClass - The DriverClass value (e.g., 'VectorSearchProvider')
     * @returns The provider entity, or undefined if not found
     */
    GetProviderByDriverClass(driverClass: string): MJSearchProviderEntity | undefined;
    /**
     * Find a provider by its Name.
     * @param name - The provider name (e.g., 'Semantic')
     * @returns The provider entity, or undefined if not found
     */
    GetProviderByName(name: string): MJSearchProviderEntity | undefined;
    /**
     * Find a provider by its ID.
     * @param id - The provider record ID
     * @returns The provider entity, or undefined if not found
     */
    GetProviderById(id: string): MJSearchProviderEntity | undefined;
    /**
     * Get the display label for a source type, resolving from provider metadata.
     * Falls back to the source type string if no provider matches.
     * @param sourceType - The source type key (e.g., 'vector', 'entity')
     */
    GetDisplayNameForSourceType(sourceType: string): string;
    /**
     * Get the icon for a source type, resolving from provider metadata.
     * Falls back to a generic icon if no provider matches.
     * @param sourceType - The source type key (e.g., 'vector', 'entity')
     */
    GetIconForSourceType(sourceType: string): string;
    /** Find a scope by ID (any status). */
    GetScopeByID(id: string): MJSearchScopeEntity | undefined;
    /** Find a scope by ID, only returning it if it is currently active. */
    GetActiveScopeByID(id: string): MJSearchScopeEntity | undefined;
    /** Find a scope by Name (any status). */
    GetScopeByName(name: string): MJSearchScopeEntity | undefined;
    /** The first scope with `IsGlobal=true` (there should be exactly one). */
    get GlobalScope(): MJSearchScopeEntity | undefined;
    /** The first scope with `IsDefault=true` (or `GlobalScope` as a fallback). */
    get DefaultScope(): MJSearchScopeEntity | undefined;
    /** Provider rows (Enabled=true) for a scope. */
    GetProvidersForScope(scopeID: string): MJSearchScopeProviderEntity[];
    /** External-index rows for a scope. */
    GetExternalIndexesForScope(scopeID: string): MJSearchScopeExternalIndexEntity[];
    /** Entity rows for a scope. */
    GetEntitiesForScope(scopeID: string): MJSearchScopeEntityEntity[];
    /** Storage-account rows for a scope. */
    GetStorageAccountsForScope(scopeID: string): MJSearchScopeStorageAccountEntity[];
    /**
     * Resolve a single scope plus every child collection in one call. Convenience
     * for SearchEngine so it does one lookup per scope instead of five.
     */
    GetScopeBundle(scopeID: string): ScopeBundle | undefined;
    /**
     * Agent-scope rows for an agent, filtered by Phase and current active window.
     * @param agentID - The `MJ: AI Agents` record ID
     * @param phase - Optional phase filter. Rows whose `Phase` is `'Both'` match any phase query.
     */
    GetAgentScopes(agentID: string, phase?: 'PreExecution' | 'AgentInvoked'): MJAIAgentSearchScopeEntity[];
    /**
     * The default `IsDefault=true` agent-scope row for an agent, or the highest-priority
     * row (lowest `Priority` value) if no row is marked default.
     */
    GetDefaultAgentScope(agentID: string): MJAIAgentSearchScopeEntity | undefined;
    private isScopeActiveNow;
    private isAgentScopeActiveNow;
}
/**
 * Bundle returned from `SearchEngineBase.GetScopeBundle()` — a single scope and every
 * child collection the search engine needs.
 */
export interface ScopeBundle {
    Scope: MJSearchScopeEntity;
    Providers: MJSearchScopeProviderEntity[];
    ExternalIndexes: MJSearchScopeExternalIndexEntity[];
    Entities: MJSearchScopeEntityEntity[];
    StorageAccounts: MJSearchScopeStorageAccountEntity[];
}
//# sourceMappingURL=SearchEngineBase.d.ts.map