import { OnInit, OnDestroy, AfterViewInit, ChangeDetectorRef } from '@angular/core';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { ResourceData } from '@memberjunction/core-entities';
import * as i0 from "@angular/core";
/**
 * Represents an application's role assignment for display in the grid.
 */
interface ApplicationRoleRow {
    ID: string;
    ApplicationID: string;
    ApplicationName: string;
    RoleID: string;
    RoleName: string;
    CanAccess: boolean;
    CanAdmin: boolean;
    IsDirty: boolean;
    IsNew: boolean;
}
/**
 * Represents an application with its role assignments grouped.
 */
interface ApplicationGroup {
    ApplicationID: string;
    ApplicationName: string;
    Roles: ApplicationRoleRow[];
    Expanded: boolean;
}
/**
 * Admin dashboard for managing Application Role assignments.
 * Shows which roles can access and administer each application.
 */
export declare class ApplicationRolesResourceComponent extends BaseResourceComponent implements OnInit, OnDestroy, AfterViewInit {
    private cdr;
    ApplicationGroups: ApplicationGroup[];
    AvailableRoles: {
        ID: string;
        Name: string;
    }[];
    IsLoading: boolean;
    IsSaving: boolean;
    HasUnsavedChanges: boolean;
    ErrorMessage: string | null;
    SuccessMessage: string | null;
    /** Application currently selected for inspection (read-only, agent-driven select / inspect). */
    SelectedApplicationId: string | null;
    SelectedApplicationName: string | null;
    SelectedRoleIdToAdd: Map<string, string>;
    constructor(cdr: ChangeDetectorRef);
    GetResourceDisplayName(_data: ResourceData): Promise<string>;
    GetResourceIconClass(_data: ResourceData): Promise<string>;
    ngOnInit(): Promise<void>;
    /**
     * After the view initializes, publish the initial agent context and register the read-only client
     * tools the AI agent can invoke against this surface. The ongoing context re-emit happens in
     * {@link loadData} and the UI handlers below, on every meaningful state change.
     */
    ngAfterViewInit(): void;
    ngOnDestroy(): void;
    /**
     * Load all application role data and available roles.
     */
    loadData(): Promise<void>;
    /**
     * Toggle the expanded/collapsed state of an application group.
     */
    ToggleGroup(group: ApplicationGroup): void;
    /**
     * Set an application group's expanded state from the accordion panel's
     * (ExpandedChange) output. Preserves the side-effects of {@link ToggleGroup}
     * (change detection + agent-context re-emit) while taking the explicit value.
     */
    OnGroupExpandedChange(group: ApplicationGroup, expanded: boolean): void;
    /**
     * Toggle CanAccess for a specific role assignment.
     */
    ToggleCanAccess(row: ApplicationRoleRow): void;
    /**
     * Toggle CanAdmin for a specific role assignment.
     */
    ToggleCanAdmin(row: ApplicationRoleRow): void;
    /**
     * Get roles not yet assigned to a specific application (for the "Add Role" dropdown).
     */
    GetUnassignedRoles(group: ApplicationGroup): {
        ID: string;
        Name: string;
    }[];
    /**
     * Add a new role assignment to an application group.
     */
    AddRole(group: ApplicationGroup): void;
    /**
     * Remove a role assignment (marks for deletion on save; removes immediately if new).
     */
    RemoveRole(group: ApplicationGroup, row: ApplicationRoleRow): void;
    private _pendingDeletes;
    /**
     * Save all unsaved changes (new records, modified records, deleted records).
     */
    SaveChanges(): Promise<void>;
    /**
     * Discard all unsaved changes and reload data.
     */
    DiscardChanges(): Promise<void>;
    /**
     * Track by function for application groups.
     */
    TrackByAppId(_index: number, group: ApplicationGroup): string;
    /**
     * Track by function for role rows.
     */
    TrackByRoleRow(_index: number, row: ApplicationRoleRow): string;
    /**
     * Get the role count label for an application.
     */
    GetRoleCountLabel(group: ApplicationGroup): string;
    /**
     * Handle dropdown selection for adding roles.
     */
    OnAddRoleSelect(group: ApplicationGroup, roleId: string): void;
    /**
     * Publish the current Application Roles state to the AI agent via NavigationService. The shaping
     * lives in the pure {@link buildApplicationRolesAgentContext} helper so it stays unit-testable.
     * Called on init and on every meaningful state change (load, expand/collapse, select).
     */
    private publishAgentContext;
    /** Application candidates (id+name) for the tolerant id→name→contains resolver. */
    private applicationCandidates;
    /**
     * Register the READ-ONLY client tools the AI agent can invoke against the Application Roles
     * surface. Each handler delegates to a read/navigation method a user interaction would call, and
     * returns `{ Success: true, Data? }` on success or `{ Success: false, ErrorMessage }` on failure.
     * Handlers are tolerant — they never throw. NO mutating tool is registered here (see the SAFETY
     * BOUNDARY comment above).
     */
    private registerAgentClientTools;
    /** Resolve an application group by id or name and toggle its expand/collapse state (UI only). */
    private toolToggleApplicationGroup;
    /** Read-only: resolve an application group by id or name and return its assigned-role count + names. */
    private toolGetRoleCountForApplication;
    /** Read-only: select an application to inspect (sets selection, expands its group, reports roles). */
    private toolSelectApplication;
    /** Read-only: serialize the visible matrix to CSV and trigger a browser download. */
    private toolExportApplicationRoles;
    /** Trigger a client-side CSV download. Side-effect-only (no mutation of any record). */
    private downloadCsv;
    static ɵfac: i0.ɵɵFactoryDeclaration<ApplicationRolesResourceComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<ApplicationRolesResourceComponent, "mj-application-roles-resource", never, {}, {}, never, never, false, never>;
}
/** Tree-shaking prevention */
export declare function LoadApplicationRolesResource(): void;
export {};
//# sourceMappingURL=application-roles-resource.component.d.ts.map