/**
 * @fileoverview Shared data layer for the **Realtime management** section.
 *
 * Distinct from `realtime-session-data.ts` (which powers the operational
 * *analytics* on voice sessions), this module loads the whole realtime + bridge
 * **management** surface described in §11b of the Realtime Bridges architecture:
 * bridge providers, agent identities, channels, provider→channel contributions,
 * co-agent pairings, live + historical session bridges, and bridge
 * participants. Everything loads in one batched `RunViews` call and is folded
 * into per-surface view models client-side.
 *
 * The pure aggregation in {@link BucketSessionBridgesByDay} +
 * {@link SummarizeBridgesByProvider} / {@link SummarizeBridgesByStatus} is
 * extracted here (no Angular, no `RunView`) so it can be unit-tested in
 * isolation — see `realtime-management-data.spec.ts`.
 */
import { IMetadataProvider } from '@memberjunction/core';
import type { MJAIBridgeProviderEntity_IBridgeProviderFeatures } from '@memberjunction/core-entities';
/** A bridge provider registry row (`MJ: AI Bridge Providers`). */
export interface BridgeProviderRecord {
    ID: string;
    Name: string;
    Description: string | null;
    BridgeType: 'Meeting' | 'Telephony';
    DriverClass: string;
    Status: 'Active' | 'Disabled';
    /** Raw `SupportedFeatures` JSON string (parsed client-side, see {@link parseFeatures}). */
    SupportedFeatures: string | null;
}
/** A bridge agent-identity row (`MJ: AI Bridge Agent Identities`). */
export interface BridgeAgentIdentityRecord {
    ID: string;
    AgentID: string;
    Agent: string | null;
    ProviderID: string;
    Provider: string;
    IdentityType: 'AccountID' | 'Email' | 'PhoneNumber';
    IdentityValue: string;
    DisplayName: string | null;
    IsActive: boolean;
}
/** An agent-channel registry row (`MJ: AI Agent Channels`). */
export interface AgentChannelRecord {
    ID: string;
    Name: string;
    Description: string | null;
    TransportType: 'PubSub' | 'WebRTC' | 'WebSocket';
    ServerPluginClass: string;
    ClientPluginClass: string;
    IsActive: boolean;
}
/** A provider→channel contribution row (`MJ: AI Bridge Provider Channels`). */
export interface BridgeProviderChannelRecord {
    ID: string;
    ProviderID: string;
    Provider: string;
    ChannelID: string;
    Channel: string;
    IsDefault: boolean;
    Sequence: number;
}
/** A co-agent pairing row (`MJ: AI Agent Co Agents`). */
export interface AgentCoAgentRecord {
    ID: string;
    CoAgentID: string;
    CoAgent: string | null;
    TargetAgentID: string | null;
    TargetAgent: string | null;
    TargetAgentTypeID: string | null;
    TargetAgentType: string | null;
    Type: 'CoAgent' | 'Delegate' | 'Fallback' | 'Observer' | 'Peer' | 'Reviewer';
    IsDefault: boolean;
    Sequence: number;
    Status: 'Active' | 'Disabled';
}
/** A session-bridge row (`MJ: AI Agent Session Bridges`). */
export interface SessionBridgeRecord {
    ID: string;
    AgentSessionID: string;
    ProviderID: string;
    Provider: string;
    Direction: 'Inbound' | 'Outbound';
    JoinMethod: 'InMeetingCommand' | 'InboundRoute' | 'Invite' | 'NativeInvite' | 'OnDemand' | 'Scheduled';
    TurnMode: 'Active' | 'Hybrid' | 'Passive';
    Address: string | null;
    Status: 'Connected' | 'Connecting' | 'Disconnected' | 'Disconnecting' | 'Failed' | 'Pending' | 'Scheduled';
    ScheduledStartTime: string | null;
    ConnectedAt: string | null;
    DisconnectedAt: string | null;
    CloseReason: 'Error' | 'Explicit' | 'HostEnded' | 'Janitor' | 'Shutdown' | null;
    HostInstanceID: string | null;
    __mj_CreatedAt: string;
}
/** A bridge participant row (`MJ: AI Agent Session Bridge Participants`). */
export interface SessionBridgeParticipantRecord {
    ID: string;
    SessionBridgeID: string;
    DisplayName: string | null;
    Role: 'Agent' | 'CoHost' | 'Host' | 'Participant';
    UserID: string | null;
    User: string | null;
    IsAgent: boolean;
    JoinedAt: string | null;
    LeftAt: string | null;
}
/** The session a bridge attaches to (`MJ: AI Agent Sessions`, narrowed). */
export interface SessionLiteRecord {
    ID: string;
    Agent: string | null;
    User: string;
    Status: 'Active' | 'Idle' | 'Closed';
    __mj_CreatedAt: string;
}
/** A provider plus its parsed capability summary and contributed channels. */
export interface BridgeProviderRollup {
    Record: BridgeProviderRecord;
    /** Parsed `SupportedFeatures` JSON; `null` when unset/unparseable. */
    Features: MJAIBridgeProviderEntity_IBridgeProviderFeatures | null;
    /** Count of `true` capability flags. */
    FeatureCount: number;
    /** Channels this provider contributes (sorted by Sequence). */
    Channels: BridgeProviderChannelRecord[];
}
/** A session bridge joined with its session + participant count. */
export interface SessionBridgeRollup {
    Record: SessionBridgeRecord;
    /** The attached session, when found in the loaded window. */
    Session: SessionLiteRecord | null;
    AgentName: string;
    UserName: string;
    ParticipantCount: number;
    StartedAt: Date;
    /** ConnectedAt → (DisconnectedAt ?? now) for connected; else 0. */
    DurationMs: number;
    /** True when the bridge is live (Connecting / Connected). */
    IsLive: boolean;
}
/** A complete load pass of the management surface. */
export interface RealtimeManagementDataset {
    Providers: BridgeProviderRollup[];
    Identities: BridgeAgentIdentityRecord[];
    Channels: AgentChannelRecord[];
    ProviderChannels: BridgeProviderChannelRecord[];
    CoAgents: AgentCoAgentRecord[];
    /** Live session bridges (Connecting / Connected), newest first. */
    LiveBridges: SessionBridgeRollup[];
    /** Closed/terminal session bridges in the window, newest first. */
    HistoryBridges: SessionBridgeRollup[];
    /** Every bridge rollup loaded (live + history), for metrics. */
    AllBridges: SessionBridgeRollup[];
    WindowStart: Date;
    WindowMs: number;
}
/**
 * Loads the full management surface in one batched `RunViews` call, then folds
 * everything into per-surface view models. History is windowed by `timeRange`;
 * live bridges are always included regardless of age.
 */
export declare function LoadRealtimeManagementDataset(provider: IMetadataProvider, timeRange: string): Promise<RealtimeManagementDataset>;
/** One day bucket for the sessions-over-time metric. */
export interface SessionBridgeDayBucket {
    /** Local-midnight Date for the bucket. */
    Date: Date;
    /** YYYY-MM-DD label. */
    Label: string;
    Count: number;
}
/** One labeled aggregate slice (provider, status, etc.) with a count. */
export interface MetricSlice {
    Label: string;
    Count: number;
}
/**
 * Buckets session bridges by their local calendar day across `[windowStart, now]`,
 * emitting one bucket **per day in the window** (including zero-count days) so the
 * resulting series is dense and renderable as bars without gaps.
 *
 * Pure + deterministic given its inputs — `now` is injected for testability.
 *
 * @param bridges   the bridge rollups to bucket (uses each `StartedAt`)
 * @param windowStart inclusive start of the window
 * @param now       the window end (exclusive upper edge is `now`'s day + 1)
 * @returns one bucket per day, oldest → newest
 */
export declare function BucketSessionBridgesByDay(bridges: SessionBridgeRollup[], windowStart: Date, now: Date): SessionBridgeDayBucket[];
/** Aggregates bridge rollups into count-by-provider slices, descending by count. */
export declare function SummarizeBridgesByProvider(bridges: SessionBridgeRollup[]): MetricSlice[];
/** Aggregates bridge rollups into count-by-status slices, descending by count. */
export declare function SummarizeBridgesByStatus(bridges: SessionBridgeRollup[]): MetricSlice[];
/** Aggregates bridge rollups into count-by-agent slices, descending by count. */
export declare function SummarizeBridgesByAgent(bridges: SessionBridgeRollup[]): MetricSlice[];
/** Font Awesome icon for a bridge type. */
export declare function BridgeTypeIcon(type: BridgeProviderRecord['BridgeType']): string;
/** Font Awesome icon for an identity type. */
export declare function IdentityTypeIcon(type: BridgeAgentIdentityRecord['IdentityType']): string;
/** Font Awesome icon for a channel transport type. */
export declare function TransportTypeIcon(type: AgentChannelRecord['TransportType']): string;
/**
 * A compact, human-readable summary of a provider's top capabilities — a few
 * key icons + label pairs derived from the parsed features, capped for density.
 */
export interface CapabilityChip {
    Icon: string;
    Label: string;
}
/**
 * Builds the prioritized capability chips for a provider's feature set. Returns
 * the highest-signal capabilities first (media, then join methods, then
 * signals), so the grid can render a few and show "+N" for the remainder.
 */
export declare function BuildCapabilityChips(features: MJAIBridgeProviderEntity_IBridgeProviderFeatures | null): CapabilityChip[];
/** Formats a duration as m:ss (or h:mm:ss past the hour). */
export declare function FormatBridgeDuration(ms: number): string;
/** Today → "3:40 pm", yesterday → "Yesterday", else "M/d". */
export declare function FormatBridgeStart(date: Date): string;
//# sourceMappingURL=realtime-management-data.d.ts.map