{"version":3,"file":"ngx-t-forms-pipeline-generator.component-Bc8En673.mjs","sources":["../../../projects/ngx-t-forms/src/lib/services/httpResources/Pipeline/pipeline.service.ts","../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/pipeline-generator/elements/aggregate-stage-editor/aggregate-stage-editor.component.ts","../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/pipeline-generator/elements/aggregate-stage-editor/aggregate-stage-editor.component.html","../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/pipeline-generator/pipeline-generator.component.ts","../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/pipeline-generator/pipeline-generator.component.html"],"sourcesContent":["import { HttpClient } from '@angular/common/http';\r\nimport { inject, Injectable, PLATFORM_ID } from '@angular/core';\r\nimport { isPlatformBrowser } from '@angular/common';\r\nimport { BehaviorSubject, catchError, combineLatest, filter, finalize,  map, Observable,  switchMap, take, tap, throwError } from 'rxjs';\r\n\r\nimport PipelineBuilder from \"db-aggregation-pipeline-builder\"\r\nimport { IPipelineGenerationError, IPipelineGenerationResponse, IRunPipelineResponse, PipelineStage, PipelineStageEnum } from 'ngx-t-forms-types';\r\nexport interface IAllowedStage {\r\n  stage: PipelineStageEnum,\r\n  description: string,\r\n  /**\r\n   * Stage-specific configuration. MongoDB pipeline stages have heterogeneous shapes\r\n   * (each `$stage` operator accepts its own option object), so this remains opaque\r\n   * at this layer. Consumers narrow per `stage`.\r\n   */\r\n  config: unknown,\r\n  valid?: boolean\r\n\r\n}\r\n\r\n/**\r\n * @deprecated\r\n *\r\n * Phase 2 layering: prefer `inject(PIPELINE_REPOSITORY)` and wire the\r\n * implementation via `withHttpPipeline()` (or your own `useClass` binding\r\n * against `PIPELINE_REPOSITORY`). This service is preserved as-is for I-1\r\n * parity — its self-contained `inject(HttpClient)` + UI-state surface\r\n * continues to work for current callers and does NOT require the consumer to\r\n * call `withHttpPipeline()`. Target removal: v3.0.0.\r\n *\r\n * Note for new code: the HTTP boundary lives on {@link PipelineRepository}\r\n * (`runPipeline` / `generatePipeline` / `getSchema`). The state-management\r\n * surface here (`pipeline$`, `chatHistory$`, etc.) is internal to the legacy\r\n * pipeline-generator UI and is not part of the repository contract.\r\n */\r\n@Injectable({\r\n  providedIn: 'root'\r\n})\r\nexport class PipelineService  {\r\n  //LOADING INDICATORS\r\n  isRunningPipeline: boolean = false\r\n  aiIsGeneratingPipeline: boolean = false\r\n  isLoadingAllowedStages: boolean = false\r\n  isLoadingWorkflowSchema: boolean = false\r\n\r\n  //States \r\n  workflowId$ = new BehaviorSubject<string|undefined>(undefined)\r\n  activeStage$ = new BehaviorSubject<number|undefined>(undefined)\r\n  prompt$ = new BehaviorSubject<string|undefined>(undefined)\r\n  schemaLoadError$ = new BehaviorSubject<string|undefined>(undefined)\r\n  \r\n\r\n  pipeline$ = new BehaviorSubject<PipelineStage[]>([])\r\n  threadId$ = new BehaviorSubject<string|undefined>(undefined)\r\n  schema$ = new BehaviorSubject<Object|undefined>(undefined)\r\n  allowedStages$ = new BehaviorSubject<IAllowedStage[]>([])\r\n  pipeLineResult$ = new BehaviorSubject<unknown>([])\r\n  chatHistory$ = new BehaviorSubject<{\r\n    user: string,\r\n    assistance:IPipelineGenerationResponse,\r\n    date:Date\r\n  }[]>([])\r\n  http = inject(HttpClient)\r\n  readonly #platformId = inject(PLATFORM_ID);\r\n  constructor() {\r\n    //Set local storage threadId\r\n    if (!isPlatformBrowser(this.#platformId)) return;\r\n    const threadId = localStorage.getItem('threadId')\r\n    if(threadId){\r\n      this.threadId$.next(threadId)\r\n    }\r\n  }\r\n\r\n  get config$() {\r\n    return this.workflowId$.pipe(\r\n      switchMap(workflowId => this.pipeline$.pipe(\r\n        switchMap(pipeline => this.pipeLineResult$.pipe(\r\n          map(responseBody => ({ workflowId, pipeline, responseBody }))\r\n        ))\r\n      ))\r\n    );\r\n  }\r\n  /**\r\n   * Fetch available pipeline stages for the user to select and generate pipelines.\r\n   * Ideally, this could be static or fetched from a backend.\r\n   */\r\n  runPipeLine(pipeline: PipelineStage[],workflowId:string): Observable<IRunPipelineResponse> {\r\n    const url = \"http://localhost:5000/api/v1/pipelineBuilder/runPipeline\"\r\n    // For now, returning a static list of pipeline stages. In a real application, you can fetch from an API.\r\n\r\n    this.isRunningPipeline = true\r\n    return this.http.post<IRunPipelineResponse>(\r\n      url,\r\n      { pipeline,workflowId }\r\n    ).pipe(\r\n      take(1),\r\n      catchError(this.handleError), // Error handling for the HTTP request,\r\n      finalize(() => this.isRunningPipeline = false)\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Generate a MongoDB pipeline based on the given user prompt.\r\n   * \r\n   * @param prompt The user's input or description of the desired pipeline.\r\n   */\r\n  private generatePipeline(query: string, schema: Object | undefined,\r\n    threadId:string|undefined, existingPipeline: PipelineStage[],previousError:string): Observable<IPipelineGenerationResponse> {\r\n    if (!schema) {\r\n      throw new Error(\"Schema is required\")\r\n    }\r\n    const payload = { query, schema ,threadId, existingPipeline ,previousError};\r\n    const url = \"http://localhost:5000/api/v1/pipelineBuilder/generatePipeline\";\r\n    this.aiIsGeneratingPipeline = true\r\n    return this.http.post<IPipelineGenerationResponse>(`${url}`, payload)\r\n      .pipe(\r\n        take(1),\r\n        catchError(this.handleError),// Error handling for the HTTP request,\r\n        finalize(() => this.aiIsGeneratingPipeline = false)\r\n      );\r\n  }\r\n\r\n  /**\r\n   * Handle any errors from the HTTP request.\r\n   *\r\n   * @param error The error response from the HTTP request\r\n   */\r\n  private handleError(error: unknown): Observable<never> {\r\n    // Return an observable with a user-facing error message\r\n    void error;\r\n    return throwError(() => new Error('Something went wrong with the pipeline generation; please try again later.'));\r\n\r\n  }\r\n\r\n\r\n  private getSchema(workflowId: string): Observable<{\r\n    schema: object\r\n  }> {\r\n    if(!workflowId){\r\n      throw new Error(\"WorkflowId is required\")\r\n    }\r\n    const url = \"http://localhost:5000/api/v1/pipelineBuilder/getSchema\";\r\n    return this.http.get<{ schema: object }>(`${url}`, { params: { workflowId: workflowId } }).pipe(\r\n      take(1),\r\n      catchError(this.handleError) // Error handling for the HTTP request\r\n    )\r\n  }\r\n/** OPERATIONS */\r\nisSchemaEmpty(object:object){\r\n\r\n}\r\n  workflowChanged(event: string | undefined | null): void {\r\n    this.workflowId$.next(event ?? undefined)\r\n    if(!event){\r\n      return\r\n    }\r\n    this.getSchema(event).pipe(\r\n        take(1),\r\n        tap(({ schema }) => {\r\n          this.schema$.next(schema)\r\n            const isEmptySchema = Object.keys( schema)[0] === \"\" && Object.values(schema)[0] === \"Array<>\"\r\n            const error = isEmptySchema \r\n            ? \"Document schema is missing. Please ensure at least one document exists for the selected workflow.\" \r\n            : undefined\r\n          this.schemaLoadError$.next(error)\r\n          this.runActivePipeline()\r\n        }),\r\n        catchError((error) => {\r\n          this.schemaLoadError$.next(\"Error loading schema\");\r\n          return this.handleError(error);\r\n        })\r\n    ).subscribe()\r\n  }\r\n\r\n  \r\n  setActiveStage(i:number|undefined){\r\n    const index = this.activeStage$.getValue()\r\n    if(index === i){\r\n      this.activeStage$.next(undefined)\r\n      return\r\n    }\r\n    this.activeStage$.next(i)\r\n\r\n    \r\n  }\r\n  addStage(): void {\r\n    // NOTE(phase-4): an empty object `{}` is not a valid `PipelineStage`; it acts as a sentinel\r\n    // \"blank slot\" until the user picks a stage type. Tracked — proper fix is a discriminated\r\n    // union `PipelineStage | { kind: 'blank' }` for the in-progress pipeline.\r\n    const blankSlot = {} as PipelineStage;\r\n    const newPipeline = this.pipeline$.getValue().concat(blankSlot);\r\n    this.pipeline$.next(newPipeline)\r\n  }\r\n  onTextChange(event: string | undefined): void {\r\n    this.prompt$.next(event)\r\n  }\r\n  promptSubmit() {\r\n    // Use combineLatest to fetch the latest values from multiple sources\r\n    combineLatest([this.schema$, this.threadId$, this.pipeline$,this.prompt$,this.chatHistory$])\r\n      .pipe(\r\n        take(1),\r\n        tap(() => {}),\r\n        filter(([schema,,,prompt]) => !!schema  && !!prompt ),\r\n        switchMap(([schema, threadId, pipeline,prompt,history]) => {\r\n          // Use a shallow copy of the pipeline\r\n          const previousError = history[history.length-1]?.assistance?.error ?? ''\r\n          const pipelineCopy = pipeline.map(stage => JSON.parse(JSON.stringify(stage))) || [];\r\n          // `prompt` is filtered to truthy above; assert via narrowing rather than `!`.\r\n          const safePrompt: string = prompt ?? '';\r\n          return this.generatePipeline(safePrompt, schema, threadId, pipelineCopy, previousError).pipe(\r\n            map((response) => ({ ...response,history,prompt: safePrompt}))\r\n          )\r\n        }),\r\n        tap((response) => {\r\n          const { pipeline, threadId,history,prompt } = response;\r\n          const historyRecord = {\r\n            user: prompt,\r\n            assistance: response,\r\n            date:new Date()\r\n          };\r\n  \r\n          // Use next with a concatenated value for chat history\r\n          this.chatHistory$.next([...(history||[]), historyRecord]);\r\n          this.pipeline$.next(pipeline);\r\n          this.threadId$.next(threadId);\r\n\r\n          // Store threadID locally\r\n          if (isPlatformBrowser(this.#platformId)) {\r\n            localStorage.setItem('threadId', threadId);\r\n          }\r\n  \r\n          // Run the active pipeline after all state updates are complete\r\n          this.runActivePipeline();\r\n        }),\r\n        catchError((error:IPipelineGenerationError) => {\r\n          return this.handleError(error);\r\n        })\r\n      ).subscribe();\r\n\r\n  }\r\n  \r\n  runActivePipeline() {\r\n    const pipeline = [...(this.pipeline$.getValue().map(stage => (JSON.parse(JSON.stringify(stage))))||[])]\r\n    const someAreNotValid = pipeline.some(stage=>Object.keys(stage).length ===0)\r\n    if(pipeline.length === 0 || someAreNotValid ){\r\n      return\r\n    }\r\n    try {\r\n       PipelineBuilder.validatePipeline(pipeline)\r\n    } catch {\r\n      return\r\n    }\r\n    const workflowId = this.workflowId$.getValue()\r\n    if (!workflowId) {\r\n      return\r\n    }\r\n  \r\n    this.runPipeLine(pipeline,workflowId).pipe(\r\n      take(1),\r\n      tap(({ results }) => {\r\n        this.pipeLineResult$.next(results)\r\n      }),\r\n      catchError((error) => {\r\n        const err = JSON.parse(JSON.stringify(error))\r\n        const errorMessage = err.error\r\n        if(errorMessage){\r\n          this.pipelineErrorLogAndRetry(errorMessage)\r\n        }\r\n        return this.handleError(error);\r\n      })\r\n    ).subscribe()\r\n  }\r\n\r\n  pipelineErrorLogAndRetry(message: string): void {\r\n    const history = this.chatHistory$.getValue();\r\n    const prompt = this.prompt$.getValue();\r\n    // NOTE(phase-4): the chatHistory `assistance` field is typed as a full\r\n    // `IPipelineGenerationResponse`, but the error path only carries `message`.\r\n    // Treat the partial record as a structural fill until the type is narrowed via\r\n    // a discriminated union `{ kind: 'ok', response } | { kind: 'error', message }`.\r\n    const partialAssistance: Partial<IPipelineGenerationResponse> = { message };\r\n    const historyRecord = {\r\n      user: prompt ?? '',\r\n      assistance: partialAssistance as IPipelineGenerationResponse,\r\n      date: new Date()\r\n    };\r\n    this.chatHistory$.next([...(history || []), historyRecord]);\r\n\r\n  }\r\n  get activeStage(): Observable<{ name: string; config: PipelineStage | undefined } | undefined> {\r\n    return this.pipeline$.asObservable().pipe(\r\n      switchMap(pipeline => this.activeStage$.pipe(\r\n        map(activeIndex => {\r\n          if (activeIndex === undefined) return undefined;\r\n          // Each `PipelineStage` in the union has exactly one operator key (e.g. `$match`).\r\n          // Read it through a typed `Record` lookup rather than casting the whole row.\r\n          const stage: PipelineStage | undefined = pipeline[activeIndex];\r\n          const stageRecord = (stage ?? {}) as Record<string, PipelineStage>;\r\n          const name = Object.keys(stageRecord)[0] ?? '';\r\n          return {\r\n            name,\r\n            config: stageRecord[name],\r\n          };\r\n        })\r\n      ))\r\n    )\r\n\r\n  }\r\n  saveStage(index: number, stage: IAllowedStage | undefined): void {\r\n    const pipeline = this.pipeline$.getValue()\r\n    if (index === undefined) {\r\n      return\r\n    }\r\n    const newPipeline: PipelineStage[] = pipeline.map((s, i) => {\r\n      if (i === index && stage) {\r\n        // NOTE(phase-4): building a `PipelineStage` from `{ [stage.stage]: stage.config }` is\r\n        // correct at runtime — the union member is keyed by the operator — but TS cannot prove\r\n        // the dynamic key matches a specific variant. Tracked for a per-stage builder fn.\r\n        const built: Record<string, unknown> = { [stage.stage]: stage.config };\r\n        // eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO(phase-4): per-stage builder fn would let TS narrow; internal-only service.\r\n        return built as any;\r\n      }\r\n      return s;\r\n    });\r\n\r\n    this.pipeline$.next(newPipeline)\r\n    this.activeStage$.next(undefined)\r\n    this.runActivePipeline()\r\n\r\n  }\r\n  deleteStage(index: number): void {\r\n    const pipeline = this.pipeline$.getValue()\r\n\r\n    if (index === undefined) {\r\n      return\r\n    }\r\n    const newPipeline: PipelineStage[] = pipeline.filter((_s, i) => i !== index);\r\n    this.pipeline$.next(newPipeline)\r\n    this.activeStage$.next(undefined)\r\n    this.runActivePipeline()\r\n  }\r\n  get pipelineGeneralValid(){\r\n    return this.pipeline$.asObservable().pipe(\r\n      map(pipeline=>{\r\n         const allHaveTypes = pipeline.every(stage=>Object.keys(stage).length === 1)\r\n         if(!allHaveTypes){\r\n           return {\r\n              valid:false,\r\n              message:\"All stages must be a valid pipeline stage\"\r\n           }\r\n         }\r\n         const AllStagesMustHaveConfig = pipeline.every((stage) => {\r\n            // Each PipelineStage union member has one operator key + value; reading via\r\n            // `Object.entries` keeps us off an `as unknown as Record<…>` cast.\r\n            const [firstEntry] = Object.entries(stage);\r\n            return firstEntry !== undefined && firstEntry[1] !== undefined;\r\n         })\r\n          if(!AllStagesMustHaveConfig){\r\n            return {\r\n              valid:false,\r\n              message:\"All stages must have a configuration\"\r\n            }\r\n          }\r\n          return {\r\n            valid:true\r\n          }\r\n      })\r\n    )\r\n  }\r\n}","import {\r\n  ChangeDetectionStrategy,\r\n  Component,\r\n  ViewEncapsulation,\r\n  computed,\r\n  input,\r\n  output,\r\n  signal,\r\n} from '@angular/core';\r\nimport PipelineBuilder from 'db-aggregation-pipeline-builder';\r\nimport { PipelineStageEnum } from 'ngx-t-forms-types';\r\n\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatCardModule } from '@angular/material/card';\r\nimport { MatDividerModule } from '@angular/material/divider';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatSelectModule, MatSelectChange } from '@angular/material/select';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\n\r\nimport { JsonEditorComponent, JsonEditorChange } from '../../../json-editor/json-editor.component';\r\nimport { IAllowedStage } from '../../../../../../services/httpResources/Pipeline/pipeline.service';\r\n\r\n/**\r\n * One row of the in-progress pipeline as surfaced by the pipeline generator:\r\n * the operator key (`name`/`stage`), its opaque config object, and a validity flag.\r\n */\r\nexport interface PipelineStageRow {\r\n  /** Operator key, e.g. `$match`. Absent on a freshly added blank slot. */\r\n  readonly name: string | undefined;\r\n  /** Mirror of {@link name}; both keys exist for template/legacy parity. */\r\n  readonly stage: string | undefined;\r\n  /** Stage-specific configuration; heterogeneous per operator, hence opaque here. */\r\n  readonly config: unknown;\r\n  /** Whether the row currently passes stage-config validation. */\r\n  readonly valid: boolean;\r\n}\r\n\r\n/** Selectable aggregate stage with its human description. */\r\ninterface AllowedStage {\r\n  readonly stage: PipelineStageEnum;\r\n  readonly description: string;\r\n}\r\n\r\n/** Working draft of the stage being edited. `stage` is absent until the user picks one. */\r\ninterface StageDraft {\r\n  readonly stage: PipelineStageEnum | undefined;\r\n  readonly config: unknown;\r\n  readonly valid: boolean;\r\n}\r\n\r\n/**\r\n * Embedded aggregate-pipeline stage editor used inside `lib-pipeline-generator`.\r\n * Lets the user pick a `$stage` operator and edit its JSON configuration (via\r\n * `lib-json-editor`), validating the config against the pipeline builder.\r\n *\r\n * Not part of the public API.\r\n *\r\n * @example\r\n *   <lib-aggregate-stage-editor\r\n *     [selectedStage]=\"stage\"\r\n *     [isRunningPipeline]=\"running\"\r\n *     (saveStage)=\"onSave($event)\"\r\n *     (deleteStage)=\"onDelete()\" />\r\n */\r\n@Component({\r\n  selector: 'lib-aggregate-stage-editor',\r\n  templateUrl: './aggregate-stage-editor.component.html',\r\n  styleUrls: ['./aggregate-stage-editor.component.scss'],\r\n  changeDetection: ChangeDetectionStrategy.OnPush,\r\n  encapsulation: ViewEncapsulation.Emulated,\r\n  host: { 'class': 'lib-aggregate-stage-editor' },\r\n  imports: [\r\n    JsonEditorComponent,\r\n    MatButtonModule,\r\n    MatCardModule,\r\n    MatDividerModule,\r\n    MatIconModule,\r\n    MatFormFieldModule,\r\n    MatSelectModule,\r\n    MatTooltipModule,\r\n  ],\r\n})\r\nexport class AggregateStageEditorComponent {\r\n  /** Stage currently being edited (one row of the pipeline generator state). */\r\n  readonly selectedStage = input<PipelineStageRow | undefined>(undefined);\r\n\r\n  /** When the parent pipeline is executing, destructive/save actions are disabled. */\r\n  readonly isRunningPipeline = input<boolean>(false);\r\n\r\n  /** Emits the prepared stage when the user saves a valid configuration. */\r\n  readonly saveStage = output<IAllowedStage | undefined>();\r\n\r\n  /** Emits when the user requests the active stage be removed. */\r\n  readonly deleteStage = output<void>();\r\n\r\n  /** Stages the user can choose from (loaded once from the pipeline builder). */\r\n  protected readonly allowedStages: readonly AllowedStage[] =\r\n    PipelineBuilder.getViewOnlyStages();\r\n\r\n  /** Working draft of the stage being edited; `undefined` until the user edits. */\r\n  readonly #draft = signal<StageDraft | undefined>(undefined);\r\n\r\n  /** Validation message from the last config check, or `undefined` when valid. */\r\n  protected readonly configValidationError = signal<string | undefined>(undefined);\r\n\r\n  /** Resolved operator key for the select control (draft first, else the input). */\r\n  protected readonly currentStage = computed<string | undefined>(\r\n    () => this.#draft()?.stage ?? this.selectedStage()?.name,\r\n  );\r\n\r\n  /** Config value passed to the JSON editor (draft first, else the input). */\r\n  protected readonly currentConfig = computed<object | undefined>(() => {\r\n    const config = this.#draft()?.config ?? this.selectedStage()?.config;\r\n    return this.#asObject(config);\r\n  });\r\n\r\n  /** Whether the editing surface (operator picker is set or config present) shows. */\r\n  protected readonly showConfig = computed<boolean>(\r\n    () => this.#draft() !== undefined || this.selectedStage()?.config !== undefined,\r\n  );\r\n\r\n  /** Human description for the currently selected operator, if any. */\r\n  protected readonly activeDescription = computed<string | undefined>(\r\n    () => this.allowedStages.find((s) => s.stage === this.currentStage())?.description,\r\n  );\r\n\r\n  /** Whether the Save action is enabled: a draft exists, is valid and error-free. */\r\n  protected readonly canSave = computed<boolean>(() => {\r\n    const draft = this.#draft();\r\n    return draft !== undefined && draft.valid === true && this.configValidationError() === undefined;\r\n  });\r\n\r\n  protected handleStageChange(event: MatSelectChange): void {\r\n    const stage = event.value as PipelineStageEnum;\r\n    // BEHAVIOUR FIX: the previous implementation spread the source row AFTER\r\n    // setting `stage`, which silently reverted the operator to its prior value.\r\n    // Here the newly picked operator always wins; the existing config carries over.\r\n    const config = this.#draft()?.config ?? this.selectedStage()?.config;\r\n    this.#draft.set({ stage, config, valid: false });\r\n    this.#validate();\r\n  }\r\n\r\n  protected handleConfigChange(change: JsonEditorChange): void {\r\n    const stage = this.#draft()?.stage ?? this.#stageFromRow();\r\n    this.#draft.set({ stage, config: change.value, valid: false });\r\n    this.#validate();\r\n  }\r\n\r\n  protected saveConfiguration(): void {\r\n    const draft = this.#draft();\r\n    if (this.canSave() && draft?.stage) {\r\n      this.saveStage.emit({\r\n        stage: draft.stage,\r\n        description: this.activeDescription() ?? '',\r\n        config: draft.config,\r\n        valid: draft.valid,\r\n      });\r\n    }\r\n  }\r\n\r\n  protected deleteActive(): void {\r\n    this.deleteStage.emit();\r\n  }\r\n\r\n  protected trackByStage(stage: AllowedStage): string {\r\n    return stage.stage;\r\n  }\r\n\r\n  /** Validates the working draft against the pipeline builder, updating state. */\r\n  #validate(): void {\r\n    this.configValidationError.set(undefined);\r\n    const draft = this.#draft();\r\n    if (!draft) return;\r\n\r\n    const { config, stage } = draft;\r\n    if ((config === undefined || config === null) || !stage) {\r\n      this.#draft.set({ ...draft, valid: false });\r\n      return;\r\n    }\r\n\r\n    try {\r\n      const valid = PipelineBuilder.validateStageConfig(stage, config);\r\n      this.#draft.set({ ...draft, valid });\r\n    } catch (error: unknown) {\r\n      const message = error instanceof Error ? error.message : 'An unknown error occurred';\r\n      this.configValidationError.set(message);\r\n      this.#draft.set({ ...draft, valid: false });\r\n    }\r\n  }\r\n\r\n  /** Reads the operator key from the input row as a typed enum, if recognised. */\r\n  #stageFromRow(): PipelineStageEnum | undefined {\r\n    const name = this.selectedStage()?.name;\r\n    return this.allowedStages.find((s) => s.stage === name)?.stage;\r\n  }\r\n\r\n  /** Narrows an opaque config value to the `object | undefined` the JSON editor accepts. */\r\n  #asObject(value: unknown): object | undefined {\r\n    return value !== null && typeof value === 'object' ? value : undefined;\r\n  }\r\n}\r\n","<mat-card class=\"lib-aggregate-stage-editor__card\" appearance=\"outlined\">\r\n  <mat-card-content>\r\n    <p class=\"lib-aggregate-stage-editor__title\">Aggregate pipeline stage configuration</p>\r\n\r\n    <mat-form-field\r\n      class=\"lib-aggregate-stage-editor__field\"\r\n      appearance=\"outline\"\r\n      subscriptSizing=\"dynamic\">\r\n      <mat-label>Select aggregate stage</mat-label>\r\n      <mat-select\r\n        [value]=\"currentStage()\"\r\n        (selectionChange)=\"handleStageChange($event)\"\r\n        placeholder=\"Choose a stage operator\">\r\n        @for (stage of allowedStages; track trackByStage(stage)) {\r\n          <mat-option [value]=\"stage.stage\">{{ stage.stage }}</mat-option>\r\n        }\r\n      </mat-select>\r\n      <mat-hint>\r\n        {{ activeDescription()\r\n          ? 'Hover the info icon to view stage details.'\r\n          : 'Select an aggregation operator from the list.' }}\r\n      </mat-hint>\r\n      @if (activeDescription(); as description) {\r\n        <mat-icon\r\n          class=\"lib-aggregate-stage-editor__hint-icon\"\r\n          matSuffix\r\n          matTooltipHideDelay=\"1000\"\r\n          [matTooltip]=\"description\">info</mat-icon>\r\n      }\r\n    </mat-form-field>\r\n\r\n    @if (configValidationError(); as error) {\r\n      <div class=\"lib-aggregate-stage-editor__warning\" role=\"alert\">\r\n        <mat-icon aria-hidden=\"true\">warning</mat-icon>\r\n        <span>{{ error }}</span>\r\n      </div>\r\n    }\r\n\r\n    @if (showConfig()) {\r\n      <div class=\"lib-aggregate-stage-editor__config\">\r\n        <lib-json-editor [value]=\"currentConfig()\" (valueChange)=\"handleConfigChange($event)\" />\r\n      </div>\r\n    }\r\n  </mat-card-content>\r\n\r\n  <mat-divider />\r\n\r\n  <mat-card-actions class=\"lib-aggregate-stage-editor__actions\" align=\"end\">\r\n    <button\r\n      mat-button\r\n      type=\"button\"\r\n      color=\"warn\"\r\n      [disabled]=\"isRunningPipeline()\"\r\n      (click)=\"deleteActive()\">\r\n      Delete\r\n      <mat-icon>delete</mat-icon>\r\n    </button>\r\n    <button\r\n      mat-flat-button\r\n      type=\"button\"\r\n      color=\"primary\"\r\n      [disabled]=\"isRunningPipeline() || !canSave()\"\r\n      (click)=\"saveConfiguration()\">\r\n      Save\r\n      <mat-icon>save</mat-icon>\r\n    </button>\r\n  </mat-card-actions>\r\n</mat-card>\r\n","import { isPlatformBrowser, JsonPipe } from '@angular/common';\r\nimport {\r\n  ChangeDetectionStrategy,\r\n  Component,\r\n  DestroyRef,\r\n  ElementRef,\r\n  Input,\r\n  OnDestroy,\r\n  OnInit,\r\n  Optional,\r\n  PLATFORM_ID,\r\n  Self,\r\n  ViewEncapsulation,\r\n  computed,\r\n  inject,\r\n  output,\r\n  signal,\r\n  viewChild,\r\n} from '@angular/core';\r\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\r\nimport { FormsModule, NgControl } from '@angular/forms';\r\nimport { MatFormFieldControl } from '@angular/material/form-field';\r\nimport { distinctUntilChanged, map, Observable, Subject, take } from 'rxjs';\r\nimport { IWorkflowOption, MongoDbPipeLineConfigInterface } from 'ngx-t-forms-types';\r\n\r\nimport { OverlayModule } from '@angular/cdk/overlay';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatDividerModule } from '@angular/material/divider';\r\nimport { MatExpansionModule } from '@angular/material/expansion';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatListModule } from '@angular/material/list';\r\nimport { MatProgressSpinnerModule } from '@angular/material/progress-spinner';\r\nimport { MatToolbarModule } from '@angular/material/toolbar';\r\n\r\nimport type { IConfigElementError } from '../../t-dynamic-data-edit.component';\r\nimport { TDynamicDataViewComponent } from '../../../t-dynamic-data-view/t-dynamic-data-view.component';\r\nimport { TWorkflowPickerComponent } from '../t-workflow-picker/t-workflow-picker.component';\r\nimport { EmptyStateComponent } from '../_shared/empty-state/empty-state.component';\r\nimport { DaysAgoPipe } from '../../../../../lib/shared/pipes/date/days-ago.pipe';\r\nimport { IAllowedStage, PipelineService } from '../../../../../lib/services/httpResources/Pipeline/pipeline.service';\r\nimport { _isEqual } from '../../../../shared/functions/isEqual';\r\nimport {\r\n  AggregateStageEditorComponent,\r\n  PipelineStageRow,\r\n} from './elements/aggregate-stage-editor/aggregate-stage-editor.component';\r\n\r\n/** Property-suggestion chip surfaced under the AI prompt as the user types `$`. */\r\ninterface SchemaProperty {\r\n  readonly label: string;\r\n  readonly value: string;\r\n}\r\n\r\n/**\r\n * Internal editor for `editType = MongoPipelineBuilder`. Implements\r\n * `MatFormFieldControl` so it can be embedded inside a `mat-form-field`, and\r\n * drives a MongoDB aggregation-pipeline builder (stage list, results preview,\r\n * AI prompt) via a component-scoped {@link PipelineService}.\r\n *\r\n * Not part of the public API.\r\n *\r\n * @deprecated The MongoDB pipeline builder (`editType = MongoPipelineBuilder`)\r\n *   is deprecated and no longer offered as a selectable editor option (filtered\r\n *   out in `getSectionElements`). It is retained only to render already-configured\r\n *   (legacy) inputs and the `data-source-picker` MongoDB-pipeline data source.\r\n *   Do not wire it to any new editor option.\r\n */\r\n@Component({\r\n  selector: 'lib-pipeline-generator',\r\n  templateUrl: './pipeline-generator.component.html',\r\n  styleUrls: ['./pipeline-generator.component.scss'],\r\n  changeDetection: ChangeDetectionStrategy.OnPush,\r\n  encapsulation: ViewEncapsulation.Emulated,\r\n  imports: [\r\n    JsonPipe,\r\n    FormsModule,\r\n    OverlayModule,\r\n    MatButtonModule,\r\n    MatDividerModule,\r\n    MatExpansionModule,\r\n    MatIconModule,\r\n    MatListModule,\r\n    MatProgressSpinnerModule,\r\n    MatToolbarModule,\r\n    TWorkflowPickerComponent,\r\n    TDynamicDataViewComponent,\r\n    AggregateStageEditorComponent,\r\n    EmptyStateComponent,\r\n    DaysAgoPipe,\r\n  ],\r\n  // Each pipeline generator owns a private PipelineService instance so concurrent\r\n  // editors never cross-pollinate state (stage list, chat history, results).\r\n  providers: [\r\n    PipelineService,\r\n    // MatFormFieldControl pattern: useExisting + the @Input() value/disabled/id\r\n    // members are framework wiring and stay together (CLAUDE.md MFC carve-out).\r\n    { provide: MatFormFieldControl, useExisting: PipelineGeneratorComponent },\r\n  ],\r\n  host: {\r\n    'class': 'lib-pipeline-generator',\r\n    '[id]': 'id',\r\n  },\r\n})\r\nexport class PipelineGeneratorComponent\r\n  implements OnInit, OnDestroy, MatFormFieldControl<MongoDbPipeLineConfigInterface>\r\n{\r\n  static nextId = 0;\r\n\r\n  readonly stateChanges = new Subject<void>();\r\n\r\n  readonly #platformId = inject(PLATFORM_ID);\r\n  readonly #destroyRef = inject(DestroyRef);\r\n  readonly #pipeline = inject(PipelineService);\r\n\r\n  // MFC requires a plain mutable `id` field (string) — cannot be a signal.\r\n  id = `app-pipeline-generator-${PipelineGeneratorComponent.nextId++}`;\r\n\r\n  placeholder = '';\r\n  focused = false;\r\n  required = false;\r\n  touched = false;\r\n  @Input() disabled = false;\r\n\r\n  controlType = 'lib-pipeline-generator';\r\n  autofilled?: boolean;\r\n  userAriaDescribedBy?: string;\r\n  disableAutomaticLabeling?: boolean;\r\n\r\n  constructor(\r\n    @Optional() @Self() public ngControl: NgControl,\r\n    private readonly _elementRef: ElementRef<HTMLElement>,\r\n  ) {}\r\n\r\n  // ---- MatFormFieldControl value ------------------------------------------\r\n\r\n  #value!: MongoDbPipeLineConfigInterface;\r\n\r\n  // MFC value setter — kept as @Input() (framework wiring).\r\n  @Input() set value(value: MongoDbPipeLineConfigInterface) {\r\n    const workflowIdChanged = this.#value?.workflowId !== value?.workflowId;\r\n    const pipelineChanged = !_isEqual(this.#value?.pipeline, value?.pipeline);\r\n    if (workflowIdChanged || pipelineChanged) {\r\n      this.#value = value;\r\n      if (value?.workflowId) {\r\n        this.workflowChanged(value.workflowId);\r\n      }\r\n      if (value?.pipeline) {\r\n        this.#pipeline.pipeline$.next(value.pipeline);\r\n      }\r\n      this.stateChanges.next();\r\n    }\r\n  }\r\n  get value(): MongoDbPipeLineConfigInterface {\r\n    return this.#value;\r\n  }\r\n\r\n  // ---- Other public inputs / outputs --------------------------------------\r\n\r\n  #workflows$: Observable<IWorkflowOption[] | undefined> | undefined;\r\n  /** Source of workflow options forwarded to the embedded workflow picker. */\r\n  @Input() set getWorkflowOptions(options$: Observable<IWorkflowOption[] | undefined> | undefined) {\r\n    this.#workflows$ = options$;\r\n  }\r\n  get getWorkflowOptions(): Observable<IWorkflowOption[] | undefined> | undefined {\r\n    return this.#workflows$;\r\n  }\r\n\r\n  /** Display name of the current user (reserved for AI prompt attribution). */\r\n  @Input() userName: string | undefined;\r\n\r\n  /** Validation errors surfaced by the parent for error-state derivation. */\r\n  @Input() set errors(value: IConfigElementError[] | undefined) {\r\n    this.#errors = value;\r\n  }\r\n  get errors(): IConfigElementError[] | undefined {\r\n    return this.#errors;\r\n  }\r\n  #errors: IConfigElementError[] | undefined = [];\r\n\r\n  /** Emits the updated pipeline configuration whenever the builder state changes. */\r\n  readonly valueChanged = output<MongoDbPipeLineConfigInterface>();\r\n\r\n  // ---- MatFormFieldControl derived state ----------------------------------\r\n\r\n  get empty(): boolean {\r\n    return !this.#value;\r\n  }\r\n  get shouldLabelFloat(): boolean {\r\n    return this.focused || !this.empty;\r\n  }\r\n  get errorState(): boolean {\r\n    const externalError = (this.#errors?.length ?? 0) > 0 && this.touched;\r\n    const ngControlError = this.ngControl?.control?.errors != null;\r\n    return (!this.#value && this.required) || externalError || ngControlError;\r\n  }\r\n\r\n  setDescribedByIds(ids: string[]): void {\r\n    if (!isPlatformBrowser(this.#platformId)) return;\r\n    // DEFECT FIX: the original queried `.app-pipeline-generator`, a class that\r\n    // never existed in the template, so describedBy was silently dropped. Apply\r\n    // it to the host element instead.\r\n    this._elementRef.nativeElement.setAttribute('aria-describedby', ids.join(' '));\r\n  }\r\n\r\n  onContainerClick(): void {\r\n    this.markAsTouched();\r\n    this.stateChanges.next();\r\n  }\r\n\r\n  onTouched = (): void => {};\r\n  markAsTouched(): void {\r\n    if (!this.touched) {\r\n      this.onTouched();\r\n      this.touched = true;\r\n    }\r\n  }\r\n\r\n  // ---- Reactive view state (signals over | async) -------------------------\r\n\r\n  protected readonly workflowId = toSignal(this.#pipeline.workflowId$, { initialValue: undefined });\r\n  protected readonly activeStageIndex = toSignal(this.#pipeline.activeStage$, { initialValue: undefined });\r\n  protected readonly pipeLineResults = toSignal(this.#pipeline.pipeLineResult$, { initialValue: undefined });\r\n  protected readonly prompt = toSignal(this.#pipeline.prompt$, { initialValue: undefined });\r\n  protected readonly schemaLoadError = toSignal(this.#pipeline.schemaLoadError$, { initialValue: undefined });\r\n  protected readonly chatHistory = toSignal(this.#pipeline.chatHistory$, { initialValue: [] });\r\n\r\n  /** Pipeline stages projected into the row shape the template + stage editor consume. */\r\n  protected readonly stages = toSignal(\r\n    this.#pipeline.pipeline$.pipe(\r\n      map((stages) =>\r\n        stages.map((stage, index): PipelineStageRow & { readonly id: number } => {\r\n          const [name, config] = Object.entries(stage ?? {}).at(0) ?? [undefined, undefined];\r\n          return {\r\n            id: index,\r\n            name,\r\n            stage: name,\r\n            config,\r\n            valid: name !== undefined && config !== undefined,\r\n          };\r\n        }),\r\n      ),\r\n    ),\r\n    { initialValue: [] },\r\n  );\r\n\r\n  /** Schema document properties filtered by the live suggestion search. */\r\n  protected readonly schema = toSignal(this.#pipeline.schema$, { initialValue: undefined });\r\n  protected readonly optionsSearch = signal('');\r\n  protected readonly schemaProperties = computed<SchemaProperty[]>(() => {\r\n    const search = this.optionsSearch().toLowerCase();\r\n    return Object.keys(this.schema() ?? {})\r\n      .map((key) => ({ label: key, value: key }))\r\n      .filter((entry) => (search ? entry.label.toLowerCase().includes(search) : true));\r\n  });\r\n\r\n  protected get isRunningPipeline(): boolean {\r\n    return this.#pipeline.isRunningPipeline;\r\n  }\r\n  protected get aiIsGeneratingPipeline(): boolean {\r\n    return this.#pipeline.aiIsGeneratingPipeline;\r\n  }\r\n\r\n  protected readonly showSuggestions = signal(false);\r\n\r\n  private readonly textareaRef = viewChild<ElementRef<HTMLTextAreaElement>>('textarea');\r\n\r\n  // ---- Lifecycle: emit config changes -------------------------------------\r\n\r\n  #initiated = false;\r\n\r\n  ngOnInit(): void {\r\n    // Skip the first (current) config emission so an inbound value does not\r\n    // immediately echo back out as a \"change\".\r\n    this.#pipeline.config$\r\n      .pipe(\r\n        distinctUntilChanged((prev, curr) => _isEqual(prev, curr)),\r\n        takeUntilDestroyed(this.#destroyRef),\r\n      )\r\n      .subscribe((config) => {\r\n        if (!this.#initiated) {\r\n          this.#initiated = true;\r\n          return;\r\n        }\r\n        const newConfig: MongoDbPipeLineConfigInterface = {\r\n          ...this.#value,\r\n          ...config,\r\n          name: this.#workflowName ?? 'Unnamed Pipeline',\r\n          source: 'mongoPipeline',\r\n        } as MongoDbPipeLineConfigInterface;\r\n        this.valueChanged.emit(newConfig);\r\n      });\r\n  }\r\n\r\n  ngOnDestroy(): void {\r\n    this.stateChanges.complete();\r\n  }\r\n\r\n  // ---- Workflow picker -----------------------------------------------------\r\n\r\n  #workflowName: string | undefined;\r\n\r\n  workflowChanged(workflowId: string | undefined): void {\r\n    // BEHAVIOUR FLAG: switching to a *different* workflow clears the AI chat\r\n    // history so prior suggestions for another collection do not leak into the\r\n    // new context. Re-setting the same workflow (e.g. an inbound value echo)\r\n    // leaves the chat intact.\r\n    if (this.#pipeline.workflowId$.getValue() !== workflowId) {\r\n      this.#pipeline.chatHistory$.next([]);\r\n    }\r\n    this.#pipeline.workflowChanged(workflowId);\r\n  }\r\n\r\n  workflowNameChanged(name: string | undefined): void {\r\n    this.#workflowName = name;\r\n  }\r\n\r\n  // ---- Stage management ----------------------------------------------------\r\n\r\n  protected trackByStageId(_index: number, stage: { readonly id: number }): number {\r\n    return stage.id;\r\n  }\r\n\r\n  protected setActiveStage(index: number | undefined): void {\r\n    this.#pipeline.setActiveStage(index);\r\n  }\r\n  protected addStage(): void {\r\n    this.#pipeline.addStage();\r\n  }\r\n  protected deleteStage(index: number): void {\r\n    this.#pipeline.deleteStage(index);\r\n  }\r\n  protected saveStage(index: number, stage: IAllowedStage | undefined): void {\r\n    this.#pipeline.saveStage(index, stage);\r\n    this.setActiveStage(undefined);\r\n  }\r\n\r\n  // ---- AI prompt -----------------------------------------------------------\r\n\r\n  #cursorPosition = 0;\r\n\r\n  protected onTextChange(event: Event): void {\r\n    const textarea = this.textareaRef()?.nativeElement;\r\n    if (!textarea) return;\r\n\r\n    const newValue = (event.target as HTMLTextAreaElement).value;\r\n    this.#cursorPosition = textarea.selectionStart ?? 0;\r\n\r\n    const lastChar = newValue[this.#cursorPosition - 1];\r\n    const match = newValue.slice(0, this.#cursorPosition).match(/\\$(\\w*)$/);\r\n\r\n    if (lastChar === '$' || (match && match[1] !== undefined)) {\r\n      this.showSuggestions.set(true);\r\n      this.optionsSearch.set(match?.[1] ?? '');\r\n    } else {\r\n      this.showSuggestions.set(false);\r\n      this.optionsSearch.set('');\r\n    }\r\n\r\n    this.#pipeline.onTextChange(newValue);\r\n  }\r\n\r\n  protected selectSuggestion(suggestion: string): void {\r\n    this.#pipeline.prompt$\r\n      .pipe(take(1), takeUntilDestroyed(this.#destroyRef))\r\n      .subscribe((prompt) => {\r\n        const match = prompt?.slice(0, this.#cursorPosition).match(/\\$(\\w*)$/);\r\n        const beforeCursor = prompt?.slice(0, match ? match.index : this.#cursorPosition - 1) ?? '';\r\n        const afterCursor = prompt?.slice(this.#cursorPosition) ?? '';\r\n        const updated = `${beforeCursor}${suggestion} ${afterCursor}`;\r\n        this.#pipeline.prompt$.next(updated);\r\n        this.#applySuggestionToTextarea(suggestion);\r\n      });\r\n  }\r\n\r\n  #applySuggestionToTextarea(suggestion: string): void {\r\n    this.showSuggestions.set(false);\r\n    if (!isPlatformBrowser(this.#platformId)) return;\r\n    const textarea = this.textareaRef()?.nativeElement;\r\n    if (!textarea) return;\r\n    textarea.focus();\r\n    const nextPosition = this.#cursorPosition + suggestion.length;\r\n    setTimeout(() => textarea.setSelectionRange(nextPosition, nextPosition), 0);\r\n  }\r\n\r\n  protected promptSubmit(): void {\r\n    this.#pipeline.promptSubmit();\r\n  }\r\n}\r\n","<p class=\"lib-pipeline-generator__intro\">\r\n  MongoDB aggregation pipeline builder for the selected workflow.\r\n</p>\r\n\r\n<lib-t-workflow-picker\r\n  [getWorkflowOptions]=\"getWorkflowOptions\"\r\n  [value]=\"workflowId() || undefined\"\r\n  (valueChanged)=\"workflowChanged($event)\"\r\n  (workflowNameChanged)=\"workflowNameChanged($event)\" />\r\n\r\n@if (workflowId()) {\r\n  <mat-accordion class=\"lib-pipeline-generator__accordion\" multi>\r\n\r\n    <!-- Pipeline stages -->\r\n    <mat-expansion-panel value=\"pipeline\">\r\n      <mat-expansion-panel-header>\r\n        <mat-panel-title>\r\n          @if (isRunningPipeline) {\r\n            <mat-spinner class=\"lib-pipeline-generator__header-spinner\" diameter=\"20\" />\r\n          }\r\n          <mat-icon class=\"lib-pipeline-generator__title-icon\">dynamic_form</mat-icon>\r\n          {{ isRunningPipeline ? 'Executing data pipeline…' : 'Data retrieval pipeline' }}\r\n        </mat-panel-title>\r\n      </mat-expansion-panel-header>\r\n\r\n      <div class=\"lib-pipeline-generator__content\">\r\n        @if (stages().length === 0) {\r\n          <lib-empty-state\r\n            icon=\"account_tree\"\r\n            message=\"Add stages to the pipeline below. Each stage filters, groups, or calculates values; its output documents flow into the next stage.\" />\r\n        }\r\n\r\n        <mat-nav-list class=\"lib-pipeline-generator__stages\">\r\n          @for (stage of stages(); track trackByStageId($index, stage)) {\r\n            <mat-list-item\r\n              class=\"lib-pipeline-generator__stage\"\r\n              [class.lib-pipeline-generator__stage--active]=\"activeStageIndex() === $index\"\r\n              [activated]=\"activeStageIndex() === $index\"\r\n              (click)=\"setActiveStage($index)\">\r\n              <span class=\"lib-pipeline-generator__stage-index\" matListItemAvatar>{{ $index + 1 }}</span>\r\n              <div matListItemTitle>\r\n                <div class=\"lib-pipeline-generator__stage-name\">{{ stage.name || 'Stage' }}</div>\r\n                @if (!stage.name && activeStageIndex() !== $index) {\r\n                  <div class=\"lib-pipeline-generator__stage-hint\">Incomplete — click to edit</div>\r\n                }\r\n              </div>\r\n\r\n              @if (activeStageIndex() === $index) {\r\n                <mat-icon matListItemMeta color=\"primary\">check_circle</mat-icon>\r\n              } @else if (!stage.valid) {\r\n                <mat-icon matListItemMeta color=\"warn\">warning</mat-icon>\r\n              }\r\n            </mat-list-item>\r\n            <mat-divider />\r\n\r\n            @if (activeStageIndex() === $index) {\r\n              <lib-aggregate-stage-editor\r\n                [selectedStage]=\"stage\"\r\n                [isRunningPipeline]=\"isRunningPipeline\"\r\n                (deleteStage)=\"deleteStage($index)\"\r\n                (saveStage)=\"saveStage($index, $event)\" />\r\n            }\r\n          }\r\n\r\n          <mat-toolbar class=\"lib-pipeline-generator__toolbar\">\r\n            <span class=\"lib-pipeline-generator__spacer\"></span>\r\n            <button\r\n              mat-flat-button\r\n              type=\"button\"\r\n              color=\"primary\"\r\n              class=\"lib-pipeline-generator__add\"\r\n              [disabled]=\"isRunningPipeline\"\r\n              (click)=\"addStage()\">\r\n              Add\r\n              <mat-icon>add</mat-icon>\r\n            </button>\r\n          </mat-toolbar>\r\n        </mat-nav-list>\r\n      </div>\r\n    </mat-expansion-panel>\r\n\r\n    <!-- Results -->\r\n    <mat-expansion-panel value=\"results\">\r\n      <mat-expansion-panel-header>\r\n        <mat-panel-title>\r\n          @if (isRunningPipeline) {\r\n            <mat-spinner class=\"lib-pipeline-generator__header-spinner\" diameter=\"20\" />\r\n          }\r\n          <mat-icon class=\"lib-pipeline-generator__title-icon\">dataset</mat-icon>\r\n          {{ isRunningPipeline ? 'Running pipeline…' : 'Data results' }}\r\n        </mat-panel-title>\r\n      </mat-expansion-panel-header>\r\n\r\n      <div class=\"lib-pipeline-generator__content\">\r\n        @if (pipeLineResults(); as results) {\r\n          <lib-t-dynamic-data-view [data]=\"results\" />\r\n        } @else {\r\n          <lib-empty-state icon=\"dataset\" message=\"No results available\" />\r\n        }\r\n      </div>\r\n    </mat-expansion-panel>\r\n\r\n    <!-- AI agent -->\r\n    <mat-expansion-panel value=\"ai\">\r\n      <mat-expansion-panel-header>\r\n        <mat-panel-title>\r\n          @if (aiIsGeneratingPipeline) {\r\n            <mat-spinner class=\"lib-pipeline-generator__header-spinner\" diameter=\"20\" />\r\n          }\r\n          <mat-icon class=\"lib-pipeline-generator__title-icon\">tips_and_updates</mat-icon>\r\n          {{ aiIsGeneratingPipeline ? 'Agent busy…' : 'AI agent prompt' }}\r\n        </mat-panel-title>\r\n      </mat-expansion-panel-header>\r\n\r\n      <div class=\"lib-pipeline-generator__content\">\r\n        @if (schemaLoadError(); as schemaLoadError) {\r\n          <div class=\"lib-pipeline-generator__warning\" role=\"alert\">\r\n            <mat-icon aria-hidden=\"true\">error</mat-icon>\r\n            <span>{{ schemaLoadError }}</span>\r\n          </div>\r\n        }\r\n\r\n        @for (chat of chatHistory(); track $index) {\r\n          <div class=\"lib-pipeline-generator__chat\">\r\n            <div class=\"lib-pipeline-generator__bubble lib-pipeline-generator__bubble--user\">\r\n              <div>{{ chat.user }}</div>\r\n              <div class=\"lib-pipeline-generator__bubble-meta\">\r\n                {{ chat.date | daysAgo }}\r\n                <mat-icon class=\"lib-pipeline-generator__sent-icon\">done_all</mat-icon>\r\n              </div>\r\n            </div>\r\n\r\n            <div class=\"lib-pipeline-generator__assistant\">\r\n              <mat-icon class=\"lib-pipeline-generator__assistant-icon\">smart_toy</mat-icon>\r\n              @if (chat.assistance.error) {\r\n                <div class=\"lib-pipeline-generator__bubble lib-pipeline-generator__bubble--error\">\r\n                  {{ chat.assistance.error }}\r\n                </div>\r\n              } @else {\r\n                <div class=\"lib-pipeline-generator__bubble lib-pipeline-generator__bubble--bot\">\r\n                  <pre>{{ chat.assistance.pipeline | json }}</pre>\r\n                </div>\r\n              }\r\n            </div>\r\n          </div>\r\n        }\r\n\r\n        <div class=\"lib-pipeline-generator__composer\">\r\n          <textarea\r\n            #textarea\r\n            class=\"lib-pipeline-generator__textarea\"\r\n            [value]=\"prompt() || ''\"\r\n            (input)=\"onTextChange($event)\"\r\n            placeholder=\"Provide a pipeline generation prompt\"></textarea>\r\n          <button\r\n            mat-mini-fab\r\n            type=\"button\"\r\n            color=\"primary\"\r\n            class=\"lib-pipeline-generator__send\"\r\n            [disabled]=\"aiIsGeneratingPipeline\"\r\n            (click)=\"promptSubmit()\">\r\n            @if (aiIsGeneratingPipeline) {\r\n              <mat-spinner class=\"lib-pipeline-generator__send-spinner\" diameter=\"24\" />\r\n            } @else {\r\n              <mat-icon>send</mat-icon>\r\n            }\r\n          </button>\r\n        </div>\r\n\r\n        @if (showSuggestions()) {\r\n          <section class=\"lib-pipeline-generator__suggestions\">\r\n            <mat-divider />\r\n            <p class=\"lib-pipeline-generator__suggestions-label\">Collection document properties</p>\r\n            <div class=\"lib-pipeline-generator__suggestion-list\">\r\n              @for (property of schemaProperties(); track property.value) {\r\n                <button\r\n                  mat-stroked-button\r\n                  type=\"button\"\r\n                  class=\"lib-pipeline-generator__suggestion\"\r\n                  (click)=\"selectSuggestion(property.value)\">\r\n                  {{ property.label }}\r\n                </button>\r\n              }\r\n            </div>\r\n          </section>\r\n        }\r\n      </div>\r\n    </mat-expansion-panel>\r\n  </mat-accordion>\r\n}\r\n\r\n<ng-template cdkConnectedOverlay [cdkConnectedOverlayOpen]=\"disabled\">\r\n  <div class=\"lib-pipeline-generator__scrim\"></div>\r\n</ng-template>\r\n"],"names":["i1","i2","i4","i5","i7","i3","i6","i8"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;;;;;;;;AAcG;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