/**
 * @fileoverview Shared Record Drilldown Panel
 *
 * A single, reusable side panel that lists records behind a selection on the
 * Knowledge Hub "Visualize" surface. It is driven entirely by inputs and emits
 * record-open intents up to the host — it never imports NavigationService, so it
 * stays a generic child that the KH resource host wires to navigation.
 *
 * Consumed by BOTH:
 *  - Cluster-point selection: the host passes a single record row.
 *  - Tag-cloud word selection: the host passes the records carrying that tag.
 */
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-shared-generic";
import * as i2 from "@memberjunction/ng-ui-components";
function RecordDrilldownComponent_Conditional_0_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 5);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r1.Subtitle);
} }
function RecordDrilldownComponent_Conditional_0_Conditional_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-loading", 9);
} }
function RecordDrilldownComponent_Conditional_0_Conditional_12_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "mj-empty-state", 10);
} }
function RecordDrilldownComponent_Conditional_0_Conditional_13_For_1_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 15);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const record_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(record_r4.Subtitle);
} }
function RecordDrilldownComponent_Conditional_0_Conditional_13_For_1_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 16);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const record_r4 = i0.ɵɵnextContext().$implicit;
    const ctx_r1 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1("", ctx_r1.WeightPercent(record_r4.Weight), "%");
} }
function RecordDrilldownComponent_Conditional_0_Conditional_13_For_1_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 12);
    i0.ɵɵlistener("click", function RecordDrilldownComponent_Conditional_0_Conditional_13_For_1_Template_div_click_0_listener() { const record_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.OnOpen(record_r4)); });
    i0.ɵɵelementStart(1, "div", 13)(2, "span", 14);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(4, RecordDrilldownComponent_Conditional_0_Conditional_13_For_1_Conditional_4_Template, 2, 1, "span", 15);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(5, RecordDrilldownComponent_Conditional_0_Conditional_13_For_1_Conditional_5_Template, 2, 1, "span", 16);
    i0.ɵɵelement(6, "i", 17);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const record_r4 = ctx.$implicit;
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(record_r4.Title);
    i0.ɵɵadvance();
    i0.ɵɵconditional(record_r4.Subtitle ? 4 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(record_r4.Weight != null ? 5 : -1);
} }
function RecordDrilldownComponent_Conditional_0_Conditional_13_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵrepeaterCreate(0, RecordDrilldownComponent_Conditional_0_Conditional_13_For_1_Template, 7, 3, "div", 11, i0.ɵɵcomponentInstance().TrackByRecord, true);
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext(2);
    i0.ɵɵrepeater(ctx_r1.Records);
} }
function RecordDrilldownComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 0)(1, "div", 1)(2, "div", 2);
    i0.ɵɵelement(3, "i");
    i0.ɵɵelementStart(4, "div", 3)(5, "span", 4);
    i0.ɵɵtext(6);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(7, RecordDrilldownComponent_Conditional_0_Conditional_7_Template, 2, 1, "span", 5);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(8, "button", 6);
    i0.ɵɵlistener("click", function RecordDrilldownComponent_Conditional_0_Template_button_click_8_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnClose()); });
    i0.ɵɵelement(9, "i", 7);
    i0.ɵɵelementEnd()();
    i0.ɵɵelementStart(10, "div", 8);
    i0.ɵɵconditionalCreate(11, RecordDrilldownComponent_Conditional_0_Conditional_11_Template, 1, 0, "mj-loading", 9)(12, RecordDrilldownComponent_Conditional_0_Conditional_12_Template, 1, 0, "mj-empty-state", 10)(13, RecordDrilldownComponent_Conditional_0_Conditional_13_Template, 2, 0);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵclassMap(ctx_r1.Icon);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r1.Title);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r1.Subtitle ? 7 : -1);
    i0.ɵɵadvance(4);
    i0.ɵɵconditional(ctx_r1.IsLoading ? 11 : ctx_r1.Records.length === 0 ? 12 : 13);
} }
export class RecordDrilldownComponent {
    /** Panel heading (e.g. the tag text or the selected record's label). */
    Title = '';
    /** Optional sub-heading under the title (e.g. "12 records"). */
    Subtitle = '';
    /** Icon class shown next to the title. */
    Icon = 'fa-solid fa-list';
    /** Whether the panel is visible. */
    Visible = false;
    /** Whether records are currently loading. */
    IsLoading = false;
    /** The records to list. */
    Records = [];
    /** Emitted when the user closes the panel. */
    Closed = new EventEmitter();
    /** Emitted when the user clicks a record to open it. */
    OpenRecord = new EventEmitter();
    OnClose() {
        this.Closed.emit();
    }
    OnOpen(record) {
        if (!record.EntityName || !record.RecordID) {
            return;
        }
        this.OpenRecord.emit({ EntityName: record.EntityName, RecordID: record.RecordID });
    }
    TrackByRecord(_index, record) {
        return `${record.EntityName}|${record.RecordID}`;
    }
    WeightPercent(weight) {
        if (weight == null) {
            return 0;
        }
        return Math.round(Math.max(0, Math.min(1, weight)) * 100);
    }
    static ɵfac = function RecordDrilldownComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || RecordDrilldownComponent)(); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RecordDrilldownComponent, selectors: [["app-kh-record-drilldown"]], inputs: { Title: "Title", Subtitle: "Subtitle", Icon: "Icon", Visible: "Visible", IsLoading: "IsLoading", Records: "Records" }, outputs: { Closed: "Closed", OpenRecord: "OpenRecord" }, standalone: false, decls: 1, vars: 1, consts: [[1, "drilldown-panel"], [1, "drilldown-header"], [1, "drilldown-title"], [1, "drilldown-title-text"], [1, "drilldown-title-main"], [1, "drilldown-title-sub"], ["mjButton", "", "variant", "icon", "size", "sm", "title", "Close", 3, "click"], [1, "fa-solid", "fa-times"], [1, "drilldown-body"], ["text", "Loading records..."], ["Size", "compact", "Icon", "fa-solid fa-inbox", "Title", "No records found", 1, "drilldown-empty"], [1, "drilldown-item"], [1, "drilldown-item", 3, "click"], [1, "drilldown-item-main"], [1, "drilldown-item-title"], [1, "drilldown-item-subtitle"], [1, "drilldown-item-weight"], [1, "fa-solid", "fa-chevron-right", "drilldown-item-chevron"]], template: function RecordDrilldownComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵconditionalCreate(0, RecordDrilldownComponent_Conditional_0_Template, 14, 5, "div", 0);
        } if (rf & 2) {
            i0.ɵɵconditional(ctx.Visible ? 0 : -1);
        } }, dependencies: [i1.LoadingComponent, i2.MJButtonDirective, i2.MJEmptyStateComponent], styles: ["[_nghost-%COMP%] {\n  display: block;\n  height: 100%;\n}\n\n.drilldown-panel[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  width: 340px;\n  max-width: 100%;\n  background: var(--mj-bg-surface);\n  border-left: 1px solid var(--mj-border-default);\n}\n\n.drilldown-header[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 8px;\n  padding: 12px 16px;\n  border-bottom: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.drilldown-title[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  min-width: 0;\n}\n\n.drilldown-title[_ngcontent-%COMP%]    > i[_ngcontent-%COMP%] {\n  color: var(--mj-brand-primary);\n  font-size: 16px;\n}\n\n.drilldown-title-text[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  min-width: 0;\n}\n\n.drilldown-title-main[_ngcontent-%COMP%] {\n  font-weight: 600;\n  color: var(--mj-text-primary);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.drilldown-title-sub[_ngcontent-%COMP%] {\n  font-size: 12px;\n  color: var(--mj-text-muted);\n}\n\n.drilldown-body[_ngcontent-%COMP%] {\n  flex: 1;\n  overflow-y: auto;\n  padding: 8px;\n}\n\n.drilldown-empty[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  gap: 8px;\n  padding: 32px 16px;\n  color: var(--mj-text-muted);\n  text-align: center;\n}\n\n.drilldown-empty[_ngcontent-%COMP%]    > i[_ngcontent-%COMP%] {\n  font-size: 28px;\n  opacity: 0.6;\n}\n\n.drilldown-item[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 10px 12px;\n  border-radius: 6px;\n  cursor: pointer;\n  transition: background 0.15s ease;\n}\n\n.drilldown-item[_ngcontent-%COMP%]:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.drilldown-item-main[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  min-width: 0;\n  flex: 1;\n}\n\n.drilldown-item-title[_ngcontent-%COMP%] {\n  font-weight: 500;\n  color: var(--mj-text-primary);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.drilldown-item-subtitle[_ngcontent-%COMP%] {\n  font-size: 12px;\n  color: var(--mj-text-muted);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.drilldown-item-weight[_ngcontent-%COMP%] {\n  font-size: 12px;\n  font-weight: 600;\n  color: var(--mj-brand-primary);\n  background: color-mix(in srgb, var(--mj-brand-primary) 12%, transparent);\n  border-radius: 10px;\n  padding: 2px 8px;\n  flex-shrink: 0;\n}\n\n.drilldown-item-chevron[_ngcontent-%COMP%] {\n  color: var(--mj-text-disabled);\n  font-size: 12px;\n  flex-shrink: 0;\n}"], changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RecordDrilldownComponent, [{
        type: Component,
        args: [{ selector: 'app-kh-record-drilldown', standalone: false, changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (Visible) {\n  <div class=\"drilldown-panel\">\n    <div class=\"drilldown-header\">\n      <div class=\"drilldown-title\">\n        <i [class]=\"Icon\"></i>\n        <div class=\"drilldown-title-text\">\n          <span class=\"drilldown-title-main\">{{ Title }}</span>\n          @if (Subtitle) {\n            <span class=\"drilldown-title-sub\">{{ Subtitle }}</span>\n          }\n        </div>\n      </div>\n      <button mjButton variant=\"icon\" size=\"sm\" (click)=\"OnClose()\" title=\"Close\">\n        <i class=\"fa-solid fa-times\"></i>\n      </button>\n    </div>\n\n    <div class=\"drilldown-body\">\n      @if (IsLoading) {\n        <mj-loading text=\"Loading records...\"></mj-loading>\n      } @else if (Records.length === 0) {\n        <mj-empty-state class=\"drilldown-empty\" Size=\"compact\"\n          Icon=\"fa-solid fa-inbox\"\n          Title=\"No records found\" />\n      } @else {\n        @for (record of Records; track TrackByRecord($index, record)) {\n          <div class=\"drilldown-item\" (click)=\"OnOpen(record)\">\n            <div class=\"drilldown-item-main\">\n              <span class=\"drilldown-item-title\">{{ record.Title }}</span>\n              @if (record.Subtitle) {\n                <span class=\"drilldown-item-subtitle\">{{ record.Subtitle }}</span>\n              }\n            </div>\n            @if (record.Weight != null) {\n              <span class=\"drilldown-item-weight\">{{ WeightPercent(record.Weight) }}%</span>\n            }\n            <i class=\"fa-solid fa-chevron-right drilldown-item-chevron\"></i>\n          </div>\n        }\n      }\n    </div>\n  </div>\n}\n", styles: [":host {\n  display: block;\n  height: 100%;\n}\n\n.drilldown-panel {\n  display: flex;\n  flex-direction: column;\n  height: 100%;\n  width: 340px;\n  max-width: 100%;\n  background: var(--mj-bg-surface);\n  border-left: 1px solid var(--mj-border-default);\n}\n\n.drilldown-header {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 8px;\n  padding: 12px 16px;\n  border-bottom: 1px solid var(--mj-border-default);\n  background: var(--mj-bg-surface-card);\n}\n\n.drilldown-title {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  min-width: 0;\n}\n\n.drilldown-title > i {\n  color: var(--mj-brand-primary);\n  font-size: 16px;\n}\n\n.drilldown-title-text {\n  display: flex;\n  flex-direction: column;\n  min-width: 0;\n}\n\n.drilldown-title-main {\n  font-weight: 600;\n  color: var(--mj-text-primary);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.drilldown-title-sub {\n  font-size: 12px;\n  color: var(--mj-text-muted);\n}\n\n.drilldown-body {\n  flex: 1;\n  overflow-y: auto;\n  padding: 8px;\n}\n\n.drilldown-empty {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  gap: 8px;\n  padding: 32px 16px;\n  color: var(--mj-text-muted);\n  text-align: center;\n}\n\n.drilldown-empty > i {\n  font-size: 28px;\n  opacity: 0.6;\n}\n\n.drilldown-item {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  padding: 10px 12px;\n  border-radius: 6px;\n  cursor: pointer;\n  transition: background 0.15s ease;\n}\n\n.drilldown-item:hover {\n  background: var(--mj-bg-surface-hover);\n}\n\n.drilldown-item-main {\n  display: flex;\n  flex-direction: column;\n  min-width: 0;\n  flex: 1;\n}\n\n.drilldown-item-title {\n  font-weight: 500;\n  color: var(--mj-text-primary);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.drilldown-item-subtitle {\n  font-size: 12px;\n  color: var(--mj-text-muted);\n  white-space: nowrap;\n  overflow: hidden;\n  text-overflow: ellipsis;\n}\n\n.drilldown-item-weight {\n  font-size: 12px;\n  font-weight: 600;\n  color: var(--mj-brand-primary);\n  background: color-mix(in srgb, var(--mj-brand-primary) 12%, transparent);\n  border-radius: 10px;\n  padding: 2px 8px;\n  flex-shrink: 0;\n}\n\n.drilldown-item-chevron {\n  color: var(--mj-text-disabled);\n  font-size: 12px;\n  flex-shrink: 0;\n}\n"] }]
    }], null, { Title: [{
            type: Input
        }], Subtitle: [{
            type: Input
        }], Icon: [{
            type: Input
        }], Visible: [{
            type: Input
        }], IsLoading: [{
            type: Input
        }], Records: [{
            type: Input
        }], Closed: [{
            type: Output
        }], OpenRecord: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(RecordDrilldownComponent, { className: "RecordDrilldownComponent", filePath: "src/KnowledgeHub/components/visualize/record-drilldown/record-drilldown.component.ts", lineNumber: 49 }); })();
/** Tree-shaking prevention */
export function LoadRecordDrilldownComponent() {
    // Prevents tree-shaking of the component
}
//# sourceMappingURL=record-drilldown.component.js.map