import { Component } from '@angular/core';
import { Validators } from '@angular/forms';
import { Subject, BehaviorSubject, takeUntil } from 'rxjs';
import { RunView } from '@memberjunction/core';
import { MJNotificationService } from '@memberjunction/ng-notifications';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-dialog";
import * as i2 from "@angular/forms";
import * as i3 from "@progress/kendo-angular-inputs";
import * as i4 from "@progress/kendo-angular-dropdowns";
import * as i5 from "@progress/kendo-angular-buttons";
import * as i6 from "@angular/common";
const _c0 = () => ({ Name: "Default Type", ID: null });
function SubAgentAdvancedSettingsDialogComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 6);
    i0.ɵɵelement(2, "i", 7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "p");
    i0.ɵɵtext(4, "Loading sub-agent settings...");
    i0.ɵɵelementEnd()();
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.getFieldError("executionOrder"));
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.executionOrderError);
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_ng_template_18_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 31)(1, "div", 32);
    i0.ɵɵelement(2, "i");
    i0.ɵɵelementStart(3, "span", 33);
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(5, "div", 34);
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const dataItem_r2 = ctx.$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵclassMapInterpolate1("fa-solid ", dataItem_r2.icon, "");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(dataItem_r2.text);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(dataItem_r2.description);
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_19_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.getFieldError("executionMode"));
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_38_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r0.getFieldError("status"));
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "form", 2)(1, "div", 8)(2, "h3", 9);
    i0.ɵɵelement(3, "i", 10);
    i0.ɵɵtext(4, " Execution Configuration ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "div", 11)(6, "div", 12)(7, "label", 13);
    i0.ɵɵtext(8, "Execution Order *");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(9, "kendo-numerictextbox", 14);
    i0.ɵɵtemplate(10, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_10_Template, 2, 1, "div", 15)(11, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_11_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(12, "small", 16);
    i0.ɵɵtext(13, "Order in which this sub-agent executes among siblings (0 = first). Must be unique among sibling agents.");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(14, "div", 12)(15, "label", 17);
    i0.ɵɵtext(16, "Execution Mode *");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(17, "kendo-dropdownlist", 18);
    i0.ɵɵtemplate(18, SubAgentAdvancedSettingsDialogComponent_Conditional_3_ng_template_18_Template, 7, 5, "ng-template", 19);
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(19, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_19_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(20, "small", 16);
    i0.ɵɵtext(21);
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(22, "div", 8)(23, "h3", 9);
    i0.ɵɵelement(24, "i", 20);
    i0.ɵɵtext(25, " Agent Configuration ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(26, "div", 11)(27, "div", 12)(28, "label", 21);
    i0.ɵɵtext(29, "Agent Type");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(30, "kendo-dropdownlist", 22);
    i0.ɵɵpipe(31, "async");
    i0.ɵɵelementStart(32, "small", 16);
    i0.ɵɵtext(33, "Specialized agent type that defines behavior and capabilities");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(34, "div", 12)(35, "label", 23);
    i0.ɵɵtext(36, "Status *");
    i0.ɵɵelementEnd();
    i0.ɵɵelement(37, "kendo-dropdownlist", 24);
    i0.ɵɵtemplate(38, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Conditional_38_Template, 2, 1, "div", 15);
    i0.ɵɵelementStart(39, "small", 16);
    i0.ɵɵtext(40, "Current operational status of this sub-agent");
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(41, "div", 8)(42, "h3", 9);
    i0.ɵɵelement(43, "i", 25);
    i0.ɵɵtext(44, " Capability Restrictions ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(45, "div", 11)(46, "div", 26)(47, "label", 27);
    i0.ɵɵelement(48, "kendo-checkbox", 28);
    i0.ɵɵtext(49, " Expose As Action ");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(50, "small", 29);
    i0.ɵɵelement(51, "i", 30);
    i0.ɵɵtext(52, " Sub-agents cannot be exposed as actions. Only root agents (without parents) can be exposed as actions for use by other agents. ");
    i0.ɵɵelementEnd()()()()();
} if (rf & 2) {
    let tmp_10_0;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("formGroup", ctx_r0.advancedForm);
    i0.ɵɵadvance(9);
    i0.ɵɵclassProp("error-border", ctx_r0.hasExecutionOrderError());
    i0.ɵɵproperty("min", 0)("format", "0");
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("executionOrder") ? 10 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.hasExecutionOrderError() ? 11 : -1);
    i0.ɵɵadvance(6);
    i0.ɵɵproperty("data", ctx_r0.executionModeOptions)("valuePrimitive", true);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("executionMode") ? 19 : -1);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.getExecutionModeDescription((tmp_10_0 = ctx_r0.advancedForm.get("executionMode")) == null ? null : tmp_10_0.value));
    i0.ɵɵadvance(9);
    i0.ɵɵproperty("data", i0.ɵɵpipeBind1(31, 18, ctx_r0.agentTypes$))("valuePrimitive", true)("defaultItem", i0.ɵɵpureFunction0(20, _c0));
    i0.ɵɵadvance(7);
    i0.ɵɵproperty("data", ctx_r0.statusOptions)("valuePrimitive", true);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.isFieldInvalid("status") ? 38 : -1);
    i0.ɵɵadvance(10);
    i0.ɵɵproperty("disabled", true);
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 35);
    i0.ɵɵtext(1, " Saving... ");
} }
function SubAgentAdvancedSettingsDialogComponent_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 36);
    i0.ɵɵtext(1, " Save Settings ");
} }
/**
 * Advanced Settings dialog for Sub-Agents.
 * Manages execution order, execution mode, and other advanced sub-agent configurations.
 */
export class SubAgentAdvancedSettingsDialogComponent {
    constructor(dialogRef, fb, cdr) {
        this.dialogRef = dialogRef;
        this.fb = fb;
        this.cdr = cdr;
        this.allSubAgents = []; // For execution order validation
        // Reactive state management
        this.destroy$ = new Subject();
        this.result = new Subject();
        this.isLoading$ = new BehaviorSubject(false);
        this.isSaving$ = new BehaviorSubject(false);
        // Dropdown data
        this.agentTypes$ = new BehaviorSubject([]);
        // Available options
        this.executionModeOptions = [
            {
                text: 'Sequential',
                value: 'Sequential',
                description: 'Child agents execute one after another in order',
                icon: 'fa-list-ol'
            },
            {
                text: 'Parallel',
                value: 'Parallel',
                description: 'Child agents execute simultaneously for faster processing',
                icon: 'fa-layer-group'
            }
        ];
        this.statusOptions = [
            { text: 'Active', value: 'Active' },
            { text: 'Disabled', value: 'Disabled' },
            { text: 'Pending', value: 'Pending' }
        ];
        // Execution order validation
        this.executionOrderError = null;
    }
    ngOnInit() {
        this.initializeForm();
        this.loadDropdownData();
    }
    ngOnDestroy() {
        this.destroy$.next();
        this.destroy$.complete();
    }
    initializeForm() {
        this.advancedForm = this.fb.group({
            executionOrder: [this.subAgent.ExecutionOrder || 0, [Validators.required, Validators.min(0)]],
            executionMode: [this.subAgent.ExecutionMode || 'Sequential', [Validators.required]],
            status: [this.subAgent.Status || 'Active', [Validators.required]],
            typeID: [this.subAgent.TypeID],
            exposeAsAction: [this.subAgent.ExposeAsAction || false]
        });
        this.setupValidationLogic();
    }
    setupValidationLogic() {
        // Execution order validation
        const executionOrderControl = this.advancedForm.get('executionOrder');
        executionOrderControl?.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(order => {
            this.validateExecutionOrder(order);
        });
        // ExposeAsAction validation (sub-agents cannot be exposed as actions)
        const exposeAsActionControl = this.advancedForm.get('exposeAsAction');
        exposeAsActionControl?.valueChanges.pipe(takeUntil(this.destroy$)).subscribe(expose => {
            if (expose && this.subAgent.ParentID) {
                // Sub-agents cannot be exposed as actions
                exposeAsActionControl.setValue(false);
                MJNotificationService.Instance.CreateSimpleNotification('Sub-agents cannot be exposed as actions. Only root agents can be exposed.', 'warning', 4000);
            }
        });
    }
    validateExecutionOrder(order) {
        if (order == null) {
            this.executionOrderError = null;
            return;
        }
        // Check for conflicts with other sub-agents under the same parent (excluding current one)
        const conflictingAgent = this.allSubAgents.find(agent => agent.ID !== this.subAgent.ID &&
            agent.ParentID === this.subAgent.ParentID &&
            agent.ExecutionOrder === order);
        if (conflictingAgent) {
            this.executionOrderError = `Execution order ${order} is already used by "${conflictingAgent.Name}". Please choose a different order.`;
        }
        else {
            this.executionOrderError = null;
        }
        this.cdr.detectChanges();
    }
    async loadDropdownData() {
        this.isLoading$.next(true);
        try {
            const rv = new RunView();
            // Load AI Agent Types
            const agentTypesResult = await rv.RunView({
                EntityName: 'MJ: AI Agent Types',
                ExtraFilter: 'IsActive = 1',
                OrderBy: 'Name',
                ResultType: 'entity_object',
                MaxRows: 1000
            });
            if (agentTypesResult.Success) {
                this.agentTypes$.next(agentTypesResult.Results || []);
            }
        }
        catch (error) {
            console.error('Error loading dropdown data:', error);
            MJNotificationService.Instance.CreateSimpleNotification('Error loading form data. Please try again.', 'error', 3000);
        }
        finally {
            this.isLoading$.next(false);
        }
    }
    // === Validation Helpers ===
    isFieldInvalid(fieldName) {
        const field = this.advancedForm.get(fieldName);
        return !!(field && field.invalid && (field.dirty || field.touched));
    }
    getFieldError(fieldName) {
        const field = this.advancedForm.get(fieldName);
        if (field?.errors) {
            if (field.errors['required'])
                return `${fieldName} is required`;
            if (field.errors['min'])
                return `${fieldName} must be greater than or equal to ${field.errors['min'].min}`;
        }
        return '';
    }
    hasExecutionOrderError() {
        return !!this.executionOrderError;
    }
    // === Execution Mode Helpers ===
    getExecutionModeIcon(mode) {
        const option = this.executionModeOptions.find(opt => opt.value === mode);
        return option?.icon || 'fa-robot';
    }
    getExecutionModeDescription(mode) {
        const option = this.executionModeOptions.find(opt => opt.value === mode);
        return option?.description || '';
    }
    // === Dialog Actions ===
    cancel() {
        this.result.next(null);
        this.dialogRef.close();
    }
    async save() {
        if (this.advancedForm.invalid || this.hasExecutionOrderError()) {
            this.advancedForm.markAllAsTouched();
            MJNotificationService.Instance.CreateSimpleNotification('Please fix validation errors before saving', 'error', 3000);
            return;
        }
        this.isSaving$.next(true);
        try {
            const formData = {
                executionOrder: this.advancedForm.get('executionOrder')?.value,
                executionMode: this.advancedForm.get('executionMode')?.value,
                status: this.advancedForm.get('status')?.value,
                typeID: this.advancedForm.get('typeID')?.value || null,
                exposeAsAction: false // Sub-agents cannot be exposed as actions
            };
            this.result.next(formData);
            this.dialogRef.close();
        }
        catch (error) {
            console.error('Error saving advanced settings:', error);
            MJNotificationService.Instance.CreateSimpleNotification('Error saving settings. Please try again.', 'error', 3000);
        }
        finally {
            this.isSaving$.next(false);
        }
    }
    static { this.ɵfac = function SubAgentAdvancedSettingsDialogComponent_Factory(t) { return new (t || SubAgentAdvancedSettingsDialogComponent)(i0.ɵɵdirectiveInject(i1.WindowRef), i0.ɵɵdirectiveInject(i2.FormBuilder), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: SubAgentAdvancedSettingsDialogComponent, selectors: [["mj-sub-agent-advanced-settings-dialog"]], decls: 14, vars: 14, consts: [[1, "sub-agent-advanced-settings-dialog"], [1, "loading-state"], [1, "advanced-form", 3, "formGroup"], [1, "dialog-footer"], ["kendoButton", "", "look", "flat", 3, "click", "disabled"], ["kendoButton", "", "themeColor", "primary", 3, "click", "disabled"], [1, "loading-spinner"], [1, "fa-solid", "fa-spinner", "fa-spin", "fa-2x"], [1, "form-section"], [1, "section-title"], [1, "fa-solid", "fa-play"], [1, "form-grid"], [1, "form-field"], ["for", "executionOrder"], ["formControlName", "executionOrder", 1, "form-control", 3, "min", "format"], [1, "field-error"], [1, "field-hint"], ["for", "executionMode"], ["formControlName", "executionMode", "textField", "text", "valueField", "value", 1, "form-control", 3, "data", "valuePrimitive"], ["kendoDropDownListItemTemplate", ""], [1, "fa-solid", "fa-robot"], ["for", "typeID"], ["formControlName", "typeID", "textField", "Name", "valueField", "ID", 1, "form-control", 3, "data", "valuePrimitive", "defaultItem"], ["for", "status"], ["formControlName", "status", "textField", "text", "valueField", "value", 1, "form-control", 3, "data", "valuePrimitive"], [1, "fa-solid", "fa-shield-alt"], [1, "form-field", "full-width"], [1, "checkbox-label", "disabled"], ["formControlName", "exposeAsAction", 3, "disabled"], [1, "field-hint", "disabled-hint"], [1, "fa-solid", "fa-info-circle"], [1, "execution-mode-option"], [1, "option-header"], [1, "option-title"], [1, "option-description"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "fa-solid", "fa-save"]], template: function SubAgentAdvancedSettingsDialogComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, SubAgentAdvancedSettingsDialogComponent_Conditional_1_Template, 5, 0, "div", 1);
            i0.ɵɵpipe(2, "async");
            i0.ɵɵtemplate(3, SubAgentAdvancedSettingsDialogComponent_Conditional_3_Template, 53, 21, "form", 2);
            i0.ɵɵelementStart(4, "div", 3)(5, "button", 4);
            i0.ɵɵpipe(6, "async");
            i0.ɵɵlistener("click", function SubAgentAdvancedSettingsDialogComponent_Template_button_click_5_listener() { return ctx.cancel(); });
            i0.ɵɵtext(7, " Cancel ");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(8, "button", 5);
            i0.ɵɵpipe(9, "async");
            i0.ɵɵpipe(10, "async");
            i0.ɵɵlistener("click", function SubAgentAdvancedSettingsDialogComponent_Template_button_click_8_listener() { return ctx.save(); });
            i0.ɵɵtemplate(11, SubAgentAdvancedSettingsDialogComponent_Conditional_11_Template, 2, 0);
            i0.ɵɵpipe(12, "async");
            i0.ɵɵtemplate(13, SubAgentAdvancedSettingsDialogComponent_Conditional_13_Template, 2, 0);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵconditional(i0.ɵɵpipeBind1(2, 4, ctx.isLoading$) ? 1 : 3);
            i0.ɵɵadvance(4);
            i0.ɵɵproperty("disabled", i0.ɵɵpipeBind1(6, 6, ctx.isSaving$) || false);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("disabled", i0.ɵɵpipeBind1(9, 8, ctx.isSaving$) || false || (i0.ɵɵpipeBind1(10, 10, ctx.isLoading$) || false) || ctx.hasExecutionOrderError());
            i0.ɵɵadvance(3);
            i0.ɵɵconditional(i0.ɵɵpipeBind1(12, 12, ctx.isSaving$) ? 11 : 13);
        } }, dependencies: [i2.ɵNgNoValidate, i2.NgControlStatus, i2.NgControlStatusGroup, i2.FormGroupDirective, i2.FormControlName, i3.NumericTextBoxComponent, i3.CheckBoxComponent, i4.ItemTemplateDirective, i4.DropDownListComponent, i5.ButtonComponent, i6.AsyncPipe], styles: [".sub-agent-advanced-settings-dialog[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n}\n\n\n\n[_nghost-%COMP%]     .k-dialog, \n[_nghost-%COMP%]     .k-window {\n  z-index: 10000 !important;\n}\n\n[_nghost-%COMP%]     .k-overlay {\n  z-index: 9999 !important;\n}\n\n\n\n.loading-state[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  height: 300px;\n  color: #6c757d;\n}\n\n.loading-spinner[_ngcontent-%COMP%] {\n  margin-bottom: 1rem;\n}\n\n.loading-spinner[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: #2196f3;\n}\n\n.loading-state[_ngcontent-%COMP%]   p[_ngcontent-%COMP%] {\n  margin-top: 1rem;\n  font-size: 1.1rem;\n}\n\n\n\n.advanced-form[_ngcontent-%COMP%] {\n  flex: 1;\n  overflow-y: auto;\n  padding: 1.5rem;\n}\n\n.form-section[_ngcontent-%COMP%] {\n  margin-bottom: 2rem;\n  background: white;\n  border-radius: 8px;\n  border: 1px solid #e0e0e0;\n  overflow: hidden;\n}\n\n.section-title[_ngcontent-%COMP%] {\n  margin: 0;\n  padding: 1rem 1.5rem;\n  background: #f8f9fa;\n  border-bottom: 1px solid #e0e0e0;\n  color: #495057;\n  font-size: 1.1rem;\n  font-weight: 600;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.section-title[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: #2196f3;\n}\n\n.form-grid[_ngcontent-%COMP%] {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 1.5rem;\n  padding: 1.5rem;\n}\n\n.form-field[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  gap: 0.5rem;\n}\n\n.form-field.full-width[_ngcontent-%COMP%] {\n  grid-column: 1 / -1;\n}\n\n\n\nlabel[_ngcontent-%COMP%] {\n  font-weight: 600;\n  color: #495057;\n  font-size: 0.9rem;\n}\n\n.checkbox-label[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  font-weight: 600;\n  color: #495057;\n  cursor: pointer;\n}\n\n.checkbox-label.disabled[_ngcontent-%COMP%] {\n  color: #6c757d;\n  cursor: not-allowed;\n}\n\n.form-control[_ngcontent-%COMP%] {\n  width: 100%;\n}\n\n.field-hint[_ngcontent-%COMP%] {\n  color: #6c757d;\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n  line-height: 1.3;\n}\n\n.disabled-hint[_ngcontent-%COMP%] {\n  color: #999;\n  font-style: italic;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.disabled-hint[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: #17a2b8;\n}\n\n.field-error[_ngcontent-%COMP%] {\n  color: #dc3545;\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n}\n\n\n\n.form-control.ng-invalid.ng-touched[_ngcontent-%COMP%], \n.error-border[_ngcontent-%COMP%] {\n  border-color: #dc3545 !important;\n}\n\n.form-control.ng-valid.ng-touched[_ngcontent-%COMP%] {\n  border-color: #28a745;\n}\n\n\n\n.execution-mode-option[_ngcontent-%COMP%] {\n  padding: 0.5rem 0;\n}\n\n.option-header[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  margin-bottom: 0.25rem;\n}\n\n.option-header[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  color: #2196f3;\n  width: 16px;\n}\n\n.option-title[_ngcontent-%COMP%] {\n  font-weight: 500;\n  color: #333;\n  font-size: 0.9rem;\n}\n\n.option-description[_ngcontent-%COMP%] {\n  font-size: 0.8rem;\n  color: #666;\n  line-height: 1.3;\n  margin-left: 1.5rem;\n}\n\n\n\n.dialog-footer[_ngcontent-%COMP%] {\n  display: flex;\n  justify-content: flex-end;\n  gap: 1rem;\n  padding: 1rem 1.5rem;\n  border-top: 1px solid #e0e0e0;\n  background: #f8f9fa;\n}\n\n.dialog-footer[_ngcontent-%COMP%]   button[_ngcontent-%COMP%] {\n  min-width: 120px;\n}\n\n.dialog-footer[_ngcontent-%COMP%]   button[themeColor=\"primary\"][_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  margin-right: 0.5rem;\n}\n\n\n\n\n\n\n.form-section[_ngcontent-%COMP%]:first-child   .section-title[_ngcontent-%COMP%] {\n  background: linear-gradient(135deg, #e3f2fd, #f8f9fa);\n}\n\n\n\n.form-section[_ngcontent-%COMP%]:nth-child(2)   .section-title[_ngcontent-%COMP%] {\n  background: linear-gradient(135deg, #f3e5f5, #f8f9fa);\n}\n\n\n\n.form-section[_ngcontent-%COMP%]:nth-child(3)   .section-title[_ngcontent-%COMP%] {\n  background: linear-gradient(135deg, #fff3e0, #f8f9fa);\n}\n\n\n\n@media (max-width: 768px) {\n  .form-grid[_ngcontent-%COMP%] {\n    grid-template-columns: 1fr;\n    gap: 1rem;\n    padding: 1rem;\n  }\n  \n  .form-field.full-width[_ngcontent-%COMP%] {\n    grid-column: 1;\n  }\n  \n  .advanced-form[_ngcontent-%COMP%] {\n    padding: 1rem;\n  }\n  \n  .section-title[_ngcontent-%COMP%] {\n    padding: 0.75rem 1rem;\n    font-size: 1rem;\n  }\n  \n  .dialog-footer[_ngcontent-%COMP%] {\n    padding: 1rem;\n    flex-direction: column;\n  }\n  \n  .dialog-footer[_ngcontent-%COMP%]   button[_ngcontent-%COMP%] {\n    width: 100%;\n  }\n}\n\n\n\n.error-border[_ngcontent-%COMP%] {\n  border: 2px solid #dc3545 !important;\n  background-color: #fff5f5;\n}"] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SubAgentAdvancedSettingsDialogComponent, [{
        type: Component,
        args: [{ selector: 'mj-sub-agent-advanced-settings-dialog', template: "<!-- Sub-Agent Advanced Settings Dialog -->\n<div class=\"sub-agent-advanced-settings-dialog\">\n  \n  <!-- Loading State -->\n  @if (isLoading$ | async) {\n    <div class=\"loading-state\">\n      <div class=\"loading-spinner\">\n        <i class=\"fa-solid fa-spinner fa-spin fa-2x\"></i>\n      </div>\n      <p>Loading sub-agent settings...</p>\n    </div>\n  } @else {\n    \n    <!-- Form Content -->\n    <form [formGroup]=\"advancedForm\" class=\"advanced-form\">\n      \n      <!-- Execution Configuration Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-play\"></i>\n          Execution Configuration\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Execution Order -->\n          <div class=\"form-field\">\n            <label for=\"executionOrder\">Execution Order *</label>\n            <kendo-numerictextbox \n              formControlName=\"executionOrder\"\n              [min]=\"0\"\n              [format]=\"'0'\"\n              [class.error-border]=\"hasExecutionOrderError()\"\n              class=\"form-control\">\n            </kendo-numerictextbox>\n            @if (isFieldInvalid('executionOrder')) {\n              <div class=\"field-error\">{{ getFieldError('executionOrder') }}</div>\n            }\n            @if (hasExecutionOrderError()) {\n              <div class=\"field-error\">{{ executionOrderError }}</div>\n            }\n            <small class=\"field-hint\">Order in which this sub-agent executes among siblings (0 = first). Must be unique among sibling agents.</small>\n          </div>\n          \n          <!-- Execution Mode -->\n          <div class=\"form-field\">\n            <label for=\"executionMode\">Execution Mode *</label>\n            <kendo-dropdownlist \n              formControlName=\"executionMode\"\n              [data]=\"executionModeOptions\"\n              textField=\"text\"\n              valueField=\"value\"\n              [valuePrimitive]=\"true\"\n              class=\"form-control\">\n              <ng-template kendoDropDownListItemTemplate let-dataItem>\n                <div class=\"execution-mode-option\">\n                  <div class=\"option-header\">\n                    <i class=\"fa-solid {{ dataItem.icon }}\"></i>\n                    <span class=\"option-title\">{{ dataItem.text }}</span>\n                  </div>\n                  <div class=\"option-description\">{{ dataItem.description }}</div>\n                </div>\n              </ng-template>\n            </kendo-dropdownlist>\n            @if (isFieldInvalid('executionMode')) {\n              <div class=\"field-error\">{{ getFieldError('executionMode') }}</div>\n            }\n            <small class=\"field-hint\">{{ getExecutionModeDescription(advancedForm.get('executionMode')?.value) }}</small>\n          </div>\n        </div>\n      </div>\n\n      <!-- Agent Configuration Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-robot\"></i>\n          Agent Configuration\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Agent Type -->\n          <div class=\"form-field\">\n            <label for=\"typeID\">Agent Type</label>\n            <kendo-dropdownlist \n              formControlName=\"typeID\"\n              [data]=\"agentTypes$ | async\"\n              textField=\"Name\"\n              valueField=\"ID\"\n              [valuePrimitive]=\"true\"\n              [defaultItem]=\"{ Name: 'Default Type', ID: null }\"\n              class=\"form-control\">\n            </kendo-dropdownlist>\n            <small class=\"field-hint\">Specialized agent type that defines behavior and capabilities</small>\n          </div>\n          \n          <!-- Status -->\n          <div class=\"form-field\">\n            <label for=\"status\">Status *</label>\n            <kendo-dropdownlist \n              formControlName=\"status\"\n              [data]=\"statusOptions\"\n              textField=\"text\"\n              valueField=\"value\"\n              [valuePrimitive]=\"true\"\n              class=\"form-control\">\n            </kendo-dropdownlist>\n            @if (isFieldInvalid('status')) {\n              <div class=\"field-error\">{{ getFieldError('status') }}</div>\n            }\n            <small class=\"field-hint\">Current operational status of this sub-agent</small>\n          </div>\n        </div>\n      </div>\n\n      <!-- Capability Restrictions Section -->\n      <div class=\"form-section\">\n        <h3 class=\"section-title\">\n          <i class=\"fa-solid fa-shield-alt\"></i>\n          Capability Restrictions\n        </h3>\n        \n        <div class=\"form-grid\">\n          <!-- Expose As Action (Disabled for Sub-Agents) -->\n          <div class=\"form-field full-width\">\n            <label class=\"checkbox-label disabled\">\n              <kendo-checkbox \n                formControlName=\"exposeAsAction\"\n                [disabled]=\"true\">\n              </kendo-checkbox>\n              Expose As Action\n            </label>\n            <small class=\"field-hint disabled-hint\">\n              <i class=\"fa-solid fa-info-circle\"></i>\n              Sub-agents cannot be exposed as actions. Only root agents (without parents) can be exposed as actions for use by other agents.\n            </small>\n          </div>\n        </div>\n      </div>\n    </form>\n  }\n\n  <!-- Dialog Footer -->\n  <div class=\"dialog-footer\">\n    <button kendoButton \n            look=\"flat\" \n            (click)=\"cancel()\"\n            [disabled]=\"(isSaving$ | async) || false\">\n      Cancel\n    </button>\n    \n    <button kendoButton \n            themeColor=\"primary\" \n            (click)=\"save()\"\n            [disabled]=\"((isSaving$ | async) || false) || ((isLoading$ | async) || false) || hasExecutionOrderError()\">\n      @if (isSaving$ | async) {\n        <i class=\"fa-solid fa-spinner fa-spin\"></i>\n        Saving...\n      } @else {\n        <i class=\"fa-solid fa-save\"></i>\n        Save Settings\n      }\n    </button>\n  </div>\n</div>", styles: [".sub-agent-advanced-settings-dialog {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n}\n\n/* Ensure dialog appears above banner and other elements */\n:host ::ng-deep .k-dialog,\n:host ::ng-deep .k-window {\n  z-index: 10000 !important;\n}\n\n:host ::ng-deep .k-overlay {\n  z-index: 9999 !important;\n}\n\n/* === Loading State === */\n.loading-state {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  height: 300px;\n  color: #6c757d;\n}\n\n.loading-spinner {\n  margin-bottom: 1rem;\n}\n\n.loading-spinner i {\n  color: #2196f3;\n}\n\n.loading-state p {\n  margin-top: 1rem;\n  font-size: 1.1rem;\n}\n\n/* === Form Layout === */\n.advanced-form {\n  flex: 1;\n  overflow-y: auto;\n  padding: 1.5rem;\n}\n\n.form-section {\n  margin-bottom: 2rem;\n  background: white;\n  border-radius: 8px;\n  border: 1px solid #e0e0e0;\n  overflow: hidden;\n}\n\n.section-title {\n  margin: 0;\n  padding: 1rem 1.5rem;\n  background: #f8f9fa;\n  border-bottom: 1px solid #e0e0e0;\n  color: #495057;\n  font-size: 1.1rem;\n  font-weight: 600;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.section-title i {\n  color: #2196f3;\n}\n\n.form-grid {\n  display: grid;\n  grid-template-columns: 1fr 1fr;\n  gap: 1.5rem;\n  padding: 1.5rem;\n}\n\n.form-field {\n  display: flex;\n  flex-direction: column;\n  gap: 0.5rem;\n}\n\n.form-field.full-width {\n  grid-column: 1 / -1;\n}\n\n/* === Form Controls === */\nlabel {\n  font-weight: 600;\n  color: #495057;\n  font-size: 0.9rem;\n}\n\n.checkbox-label {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  font-weight: 600;\n  color: #495057;\n  cursor: pointer;\n}\n\n.checkbox-label.disabled {\n  color: #6c757d;\n  cursor: not-allowed;\n}\n\n.form-control {\n  width: 100%;\n}\n\n.field-hint {\n  color: #6c757d;\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n  line-height: 1.3;\n}\n\n.disabled-hint {\n  color: #999;\n  font-style: italic;\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n}\n\n.disabled-hint i {\n  color: #17a2b8;\n}\n\n.field-error {\n  color: #dc3545;\n  font-size: 0.8rem;\n  margin-top: 0.25rem;\n}\n\n/* === Validation States === */\n.form-control.ng-invalid.ng-touched,\n.error-border {\n  border-color: #dc3545 !important;\n}\n\n.form-control.ng-valid.ng-touched {\n  border-color: #28a745;\n}\n\n/* === Execution Mode Option Template === */\n.execution-mode-option {\n  padding: 0.5rem 0;\n}\n\n.option-header {\n  display: flex;\n  align-items: center;\n  gap: 0.5rem;\n  margin-bottom: 0.25rem;\n}\n\n.option-header i {\n  color: #2196f3;\n  width: 16px;\n}\n\n.option-title {\n  font-weight: 500;\n  color: #333;\n  font-size: 0.9rem;\n}\n\n.option-description {\n  font-size: 0.8rem;\n  color: #666;\n  line-height: 1.3;\n  margin-left: 1.5rem;\n}\n\n/* === Dialog Footer === */\n.dialog-footer {\n  display: flex;\n  justify-content: flex-end;\n  gap: 1rem;\n  padding: 1rem 1.5rem;\n  border-top: 1px solid #e0e0e0;\n  background: #f8f9fa;\n}\n\n.dialog-footer button {\n  min-width: 120px;\n}\n\n.dialog-footer button[themeColor=\"primary\"] i {\n  margin-right: 0.5rem;\n}\n\n/* === Section-Specific Styling === */\n\n/* Execution Configuration */\n.form-section:first-child .section-title {\n  background: linear-gradient(135deg, #e3f2fd, #f8f9fa);\n}\n\n/* Agent Configuration */\n.form-section:nth-child(2) .section-title {\n  background: linear-gradient(135deg, #f3e5f5, #f8f9fa);\n}\n\n/* Capability Restrictions */\n.form-section:nth-child(3) .section-title {\n  background: linear-gradient(135deg, #fff3e0, #f8f9fa);\n}\n\n/* === Responsive Design === */\n@media (max-width: 768px) {\n  .form-grid {\n    grid-template-columns: 1fr;\n    gap: 1rem;\n    padding: 1rem;\n  }\n  \n  .form-field.full-width {\n    grid-column: 1;\n  }\n  \n  .advanced-form {\n    padding: 1rem;\n  }\n  \n  .section-title {\n    padding: 0.75rem 1rem;\n    font-size: 1rem;\n  }\n  \n  .dialog-footer {\n    padding: 1rem;\n    flex-direction: column;\n  }\n  \n  .dialog-footer button {\n    width: 100%;\n  }\n}\n\n/* === Error Highlighting === */\n.error-border {\n  border: 2px solid #dc3545 !important;\n  background-color: #fff5f5;\n}"] }]
    }], () => [{ type: i1.WindowRef }, { type: i2.FormBuilder }, { type: i0.ChangeDetectorRef }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(SubAgentAdvancedSettingsDialogComponent, { className: "SubAgentAdvancedSettingsDialogComponent", filePath: "src/lib/custom/AIAgents/sub-agent-advanced-settings-dialog.component.ts", lineNumber: 26 }); })();
//# sourceMappingURL=sub-agent-advanced-settings-dialog.component.js.map