import { OnInit, OnDestroy } from '@angular/core';
import { EntityInfo, EntityFieldInfo, EntityRelationshipInfo, EntityOrganicKeyInfo, EntityOrganicKeyRelatedEntityInfo, EntityPermissionInfo } from '@memberjunction/core';
import { MJEntityEntity } from '@memberjunction/core-entities';
import { ERDCompositeState } from '@memberjunction/ng-entity-relationship-diagram';
import { RecordOpenedEvent } from '@memberjunction/ng-entity-viewer';
import { MJEntityFormComponent } from '../../generated/Entities/MJEntity/mjentity.form.component';
import * as i0 from "@angular/core";
export type ExplorerSection = 'overview' | 'fields' | 'relationships' | 'organicKeys' | 'permissions' | 'data' | 'lineage' | 'history' | 'settings';
export interface NavItem {
    id: ExplorerSection;
    icon: string;
    label: string;
    badge?: number;
}
export interface EntityStats {
    fieldCount: number;
    relationshipCount: number;
    permissionCount: number;
    rowCount: number | null;
    primaryKeyCount: number;
    foreignKeyCount: number;
    encryptedFieldCount: number;
    valueListFieldCount: number;
}
export interface FieldGroup {
    id: string;
    label: string;
    icon: string;
    fields: EntityFieldInfo[];
    expanded: boolean;
}
/**
 * Represents a group of fields organized by their source entity in an IS-A hierarchy.
 */
export interface ISAFieldGroup {
    /** The source entity name (e.g., "Products", "Meetings") */
    EntityName: string;
    /** The EntityInfo for the source entity */
    EntityInfo: EntityInfo | null;
    /** Label like "Own Fields" or "Inherited from Products" */
    Label: string;
    /** Hierarchy level: 0 = own, 1 = parent, 2 = grandparent, etc. */
    Level: number;
    /** Fields belonging to this group */
    Fields: EntityFieldInfo[];
    /** Whether this group is expanded in the UI */
    Expanded: boolean;
}
/**
 * Record count for a child entity type
 */
export interface ChildEntityCount {
    EntityName: string;
    EntityInfo: EntityInfo;
    RecordCount: number | null;
    IsLoading: boolean;
}
/**
 * Grouped outgoing relationship - an entity this entity references via FK fields
 */
export interface GroupedOutgoingRelationship {
    /** The entity being referenced */
    entityId: string;
    entityName: string;
    /** All fields on THIS entity that reference the target entity */
    fields: EntityFieldInfo[];
}
/**
 * Grouped incoming relationship - an entity that references this entity
 */
export interface GroupedIncomingRelationship {
    /** The entity that references this entity */
    entityName: string;
    /** All fields on the OTHER entity that reference THIS entity */
    fields: {
        fieldName: string;
        type: string;
        bundleInAPI: boolean;
    }[];
}
/**
 * An organic key defined on THIS entity, with its related entity targets
 */
export interface OrganicKeyOutgoing {
    OrganicKey: EntityOrganicKeyInfo;
    RelatedEntities: {
        Info: EntityOrganicKeyRelatedEntityInfo;
        EntityName: string;
        EntityIcon: string;
    }[];
}
/**
 * An organic key on ANOTHER entity that targets THIS entity as a related entity
 */
export interface OrganicKeyIncoming {
    SourceEntityID: string;
    SourceEntityName: string;
    SourceEntityIcon: string;
    OrganicKey: EntityOrganicKeyInfo;
    RelatedEntityConfig: EntityOrganicKeyRelatedEntityInfo;
    MatchType: 'Direct' | 'Transitive';
}
/**
 * World-class Entity Explorer form component that provides an exploration-focused
 * interface for understanding entities in the MemberJunction system.
 *
 * This component replaces the traditional edit-focused entity form with a rich
 * exploration experience featuring:
 * - Three-zone architecture (Header, Nav Rail, Main Canvas)
 * - Seven exploration sections: Overview, Fields, Relationships, Permissions, Lineage, History, Settings
 * - Semantic field grouping by purpose (Primary Keys, Foreign Keys, Encrypted, etc.)
 * - Visual ERD integration for relationship exploration
 * - Slide-in detail panels for contextual information
 */
export declare class MJEntityFormComponentExtended extends MJEntityFormComponent implements OnInit, OnDestroy {
    private sharedService;
    /** The Entity record being displayed */
    record: MJEntityEntity;
    /** Runtime EntityInfo metadata (populated from record.ID) */
    entity: EntityInfo | null;
    /** All entities for relationship lookups */
    allEntities: EntityInfo[];
    /** All entity fields (flattened from all entities) for ERD details panel */
    allEntityFields: EntityFieldInfo[];
    /** Loading state */
    isExplorerLoading: boolean;
    /** Error message if loading fails */
    explorerError: string | null;
    /** Current active section in the explorer */
    activeSection: ExplorerSection;
    /** Navigation items for the rail - world-class minimalist icons */
    navItems: NavItem[];
    /** Computed statistics for the entity */
    stats: EntityStats;
    /** Semantically grouped fields */
    fieldGroups: FieldGroup[];
    /** Field search term for filtering */
    fieldSearchTerm: string;
    /** Set of expanded field group IDs */
    expandedFieldGroups: Set<string>;
    /** Field view mode: grouped by category or flat list */
    fieldViewMode: 'grouped' | 'list';
    /** IS-A field groups organized by source entity */
    isaFieldGroups: ISAFieldGroup[];
    /** Child entity record counts for the IS-A parent type summary */
    childEntityCounts: ChildEntityCount[];
    /** Whether the IS-A field inspector panel is expanded */
    isaFieldInspectorExpanded: boolean;
    /** Field list sort configuration */
    fieldListSortColumn: string;
    fieldListSortDirection: 'asc' | 'desc';
    /** Relationship view mode toggle */
    relationshipViewMode: 'diagram' | 'list';
    /** ERD depth level (1-5) */
    erdDepth: number;
    /** Whether the row count is loading */
    isRowCountLoading: boolean;
    /** Outgoing relationships (this entity references others) */
    outgoingRelationships: EntityRelationshipInfo[];
    /** Incoming relationships (other entities reference this one) */
    incomingRelationships: EntityRelationshipInfo[];
    /** Grouped outgoing relationships by target entity */
    groupedOutgoingRelationships: GroupedOutgoingRelationship[];
    /** Grouped incoming relationships by source entity */
    groupedIncomingRelationships: GroupedIncomingRelationship[];
    /** Outgoing organic keys (defined on THIS entity) */
    organicKeysOutgoing: OrganicKeyOutgoing[];
    /** Incoming organic keys (other entities targeting THIS entity) */
    organicKeysIncoming: OrganicKeyIncoming[];
    /** Whether detail panel is open */
    detailPanelOpen: boolean;
    /** Currently selected field for detail panel */
    selectedField: EntityFieldInfo | null;
    /** Currently selected relationship for detail panel */
    selectedRelationship: EntityRelationshipInfo | null;
    private destroy$;
    private stateChange$;
    private _metadata;
    ngOnInit(): Promise<void>;
    ngOnDestroy(): void;
    private setupStateManagement;
    private loadExplorerData;
    /**
     * Loads the row count asynchronously using RunView with count_only.
     * This doesn't block the UI - updates when complete.
     */
    private loadRowCountAsync;
    private computeStats;
    private buildFieldGroups;
    /**
     * Builds field groups organized by source entity in the IS-A hierarchy.
     * Own fields first, then parent fields, then grandparent, etc.
     */
    private buildISAFieldGroups;
    /**
     * Loads record counts for each IS-A child entity type asynchronously.
     */
    private loadChildEntityCounts;
    private buildRelationships;
    private buildOrganicKeys;
    /**
     * Navigate to the Entity admin form for a given entity ID.
     */
    NavigateToEntityByID(entityID: string): void;
    /** Total organic key connection count (outgoing targets + incoming sources) */
    get OrganicKeyTotalCount(): number;
    private updateNavBadges;
    setActiveSection(section: ExplorerSection): void;
    /**
     * Handle record opened from the entity viewer (double-click or open button).
     * Emits a Navigate event so the host app can open the record.
     */
    OnRecordOpened(event: RecordOpenedEvent): void;
    /**
     * Handle add requested from the entity viewer toolbar.
     * Emits a Navigate event to create a new record of this entity type.
     */
    OnAddRequested(): void;
    toggleFieldGroup(groupId: string): void;
    isFieldGroupExpanded(groupId: string): boolean;
    expandAllFieldGroups(): void;
    collapseAllFieldGroups(): void;
    get allFieldGroupsExpanded(): boolean;
    get allFieldGroupsCollapsed(): boolean;
    /**
     * Get all fields for the list view with sorting and filtering applied.
     */
    getFilteredFieldsList(): EntityFieldInfo[];
    private getFieldSortValue;
    sortFieldList(column: string): void;
    selectField(field: EntityFieldInfo): void;
    selectRelationship(relationship: EntityRelationshipInfo): void;
    closeDetailPanel(): void;
    toggleRelationshipView(): void;
    /**
     * Change the ERD depth level.
     */
    setErdDepth(depth: number): void;
    /**
     * Handle open record from the ERD composite component.
     * Navigates to the selected entity's form using SharedService.
     */
    onERDOpenRecord(event: {
        EntityName: string;
        RecordID: string;
    }): void;
    /**
     * Handle ERD composite state changes (for future persistence if needed).
     */
    onERDStateChange(_state: ERDCompositeState): void;
    onFieldSearch(term: string): void;
    getFilteredFieldGroups(): FieldGroup[];
    /** Whether this entity is a virtual entity (read-only view) */
    get IsVirtualEntity(): boolean;
    /** Whether this entity is a child type in an IS-A relationship */
    get IsChildType(): boolean;
    /** Whether this entity is a parent type in an IS-A relationship */
    get IsParentType(): boolean;
    /** Whether this entity allows overlapping subtypes (multiple children per parent record) */
    get HasOverlappingSubtypes(): boolean;
    /** The parent chain for IS-A child entities */
    get ParentChain(): EntityInfo[];
    /** Child entities for IS-A parent entities */
    get ChildEntities(): EntityInfo[];
    /** Whether this entity has any IS-A relationship (parent or child) */
    get HasISARelationship(): boolean;
    /** IS-A breadcrumb string: "Webinar IS-A Meeting IS-A Product" */
    get IsaBreadcrumb(): string;
    /** Number of fields inherited from parent entities */
    get InheritedFieldCount(): number;
    /** Navigate to an entity record in the Entity Explorer */
    NavigateToEntity(entityInfo: EntityInfo): void;
    /**
     * Returns the source entity name for an IS-A inherited field, or null if the
     * field is owned by this entity. Used for displaying field source badges.
     */
    GetISAFieldSource(field: EntityFieldInfo): string | null;
    /**
     * Returns true if the given field is inherited from a parent entity via IS-A.
     */
    IsInheritedField(field: EntityFieldInfo): boolean;
    /** All entities available as potential IS-A parents (excluding self and descendants) */
    get AvailableParentEntities(): EntityInfo[];
    /** Sibling entities that share the same parent type */
    get SiblingEntities(): EntityInfo[];
    get statusClass(): string;
    get entityIcon(): string;
    get entityDisplayName(): string;
    get formattedRowCount(): string;
    get capabilitySummary(): string[];
    getFieldTypeIcon(field: EntityFieldInfo): string;
    getRelatedEntityName(field: EntityFieldInfo): string | null;
    getRelatedEntity(field: EntityFieldInfo): EntityInfo | null;
    navigateToRelatedEntity(field: EntityFieldInfo): void;
    /**
     * Open an entity record from the field detail panel.
     */
    openRelatedEntityFromField(entityId: string): void;
    formatFieldType(field: EntityFieldInfo): string;
    /**
     * Get the role name for a permission entry.
     * The EntityPermissionInfo.Role property is not populated because the database view
     * returns 'RoleName' but the class expects 'Role'. This helper looks up the role
     * from the Metadata.Roles collection using the RoleID.
     */
    getRoleName(perm: EntityPermissionInfo): string;
    /**
     * Checks if a string value is valid JSON (object or array).
     */
    isJsonValue(value: string): boolean;
    /**
     * Formats a JSON string for display with proper indentation.
     */
    /** Case-insensitive UUID check whether an entity field is the currently selected field. */
    IsFieldSelected(field: EntityFieldInfo): boolean;
    formatJsonValue(value: string): string;
    static ɵfac: i0.ɵɵFactoryDeclaration<MJEntityFormComponentExtended, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<MJEntityFormComponentExtended, "mj-entity-form", never, {}, {}, never, never, false, never>;
}
//# sourceMappingURL=entity-form.component.d.ts.map