/**
 * @fileoverview Content Autotagging Dashboard
 *
 * Full dashboard for the content autotagging pipeline with left-nav and 5 tabs:
 * Pipeline Monitor, Sources Management, Content Types, Tag Library, Run History.
 * Supports CRUD on sources and content types via slide-in forms,
 * pipeline triggering with real-time GraphQL subscription progress.
 */
import { OnDestroy, AfterViewInit } from '@angular/core';
import { Subject } from 'rxjs';
import { CompositeKey } from '@memberjunction/core';
import { ResourceData, MJScheduledActionEntity } from '@memberjunction/core-entities';
import { BaseResourceComponent, NavigationService } from '@memberjunction/ng-shared';
import { MJLeftNavItem, MJLeftNavSection } from '@memberjunction/ng-ui-components';
import { TabName, NavItem, KPIMetric, PipelineStageInfo, FeedItem, SourceMini, SourceCard, ContentTypeCard, TagCloudItem, ContentDuplicateRow, RunDetailRow, ContentItemDetail } from './shared/classify.types';
import * as i0 from "@angular/core";
export declare class AutotaggingPipelineResourceComponent extends BaseResourceComponent implements AfterViewInit, OnDestroy {
    protected destroy$: Subject<void>;
    private cdr;
    private activityService;
    /** Activity-tracker id for the currently running pipeline (P3). */
    private pipelineActivityID;
    /** Debounced bus of entity names that changed externally; drives targeted reloads. */
    private entityChange$;
    protected navigationService: NavigationService;
    IsLoading: boolean;
    private totalContentItemCount;
    private totalContentTagCount;
    private totalRunHistoryCount;
    private static readonly CONTENT_ITEMS_PAGE_SIZE;
    private static readonly RUN_HISTORY_PAGE_SIZE;
    /** Current number of `MJ: Content Items` rows loaded into the feed window. */
    private contentItemsPageSize;
    /** Current number of `MJ: Content Process Runs` rows loaded into the history window. */
    private runHistoryWindowSize;
    /** True while a "Load more" fetch is in flight. */
    IsLoadingMoreItems: boolean;
    IsLoadingMoreRuns: boolean;
    private _activeTab;
    /** True once the view exists (after ngAfterViewInit), so the setter can safely run CD. */
    private viewReady;
    /**
     * The active tab. Backed by a setter that, once the view is ready, synchronously
     * flushes change detection whenever the value changes. The left-nav binds
     * `[ActiveId]="ActiveTab"`; mutating this during an async gap in init (e.g. between
     * the await in ngAfterViewInit and the next CD pass) previously surfaced an NG0100
     * (`Previous value: 'pipeline'. Current value: 'sources'`). Flushing in the setter
     * keeps the bound value stable across the check that follows.
     */
    get ActiveTab(): TabName;
    set ActiveTab(value: TabName);
    private tabDataLoaded;
    /** Live reference to the Tag Library tab (for deep-link + agent-tool search). */
    private tagsTab?;
    NavItems: NavItem[];
    KPIMetrics: KPIMetric[];
    PipelineStages: PipelineStageInfo[];
    FeedItems: FeedItem[];
    SourceMinis: SourceMini[];
    TrendingTags: TagCloudItem[];
    private _isRunning;
    /**
     * True while a classification pipeline run is in flight. Backed by a setter
     * that flushes change detection once the view is ready, so the `[disabled]="IsRunning"`
     * Run button binding stays stable across the check that follows a within-cycle
     * flip (run starting / instantly completing on an empty source) — eliminating
     * the NG0100 (`Previous value: 'true'. Current value: 'false'`). Mirrors the
     * `ActiveTab` setter pattern above.
     */
    get IsRunning(): boolean;
    set IsRunning(value: boolean);
    IsPaused: boolean;
    RunProgress: number;
    RunStage: string;
    RunCurrentItem: string;
    /** The current pipeline run ID (from GraphQL subscription) */
    CurrentPipelineRunID: string | null;
    /** The process run ID (server-side ContentProcessRun) for pause/cancel/resume */
    CurrentProcessRunID: string | null;
    ShowPipelineConfig: boolean;
    PipelineConfig: {
        Pipeline?: {
            BatchSize?: number;
            MaxConcurrentBatches?: number;
            DelayBetweenBatchesMs?: number;
            ResumeFromLastBatch?: boolean;
            ErrorThresholdPercent?: number;
        };
        RateLimits?: {
            LLM?: {
                RequestsPerMinute?: number;
                TokensPerMinute?: number;
            };
            Embedding?: {
                RequestsPerMinute?: number;
                TokensPerMinute?: number;
            };
            VectorDB?: {
                RequestsPerMinute?: number;
            };
        };
    };
    TogglePipelineConfig(): void;
    private persistClassifyPreferences;
    private loadClassifyPreferences;
    ContentDuplicates: ContentDuplicateRow[];
    IsLoadingDuplicates: boolean;
    LiveRunDetailRows: RunDetailRow[];
    IsLoadingLiveDetails: boolean;
    ShowNoContentTypeWarning: boolean;
    /** Live reference to the slide-in CRUD form dialog (driven from tab events). */
    private formDialog?;
    private setupWizard?;
    /** Cached ScheduledAction entities, keyed by normalized ID */
    private scheduledActionsCache;
    SelectedFeedItem: ContentItemDetail | null;
    ShowItemDetail: boolean;
    /** ID of the content item shown in the drilldown slide-in, or null when closed. */
    DrilldownItemID: string | null;
    ShowItemDrilldown: boolean;
    private contentSourcesRaw;
    private contentItemsRaw;
    private contentTagsRaw;
    private contentRunsRaw;
    /** Exposes the raw run rows to the Run History tab component via `[Runs]`. */
    get ContentRunsRaw(): Record<string, unknown>[];
    private contentSourceTypesRaw;
    private contentTypesRaw;
    private contentFileTypesRaw;
    private aiModelsRaw;
    /** Exposes raw content types to the Content Types tab via `[ContentTypes]`. */
    get ContentTypesRaw(): Record<string, unknown>[];
    /** Exposes raw content sources to the Content Types tab via `[Sources]`. */
    get ContentSourcesRaw(): Record<string, unknown>[];
    /** Exposes raw content items to the Content Types / Tag Library tabs via `[Items]`/`[ContentItems]`. */
    get ContentItemsRaw(): Record<string, unknown>[];
    /** Exposes raw content item tags to the Tag Library tab via `[ContentTags]`. */
    get ContentTagsRaw(): Record<string, unknown>[];
    /** Exposes the accurate total item count to the Content Types / Sources tabs via `[TotalItemCount]`. */
    get TotalContentItemCount(): number;
    /** Exposes the accurate total tag count to the Sources tab via `[TotalTagCount]`. */
    get TotalContentTagCount(): number;
    /** Exposes the accurate total run-history count to the Run History tab via `[TotalRunCount]`. */
    get TotalRunHistoryCount(): number;
    /** Exposes the cached ScheduledAction entities to the Sources tab via `[ScheduledActions]`. */
    get ScheduledActionsCache(): Map<string, MJScheduledActionEntity>;
    /** Exposes the EntityRecordDocument ID→RecordID cache to the Sources tab via `[EntityRecordDocCache]`. */
    get EntityRecordDocCacheMap(): Map<string, string>;
    /**
     * Reload the shared source list after the Sources tab mutates a source
     * (delete / schedule change). Rebinding `contentSourcesRaw` flows through the
     * tab's `[Sources]` input setter, which rebuilds its cards.
     */
    OnSourcesDataChanged(): Promise<void>;
    /**
     * Hook for the Taxonomy tab's `(DataChanged)` output. The taxonomy tab owns
     * and reloads its own data; the host has no shared taxonomy surface to
     * refresh today, so this is a no-op placeholder kept for future cross-tab wiring.
     */
    OnTaxonomyDataChanged(): void;
    private static readonly PREFS_KEY;
    private static readonly VALID_TABS;
    /** Lightweight count of Pending tag suggestions for the Inbox nav badge. */
    InboxPendingCount: number;
    /** Lightweight count of Pending health-signal suggestions for the Health nav badge. */
    HealthPendingCount: number;
    /** Live reference to the Suggestions Inbox tab (for refresh after host actions). */
    private inboxTab?;
    /** Live reference to the Tag Health tab (for refresh after host actions). */
    private healthTab?;
    ngAfterViewInit(): Promise<void>;
    /**
     * D9: Read incoming configuration from ResourceData (e.g. from Analytics tag navigation).
     * Sets the initial tab and tag search query if provided.
     */
    private applyIncomingConfiguration;
    /**
     * Tag browsing/search now lives on the dedicated Tags surface, so the Classify
     * cockpit no longer hosts a `tagSearch` deep-link target. Kept as a no-op to
     * preserve the call site. (Re-targeting Analytics' tag drill-down to the Tags
     * surface is a tracked follow-up.)
     */
    private handleInitialTagSearch;
    ngOnDestroy(): void;
    /** Lowercased names of the entities whose external changes should refresh this dashboard. */
    private static readonly REACTIVE_ENTITIES;
    /**
     * Lightweight reactivity: listen for BaseEntity save/delete/remote-invalidate
     * events on the entities this dashboard renders, debounce them (~300ms to
     * coalesce bursts), and re-call the matching host load method. Reloads never
     * call Save(), so this cannot create a reload loop.
     */
    private subscribeToEntityChanges;
    /** Re-run the host load method(s) affected by an external change to `entityName`. */
    private reloadForEntity;
    /** Report current classify dashboard state to the agent */
    private emitAgentContext;
    /** Register client tools the agent can invoke on the Classify dashboard */
    private registerAgentTools;
    GetResourceDisplayName(_data: ResourceData): Promise<string>;
    GetResourceIconClass(_data: ResourceData): Promise<string>;
    /** Memoized backing store + input signature for {@link navSections}. */
    private _navSections;
    private _navSectionsSignature;
    /**
     * Wraps `NavItems` for `<mj-left-nav>`. Hardcoded "Run History" item goes
     * into a second `MJLeftNavSection` — the rail's natural section break
     * replaces the bespoke `.at-nav-divider` line.
     *
     * Memoized: the array (and its element objects) are rebuilt only when one of
     * the inputs actually changes. Returning a fresh array on every change-detection
     * pass made `<mj-left-nav>` see a new `[Sections]` reference each cycle, which
     * triggered `ExpressionChangedAfterItHasBeenCheckedError` (NG0100) during rapid
     * tab switching (badge counts / IsRunning resolving mid-CD-cycle). A stable
     * reference until inputs change eliminates that.
     */
    get navSections(): MJLeftNavSection[];
    /** Cheap stable fingerprint of every value that feeds {@link buildNavSections}. */
    private computeNavSectionsSignature;
    /** Constructs the left-nav section model from current state (see {@link navSections}). */
    private buildNavSections;
    /**
     * Loads a lightweight count of Pending tag suggestions for the Inbox nav badge
     * so the badge shows even before the Inbox tab is first opened. Mirrors the
     * Inbox tab's default scope: excludes the 3 Health-owned reasons
     * (MergeCandidate / LowUsage / WideNode).
     */
    private loadInboxPendingCount;
    /**
     * Fired by the Inbox tab after a suggestion is approved/merged/rejected.
     * Refreshes the nav badge count.
     */
    onInboxResolved(): Promise<void>;
    /**
     * Loads a lightweight count of Pending health-signal suggestions for the
     * Health nav badge — the 3 reasons the Inbox excludes (MergeCandidate /
     * LowUsage / WideNode), which the Tag Health tab owns.
     */
    private loadHealthPendingCount;
    /**
     * Fired by the Health tab after a merge/deprecate/dismiss. Refreshes the
     * Health nav badge count.
     */
    onHealthResolved(): Promise<void>;
    /**
     * Fired by the Health tab's "Review in Taxonomy" action with a tag ID. The
     * Taxonomy tab has no public select-tag input today, so this simply switches
     * to it; selecting the specific node is a future enhancement.
     */
    onOpenInTaxonomyRequested(_tagID: string): void;
    /** Adapter for `<mj-left-nav>`'s `(ItemClicked)` output. */
    onNavItemClicked(item: MJLeftNavItem): void;
    SwitchTab(tab: TabName): Promise<void>;
    private loadTabData;
    LoadPipelineData(): Promise<void>;
    /**
     * Widen the loaded content-item window by one page and reload, so the user can
     * see items previously truncated by the MaxRows cap. Wired to the pipeline
     * tab's `(LoadMoreItemsRequested)`.
     */
    LoadMoreContentItems(): Promise<void>;
    private buildNavItems;
    private buildKPIMetrics;
    private buildPipelineStages;
    private buildFeedItems;
    private buildSourceMinis;
    /**
     * D6: Build trending tags weighted by recency (last 7 days).
     * Counts tags from ContentItemTag records created in the last 7 days
     * and weights by frequency. Falls back to all-time data if no recent tags.
     */
    private buildTrendingTags;
    /**
     * Compute scored trending tags from a given set of tag records.
     * Returns top 12 tags sorted by score (frequency x avg weight).
     */
    private computeTrendingFromTags;
    private loadSourcesData;
    /** Check if a source type's Configuration says RequiresFileType !== false */
    private sourceTypeRequiresFileType;
    private loadContentTypesData;
    private loadTagLibraryData;
    private loadRunHistoryData;
    /**
     * Host handler for the Run History tab's `(RefreshRequested)` output. Forces a
     * reload of `MJ: Content Process Runs`; the new array re-binds via `[Runs]`,
     * which rebuilds the tab's rows and clears its loading state.
     */
    ReloadRunHistory(): Promise<void>;
    /**
     * Host handler for the Run History tab's `(LoadMoreRequested)` output. Widens
     * the loaded window by one page and reloads, so the user can see the runs that
     * were previously truncated. The new array re-binds via `[Runs]`.
     */
    LoadMoreRunHistory(): Promise<void>;
    /**
     * D2: Load live per-source progress for the currently running pipeline.
     * Called when the pipeline is actively running.
     */
    LoadLiveRunDetails(): Promise<void>;
    OpenAddSourceForm(): void;
    /** Open the guided setup wizard (empty-state CTA + "Add Source (Guided)"). */
    OpenSetupWizard(): void;
    /** Show the guided onboarding checklist until content has been classified. */
    get ShowOnboarding(): boolean;
    /** Whether the onboarding card has been dismissed this session. */
    OnboardingDismissed: boolean;
    /** Steps for the first-run onboarding checklist, with live completion state. */
    get OnboardingSteps(): Array<{
        N: number;
        Title: string;
        Desc: string;
        Done: boolean;
        Action: 'add' | 'run' | '';
        Cta: string;
    }>;
    /** Index of the first incomplete step (the "active" one). */
    get OnboardingActiveStep(): number;
    /** Handle an onboarding step CTA. */
    OnOnboardingAction(action: 'add' | 'run' | 'seed'): void;
    /** Dismiss the onboarding card (until next load / still empty). */
    DismissOnboarding(): void;
    /** After the wizard creates a source, reload the shared source list. */
    onWizardCreated(_event: {
        SourceID: string;
    }): Promise<void>;
    OpenEditSourceForm(card: SourceCard): void;
    OpenAddTypeForm(): void;
    OpenEditTypeForm(card: ContentTypeCard): void;
    /**
     * Reload the relevant shared data after the slide-in form saves. The form
     * dialog closes itself; the host only re-pulls the cards' source data.
     */
    onFormSaved(event: {
        kind: 'source' | 'type';
    }): Promise<void>;
    /**
     * The form dialog's "Open advanced settings" link bubbles up here so the host
     * (which owns NavigationService) can open the full entity form.
     */
    onFormNavigateToRecord(event: {
        entityName: string;
        key: CompositeKey;
    }): Promise<void>;
    /**
     * Loads ScheduledAction entities referenced by content sources into the local cache.
     * Called during initial data load so cron descriptions are available for card rendering.
     */
    private loadScheduledActionsForSources;
    /**
     * Run the pipeline for a specific content source only.
     */
    RunPipelineForSource(contentSourceID: string): Promise<void>;
    RunPipeline(contentSourceIDs?: string[]): Promise<void>;
    /**
     * Pause a running classification pipeline. The server sets CancellationRequested
     * on the process run so the engine pauses gracefully after the current batch.
     */
    PausePipeline(): Promise<void>;
    /**
     * Resume a paused classification pipeline from its last completed offset.
     */
    ResumePipeline(): Promise<void>;
    /**
     * Cancel a running or paused pipeline. Uses pause mechanism and resets UI state.
     */
    CancelPipeline(): Promise<void>;
    private subscribeToPipelineProgress;
    private updateStagesForActiveRun;
    private formatStageName;
    private countTagsByItem;
    private getTopTagsForItem;
    private countItemsBySource;
    private inferItemStatus;
    formatRelativeTime(dateStr: string | null | undefined): string;
    private ensureBaseDataLoaded;
    private refreshSourcesTab;
    private refreshContentTypesTab;
    OpenFeedItemDetail(index: number): void;
    OpenContentItemDetail(item: ContentItemDetail): void;
    /** Open content item detail slide-in by content item ID (used from tag drill-down) */
    OpenItemDetailByID(contentItemID: string): void;
    CloseItemDetail(): void;
    /** Open the audit/analytics drilldown slide-in for a content item. */
    OpenItemDrilldown(itemID: string): void;
    CloseItemDrilldown(): void;
    /**
     * Handle a record-open intent bubbled up from the drilldown (item record,
     * source, prompt run, entity record document). The host owns NavigationService.
     */
    OpenDrilldownRecord(event: {
        entityName: string;
        recordID: string;
    }): void;
    OpenRecordFromItem(item: ContentItemDetail): void;
    /** Cache: EntityRecordDocument ID → RecordID */
    private entityRecordDocCache;
    /** Load ERD RecordIDs for entity-sourced content items */
    private loadEntityRecordDocCache;
    private getAllWeightedTagsForItem;
    /**
     * D4: Infer embedding and tagging pipeline statuses for a content item.
     * Uses tag count and run history heuristics since dedicated status columns
     * are not yet available on the ContentItem entity.
     */
    private inferPipelineStatuses;
    /** Map a raw status string to the ItemPipelineStatus union */
    private mapStatusString;
    /** Load pending content item duplicates for review */
    LoadContentDuplicates(): Promise<void>;
    /** Resolve content source names for a list of content item IDs */
    private resolveItemSourceNames;
    /** Confirm a content duplicate pair */
    ConfirmContentDuplicate(dupRow: ContentDuplicateRow): Promise<void>;
    /** Dismiss a content duplicate pair */
    DismissContentDuplicate(dupRow: ContentDuplicateRow): Promise<void>;
    static ɵfac: i0.ɵɵFactoryDeclaration<AutotaggingPipelineResourceComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<AutotaggingPipelineResourceComponent, "app-autotagging-pipeline-resource", never, {}, {}, never, never, false, never>;
}
export declare function LoadAutotaggingPipelineResource(): void;
//# sourceMappingURL=autotagging-pipeline-resource.component.d.ts.map