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 { NavigationEnd } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil, filter, debounceTime, combineLatestWith } from 'rxjs/operators';
import { CompositeKey, LogError, RunView } from '@memberjunction/core';
import { ActionEngineBase } from '@memberjunction/actions-base';
import { RegisterClass, UUIDsEqual } from '@memberjunction/global';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { ActionExplorerStateService } from '../../services/action-explorer-state.service';
import { ActionTreePanelComponent } from './action-tree-panel.component';
import * as i0 from "@angular/core";
import * as i1 from "../../services/action-explorer-state.service";
import * as i2 from "@memberjunction/ng-shared";
import * as i3 from "@angular/router";
import * as i4 from "@progress/kendo-angular-buttons";
import * as i5 from "@memberjunction/ng-actions";
import * as i6 from "@memberjunction/ng-shared-generic";
import * as i7 from "./action-tree-panel.component";
import * as i8 from "./action-toolbar.component";
import * as i9 from "./action-breadcrumb.component";
import * as i10 from "./action-card.component";
import * as i11 from "./action-list-item.component";
import * as i12 from "./new-category-panel.component";
import * as i13 from "./new-action-panel.component";
const _forTrack0 = ($index, $item) => $item.ID;
function ActionExplorerComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵelement(1, "mj-loading", 11);
    i0.ɵɵelementEnd();
} }
function ActionExplorerComponent_Conditional_7_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelement(0, "i", 12);
    i0.ɵɵelementStart(1, "h3");
    i0.ɵɵtext(2, "No actions match your filters");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "p");
    i0.ɵɵtext(4, "Try adjusting your search or filter criteria");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "button", 13);
    i0.ɵɵlistener("click", function ActionExplorerComponent_Conditional_7_Conditional_1_Template_button_click_5_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(2); ctx_r1.StateService.clearFilters(); return i0.ɵɵresetView(ctx_r1.StateService.setSelectedCategoryId("all")); });
    i0.ɵɵelement(6, "i", 14);
    i0.ɵɵtext(7, " Clear All Filters ");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("fillMode", "outline");
} }
function ActionExplorerComponent_Conditional_7_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelement(0, "i", 15);
    i0.ɵɵelementStart(1, "h3");
    i0.ɵɵtext(2, "No actions yet");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "p");
    i0.ɵɵtext(4, "Create your first action to get started");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "button", 16);
    i0.ɵɵlistener("click", function ActionExplorerComponent_Conditional_7_Conditional_2_Template_button_click_5_listener() { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.onNewAction()); });
    i0.ɵɵelement(6, "i", 17);
    i0.ɵɵtext(7, " Create Action ");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵadvance(5);
    i0.ɵɵproperty("fillMode", "solid")("themeColor", "primary");
} }
function ActionExplorerComponent_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵconditionalCreate(1, ActionExplorerComponent_Conditional_7_Conditional_1_Template, 8, 1)(2, ActionExplorerComponent_Conditional_7_Conditional_2_Template, 8, 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.StateService.hasActiveFilters() || ctx_r1.SelectedCategoryId !== "all" ? 1 : 2);
} }
function ActionExplorerComponent_Conditional_8_Conditional_0_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-action-card", 22);
    i0.ɵɵlistener("ActionClick", function ActionExplorerComponent_Conditional_8_Conditional_0_For_2_Template_mj_action_card_ActionClick_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionClick($event)); })("EditClick", function ActionExplorerComponent_Conditional_8_Conditional_0_For_2_Template_mj_action_card_EditClick_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionEdit($event)); })("RunClick", function ActionExplorerComponent_Conditional_8_Conditional_0_For_2_Template_mj_action_card_RunClick_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionRun($event)); })("CategoryClick", function ActionExplorerComponent_Conditional_8_Conditional_0_For_2_Template_mj_action_card_CategoryClick_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onCategoryClick($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const action_r5 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("Action", action_r5)("Categories", ctx_r1.CategoriesMap);
} }
function ActionExplorerComponent_Conditional_8_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵrepeaterCreate(1, ActionExplorerComponent_Conditional_8_Conditional_0_For_2_Template, 1, 2, "mj-action-card", 21, _forTrack0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.FilteredActions);
} }
function ActionExplorerComponent_Conditional_8_Conditional_1_For_17_Template(rf, ctx) { if (rf & 1) {
    const _r6 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-action-list-item", 33);
    i0.ɵɵlistener("ActionClick", function ActionExplorerComponent_Conditional_8_Conditional_1_For_17_Template_mj_action_list_item_ActionClick_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionClick($event)); })("EditClick", function ActionExplorerComponent_Conditional_8_Conditional_1_For_17_Template_mj_action_list_item_EditClick_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionEdit($event)); })("RunClick", function ActionExplorerComponent_Conditional_8_Conditional_1_For_17_Template_mj_action_list_item_RunClick_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionRun($event)); })("CategoryClick", function ActionExplorerComponent_Conditional_8_Conditional_1_For_17_Template_mj_action_list_item_CategoryClick_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onCategoryClick($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const action_r7 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("Action", action_r7)("Categories", ctx_r1.CategoriesMap)("IsCompact", false);
} }
function ActionExplorerComponent_Conditional_8_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 19)(1, "div", 23);
    i0.ɵɵelement(2, "div", 24);
    i0.ɵɵelementStart(3, "div", 25);
    i0.ɵɵtext(4, "Name");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 26);
    i0.ɵɵtext(6, "Category");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "div", 27);
    i0.ɵɵtext(8, "Status");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "div", 28);
    i0.ɵɵtext(10, "Type");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(11, "div", 29);
    i0.ɵɵtext(12, "Params");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(13, "div", 30);
    i0.ɵɵtext(14, "Updated");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(15, "div", 31);
    i0.ɵɵelementEnd();
    i0.ɵɵrepeaterCreate(16, ActionExplorerComponent_Conditional_8_Conditional_1_For_17_Template, 1, 3, "mj-action-list-item", 32, _forTrack0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(16);
    i0.ɵɵrepeater(ctx_r1.FilteredActions);
} }
function ActionExplorerComponent_Conditional_8_Conditional_2_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r8 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-action-list-item", 33);
    i0.ɵɵlistener("ActionClick", function ActionExplorerComponent_Conditional_8_Conditional_2_For_2_Template_mj_action_list_item_ActionClick_0_listener($event) { i0.ɵɵrestoreView(_r8); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionClick($event)); })("EditClick", function ActionExplorerComponent_Conditional_8_Conditional_2_For_2_Template_mj_action_list_item_EditClick_0_listener($event) { i0.ɵɵrestoreView(_r8); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionEdit($event)); })("RunClick", function ActionExplorerComponent_Conditional_8_Conditional_2_For_2_Template_mj_action_list_item_RunClick_0_listener($event) { i0.ɵɵrestoreView(_r8); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onActionRun($event)); })("CategoryClick", function ActionExplorerComponent_Conditional_8_Conditional_2_For_2_Template_mj_action_list_item_CategoryClick_0_listener($event) { i0.ɵɵrestoreView(_r8); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.onCategoryClick($event)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const action_r9 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("Action", action_r9)("Categories", ctx_r1.CategoriesMap)("IsCompact", true);
} }
function ActionExplorerComponent_Conditional_8_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 20);
    i0.ɵɵrepeaterCreate(1, ActionExplorerComponent_Conditional_8_Conditional_2_For_2_Template, 1, 3, "mj-action-list-item", 32, _forTrack0);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.FilteredActions);
} }
function ActionExplorerComponent_Conditional_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵconditionalCreate(0, ActionExplorerComponent_Conditional_8_Conditional_0_Template, 3, 0, "div", 18);
    i0.ɵɵconditionalCreate(1, ActionExplorerComponent_Conditional_8_Conditional_1_Template, 18, 0, "div", 19);
    i0.ɵɵconditionalCreate(2, ActionExplorerComponent_Conditional_8_Conditional_2_Template, 3, 0, "div", 20);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵconditional(ctx_r1.ViewMode === "card" ? 0 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.ViewMode === "list" ? 1 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.ViewMode === "compact" ? 2 : -1);
} }
function ActionExplorerComponent_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mj-action-test-harness-dialog", 34);
    i0.ɵɵlistener("Close", function ActionExplorerComponent_Conditional_11_Template_mj_action_test_harness_dialog_Close_0_listener() { i0.ɵɵrestoreView(_r10); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnRunDialogClose()); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵproperty("Action", ctx_r1.SelectedActionForRun)("ActionParams", ctx_r1.SelectedActionParams)("IsOpen", ctx_r1.IsRunDialogOpen);
} }
let ActionExplorerComponent = class ActionExplorerComponent extends BaseResourceComponent {
    StateService;
    navigationService;
    router;
    cdr;
    TreePanel;
    IsLoading = true;
    Actions = [];
    FilteredActions = [];
    Categories = [];
    CategoriesMap = new Map();
    ViewMode = 'card';
    SelectedCategoryId = 'all';
    NewCategoryParentId = null;
    // Run dialog state
    IsRunDialogOpen = false;
    SelectedActionForRun = null;
    SelectedActionParams = [];
    destroy$ = new Subject();
    lastNavigatedUrl = '';
    skipUrlUpdate = false;
    constructor(StateService, navigationService, router, cdr) {
        super();
        this.StateService = StateService;
        this.navigationService = navigationService;
        this.router = router;
        this.cdr = cdr;
    }
    ngOnInit() {
        this.subscribeToState();
        this.subscribeToRouterEvents();
        this.loadInitialState();
        this.loadData();
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    subscribeToState() {
        // Subscribe to view mode changes
        this.StateService.ViewMode$.pipe(takeUntil(this.destroy$)).subscribe(mode => {
            this.ViewMode = mode;
            this.cdr.markForCheck();
        });
        // Subscribe to selected category changes
        this.StateService.SelectedCategoryId$.pipe(takeUntil(this.destroy$)).subscribe(id => {
            this.SelectedCategoryId = id;
            this.applyFilters();
            this.updateUrl();
            this.cdr.markForCheck();
        });
        // Subscribe to filter and sort changes
        this.StateService.Filters$.pipe(combineLatestWith(this.StateService.SortConfig$), debounceTime(50), takeUntil(this.destroy$)).subscribe(() => {
            this.applyFilters();
            this.updateUrl();
            this.cdr.markForCheck();
        });
    }
    subscribeToRouterEvents() {
        this.router.events.pipe(filter((event) => event instanceof NavigationEnd), takeUntil(this.destroy$)).subscribe(event => {
            const currentUrl = event.urlAfterRedirects || event.url;
            if (currentUrl !== this.lastNavigatedUrl) {
                this.onExternalNavigation(currentUrl);
            }
        });
    }
    loadInitialState() {
        // Parse URL query params
        const url = this.router.url;
        const queryIndex = url.indexOf('?');
        if (queryIndex !== -1) {
            const queryString = url.substring(queryIndex + 1);
            const params = new URLSearchParams(queryString);
            this.skipUrlUpdate = true;
            this.StateService.parseQueryParams(params);
            this.skipUrlUpdate = false;
        }
        // Load saved state from UserInfoEngine
        this.StateService.loadSavedState();
    }
    async loadData() {
        try {
            this.IsLoading = true;
            this.cdr.markForCheck();
            // Initialize ActionEngineBase
            await ActionEngineBase.Instance.Config(false);
            // Get actions and categories from engine
            this.Actions = ActionEngineBase.Instance.Actions;
            this.Categories = ActionEngineBase.Instance.ActionCategories;
            // Build categories map
            this.CategoriesMap.clear();
            this.Categories.forEach(c => this.CategoriesMap.set(c.ID, c));
            // Build tree panel if available
            if (this.TreePanel) {
                this.TreePanel.Categories = this.Categories;
                this.TreePanel.Actions = this.Actions;
                this.TreePanel.buildCategoryTree();
            }
            // Apply filters
            this.applyFilters();
            // Expand path to selected category if needed
            if (this.SelectedCategoryId !== 'all' && this.SelectedCategoryId !== 'uncategorized') {
                const categoryParentMap = new Map();
                this.Categories.forEach(c => categoryParentMap.set(c.ID, c.ParentID || null));
                this.StateService.expandPathToCategory(this.SelectedCategoryId, categoryParentMap);
            }
        }
        catch (error) {
            LogError('Failed to load action explorer data', undefined, error);
        }
        finally {
            this.IsLoading = false;
            this.cdr.markForCheck();
            this.NotifyLoadComplete();
        }
    }
    applyFilters() {
        let filtered = [...this.Actions];
        const filters = this.StateService.Filters;
        const sortConfig = this.StateService.SortConfig;
        // Apply category filter
        if (this.SelectedCategoryId === 'uncategorized') {
            filtered = filtered.filter(a => !a.CategoryID);
        }
        else if (this.SelectedCategoryId !== 'all') {
            // Include descendants
            const descendants = this.getDescendantCategoryIds(this.SelectedCategoryId);
            filtered = filtered.filter(a => a.CategoryID && descendants.has(a.CategoryID));
        }
        // Apply search filter
        if (filters.searchTerm) {
            const term = filters.searchTerm.toLowerCase();
            filtered = filtered.filter(a => a.Name.toLowerCase().includes(term) ||
                (a.Description || '').toLowerCase().includes(term));
        }
        // Apply status filter
        if (filters.statuses.length > 0) {
            filtered = filtered.filter(a => filters.statuses.includes(a.Status));
        }
        // Apply type filter
        if (filters.types.length > 0) {
            filtered = filtered.filter(a => filters.types.includes(a.Type));
        }
        // Apply sorting
        filtered = this.sortActions(filtered, sortConfig);
        this.FilteredActions = filtered;
    }
    getDescendantCategoryIds(categoryId) {
        const descendants = new Set([categoryId]);
        const addDescendants = (parentId) => {
            this.Categories.forEach(c => {
                if (UUIDsEqual(c.ParentID, parentId) && !descendants.has(c.ID)) {
                    descendants.add(c.ID);
                    addDescendants(c.ID);
                }
            });
        };
        addDescendants(categoryId);
        return descendants;
    }
    sortActions(actions, config) {
        const sorted = [...actions];
        const direction = config.direction === 'asc' ? 1 : -1;
        sorted.sort((a, b) => {
            let comparison = 0;
            switch (config.field) {
                case 'name':
                    comparison = a.Name.localeCompare(b.Name);
                    break;
                case 'updated':
                    const dateA = a.__mj_UpdatedAt ? new Date(a.__mj_UpdatedAt).getTime() : 0;
                    const dateB = b.__mj_UpdatedAt ? new Date(b.__mj_UpdatedAt).getTime() : 0;
                    comparison = dateA - dateB;
                    break;
                case 'status':
                    comparison = (a.Status || '').localeCompare(b.Status || '');
                    break;
                case 'type':
                    comparison = (a.Type || '').localeCompare(b.Type || '');
                    break;
                case 'category':
                    const catA = this.CategoriesMap.get(a.CategoryID || '')?.Name || '';
                    const catB = this.CategoriesMap.get(b.CategoryID || '')?.Name || '';
                    comparison = catA.localeCompare(catB);
                    break;
            }
            return comparison * direction;
        });
        return sorted;
    }
    updateUrl() {
        if (this.skipUrlUpdate)
            return;
        const queryParams = this.StateService.buildQueryParams();
        this.navigationService.UpdateActiveTabQueryParams(queryParams);
        this.lastNavigatedUrl = this.router.url;
    }
    onExternalNavigation(url) {
        const queryIndex = url.indexOf('?');
        if (queryIndex !== -1) {
            const queryString = url.substring(queryIndex + 1);
            const params = new URLSearchParams(queryString);
            this.skipUrlUpdate = true;
            this.StateService.parseQueryParams(params);
            this.skipUrlUpdate = false;
            this.applyFilters();
            this.cdr.markForCheck();
        }
    }
    async onRefresh() {
        await ActionEngineBase.Instance.Config(true); // Force refresh
        await this.loadData();
    }
    onCategorySelect(categoryId) {
        this.StateService.setSelectedCategoryId(categoryId);
    }
    onNewCategory(parentId) {
        this.NewCategoryParentId = parentId;
        this.StateService.openNewCategoryPanel();
    }
    onEditCategory(category) {
        const key = new CompositeKey([{ FieldName: 'ID', Value: category.ID }]);
        this.navigationService.OpenEntityRecord('MJ: Action Categories', key);
    }
    onNewAction() {
        this.StateService.openNewActionPanel();
    }
    onActionClick(action) {
        const key = new CompositeKey([{ FieldName: 'ID', Value: action.ID }]);
        this.navigationService.OpenEntityRecord('MJ: Actions', key);
    }
    onActionEdit(action) {
        this.onActionClick(action);
    }
    async onActionRun(action) {
        if (action.Status !== 'Active') {
            return; // Can't run inactive actions
        }
        try {
            // Load action params
            const rv = new RunView();
            const result = await rv.RunView({
                EntityName: 'MJ: Action Params',
                ExtraFilter: `ActionID='${action.ID}'`,
                OrderBy: 'Name',
                ResultType: 'entity_object'
            });
            this.SelectedActionParams = result.Success ? result.Results || [] : [];
            // MJActionEntityExtended extends MJActionEntity, so this cast is safe
            this.SelectedActionForRun = action;
            this.IsRunDialogOpen = true;
            this.cdr.markForCheck();
        }
        catch (error) {
            LogError('Failed to open action run dialog', undefined, error);
        }
    }
    OnRunDialogClose() {
        this.IsRunDialogOpen = false;
        this.SelectedActionForRun = null;
        this.SelectedActionParams = [];
        this.cdr.markForCheck();
    }
    onCategoryClick(categoryId) {
        this.StateService.setSelectedCategoryId(categoryId);
    }
    async onCategoryCreated(category) {
        // Refresh data to include new category
        await this.loadData();
        // Select the new category
        this.StateService.setSelectedCategoryId(category.ID);
    }
    async onActionCreated() {
        // Refresh data to include new action
        await this.loadData();
    }
    async GetResourceDisplayName(data) {
        return 'Action Explorer';
    }
    async GetResourceIconClass(data) {
        return 'fa-solid fa-folder-tree';
    }
    static ɵfac = function ActionExplorerComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ActionExplorerComponent)(i0.ɵɵdirectiveInject(i1.ActionExplorerStateService), i0.ɵɵdirectiveInject(i2.NavigationService), i0.ɵɵdirectiveInject(i3.Router), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ActionExplorerComponent, selectors: [["mj-action-explorer"]], viewQuery: function ActionExplorerComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(ActionTreePanelComponent, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.TreePanel = _t.first);
        } }, standalone: false, features: [i0.ɵɵProvidersFeature([ActionExplorerStateService]), i0.ɵɵInheritDefinitionFeature], decls: 12, vars: 12, consts: [[1, "action-explorer"], [1, "loading-overlay"], [3, "CategorySelected", "NewCategoryClick", "EditCategoryClick", "Categories", "Actions"], [1, "explorer-main"], [3, "NewActionClick", "RefreshClick", "TotalCount", "FilteredCount"], [3, "CategorySelect", "SelectedCategoryId", "Categories"], [1, "explorer-content"], [1, "empty-state"], [3, "CategoryCreated", "Close", "Categories", "PreselectedParentId"], [3, "ActionCreated", "Categories"], [3, "Action", "ActionParams", "IsOpen"], ["text", "Loading actions...", "size", "medium"], [1, "fa-solid", "fa-filter-circle-xmark"], ["kendoButton", "", 3, "click", "fillMode"], [1, "fa-solid", "fa-times"], [1, "fa-solid", "fa-bolt"], ["kendoButton", "", 3, "click", "fillMode", "themeColor"], [1, "fa-solid", "fa-plus"], [1, "card-grid"], [1, "list-view"], [1, "compact-view"], [3, "Action", "Categories"], [3, "ActionClick", "EditClick", "RunClick", "CategoryClick", "Action", "Categories"], [1, "list-header"], [1, "header-icon"], [1, "header-name"], [1, "header-category"], [1, "header-status"], [1, "header-type"], [1, "header-params"], [1, "header-updated"], [1, "header-actions"], [3, "Action", "Categories", "IsCompact"], [3, "ActionClick", "EditClick", "RunClick", "CategoryClick", "Action", "Categories", "IsCompact"], [3, "Close", "Action", "ActionParams", "IsOpen"]], template: function ActionExplorerComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵconditionalCreate(1, ActionExplorerComponent_Conditional_1_Template, 2, 0, "div", 1);
            i0.ɵɵelementStart(2, "mj-action-tree-panel", 2);
            i0.ɵɵlistener("CategorySelected", function ActionExplorerComponent_Template_mj_action_tree_panel_CategorySelected_2_listener($event) { return ctx.onCategorySelect($event); })("NewCategoryClick", function ActionExplorerComponent_Template_mj_action_tree_panel_NewCategoryClick_2_listener($event) { return ctx.onNewCategory($event); })("EditCategoryClick", function ActionExplorerComponent_Template_mj_action_tree_panel_EditCategoryClick_2_listener($event) { return ctx.onEditCategory($event); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(3, "div", 3)(4, "mj-action-toolbar", 4);
            i0.ɵɵlistener("NewActionClick", function ActionExplorerComponent_Template_mj_action_toolbar_NewActionClick_4_listener() { return ctx.onNewAction(); })("RefreshClick", function ActionExplorerComponent_Template_mj_action_toolbar_RefreshClick_4_listener() { return ctx.onRefresh(); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(5, "mj-action-breadcrumb", 5);
            i0.ɵɵlistener("CategorySelect", function ActionExplorerComponent_Template_mj_action_breadcrumb_CategorySelect_5_listener($event) { return ctx.onCategorySelect($event); });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(6, "div", 6);
            i0.ɵɵconditionalCreate(7, ActionExplorerComponent_Conditional_7_Template, 3, 1, "div", 7)(8, ActionExplorerComponent_Conditional_8_Template, 3, 3);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(9, "mj-new-category-panel", 8);
            i0.ɵɵlistener("CategoryCreated", function ActionExplorerComponent_Template_mj_new_category_panel_CategoryCreated_9_listener($event) { return ctx.onCategoryCreated($event); })("Close", function ActionExplorerComponent_Template_mj_new_category_panel_Close_9_listener() { return ctx.NewCategoryParentId = null; });
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(10, "mj-new-action-panel", 9);
            i0.ɵɵlistener("ActionCreated", function ActionExplorerComponent_Template_mj_new_action_panel_ActionCreated_10_listener() { return ctx.onActionCreated(); });
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(11, ActionExplorerComponent_Conditional_11_Template, 1, 3, "mj-action-test-harness-dialog", 10);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.IsLoading ? 1 : -1);
            i0.ɵɵadvance();
            i0.ɵɵproperty("Categories", ctx.Categories)("Actions", ctx.Actions);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("TotalCount", ctx.Actions.length)("FilteredCount", ctx.FilteredActions.length);
            i0.ɵɵadvance();
            i0.ɵɵproperty("SelectedCategoryId", ctx.SelectedCategoryId)("Categories", ctx.Categories);
            i0.ɵɵadvance(2);
            i0.ɵɵconditional(ctx.FilteredActions.length === 0 && !ctx.IsLoading ? 7 : 8);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("Categories", ctx.Categories)("PreselectedParentId", ctx.NewCategoryParentId);
            i0.ɵɵadvance();
            i0.ɵɵproperty("Categories", ctx.Categories);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.SelectedActionForRun ? 11 : -1);
        } }, dependencies: [i4.ButtonComponent, i5.ActionTestHarnessDialogComponent, i6.LoadingComponent, i7.ActionTreePanelComponent, i8.ActionToolbarComponent, i9.ActionBreadcrumbComponent, i10.ActionCardComponent, i11.ActionListItemComponent, i12.NewCategoryPanelComponent, i13.NewActionPanelComponent], styles: [".action-explorer[_ngcontent-%COMP%] {\n  display: flex;\n  height: 100%;\n  background: var(--mj-bg-page);\n  overflow: hidden;\n  position: relative;\n}\n\n\n\n.explorer-main[_ngcontent-%COMP%] {\n  flex: 1;\n  display: flex;\n  flex-direction: column;\n  min-width: 0;\n  overflow: hidden;\n}\n\n.explorer-content[_ngcontent-%COMP%] {\n  flex: 1;\n  overflow-y: auto;\n  padding: 20px;\n}\n\n\n\n.loading-overlay[_ngcontent-%COMP%] {\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  background: color-mix(in srgb, var(--mj-bg-surface) 85%, transparent);\n  z-index: 100;\n  backdrop-filter: blur(2px);\n}\n\n\n\n.loading-container[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  height: 100%;\n  min-height: 300px;\n}\n\n\n\n.empty-state[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  text-align: center;\n  padding: 60px 20px;\n  color: var(--mj-text-muted);\n}\n\n.empty-state[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 48px;\n  margin-bottom: 20px;\n  opacity: 0.5;\n}\n\n.empty-state[_ngcontent-%COMP%]   h3[_ngcontent-%COMP%] {\n  margin: 0 0 8px 0;\n  font-size: 18px;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.empty-state[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] {\n  margin: 0 0 20px 0;\n  font-size: 14px;\n}\n\n.empty-state[_ngcontent-%COMP%]   button[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n}\n\n\n\n.card-grid[_ngcontent-%COMP%] {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));\n  gap: 20px;\n}\n\n\n\n.list-view[_ngcontent-%COMP%] {\n  background: var(--mj-bg-surface-card);\n  border: 1px solid var(--mj-border-default);\n  border-radius: 8px;\n  overflow: hidden;\n}\n\n.list-header[_ngcontent-%COMP%] {\n  display: grid;\n  grid-template-columns: 40px 1fr 140px 90px 70px 50px 90px 70px;\n  gap: 12px;\n  padding: 12px 16px;\n  background: var(--mj-bg-page);\n  border-bottom: 1px solid var(--mj-border-default);\n  font-size: 11px;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  color: var(--mj-text-muted);\n}\n\n.header-icon[_ngcontent-%COMP%] {\n  \n\n}\n\n\n\n.compact-view[_ngcontent-%COMP%] {\n  background: var(--mj-bg-surface-card);\n  border: 1px solid var(--mj-border-default);\n  border-radius: 8px;\n  overflow: hidden;\n}\n\n\n\n@media (max-width: 1200px) {\n  .card-grid[_ngcontent-%COMP%] {\n    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n  }\n}\n\n@media (max-width: 1024px) {\n  .list-header[_ngcontent-%COMP%] {\n    grid-template-columns: 36px 1fr 90px 50px 80px 60px;\n  }\n\n  .list-header[_ngcontent-%COMP%]   .header-category[_ngcontent-%COMP%], \n   .list-header[_ngcontent-%COMP%]   .header-params[_ngcontent-%COMP%] {\n    display: none;\n  }\n}\n\n@media (max-width: 768px) {\n  .explorer-content[_ngcontent-%COMP%] {\n    padding: 12px;\n  }\n\n  .card-grid[_ngcontent-%COMP%] {\n    grid-template-columns: 1fr;\n    gap: 12px;\n  }\n\n  .list-header[_ngcontent-%COMP%] {\n    display: none;\n  }\n}\n\n\n\n.explorer-content[_ngcontent-%COMP%]::-webkit-scrollbar {\n  width: 8px;\n}\n\n.explorer-content[_ngcontent-%COMP%]::-webkit-scrollbar-track {\n  background: transparent;\n}\n\n.explorer-content[_ngcontent-%COMP%]::-webkit-scrollbar-thumb {\n  background: var(--mj-border-default);\n  border-radius: 4px;\n}\n\n.explorer-content[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover {\n  background: var(--mj-text-muted);\n}"], changeDetection: 0 });
};
ActionExplorerComponent = __decorate([
    RegisterClass(BaseResourceComponent, 'ActionExplorerResource')
], ActionExplorerComponent);
export { ActionExplorerComponent };
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ActionExplorerComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-action-explorer', changeDetection: ChangeDetectionStrategy.OnPush, providers: [ActionExplorerStateService], template: "<div class=\"action-explorer\">\n  <!-- Full-page Loading Overlay -->\n  @if (IsLoading) {\n    <div class=\"loading-overlay\">\n      <mj-loading text=\"Loading actions...\" size=\"medium\"></mj-loading>\n    </div>\n  }\n\n  <!-- Tree Panel (Left Sidebar) -->\n  <mj-action-tree-panel\n    [Categories]=\"Categories\"\n    [Actions]=\"Actions\"\n    (CategorySelected)=\"onCategorySelect($event)\"\n    (NewCategoryClick)=\"onNewCategory($event)\"\n    (EditCategoryClick)=\"onEditCategory($event)\">\n  </mj-action-tree-panel>\n\n  <!-- Main Content Area -->\n  <div class=\"explorer-main\">\n    <!-- Toolbar -->\n    <mj-action-toolbar\n      [TotalCount]=\"Actions.length\"\n      [FilteredCount]=\"FilteredActions.length\"\n      (NewActionClick)=\"onNewAction()\"\n      (RefreshClick)=\"onRefresh()\">\n    </mj-action-toolbar>\n\n    <!-- Breadcrumb -->\n    <mj-action-breadcrumb\n      [SelectedCategoryId]=\"SelectedCategoryId\"\n      [Categories]=\"Categories\"\n      (CategorySelect)=\"onCategorySelect($event)\">\n    </mj-action-breadcrumb>\n\n    <!-- Content Area -->\n    <div class=\"explorer-content\">\n      @if (FilteredActions.length === 0 && !IsLoading) {\n        <div class=\"empty-state\">\n          @if (StateService.hasActiveFilters() || SelectedCategoryId !== 'all') {\n            <i class=\"fa-solid fa-filter-circle-xmark\"></i>\n            <h3>No actions match your filters</h3>\n            <p>Try adjusting your search or filter criteria</p>\n            <button kendoButton\n              [fillMode]=\"'outline'\"\n              (click)=\"StateService.clearFilters(); StateService.setSelectedCategoryId('all')\">\n              <i class=\"fa-solid fa-times\"></i>\n              Clear All Filters\n            </button>\n          } @else {\n            <i class=\"fa-solid fa-bolt\"></i>\n            <h3>No actions yet</h3>\n            <p>Create your first action to get started</p>\n            <button kendoButton\n              [fillMode]=\"'solid'\"\n              [themeColor]=\"'primary'\"\n              (click)=\"onNewAction()\">\n              <i class=\"fa-solid fa-plus\"></i>\n              Create Action\n            </button>\n          }\n        </div>\n      } @else {\n        <!-- Card View -->\n        @if (ViewMode === 'card') {\n          <div class=\"card-grid\">\n            @for (action of FilteredActions; track action.ID) {\n              <mj-action-card\n                [Action]=\"action\"\n                [Categories]=\"CategoriesMap\"\n                (ActionClick)=\"onActionClick($event)\"\n                (EditClick)=\"onActionEdit($event)\"\n                (RunClick)=\"onActionRun($event)\"\n                (CategoryClick)=\"onCategoryClick($event)\">\n              </mj-action-card>\n            }\n          </div>\n        }\n\n        <!-- List View -->\n        @if (ViewMode === 'list') {\n          <div class=\"list-view\">\n            <div class=\"list-header\">\n              <div class=\"header-icon\"></div>\n              <div class=\"header-name\">Name</div>\n              <div class=\"header-category\">Category</div>\n              <div class=\"header-status\">Status</div>\n              <div class=\"header-type\">Type</div>\n              <div class=\"header-params\">Params</div>\n              <div class=\"header-updated\">Updated</div>\n              <div class=\"header-actions\"></div>\n            </div>\n            @for (action of FilteredActions; track action.ID) {\n              <mj-action-list-item\n                [Action]=\"action\"\n                [Categories]=\"CategoriesMap\"\n                [IsCompact]=\"false\"\n                (ActionClick)=\"onActionClick($event)\"\n                (EditClick)=\"onActionEdit($event)\"\n                (RunClick)=\"onActionRun($event)\"\n                (CategoryClick)=\"onCategoryClick($event)\">\n              </mj-action-list-item>\n            }\n          </div>\n        }\n\n        <!-- Compact View -->\n        @if (ViewMode === 'compact') {\n          <div class=\"compact-view\">\n            @for (action of FilteredActions; track action.ID) {\n              <mj-action-list-item\n                [Action]=\"action\"\n                [Categories]=\"CategoriesMap\"\n                [IsCompact]=\"true\"\n                (ActionClick)=\"onActionClick($event)\"\n                (EditClick)=\"onActionEdit($event)\"\n                (RunClick)=\"onActionRun($event)\"\n                (CategoryClick)=\"onCategoryClick($event)\">\n              </mj-action-list-item>\n            }\n          </div>\n        }\n      }\n    </div>\n  </div>\n\n  <!-- Slide-in Panels -->\n  <mj-new-category-panel\n    [Categories]=\"Categories\"\n    [PreselectedParentId]=\"NewCategoryParentId\"\n    (CategoryCreated)=\"onCategoryCreated($event)\"\n    (Close)=\"NewCategoryParentId = null\">\n  </mj-new-category-panel>\n\n  <mj-new-action-panel\n    [Categories]=\"Categories\"\n    (ActionCreated)=\"onActionCreated()\">\n  </mj-new-action-panel>\n\n  <!-- Action Run Dialog -->\n  @if (SelectedActionForRun) {\n    <mj-action-test-harness-dialog\n      [Action]=\"SelectedActionForRun\"\n      [ActionParams]=\"SelectedActionParams\"\n      [IsOpen]=\"IsRunDialogOpen\"\n      (Close)=\"OnRunDialogClose()\">\n    </mj-action-test-harness-dialog>\n  }\n</div>\n", styles: [".action-explorer {\n  display: flex;\n  height: 100%;\n  background: var(--mj-bg-page);\n  overflow: hidden;\n  position: relative;\n}\n\n/* Main Content Area */\n.explorer-main {\n  flex: 1;\n  display: flex;\n  flex-direction: column;\n  min-width: 0;\n  overflow: hidden;\n}\n\n.explorer-content {\n  flex: 1;\n  overflow-y: auto;\n  padding: 20px;\n}\n\n/* Full-page Loading Overlay */\n.loading-overlay {\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  background: color-mix(in srgb, var(--mj-bg-surface) 85%, transparent);\n  z-index: 100;\n  backdrop-filter: blur(2px);\n}\n\n/* Legacy loading container (kept for backwards compatibility) */\n.loading-container {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  height: 100%;\n  min-height: 300px;\n}\n\n/* Empty State */\n.empty-state {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  text-align: center;\n  padding: 60px 20px;\n  color: var(--mj-text-muted);\n}\n\n.empty-state i {\n  font-size: 48px;\n  margin-bottom: 20px;\n  opacity: 0.5;\n}\n\n.empty-state h3 {\n  margin: 0 0 8px 0;\n  font-size: 18px;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.empty-state p {\n  margin: 0 0 20px 0;\n  font-size: 14px;\n}\n\n.empty-state button {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n}\n\n/* Card Grid */\n.card-grid {\n  display: grid;\n  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));\n  gap: 20px;\n}\n\n/* List View */\n.list-view {\n  background: var(--mj-bg-surface-card);\n  border: 1px solid var(--mj-border-default);\n  border-radius: 8px;\n  overflow: hidden;\n}\n\n.list-header {\n  display: grid;\n  grid-template-columns: 40px 1fr 140px 90px 70px 50px 90px 70px;\n  gap: 12px;\n  padding: 12px 16px;\n  background: var(--mj-bg-page);\n  border-bottom: 1px solid var(--mj-border-default);\n  font-size: 11px;\n  font-weight: 600;\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n  color: var(--mj-text-muted);\n}\n\n.header-icon {\n  /* Empty column for icon */\n}\n\n/* Compact View */\n.compact-view {\n  background: var(--mj-bg-surface-card);\n  border: 1px solid var(--mj-border-default);\n  border-radius: 8px;\n  overflow: hidden;\n}\n\n/* Responsive */\n@media (max-width: 1200px) {\n  .card-grid {\n    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n  }\n}\n\n@media (max-width: 1024px) {\n  .list-header {\n    grid-template-columns: 36px 1fr 90px 50px 80px 60px;\n  }\n\n  .list-header .header-category,\n  .list-header .header-params {\n    display: none;\n  }\n}\n\n@media (max-width: 768px) {\n  .explorer-content {\n    padding: 12px;\n  }\n\n  .card-grid {\n    grid-template-columns: 1fr;\n    gap: 12px;\n  }\n\n  .list-header {\n    display: none;\n  }\n}\n\n/* Scrollbar Styling */\n.explorer-content::-webkit-scrollbar {\n  width: 8px;\n}\n\n.explorer-content::-webkit-scrollbar-track {\n  background: transparent;\n}\n\n.explorer-content::-webkit-scrollbar-thumb {\n  background: var(--mj-border-default);\n  border-radius: 4px;\n}\n\n.explorer-content::-webkit-scrollbar-thumb:hover {\n  background: var(--mj-text-muted);\n}\n"] }]
    }], () => [{ type: i1.ActionExplorerStateService }, { type: i2.NavigationService }, { type: i3.Router }, { type: i0.ChangeDetectorRef }], { TreePanel: [{
            type: ViewChild,
            args: [ActionTreePanelComponent]
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ActionExplorerComponent, { className: "ActionExplorerComponent", filePath: "src/Actions/components/explorer/action-explorer.component.ts", lineNumber: 33 }); })();
//# sourceMappingURL=action-explorer.component.js.map