/**
 * @module step-pipeline.component
 * @description Step 5 wrapper — hosts EntityPipelinePanelComponent.
 * Starts pipeline execution on init and surfaces success/retry CTAs.
 */
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ChangeDetectorRef, ViewChild, inject, } from '@angular/core';
import { EntityPipelinePanelComponent } from '../../shared/entity-pipeline-panel.component.js';
import * as i0 from "@angular/core";
import * as i1 from "@memberjunction/ng-ui-components";
import * as i2 from "../../shared/entity-pipeline-panel.component";
function StepPipelineComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 2)(1, "button", 3);
    i0.ɵɵlistener("click", function StepPipelineComponent_Conditional_2_Template_button_click_1_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.CreateAnother.emit()); });
    i0.ɵɵelement(2, "i", 4);
    i0.ɵɵtext(3, " Create Another Entity ");
    i0.ɵɵelementEnd()();
} }
export class StepPipelineComponent {
    cdr = inject(ChangeDetectorRef);
    TableDefinition = {};
    PipelineCompleted = new EventEmitter();
    CreateAnother = new EventEmitter();
    pipelinePanel;
    PipelineResult = null;
    ngAfterViewInit() {
        // Kick off the pipeline immediately once the view is ready
        this.pipelinePanel?.StartExecution();
    }
    /** Backup trigger called by the wizard after the @if block renders the step. */
    StartPipeline() {
        this.pipelinePanel?.StartExecution();
    }
    OnCompleted(result) {
        this.PipelineResult = result;
        this.PipelineCompleted.emit(result);
    }
    get AsEntityTableSpec() {
        const td = this.TableDefinition;
        if (!td.EntityName || !td.TableName || !td.SchemaName)
            return null;
        return td;
    }
    static ɵfac = function StepPipelineComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || StepPipelineComponent)(); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: StepPipelineComponent, selectors: [["mj-entity-step-pipeline"]], viewQuery: function StepPipelineComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(EntityPipelinePanelComponent, 5);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.pipelinePanel = _t.first);
        } }, inputs: { TableDefinition: "TableDefinition" }, outputs: { PipelineCompleted: "PipelineCompleted", CreateAnother: "CreateAnother" }, standalone: false, decls: 3, vars: 3, consts: [[1, "step-pipeline"], ["ModificationType", "create", 3, "Completed", "Errored", "TableDefinition", "AutoStart"], [1, "pipeline-ctas"], ["mjButton", "", "buttonStyle", "secondary", 3, "click"], [1, "fa-solid", "fa-plus"]], template: function StepPipelineComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0)(1, "mj-database-pipeline-panel", 1);
            i0.ɵɵlistener("Completed", function StepPipelineComponent_Template_mj_database_pipeline_panel_Completed_1_listener($event) { return ctx.OnCompleted($event); })("Errored", function StepPipelineComponent_Template_mj_database_pipeline_panel_Errored_1_listener($event) { return ctx.PipelineCompleted.emit({ Success: false, ErrorMessage: $event }); });
            i0.ɵɵelementEnd();
            i0.ɵɵconditionalCreate(2, StepPipelineComponent_Conditional_2_Template, 4, 0, "div", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵproperty("TableDefinition", ctx.AsEntityTableSpec)("AutoStart", true);
            i0.ɵɵadvance();
            i0.ɵɵconditional((ctx.PipelineResult == null ? null : ctx.PipelineResult.Success) ? 2 : -1);
        } }, dependencies: [i1.MJButtonDirective, i2.EntityPipelinePanelComponent], encapsulation: 2, changeDetection: 0 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(StepPipelineComponent, [{
        type: Component,
        args: [{ standalone: false, selector: 'mj-entity-step-pipeline', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"step-pipeline\">\n\n  <mj-database-pipeline-panel\n    [TableDefinition]=\"AsEntityTableSpec\"\n    ModificationType=\"create\"\n    [AutoStart]=\"true\"\n    (Completed)=\"OnCompleted($event)\"\n    (Errored)=\"PipelineCompleted.emit({ Success: false, ErrorMessage: $event })\">\n  </mj-database-pipeline-panel>\n\n  <!-- CTA buttons shown after success -->\n  @if (PipelineResult?.Success) {\n    <div class=\"pipeline-ctas\">\n      <button mjButton buttonStyle=\"secondary\" (click)=\"CreateAnother.emit()\">\n        <i class=\"fa-solid fa-plus\"></i>\n        Create Another Entity\n      </button>\n    </div>\n  }\n\n</div>\n" }]
    }], null, { TableDefinition: [{
            type: Input
        }], PipelineCompleted: [{
            type: Output
        }], CreateAnother: [{
            type: Output
        }], pipelinePanel: [{
            type: ViewChild,
            args: [EntityPipelinePanelComponent]
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StepPipelineComponent, { className: "StepPipelineComponent", filePath: "src/DatabaseDesigner/components/create-wizard/steps/step-pipeline.component.ts", lineNumber: 20 }); })();
//# sourceMappingURL=step-pipeline.component.js.map