/**
 * @fileoverview `app-analytics-realtime-transcripts` — the "Voice Transcripts" view in the AI Analytics
 * shell. A master-detail browser over the unified per-room meeting transcripts the realtime bridge records:
 * a list of meeting rooms on the left, the speaker-attributed (diarized) transcript on the right. Read-only;
 * a child view of the analytics shell (extends {@link BaseAngularComponent}, threads `ProviderToUse`).
 *
 * @module @memberjunction/ng-dashboards
 */
import { Component, ChangeDetectorRef, inject } from '@angular/core';
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
import { AIEngineBase } from '@memberjunction/ai-engine-base';
import { LoadMeetingRooms, LoadRoomTranscript, } from './realtime-transcripts-data';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-shared-generic";
import * as i2 from "@memberjunction/ng-ui-components";
import * as i3 from "@angular/common";
const _forTrack0 = ($index, $item) => $item.ConversationID;
const _forTrack1 = ($index, $item) => $item.ID;
function AnalyticsRealtimeTranscriptsComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 0);
    i0.ɵɵelement(1, "mj-loading", 2);
    i0.ɵɵelementEnd();
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-empty-state", 7);
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_8_For_1_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 11);
    i0.ɵɵlistener("click", function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_8_For_1_Template_button_click_0_listener() { const room_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.selectRoom(room_r4)); });
    i0.ɵɵelement(1, "i", 12);
    i0.ɵɵelementStart(2, "span", 13);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span", 14);
    i0.ɵɵtext(5);
    i0.ɵɵpipe(6, "date");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const room_r4 = ctx.$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("room--active", room_r4.ConversationID === (ctx_r1.SelectedRoom == null ? null : ctx_r1.SelectedRoom.ConversationID));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(room_r4.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(6, 4, room_r4.LastActivity, "MMM d, h:mm a"));
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵrepeaterCreate(0, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_8_For_1_Template, 7, 7, "button", 10, _forTrack0);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵrepeater(ctx_r1.Rooms);
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-empty-state", 9);
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 0);
    i0.ɵɵelement(1, "mj-loading", 15);
    i0.ɵɵelementEnd();
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_12_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-empty-state", 19);
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_12_For_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div")(1, "div", 21)(2, "span", 22);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span", 23);
    i0.ɵɵtext(5);
    i0.ɵɵpipe(6, "date");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(7, "div", 24);
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const line_r5 = ctx.$implicit;
    i0.ɵɵclassMap(i0.ɵɵinterpolate1("line line--", line_r5.Kind));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(line_r5.Speaker);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind2(6, 6, line_r5.At, "h:mm:ss a"));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(line_r5.Message);
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 16)(1, "h3");
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "span", 17);
    i0.ɵɵtext(4);
    i0.ɵɵpipe(5, "date");
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(6, "div", 18);
    i0.ɵɵconditionalCreate(7, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_12_Conditional_7_Template, 1, 0, "mj-empty-state", 19);
    i0.ɵɵrepeaterCreate(8, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_12_For_9_Template, 9, 9, "div", 20, _forTrack1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r1.SelectedRoom.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate3("", ctx_r1.Lines.length, " utterance", ctx_r1.Lines.length === 1 ? "" : "s", " \u00B7 ", i0.ɵɵpipeBind2(5, 5, ctx_r1.SelectedRoom.CreatedAt, "medium"));
    i0.ɵɵadvance(3);
    i0.ɵɵconditional(ctx_r1.Lines.length === 0 ? 7 : -1);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r1.Lines);
} }
function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 3)(2, "div", 4)(3, "span");
    i0.ɵɵtext(4);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "button", 5);
    i0.ɵɵlistener("click", function AnalyticsRealtimeTranscriptsComponent_Conditional_1_Template_button_click_5_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.reload()); });
    i0.ɵɵelement(6, "i", 6);
    i0.ɵɵelementEnd()();
    i0.ɵɵconditionalCreate(7, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_7_Template, 1, 0, "mj-empty-state", 7)(8, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_8_Template, 2, 0);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "div", 8);
    i0.ɵɵconditionalCreate(10, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_10_Template, 1, 0, "mj-empty-state", 9)(11, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_11_Template, 2, 0, "div", 0)(12, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Conditional_12_Template, 10, 8);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate2("", ctx_r1.Rooms.length, " meeting", ctx_r1.Rooms.length === 1 ? "" : "s");
    i0.ɵɵadvance(3);
    i0.ɵɵconditional(ctx_r1.Rooms.length === 0 ? 7 : 8);
    i0.ɵɵadvance(3);
    i0.ɵɵconditional(!ctx_r1.SelectedRoom ? 10 : ctx_r1.IsLoadingTranscript ? 11 : 12);
} }
export class AnalyticsRealtimeTranscriptsComponent extends BaseAngularComponent {
    cdr = inject(ChangeDetectorRef);
    IsLoading = true;
    IsLoadingTranscript = false;
    Rooms = [];
    SelectedRoom = null;
    Lines = [];
    async ngOnInit() {
        await this.reload();
    }
    async reload() {
        this.IsLoading = true;
        this.cdr.detectChanges();
        await AIEngineBase.Instance.EnsureLoaded(); // agents cache, for AI-line attribution
        this.Rooms = await LoadMeetingRooms(this.ProviderToUse);
        this.IsLoading = false;
        this.cdr.detectChanges();
    }
    async selectRoom(room) {
        this.SelectedRoom = room;
        this.Lines = [];
        this.IsLoadingTranscript = true;
        this.cdr.detectChanges();
        this.Lines = await LoadRoomTranscript(this.ProviderToUse, room.ConversationID, room.RoomKey);
        this.IsLoadingTranscript = false;
        this.cdr.detectChanges();
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵAnalyticsRealtimeTranscriptsComponent_BaseFactory; return function AnalyticsRealtimeTranscriptsComponent_Factory(__ngFactoryType__) { return (ɵAnalyticsRealtimeTranscriptsComponent_BaseFactory || (ɵAnalyticsRealtimeTranscriptsComponent_BaseFactory = i0.ɵɵgetInheritedFactory(AnalyticsRealtimeTranscriptsComponent)))(__ngFactoryType__ || AnalyticsRealtimeTranscriptsComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AnalyticsRealtimeTranscriptsComponent, selectors: [["app-analytics-realtime-transcripts"]], standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 2, vars: 1, consts: [[1, "loading-container"], [1, "transcripts"], ["text", "Loading meeting transcripts..."], [1, "room-list"], [1, "room-list__head"], ["title", "Refresh", 1, "rt-refresh", 3, "click"], [1, "fa-solid", "fa-rotate"], ["Size", "compact", "Icon", "fa-solid fa-comment-slash", "Title", "No meeting transcripts yet", 1, "empty"], [1, "transcript-pane"], ["Icon", "fa-solid fa-arrow-left", "Title", "Select a meeting", "Message", "Select a meeting to view its transcript.", 1, "empty", "empty--center"], [1, "room", 3, "room--active"], [1, "room", 3, "click"], [1, "fa-solid", "fa-tower-broadcast", "room__icon"], [1, "room__name"], [1, "room__when"], ["text", "Loading transcript..."], [1, "transcript-pane__head"], [1, "muted"], [1, "lines"], ["Size", "compact", "Icon", "", "Title", "This meeting has no recorded utterances.", 1, "empty"], [3, "class"], [1, "line__meta"], [1, "line__speaker"], [1, "line__time"], [1, "line__bubble"]], template: function AnalyticsRealtimeTranscriptsComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵconditionalCreate(0, AnalyticsRealtimeTranscriptsComponent_Conditional_0_Template, 2, 0, "div", 0)(1, AnalyticsRealtimeTranscriptsComponent_Conditional_1_Template, 13, 4, "div", 1);
        } if (rf & 2) {
            i0.ɵɵconditional(ctx.IsLoading ? 0 : 1);
        } }, dependencies: [i1.LoadingComponent, i2.MJEmptyStateComponent, i3.DatePipe], styles: ["[_nghost-%COMP%] { display: block; height: 100%; }\n        .loading-container[_ngcontent-%COMP%] { display: flex; align-items: center; justify-content: center; padding: 48px; }\n        .transcripts[_ngcontent-%COMP%] { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: 100%; min-height: 420px; }\n        .room-list[_ngcontent-%COMP%] { border: 1px solid var(--mj-border-default); border-radius: 8px; background: var(--mj-bg-surface); overflow-y: auto; }\n        .room-list__head[_ngcontent-%COMP%] { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-size: 12px; color: var(--mj-text-muted); border-bottom: 1px solid var(--mj-border-subtle); position: sticky; top: 0; background: var(--mj-bg-surface); }\n        .rt-refresh[_ngcontent-%COMP%] { background: none; border: none; color: var(--mj-text-muted); cursor: pointer; padding: 4px; }\n        .rt-refresh[_ngcontent-%COMP%]:hover { color: var(--mj-brand-primary); }\n        .room[_ngcontent-%COMP%] { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; width: 100%; text-align: left; padding: 10px 12px; border: none; border-bottom: 1px solid var(--mj-border-subtle); background: none; cursor: pointer; }\n        .room[_ngcontent-%COMP%]:hover { background: var(--mj-bg-surface-hover); }\n        .room--active[_ngcontent-%COMP%] { background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface)); }\n        .room__icon[_ngcontent-%COMP%] { grid-row: 1 / 3; align-self: center; color: var(--mj-brand-primary); }\n        .room__name[_ngcontent-%COMP%] { font-weight: 600; color: var(--mj-text-primary); font-size: 13px; }\n        .room__when[_ngcontent-%COMP%] { color: var(--mj-text-muted); font-size: 11px; }\n        .transcript-pane[_ngcontent-%COMP%] { border: 1px solid var(--mj-border-default); border-radius: 8px; background: var(--mj-bg-surface); display: flex; flex-direction: column; overflow: hidden; }\n        .transcript-pane__head[_ngcontent-%COMP%] { padding: 12px 16px; border-bottom: 1px solid var(--mj-border-subtle); }\n        .transcript-pane__head[_ngcontent-%COMP%]   h3[_ngcontent-%COMP%] { margin: 0; font-size: 15px; color: var(--mj-text-primary); }\n        .muted[_ngcontent-%COMP%] { color: var(--mj-text-muted); font-size: 12px; }\n        .lines[_ngcontent-%COMP%] { padding: 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }\n        .line[_ngcontent-%COMP%] { display: flex; flex-direction: column; gap: 3px; max-width: 80%; }\n        .line--agent[_ngcontent-%COMP%] { align-self: flex-start; }\n        .line--human[_ngcontent-%COMP%] { align-self: flex-end; align-items: flex-end; }\n        .line--error[_ngcontent-%COMP%] { align-self: center; max-width: 90%; }\n        .line__meta[_ngcontent-%COMP%] { display: flex; gap: 8px; font-size: 11px; }\n        .line__speaker[_ngcontent-%COMP%] { font-weight: 600; color: var(--mj-text-secondary); }\n        .line__time[_ngcontent-%COMP%] { color: var(--mj-text-disabled); }\n        .line__bubble[_ngcontent-%COMP%] { padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }\n        .line--agent[_ngcontent-%COMP%]   .line__bubble[_ngcontent-%COMP%] { background: color-mix(in srgb, var(--mj-brand-primary) 12%, var(--mj-bg-surface)); color: var(--mj-text-primary); }\n        .line--human[_ngcontent-%COMP%]   .line__bubble[_ngcontent-%COMP%] { background: var(--mj-bg-surface-sunken); color: var(--mj-text-primary); }\n        .line--error[_ngcontent-%COMP%]   .line__bubble[_ngcontent-%COMP%] { background: var(--mj-status-error-bg); color: var(--mj-status-error-text); border: 1px solid var(--mj-status-error-border); }\n        .empty[_ngcontent-%COMP%] { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px; color: var(--mj-text-muted); }\n        .empty--center[_ngcontent-%COMP%] { margin: auto; }\n        .empty[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] { font-size: 28px; opacity: 0.5; }"] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AnalyticsRealtimeTranscriptsComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'app-analytics-realtime-transcripts', template: `
        @if (IsLoading) {
            <div class="loading-container"><mj-loading text="Loading meeting transcripts..."></mj-loading></div>
        } @else {
            <div class="transcripts">
                <!-- Room list -->
                <div class="room-list">
                    <div class="room-list__head">
                        <span>{{ Rooms.length }} meeting{{ Rooms.length === 1 ? '' : 's' }}</span>
                        <button class="rt-refresh" title="Refresh" (click)="reload()"><i class="fa-solid fa-rotate"></i></button>
                    </div>
                    @if (Rooms.length === 0) {
                        <mj-empty-state class="empty" Size="compact" Icon="fa-solid fa-comment-slash" Title="No meeting transcripts yet" />
                    } @else {
                        @for (room of Rooms; track room.ConversationID) {
                            <button class="room" [class.room--active]="room.ConversationID === SelectedRoom?.ConversationID" (click)="selectRoom(room)">
                                <i class="fa-solid fa-tower-broadcast room__icon"></i>
                                <span class="room__name">{{ room.Name }}</span>
                                <span class="room__when">{{ room.LastActivity | date: 'MMM d, h:mm a' }}</span>
                            </button>
                        }
                    }
                </div>

                <!-- Transcript pane -->
                <div class="transcript-pane">
                    @if (!SelectedRoom) {
                        <mj-empty-state class="empty empty--center" Icon="fa-solid fa-arrow-left" Title="Select a meeting" Message="Select a meeting to view its transcript." />
                    } @else if (IsLoadingTranscript) {
                        <div class="loading-container"><mj-loading text="Loading transcript..."></mj-loading></div>
                    } @else {
                        <div class="transcript-pane__head">
                            <h3>{{ SelectedRoom.Name }}</h3>
                            <span class="muted">{{ Lines.length }} utterance{{ Lines.length === 1 ? '' : 's' }} · {{ SelectedRoom.CreatedAt | date: 'medium' }}</span>
                        </div>
                        <div class="lines">
                            @if (Lines.length === 0) {
                                <mj-empty-state class="empty" Size="compact" Icon="" Title="This meeting has no recorded utterances." />
                            }
                            @for (line of Lines; track line.ID) {
                                <div class="line line--{{ line.Kind }}">
                                    <div class="line__meta">
                                        <span class="line__speaker">{{ line.Speaker }}</span>
                                        <span class="line__time">{{ line.At | date: 'h:mm:ss a' }}</span>
                                    </div>
                                    <div class="line__bubble">{{ line.Message }}</div>
                                </div>
                            }
                        </div>
                    }
                </div>
            </div>
        }
    `, styles: ["\n        :host { display: block; height: 100%; }\n        .loading-container { display: flex; align-items: center; justify-content: center; padding: 48px; }\n        .transcripts { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: 100%; min-height: 420px; }\n        .room-list { border: 1px solid var(--mj-border-default); border-radius: 8px; background: var(--mj-bg-surface); overflow-y: auto; }\n        .room-list__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; font-size: 12px; color: var(--mj-text-muted); border-bottom: 1px solid var(--mj-border-subtle); position: sticky; top: 0; background: var(--mj-bg-surface); }\n        .rt-refresh { background: none; border: none; color: var(--mj-text-muted); cursor: pointer; padding: 4px; }\n        .rt-refresh:hover { color: var(--mj-brand-primary); }\n        .room { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; width: 100%; text-align: left; padding: 10px 12px; border: none; border-bottom: 1px solid var(--mj-border-subtle); background: none; cursor: pointer; }\n        .room:hover { background: var(--mj-bg-surface-hover); }\n        .room--active { background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface)); }\n        .room__icon { grid-row: 1 / 3; align-self: center; color: var(--mj-brand-primary); }\n        .room__name { font-weight: 600; color: var(--mj-text-primary); font-size: 13px; }\n        .room__when { color: var(--mj-text-muted); font-size: 11px; }\n        .transcript-pane { border: 1px solid var(--mj-border-default); border-radius: 8px; background: var(--mj-bg-surface); display: flex; flex-direction: column; overflow: hidden; }\n        .transcript-pane__head { padding: 12px 16px; border-bottom: 1px solid var(--mj-border-subtle); }\n        .transcript-pane__head h3 { margin: 0; font-size: 15px; color: var(--mj-text-primary); }\n        .muted { color: var(--mj-text-muted); font-size: 12px; }\n        .lines { padding: 12px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }\n        .line { display: flex; flex-direction: column; gap: 3px; max-width: 80%; }\n        .line--agent { align-self: flex-start; }\n        .line--human { align-self: flex-end; align-items: flex-end; }\n        .line--error { align-self: center; max-width: 90%; }\n        .line__meta { display: flex; gap: 8px; font-size: 11px; }\n        .line__speaker { font-weight: 600; color: var(--mj-text-secondary); }\n        .line__time { color: var(--mj-text-disabled); }\n        .line__bubble { padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }\n        .line--agent .line__bubble { background: color-mix(in srgb, var(--mj-brand-primary) 12%, var(--mj-bg-surface)); color: var(--mj-text-primary); }\n        .line--human .line__bubble { background: var(--mj-bg-surface-sunken); color: var(--mj-text-primary); }\n        .line--error .line__bubble { background: var(--mj-status-error-bg); color: var(--mj-status-error-text); border: 1px solid var(--mj-status-error-border); }\n        .empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px; color: var(--mj-text-muted); }\n        .empty--center { margin: auto; }\n        .empty i { font-size: 28px; opacity: 0.5; }\n    "] }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AnalyticsRealtimeTranscriptsComponent, { className: "AnalyticsRealtimeTranscriptsComponent", filePath: "src/AI/components/analytics/realtime/realtime-transcripts.component.ts", lineNumber: 111 }); })();
/** Tree-shaking prevention — called from the module constructor so the component class isn't elided. */
export function LoadAnalyticsRealtimeTranscripts() { }
//# sourceMappingURL=realtime-transcripts.component.js.map