import { OnInit, OnDestroy, ChangeDetectorRef, ElementRef, AfterViewInit, NgZone } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subject } from 'rxjs';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { TelemetryInsight, TelemetryCategory, TelemetryParamsUnion } from '@memberjunction/core';
import { ResourceData } from '@memberjunction/core-entities';
import { EngineMemoryStats, CacheEntryInfo, CacheStats, CacheEntryType } from '@memberjunction/core';
import { TabConfig } from '@memberjunction/ng-ui-components';
import * as i0 from "@angular/core";
/**
 * Interface representing a single engine's diagnostic info for display
 */
export interface EngineDiagnosticInfo {
    className: string;
    isLoaded: boolean;
    registeredAt: Date;
    lastLoadedAt: Date | null;
    estimatedMemoryBytes: number;
    itemCount: number;
    memoryDisplay: string;
}
/**
 * Interface for engine config items for drill-down detail
 */
export interface EngineConfigItemDisplay {
    propertyName: string;
    type: 'entity' | 'dataset';
    entityName?: string;
    datasetName?: string;
    filter?: string;
    orderBy?: string;
    itemCount: number;
    estimatedMemoryBytes: number;
    memoryDisplay: string;
    sampleData: unknown[];
    expanded: boolean;
    /** Whether this property loaded successfully during engine startup */
    loadedSuccessfully: boolean;
    /** Error message if the property failed to load */
    errorMessage?: string;
    displayedData: unknown[];
    allDataLoaded: boolean;
    isLoadingMore: boolean;
    currentPage: number;
    pageSize: number;
}
/**
 * Engine detail panel state
 */
export interface EngineDetailPanelState {
    isOpen: boolean;
    engine: EngineDiagnosticInfo | null;
    configItems: EngineConfigItemDisplay[];
    isRefreshing: boolean;
}
/**
 * Interface for redundant entity loading info
 */
export interface RedundantLoadInfo {
    entityName: string;
    engines: string[];
}
/**
 * Display-friendly telemetry pattern info
 */
export interface TelemetryPatternDisplay {
    fingerprint: string;
    category: TelemetryCategory;
    operation: string;
    entityName: string | null;
    filter: string | null;
    orderBy: string | null;
    count: number;
    avgElapsedMs: number;
    totalElapsedMs: number;
    minElapsedMs: number;
    maxElapsedMs: number;
    lastSeen: Date;
    sampleParams: TelemetryParamsUnion;
}
/**
 * Display-friendly telemetry event for timeline
 */
export interface TelemetryEventDisplay {
    id: string;
    category: TelemetryCategory;
    operation: string;
    entityName: string | null;
    filter: string | null;
    startTime: number;
    endTime: number | undefined;
    elapsedMs: number | undefined;
    timestamp: Date;
    params: TelemetryParamsUnion;
}
/**
 * Extended insight with expansion state
 */
export interface TelemetryInsightDisplay extends TelemetryInsight {
    expanded: boolean;
    relatedEvents: TelemetryEventDisplay[];
}
/**
 * Sort configuration for patterns table
 */
export interface PatternSortConfig {
    column: 'category' | 'operation' | 'entity' | 'count' | 'avgMs' | 'totalMs';
    direction: 'asc' | 'desc';
}
/**
 * Event detail panel state
 */
export interface EventDetailPanelState {
    isOpen: boolean;
    event: TelemetryEventDisplay | null;
    relatedPattern: TelemetryPatternDisplay | null;
}
/**
 * Summary stats for telemetry
 */
export interface TelemetrySummary {
    totalEvents: number;
    totalPatterns: number;
    totalInsights: number;
    activeEvents: number;
    byCategory: Record<TelemetryCategory, {
        events: number;
        avgMs: number;
    }>;
}
/**
 * Interface for persisted user preferences
 */
export interface SystemDiagnosticsUserPreferences {
    activeSection: 'engines' | 'redundant' | 'performance' | 'cache';
    perfTab: 'monitor' | 'overview' | 'events' | 'patterns' | 'insights';
    telemetrySource: 'client' | 'server';
    categoryFilter: 'all' | TelemetryCategory;
    chartZoomLevel: number;
    chartGapCompression: boolean;
    autoRefresh: boolean;
}
/**
 * System Diagnostics Resource Component
 *
 * Provides a comprehensive view of:
 * - All registered BaseEngine instances and their memory usage
 * - Entity load tracking across engines (identifies redundant loading)
 *
 * This is a client-side only dashboard - all data comes from in-memory registries.
 */
export declare class SystemDiagnosticsComponent extends BaseResourceComponent implements OnInit, OnDestroy, AfterViewInit {
    private cdr;
    private ngZone;
    private route;
    protected destroy$: Subject<void>;
    private metadata;
    private userSettingEntity;
    private saveSettingsTimeout;
    private settingsLoaded;
    isLoading: boolean;
    autoRefresh: boolean;
    activeSection: 'engines' | 'redundant' | 'performance' | 'cache';
    lastUpdated: Date;
    isRefreshingEngines: boolean;
    engineStats: EngineMemoryStats | null;
    engines: EngineDiagnosticInfo[];
    redundantLoads: RedundantLoadInfo[];
    telemetrySummary: TelemetrySummary | null;
    telemetryPatterns: TelemetryPatternDisplay[];
    telemetryInsights: TelemetryInsightDisplay[];
    telemetryEnabled: boolean;
    categoriesWithData: {
        name: string;
        events: number;
        avgMs: number;
    }[];
    telemetrySource: 'client' | 'server';
    serverTelemetryLoading: boolean;
    serverTelemetryError: string | null;
    serverTelemetryEnabled: boolean;
    telemetryEvents: TelemetryEventDisplay[];
    timelineView: 'insights' | 'timeline' | 'chart';
    perfTab: 'monitor' | 'overview' | 'events' | 'patterns' | 'insights';
    perfChartRef: ElementRef<HTMLDivElement>;
    private chartInitialized;
    chartZoomLevel: number;
    chartGapCompression: boolean;
    private chartViewportStart;
    private chartViewportEnd;
    private expandedGaps;
    private isSelecting;
    private selectionStartX;
    private selectionRect;
    private chartXScale;
    private chartMarginLeft;
    chartTimeRangeStart: number | null;
    chartInteractionMode: 'pointer' | 'select' | 'pan';
    private chartGapSegments;
    chartTimeRangeEnd: number | null;
    slowQueries: TelemetryEventDisplay[];
    slowQueryThresholdMs: number;
    patternSort: PatternSortConfig;
    searchQuery: string;
    categoryFilter: TelemetryCategory | 'all';
    telemetryBootTime: number;
    eventDetailPanel: EventDetailPanelState;
    cacheStats: CacheStats | null;
    cacheEntries: CacheEntryInfo[];
    cacheTypeFilter: CacheEntryType | 'all';
    cacheInitialized: boolean;
    cacheHitRate: number;
    engineDetailPanel: EngineDetailPanelState;
    isRefreshingSingleEngine: string | null;
    constructor(cdr: ChangeDetectorRef, ngZone: NgZone, route: ActivatedRoute);
    ngOnInit(): Promise<void>;
    ngOnDestroy(): void;
    ngAfterViewInit(): void;
    setActiveSection(section: 'engines' | 'redundant' | 'performance' | 'cache'): void;
    /**
     * Adapter for `<mj-tab-nav>`'s string-typed `(TabChange)` output.
     * Narrows the emitted key to the typed `activeSection` union before
     * delegating to `setActiveSection`.
     */
    onSectionTabChange(key: string): void;
    /**
     * L2 section tabs for `<mj-tab-nav>` in the interior chrome's [toolbar] slot.
     * Badges are dynamic (engine count, redundant-load count w/ warning variant,
     * telemetry event count, cache entry count).
     */
    get diagnosticsTabs(): TabConfig[];
    toggleAutoRefresh(): void;
    refreshData(): Promise<void>;
    private refreshTelemetryData;
    private eventToDisplay;
    private getRelatedEventsForInsight;
    private sortPatterns;
    sortPatternsBy(column: PatternSortConfig['column']): void;
    getSortIcon(column: PatternSortConfig['column']): string;
    toggleInsightExpanded(insight: TelemetryInsightDisplay): void;
    setTimelineView(view: 'insights' | 'timeline' | 'chart'): void;
    setPerfTab(tab: 'monitor' | 'overview' | 'events' | 'patterns' | 'insights'): void;
    jumpToPatternsByCategory(categoryName: string): void;
    getInsightFilter(insight: TelemetryInsightDisplay): string | null;
    getEventParams(event: TelemetryEventDisplay): Array<{
        key: string;
        value: string;
    }>;
    private formatParamValue;
    /**
     * Check if this is a RunView/RunViews operation
     */
    isRunViewOperation(event: TelemetryEventDisplay): boolean;
    /**
     * Check if this is a batch RunViews operation
     */
    isRunViewsOperation(event: TelemetryEventDisplay): boolean;
    /**
     * Get entity names for RunViews batch operation (first few for display)
     */
    getRunViewsEntities(event: TelemetryEventDisplay, maxDisplay?: number): string[];
    /**
     * Get total entity count for RunViews batch operation
     */
    getRunViewsEntityCount(event: TelemetryEventDisplay): number;
    /**
     * Check if there are more entities than displayed
     */
    hasMoreEntities(event: TelemetryEventDisplay, maxDisplay?: number): boolean;
    /**
     * Check if the event was a cache hit (safe accessor for union type params)
     */
    isCacheHit(event: TelemetryEventDisplay | {
        params: TelemetryParamsUnion;
    }): boolean;
    /**
     * Get entity name from telemetry params (safe accessor for union type)
     */
    getEntityName(params: TelemetryParamsUnion | undefined): string | null;
    /**
     * Get filter from telemetry params (safe accessor for union type)
     */
    getFilter(params: TelemetryParamsUnion | undefined): string | null;
    /**
     * Get order by from telemetry params (safe accessor for union type)
     */
    getOrderBy(params: TelemetryParamsUnion | undefined): string | null;
    /**
     * Get RunView parameter pills for display
     */
    getRunViewPills(event: TelemetryEventDisplay): Array<{
        label: string;
        value: string;
        type: 'filter' | 'order' | 'result' | 'limit' | 'batch' | 'info';
    }>;
    openEventDetailPanel(event: TelemetryEventDisplay): void;
    closeEventDetailPanel(): void;
    copyEventToClipboard(event: TelemetryEventDisplay): void;
    filterByEntity(entityName: string | null): void;
    exportTelemetryData(): void;
    setCategoryFilter(category: TelemetryCategory | 'all'): void;
    setCategoryFilterByName(name: string): void;
    onSearchChange(): void;
    clearSearch(): void;
    private searchParamsTimeout;
    private updateQueryParamsDebounced;
    get filteredPatterns(): TelemetryPatternDisplay[];
    get filteredEvents(): TelemetryEventDisplay[];
    formatTimestamp(date: Date): string;
    truncateString(str: string | null, maxLength: number): string;
    toggleTelemetry(): void;
    clearTelemetry(): void;
    /**
     * Switch between client and server telemetry sources
     */
    setTelemetrySource(source: 'client' | 'server'): void;
    /**
     * Load telemetry data from the server via GraphQL
     */
    private loadServerTelemetry;
    getSeverityClass(severity: string): string;
    getSeverityIcon(severity: string): string;
    refreshAllEngines(): Promise<void>;
    formatBytes(bytes: number): string;
    formatTime(date: Date): string;
    formatRelativeTime(ms: number): string;
    /**
     * Renders a Windows PerfMon-style D3 time series chart
     * Shows performance events over time with duration spikes
     */
    renderPerfChart(): void;
    private drawGridLines;
    private drawAxes;
    /**
     * Format time for axis labels - shows relative time since process start
     */
    private formatAxisTime;
    /**
     * Format duration for Y axis labels
     */
    private formatAxisDuration;
    private drawCategoryArea;
    private drawEventPoints;
    private drawThresholdLine;
    /**
     * Zoom the chart in or out
     */
    zoomPerfChart(direction: 'in' | 'out'): void;
    /**
     * Reset chart zoom to default
     */
    resetPerfChartZoom(): void;
    /**
     * Handle gap compression toggle
     */
    onGapCompressionChange(): void;
    /**
     * Set chart interaction mode (select for drag-to-zoom, pan for click-to-view)
     */
    setChartInteractionMode(mode: 'pointer' | 'select' | 'pan'): void;
    /**
     * Returns the appropriate cursor style based on the current chart interaction mode
     */
    private getChartCursor;
    /**
     * Returns whether the overlay should intercept pointer events based on the current mode
     */
    private getOverlayPointerEvents;
    /**
     * Identifies gaps in the data where there's no activity
     * Returns segments with their type (events or gap)
     */
    private identifyGaps;
    /**
     * Draws a compressed gap indicator
     */
    private drawGapIndicator;
    /**
     * Adds a drag-to-select brush overlay for zooming into a time range
     * Only active when chartInteractionMode is 'select'
     */
    private addSelectionBrush;
    /**
     * Zooms the chart to show only events within the specified time range
     */
    private zoomToTimeRange;
    /**
     * Refreshes cache data from LocalCacheManager
     */
    refreshCacheData(): void;
    /**
     * Getter for filtered cache entries based on type filter
     */
    get filteredCacheEntries(): CacheEntryInfo[];
    /**
     * Sets the cache type filter
     */
    setCacheTypeFilter(type: CacheEntryType | 'all'): void;
    /**
     * Clears all cache entries
     */
    clearAllCache(): Promise<void>;
    /**
     * Invalidates a single cache entry
     */
    invalidateCacheEntry(entry: CacheEntryInfo): Promise<void>;
    /**
     * Formats a cache timestamp (unix ms) to display string
     */
    formatCacheTimestamp(timestamp: number): string;
    /**
     * Refresh a single engine
     */
    refreshSingleEngine(engine: EngineDiagnosticInfo, event: Event): Promise<void>;
    /**
     * Opens the engine detail panel for a specific engine
     */
    openEngineDetailPanel(engine: EngineDiagnosticInfo): void;
    /**
     * Closes the engine detail panel
     */
    closeEngineDetailPanel(): void;
    /**
     * Refreshes the engine shown in the detail panel
     */
    refreshEngineInDetailPanel(): Promise<void>;
    /**
     * Gets config items for an engine by examining its Configs property
     */
    private getEngineConfigItems;
    /**
     * Estimates memory for an array of objects
     */
    private estimateArrayMemory;
    /**
     * Toggle expansion of a config item
     */
    toggleConfigItemExpanded(item: EngineConfigItemDisplay): void;
    /**
     * Get column names for sample data display
     */
    getSampleDataColumns(item: EngineConfigItemDisplay): string[];
    /**
     * Get a value from sample data for display
     */
    getSampleDataValue(row: unknown, column: string): string;
    /**
     * Format a value for display in sample data table
     */
    private formatValueForDisplay;
    /**
     * Load more data for a config item (paging)
     */
    loadMoreData(item: EngineConfigItemDisplay): void;
    /**
     * Load all remaining data for a config item
     */
    loadAllData(item: EngineConfigItemDisplay): void;
    /**
     * Get the record ID from a row (for opening entity records)
     */
    getRecordId(row: unknown): string | null;
    /**
     * Open an entity record using NavigationService
     */
    openEntityRecord(entityName: string, row: unknown): void;
    /**
     * Open an entity in the explorer (placeholder - would need routing integration)
     */
    openEntityInExplorer(entityName: string): void;
    /**
     * Apply query parameters to component state (deep linking support)
     * Query params take precedence over saved preferences
     */
    private applyQueryParams;
    /**
     * Update query parameters to reflect current state (for deep linking)
     * Uses NavigationService for proper URL management that respects app-scoped routes.
     */
    private updateQueryParams;
    /**
     * Load user preferences from MJ: User Settings entity using UserInfoEngine for cached access
     */
    private loadUserPreferences;
    /**
     * Apply loaded user preferences to component state
     */
    private applyUserPreferences;
    /**
     * Get current preferences as an object
     */
    private getCurrentPreferences;
    /**
     * Debounced save of user preferences (500ms delay)
     * Also updates query params for deep linking
     */
    private saveUserPreferencesDebounced;
    /**
     * Save user preferences to MJ: User Settings entity using UserInfoEngine for cached lookup
     */
    private saveUserPreferences;
    GetResourceDisplayName(data: ResourceData): Promise<string>;
    GetResourceIconClass(data: ResourceData): Promise<string>;
    static ɵfac: i0.ɵɵFactoryDeclaration<SystemDiagnosticsComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<SystemDiagnosticsComponent, "app-system-diagnostics", never, {}, {}, never, never, false, never>;
}
//# sourceMappingURL=system-diagnostics.component.d.ts.map