import { OnInit, OnDestroy, ElementRef, ChangeDetectorRef, AfterViewInit } from '@angular/core';
import { AIPromptRunEntity } from '@memberjunction/core-entities';
import { AIAgentRunCostService } from './ai-agent-run-cost.service';
import * as i0 from "@angular/core";
interface PromptMetrics {
    totalCount: number;
    totalExecutionTime: number;
    averageExecutionTime: number;
    byModel: Map<string, {
        count: number;
        totalTime: number;
        avgTime: number;
    }>;
    byVendor: Map<string, {
        count: number;
        totalTime: number;
        avgTime: number;
    }>;
    byPrompt: Map<string, {
        count: number;
        totalTime: number;
        avgTime: number;
    }>;
    statusBreakdown: {
        success: number;
        failed: number;
        timeout: number;
    };
    costBreakdown: {
        totalCost: number;
        byModel: Map<string, number>;
        byVendor: Map<string, number>;
    };
    tokenUsage: {
        totalInput: number;
        totalOutput: number;
        byModel: Map<string, {
            input: number;
            output: number;
        }>;
    };
}
interface ActionMetrics {
    totalCount: number;
    totalExecutionTime: number;
    averageExecutionTime: number;
    byAction: Map<string, {
        count: number;
        totalTime: number;
        avgTime: number;
        successRate: number;
    }>;
    byType: Map<string, {
        count: number;
        totalTime: number;
        avgTime: number;
    }>;
    statusBreakdown: {
        success: number;
        failed: number;
        timeout: number;
    };
    errorAnalysis: Map<string, number>;
}
interface TimelineMetrics {
    totalSteps: number;
    stepsByType: Map<string, number>;
    parallelExecutions: number;
    deepestNesting: number;
    criticalPath: {
        steps: string[];
        totalTime: number;
    };
}
interface SimpleAgentRun {
    ID: string;
    AgentID?: string;
    Status?: string;
}
interface SimpleAgentRunStep {
    ID: string;
    StepType: string;
    TargetLogID?: string;
}
interface SimpleActionLog {
    ID: string;
    Action: string | null;
    StartedAt: Date | null;
    EndedAt: Date | null;
    ResultCode: string | null;
    Message: string | null;
}
export declare class AIAgentRunAnalyticsComponent implements OnInit, OnDestroy, AfterViewInit {
    private cdr;
    private costService;
    agentRunId: string;
    private destroy$;
    /** Track active timeouts for cleanup */
    private activeTimeouts;
    /** Helper method to create tracked setTimeout calls */
    private setTrackedTimeout;
    /** Remove timeout from tracking array */
    private removeTimeoutFromTracking;
    expandedCharts: {
        [key: string]: boolean;
    };
    viewMode: 'grid' | 'expanded';
    isLoading: boolean;
    error: string | null;
    agentRun: SimpleAgentRun | null;
    allPromptRuns: AIPromptRunEntity[];
    allActionLogs: SimpleActionLog[];
    allSteps: SimpleAgentRunStep[];
    subAgentRuns: SimpleAgentRun[];
    promptMetrics: PromptMetrics;
    actionMetrics: ActionMetrics;
    timelineMetrics: TimelineMetrics;
    modelDistributionChartData: any;
    executionTimeChartData: any;
    costByVendorChartData: any;
    tokenUsageChartData: any;
    actionSuccessRateChartData: any;
    stepTypeDistributionChartData: any;
    promptDetailsExpanded: boolean;
    actionDetailsExpanded: boolean;
    panelStates: {
        summary: boolean;
        prompts: boolean;
        actions: boolean;
        models: boolean;
        timeline: boolean;
    };
    modelDistributionChart: ElementRef;
    executionTimeChart: ElementRef;
    costByVendorChart: ElementRef;
    tokenUsageChart: ElementRef;
    actionSuccessRateChart: ElementRef;
    stepTypeChart: ElementRef;
    promptTimeDistributionChart: ElementRef;
    promptTokenDistributionChart: ElementRef;
    promptCostDistributionChart: ElementRef;
    promptCountByNameChart: ElementRef;
    constructor(cdr: ChangeDetectorRef, costService: AIAgentRunCostService);
    ngOnInit(): void;
    ngOnDestroy(): void;
    private cleanupAllCharts;
    ngAfterViewInit(): void;
    loadData(): Promise<void>;
    private loadAllRunData;
    private initializePromptMetrics;
    private initializeActionMetrics;
    private initializeTimelineMetrics;
    private calculatePromptMetrics;
    private calculateActionMetrics;
    private calculateTimelineMetrics;
    private calculateExecutionTime;
    private prepareChartData;
    private generateColors;
    formatDuration(ms: number): string;
    formatCost(cost: number): string;
    refresh(): void;
    private renderCharts;
    private renderModelDistributionChart;
    private renderExecutionTimeChart;
    private renderCostByVendorChart;
    private renderTokenUsageChart;
    private renderActionSuccessRateChart;
    private renderStepTypeChart;
    calculatePromptSuccessRate(promptName: string): string;
    toggleChartExpansion(chartKey: string): void;
    toggleViewMode(): void;
    getActionType(actionName: string): string;
    getTopErrors(): Array<{
        message: string;
        count: number;
    }>;
    getModelPerformanceData(): any[];
    getStepTypeIcon(stepType: string): string;
    getModelColor(model: string): string;
    private renderPromptTimeDistributionChart;
    private renderPromptTokenDistributionChart;
    private renderPromptCostDistributionChart;
    private renderPromptCountByNameChart;
    /**
     * Get all agent run IDs in hierarchy, starting from the root run
     */
    private getAllAgentRunIds;
    /**
     * Load all prompt runs for the given agent run IDs
     * Uses the same approach as the cost calculation: find prompt runs via agent run steps
     */
    private loadAllPromptRuns;
    /**
     * TrackBy function for keyvalue pipe
     */
    trackByKey(index: number, item: {
        key: string;
        value: any;
    }): string;
    /**
     * TrackBy function for error messages
     */
    trackByErrorMessage(index: number, error: {
        message: string;
        count: number;
    }): string;
    /**
     * TrackBy function for model performance data
     */
    trackByModelName(index: number, model: any): string;
    static ɵfac: i0.ɵɵFactoryDeclaration<AIAgentRunAnalyticsComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<AIAgentRunAnalyticsComponent, "mj-ai-agent-run-analytics", never, { "agentRunId": { "alias": "agentRunId"; "required": false; }; }, {}, never, never, false, never>;
}
export {};
//# sourceMappingURL=ai-agent-run-analytics.component.d.ts.map