/**
 * @module entity-pipeline-panel.component
 * @description Displays pipeline execution progress and results for entity
 * creation/modification. Used in wizard Step 5 and the Modify "Apply" tab.
 *
 * ### Lifecycle
 * The component does NOT start the pipeline automatically on mount — the parent
 * must call `StartExecution()` explicitly.  This keeps "panel visible" and
 * "pipeline running" as separate events, which simplifies the host wizard logic.
 *
 * ### States
 *  - `idle`      → waiting for StartExecution() call
 *  - `running`   → action in flight, spinner shown
 *  - `success`   → pipeline returned Success=true, success card shown
 *  - `failed`    → pipeline returned Success=false, error card shown
 */
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, inject, } from '@angular/core';
import { DatabaseDesignerService } from '../../services/database-designer.service.js';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-ui-components";
function EntityPipelinePanelComponent_Conditional_1_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Creating entity\u2026 ");
} }
function EntityPipelinePanelComponent_Conditional_1_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Applying changes\u2026 ");
} }
function EntityPipelinePanelComponent_Conditional_1_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "p", 7);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate2(" ", ctx_r0.TableDefinition.SchemaName, ".", ctx_r0.TableDefinition.TableName, " ");
} }
function EntityPipelinePanelComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 1)(1, "div", 4);
    i0.ɵɵelement(2, "i", 5);
    i0.ɵɵelementStart(3, "span", 6);
    i0.ɵɵconditionalCreate(4, EntityPipelinePanelComponent_Conditional_1_Conditional_4_Template, 1, 0)(5, EntityPipelinePanelComponent_Conditional_1_Conditional_5_Template, 1, 0);
    i0.ɵɵelementEnd()();
    i0.ɵɵconditionalCreate(6, EntityPipelinePanelComponent_Conditional_1_Conditional_6_Template, 2, 2, "p", 7);
    i0.ɵɵelementStart(7, "p", 8);
    i0.ɵɵtext(8, " This typically takes 5\u201310 minutes. The server is running migrations, regenerating code, and restarting. You can safely close this panel \u2014 check back in Database Designer once it's done. ");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(4);
    i0.ɵɵconditional(ctx_r0.ModificationType === "create" ? 4 : 5);
    i0.ɵɵadvance(2);
    i0.ɵɵconditional(ctx_r0.TableDefinition ? 6 : -1);
} }
function EntityPipelinePanelComponent_Conditional_2_Conditional_1_For_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵelement(1, "i");
    i0.ɵɵelementStart(2, "span", 19);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span", 20);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const step_r2 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("step-failed", step_r2.Status === "failed")("step-skipped", step_r2.Status === "skipped");
    i0.ɵɵadvance();
    i0.ɵɵclassMap(ctx_r0.StepIcon(step_r2));
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(step_r2.Name);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.FormatDuration(step_r2.DurationMs));
} }
function EntityPipelinePanelComponent_Conditional_2_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵrepeaterCreate(1, EntityPipelinePanelComponent_Conditional_2_Conditional_1_For_2_Template, 6, 8, "div", 17, i0.ɵɵcomponentInstance().TrackByStep, true);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r0.Steps);
} }
function EntityPipelinePanelComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵconditionalCreate(1, EntityPipelinePanelComponent_Conditional_2_Conditional_1_Template, 3, 0, "div", 9);
    i0.ɵɵelementStart(2, "div", 10);
    i0.ɵɵelement(3, "i", 11);
    i0.ɵɵelementStart(4, "h3", 12);
    i0.ɵɵtext(5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(6, "p", 13);
    i0.ɵɵtext(7);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(8, "p", 14);
    i0.ɵɵtext(9);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(10, "p", 15);
    i0.ɵɵelement(11, "i", 16);
    i0.ɵɵtext(12, " Don't see it in the entity list? Click ");
    i0.ɵɵelementStart(13, "strong");
    i0.ɵɵtext(14, "Refresh");
    i0.ɵɵelementEnd();
    i0.ɵɵtext(15, " to reload. ");
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.Steps.length > 0 ? 1 : -1);
    i0.ɵɵadvance(4);
    i0.ɵɵtextInterpolate1("", ctx_r0.PipelineResult.EntityName, " created!");
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.FullTablePath);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(ctx_r0.SuccessColumnSummary);
} }
function EntityPipelinePanelComponent_Conditional_3_Conditional_1_For_2_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 26);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const step_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(step_r4.Message);
} }
function EntityPipelinePanelComponent_Conditional_3_Conditional_1_For_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 18);
    i0.ɵɵelement(1, "i");
    i0.ɵɵelementStart(2, "span", 19);
    i0.ɵɵtext(3);
    i0.ɵɵelementEnd();
    i0.ɵɵconditionalCreate(4, EntityPipelinePanelComponent_Conditional_3_Conditional_1_For_2_Conditional_4_Template, 2, 1, "span", 26);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const step_r4 = ctx.$implicit;
    const ctx_r0 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("step-failed", step_r4.Status === "failed")("step-skipped", step_r4.Status === "skipped");
    i0.ɵɵadvance();
    i0.ɵɵclassMap(ctx_r0.StepIcon(step_r4));
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(step_r4.Name);
    i0.ɵɵadvance();
    i0.ɵɵconditional(step_r4.Message ? 4 : -1);
} }
function EntityPipelinePanelComponent_Conditional_3_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 9);
    i0.ɵɵrepeaterCreate(1, EntityPipelinePanelComponent_Conditional_3_Conditional_1_For_2_Template, 5, 8, "div", 17, i0.ɵɵcomponentInstance().TrackByStep, true);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵrepeater(ctx_r0.Steps);
} }
function EntityPipelinePanelComponent_Conditional_3_Conditional_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Entity creation failed ");
} }
function EntityPipelinePanelComponent_Conditional_3_Conditional_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtext(0, " Apply changes failed ");
} }
function EntityPipelinePanelComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    const _r3 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 3);
    i0.ɵɵconditionalCreate(1, EntityPipelinePanelComponent_Conditional_3_Conditional_1_Template, 3, 0, "div", 9);
    i0.ɵɵelementStart(2, "div", 21);
    i0.ɵɵelement(3, "i", 22);
    i0.ɵɵelementStart(4, "h3", 23);
    i0.ɵɵconditionalCreate(5, EntityPipelinePanelComponent_Conditional_3_Conditional_5_Template, 1, 0)(6, EntityPipelinePanelComponent_Conditional_3_Conditional_6_Template, 1, 0);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(7, "p", 24);
    i0.ɵɵtext(8);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(9, "button", 25);
    i0.ɵɵlistener("click", function EntityPipelinePanelComponent_Conditional_3_Template_button_click_9_listener() { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.Reset()); });
    i0.ɵɵelement(10, "i", 16);
    i0.ɵɵtext(11, " Try Again ");
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r0.Steps.length > 0 ? 1 : -1);
    i0.ɵɵadvance(4);
    i0.ɵɵconditional(ctx_r0.ModificationType === "create" ? 5 : 6);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(ctx_r0.ErrorMessage);
} }
export class EntityPipelinePanelComponent {
    // ─── Injected ──────────────────────────────────────────────────────────
    service = inject(DatabaseDesignerService);
    cdr = inject(ChangeDetectorRef);
    // ─── Inputs ────────────────────────────────────────────────────────────
    /** Table spec to create or modify. */
    TableDefinition = null;
    /** Whether this panel is creating a new entity or altering an existing one. */
    ModificationType = 'create';
    /** Required only in 'alter' mode — ID of the entity being modified. */
    ExistingEntityId = null;
    /** When true, `StartExecution()` is called automatically on mount. */
    AutoStart = false;
    // ─── Outputs ───────────────────────────────────────────────────────────
    /** Emitted when the pipeline completes successfully. */
    Completed = new EventEmitter();
    /** Emitted when the pipeline fails or throws. */
    Errored = new EventEmitter();
    // ─── View state ────────────────────────────────────────────────────────
    State = 'idle';
    PipelineResult = null;
    ErrorMessage = '';
    Steps = [];
    // ─── Public API ────────────────────────────────────────────────────────
    /**
     * Kick off the pipeline.  Idempotent — calling while already running is a no-op.
     * Called by the parent (wizard step 5 or modify "Apply" tab).
     */
    ngAfterViewInit() {
        if (this.AutoStart) {
            // Defer to next microtask so Angular's current CD cycle finishes before
            // we transition to 'running' (avoids ExpressionChangedAfterItHasBeenCheckedError).
            Promise.resolve().then(() => this.StartExecution());
        }
    }
    async StartExecution() {
        if (this.State === 'running')
            return;
        if (!this.TableDefinition) {
            this.State = 'failed';
            this.ErrorMessage = 'Entity definition is incomplete — required fields (EntityName, TableName, SchemaName) are missing. Go back and complete all steps.';
            this.cdr.detectChanges();
            this.Errored.emit(this.ErrorMessage);
            return;
        }
        this.State = 'running';
        this.ErrorMessage = '';
        this.Steps = [];
        this.PipelineResult = null;
        this.cdr.detectChanges();
        try {
            // SkipRestart: true prevents the server from restarting MJAPI mid-request.
            // The Angular client communicates over a long-lived HTTP connection; a server
            // restart would drop the connection before the response arrives.  The agent path
            // (EntitySchemaBuilder) uses the same flag for the same reason.
            const result = this.ModificationType === 'create'
                ? await this.service.createEntity(this.TableDefinition, { skipRestart: true })
                : await this.service.modifyEntity(this.TableDefinition, {
                    existingEntityId: this.ExistingEntityId ?? '',
                    skipRestart: true,
                });
            this.PipelineResult = result;
            this.Steps = result.PipelineSteps ?? [];
            if (result.Success) {
                this.State = 'success';
                this.Completed.emit(result);
            }
            else {
                this.State = 'failed';
                this.ErrorMessage = result.ErrorMessage ?? 'An unknown error occurred.';
                this.Errored.emit(this.ErrorMessage);
            }
        }
        catch (err) {
            const msg = err instanceof Error ? err.message : String(err);
            this.State = 'failed';
            this.ErrorMessage = msg;
            this.Errored.emit(msg);
        }
        finally {
            this.cdr.detectChanges();
        }
    }
    /** Reset to idle so the panel can be reused (e.g., "Try Again"). */
    Reset() {
        this.State = 'idle';
        this.PipelineResult = null;
        this.ErrorMessage = '';
        this.Steps = [];
        this.cdr.detectChanges();
    }
    // ─── Template helpers ──────────────────────────────────────────────────
    TrackByStep(_, step) {
        return step.Name;
    }
    StepIcon(step) {
        switch (step.Status) {
            case 'success': return 'fa-solid fa-circle-check step-success';
            case 'failed': return 'fa-solid fa-circle-xmark step-failed';
            case 'skipped': return 'fa-solid fa-circle-minus step-skipped';
            default: return 'fa-solid fa-circle step-unknown';
        }
    }
    FormatDuration(ms) {
        return ms >= 1000 ? `${(ms / 1000).toFixed(1)}s` : `${ms}ms`;
    }
    /** Summary line for the success card: "4 custom columns + 3 auto-managed". */
    get SuccessColumnSummary() {
        const custom = this.TableDefinition?.Columns.length ?? 0;
        return `${custom} custom column${custom !== 1 ? 's' : ''} + 3 auto-managed`;
    }
    get FullTablePath() {
        if (!this.PipelineResult)
            return '';
        return `${this.PipelineResult.SchemaName}.${this.PipelineResult.TableName}`;
    }
    static ɵfac = function EntityPipelinePanelComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || EntityPipelinePanelComponent)(); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: EntityPipelinePanelComponent, selectors: [["mj-database-pipeline-panel"]], inputs: { TableDefinition: "TableDefinition", ModificationType: "ModificationType", ExistingEntityId: "ExistingEntityId", AutoStart: "AutoStart" }, outputs: { Completed: "Completed", Errored: "Errored" }, standalone: false, decls: 4, vars: 3, consts: [[1, "pipeline-panel"], ["aria-live", "polite", "aria-label", "Creating entity\u2026", 1, "panel-running"], [1, "panel-success"], [1, "panel-failed"], [1, "running-header"], [1, "fa-solid", "fa-spinner", "fa-spin", "running-spinner"], [1, "running-title"], [1, "running-target"], [1, "running-note"], ["aria-label", "Pipeline steps", 1, "steps-list"], [1, "success-card"], [1, "fa-solid", "fa-circle-check", "success-icon"], [1, "success-title"], [1, "success-path"], [1, "success-cols"], [1, "success-refresh-hint"], [1, "fa-solid", "fa-rotate-right"], [1, "step-item", 3, "step-failed", "step-skipped"], [1, "step-item"], [1, "step-name"], [1, "step-duration"], [1, "error-card"], [1, "fa-solid", "fa-circle-xmark", "error-icon"], [1, "error-title"], [1, "error-message"], ["mjButton", "", "buttonStyle", "secondary", 3, "click"], [1, "step-message"]], template: function EntityPipelinePanelComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵconditionalCreate(1, EntityPipelinePanelComponent_Conditional_1_Template, 9, 2, "div", 1);
            i0.ɵɵconditionalCreate(2, EntityPipelinePanelComponent_Conditional_2_Template, 16, 4, "div", 2);
            i0.ɵɵconditionalCreate(3, EntityPipelinePanelComponent_Conditional_3_Template, 12, 3, "div", 3);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.State === "idle" || ctx.State === "running" ? 1 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.State === "success" && ctx.PipelineResult ? 2 : -1);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.State === "failed" ? 3 : -1);
        } }, dependencies: [i1.MJButtonDirective], styles: [".pipeline-panel[_ngcontent-%COMP%] {\n  padding: 24px;\n  display: flex;\n  flex-direction: column;\n  gap: 20px;\n}\n\n\n\n\n.panel-idle[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 12px;\n  padding: 32px;\n  text-align: center;\n}\n\n.idle-icon[_ngcontent-%COMP%] {\n  width: 64px;\n  height: 64px;\n  border-radius: 50%;\n  background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n\n.idle-icon[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 1.8rem;\n  color: var(--mj-brand-primary);\n}\n\n.idle-title[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 1.1rem;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.idle-body[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 0.9rem;\n  color: var(--mj-text-secondary);\n  max-width: 440px;\n}\n\n\n\n\n.panel-running[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 14px;\n  padding: 32px;\n  text-align: center;\n}\n\n.running-header[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n\n.running-spinner[_ngcontent-%COMP%] {\n  font-size: 1.5rem;\n  color: var(--mj-brand-primary);\n}\n\n.running-title[_ngcontent-%COMP%] {\n  font-size: 1.1rem;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.running-target[_ngcontent-%COMP%] {\n  margin: 0;\n  font-family: monospace;\n  font-size: 0.9rem;\n  color: var(--mj-text-secondary);\n}\n\n.running-note[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 0.875rem;\n  font-weight: 500;\n  color: var(--mj-text-secondary);\n  max-width: 440px;\n  line-height: 1.5;\n}\n\n\n\n\n.steps-list[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n  background: var(--mj-bg-surface-card);\n  border: 1px solid var(--mj-border-subtle);\n  border-radius: 8px;\n  padding: 14px 18px;\n}\n\n.step-item[_ngcontent-%COMP%] {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  font-size: 0.875rem;\n  color: var(--mj-text-primary);\n}\n\n.step-item[_ngcontent-%COMP%]   i[_ngcontent-%COMP%] {\n  font-size: 1rem;\n  flex-shrink: 0;\n  width: 18px;\n}\n\n.step-item[_ngcontent-%COMP%]   i.step-success[_ngcontent-%COMP%] { color: var(--mj-status-success); }\n.step-item[_ngcontent-%COMP%]   i.step-failed[_ngcontent-%COMP%]  { color: var(--mj-status-error); }\n.step-item[_ngcontent-%COMP%]   i.step-skipped[_ngcontent-%COMP%] { color: var(--mj-text-muted); }\n.step-item[_ngcontent-%COMP%]   i.step-unknown[_ngcontent-%COMP%] { color: var(--mj-text-muted); }\n\n.step-name[_ngcontent-%COMP%] {\n  flex: 1;\n}\n\n.step-duration[_ngcontent-%COMP%] {\n  font-size: 0.8rem;\n  color: var(--mj-text-secondary);\n  font-variant-numeric: tabular-nums;\n}\n\n.step-message[_ngcontent-%COMP%] {\n  font-size: 0.8rem;\n  color: var(--mj-status-error-text);\n  flex: 1;\n}\n\n.step-item.step-failed[_ngcontent-%COMP%]   .step-name[_ngcontent-%COMP%] {\n  color: var(--mj-status-error-text);\n}\n\n.step-item.step-skipped[_ngcontent-%COMP%]   .step-name[_ngcontent-%COMP%] {\n  color: var(--mj-text-muted);\n}\n\n\n\n\n.success-card[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 8px;\n  padding: 24px;\n  background: var(--mj-status-success-bg);\n  border: 1px solid var(--mj-status-success-border);\n  border-radius: 8px;\n  text-align: center;\n}\n\n.success-icon[_ngcontent-%COMP%] {\n  font-size: 2rem;\n  color: var(--mj-status-success);\n}\n\n.success-title[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 1.1rem;\n  font-weight: 700;\n  color: var(--mj-status-success-text);\n}\n\n.success-path[_ngcontent-%COMP%] {\n  margin: 0;\n  font-family: monospace;\n  font-size: 0.85rem;\n  color: var(--mj-text-secondary);\n}\n\n.success-cols[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 0.85rem;\n  color: var(--mj-text-secondary);\n}\n\n.success-refresh-hint[_ngcontent-%COMP%] {\n  margin: 4px 0 0;\n  font-size: 0.8rem;\n  color: var(--mj-text-muted);\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n\n\n\n\n.error-card[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 10px;\n  padding: 24px;\n  background: var(--mj-status-error-bg);\n  border: 1px solid var(--mj-status-error-border);\n  border-radius: 8px;\n  text-align: center;\n}\n\n.error-icon[_ngcontent-%COMP%] {\n  font-size: 2rem;\n  color: var(--mj-status-error);\n}\n\n.error-title[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 1rem;\n  font-weight: 600;\n  color: var(--mj-status-error-text);\n}\n\n.error-message[_ngcontent-%COMP%] {\n  margin: 0;\n  font-size: 0.875rem;\n  color: var(--mj-text-secondary);\n  max-width: 440px;\n  line-height: 1.5;\n  word-break: break-word;\n  overflow-wrap: break-word;\n}"], changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(EntityPipelinePanelComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-database-pipeline-panel', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"pipeline-panel\">\n\n  <!-- \u2500\u2500 Running state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->\n  @if (State === 'idle' || State === 'running') {\n    <div class=\"panel-running\" aria-live=\"polite\" aria-label=\"Creating entity\u2026\">\n      <div class=\"running-header\">\n        <i class=\"fa-solid fa-spinner fa-spin running-spinner\"></i>\n        <span class=\"running-title\">\n          @if (ModificationType === 'create') { Creating entity\u2026 }\n          @else { Applying changes\u2026 }\n        </span>\n      </div>\n      @if (TableDefinition) {\n        <p class=\"running-target\">\n          {{ TableDefinition.SchemaName }}.{{ TableDefinition.TableName }}\n        </p>\n      }\n      <p class=\"running-note\">\n        This typically takes 5\u201310 minutes. The server is running migrations,\n        regenerating code, and restarting. You can safely close this panel \u2014\n        check back in Database Designer once it's done.\n      </p>\n    </div>\n  }\n\n  <!-- \u2500\u2500 Success state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->\n  @if (State === 'success' && PipelineResult) {\n    <div class=\"panel-success\">\n\n      <!-- Step list -->\n      @if (Steps.length > 0) {\n        <div class=\"steps-list\" aria-label=\"Pipeline steps\">\n          @for (step of Steps; track TrackByStep($index, step)) {\n            <div class=\"step-item\" [class.step-failed]=\"step.Status === 'failed'\" [class.step-skipped]=\"step.Status === 'skipped'\">\n              <i [class]=\"StepIcon(step)\"></i>\n              <span class=\"step-name\">{{ step.Name }}</span>\n              <span class=\"step-duration\">{{ FormatDuration(step.DurationMs) }}</span>\n            </div>\n          }\n        </div>\n      }\n\n      <!-- Success card -->\n      <div class=\"success-card\">\n        <i class=\"fa-solid fa-circle-check success-icon\"></i>\n        <h3 class=\"success-title\">{{ PipelineResult.EntityName }} created!</h3>\n        <p class=\"success-path\">{{ FullTablePath }}</p>\n        <p class=\"success-cols\">{{ SuccessColumnSummary }}</p>\n        <p class=\"success-refresh-hint\">\n          <i class=\"fa-solid fa-rotate-right\"></i>\n          Don't see it in the entity list? Click <strong>Refresh</strong> to reload.\n        </p>\n      </div>\n    </div>\n  }\n\n  <!-- \u2500\u2500 Failed state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 -->\n  @if (State === 'failed') {\n    <div class=\"panel-failed\">\n\n      <!-- Step list (partial results if available) -->\n      @if (Steps.length > 0) {\n        <div class=\"steps-list\" aria-label=\"Pipeline steps\">\n          @for (step of Steps; track TrackByStep($index, step)) {\n            <div class=\"step-item\" [class.step-failed]=\"step.Status === 'failed'\" [class.step-skipped]=\"step.Status === 'skipped'\">\n              <i [class]=\"StepIcon(step)\"></i>\n              <span class=\"step-name\">{{ step.Name }}</span>\n              @if (step.Message) {\n                <span class=\"step-message\">{{ step.Message }}</span>\n              }\n            </div>\n          }\n        </div>\n      }\n\n      <!-- Error card -->\n      <div class=\"error-card\">\n        <i class=\"fa-solid fa-circle-xmark error-icon\"></i>\n        <h3 class=\"error-title\">\n          @if (ModificationType === 'create') { Entity creation failed }\n          @else { Apply changes failed }\n        </h3>\n        <p class=\"error-message\">{{ ErrorMessage }}</p>\n        <button mjButton buttonStyle=\"secondary\" (click)=\"Reset()\">\n          <i class=\"fa-solid fa-rotate-right\"></i>\n          Try Again\n        </button>\n      </div>\n    </div>\n  }\n\n</div>\n", styles: [".pipeline-panel {\n  padding: 24px;\n  display: flex;\n  flex-direction: column;\n  gap: 20px;\n}\n\n/* \u2500\u2500 Idle \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.panel-idle {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 12px;\n  padding: 32px;\n  text-align: center;\n}\n\n.idle-icon {\n  width: 64px;\n  height: 64px;\n  border-radius: 50%;\n  background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n\n.idle-icon i {\n  font-size: 1.8rem;\n  color: var(--mj-brand-primary);\n}\n\n.idle-title {\n  margin: 0;\n  font-size: 1.1rem;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.idle-body {\n  margin: 0;\n  font-size: 0.9rem;\n  color: var(--mj-text-secondary);\n  max-width: 440px;\n}\n\n/* \u2500\u2500 Running \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.panel-running {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 14px;\n  padding: 32px;\n  text-align: center;\n}\n\n.running-header {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n}\n\n.running-spinner {\n  font-size: 1.5rem;\n  color: var(--mj-brand-primary);\n}\n\n.running-title {\n  font-size: 1.1rem;\n  font-weight: 600;\n  color: var(--mj-text-primary);\n}\n\n.running-target {\n  margin: 0;\n  font-family: monospace;\n  font-size: 0.9rem;\n  color: var(--mj-text-secondary);\n}\n\n.running-note {\n  margin: 0;\n  font-size: 0.875rem;\n  font-weight: 500;\n  color: var(--mj-text-secondary);\n  max-width: 440px;\n  line-height: 1.5;\n}\n\n/* \u2500\u2500 Steps list (shared between success and failed) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.steps-list {\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n  background: var(--mj-bg-surface-card);\n  border: 1px solid var(--mj-border-subtle);\n  border-radius: 8px;\n  padding: 14px 18px;\n}\n\n.step-item {\n  display: flex;\n  align-items: center;\n  gap: 10px;\n  font-size: 0.875rem;\n  color: var(--mj-text-primary);\n}\n\n.step-item i {\n  font-size: 1rem;\n  flex-shrink: 0;\n  width: 18px;\n}\n\n.step-item i.step-success { color: var(--mj-status-success); }\n.step-item i.step-failed  { color: var(--mj-status-error); }\n.step-item i.step-skipped { color: var(--mj-text-muted); }\n.step-item i.step-unknown { color: var(--mj-text-muted); }\n\n.step-name {\n  flex: 1;\n}\n\n.step-duration {\n  font-size: 0.8rem;\n  color: var(--mj-text-secondary);\n  font-variant-numeric: tabular-nums;\n}\n\n.step-message {\n  font-size: 0.8rem;\n  color: var(--mj-status-error-text);\n  flex: 1;\n}\n\n.step-item.step-failed .step-name {\n  color: var(--mj-status-error-text);\n}\n\n.step-item.step-skipped .step-name {\n  color: var(--mj-text-muted);\n}\n\n/* \u2500\u2500 Success card \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.success-card {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 8px;\n  padding: 24px;\n  background: var(--mj-status-success-bg);\n  border: 1px solid var(--mj-status-success-border);\n  border-radius: 8px;\n  text-align: center;\n}\n\n.success-icon {\n  font-size: 2rem;\n  color: var(--mj-status-success);\n}\n\n.success-title {\n  margin: 0;\n  font-size: 1.1rem;\n  font-weight: 700;\n  color: var(--mj-status-success-text);\n}\n\n.success-path {\n  margin: 0;\n  font-family: monospace;\n  font-size: 0.85rem;\n  color: var(--mj-text-secondary);\n}\n\n.success-cols {\n  margin: 0;\n  font-size: 0.85rem;\n  color: var(--mj-text-secondary);\n}\n\n.success-refresh-hint {\n  margin: 4px 0 0;\n  font-size: 0.8rem;\n  color: var(--mj-text-muted);\n  display: flex;\n  align-items: center;\n  gap: 6px;\n}\n\n/* \u2500\u2500 Error card \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.error-card {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 10px;\n  padding: 24px;\n  background: var(--mj-status-error-bg);\n  border: 1px solid var(--mj-status-error-border);\n  border-radius: 8px;\n  text-align: center;\n}\n\n.error-icon {\n  font-size: 2rem;\n  color: var(--mj-status-error);\n}\n\n.error-title {\n  margin: 0;\n  font-size: 1rem;\n  font-weight: 600;\n  color: var(--mj-status-error-text);\n}\n\n.error-message {\n  margin: 0;\n  font-size: 0.875rem;\n  color: var(--mj-text-secondary);\n  max-width: 440px;\n  line-height: 1.5;\n  word-break: break-word;\n  overflow-wrap: break-word;\n}\n"] }]
    }], null, { TableDefinition: [{
            type: Input
        }], ModificationType: [{
            type: Input
        }], ExistingEntityId: [{
            type: Input
        }], AutoStart: [{
            type: Input
        }], Completed: [{
            type: Output
        }], Errored: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(EntityPipelinePanelComponent, { className: "EntityPipelinePanelComponent", filePath: "src/DatabaseDesigner/components/shared/entity-pipeline-panel.component.ts", lineNumber: 38 }); })();
//# sourceMappingURL=entity-pipeline-panel.component.js.map