import { AfterViewInit, OnDestroy, ElementRef, ChangeDetectorRef } from '@angular/core';
import { BaseDashboard } from '@memberjunction/ng-shared';
import { ResourceData } from '@memberjunction/core-entities';
import { Subject } from 'rxjs';
import { ComponentSpec } from '@memberjunction/interactive-component-types';
import { ArtifactSelectionResult } from './components/artifact-selection-dialog.component';
import { ArtifactLoadResult } from './components/artifact-load-dialog.component';
import { MJNotificationService } from '@memberjunction/ng-notifications';
import { ComponentStudioStateService, ComponentError } from './services/component-studio-state.service';
import { ComponentVersionService } from './services/component-version.service';
import { SaveVersionResult } from './components/save-version-dialog/save-version-dialog.component';
import { FormOverrideDialogResult } from './components/form-override-dialog.component';
import { EntityFormOverrideService } from './services/entity-form-override.service';
import { type FormCanvasElement, type FormCanvasSection } from './services/form-canvas-model';
import * as i0 from "@angular/core";
/**
 * Result from the New Component dialog.
 */
export interface NewComponentResult {
    name: string;
    title: string;
    description: string;
    type: string;
}
export declare class ComponentStudioDashboardComponent extends BaseDashboard implements AfterViewInit, OnDestroy {
    state: ComponentStudioStateService;
    versionService: ComponentVersionService;
    private cdr;
    private notificationService;
    private entityFormOverrideService;
    private static readonly USER_PREFS_KEY;
    leftPanelWidth: number;
    rightPanelWidth: number;
    previewFlex: string;
    editorFlex: string;
    private previewFlexPercent;
    exportDropdownOpen: boolean;
    IsResizing: boolean;
    private resizeType;
    private resizeStartX;
    private resizeStartValue;
    IsLeftPanelCollapsed: boolean;
    IsEditorPanelCollapsed: boolean;
    ShowNewComponentDialog: boolean;
    ShowKeyboardShortcuts: boolean;
    ShowSaveVersionDialog: boolean;
    ShowTextImportDialog: boolean;
    ShowArtifactLoadDialog: boolean;
    ShowArtifactSelectionDialog: boolean;
    /** Toggled after a form-role Component is saved (see OnSaveVersionConfirm). */
    ShowFormOverrideDialog: boolean;
    /** ComponentID of the just-saved Component, set when ShowFormOverrideDialog flips on. */
    PendingOverrideComponentID: string | null;
    /** Entity name to seed the override dialog from (mirrors state.FormTargetEntityName). */
    PendingOverrideEntityName: string;
    /** Component name to seed the override Name field. */
    PendingOverrideComponentName: string;
    LastSavedTime: Date | null;
    private prefsLoaded;
    /**
     * True once the user has invoked "Open in Chat" and the form agent
     * context + tools are wired. Gates {@link reemitFormAgentContext} so canvas
     * edits made before the agent is involved don't register context/tools.
     */
    private formAgentContextActive;
    fileInput?: ElementRef<HTMLInputElement>;
    protected destroy$: Subject<void>;
    private get metadata();
    constructor(state: ComponentStudioStateService, versionService: ComponentVersionService, cdr: ChangeDetectorRef, notificationService: MJNotificationService, entityFormOverrideService: EntityFormOverrideService);
    GetResourceDisplayName(data: ResourceData): Promise<string>;
    ngAfterViewInit(): Promise<void>;
    ngOnDestroy(): void;
    protected initDashboard(): void;
    protected loadData(): void;
    private loadUserPreferences;
    private applyPreferences;
    private getCurrentPreferences;
    private saveUserPreferences;
    private saveUserPreferencesDebounced;
    OnKeyDown(event: KeyboardEvent): void;
    SaveVersion(): void;
    OnSaveVersionConfirm(result: SaveVersionResult): Promise<void>;
    /**
     * Handle the post-save override dialog. Persists an EntityFormOverride
     * row via {@link EntityFormOverrideService}. Currently surfaces an error
     * because the underlying write is blocked on the generated
     * `EntityFormOverrideEntity` class (Task 15) — the UI is wired so the
     * unblock is one swap of the service stub.
     */
    OnFormOverrideDialogConfirm(result: FormOverrideDialogResult): Promise<void>;
    OnFormOverrideDialogDismiss(): void;
    RefreshComponent(): void;
    ToggleAIPanel(): void;
    ToggleLeftPanel(): void;
    ToggleEditorPanel(): void;
    OnAskAIToFix(error: ComponentError): void;
    OnNewComponent(): void;
    /**
     * True iff the currently-loaded Component declares itself as a form-role
     * component. Controls whether the right rail renders the field-binding
     * inspector or the default AI assistant panel.
     */
    get IsFormRoleComponent(): boolean;
    /**
     * Forwards a snippet emitted by the field-binding inspector to the code
     * editor. Inserts at the end of the current code with a leading blank
     * line so it lands inside the function body but doesn't clobber the
     * cursor's current position. (Cursor-aware insertion is a follow-up —
     * it requires plumbing EditorView refs from this component through
     * EditorTabs → CodeEditorPanel → mj-code-editor.)
     */
    OnFieldSnippetRequested(snippet: string): void;
    OnFormBuilderElementChanged(next: FormCanvasElement): void;
    OnFormBuilderSectionChanged(next: FormCanvasSection): void;
    OnFormBuilderElementDeleted(elementId: string): void;
    OnFormBuilderSectionDeleted(sectionId: string): void;
    OnFormBuilderFieldAdded(payload: {
        fieldName: string;
    }): void;
    /**
     * Persist the canvas mutation, mirror it into code, mark the dashboard
     * dirty. Centralised so right-panel events and tab events share the same
     * pipeline.
     */
    private applyCanvasUpdate;
    /**
     * {@link CanvasEditHost} adapter for the shared granular canvas-edit tool
     * suite. `ApplyCanvas` routes through `applyCanvasUpdate` so agent edits go
     * through the same dirty-track + code-regen + change-detection path as the
     * right-panel/tab events. Pane-navigation actions are intentionally omitted
     * (Component Studio uses its tab system), so the factory drops those tools.
     */
    private buildCanvasEditHost;
    /**
     * Build the deep, bounded agent-context slice for the active form canvas.
     * Mirrors the Form Builder cockpit's depth: a section/element summary the
     * agent can target by id OR label, the curated entity field names not yet
     * placed (AddField candidates), the resolved selected element/section names,
     * the dirty flag, and the active tab. All lists are capped inside
     * {@link buildCanvasStateSummary}.
     */
    private buildFormAgentContext;
    /**
     * Re-publish the form agent context after a canvas mutation, but ONLY when
     * the agent tools were already wired (the user invoked "Open in Chat"). We
     * track that with {@link formAgentContextActive} so a canvas edit before the
     * agent is involved doesn't spuriously register context/tools.
     */
    private reemitFormAgentContext;
    /**
     * Serialise the canvas → JSX into state.EditableCode. Quietly no-ops if
     * we don't have both a canvas and a schema (the FormSelected* events
     * shouldn't fire in that case anyway).
     */
    private regenerateFormCodeFromCanvas;
    /**
     * Bridge the Form Builder tab's "Open in Chat" button to NavigationService.
     * Publishes the active canvas as agent context and registers an UpdateForm
     * tool so Sage can mutate the canvas live. Falls back to clipboard if the
     * navigation service isn't available (e.g. embedded host).
     */
    private OnOpenFormInChat;
    OnNewComponentDialogClose(result: NewComponentResult | null): void;
    OnQuickStart(type: string): void;
    private createComponentFromResult;
    private getTemplateCode;
    /**
     * JSX skeleton for form-role components. Pre-wires destructured
     * FormHostProps, local `draft` state for the dirty-field diff, and the
     * three canonical lifecycle events (BeforeSave, BeforeDelete,
     * EditModeChangeRequested). Authors fill in the field rendering; the
     * persistence path is already correct.
     */
    private getFormTemplateCode;
    /** Sanitises a human-readable component name into a JS identifier. */
    private toIdentifier;
    ToggleExportDropdown(): void;
    OnDocumentClick(event: MouseEvent): void;
    ImportFromFile(): void;
    ImportFromText(): void;
    OnTextImportSpec(spec: ComponentSpec): void;
    OnTextImportCancel(): void;
    ImportFromArtifact(): void;
    OnArtifactLoadClose(result: ArtifactLoadResult | undefined): void;
    HandleFileSelect(event: Event): Promise<void>;
    private handleSpecImport;
    ExportToArtifact(): void;
    OnArtifactSelectionClose(result: ArtifactSelectionResult | undefined): Promise<void>;
    ExportToFile(): void;
    ExportToClipboard(): Promise<void>;
    RefreshData(): Promise<void>;
    OnLeftResizeStart(event: MouseEvent): void;
    OnRightResizeStart(event: MouseEvent): void;
    OnCenterResizeStart(event: MouseEvent): void;
    private addResizeListeners;
    private onResizeMove;
    private onResizeEnd;
    private readFile;
    private generateSHA256Hash;
    static ɵfac: i0.ɵɵFactoryDeclaration<ComponentStudioDashboardComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<ComponentStudioDashboardComponent, "mj-component-studio-dashboard", never, {}, {}, never, never, false, never>;
}
//# sourceMappingURL=component-studio-dashboard.component.d.ts.map