var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component, ChangeDetectionStrategy, ViewChild } from '@angular/core';
import { BaseDashboard } from '@memberjunction/ng-shared';
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
import { Subject } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { SharedService } from '@memberjunction/ng-shared';
import { buildSchedulingAgentContext, buildSchedulingNotFoundError, isValidSchedulingTab, resolveSchedulingItem, SCHEDULING_TABS, SCHEDULING_JOB_STATUSES, } from './scheduling-agent-context';
import * as i0 from "@angular/core";
import * as i1 from "./services/scheduling-instrumentation.service";
import * as i2 from "@memberjunction/ng-ui-components";
import * as i3 from "./components/scheduling-overview.component";
import * as i4 from "./components/scheduling-jobs.component";
import * as i5 from "./components/scheduling-activity.component";
const _c0 = ["overviewCmp"];
const _c1 = ["jobsCmp"];
const _c2 = ["activityCmp"];
const _forTrack0 = ($index, $item) => $item.value;
function SchedulingDashboardComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-stat-badge", 5);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("Count", ctx_r0.AlertCount)("Label", ctx_r0.AlertCount === 1 ? "Alert" : "Alerts");
} }
function SchedulingDashboardComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-stat-badge", 6);
} }
function SchedulingDashboardComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-stat-badge", 7);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("Count", (ctx_r0.jobsCmp == null ? null : ctx_r0.jobsCmp.FilteredJobs == null ? null : ctx_r0.jobsCmp.FilteredJobs.length) ?? 0)("Total", (ctx_r0.jobsCmp == null ? null : ctx_r0.jobsCmp.Jobs == null ? null : ctx_r0.jobsCmp.Jobs.length) ?? 0);
} }
function SchedulingDashboardComponent_Case_7_Template(rf, ctx) { if (rf & 1) {
    const _r2 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-refresh-button", 13);
    i0.ɵɵlistener("Clicked", function SchedulingDashboardComponent_Case_7_Template_mj_refresh_button_Clicked_0_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.overviewCmp == null ? null : ctx_r0.overviewCmp.Refresh()); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(1, "button", 14);
    i0.ɵɵlistener("click", function SchedulingDashboardComponent_Case_7_Template_button_click_1_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.overviewCmp == null ? null : ctx_r0.overviewCmp.ToggleAutoRefresh()); });
    i0.ɵɵelement(2, "i", 15);
    i0.ɵɵelementStart(3, "span", 16);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵproperty("variant", (ctx_r0.overviewCmp == null ? null : ctx_r0.overviewCmp.AutoRefreshEnabled) ? "primary" : "secondary");
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate1("Auto: ", (ctx_r0.overviewCmp == null ? null : ctx_r0.overviewCmp.AutoRefreshEnabled) ? "ON" : "OFF");
} }
function SchedulingDashboardComponent_Case_8_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-filter-popover", 17);
    i0.ɵɵlistener("ClearAllRequested", function SchedulingDashboardComponent_Case_8_Template_mj_filter_popover_ClearAllRequested_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.resetJobsFilters()); });
    i0.ɵɵelementStart(1, "mj-filter-panel", 18);
    i0.ɵɵlistener("ValuesChange", function SchedulingDashboardComponent_Case_8_Template_mj_filter_panel_ValuesChange_1_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.onJobsFilterValuesChange($event)); })("Reset", function SchedulingDashboardComponent_Case_8_Template_mj_filter_panel_Reset_1_listener() { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.resetJobsFilters()); });
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(2, "mj-refresh-button", 13);
    i0.ɵɵlistener("Clicked", function SchedulingDashboardComponent_Case_8_Template_mj_refresh_button_Clicked_2_listener() { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.jobsCmp == null ? null : ctx_r0.jobsCmp.Refresh()); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "button", 19);
    i0.ɵɵlistener("click", function SchedulingDashboardComponent_Case_8_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.jobsCmp == null ? null : ctx_r0.jobsCmp.OpenCreateSlideout()); });
    i0.ɵɵelement(4, "i", 20);
    i0.ɵɵelementStart(5, "span", 16);
    i0.ɵɵtext(6, "New Job");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ActiveCount", ctx_r0.JobsActiveFilterCount)("ShowClearAll", ctx_r0.JobsActiveFilterCount > 0);
    i0.ɵɵadvance();
    i0.ɵɵproperty("Fields", ctx_r0.JobsFilterFields)("Values", ctx_r0.JobsFilterValues);
} }
function SchedulingDashboardComponent_Case_9_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-filter-popover", 17);
    i0.ɵɵlistener("ClearAllRequested", function SchedulingDashboardComponent_Case_9_Template_mj_filter_popover_ClearAllRequested_0_listener() { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.resetActivityFilters()); });
    i0.ɵɵelementStart(1, "mj-filter-panel", 18);
    i0.ɵɵlistener("ValuesChange", function SchedulingDashboardComponent_Case_9_Template_mj_filter_panel_ValuesChange_1_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.onActivityFilterValuesChange($event)); })("Reset", function SchedulingDashboardComponent_Case_9_Template_mj_filter_panel_Reset_1_listener() { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.resetActivityFilters()); });
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(2, "mj-refresh-button", 13);
    i0.ɵɵlistener("Clicked", function SchedulingDashboardComponent_Case_9_Template_mj_refresh_button_Clicked_2_listener() { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.activityCmp == null ? null : ctx_r0.activityCmp.Refresh()); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ActiveCount", ctx_r0.ActivityActiveFilterCount)("ShowClearAll", ctx_r0.ActivityActiveFilterCount > 0);
    i0.ɵɵadvance();
    i0.ɵɵproperty("Fields", ctx_r0.ActivityFilterFields)("Values", ctx_r0.ActivityFilterValues);
} }
function SchedulingDashboardComponent_Case_12_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-page-search", 21);
    i0.ɵɵlistener("ValueChange", function SchedulingDashboardComponent_Case_12_Template_mj_page_search_ValueChange_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.jobsCmp == null ? null : ctx_r0.jobsCmp.OnSearchChange($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("Value", (ctx_r0.jobsCmp == null ? null : ctx_r0.jobsCmp.SearchTerm) ?? "");
} }
function SchedulingDashboardComponent_Case_13_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-filter-chip", 24);
    i0.ɵɵlistener("Clicked", function SchedulingDashboardComponent_Case_13_For_2_Template_mj_filter_chip_Clicked_0_listener() { const range_r8 = i0.ɵɵrestoreView(_r7).$implicit; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.activityCmp == null ? null : ctx_r0.activityCmp.OnTimeRangeChange(range_r8.value)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const range_r8 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("Label", range_r8.label)("Active", (ctx_r0.activityCmp == null ? null : ctx_r0.activityCmp.SelectedTimeRange) === range_r8.value);
} }
function SchedulingDashboardComponent_Case_13_Template(rf, ctx) { if (rf & 1) {
    const _r6 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-page-search", 22);
    i0.ɵɵlistener("ValueChange", function SchedulingDashboardComponent_Case_13_Template_mj_page_search_ValueChange_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.activityCmp == null ? null : ctx_r0.activityCmp.OnSearchChange($event)); });
    i0.ɵɵelementEnd();
    i0.ɵɵrepeaterCreate(1, SchedulingDashboardComponent_Case_13_For_2_Template, 1, 2, "mj-filter-chip", 23, _forTrack0);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("Value", (ctx_r0.activityCmp == null ? null : ctx_r0.activityCmp.SearchTerm) ?? "");
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r0.activityCmp == null ? null : ctx_r0.activityCmp.TimeRanges);
} }
function SchedulingDashboardComponent_Case_15_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "app-scheduling-overview", 25, 0);
    i0.ɵɵlistener("stateChange", function SchedulingDashboardComponent_Case_15_Template_app_scheduling_overview_stateChange_0_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnDashboardStateChange($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("initialState", ctx_r0.DashboardState)("HideToolbar", true);
} }
function SchedulingDashboardComponent_Case_16_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "app-scheduling-jobs", 25, 1);
    i0.ɵɵlistener("stateChange", function SchedulingDashboardComponent_Case_16_Template_app_scheduling_jobs_stateChange_0_listener($event) { i0.ɵɵrestoreView(_r10); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnJobsStateChange($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("initialState", ctx_r0.JobsState)("HideToolbar", true);
} }
function SchedulingDashboardComponent_Case_17_Template(rf, ctx) { if (rf & 1) {
    const _r11 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "app-scheduling-activity", 25, 2);
    i0.ɵɵlistener("stateChange", function SchedulingDashboardComponent_Case_17_Template_app_scheduling_activity_stateChange_0_listener($event) { i0.ɵɵrestoreView(_r11); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.OnActivityStateChange($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("initialState", ctx_r0.ActivityState)("HideToolbar", true);
} }
let SchedulingDashboardComponent = class SchedulingDashboardComponent extends BaseDashboard {
    cdr;
    schedulingService;
    IsLoading = false;
    ActiveTab = 'dashboard';
    DashboardState = {};
    JobsState = {};
    ActivityState = {};
    visitedTabs = new Set();
    stateChangeSubject = new Subject();
    ActiveJobCount = 0;
    AlertCount = 0;
    /** Live snapshot of every scheduled job — used both for the agent context and the read-only GetJobDetails tool. */
    currentJobs = [];
    /** Live snapshot of the loaded executions (activity rows) — feeds the activity-tab context + select tool. */
    currentExecutions = [];
    /** Live snapshot of the job-type statistics — feeds the KPI slice job-type breakdown. */
    currentJobTypes = [];
    /** Count of jobs holding a lock (stale or live) — derived from lock info. */
    lockedJobCount = 0;
    /** Count of executions currently running — derived from live executions. */
    runningCount = 0;
    /**
     * The tab the agent tool-set was last registered for. Mode-scoping guard: the
     * tool surface differs per tab, so we only re-register on a tab transition
     * (mirrors the Data Explorer's / Testing dashboard's `lastRegisteredToolMode`).
     */
    lastRegisteredToolMode = null;
    /** ViewChild references to the active inner tab component — drive the toolbar UI rendered in <mj-page-header>. */
    overviewCmp;
    jobsCmp;
    activityCmp;
    kpiSub;
    alertSub;
    jobsSub;
    executionsSub;
    jobTypesSub;
    locksSub;
    get Tabs() {
        return [
            { key: 'dashboard', label: 'Dashboard', icon: 'fa-solid fa-gauge-high' },
            {
                key: 'jobs',
                label: 'Jobs',
                icon: 'fa-solid fa-calendar-check',
                badge: this.ActiveJobCount > 0 ? this.ActiveJobCount : null
            },
            { key: 'activity', label: 'Activity', icon: 'fa-solid fa-clock-rotate-left' }
        ];
    }
    constructor(cdr, schedulingService) {
        super();
        this.cdr = cdr;
        this.schedulingService = schedulingService;
        this.setupStateManagement();
    }
    async GetResourceDisplayName(data) {
        return 'Scheduling';
    }
    ngAfterViewInit() {
        this.visitedTabs.add(this.ActiveTab);
        this.loadSidebarCounts();
        // Publish the initial agent context and register the client tools the AI agent
        // can invoke against this surface. Context is re-emitted whenever the job list,
        // alert count, or active tab changes (see loadSidebarCounts / OnTabChange).
        this.publishAgentContext();
        this.syncAgentToolsForMode();
        this.cdr.detectChanges();
    }
    ngOnDestroy() {
        super.ngOnDestroy();
        this.stateChangeSubject.complete();
        if (this.kpiSub)
            this.kpiSub.unsubscribe();
        if (this.alertSub)
            this.alertSub.unsubscribe();
        if (this.jobsSub)
            this.jobsSub.unsubscribe();
        if (this.executionsSub)
            this.executionsSub.unsubscribe();
        if (this.jobTypesSub)
            this.jobTypesSub.unsubscribe();
        if (this.locksSub)
            this.locksSub.unsubscribe();
    }
    loadSidebarCounts() {
        this.kpiSub = this.schedulingService.kpis$.subscribe(kpis => {
            this.ActiveJobCount = kpis.totalActiveJobs;
            this.cdr.markForCheck();
        });
        this.alertSub = this.schedulingService.alerts$.subscribe(alerts => {
            this.AlertCount = alerts.length;
            this.publishAgentContext();
            this.cdr.markForCheck();
        });
        this.jobsSub = this.schedulingService.jobStatistics$.subscribe(jobs => {
            this.currentJobs = jobs;
            this.publishAgentContext();
            this.cdr.markForCheck();
        });
        this.executionsSub = this.schedulingService.executionHistory$.subscribe(execs => {
            this.currentExecutions = execs;
            this.runningCount = execs.filter(e => e.status === 'Running').length;
            this.publishAgentContext();
            this.cdr.markForCheck();
        });
        this.jobTypesSub = this.schedulingService.jobTypes$.subscribe(types => {
            this.currentJobTypes = types;
            this.publishAgentContext();
            this.cdr.markForCheck();
        });
        this.locksSub = this.schedulingService.lockInfo$.subscribe(locks => {
            this.lockedJobCount = locks.length;
            this.publishAgentContext();
            this.cdr.markForCheck();
        });
    }
    OnTabChange(tabId) {
        this.ActiveTab = tabId;
        this.visitedTabs.add(tabId);
        setTimeout(() => {
            SharedService.Instance.InvokeManualResize();
        }, 100);
        this.emitStateChange();
        this.publishAgentContext();
        this.syncAgentToolsForMode();
        this.cdr.markForCheck();
    }
    HasVisited(tabId) {
        return this.visitedTabs.has(tabId);
    }
    // ========================================================================
    // AI AGENT CONTEXT & CLIENT TOOLS — deep ("hardcore") / Data-Explorer depth
    //
    // 🔒 SAFETY BOUNDARY: the Scheduling surface exposes ONLY navigational /
    // filter / search / read-only / select tools to the agent. The following are
    // INTENTIONALLY NOT exposed because they mutate or destroy operational state:
    //   - updateJobStatus / ToggleJobStatus (pause / resume a job) — state mutation
    //   - ConfirmDelete / deleteJob — destructive
    //   - OpenCreateSlideout / saveJob (create a job) — state mutation
    //   - releaseLock — operational mutation
    // The agent finds / filters / inspects / selects / navigates; the user performs
    // every mutation from the UI. Context surfaces aggregate counts, active
    // filters/search, and visible display names only — never lock tokens or raw
    // job-configuration blobs.
    //
    // MODE-SCOPING (mirrors the Data Explorer's / Testing dashboard's
    // `syncAgentToolsForMode`): the active tab decides which deep context slice is
    // published AND which surface-scoped tools are registered. COMMON tools
    // (SwitchSchedulingTab / RefreshSchedulingData / GetJobDetails) are always
    // present; the Jobs-only filter/search/select tools and the Activity-only
    // filter/search/select tools swap on every tab flip, so a jobs-only tool is
    // never visible while Activity is open. `SetAgentClientTools` replaces the
    // registered set wholesale, so we only re-register on a tab transition (guarded
    // by {@link lastRegisteredToolMode}).
    // ========================================================================
    /**
     * Publish the current Scheduling state to the AI agent via NavigationService.
     * Always reports the KPI slice (per-status job counts, alerts, locked/running
     * counts, success rate, job-type breakdown); the ACTIVE tab adds its detailed
     * slice (Jobs: search/filters, visible names, selection; Activity: search/
     * filters, time range, visible executions, distinct job names). The shaping
     * lives in the pure {@link buildSchedulingAgentContext} helper so it stays
     * unit-testable. Called on init and on every meaningful state change.
     */
    publishAgentContext() {
        const input = {
            ActiveTab: this.ActiveTab,
            Jobs: this.currentJobs.map(j => this.toJobSnapshot(j)),
            AlertCount: this.AlertCount,
            LockedJobCount: this.lockedJobCount,
            RunningCount: this.runningCount,
            JobTypeBreakdown: this.currentJobTypes.map(t => ({
                TypeName: t.typeName,
                ActiveJobsCount: t.activeJobsCount,
                TotalRuns: t.totalRuns,
            })),
            JobsSearchTerm: this.jobsCmp?.SearchTerm ?? '',
            StatusFilter: this.jobsCmp?.StatusFilter ?? '',
            TypeFilter: this.jobsCmp?.TypeFilter ?? '',
            VisibleJobs: (this.jobsCmp?.FilteredJobs ?? []).map(j => this.toJobSnapshot(j)),
            SelectedJob: this.jobsCmp?.SelectedJob ? this.toJobSnapshot(this.jobsCmp.SelectedJob) : null,
            ActivitySearchTerm: this.activityCmp?.SearchTerm ?? '',
            ActivityStatusFilter: this.activityCmp?.StatusFilter ?? '',
            ActivityJobNameFilter: this.activityCmp?.JobNameFilter ?? '',
            ActivityTimeRange: this.activityCmp?.SelectedTimeRange ?? '7d',
            VisibleExecutions: (this.activityCmp?.FilteredExecutions ?? []).map(e => this.toExecutionSnapshot(e)),
            ActivityJobNames: this.activityCmp?.UniqueJobNames ?? [],
        };
        this.navigationService.SetAgentContext(this, buildSchedulingAgentContext(input));
    }
    /** Project a full job statistics row into the read-only snapshot shape. */
    toJobSnapshot(job) {
        return {
            JobId: job.jobId,
            JobName: job.jobName,
            JobType: job.jobType,
            Status: job.status,
            SuccessRate: job.successRate,
            TotalRuns: job.totalRuns,
            CronExpression: job.cronExpression,
            Timezone: job.timezone,
        };
    }
    /** Project an execution row into the read-only activity snapshot shape. */
    toExecutionSnapshot(exec) {
        return {
            ExecutionId: exec.id,
            JobId: exec.jobId,
            JobName: exec.jobName,
            Status: exec.status,
        };
    }
    /** Job candidates (id+name) for the name/id resolver in select/details tools. */
    get jobCandidates() {
        return this.currentJobs.map(j => ({ ID: j.jobId, Name: j.jobName }));
    }
    /**
     * Register the agent tool-set appropriate for the active tab. The tool surface
     * differs per tab; `SetAgentClientTools` replaces the registered set wholesale,
     * so we only re-register on a tab transition (guarded by
     * {@link lastRegisteredToolMode}). See the SAFETY BOUNDARY comment above.
     */
    syncAgentToolsForMode() {
        const tab = isValidSchedulingTab(this.ActiveTab) ? this.ActiveTab : 'dashboard';
        if (this.lastRegisteredToolMode === tab) {
            return;
        }
        this.lastRegisteredToolMode = tab;
        this.navigationService.SetAgentClientTools(this, this.buildToolsForMode(tab));
    }
    /** Compose the tool list for a given tab: common tools + per-tab tools. */
    buildToolsForMode(tab) {
        const tools = [...this.buildCommonTools()];
        switch (tab) {
            case 'jobs':
                tools.push(...this.buildJobsTools());
                break;
            case 'activity':
                tools.push(...this.buildActivityTools());
                break;
            case 'dashboard':
            default:
                // Dashboard (overview) tab: common navigation / refresh / read-only tools only.
                break;
        }
        return tools;
    }
    /** Tools available on EVERY tab: tab switch, refresh, read-only job details. */
    buildCommonTools() {
        return [
            {
                Name: 'SwitchSchedulingTab',
                Description: `Switch the active Scheduling tab. One of: ${SCHEDULING_TABS.join(', ')}.`,
                ParameterSchema: { type: 'object', properties: { tab: { type: 'string', enum: [...SCHEDULING_TABS] } }, required: ['tab'] },
                Handler: async (params) => this.toolSwitchTab(params),
            },
            {
                Name: 'RefreshSchedulingData',
                Description: 'Refresh the scheduling data (jobs, executions, KPIs, alerts) from the server.',
                ParameterSchema: { type: 'object', properties: {} },
                Handler: async () => {
                    this.schedulingService.refresh();
                    return { Success: true };
                },
            },
            {
                Name: 'GetJobDetails',
                Description: 'Get the read-only details of a single scheduled job by its ID or name (exact id, then exact name, then partial-name match).',
                ParameterSchema: { type: 'object', properties: { job: { type: 'string' } }, required: ['job'] },
                Handler: async (params) => this.toolGetJobDetails(params),
            },
        ];
    }
    /** Jobs-tab tools: status/type filter, search, select (open) a job, open its record. */
    buildJobsTools() {
        return [
            {
                Name: 'FilterJobsByStatus',
                Description: `Filter the jobs list by status. One of: ${SCHEDULING_JOB_STATUSES.filter(s => s).join(', ')}, or empty string to clear.`,
                ParameterSchema: { type: 'object', properties: { status: { type: 'string', enum: [...SCHEDULING_JOB_STATUSES] } }, required: ['status'] },
                Handler: async (params) => this.toolFilterJobsByStatus(params),
            },
            {
                Name: 'FilterJobsByType',
                Description: 'Filter the jobs list by job type (e.g. Action, Agent), or empty string to clear. Use GetSchedulingContext job-type names for valid values.',
                ParameterSchema: { type: 'object', properties: { type: { type: 'string' } }, required: ['type'] },
                Handler: async (params) => this.toolFilterJobsByType(params),
            },
            {
                Name: 'SearchJobs',
                Description: 'Search the jobs list by a free-text query (matches job name, type, and description).',
                ParameterSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
                Handler: async (params) => this.toolSearchJobs(params),
            },
            {
                Name: 'SelectJob',
                Description: 'Open a job in the read-only editor slideout by its id or name (exact id, then exact name, then partial-name). This opens the job for viewing; it does not save or mutate.',
                ParameterSchema: { type: 'object', properties: { job: { type: 'string' } }, required: ['job'] },
                Handler: async (params) => this.toolSelectJob(params),
            },
            {
                Name: 'OpenJobRecord',
                Description: 'Open the full entity record for a scheduled job (in a tab, for viewing) by its id or name.',
                ParameterSchema: { type: 'object', properties: { job: { type: 'string' } }, required: ['job'] },
                Handler: async (params) => this.toolOpenJobRecord(params),
            },
        ];
    }
    /** Activity-tab tools: execution-status filter, job-name filter, search, time range. */
    buildActivityTools() {
        return [
            {
                Name: 'FilterActivityByStatus',
                Description: 'Filter the activity (executions) list by status: Running, Completed, Failed, Cancelled, Timeout, or empty string to clear.',
                ParameterSchema: { type: 'object', properties: { status: { type: 'string' } }, required: ['status'] },
                Handler: async (params) => this.toolFilterActivityByStatus(params),
            },
            {
                Name: 'FilterActivityByJob',
                Description: 'Filter the activity list to a single job by its (exact) job name, or empty string to clear. Use the ActivityJobNames context for valid values.',
                ParameterSchema: { type: 'object', properties: { jobName: { type: 'string' } }, required: ['jobName'] },
                Handler: async (params) => this.toolFilterActivityByJob(params),
            },
            {
                Name: 'SearchActivity',
                Description: 'Search the activity list by a free-text query (matches job name and error message).',
                ParameterSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] },
                Handler: async (params) => this.toolSearchActivity(params),
            },
            {
                Name: 'SetActivityTimeRange',
                Description: 'Set the activity time range. One of: 24h, 7d, 30d, 90d.',
                ParameterSchema: { type: 'object', properties: { range: { type: 'string', enum: ['24h', '7d', '30d', '90d'] } }, required: ['range'] },
                Handler: async (params) => this.toolSetActivityTimeRange(params),
            },
        ];
    }
    // ───── Common tool handlers ─────
    /** Switch the active tab after validating the requested tab id. */
    toolSwitchTab(params) {
        const tab = params['tab'];
        if (!isValidSchedulingTab(tab)) {
            return { Success: false, ErrorMessage: `Invalid tab "${String(tab)}". Valid tabs: ${SCHEDULING_TABS.join(', ')}.` };
        }
        this.OnTabChange(tab);
        return { Success: true, Data: { ActiveTab: tab } };
    }
    /** Return the read-only details of a single job, resolved by id or name. */
    toolGetJobDetails(params) {
        const ref = typeof params['job'] === 'string' ? params['job'] : '';
        if (!ref) {
            return { Success: false, ErrorMessage: 'A job id or name is required.' };
        }
        const match = resolveSchedulingItem(ref, this.jobCandidates);
        if (!match) {
            return { Success: false, ErrorMessage: buildSchedulingNotFoundError(ref, this.jobCandidates) };
        }
        const job = this.currentJobs.find(j => UUIDsEqual(j.jobId, match.ID));
        if (!job) {
            return { Success: false, ErrorMessage: buildSchedulingNotFoundError(ref, this.jobCandidates) };
        }
        return { Success: true, Data: this.toJobSnapshot(job) };
    }
    // ───── Jobs-tab tool handlers ─────
    /** Ensure the jobs tab is active and its component is mounted; null on not-ready. */
    ensureJobsReady() {
        if (this.ActiveTab !== 'jobs') {
            this.OnTabChange('jobs');
        }
        if (!this.jobsCmp) {
            return { Success: false, ErrorMessage: 'The jobs view is not ready yet. Try again after switching to the jobs tab.' };
        }
        return null;
    }
    /** Apply a status filter on the jobs tab (switching to it first if needed). */
    toolFilterJobsByStatus(params) {
        const status = typeof params['status'] === 'string' ? params['status'] : '';
        if (!SCHEDULING_JOB_STATUSES.includes(status)) {
            return { Success: false, ErrorMessage: `Invalid status "${status}". Expected one of: ${SCHEDULING_JOB_STATUSES.filter(s => s).join(', ')} (or empty to clear).` };
        }
        const notReady = this.ensureJobsReady();
        if (notReady)
            return notReady;
        this.jobsCmp.OnStatusFilterChange(status);
        this.publishAgentContext();
        return { Success: true };
    }
    /** Apply a job-type filter on the jobs tab (switching to it first if needed). */
    toolFilterJobsByType(params) {
        const type = typeof params['type'] === 'string' ? params['type'] : '';
        const notReady = this.ensureJobsReady();
        if (notReady)
            return notReady;
        if (type && !this.jobsCmp.TypeOptions.includes(type)) {
            const valid = this.jobsCmp.TypeOptions.filter(t => t);
            return { Success: false, ErrorMessage: `Invalid type "${type}". Available types: ${valid.join(', ') || '(none loaded)'} (or empty to clear).` };
        }
        this.jobsCmp.OnTypeFilterChange(type);
        this.publishAgentContext();
        return { Success: true };
    }
    /** Apply a search query on the jobs tab (switching to it first if needed). */
    toolSearchJobs(params) {
        const query = typeof params['query'] === 'string' ? params['query'] : '';
        const notReady = this.ensureJobsReady();
        if (notReady)
            return notReady;
        this.jobsCmp.OnSearchChange(query);
        this.publishAgentContext();
        return { Success: true };
    }
    /** Open a job (read-only) in the editor slideout, resolved by id or name. */
    toolSelectJob(params) {
        const ref = typeof params['job'] === 'string' ? params['job'] : '';
        if (!ref) {
            return { Success: false, ErrorMessage: 'A job id or name is required.' };
        }
        const match = resolveSchedulingItem(ref, this.jobCandidates);
        if (!match) {
            return { Success: false, ErrorMessage: buildSchedulingNotFoundError(ref, this.jobCandidates) };
        }
        const job = this.currentJobs.find(j => UUIDsEqual(j.jobId, match.ID));
        if (!job) {
            return { Success: false, ErrorMessage: buildSchedulingNotFoundError(ref, this.jobCandidates) };
        }
        const notReady = this.ensureJobsReady();
        if (notReady)
            return notReady;
        this.jobsCmp.OpenEditSlideout(job);
        this.publishAgentContext();
        return { Success: true, Data: { SelectedJobId: job.jobId, SelectedJobName: job.jobName } };
    }
    /** Open the full entity record for a job (for viewing), resolved by id or name. */
    toolOpenJobRecord(params) {
        const ref = typeof params['job'] === 'string' ? params['job'] : '';
        if (!ref) {
            return { Success: false, ErrorMessage: 'A job id or name is required.' };
        }
        const match = resolveSchedulingItem(ref, this.jobCandidates);
        if (!match) {
            return { Success: false, ErrorMessage: buildSchedulingNotFoundError(ref, this.jobCandidates) };
        }
        const job = this.currentJobs.find(j => UUIDsEqual(j.jobId, match.ID));
        if (!job) {
            return { Success: false, ErrorMessage: buildSchedulingNotFoundError(ref, this.jobCandidates) };
        }
        const notReady = this.ensureJobsReady();
        if (notReady)
            return notReady;
        this.jobsCmp.OpenEntityRecord(job);
        return { Success: true, Data: { JobId: job.jobId, JobName: job.jobName } };
    }
    // ───── Activity-tab tool handlers ─────
    /** Ensure the activity tab is active and its component is mounted; null on not-ready. */
    ensureActivityReady() {
        if (this.ActiveTab !== 'activity') {
            this.OnTabChange('activity');
        }
        if (!this.activityCmp) {
            return { Success: false, ErrorMessage: 'The activity view is not ready yet. Try again after switching to the activity tab.' };
        }
        return null;
    }
    /** Apply an execution-status filter on the activity tab. */
    toolFilterActivityByStatus(params) {
        const status = typeof params['status'] === 'string' ? params['status'] : '';
        const allowed = ['', 'Running', 'Completed', 'Failed', 'Cancelled', 'Timeout'];
        if (!allowed.includes(status)) {
            return { Success: false, ErrorMessage: `Invalid status "${status}". Expected one of: ${allowed.filter(s => s).join(', ')} (or empty to clear).` };
        }
        const notReady = this.ensureActivityReady();
        if (notReady)
            return notReady;
        this.activityCmp.OnStatusFilterChange(status);
        this.publishAgentContext();
        return { Success: true };
    }
    /** Filter the activity list to a single job by exact job name. */
    toolFilterActivityByJob(params) {
        const jobName = typeof params['jobName'] === 'string' ? params['jobName'] : '';
        const notReady = this.ensureActivityReady();
        if (notReady)
            return notReady;
        if (jobName && !this.activityCmp.UniqueJobNames.includes(jobName)) {
            const names = this.activityCmp.UniqueJobNames.slice(0, 25);
            return { Success: false, ErrorMessage: `No activity for a job named "${jobName}". Available: ${names.join(', ') || '(none loaded)'} (or empty to clear).` };
        }
        this.activityCmp.OnJobNameFilterChange(jobName);
        this.publishAgentContext();
        return { Success: true };
    }
    /** Apply a search query on the activity tab. */
    toolSearchActivity(params) {
        const query = typeof params['query'] === 'string' ? params['query'] : '';
        const notReady = this.ensureActivityReady();
        if (notReady)
            return notReady;
        this.activityCmp.OnSearchChange(query);
        this.publishAgentContext();
        return { Success: true };
    }
    /** Set the activity time range (24h / 7d / 30d / 90d). */
    toolSetActivityTimeRange(params) {
        const range = typeof params['range'] === 'string' ? params['range'] : '';
        const allowed = ['24h', '7d', '30d', '90d'];
        if (!allowed.includes(range)) {
            return { Success: false, ErrorMessage: `Invalid range "${range}". Expected one of: ${allowed.join(', ')}.` };
        }
        const notReady = this.ensureActivityReady();
        if (notReady)
            return notReady;
        this.activityCmp.OnTimeRangeChange(range);
        this.publishAgentContext();
        return { Success: true };
    }
    // ───── Filter-popover plumbing for the [actions]/[toolbar] slots ─────
    get JobsFilterFields() {
        const statusOptions = (this.jobsCmp?.StatusOptions ?? ['']).map(s => ({
            text: s === '' ? 'All Statuses' : s,
            value: s
        }));
        const typeOptions = (this.jobsCmp?.TypeOptions ?? ['']).map(t => ({
            text: t === '' ? 'All Types' : t,
            value: t
        }));
        return [
            { key: 'statusFilter', type: 'dropdown', label: 'Status', icon: 'fa-solid fa-circle-info', placeholder: 'All Statuses', options: statusOptions },
            { key: 'typeFilter', type: 'dropdown', label: 'Type', icon: 'fa-solid fa-shapes', placeholder: 'All Types', options: typeOptions }
        ];
    }
    get JobsFilterValues() {
        return {
            statusFilter: this.jobsCmp?.StatusFilter ?? '',
            typeFilter: this.jobsCmp?.TypeFilter ?? ''
        };
    }
    get JobsActiveFilterCount() {
        let n = 0;
        if (this.jobsCmp?.StatusFilter)
            n++;
        if (this.jobsCmp?.TypeFilter)
            n++;
        return n;
    }
    onJobsFilterValuesChange(v) {
        if (!this.jobsCmp)
            return;
        const next = (v ?? {});
        if ((next.statusFilter ?? '') !== this.jobsCmp.StatusFilter)
            this.jobsCmp.OnStatusFilterChange(next.statusFilter ?? '');
        if ((next.typeFilter ?? '') !== this.jobsCmp.TypeFilter)
            this.jobsCmp.OnTypeFilterChange(next.typeFilter ?? '');
    }
    resetJobsFilters() {
        if (this.jobsCmp?.StatusFilter)
            this.jobsCmp.OnStatusFilterChange('');
        if (this.jobsCmp?.TypeFilter)
            this.jobsCmp.OnTypeFilterChange('');
    }
    get ActivityFilterFields() {
        const statusOptions = (this.activityCmp?.StatusOptions ?? ['']).map(s => ({
            text: s === '' ? 'All Statuses' : s,
            value: s
        }));
        const jobNames = this.activityCmp?.UniqueJobNames ?? [];
        const jobOptions = [{ text: 'All Jobs', value: '' }, ...jobNames.map(n => ({ text: n, value: n }))];
        return [
            { key: 'statusFilter', type: 'dropdown', label: 'Status', icon: 'fa-solid fa-circle-info', placeholder: 'All Statuses', options: statusOptions },
            { key: 'jobNameFilter', type: 'dropdown', label: 'Job', icon: 'fa-solid fa-tag', placeholder: 'All Jobs', filterable: true, options: jobOptions }
        ];
    }
    get ActivityFilterValues() {
        return {
            statusFilter: this.activityCmp?.StatusFilter ?? '',
            jobNameFilter: this.activityCmp?.JobNameFilter ?? ''
        };
    }
    get ActivityActiveFilterCount() {
        let n = 0;
        if (this.activityCmp?.StatusFilter)
            n++;
        if (this.activityCmp?.JobNameFilter)
            n++;
        return n;
    }
    onActivityFilterValuesChange(v) {
        if (!this.activityCmp)
            return;
        const next = (v ?? {});
        if ((next.statusFilter ?? '') !== this.activityCmp.StatusFilter)
            this.activityCmp.OnStatusFilterChange(next.statusFilter ?? '');
        if ((next.jobNameFilter ?? '') !== this.activityCmp.JobNameFilter)
            this.activityCmp.OnJobNameFilterChange(next.jobNameFilter ?? '');
    }
    resetActivityFilters() {
        if (this.activityCmp?.StatusFilter)
            this.activityCmp.OnStatusFilterChange('');
        if (this.activityCmp?.JobNameFilter)
            this.activityCmp.OnJobNameFilterChange('');
    }
    setupStateManagement() {
        this.stateChangeSubject.pipe(debounceTime(50), takeUntil(this.destroy$)).subscribe(state => {
            this.UserStateChanged.emit(state);
        });
    }
    emitStateChange() {
        this.stateChangeSubject.next({
            activeTab: this.ActiveTab,
            dashboardState: this.DashboardState,
            jobsState: this.JobsState,
            activityState: this.ActivityState
        });
    }
    OnDashboardStateChange(state) {
        this.DashboardState = state;
        this.emitStateChange();
    }
    OnJobsStateChange(state) {
        this.JobsState = state;
        this.emitStateChange();
    }
    OnActivityStateChange(state) {
        this.ActivityState = state;
        this.emitStateChange();
    }
    initDashboard() {
        this.schedulingService.Provider = this.ProviderToUse;
        this.IsLoading = false;
    }
    loadData() {
        if (this.Config?.userState) {
            const state = this.Config.userState;
            if (state.activeTab) {
                this.ActiveTab = state.activeTab;
                this.visitedTabs.add(state.activeTab);
            }
            if (state.dashboardState)
                this.DashboardState = state.dashboardState;
            if (state.jobsState)
                this.JobsState = state.jobsState;
            if (state.activityState)
                this.ActivityState = state.activityState;
            this.cdr.markForCheck();
        }
        this.NotifyLoadComplete();
    }
    static ɵfac = function SchedulingDashboardComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SchedulingDashboardComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i1.SchedulingInstrumentationService)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SchedulingDashboardComponent, selectors: [["mj-scheduling-dashboard"]], viewQuery: function SchedulingDashboardComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.overviewCmp = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.jobsCmp = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.activityCmp = _t.first);
        } }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 18, vars: 7, consts: [["overviewCmp", ""], ["jobsCmp", ""], ["activityCmp", ""], ["Title", "Scheduling", "Icon", "fa-solid fa-calendar-check", "Subtitle", "Background jobs, executions, and system health"], ["meta", ""], ["Icon", "fa-solid fa-triangle-exclamation", "Variant", "error", 3, "Count", "Label"], ["Icon", "fa-solid fa-circle-check", "Label", "Healthy", "Variant", "success"], ["Label", "jobs", 3, "Count", "Total"], ["actions", ""], ["toolbar", "", 1, "scheduling-toolbar"], [3, "TabChange", "Tabs", "ActiveKey"], ["Placeholder", "Search jobs...", 3, "Value"], [3, "initialState", "HideToolbar"], [3, "Clicked"], ["mjButton", "", "size", "sm", "title", "Toggle auto-refresh", 3, "click", "variant"], [1, "fa-solid", "fa-rotate"], [1, "action-btn-label"], [3, "ClearAllRequested", "ActiveCount", "ShowClearAll"], [3, "ValuesChange", "Reset", "Fields", "Values"], ["mjButton", "", "variant", "primary", "size", "sm", 3, "click"], [1, "fa-solid", "fa-plus"], ["Placeholder", "Search jobs...", 3, "ValueChange", "Value"], ["Placeholder", "Search executions...", 3, "ValueChange", "Value"], [3, "Label", "Active"], [3, "Clicked", "Label", "Active"], [3, "stateChange", "initialState", "HideToolbar"]], template: function SchedulingDashboardComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "mj-page-layout")(1, "mj-page-header", 3)(2, "div", 4);
            i0.ɵɵconditionalCreate(3, SchedulingDashboardComponent_Conditional_3_Template, 1, 2, "mj-stat-badge", 5)(4, SchedulingDashboardComponent_Conditional_4_Template, 1, 0, "mj-stat-badge", 6);
            i0.ɵɵconditionalCreate(5, SchedulingDashboardComponent_Conditional_5_Template, 1, 2, "mj-stat-badge", 7);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "div", 8);
            i0.ɵɵconditionalCreate(7, SchedulingDashboardComponent_Case_7_Template, 5, 2)(8, SchedulingDashboardComponent_Case_8_Template, 7, 4)(9, SchedulingDashboardComponent_Case_9_Template, 3, 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(10, "div", 9)(11, "mj-tab-nav", 10);
            i0.ɵɵlistener("TabChange", function SchedulingDashboardComponent_Template_mj_tab_nav_TabChange_11_listener($event) { return ctx.OnTabChange($event); });
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(12, SchedulingDashboardComponent_Case_12_Template, 1, 1, "mj-page-search", 11)(13, SchedulingDashboardComponent_Case_13_Template, 3, 1);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(14, "mj-page-body");
            i0.ɵɵconditionalCreate(15, SchedulingDashboardComponent_Case_15_Template, 2, 2, "app-scheduling-overview", 12)(16, SchedulingDashboardComponent_Case_16_Template, 2, 2, "app-scheduling-jobs", 12)(17, SchedulingDashboardComponent_Case_17_Template, 2, 2, "app-scheduling-activity", 12);
            i0.ɵɵelementEnd()();
        } if (rf & 2) {
            let tmp_2_0;
            let tmp_5_0;
            let tmp_6_0;
            i0.ɵɵadvance(3);
            i0.ɵɵconditional(ctx.AlertCount > 0 ? 3 : 4);
            i0.ɵɵadvance(2);
            i0.ɵɵconditional(ctx.ActiveTab === "jobs" ? 5 : -1);
            i0.ɵɵadvance(2);
            i0.ɵɵconditional((tmp_2_0 = ctx.ActiveTab) === "dashboard" ? 7 : tmp_2_0 === "jobs" ? 8 : tmp_2_0 === "activity" ? 9 : -1);
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("Tabs", ctx.Tabs)("ActiveKey", ctx.ActiveTab);
            i0.ɵɵadvance();
            i0.ɵɵconditional((tmp_5_0 = ctx.ActiveTab) === "jobs" ? 12 : tmp_5_0 === "activity" ? 13 : -1);
            i0.ɵɵadvance(3);
            i0.ɵɵconditional((tmp_6_0 = ctx.ActiveTab) === "dashboard" ? 15 : tmp_6_0 === "jobs" ? 16 : tmp_6_0 === "activity" ? 17 : -1);
        } }, dependencies: [i2.MJButtonDirective, i2.MJPageHeaderComponent, i2.MJPageLayoutComponent, i2.MJPageBodyComponent, i2.MJTabNavComponent, i2.MJPageSearchComponent, i2.MJFilterChipComponent, i2.MJFilterPopoverComponent, i2.MJFilterPanelComponent, i2.MJStatBadgeComponent, i2.MJRefreshButtonComponent, i3.SchedulingOverviewComponent, i4.SchedulingJobsComponent, i5.SchedulingActivityComponent], styles: ["\n\n.scheduling-toolbar[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    flex-wrap: wrap;\n}"], changeDetection: 0 });
};
SchedulingDashboardComponent = __decorate([
    RegisterClass(BaseDashboard, 'SchedulingDashboard')
], SchedulingDashboardComponent);
export { SchedulingDashboardComponent };
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SchedulingDashboardComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-scheduling-dashboard', changeDetection: ChangeDetectionStrategy.OnPush, template: "<mj-page-layout>\n  <mj-page-header\n    Title=\"Scheduling\"\n    Icon=\"fa-solid fa-calendar-check\"\n    Subtitle=\"Background jobs, executions, and system health\">\n    <div meta>\n      @if (AlertCount > 0) {\n        <mj-stat-badge\n          Icon=\"fa-solid fa-triangle-exclamation\"\n          [Count]=\"AlertCount\"\n          [Label]=\"AlertCount === 1 ? 'Alert' : 'Alerts'\"\n          Variant=\"error\">\n        </mj-stat-badge>\n      } @else {\n        <mj-stat-badge\n          Icon=\"fa-solid fa-circle-check\"\n          Label=\"Healthy\"\n          Variant=\"success\">\n        </mj-stat-badge>\n      }\n      @if (ActiveTab === 'jobs') {\n        <mj-stat-badge\n          [Count]=\"jobsCmp?.FilteredJobs?.length ?? 0\"\n          [Total]=\"jobsCmp?.Jobs?.length ?? 0\"\n          Label=\"jobs\">\n        </mj-stat-badge>\n      }\n    </div>\n    <div actions>\n      @switch (ActiveTab) {\n        @case ('dashboard') {\n          <mj-refresh-button (Clicked)=\"overviewCmp?.Refresh()\"></mj-refresh-button>\n          <button mjButton\n            [variant]=\"overviewCmp?.AutoRefreshEnabled ? 'primary' : 'secondary'\"\n            size=\"sm\"\n            (click)=\"overviewCmp?.ToggleAutoRefresh()\"\n            title=\"Toggle auto-refresh\">\n            <i class=\"fa-solid fa-rotate\"></i>\n            <span class=\"action-btn-label\">Auto: {{overviewCmp?.AutoRefreshEnabled ? 'ON' : 'OFF'}}</span>\n          </button>\n        }\n        @case ('jobs') {\n          <mj-filter-popover\n            [ActiveCount]=\"JobsActiveFilterCount\"\n            [ShowClearAll]=\"JobsActiveFilterCount > 0\"\n            (ClearAllRequested)=\"resetJobsFilters()\">\n            <mj-filter-panel\n              [Fields]=\"JobsFilterFields\"\n              [Values]=\"JobsFilterValues\"\n              (ValuesChange)=\"onJobsFilterValuesChange($event)\"\n              (Reset)=\"resetJobsFilters()\">\n            </mj-filter-panel>\n          </mj-filter-popover>\n          <mj-refresh-button (Clicked)=\"jobsCmp?.Refresh()\"></mj-refresh-button>\n          <button mjButton variant=\"primary\" size=\"sm\" (click)=\"jobsCmp?.OpenCreateSlideout()\">\n            <i class=\"fa-solid fa-plus\"></i> <span class=\"action-btn-label\">New Job</span>\n          </button>\n        }\n        @case ('activity') {\n          <mj-filter-popover\n            [ActiveCount]=\"ActivityActiveFilterCount\"\n            [ShowClearAll]=\"ActivityActiveFilterCount > 0\"\n            (ClearAllRequested)=\"resetActivityFilters()\">\n            <mj-filter-panel\n              [Fields]=\"ActivityFilterFields\"\n              [Values]=\"ActivityFilterValues\"\n              (ValuesChange)=\"onActivityFilterValuesChange($event)\"\n              (Reset)=\"resetActivityFilters()\">\n            </mj-filter-panel>\n          </mj-filter-popover>\n          <mj-refresh-button (Clicked)=\"activityCmp?.Refresh()\"></mj-refresh-button>\n        }\n      }\n    </div>\n\n    <div toolbar class=\"scheduling-toolbar\">\n      <mj-tab-nav\n        [Tabs]=\"Tabs\"\n        [ActiveKey]=\"ActiveTab\"\n        (TabChange)=\"OnTabChange($any($event))\">\n      </mj-tab-nav>\n      @switch (ActiveTab) {\n        @case ('jobs') {\n          <mj-page-search\n            Placeholder=\"Search jobs...\"\n            [Value]=\"jobsCmp?.SearchTerm ?? ''\"\n            (ValueChange)=\"jobsCmp?.OnSearchChange($event)\">\n          </mj-page-search>\n        }\n        @case ('activity') {\n          <mj-page-search\n            Placeholder=\"Search executions...\"\n            [Value]=\"activityCmp?.SearchTerm ?? ''\"\n            (ValueChange)=\"activityCmp?.OnSearchChange($event)\">\n          </mj-page-search>\n          @for (range of activityCmp?.TimeRanges; track range.value) {\n            <mj-filter-chip\n              [Label]=\"range.label\"\n              [Active]=\"activityCmp?.SelectedTimeRange === range.value\"\n              (Clicked)=\"activityCmp?.OnTimeRangeChange(range.value)\">\n            </mj-filter-chip>\n          }\n        }\n      }\n    </div>\n  </mj-page-header>\n\n  <mj-page-body>\n    @switch (ActiveTab) {\n      @case ('dashboard') {\n        <app-scheduling-overview\n          #overviewCmp\n          [initialState]=\"DashboardState\"\n          [HideToolbar]=\"true\"\n          (stateChange)=\"OnDashboardStateChange($event)\">\n        </app-scheduling-overview>\n      }\n      @case ('jobs') {\n        <app-scheduling-jobs\n          #jobsCmp\n          [initialState]=\"JobsState\"\n          [HideToolbar]=\"true\"\n          (stateChange)=\"OnJobsStateChange($event)\">\n        </app-scheduling-jobs>\n      }\n      @case ('activity') {\n        <app-scheduling-activity\n          #activityCmp\n          [initialState]=\"ActivityState\"\n          [HideToolbar]=\"true\"\n          (stateChange)=\"OnActivityStateChange($event)\">\n        </app-scheduling-activity>\n      }\n    }\n  </mj-page-body>\n</mj-page-layout>\n", styles: ["/* Per-tab toolbar rendered in the [toolbar] slot of <mj-page-header>. */\n.scheduling-toolbar {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    flex-wrap: wrap;\n}\n"] }]
    }], () => [{ type: i0.ChangeDetectorRef }, { type: i1.SchedulingInstrumentationService }], { overviewCmp: [{
            type: ViewChild,
            args: ['overviewCmp']
        }], jobsCmp: [{
            type: ViewChild,
            args: ['jobsCmp']
        }], activityCmp: [{
            type: ViewChild,
            args: ['activityCmp']
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SchedulingDashboardComponent, { className: "SchedulingDashboardComponent", filePath: "src/Scheduling/scheduling-dashboard.component.ts", lineNumber: 60 }); })();
//# sourceMappingURL=scheduling-dashboard.component.js.map