{"version":3,"file":"ngx-t-forms-conditional-display-config.component-Cmf7gDfO.mjs","sources":["../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/conditional-display-config/conditional-display-config.component.ts","../../../projects/ngx-t-forms/src/lib/components/t-dynamic-data-edit/elements/conditional-display-config/conditional-display-config.component.html"],"sourcesContent":["import {\n  ChangeDetectionStrategy,\n  Component,\n  ElementRef,\n  Input,\n  type OnChanges,\n  type OnDestroy,\n  type SimpleChanges,\n  ViewEncapsulation,\n  computed,\n  inject,\n  input,\n  output,\n  signal,\n} from '@angular/core';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport type { ConditionalInputRule, FormColumnInputs } from 'ngx-t-forms-types';\nimport { CalculationFunctions, InputDataTypes, InputTypes } from 'ngx-t-forms-types';\n\nimport { CommonModule } from '@angular/common';\nimport { NgControl } from '@angular/forms';\nimport { MatFormFieldControl } from '@angular/material/form-field';\nimport { MatIconModule } from '@angular/material/icon';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatButtonToggleModule } from '@angular/material/button-toggle';\nimport { MatCardModule } from '@angular/material/card';\nimport { MatTooltipModule } from '@angular/material/tooltip';\nimport { Subject } from 'rxjs';\n\nimport { evaluatePredicate } from '../../../../shared/functions/array-access/predicate-dsl';\nimport type { IConfigElementError } from '../../t-dynamic-data-edit.component';\nimport {\n  type FieldBinding,\n  PREDICATE_OPERATORS,\n  type ValidatorCondition,\n  type ValidatorConditionGroup,\n  deriveObservedInputs,\n  emptyCondition,\n  parseConditions,\n  referencedTokens,\n  serializeConditions,\n} from '../validators-config/validator-condition';\n\n/** A selectable field in the condition builder's field/value dropdowns. */\ninterface FieldOption {\n  readonly variable: string;\n  readonly label: string;\n  readonly isSelf: boolean;\n  /** A multiple-input column (lives inside a repeatable group). */\n  readonly isMultiple: boolean;\n  /** Whether the field holds a numeric value (gates numeric aggregates). */\n  readonly numeric: boolean;\n  /** The input read at runtime: a primary input id, or a list sub-item id. */\n  readonly inputId: string;\n  /** Row-array container id, for multiple-input columns. */\n  readonly parentInputId?: string;\n}\n\n/** A friendly aggregate choice shown for a referenced list field. */\ninterface AggregateOption {\n  readonly value: CalculationFunctions;\n  readonly label: string;\n}\n\n/**\n * Internal editor implementing `MatFormFieldControl<ConditionalInputRule[]>` for\n * authoring a form input's **conditional display** rule.\n *\n * ### Relationship to `validators-config`\n *\n * This is `validators-config` minus `message` and `canOverride`, and minus the\n * multi-rule chip list. It reuses that editor's condition model verbatim —\n * `parseConditions` / `serializeConditions` / `emptyCondition` /\n * `deriveObservedInputs` / `PREDICATE_OPERATORS` — so an author who has written\n * a validator already knows how to write a display rule, and the engine reads\n * both through the same `readDep` dependency model.\n *\n * The one thing that differs is **polarity**, and the copy in the template leans\n * on it hard because getting it backwards is the obvious authoring mistake:\n *\n * | | Expression `true` means |\n * |---|---|\n * | a validator | the entry is **invalid** |\n * | a display rule | the field is **shown** |\n *\n * ### Why exactly one rule\n *\n * `conditionalInputConfig` is an array, and the engine combines multiple rules\n * with AND. This editor deliberately authors a **single** rule: the guided\n * builder already composes many conditions with All/Any inside one expression,\n * so a second rule would add a second, less visible combination layer that means\n * something subtly different. Keeping it to one makes the AND-across-rules\n * semantics unreachable through the UI — it exists only for hand-authored\n * configuration.\n *\n * ### Committing\n *\n * Unlike the validator editor there is no draft/Save cycle: with one rule and no\n * message to compose, every change commits immediately. A half-built condition\n * serialises to an empty expression, which the engine treats as *no rule* — so\n * an incomplete edit leaves the field visible rather than making it vanish\n * mid-authoring.\n *\n * NOTE: `MatFormFieldControl<T>` mandates plain mutable `value` / `disabled` /\n * `required` / `placeholder` / `id` members, `@Input()` decorators, the\n * `focused` / `touched` / `stateChanges` members, and the `useExisting`\n * provider. These are framework wiring, not defects — the CLAUDE.md bans on\n * `@Input()` / `useExisting` do not apply to MatFormFieldControl integration.\n */\n@Component({\n  selector: 'lib-conditional-display-config',\n  templateUrl: './conditional-display-config.component.html',\n  styleUrls: ['./conditional-display-config.component.scss'],\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  encapsulation: ViewEncapsulation.Emulated,\n  imports: [\n    CommonModule,\n    MatIconModule,\n    MatButtonModule,\n    MatButtonToggleModule,\n    MatCardModule,\n    MatTooltipModule,\n  ],\n  providers: [{ provide: MatFormFieldControl, useExisting: ConditionalDisplayConfigComponent }],\n  host: {\n    'class': 'lib-conditional-display-config',\n    '[attr.id]': 'id',\n  },\n})\nexport class ConditionalDisplayConfigComponent\n  implements MatFormFieldControl<ConditionalInputRule[]>, OnChanges, OnDestroy {\n  static nextId = 0;\n\n  /** Emits whenever a piece of `MatFormFieldControl` state changes. */\n  readonly stateChanges = new Subject<void>();\n  readonly controlType = 'lib-conditional-display-config';\n\n  id = `lib-conditional-display-config-${ConditionalDisplayConfigComponent.nextId++}`;\n  placeholder = '';\n  focused = false;\n  touched = false;\n  required = false;\n  describedBy = '';\n  autofilled: boolean | undefined = undefined;\n  userAriaDescribedBy: string | undefined = undefined;\n  disableAutomaticLabeling: boolean | undefined = undefined;\n\n  /** Whether the editor is inert. Kept as `@Input()` for the MFC contract. */\n  @Input() disabled = false;\n  /** Current rule list. Kept as `@Input()` for the MFC contract. */\n  @Input() value: ConditionalInputRule[] = [];\n  /** Validation errors surfaced by the parent for error-state derivation. */\n  @Input() errors: IConfigElementError[] | undefined = [];\n\n  /** The input that owns this rule (for multiple-input scopes + self-labelling). */\n  readonly mapToData = input<FormColumnInputs | undefined>(undefined);\n  /** Available form inputs offered as variables. */\n  readonly formInputs = input<Array<FormColumnInputs>>([]);\n\n  /** Emits the full rule list whenever it changes. */\n  readonly valueChanged = output<ConditionalInputRule[]>();\n\n  /** Operator choices shared with the validator + array-access builders. */\n  protected readonly operators = PREDICATE_OPERATORS;\n\n  /** Aggregate choices for a list field, with non-technical labels. */\n  protected readonly aggregates: readonly AggregateOption[] = [\n    { value: CalculationFunctions.Sum, label: 'total' },\n    { value: CalculationFunctions.Avg, label: 'average' },\n    { value: CalculationFunctions.Min, label: 'lowest' },\n    { value: CalculationFunctions.Max, label: 'highest' },\n    { value: CalculationFunctions.Count, label: 'count' },\n  ];\n\n  readonly #elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n  readonly ngControl = inject(NgControl, { self: true, optional: true });\n\n  /** Guided builder model mirroring the current expression. */\n  readonly #group = signal<ValidatorConditionGroup>({ connector: '&&', conditions: [] });\n  protected readonly group = this.#group.asReadonly();\n\n  /** Whether the rule is being edited as a raw expression instead of guided rows. */\n  readonly #raw = signal(false);\n  protected readonly raw = this.#raw.asReadonly();\n\n  /** The live expression text. Mirrors `value[0].expression`. */\n  readonly #expression = signal('');\n  protected readonly expression = this.#expression.asReadonly();\n\n  /** Chosen aggregate per referenced list variable (keyed by variable name). */\n  readonly #functions = signal<Record<string, CalculationFunctions>>({});\n\n  /**\n   * The list this editor last emitted. Used to tell an incoming `value` binding\n   * that is genuinely new (a different input opened for editing) from the echo\n   * of our own commit — re-seeding on the echo would rebuild the guided model\n   * from the serialised text on every keystroke and fight the user's edit.\n   */\n  #lastCommitted: ConditionalInputRule[] | undefined;\n\n  /**\n   * Fields the builder can reference: every primary input plus every\n   * multiple-input column. `inputId` resolves to the composite id for a sub-row\n   * field, which is exactly the key the engine's visibility map uses — the same\n   * resolution the validator editor already relies on.\n   */\n  protected readonly fieldOptions = computed<readonly FieldOption[]>(() => {\n    const self = this.mapToData();\n    const selfId = self?.id;\n    const options: FieldOption[] = [];\n    for (const input of this.formInputs()) {\n      if (!input.formControlName) continue;\n      const group = input.multipleInputInEditId;\n      options.push({\n        variable: input.formControlName,\n        label: input.label || input.formControlName,\n        isSelf: input.id === selfId,\n        isMultiple: !!group,\n        numeric: this.#isNumeric(input),\n        inputId: group ? input.id : (input.originalId ?? input.id),\n        parentInputId: group,\n      });\n    }\n    return options;\n  });\n\n  /**\n   * Primary (scalar) fields, minus this input itself.\n   *\n   * A display rule that references its own field can never fire: the engine's\n   * self-edge guard resolves the owning input to `undefined` BEFORE the\n   * visibility gate (it has to, or evaluating `vis(X)` would recurse into\n   * `vis(X)`). Offering it would let an author build a rule that silently never\n   * matches, so it is not offered.\n   */\n  protected readonly directFields = computed<readonly FieldOption[]>(() =>\n    this.fieldOptions().filter((f) => !f.isMultiple && !f.isSelf),\n  );\n\n  /** Multiple-input columns, for the second dropdown group. */\n  protected readonly listFields = computed<readonly FieldOption[]>(() =>\n    this.fieldOptions().filter((f) => f.isMultiple && !f.isSelf),\n  );\n\n  /** Field option keyed by its expression variable, for operand lookups. */\n  readonly #fieldByVariable = computed<ReadonlyMap<string, FieldOption>>(\n    () => new Map(this.fieldOptions().map((f) => [f.variable, f])),\n  );\n\n  /** Multiple-input columns actually referenced by the current expression. */\n  protected readonly referencedListFields = computed<readonly FieldOption[]>(() => {\n    const tokens = referencedTokens(this.#expression());\n    return this.listFields().filter((f) => tokens.has(f.variable));\n  });\n\n  /**\n   * Multiple-input variables that MUST be aggregated: a list column compared\n   * against a non-list operand has to be reduced to a single value. In raw mode\n   * operand pairing cannot be analysed, so every referenced list column counts.\n   */\n  protected readonly requiredAggregateVariables = computed<ReadonlySet<string>>(() => {\n    if (this.#raw()) {\n      return new Set(this.referencedListFields().map((f) => f.variable));\n    }\n    const byVariable = this.#fieldByVariable();\n    const required = new Set<string>();\n    for (const cond of this.#group().conditions) {\n      const left = byVariable.get(cond.field);\n      const right = cond.compareTo === 'field' ? byVariable.get(cond.value) : undefined;\n      const leftMultiple = !!left?.isMultiple;\n      const rightMultiple = !!right?.isMultiple;\n      if (leftMultiple && !rightMultiple) required.add(cond.field);\n      if (rightMultiple && !leftMultiple && right) required.add(right.variable);\n    }\n    return required;\n  });\n\n  /** Aggregates offered for a field: numeric columns get all, others only count. */\n  protected aggregatesFor(field: FieldOption): readonly AggregateOption[] {\n    return field.numeric\n      ? this.aggregates\n      : this.aggregates.filter((a) => a.value === CalculationFunctions.Count);\n  }\n\n  /** Whether a referenced list column is required to have an aggregate. */\n  protected isAggregateRequired(variable: string): boolean {\n    return this.requiredAggregateVariables().has(variable);\n  }\n\n  /** Human-readable syntax error for the raw editor, or `null` when valid/empty. */\n  protected readonly syntaxError = computed<string | null>(() => {\n    const expression = this.#expression();\n    if (expression.trim() === '') return null;\n    try {\n      evaluatePredicate(expression, {});\n      return null;\n    } catch (error: unknown) {\n      return error instanceof Error ? error.message : 'The expression syntax is invalid.';\n    }\n  });\n\n  /** Whether the current expression can be edited in the guided builder. */\n  protected readonly canUseGuided = computed<boolean>(\n    () => parseConditions(this.#expression(), this.#fieldNameSet()) !== null,\n  );\n\n  /** Whether a rule is in force right now. */\n  protected readonly hasRule = computed<boolean>(() => this.#expression().trim() !== '');\n\n  /**\n   * Whether the guided builder currently holds a condition that will be DROPPED\n   * on serialisation — no field chosen, or a field-vs-field comparison with no\n   * right-hand field. The template surfaces this as a one-line pending hint,\n   * because the alternative is a silently inert rule: the author adds a row,\n   * assumes the field is now conditional, and nothing tells them it is not.\n   *\n   * A typed value of `''` is NOT incomplete — `x === \"\"` is the legitimate\n   * \"while the field is empty\" rule.\n   */\n  protected readonly hasIncompleteCondition = computed<boolean>(() => {\n    if (this.#raw()) return false;\n    return this.#group().conditions.some(\n      (cond) =>\n        cond.field.trim() === '' ||\n        (cond.compareTo === 'field' && cond.value.trim() === ''),\n    );\n  });\n\n  // MatFormFieldControl reads these as plain getters during its own change\n  // detection, so they stay getters rather than `computed()` signals.\n\n  get empty(): boolean {\n    return !this.#currentRule();\n  }\n\n  get shouldLabelFloat(): boolean {\n    return this.focused || !this.empty;\n  }\n\n  get errorState(): boolean {\n    const ngControlError = this.ngControl?.errors != null;\n    const externalError = (this.errors?.length ?? 0) > 0 && this.touched;\n    return ngControlError || externalError;\n  }\n\n  setDescribedByIds(ids: string[]): void {\n    this.describedBy = ids.join(' ');\n    const el = this.#elementRef.nativeElement;\n    const controlElement = el.querySelector('.lib-conditional-display-config__body');\n    controlElement?.setAttribute('aria-describedby', this.describedBy);\n    this.stateChanges.next();\n  }\n\n  onContainerClick(): void {\n    this.markAsTouched();\n    this.stateChanges.next();\n  }\n\n  onTouched: () => void = () => { };\n\n  markAsTouched(): void {\n    if (!this.touched) {\n      this.touched = true;\n      this.onTouched();\n      this.stateChanges.next();\n    }\n  }\n\n  /** Tear down the MFC state stream so subscribers do not leak. */\n  ngOnDestroy(): void {\n    this.stateChanges.complete();\n  }\n\n  /**\n   * Seeds the guided builder from the bound `value`.\n   *\n   * Runs in `ngOnChanges`, not from the template and not from a `value` setter,\n   * for two reasons:\n   *\n   * - **Signal writes.** Seeding writes `#group` / `#raw` / `#expression`.\n   *   Doing that from a template getter throws NG0600 (writing to signals while\n   *   Angular renders).\n   * - **Binding order.** The host template binds `[value]` *before*\n   *   `[formInputs]`, and parsing an expression into guided rows needs the field\n   *   list to recognise its variable names. A `value` setter would parse against\n   *   an empty field set and drop every rule into Advanced mode. `ngOnChanges`\n   *   runs after the whole binding pass, so both are present.\n   */\n  ngOnChanges(changes: SimpleChanges): void {\n    if (!changes['value']) return;\n    if (this.value === this.#lastCommitted) return; // our own echo\n    this.#seed();\n  }\n\n  #seed(): void {\n    const rule = this.#currentRule();\n    const expression = rule?.expression ?? '';\n    this.#expression.set(expression);\n    this.#functions.set(this.#functionsFromRule(rule));\n    const parsed = parseConditions(expression, this.#fieldNameSet());\n    if (parsed) {\n      this.#group.set(parsed);\n      this.#raw.set(false);\n    } else if (expression.trim() !== '') {\n      // An expression the guided builder cannot represent (grouping, mixed\n      // connectors, negation) opens in Advanced and round-trips unchanged.\n      this.#raw.set(true);\n    } else {\n      this.#group.set({ connector: '&&', conditions: [] });\n      this.#raw.set(false);\n    }\n  }\n\n  // ---- guided condition builder ------------------------------------------\n\n  /** Switch the All/Any connector joining the conditions. */\n  protected setConnector(connector: '&&' | '||'): void {\n    this.#applyGroup({ ...this.#group(), connector });\n  }\n\n  /**\n   * Append a fresh, **field-less** condition.\n   *\n   * The validator editor defaults the field to the input being validated, which\n   * is nearly always what its author wants. Here the owning field is explicitly\n   * excluded (a rule cannot observe itself), so any default would be an\n   * arbitrary pick — and it would not be inert. `serializeConditions` treats a\n   * typed value of `''` as complete, because `x === \"\"` is a legitimate \"is\n   * empty\" rule, so a pre-filled field would turn a single click on \"Add\n   * condition\" into a live rule that starts hiding the field. Leaving the field\n   * unset serialises to nothing, so the rule only exists once the author has\n   * actually said what it is about.\n   */\n  protected addCondition(): void {\n    const group = this.#group();\n    this.#applyGroup({\n      ...group,\n      conditions: [...group.conditions, emptyCondition('')],\n    });\n  }\n\n  /** Apply a partial change to the condition at `index`. */\n  protected updateCondition(index: number, patch: Partial<ValidatorCondition>): void {\n    const group = this.#group();\n    const conditions = group.conditions.map((c, i) => (i === index ? { ...c, ...patch } : c));\n    this.#applyGroup({ ...group, conditions });\n  }\n\n  /** Flip a condition between comparing to a typed value and another field. */\n  protected toggleCompareTo(index: number): void {\n    const condition = this.#group().conditions[index];\n    if (!condition) return;\n    if (condition.compareTo === 'value') {\n      const field = this.fieldOptions().find((f) => f.variable !== condition.field && !f.isSelf);\n      this.updateCondition(index, { compareTo: 'field', value: field?.variable ?? '' });\n    } else {\n      this.updateCondition(index, { compareTo: 'value', value: '' });\n    }\n  }\n\n  /** Remove the condition at `index`. */\n  protected removeCondition(index: number): void {\n    const group = this.#group();\n    this.#applyGroup({ ...group, conditions: group.conditions.filter((_, i) => i !== index) });\n  }\n\n  /**\n   * Choose (or clear, by re-clicking) the aggregate that reduces a referenced\n   * list field to a single value.\n   */\n  protected setFunction(variable: string, fn: CalculationFunctions): void {\n    this.#functions.update((current) => {\n      const next = { ...current };\n      if (next[variable] === fn) {\n        delete next[variable];\n      } else {\n        next[variable] = fn;\n      }\n      return next;\n    });\n    // The expression text is unchanged, but the observed deps now carry the\n    // aggregate — re-commit so inputsObservedForChanges reflects the choice.\n    this.#commitExpression(this.#expression());\n  }\n\n  /** The aggregate currently chosen for a list variable, if any. */\n  protected currentFunction(variable: string): CalculationFunctions | undefined {\n    return this.#functions()[variable];\n  }\n\n  /** Replace the raw expression as the user types. */\n  protected onExpressionInput(event: Event): void {\n    this.#commitExpression((event.target as HTMLTextAreaElement).value);\n  }\n\n  /** Switch to the raw expression editor. */\n  protected useRaw(): void {\n    this.#raw.set(true);\n  }\n\n  /** Switch back to the guided builder, reparsing the current expression. */\n  protected useGuided(): void {\n    const parsed = parseConditions(this.#expression(), this.#fieldNameSet());\n    if (!parsed) return;\n    this.#group.set(parsed);\n    this.#raw.set(false);\n  }\n\n  /**\n   * Remove the rule entirely — the field becomes unconditionally visible again.\n   *\n   * Commits an empty array rather than a rule with a blank expression, so the\n   * engine builds no visibility signal at all for this input and the form pays\n   * nothing for a rule that no longer exists.\n   */\n  protected clearRule(): void {\n    this.#group.set({ connector: '&&', conditions: [] });\n    this.#functions.set({});\n    this.#expression.set('');\n    this.#raw.set(false);\n    this.#commit([]);\n  }\n\n  /** Read the value-event target as a string. */\n  protected inputValue(event: Event): string {\n    return (event.target as HTMLInputElement | HTMLSelectElement).value;\n  }\n\n  // ---- internal ----------------------------------------------------------\n\n  /** The single rule this editor owns, if one is bound. */\n  #currentRule(): ConditionalInputRule | undefined {\n    return this.value?.[0];\n  }\n\n  /** Set of field variable names the builder recognises (for parsing). */\n  #fieldNameSet(): ReadonlySet<string> {\n    return new Set(this.fieldOptions().map((f) => f.variable));\n  }\n\n  /** Whether an input carries a numeric data type. */\n  #isNumeric(input: FormColumnInputs): boolean {\n    return input.dataType === InputDataTypes.Number || input.type === InputTypes.Number;\n  }\n\n  /** Recover the per-variable aggregate choices from a rule's observed inputs. */\n  #functionsFromRule(rule: ConditionalInputRule | undefined): Record<string, CalculationFunctions> {\n    const map: Record<string, CalculationFunctions> = {};\n    for (const observed of rule?.inputsObservedForChanges ?? []) {\n      if (observed.function) map[observed.variable] = observed.function;\n    }\n    return map;\n  }\n\n  /** Store a builder change: update the model, then serialise + commit. */\n  #applyGroup(next: ValidatorConditionGroup): void {\n    this.#group.set(next);\n    this.#commitExpression(serializeConditions(next));\n  }\n\n  /**\n   * Write an expression onto the rule, re-deriving its observed-input deps.\n   *\n   * An expression that serialises to nothing means the author has not finished —\n   * commit an empty list so the engine treats the input as unconditional. A\n   * half-built rule must never hide the field it is being written on.\n   */\n  #commitExpression(expression: string): void {\n    this.#expression.set(expression);\n    if (expression.trim() === '') {\n      this.#commit([]);\n      return;\n    }\n    const fields: readonly FieldBinding[] = this.fieldOptions();\n    const existing = this.#currentRule();\n    const rule: ConditionalInputRule = {\n      // Preserve every legacy descriptive field an older form may carry; the\n      // engine ignores them, but an external consumer still renders them.\n      ...existing,\n      id: existing?.id ?? uuidv4(),\n      expression,\n      inputsObservedForChanges: deriveObservedInputs(expression, fields, this.#functions()),\n    };\n    this.#commit([rule]);\n  }\n\n  /** Single mutation path: store the new list and notify the parent. */\n  #commit(next: ConditionalInputRule[]): void {\n    this.#lastCommitted = next;\n    this.value = next;\n    this.markAsTouched();\n    this.stateChanges.next();\n    this.valueChanged.emit([...next]);\n  }\n}\n","<section class=\"lib-conditional-display-config__body\">\n  @if (!hasRule()) {\n  <p class=\"lib-conditional-display-config__hint\">\n    Appears only while a condition you define is true. Leave empty to always show.\n  </p>\n  }\n\n  <div class=\"lib-conditional-display-config__condition-head\">\n    <span class=\"lib-conditional-display-config__f-label\">Show this field when</span>\n    @if (!raw() && group().conditions.length > 1) {\n    <mat-button-toggle-group\n      class=\"lib-conditional-display-config__seg\"\n      [value]=\"group().connector\"\n      hideSingleSelectionIndicator\n      (change)=\"setConnector($event.value)\"\n      aria-label=\"Combine conditions\"\n    >\n      <mat-button-toggle value=\"&&\">All</mat-button-toggle>\n      <mat-button-toggle value=\"||\">Any</mat-button-toggle>\n    </mat-button-toggle-group>\n    }\n  </div>\n\n  @if (raw()) {\n  <textarea\n    class=\"lib-conditional-display-config__control lib-conditional-display-config__textarea lib-conditional-display-config__mono\"\n    rows=\"2\"\n    [value]=\"expression()\"\n    [disabled]=\"disabled\"\n    (input)=\"onExpressionInput($event)\"\n    aria-label=\"Visibility expression\"\n    placeholder='e.g. contactMethod === \"phone\"'\n  ></textarea>\n  @if (syntaxError(); as error) {\n  <p class=\"lib-conditional-display-config__error\">\n    <mat-icon class=\"lib-conditional-display-config__error-icon\">error_outline</mat-icon>\n    <span>{{ error }}</span>\n  </p>\n  } @else {\n  <p class=\"lib-conditional-display-config__sub-hint\">\n    True = shown. Use field names with <code>===</code>, <code>&gt;</code>, <code>includes</code> …\n  </p>\n  }\n  } @else {\n\n  @if (fieldOptions().length === 0) {\n  <p class=\"lib-conditional-display-config__sub-hint\">\n    No other fields available yet — switch to Advanced to type an expression.\n  </p>\n  }\n\n  @for (cond of group().conditions; track $index; let first = $first) {\n  @if (!first) {\n  <span class=\"lib-conditional-display-config__connector\" aria-hidden=\"true\">\n    {{ group().connector === '&&' ? 'and' : 'or' }}\n  </span>\n  }\n  <div class=\"lib-conditional-display-config__cond\">\n    <label class=\"lib-conditional-display-config__field\">\n      <span class=\"lib-conditional-display-config__f-label\">Field</span>\n      <select\n        class=\"lib-conditional-display-config__control\"\n        [class.lib-conditional-display-config__control--invalid]=\"!cond.field\"\n        [disabled]=\"disabled\"\n        (change)=\"updateCondition($index, { field: inputValue($event) })\"\n      >\n        <option value=\"\" disabled [selected]=\"!cond.field\">Choose…</option>\n        @if (directFields().length) {\n        <optgroup label=\"Fields\">\n          @for (f of directFields(); track f.variable) {\n          <option [value]=\"f.variable\" [selected]=\"f.variable === cond.field\">{{ f.label }}</option>\n          }\n        </optgroup>\n        }\n        @if (listFields().length) {\n        <optgroup label=\"List fields\">\n          @for (f of listFields(); track f.variable) {\n          <option [value]=\"f.variable\" [selected]=\"f.variable === cond.field\">{{ f.label }}</option>\n          }\n        </optgroup>\n        }\n      </select>\n    </label>\n\n    <label class=\"lib-conditional-display-config__field\">\n      <span class=\"lib-conditional-display-config__f-label\">Condition</span>\n      <select\n        class=\"lib-conditional-display-config__control\"\n        [disabled]=\"disabled\"\n        (change)=\"updateCondition($index, { operator: inputValue($event) })\"\n      >\n        @for (op of operators; track op.value) {\n        <option [value]=\"op.value\" [selected]=\"op.value === cond.operator\">{{ op.label }}</option>\n        }\n      </select>\n    </label>\n\n    <div class=\"lib-conditional-display-config__field lib-conditional-display-config__field--value\">\n      <span class=\"lib-conditional-display-config__f-label\">\n        {{ cond.compareTo === 'field' ? 'Other field' : 'Value' }}\n      </span>\n      <div class=\"lib-conditional-display-config__value\">\n        @if (cond.compareTo === 'field') {\n        <select\n          class=\"lib-conditional-display-config__control\"\n          [class.lib-conditional-display-config__control--invalid]=\"!cond.value\"\n          [disabled]=\"disabled\"\n          (change)=\"updateCondition($index, { value: inputValue($event) })\"\n        >\n          <option value=\"\" disabled [selected]=\"!cond.value\">Choose…</option>\n          @if (directFields().length) {\n          <optgroup label=\"Fields\">\n            @for (f of directFields(); track f.variable) {\n            <option [value]=\"f.variable\" [selected]=\"f.variable === cond.value\">{{ f.label }}</option>\n            }\n          </optgroup>\n          }\n          @if (listFields().length) {\n          <optgroup label=\"List fields\">\n            @for (f of listFields(); track f.variable) {\n            <option [value]=\"f.variable\" [selected]=\"f.variable === cond.value\">{{ f.label }}</option>\n            }\n          </optgroup>\n          }\n        </select>\n        } @else {\n        <input\n          class=\"lib-conditional-display-config__control\"\n          [value]=\"cond.value\"\n          [disabled]=\"disabled\"\n          (input)=\"updateCondition($index, { value: inputValue($event) })\"\n          placeholder=\"leave empty for “is empty”\"\n        />\n        }\n        <button\n          type=\"button\"\n          class=\"lib-conditional-display-config__icon-btn\"\n          [disabled]=\"disabled\"\n          (click)=\"toggleCompareTo($index)\"\n          [attr.aria-label]=\"\n            cond.compareTo === 'field' ? 'Compare to a typed value' : 'Compare to another field'\n          \"\n          [matTooltip]=\"\n            cond.compareTo === 'field' ? 'Compare to a typed value' : 'Compare to another field'\n          \"\n        >\n          <mat-icon>{{ cond.compareTo === 'field' ? 'edit' : 'link' }}</mat-icon>\n        </button>\n        <button\n          type=\"button\"\n          class=\"lib-conditional-display-config__icon-btn\"\n          [disabled]=\"disabled\"\n          (click)=\"removeCondition($index)\"\n          matTooltip=\"Remove condition\"\n          aria-label=\"Remove condition\"\n        >\n          <mat-icon>close</mat-icon>\n        </button>\n      </div>\n    </div>\n  </div>\n  }\n\n  <button\n    type=\"button\"\n    class=\"lib-conditional-display-config__link\"\n    [disabled]=\"disabled\"\n    (click)=\"addCondition()\"\n  >\n    <mat-icon>add</mat-icon> Add condition\n  </button>\n  }\n\n  @if (hasIncompleteCondition()) {\n  <p class=\"lib-conditional-display-config__sub-hint lib-conditional-display-config__sub-hint--pending\">\n    <mat-icon class=\"lib-conditional-display-config__pending-icon\">pending</mat-icon>\n    <span>Unfinished conditions are ignored — pick a field to activate the rule.</span>\n  </p>\n  }\n\n  @if (referencedListFields().length) {\n  <div class=\"lib-conditional-display-config__lists\">\n    <span class=\"lib-conditional-display-config__f-label\">Combine each list</span>\n    @for (f of referencedListFields(); track f.variable) {\n    <div\n      class=\"lib-conditional-display-config__list-row\"\n      [class.lib-conditional-display-config__list-row--unset]=\"\n        isAggregateRequired(f.variable) && !currentFunction(f.variable)\n      \"\n    >\n      <span class=\"lib-conditional-display-config__list-name\">{{ f.label }}</span>\n      <div class=\"lib-conditional-display-config__agg\" role=\"group\" [attr.aria-label]=\"'Combine ' + f.label\">\n        @for (agg of aggregatesFor(f); track agg.value) {\n        <button\n          type=\"button\"\n          class=\"lib-conditional-display-config__agg-chip\"\n          [class.lib-conditional-display-config__agg-chip--on]=\"currentFunction(f.variable) === agg.value\"\n          [disabled]=\"disabled\"\n          (click)=\"setFunction(f.variable, agg.value)\"\n        >\n          {{ agg.label }}\n        </button>\n        }\n      </div>\n    </div>\n    }\n  </div>\n  }\n\n  @if (hasRule()) {\n  <p class=\"lib-conditional-display-config__summary\">\n    While hidden, this field is removed from the form — nothing is submitted and\n    its validation cannot block.\n  </p>\n\n  @if (!raw()) {\n  <details class=\"lib-conditional-display-config__preview\">\n    <summary class=\"lib-conditional-display-config__preview-summary\">Expression</summary>\n    <code>{{ expression() }}</code>\n  </details>\n  }\n  }\n\n  <div class=\"lib-conditional-display-config__foot\">\n    @if (raw()) {\n    <button\n      type=\"button\"\n      class=\"lib-conditional-display-config__link\"\n      [disabled]=\"!canUseGuided()\"\n      [matTooltip]=\"canUseGuided() ? '' : 'This expression is too advanced for the guided builder'\"\n      (click)=\"useGuided()\"\n    >\n      <mat-icon>view_module</mat-icon> Guided\n    </button>\n    } @else {\n    <button type=\"button\" class=\"lib-conditional-display-config__link\" (click)=\"useRaw()\">\n      <mat-icon>code</mat-icon> Advanced\n    </button>\n    }\n\n    @if (hasRule()) {\n    <button\n      type=\"button\"\n      class=\"lib-conditional-display-config__link lib-conditional-display-config__link--danger\"\n      [disabled]=\"disabled\"\n      matTooltip=\"Remove the rule — the field becomes always visible\"\n      (click)=\"clearRule()\"\n    >\n      <mat-icon>visibility</mat-icon> Always show\n    </button>\n    }\n  </div>\n</section>\n"],"names":["uuidv4","i1","i2","i3"],"mappings":";;;;;;;;;;;;;;;;;;AAkEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CG;MAqBU,iCAAiC,CAAA;AApB9C,IAAA,WAAA,GAAA;;AAyBW,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,OAAO,EAAQ;QAClC,IAAA,CAAA,WAAW,GAAG,gCAAgC;AAEvD,QAAA,IAAA,CAAA,EAAE,GAAG,CAAA,+BAAA,EAAkC,iCAAiC,CAAC,MAAM,EAAE,EAAE;QACnF,IAAA,CAAA,WAAW,GAAG,EAAE;QAChB,IAAA,CAAA,OAAO,GAAG,KAAK;QACf,IAAA,CAAA,OAAO,GAAG,KAAK;QACf,IAAA,CAAA,QAAQ,GAAG,KAAK;QAChB,IAAA,CAAA,WAAW,GAAG,EAAE;QAChB,IAAA,CAAA,UAAU,GAAwB,SAAS;QAC3C,IAAA,CAAA,mBAAmB,GAAuB,SAAS;QACnD,IAAA,CAAA,wBAAwB,GAAwB,SAAS;;QAGhD,IAAA,CAAA,QAAQ,GAAG,KAAK;;QAEhB,IAAA,CAAA,KAAK,GAA2B,EAAE;;QAElC,IAAA,CAAA,MAAM,GAAsC,EAAE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