/**
 * @fileoverview Classify · Seed-taxonomy review.
 *
 * Calls the server-side `GenerateSeedTaxonomy` GraphQL mutation (which samples a
 * source's content and proposes a tag tree), renders the proposal as a checkbox
 * tree with inline rename, and — on Accept — persists the selected nodes as
 * `MJ: Tags` (parent/child wired via ParentID). Used standalone on the Tags /
 * Taxonomy area and embedded inside the setup wizard's Taxonomy step.
 *
 * The mutation is invoked through the first-class transport helper
 * `GraphQLClassifyClient` (constructed from the threaded `ProviderToUse`,
 * narrowed to the concrete `GraphQLDataProvider` it is at runtime), which
 * returns a strongly-typed `SeedTaxonomyResult` — no inline GraphQL or manual
 * JSON parsing in the component.
 */
import { Component, ChangeDetectorRef, EventEmitter, Input, Output, inject } from '@angular/core';
import { BaseAngularComponent } from '@memberjunction/ng-base-types';
import { MJNotificationService } from '@memberjunction/ng-notifications';
import { TagEngineBase } from '@memberjunction/tag-engine-base';
import { GraphQLClassifyClient, } from '@memberjunction/graphql-dataprovider';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-shared-generic";
import * as i2 from "@memberjunction/ng-ui-components";
const _forTrack0 = ($index, $item) => $item.Key;
function ClassifySeedTaxonomyComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 6);
    i0.ɵɵtext(1, " Generating\u2026 ");
} }
function ClassifySeedTaxonomyComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 7);
    i0.ɵɵtext(1, " Generate again ");
} }
function ClassifySeedTaxonomyComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 8);
    i0.ɵɵtext(1, " Generate seed taxonomy ");
} }
function ClassifySeedTaxonomyComponent_Conditional_6_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵtextInterpolate1(" \u00B7 ", ctx_r0.LastMethod, " ");
} }
function ClassifySeedTaxonomyComponent_Conditional_6_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵtextInterpolate1(" \u00B7 sampled ", ctx_r0.LastSampleSize, " ");
} }
function ClassifySeedTaxonomyComponent_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 4);
    i0.ɵɵtext(1);
    i0.ɵɵconditionalCreate(2, ClassifySeedTaxonomyComponent_Conditional_6_Conditional_2_Template, 1, 1);
    i0.ɵɵconditionalCreate(3, ClassifySeedTaxonomyComponent_Conditional_6_Conditional_3_Template, 1, 1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" ", ctx_r0.SelectedCount, " selected ");
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.LastMethod ? 2 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.LastSampleSize != null ? 3 : -1);
} }
function ClassifySeedTaxonomyComponent_Conditional_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 5);
    i0.ɵɵelement(1, "mj-loading", 9);
    i0.ɵɵelementEnd();
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_0_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵelement(1, "i", 11);
    i0.ɵɵtext(2, " No content sampled \u2014 this source has no ingested content items yet. Add content (crawl & vectorize the source) first, then generate a taxonomy, or skip this step and define the taxonomy later. ");
    i0.ɵɵelementEnd();
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_0_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵelement(1, "i", 12);
    i0.ɵɵtext(2, " The model proposed no tags from the sampled content. Try generating again, or skip this step and define the taxonomy later. ");
    i0.ɵɵelementEnd();
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵconditionalCreate(0, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_0_Conditional_0_Template, 3, 0, "div", 10)(1, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_0_Conditional_1_Template, 3, 0, "div", 10);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵconditional(ctx_r0.LastSampleSize === 0 ? 0 : 1);
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    const _r5 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "input", 20, 0);
    i0.ɵɵlistener("blur", function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_2_Template_input_blur_0_listener() { i0.ɵɵrestoreView(_r5); const renameInput_r6 = i0.ɵɵreference(1); const node_r4 = i0.ɵɵnextContext().$implicit; const ctx_r0 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r0.CommitRename(node_r4, renameInput_r6.value)); })("keyup.enter", function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_2_Template_input_keyup_enter_0_listener() { i0.ɵɵrestoreView(_r5); const renameInput_r6 = i0.ɵɵreference(1); const node_r4 = i0.ɵɵnextContext().$implicit; const ctx_r0 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r0.CommitRename(node_r4, renameInput_r6.value)); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const node_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("value", node_r4.Name);
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_3_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 22);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const node_r4 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(node_r4.MemberCount);
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    const _r7 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "span", 21);
    i0.ɵɵlistener("click", function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_3_Template_span_click_0_listener() { i0.ɵɵrestoreView(_r7); const node_r4 = i0.ɵɵnextContext().$implicit; const ctx_r0 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r0.StartRename(node_r4)); });
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(2, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_3_Conditional_2_Template, 2, 1, "span", 22);
    i0.ɵɵelementStart(3, "button", 23);
    i0.ɵɵlistener("click", function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_3_Template_button_click_3_listener() { i0.ɵɵrestoreView(_r7); const node_r4 = i0.ɵɵnextContext().$implicit; const ctx_r0 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r0.StartRename(node_r4)); });
    i0.ɵɵelement(4, "i", 24);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const node_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(node_r4.Name);
    i0.ɵɵadvance();
    i0.ɵɵconditional(node_r4.MemberCount != null ? 2 : -1);
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 17)(1, "input", 18);
    i0.ɵɵlistener("change", function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Template_input_change_1_listener() { const node_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r0 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r0.ToggleNode(node_r4)); });
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(2, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_2_Template, 2, 1, "input", 19)(3, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Conditional_3_Template, 5, 2);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const node_r4 = ctx.$implicit;
    i0.ɵɵstyleProp("padding-left", 12 + node_r4.Depth * 20, "px");
    i0.ɵɵadvance();
    i0.ɵɵproperty("checked", node_r4.Selected);
    i0.ɵɵadvance();
    i0.ɵɵconditional(node_r4.Renaming ? 2 : 3);
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 6);
    i0.ɵɵtext(1, " Saving\u2026 ");
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 25);
    i0.ɵɵtext(1);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1(" Accept selected (", ctx_r0.SelectedCount, ") ");
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    const _r2 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵrepeaterCreate(1, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_For_2_Template, 4, 4, "div", 14, _forTrack0);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(3, "div", 15)(4, "button", 3);
    i0.ɵɵlistener("click", function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.AcceptSelected()); });
    i0.ɵɵconditionalCreate(5, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Conditional_5_Template, 2, 0)(6, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Conditional_6_Template, 2, 1);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "button", 16);
    i0.ɵɵlistener("click", function ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Template_button_click_7_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.Generate()); });
    i0.ɵɵelement(8, "i", 7);
    i0.ɵɵtext(9, " Generate again ");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r0.FlatNodes);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("disabled", ctx_r0.IsAccepting || !ctx_r0.HasSelection);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.IsAccepting ? 5 : 6);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("disabled", ctx_r0.IsGenerating);
} }
function ClassifySeedTaxonomyComponent_Conditional_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵconditionalCreate(0, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_0_Template, 2, 1)(1, ClassifySeedTaxonomyComponent_Conditional_8_Conditional_1_Template, 10, 3);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵconditional(ctx_r0.FlatNodes.length === 0 ? 0 : 1);
} }
export class ClassifySeedTaxonomyComponent extends BaseAngularComponent {
    cdr = inject(ChangeDetectorRef);
    /** The content source to sample for the taxonomy proposal. */
    SourceID = null;
    /** How many items to sample (passed to the mutation). */
    SampleSize = 50;
    /** Optional parent tag ID under which accepted root nodes are created. */
    ParentTagID = null;
    /** Emitted after Accept persists tags, with the count created. */
    Accepted = new EventEmitter();
    IsGenerating = false;
    IsAccepting = false;
    ProposedNodes = [];
    HasGenerated = false;
    LastMethod = null;
    LastSampleSize = null;
    keySeq = 0;
    /** True when at least one node is checked. */
    get HasSelection() {
        return this.countSelected(this.ProposedNodes) > 0;
    }
    /** Count of currently-selected nodes (template-facing). */
    get SelectedCount() {
        return this.countSelected(this.ProposedNodes);
    }
    countSelected(nodes) {
        let n = 0;
        for (const node of nodes) {
            if (node.Selected)
                n++;
            n += this.countSelected(node.Children);
        }
        return n;
    }
    /** Call the GenerateSeedTaxonomy mutation and render the proposal. */
    async Generate() {
        if (this.IsGenerating)
            return;
        if (!this.SourceID) {
            MJNotificationService.Instance.CreateSimpleNotification('Select a source first.', 'warning', 3000);
            return;
        }
        this.IsGenerating = true;
        this.cdr.detectChanges();
        try {
            const client = new GraphQLClassifyClient(this.ProviderToUse);
            const result = await client.GenerateSeedTaxonomy({
                SourceID: this.SourceID,
                SampleSize: this.SampleSize,
            });
            if (!result.Success) {
                MJNotificationService.Instance.CreateSimpleNotification(`Failed to generate taxonomy: ${result.ErrorMessage ?? 'Unknown error'}`, 'error', 5000);
                return;
            }
            this.LastMethod = result.Method ?? null;
            this.LastSampleSize = result.SampleSize;
            this.ProposedNodes = this.toViewModel(result.Nodes, 0);
            this.HasGenerated = true;
        }
        catch (error) {
            const msg = error instanceof Error ? error.message : String(error);
            MJNotificationService.Instance.CreateSimpleNotification(`Error: ${msg}`, 'error', 5000);
        }
        finally {
            this.IsGenerating = false;
            this.cdr.detectChanges();
        }
    }
    toViewModel(nodes, depth) {
        return nodes.map(n => ({
            Key: `n${this.keySeq++}`,
            Name: n.Name ?? '(unnamed)',
            Description: n.Description,
            MemberCount: n.MemberCount,
            Selected: true,
            Renaming: false,
            Depth: depth,
            Children: this.toViewModel(n.Children ?? [], depth + 1),
        }));
    }
    // ── Tree interactions ──
    /** Toggle a node's selection, cascading to descendants. */
    ToggleNode(node) {
        const next = !node.Selected;
        this.setSelectedRecursive(node, next);
        this.cdr.detectChanges();
    }
    setSelectedRecursive(node, value) {
        node.Selected = value;
        for (const child of node.Children)
            this.setSelectedRecursive(child, value);
    }
    StartRename(node) {
        node.Renaming = true;
        this.cdr.detectChanges();
    }
    CommitRename(node, value) {
        const trimmed = value.trim();
        if (trimmed)
            node.Name = trimmed;
        node.Renaming = false;
        this.cdr.detectChanges();
    }
    /** Flatten the visible tree for the template (depth-first), preserving order. */
    get FlatNodes() {
        const out = [];
        const walk = (nodes) => {
            for (const n of nodes) {
                out.push(n);
                walk(n.Children);
            }
        };
        walk(this.ProposedNodes);
        return out;
    }
    // ── Accept → persist as MJ: Tags ──
    /**
     * Persist every selected node as an `MJ: Tags` record. Parent/child links use
     * ParentID; root nodes use the optional ParentTagID input. Walks the tree
     * top-down so a parent's saved ID is available when creating its children.
     */
    async AcceptSelected() {
        if (this.IsAccepting)
            return;
        if (!this.HasSelection) {
            MJNotificationService.Instance.CreateSimpleNotification('Select at least one tag to accept.', 'warning', 3000);
            return;
        }
        this.IsAccepting = true;
        this.cdr.detectChanges();
        let created = 0;
        try {
            const p = this.ProviderToUse;
            const persistLevel = async (nodes, parentID) => {
                for (const node of nodes) {
                    let savedID = parentID;
                    if (node.Selected) {
                        const tag = await p.GetEntityObject('MJ: Tags', p.CurrentUser);
                        tag.NewRecord();
                        tag.Name = node.Name;
                        tag.DisplayName = node.Name;
                        if (node.Description)
                            tag.Description = node.Description;
                        tag.ParentID = parentID;
                        tag.Status = 'Active';
                        const ok = await tag.Save();
                        if (ok) {
                            created++;
                            savedID = tag.ID;
                        }
                        else {
                            const detail = tag.LatestResult?.CompleteMessage ?? 'Unknown error';
                            MJNotificationService.Instance.CreateSimpleNotification(`Failed to save tag "${node.Name}": ${detail}`, 'error', 5000);
                            // Children still attach to the original parent so the tree isn't orphaned.
                            savedID = parentID;
                        }
                    }
                    // Recurse: children of an unselected node attach to the nearest selected ancestor.
                    await persistLevel(node.Children, savedID);
                }
            };
            await persistLevel(this.ProposedNodes, this.ParentTagID);
            // Refresh the tag cache so other views see the new tags.
            await TagEngineBase.Instance.Config(true, p.CurrentUser, p);
            MJNotificationService.Instance.CreateSimpleNotification(`Created ${created} tag${created === 1 ? '' : 's'}`, 'success', 3000);
            this.Accepted.emit({ Created: created });
            this.ProposedNodes = [];
            this.HasGenerated = false;
        }
        catch (error) {
            const msg = error instanceof Error ? error.message : String(error);
            MJNotificationService.Instance.CreateSimpleNotification(`Error: ${msg}`, 'error', 5000);
        }
        finally {
            this.IsAccepting = false;
            this.cdr.detectChanges();
        }
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵClassifySeedTaxonomyComponent_BaseFactory; return function ClassifySeedTaxonomyComponent_Factory(__ngFactoryType__) { return (ɵClassifySeedTaxonomyComponent_BaseFactory || (ɵClassifySeedTaxonomyComponent_BaseFactory = i0.ɵɵgetInheritedFactory(ClassifySeedTaxonomyComponent)))(__ngFactoryType__ || ClassifySeedTaxonomyComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ClassifySeedTaxonomyComponent, selectors: [["classify-seed-taxonomy"]], inputs: { SourceID: "SourceID", SampleSize: "SampleSize", ParentTagID: "ParentTagID" }, outputs: { Accepted: "Accepted" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature], decls: 9, vars: 4, consts: [["renameInput", ""], [1, "cls-seed"], [1, "cls-seed-bar"], ["mjButton", "", "variant", "primary", "size", "sm", 3, "click", "disabled"], [1, "cls-seed-meta"], [1, "cls-seed-loading"], [1, "fa-solid", "fa-spinner", "fa-spin"], [1, "fa-solid", "fa-rotate"], [1, "fa-solid", "fa-wand-magic-sparkles"], ["text", "Sampling content and proposing tags\u2026"], [1, "cls-seed-empty"], [1, "fa-solid", "fa-triangle-exclamation"], [1, "fa-solid", "fa-circle-info"], [1, "cls-seed-tree"], [1, "cls-seed-row", 3, "padding-left"], [1, "cls-seed-actions"], ["mjButton", "", "variant", "secondary", "size", "sm", 3, "click", "disabled"], [1, "cls-seed-row"], ["type", "checkbox", 3, "change", "checked"], ["type", "text", 1, "mj-input", "cls-seed-rename", 3, "value"], ["type", "text", 1, "mj-input", "cls-seed-rename", 3, "blur", "keyup.enter", "value"], ["title", "Click to rename", 1, "cls-seed-name", 3, "click"], [1, "cls-seed-count"], ["aria-label", "Rename", 1, "cls-seed-rename-btn", 3, "click"], [1, "fa-solid", "fa-pen"], [1, "fa-solid", "fa-check"]], template: function ClassifySeedTaxonomyComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 1)(1, "div", 2)(2, "button", 3);
            i0.ɵɵlistener("click", function ClassifySeedTaxonomyComponent_Template_button_click_2_listener() { return ctx.Generate(); });
            i0.ɵɵconditionalCreate(3, ClassifySeedTaxonomyComponent_Conditional_3_Template, 2, 0)(4, ClassifySeedTaxonomyComponent_Conditional_4_Template, 2, 0)(5, ClassifySeedTaxonomyComponent_Conditional_5_Template, 2, 0);
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(6, ClassifySeedTaxonomyComponent_Conditional_6_Template, 4, 3, "span", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(7, ClassifySeedTaxonomyComponent_Conditional_7_Template, 2, 0, "div", 5)(8, ClassifySeedTaxonomyComponent_Conditional_8_Template, 2, 1);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("disabled", ctx.IsGenerating || !ctx.SourceID);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.IsGenerating ? 3 : ctx.HasGenerated ? 4 : 5);
            i0.ɵɵadvance(3);
            i0.ɵɵconditional(ctx.HasGenerated ? 6 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.IsGenerating ? 7 : ctx.HasGenerated ? 8 : -1);
        } }, dependencies: [i1.LoadingComponent, i2.MJButtonDirective], styles: [".cls-seed[_ngcontent-%COMP%] {\n    display: flex;\n    flex-direction: column;\n    gap: 12px;\n}\n.cls-seed-bar[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    flex-wrap: wrap;\n}\n.cls-seed-meta[_ngcontent-%COMP%] {\n    font-size: 0.78rem;\n    color: var(--mj-text-muted);\n}\n.cls-seed-loading[_ngcontent-%COMP%] {\n    display: flex;\n    justify-content: center;\n    padding: 24px;\n}\n.cls-seed-empty[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    padding: 16px;\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    color: var(--mj-text-secondary);\n    font-size: 0.85rem;\n}\n.cls-seed-empty[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] { color: var(--mj-status-info); }\n.cls-seed-tree[_ngcontent-%COMP%] {\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    background: var(--mj-bg-surface);\n    max-height: 360px;\n    overflow-y: auto;\n    padding: 6px 0;\n}\n.cls-seed-row[_ngcontent-%COMP%] {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    padding-top: 5px;\n    padding-bottom: 5px;\n    padding-right: 12px;\n}\n.cls-seed-row[_ngcontent-%COMP%]:hover { background: var(--mj-bg-surface-hover); }\n.cls-seed-name[_ngcontent-%COMP%] {\n    flex: 1;\n    font-size: 0.85rem;\n    color: var(--mj-text-primary);\n    cursor: text;\n}\n.cls-seed-rename[_ngcontent-%COMP%] {\n    flex: 1;\n    font-size: 0.85rem;\n}\n.cls-seed-count[_ngcontent-%COMP%] {\n    font-size: 0.72rem;\n    color: var(--mj-text-muted);\n    background: var(--mj-bg-surface-sunken);\n    border-radius: 999px;\n    padding: 1px 8px;\n}\n.cls-seed-rename-btn[_ngcontent-%COMP%] {\n    background: none;\n    border: none;\n    color: var(--mj-text-muted);\n    cursor: pointer;\n    padding: 2px 6px;\n    font-size: 0.75rem;\n}\n.cls-seed-rename-btn[_ngcontent-%COMP%]:hover { color: var(--mj-brand-primary); }\n.cls-seed-actions[_ngcontent-%COMP%] {\n    display: flex;\n    gap: 8px;\n}"] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ClassifySeedTaxonomyComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'classify-seed-taxonomy', template: "<div class=\"cls-seed\">\n    <div class=\"cls-seed-bar\">\n        <button mjButton variant=\"primary\" size=\"sm\" (click)=\"Generate()\" [disabled]=\"IsGenerating || !SourceID\">\n            @if (IsGenerating) {\n                <i class=\"fa-solid fa-spinner fa-spin\"></i> Generating\u2026\n            } @else if (HasGenerated) {\n                <i class=\"fa-solid fa-rotate\"></i> Generate again\n            } @else {\n                <i class=\"fa-solid fa-wand-magic-sparkles\"></i> Generate seed taxonomy\n            }\n        </button>\n        @if (HasGenerated) {\n            <span class=\"cls-seed-meta\">\n                {{ SelectedCount }} selected\n                @if (LastMethod) { \u00B7 {{ LastMethod }} }\n                @if (LastSampleSize != null) { \u00B7 sampled {{ LastSampleSize }} }\n            </span>\n        }\n    </div>\n\n    @if (IsGenerating) {\n        <div class=\"cls-seed-loading\">\n            <mj-loading text=\"Sampling content and proposing tags\u2026\"></mj-loading>\n        </div>\n    } @else if (HasGenerated) {\n        @if (FlatNodes.length === 0) {\n            @if (LastSampleSize === 0) {\n                <div class=\"cls-seed-empty\">\n                    <i class=\"fa-solid fa-triangle-exclamation\"></i>\n                    No content sampled \u2014 this source has no ingested content items yet.\n                    Add content (crawl &amp; vectorize the source) first, then generate a\n                    taxonomy, or skip this step and define the taxonomy later.\n                </div>\n            } @else {\n                <div class=\"cls-seed-empty\">\n                    <i class=\"fa-solid fa-circle-info\"></i>\n                    The model proposed no tags from the sampled content. Try generating again,\n                    or skip this step and define the taxonomy later.\n                </div>\n            }\n        } @else {\n            <div class=\"cls-seed-tree\">\n                @for (node of FlatNodes; track node.Key) {\n                    <div class=\"cls-seed-row\" [style.padding-left.px]=\"12 + node.Depth * 20\">\n                        <input type=\"checkbox\" [checked]=\"node.Selected\" (change)=\"ToggleNode(node)\">\n                        @if (node.Renaming) {\n                            <input #renameInput type=\"text\" class=\"mj-input cls-seed-rename\" [value]=\"node.Name\"\n                                   (blur)=\"CommitRename(node, renameInput.value)\"\n                                   (keyup.enter)=\"CommitRename(node, renameInput.value)\">\n                        } @else {\n                            <span class=\"cls-seed-name\" (click)=\"StartRename(node)\" title=\"Click to rename\">{{ node.Name }}</span>\n                            @if (node.MemberCount != null) {\n                                <span class=\"cls-seed-count\">{{ node.MemberCount }}</span>\n                            }\n                            <button class=\"cls-seed-rename-btn\" (click)=\"StartRename(node)\" aria-label=\"Rename\">\n                                <i class=\"fa-solid fa-pen\"></i>\n                            </button>\n                        }\n                    </div>\n                }\n            </div>\n\n            <div class=\"cls-seed-actions\">\n                <button mjButton variant=\"primary\" size=\"sm\" (click)=\"AcceptSelected()\"\n                        [disabled]=\"IsAccepting || !HasSelection\">\n                    @if (IsAccepting) { <i class=\"fa-solid fa-spinner fa-spin\"></i> Saving\u2026 }\n                    @else { <i class=\"fa-solid fa-check\"></i> Accept selected ({{ SelectedCount }}) }\n                </button>\n                <button mjButton variant=\"secondary\" size=\"sm\" (click)=\"Generate()\" [disabled]=\"IsGenerating\">\n                    <i class=\"fa-solid fa-rotate\"></i> Generate again\n                </button>\n            </div>\n        }\n    }\n</div>\n", styles: [".cls-seed {\n    display: flex;\n    flex-direction: column;\n    gap: 12px;\n}\n.cls-seed-bar {\n    display: flex;\n    align-items: center;\n    gap: 12px;\n    flex-wrap: wrap;\n}\n.cls-seed-meta {\n    font-size: 0.78rem;\n    color: var(--mj-text-muted);\n}\n.cls-seed-loading {\n    display: flex;\n    justify-content: center;\n    padding: 24px;\n}\n.cls-seed-empty {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    padding: 16px;\n    background: var(--mj-bg-surface-card);\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    color: var(--mj-text-secondary);\n    font-size: 0.85rem;\n}\n.cls-seed-empty i { color: var(--mj-status-info); }\n.cls-seed-tree {\n    border: 1px solid var(--mj-border-default);\n    border-radius: 8px;\n    background: var(--mj-bg-surface);\n    max-height: 360px;\n    overflow-y: auto;\n    padding: 6px 0;\n}\n.cls-seed-row {\n    display: flex;\n    align-items: center;\n    gap: 8px;\n    padding-top: 5px;\n    padding-bottom: 5px;\n    padding-right: 12px;\n}\n.cls-seed-row:hover { background: var(--mj-bg-surface-hover); }\n.cls-seed-name {\n    flex: 1;\n    font-size: 0.85rem;\n    color: var(--mj-text-primary);\n    cursor: text;\n}\n.cls-seed-rename {\n    flex: 1;\n    font-size: 0.85rem;\n}\n.cls-seed-count {\n    font-size: 0.72rem;\n    color: var(--mj-text-muted);\n    background: var(--mj-bg-surface-sunken);\n    border-radius: 999px;\n    padding: 1px 8px;\n}\n.cls-seed-rename-btn {\n    background: none;\n    border: none;\n    color: var(--mj-text-muted);\n    cursor: pointer;\n    padding: 2px 6px;\n    font-size: 0.75rem;\n}\n.cls-seed-rename-btn:hover { color: var(--mj-brand-primary); }\n.cls-seed-actions {\n    display: flex;\n    gap: 8px;\n}\n"] }]
    }], null, { SourceID: [{
            type: Input
        }], SampleSize: [{
            type: Input
        }], ParentTagID: [{
            type: Input
        }], Accepted: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ClassifySeedTaxonomyComponent, { className: "ClassifySeedTaxonomyComponent", filePath: "src/AI/components/autotagging/components/classify-seed-taxonomy.component.ts", lineNumber: 45 }); })();
//# sourceMappingURL=classify-seed-taxonomy.component.js.map