import { EventEmitter } from '@angular/core';
import { IMetadataProvider } from '@memberjunction/core';
import { ComponentSpec } from '@memberjunction/interactive-component-types';
import { CuratedFormSchema, FormMode } from '@memberjunction/interactive-component-types/forms';
import { FormCanvasModel } from './form-canvas-model';
import * as i0 from "@angular/core";
/**
 * Lightweight summary of a database component for the browser list.
 * Only contains fields needed for display — Specification and other heavy
 * columns are fetched on demand when a component is selected.
 */
export interface DbComponentSummary {
    ID: string;
    Name: string;
    Namespace: string | null;
    Version: string | null;
    Type: string | null;
    Status: string | null;
    Description: string | null;
    HasRequiredCustomProps: boolean;
    __mj_UpdatedAt: Date | null;
    isFileLoaded?: false;
}
/**
 * Interface for components loaded from files, text, or artifacts (not from database)
 */
export interface FileLoadedComponent {
    id: string;
    name: string;
    description?: string;
    specification: ComponentSpec;
    filename: string;
    loadedAt: Date;
    isFileLoaded: true;
    type?: string;
    status?: string;
    sourceArtifactID?: string;
    sourceVersionID?: string;
}
/**
 * Union type for both database and file-loaded components
 */
export type DisplayComponent = DbComponentSummary | FileLoadedComponent;
/**
 * Category for filtering
 */
export interface Category {
    name: string;
    count: number;
    color: string;
}
/**
 * Component error info
 */
export interface ComponentError {
    type: string;
    message: string;
    technicalDetails?: Record<string, unknown> | string;
}
/**
 * Code section for the code editor tabbed panel
 */
export interface CodeSection {
    title: string;
    code: string;
    originalCode: string;
    isDependency: boolean;
    index?: number;
}
/**
 * Central state management service for Component Studio.
 * Decouples state from components so sub-components can share state.
 */
export declare class ComponentStudioStateService {
    private _dbComponents;
    private _fileLoadedComponents;
    get DbComponents(): DbComponentSummary[];
    get FileLoadedComponents(): FileLoadedComponent[];
    /** Combined list of all components (file-loaded first, then DB) */
    get AllComponents(): DisplayComponent[];
    private _filteredComponents;
    get FilteredComponents(): DisplayComponent[];
    private _selectedComponent;
    private _expandedComponent;
    private _componentSpec;
    private _isRunning;
    get SelectedComponent(): DisplayComponent | null;
    set SelectedComponent(value: DisplayComponent | null);
    get ExpandedComponent(): DisplayComponent | null;
    set ExpandedComponent(value: DisplayComponent | null);
    get ComponentSpec(): ComponentSpec | null;
    set ComponentSpec(value: ComponentSpec | null);
    get IsRunning(): boolean;
    set IsRunning(value: boolean);
    private _formTargetEntityName;
    get FormTargetEntityName(): string | null;
    set FormTargetEntityName(value: string | null);
    private _formCanvas;
    get FormCanvas(): FormCanvasModel | null;
    set FormCanvas(value: FormCanvasModel | null);
    private _formSchema;
    get FormSchema(): CuratedFormSchema | null;
    private _formSelectedElementId;
    get FormSelectedElementId(): string | null;
    set FormSelectedElementId(value: string | null);
    private _formSelectedSectionId;
    get FormSelectedSectionId(): string | null;
    set FormSelectedSectionId(value: string | null);
    /** True when the parser couldn't fully round-trip code → canvas. UI shows a banner. */
    private _formCodeOnlySectionsDetected;
    get FormCodeOnlySectionsDetected(): boolean;
    set FormCodeOnlySectionsDetected(value: boolean);
    /** Preview mode for the Form Builder tab — drives the toolbar pills AND the preview pane. */
    private _formPreviewMode;
    get FormPreviewMode(): FormMode;
    set FormPreviewMode(value: FormMode);
    /** Build (and cache) the curated schema for the given entity. */
    BuildFormSchema(entityName: string | null): CuratedFormSchema | null;
    private _isLoading;
    get IsLoading(): boolean;
    private _currentError;
    get CurrentError(): ComponentError | null;
    set CurrentError(value: ComponentError | null);
    private _searchQuery;
    private _selectedCategories;
    private _showOnlyFavorites;
    private _showDeprecatedComponents;
    private _showAllCategories;
    private _isFilterPanelExpanded;
    get SearchQuery(): string;
    set SearchQuery(value: string);
    get SelectedCategories(): Set<string>;
    get ShowOnlyFavorites(): boolean;
    get ShowDeprecatedComponents(): boolean;
    get ShowAllCategories(): boolean;
    get IsFilterPanelExpanded(): boolean;
    private _favoriteComponents;
    get FavoriteComponents(): Set<string>;
    private _availableCategories;
    get AvailableCategories(): Category[];
    private _editableSpec;
    private _editableCode;
    private _codeSections;
    private _isEditingSpec;
    private _isEditingCode;
    private _activeTab;
    private _isDetailsPaneCollapsed;
    get EditableSpec(): string;
    set EditableSpec(value: string);
    get EditableCode(): string;
    set EditableCode(value: string);
    get CodeSections(): CodeSection[];
    get IsEditingSpec(): boolean;
    set IsEditingSpec(value: boolean);
    get IsEditingCode(): boolean;
    set IsEditingCode(value: boolean);
    get ActiveTab(): number;
    set ActiveTab(value: number);
    get IsDetailsPaneCollapsed(): boolean;
    set IsDetailsPaneCollapsed(value: boolean);
    private _hasUnsavedChanges;
    private _hasResolvedSpec;
    get HasUnsavedChanges(): boolean;
    set HasUnsavedChanges(value: boolean);
    private _isAIPanelCollapsed;
    get IsAIPanelCollapsed(): boolean;
    set IsAIPanelCollapsed(value: boolean);
    /** Emitted when state changes require UI update */
    StateChanged: EventEmitter<void>;
    /** Emitted when the running component needs to refresh */
    RefreshComponent: EventEmitter<void>;
    /** Emitted when an error should be sent to AI for diagnosis */
    SendErrorToAI: EventEmitter<ComponentError>;
    /** Emitted when a component spec is updated (e.g. by AI) */
    SpecUpdated: EventEmitter<ComponentSpec>;
    /** Emitted when the Form Builder tab's "Open in Chat" button is clicked.
     * The dashboard subscribes and forwards to NavigationService.SetAgentContext. */
    OpenInChatRequested: EventEmitter<void>;
    private _provider;
    /** Set the metadata provider this service should use. Components should call this after injection. */
    set Provider(value: IMetadataProvider | null);
    get Provider(): IMetadataProvider;
    private get metadata();
    LoadComponents(): Promise<void>;
    private loadFavorites;
    ApplyFilters(): void;
    private buildCategories;
    private extractCategoryFromNamespace;
    private getCategoryColor;
    ToggleFilterPanel(): void;
    ToggleCategory(category: string): void;
    ToggleShowOnlyFavorites(): void;
    ToggleShowDeprecatedComponents(): void;
    ToggleShowAllCategories(): void;
    ClearAllFilters(): void;
    GetActiveFilterCount(): number;
    GetDeprecatedCount(): number;
    GetVisibleCategories(): Category[];
    IsCategorySelected(category: string): boolean;
    IsFavorite(component: DisplayComponent): boolean;
    ToggleFavorite(component: DisplayComponent): Promise<void>;
    IsFileLoadedComponent(component: DisplayComponent): component is FileLoadedComponent;
    GetComponentName(component: DisplayComponent): string;
    GetComponentDescription(component: DisplayComponent): string | undefined;
    GetComponentType(component: DisplayComponent): string | undefined;
    GetComponentStatus(component: DisplayComponent): string | undefined;
    GetComponentVersion(component: DisplayComponent): string;
    /**
     * Fetches the full component specification. For file-loaded components, returns
     * the in-memory spec. For database components, loads the full entity record
     * on demand via ComponentMetadataEngine.FindComponentByID() — the lightweight
     * summary loaded at startup does not include the Specification column.
     */
    GetComponentSpec(component: DisplayComponent): Promise<ComponentSpec>;
    GetComponentId(component: DisplayComponent): string;
    GetComponentNamespace(component: DisplayComponent): string | undefined;
    GetComponentFilename(component: DisplayComponent): string | undefined;
    GetComponentLoadedAt(component: DisplayComponent): Date | undefined;
    GetComponentUpdatedAt(component: DisplayComponent): Date | undefined;
    StartComponent(component: DisplayComponent): Promise<void>;
    StopComponent(): void;
    RunComponent(component: DisplayComponent): Promise<void>;
    InitializeEditors(): void;
    BuildCodeSections(): void;
    /**
     * Apply spec changes from the JSON editor back to the component
     */
    ApplySpecChanges(): boolean;
    /**
     * Apply code changes from the code editor back to the spec
     */
    ApplyCodeChanges(): boolean;
    /**
     * Update the internal spec with the fully resolved version returned by the
     * React bridge after it loads the component hierarchy.  This replaces
     * registry-reference stubs with real code so code sections show actual source.
     * Does NOT mark the component as having unsaved changes or trigger a re-render.
     *
     * Runs at most once per component load. The bridge re-resolves from the registry
     * on every refresh (including the refresh triggered by Apply Changes), and we
     * must not let that round-trip clobber edits the user has already applied.
     */
    UpdateWithResolvedSpec(resolvedSpec: ComponentSpec): void;
    /**
     * Update the component spec directly (e.g., from AI)
     */
    UpdateSpec(newSpec: ComponentSpec): void;
    AddFileLoadedComponent(component: FileLoadedComponent): void;
    RemoveFileLoadedComponent(component: FileLoadedComponent): void;
    GenerateId(): string;
    GetComponentTypeIcon(type: string | null | undefined): string;
    GetComponentTypeColor(type: string | null | undefined): string;
    GetNamespaceColor(namespace: string | undefined): string;
    FormatNamespace(namespace: string | undefined): string;
    /**
     * Get the current spec, preferring edited version if available
     */
    GetCurrentSpec(): ComponentSpec | null;
    static ɵfac: i0.ɵɵFactoryDeclaration<ComponentStudioStateService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<ComponentStudioStateService>;
}
//# sourceMappingURL=component-studio-state.service.d.ts.map