@angular/forms
Version:
Angular - directives and services for creating forms
1 lines • 241 kB
Source Map (JSON)
{"version":3,"file":"_validation_errors-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/api/symbols.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/resolution.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/util.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/util/type_guards.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/schema/logic.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/schema/logic_node.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/schema/path_node.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/schema/schema.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/api/rules/metadata.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/util/array.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/validation.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/debounce.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/context.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/metadata.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/proxy.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/util/deep_signal.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/structure.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/submit.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/node.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/state.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/field_adapter.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/field/manager.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/webmcp/tokens.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/util/normalize_form_args.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/api/structure.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/packages/forms/signals/src/compat/validation_errors.ts"],"sourcesContent":["/*!\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * Symbol used to retain generic type information when it would otherwise be lost.\n */\nexport declare const ɵɵTYPE: unique symbol;\n\n/**\n * Symbol used to indicate that a value is a field tree.\n */\nexport const FIELD_TREE: unique symbol = /* @__PURE__ */ Symbol('FIELD_TREE');\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nlet boundPathDepth = 0;\n\n/**\n * The depth of the current path when evaluating a logic function.\n * Do not set this directly, it is a context variable managed by `setBoundPathDepthForResolution`.\n */\nexport function getBoundPathDepth() {\n return boundPathDepth;\n}\n\n/**\n * Sets the bound path depth for the duration of the given logic function.\n * This is used to ensure that the field resolution algorithm walks far enough up the field tree to\n * reach the point where the root of the path we're bound to is applied. This normally isn't a big\n * concern, but matters when we're dealing with recursive structures.\n *\n * Consider this example:\n *\n * ```ts\n * const s = schema(p => {\n * disabled(p.next, ({valueOf}) => valueOf(p.data));\n * apply(p.next, s);\n * });\n * ```\n *\n * Here we need to know that the `disabled` logic was bound to a path of depth 1. Otherwise we'd\n * attempt to resolve `p.data` in the context of the field corresponding to `p.next`.\n * The resolution algorithm would start with the field for `p.next` and see that it *does* contain\n * the logic for `s` (due to the fact that its recursively applied.) It would then decide not to\n * walk up the field tree at all, and to immediately start walking down the keys for the target path\n * `p.data`, leading it to grab the field corresponding to `p.next.data`.\n *\n * We avoid the problem described above by keeping track of the depth (relative to Schema root) of\n * the path we were bound to. We then require the resolution algorithm to walk at least that far up\n * the tree before finding a node that contains the logic for `s`.\n *\n * @param fn A logic function that is bound to a particular path\n * @param depth The depth in the field tree of the field the logic is bound to\n * @returns A version of the logic function that is aware of its depth.\n */\nexport function setBoundPathDepthForResolution<A extends any[], R>(\n fn: (...args: A) => R,\n depth: number,\n): (...args: A) => R {\n return (...args: A) => {\n try {\n boundPathDepth = depth;\n return fn(...args);\n } finally {\n boundPathDepth = 0;\n }\n };\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport type {FieldNodeOptions} from './structure';\n\n/** A shortCircuit function for reduceChildren that short-circuits if the value is false. */\nexport function shortCircuitFalse(value: boolean): boolean {\n return !value;\n}\n\n/** A shortCircuit function for reduceChildren that short-circuits if the value is true. */\nexport function shortCircuitTrue(value: boolean): boolean {\n return value;\n}\n\n/** Recasts the given value as a new type. */\nexport function cast<T>(value: unknown): asserts value is T {}\n\n/**\n * A helper method allowing to get injector regardless of the options type.\n * @param options\n */\nexport function getInjectorFromOptions(options: FieldNodeOptions) {\n if (options.kind === 'root') {\n return options.fieldManager.injector;\n }\n\n return options.parent.structure.root.structure.injector;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * A version of `Array.isArray` that handles narrowing of readonly arrays properly.\n */\nexport function isArray(value: unknown): value is any[] | readonly any[] {\n return Array.isArray(value);\n}\n\n/**\n * Checks if a value is an object.\n */\nexport function isObject(value: unknown): value is Record<PropertyKey, unknown> {\n return (typeof value === 'object' || typeof value === 'function') && value != null;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {untracked} from '@angular/core';\nimport type {MetadataKey} from '../api/rules/metadata';\nimport type {ValidationError} from '../api/rules/validation/validation_errors';\nimport {DisabledReason, type FieldContext, type LogicFn, type SchemaPath} from '../api/types';\nimport type {FieldNode} from '../field/node';\nimport {cast} from '../field/util';\nimport {isArray} from '../util/type_guards';\n\n/**\n * Special key which is used to represent a dynamic logic property in a `FieldPathNode` path.\n * This property is used to represent logic that applies to every element of some dynamic form data\n * (i.e. an array).\n *\n * For example, a rule like `applyEach(p.myArray, () => { ... })` will add logic to the `DYNAMIC`\n * property of `p.myArray`.\n */\nexport const DYNAMIC: unique symbol = Symbol();\n\n/** Represents a result that should be ignored because its predicate indicates it is not active. */\nconst IGNORED = Symbol();\n\n/**\n * A predicate that indicates whether an `AbstractLogic` instance is currently active, or should be\n * ignored.\n */\nexport interface Predicate {\n /** A boolean logic function that returns true if the logic is considered active. */\n readonly fn: LogicFn<any, boolean>;\n /**\n * The path which this predicate was created for. This is used to determine the correct\n * `FieldContext` to pass to the predicate function.\n */\n readonly path: SchemaPath<any>;\n}\n\n/**\n * Represents a predicate that is bound to a particular depth in the field tree. This is needed for\n * recursively applied logic to ensure that the predicate is evaluated against the correct\n * application of that logic.\n *\n * Consider the following example:\n *\n * ```ts\n * const s = schema(p => {\n * disabled(p.data);\n * applyWhen(p.next, ({valueOf}) => valueOf(p.data) === 1, s);\n * });\n *\n * const f = form(signal({data: 0, next: {data: 1, next: {data: 2, next: undefined}}}), s);\n *\n * const isDisabled = f.next.next.data().disabled();\n * ```\n *\n * In order to determine `isDisabled` we need to evaluate the predicate from `applyWhen` *twice*.\n * Once to see if the schema should be applied to `f.next` and again to see if it should be applied\n * to `f.next.next`. The `depth` tells us which field we should be evaluating against each time.\n */\nexport interface BoundPredicate extends Predicate {\n /** The depth in the field tree at which this predicate is bound. */\n readonly depth: number;\n}\n\n/**\n * Base class for all logic. It is responsible for combining the results from multiple individual\n * logic functions registered in the schema, and using them to derive the value for some associated\n * piece of field state.\n */\nexport abstract class AbstractLogic<TReturn, TValue = TReturn> {\n /** The set of logic functions that contribute to the value of the associated state. */\n protected readonly fns: Array<LogicFn<any, TValue | typeof IGNORED>> = [];\n\n constructor(\n /**\n * A list of predicates that conditionally enable all logic in this logic instance.\n * The logic is only enabled when *all* of the predicates evaluate to true.\n */\n private predicates: ReadonlyArray<BoundPredicate>,\n ) {}\n\n /**\n * Computes the value of the associated field state based on the logic functions and predicates\n * registered with this logic instance.\n */\n abstract compute(arg: FieldContext<any>): TReturn;\n\n /**\n * The default value that the associated field state should assume if there are no logic functions\n * registered by the schema (or if the logic is disabled by a predicate).\n */\n abstract get defaultValue(): TReturn;\n\n /** Registers a logic function with this logic instance. */\n push(logicFn: LogicFn<any, TValue>) {\n this.fns.push(wrapWithPredicates(this.predicates, logicFn));\n }\n\n /**\n * Merges in the logic from another logic instance, subject to the predicates of both the other\n * instance and this instance.\n */\n mergeIn(other: AbstractLogic<TReturn, TValue>) {\n const fns = this.predicates\n ? other.fns.map((fn) => wrapWithPredicates(this.predicates, fn))\n : other.fns;\n this.fns.push(...fns);\n }\n\n /** Checks if any logic rules are registered in this instance. */\n hasRules(): boolean {\n return this.fns.length > 0;\n }\n}\n\n/** Logic that combines its individual logic function results with logical OR. */\nexport class BooleanOrLogic extends AbstractLogic<boolean> {\n override get defaultValue() {\n return false;\n }\n\n override compute(arg: FieldContext<any>): boolean {\n return this.fns.some((f) => {\n const result = f(arg);\n return result && result !== IGNORED;\n });\n }\n}\n\n/**\n * Logic that combines its individual logic function results by aggregating them in an array.\n * Depending on its `ignore` function it may ignore certain values, omitting them from the array.\n */\nexport class ArrayMergeIgnoreLogic<TElement, TIgnore = never> extends AbstractLogic<\n readonly TElement[],\n TElement | readonly (TElement | TIgnore)[] | TIgnore | undefined | void\n> {\n /** Creates an instance of this class that ignores `null` values. */\n static ignoreNull<TElement>(predicates: ReadonlyArray<BoundPredicate>) {\n return new ArrayMergeIgnoreLogic<TElement, null>(predicates, (e: unknown) => e === null);\n }\n\n constructor(\n predicates: ReadonlyArray<BoundPredicate>,\n private ignore: undefined | ((e: TElement | undefined | TIgnore) => e is TIgnore),\n ) {\n super(predicates);\n }\n\n override get defaultValue() {\n return [];\n }\n\n override compute(arg: FieldContext<any>): readonly TElement[] {\n return this.fns.reduce((prev, f) => {\n const value = f(arg);\n\n if (value === undefined || value === IGNORED) {\n return prev;\n } else if (isArray(value)) {\n return [...prev, ...(this.ignore ? value.filter((e) => !this.ignore!(e)) : value)];\n } else {\n if (this.ignore && this.ignore(value as TElement | TIgnore | undefined)) {\n return prev;\n }\n return [...prev, value];\n }\n }, [] as TElement[]);\n }\n}\n\n/** Logic that combines its individual logic function results by aggregating them in an array. */\nexport class ArrayMergeLogic<TElement> extends ArrayMergeIgnoreLogic<TElement, never> {\n constructor(predicates: ReadonlyArray<BoundPredicate>) {\n super(predicates, undefined);\n }\n}\n\n/** Logic that combines metadata according to the keys's reduce function. */\nexport class MetadataMergeLogic<TAcc, TItem> extends AbstractLogic<TAcc, TItem> {\n override get defaultValue() {\n return this.key.reducer.getInitial();\n }\n\n constructor(\n predicates: ReadonlyArray<BoundPredicate>,\n private key: MetadataKey<any, TItem, TAcc>,\n ) {\n super(predicates);\n }\n\n override compute(ctx: FieldContext<any>): TAcc {\n if (this.fns.length === 0) {\n return this.key.reducer.getInitial();\n }\n let acc: TAcc = this.key.reducer.getInitial();\n for (let i = 0; i < this.fns.length; i++) {\n const item = this.fns[i](ctx);\n if (item !== IGNORED) {\n acc = this.key.reducer.reduce(acc, item);\n }\n }\n return acc;\n }\n}\n\n/**\n * Wraps a logic function such that it returns the special `IGNORED` sentinel value if any of the\n * given predicates evaluates to false.\n *\n * @param predicates A list of bound predicates to apply to the logic function\n * @param logicFn The logic function to wrap\n * @returns A wrapped version of the logic function that may return `IGNORED`.\n */\nfunction wrapWithPredicates<TValue, TReturn>(\n predicates: ReadonlyArray<BoundPredicate>,\n logicFn: LogicFn<TValue, TReturn>,\n): LogicFn<TValue, TReturn | typeof IGNORED> {\n if (predicates.length === 0) {\n return logicFn;\n }\n return (arg: FieldContext<any>): TReturn | typeof IGNORED => {\n for (const predicate of predicates) {\n let predicateField = arg.stateOf(predicate.path) as FieldNode;\n // Check the depth of the current field vs the depth this predicate is supposed to be\n // evaluated at. If necessary, walk up the field tree to grab the correct context field.\n // We can check the pathKeys as an untracked read since we know the structure of our fields\n // doesn't change.\n const depthDiff = untracked(predicateField.structure.pathKeys).length - predicate.depth;\n for (let i = 0; i < depthDiff; i++) {\n predicateField = predicateField.structure.parent!;\n }\n // If any of the predicates don't match, don't actually run the logic function, just return\n // the default value.\n if (!predicate.fn(predicateField.context)) {\n return IGNORED;\n }\n }\n return logicFn(arg);\n };\n}\n\n/**\n * Container for all the different types of logic that can be applied to a field\n * (disabled, hidden, errors, etc.)\n */\n\nexport class LogicContainer {\n /** Logic that determines if the field is hidden. */\n readonly hidden: BooleanOrLogic;\n /** Logic that determines reasons for the field being disabled. */\n readonly disabledReasons: ArrayMergeLogic<DisabledReason>;\n /** Logic that determines if the field is read-only. */\n readonly readonly: BooleanOrLogic;\n /** Logic that produces synchronous validation errors for the field. */\n readonly syncErrors: ArrayMergeIgnoreLogic<ValidationError.WithFieldTree, null>;\n /** Logic that produces synchronous validation errors for the field's subtree. */\n readonly syncTreeErrors: ArrayMergeIgnoreLogic<ValidationError.WithFieldTree, null>;\n /** Logic that produces asynchronous validation results (errors or 'pending'). */\n readonly asyncErrors: ArrayMergeIgnoreLogic<ValidationError.WithFieldTree | 'pending', null>;\n /** A map of metadata keys to the `AbstractLogic` instances that compute their values. */\n private readonly metadata = new Map<\n MetadataKey<unknown, unknown, unknown>,\n AbstractLogic<unknown>\n >();\n\n /**\n * Constructs a new `Logic` container.\n * @param predicates An array of predicates that must all be true for the logic\n * functions within this container to be active.\n */\n constructor(private predicates: ReadonlyArray<BoundPredicate>) {\n this.hidden = new BooleanOrLogic(predicates);\n this.disabledReasons = new ArrayMergeLogic(predicates);\n this.readonly = new BooleanOrLogic(predicates);\n this.syncErrors = ArrayMergeIgnoreLogic.ignoreNull<ValidationError.WithFieldTree>(predicates);\n this.syncTreeErrors =\n ArrayMergeIgnoreLogic.ignoreNull<ValidationError.WithFieldTree>(predicates);\n this.asyncErrors = ArrayMergeIgnoreLogic.ignoreNull<ValidationError.WithFieldTree | 'pending'>(\n predicates,\n );\n }\n\n /**\n * Checks whether this container has any logic rules registered in any of its categories.\n * @returns True if at least one logic rule exists.\n */\n hasAnyLogic(): boolean {\n return (\n this.hidden.hasRules() ||\n this.disabledReasons.hasRules() ||\n this.readonly.hasRules() ||\n this.syncErrors.hasRules() ||\n this.syncTreeErrors.hasRules() ||\n this.asyncErrors.hasRules() ||\n this.metadata.size > 0\n );\n }\n\n /** Checks whether there is logic for the given metadata key. */\n hasMetadata(key: MetadataKey<any, any, any>) {\n return this.metadata.has(key);\n }\n\n hasMetadataKeys(): boolean {\n return this.metadata.size > 0;\n }\n\n /**\n * Gets an iterable of [metadata key, logic function] pairs.\n * @returns An iterable of metadata keys.\n */\n getMetadataKeys() {\n return this.metadata.keys();\n }\n\n /**\n * Retrieves or creates the `AbstractLogic` for a given metadata key.\n * @param key The `MetadataKey` for which to get the logic.\n * @returns The `AbstractLogic` associated with the key.\n */\n getMetadata<T>(key: MetadataKey<any, T, any>): AbstractLogic<T> {\n cast<MetadataKey<unknown, unknown, unknown>>(key);\n if (!this.metadata.has(key)) {\n this.metadata.set(key, new MetadataMergeLogic(this.predicates, key));\n }\n return this.metadata.get(key)! as AbstractLogic<T>;\n }\n\n /**\n * Merges logic from another `Logic` instance into this one.\n * @param other The `Logic` instance to merge from.\n */\n mergeIn(other: LogicContainer) {\n this.hidden.mergeIn(other.hidden);\n this.disabledReasons.mergeIn(other.disabledReasons);\n this.readonly.mergeIn(other.readonly);\n this.syncErrors.mergeIn(other.syncErrors);\n this.syncTreeErrors.mergeIn(other.syncTreeErrors);\n this.asyncErrors.mergeIn(other.asyncErrors);\n for (const key of other.getMetadataKeys()) {\n const metadataLogic = other.metadata.get(key)!;\n this.getMetadata(key).mergeIn(metadataLogic);\n }\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ɵRuntimeError as RuntimeError} from '@angular/core';\nimport {RuntimeErrorCode} from '../errors';\n\nimport type {MetadataKey, ValidationError} from '../api/rules';\nimport type {AsyncValidationResult, DisabledReason, LogicFn, ValidationResult} from '../api/types';\nimport {setBoundPathDepthForResolution} from '../field/resolution';\nimport {type BoundPredicate, DYNAMIC, LogicContainer, type Predicate} from './logic';\n\n/**\n * Abstract base class for building a `LogicNode`.\n * This class defines the interface for adding various logic rules (e.g., hidden, disabled)\n * and data factories to a node in the logic tree.\n * LogicNodeBuilders are 1:1 with nodes in the Schema tree.\n */\nexport abstract class AbstractLogicNodeBuilder {\n constructor(\n /** The depth of this node in the schema tree. */\n protected readonly depth: number,\n ) {}\n\n /** Adds a rule to determine if a field should be hidden. */\n abstract addHiddenRule(logic: LogicFn<any, boolean>): void;\n\n /** Adds a rule to determine if a field should be disabled, and for what reason. */\n abstract addDisabledReasonRule(logic: LogicFn<any, DisabledReason | undefined>): void;\n\n /** Adds a rule to determine if a field should be read-only. */\n abstract addReadonlyRule(logic: LogicFn<any, boolean>): void;\n\n /** Adds a rule for synchronous validation errors for a field. */\n abstract addSyncErrorRule(logic: LogicFn<any, ValidationResult>): void;\n\n /** Adds a rule for synchronous validation errors that apply to a subtree. */\n abstract addSyncTreeErrorRule(logic: LogicFn<any, ValidationResult>): void;\n\n /** Adds a rule for asynchronous validation errors for a field. */\n abstract addAsyncErrorRule(logic: LogicFn<any, AsyncValidationResult>): void;\n\n /** Adds a rule to compute metadata for a field. */\n abstract addMetadataRule<M>(key: MetadataKey<unknown, M, unknown>, logic: LogicFn<any, M>): void;\n\n /**\n * Gets a builder for a child node associated with the given property key.\n * @param key The property key of the child.\n * @returns A `LogicNodeBuilder` for the child.\n */\n abstract getChild(key: PropertyKey): LogicNodeBuilder;\n\n /**\n * Checks whether a particular `AbstractLogicNodeBuilder` has been merged into this one.\n * @param builder The builder to check for.\n * @returns True if the builder has been merged, false otherwise.\n */\n abstract hasLogic(builder: AbstractLogicNodeBuilder): boolean;\n\n /**\n * Checks whether this builder or any of its children have any logic rules defined.\n * @returns True if rules exist, false otherwise.\n */\n abstract hasRules(): boolean;\n\n /**\n * Checks whether any of the children of this builder have any logic rules defined.\n * @returns True if rules exist on any child, false otherwise.\n */\n abstract anyChildHasLogic(): boolean;\n\n /**\n * Builds the `LogicNode` from the accumulated rules and child builders.\n * @returns The constructed `LogicNode`.\n */\n build(): LogicNode {\n return new LeafLogicNode(this, [], 0);\n }\n}\n\n/**\n * A builder for `LogicNode`. Used to add logic to the final `LogicNode` tree.\n * This builder supports merging multiple sources of logic, potentially with predicates,\n * preserving the order of rule application.\n */\nexport class LogicNodeBuilder extends AbstractLogicNodeBuilder {\n constructor(depth: number) {\n super(depth);\n }\n\n /**\n * The current `NonMergeableLogicNodeBuilder` being used to add rules directly to this\n * `LogicNodeBuilder`. Do not use this directly, call `getCurrent()` which will create a current\n * builder if there is none.\n */\n private current: NonMergeableLogicNodeBuilder | undefined;\n /**\n * Stores all builders that contribute to this node, along with any predicates\n * that gate their application.\n */\n readonly all: {builder: AbstractLogicNodeBuilder; predicate?: Predicate}[] = [];\n\n override addHiddenRule(logic: LogicFn<any, boolean>): void {\n this.getCurrent().addHiddenRule(logic);\n }\n\n override addDisabledReasonRule(logic: LogicFn<any, DisabledReason | undefined>): void {\n this.getCurrent().addDisabledReasonRule(logic);\n }\n\n override addReadonlyRule(logic: LogicFn<any, boolean>): void {\n this.getCurrent().addReadonlyRule(logic);\n }\n\n override addSyncErrorRule(\n logic: LogicFn<any, ValidationResult<ValidationError.WithFieldTree>>,\n ): void {\n this.getCurrent().addSyncErrorRule(logic);\n }\n\n override addSyncTreeErrorRule(\n logic: LogicFn<any, ValidationResult<ValidationError.WithFieldTree>>,\n ): void {\n this.getCurrent().addSyncTreeErrorRule(logic);\n }\n\n override addAsyncErrorRule(\n logic: LogicFn<any, AsyncValidationResult<ValidationError.WithFieldTree>>,\n ): void {\n this.getCurrent().addAsyncErrorRule(logic);\n }\n\n override addMetadataRule<T>(key: MetadataKey<unknown, T, any>, logic: LogicFn<any, T>): void {\n this.getCurrent().addMetadataRule(key, logic);\n }\n\n override getChild(key: PropertyKey): LogicNodeBuilder {\n // Close off the current builder if the key is DYNAMIC and the current builder already has logic\n // for some non-DYNAMIC key. This guarantees that all of the DYNAMIC logic always comes before\n // all of the specific-key logic for any given instance of `NonMergeableLogicNodeBuilder`.\n // We rely on this fact in `getAllChildBuilder` to know that we can return the DYNAMIC logic,\n // followed by the property-specific logic, in that order.\n if (key === DYNAMIC) {\n const children = this.getCurrent().children;\n // Use the children size to determine if there is logic registered for a property other than\n // the DYNAMIC property.\n // - If the children map doesn't have DYNAMIC logic, but the size is still >0 then we know it\n // has logic for some other property.\n // - If the children map does have DYNAMIC logic then its size is going to be at least 1,\n // because it has the DYNAMIC key. However if it is >1, then we again know it contains other\n // keys.\n if (children.size > (children.has(DYNAMIC) ? 1 : 0)) {\n this.current = undefined;\n }\n }\n return this.getCurrent().getChild(key);\n }\n\n override hasLogic(builder: AbstractLogicNodeBuilder): boolean {\n if (this === builder) {\n return true;\n }\n return this.all.some(({builder: subBuilder}) => subBuilder.hasLogic(builder));\n }\n\n override hasRules(): boolean {\n return this.all.length > 0;\n }\n\n override anyChildHasLogic(): boolean {\n return this.all.some(({builder}) => builder.anyChildHasLogic());\n }\n\n /**\n * Merges logic from another `LogicNodeBuilder` into this one.\n * If a `predicate` is provided, all logic from the `other` builder will only apply\n * when the predicate evaluates to true.\n * @param other The `LogicNodeBuilder` to merge in.\n * @param predicate An optional predicate to gate the merged logic.\n */\n mergeIn(other: LogicNodeBuilder, predicate?: Predicate): void {\n // Add the other builder to our collection, we'll defer the actual merging of the logic until\n // the logic node is requested to be created. In order to preserve the original ordering of the\n // rules, we close off the current builder to any further edits. If additional logic is added,\n // a new current builder will be created to capture it.\n if (predicate) {\n this.all.push({\n builder: other,\n predicate: {\n fn: setBoundPathDepthForResolution(predicate.fn, this.depth),\n path: predicate.path,\n },\n });\n } else {\n this.all.push({builder: other});\n }\n this.current = undefined;\n }\n\n /**\n * Gets the current `NonMergeableLogicNodeBuilder` for adding rules directly to this\n * `LogicNodeBuilder`. If no current builder exists, a new one is created.\n * The current builder is cleared whenever `mergeIn` is called to preserve the order\n * of rules when merging separate builder trees.\n * @returns The current `NonMergeableLogicNodeBuilder`.\n */\n private getCurrent(): NonMergeableLogicNodeBuilder {\n if (this.current === undefined) {\n this.current = new NonMergeableLogicNodeBuilder(this.depth);\n this.all.push({builder: this.current});\n }\n return this.current;\n }\n\n /**\n * Creates a new root `LogicNodeBuilder`.\n * @returns A new instance of `LogicNodeBuilder`.\n */\n static newRoot(): LogicNodeBuilder {\n return new LogicNodeBuilder(0);\n }\n}\n\n/**\n * A type of `AbstractLogicNodeBuilder` used internally by the `LogicNodeBuilder` to record \"pure\"\n * chunks of logic that do not require merging in other builders.\n */\nclass NonMergeableLogicNodeBuilder extends AbstractLogicNodeBuilder {\n /** The collection of logic rules directly added to this builder. */\n readonly logic = new LogicContainer([]);\n /**\n * A map of child property keys to their corresponding `LogicNodeBuilder` instances.\n * This allows for building a tree of logic.\n */\n readonly children = new Map<PropertyKey, LogicNodeBuilder>();\n\n constructor(depth: number) {\n super(depth);\n }\n\n override addHiddenRule(logic: LogicFn<any, boolean>): void {\n this.logic.hidden.push(setBoundPathDepthForResolution(logic, this.depth));\n }\n\n override addDisabledReasonRule(logic: LogicFn<any, DisabledReason | undefined>): void {\n this.logic.disabledReasons.push(setBoundPathDepthForResolution(logic, this.depth));\n }\n\n override addReadonlyRule(logic: LogicFn<any, boolean>): void {\n this.logic.readonly.push(setBoundPathDepthForResolution(logic, this.depth));\n }\n\n override addSyncErrorRule(\n logic: LogicFn<any, ValidationResult<ValidationError.WithFieldTree>>,\n ): void {\n this.logic.syncErrors.push(setBoundPathDepthForResolution(logic, this.depth));\n }\n\n override addSyncTreeErrorRule(\n logic: LogicFn<any, ValidationResult<ValidationError.WithFieldTree>>,\n ): void {\n this.logic.syncTreeErrors.push(setBoundPathDepthForResolution(logic, this.depth));\n }\n\n override addAsyncErrorRule(\n logic: LogicFn<any, AsyncValidationResult<ValidationError.WithFieldTree>>,\n ): void {\n this.logic.asyncErrors.push(setBoundPathDepthForResolution(logic, this.depth));\n }\n\n override addMetadataRule<T>(key: MetadataKey<unknown, T, unknown>, logic: LogicFn<any, T>): void {\n this.logic.getMetadata(key).push(setBoundPathDepthForResolution(logic, this.depth));\n }\n\n override getChild(key: PropertyKey): LogicNodeBuilder {\n if (!this.children.has(key)) {\n this.children.set(key, new LogicNodeBuilder(this.depth + 1));\n }\n return this.children.get(key)!;\n }\n\n override hasLogic(builder: AbstractLogicNodeBuilder): boolean {\n return this === builder;\n }\n\n override hasRules(): boolean {\n return this.logic.hasAnyLogic() || this.children.size > 0;\n }\n\n override anyChildHasLogic(): boolean {\n for (const child of this.children.values()) {\n if (child.hasRules()) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * Represents a node in the logic tree, containing all logic applicable\n * to a specific field or path in the form structure.\n * LogicNodes are 1:1 with nodes in the Field tree.\n */\nexport interface LogicNode {\n /** The collection of logic rules (hidden, disabled, errors, etc.) for this node. */\n readonly logic: LogicContainer;\n\n /**\n * Retrieves the `LogicNode` for a child identified by the given property key.\n * @param key The property key of the child.\n * @returns The `LogicNode` for the specified child.\n */\n getChild(key: PropertyKey): LogicNode;\n\n /**\n * Checks whether the logic from a particular `AbstractLogicNodeBuilder` has been merged into this\n * node.\n * @param builder The builder to check for.\n * @returns True if the builder has been merged, false otherwise.\n */\n hasLogic(builder: AbstractLogicNodeBuilder): boolean;\n\n /**\n * Checks whether this node or any of its children have any logic rules defined.\n * @returns True if rules exist, false otherwise.\n */\n hasRules(): boolean;\n\n /**\n * Checks whether any of the children of this node have any logic rules defined.\n * @returns True if rules exist on any child, false otherwise.\n */\n anyChildHasLogic(): boolean;\n}\n\n/**\n * A tree structure of `Logic` corresponding to a tree of fields.\n * This implementation represents a leaf in the sense that its logic is derived\n * from a single builder.\n */\nclass LeafLogicNode implements LogicNode {\n /** The computed logic for this node. */\n readonly logic: LogicContainer;\n\n /**\n * Constructs a `LeafLogicNode`.\n * @param builder The `AbstractLogicNodeBuilder` from which to derive the logic.\n * If undefined, an empty `Logic` instance is created.\n * @param predicates An array of predicates that gate the logic from the builder.\n */\n constructor(\n private builder: AbstractLogicNodeBuilder | undefined,\n private predicates: BoundPredicate[],\n /** The depth of this node in the field tree. */\n private depth: number,\n ) {\n this.logic = builder ? createLogic(builder, predicates, depth) : new LogicContainer([]);\n }\n\n // TODO: cache here, or just rely on the user of this API to do caching?\n /**\n * Retrieves the `LogicNode` for a child identified by the given property key.\n * @param key The property key of the child.\n * @returns The `LogicNode` for the specified child.\n */\n getChild(key: PropertyKey): LogicNode {\n // The logic for a particular child may be spread across multiple builders. We lazily combine\n // this logic at the time the child logic node is requested to be created.\n const childBuilders = this.builder ? getAllChildBuilders(this.builder, key) : [];\n if (childBuilders.length === 0) {\n return new LeafLogicNode(undefined, [], this.depth + 1);\n } else if (childBuilders.length === 1) {\n const {builder, predicates} = childBuilders[0];\n return new LeafLogicNode(\n builder,\n [...this.predicates, ...predicates.map((p) => bindLevel(p, this.depth))],\n this.depth + 1,\n );\n } else {\n const builtNodes = childBuilders.map(\n ({builder, predicates}) =>\n new LeafLogicNode(\n builder,\n [...this.predicates, ...predicates.map((p) => bindLevel(p, this.depth))],\n this.depth + 1,\n ),\n );\n return new CompositeLogicNode(builtNodes);\n }\n }\n\n hasLogic(builder: AbstractLogicNodeBuilder): boolean {\n if (!this.builder) {\n return false;\n }\n return this.builder.hasLogic(builder);\n }\n\n hasRules(): boolean {\n return this.builder ? this.builder.hasRules() : false;\n }\n\n anyChildHasLogic(): boolean {\n return this.builder ? this.builder.anyChildHasLogic() : false;\n }\n}\n\n/**\n * A `LogicNode` that represents the composition of multiple `LogicNode` instances.\n * This is used when logic for a particular path is contributed by several distinct\n * builder branches that need to be merged.\n */\nclass CompositeLogicNode implements LogicNode {\n /** The merged logic from all composed nodes. */\n readonly logic: LogicContainer;\n\n /**\n * Constructs a `CompositeLogicNode`.\n * @param all An array of `LogicNode` instances to compose.\n */\n constructor(private all: LogicNode[]) {\n this.logic = new LogicContainer([]);\n for (const node of all) {\n this.logic.mergeIn(node.logic);\n }\n }\n\n /**\n * Retrieves the child `LogicNode` by composing the results of `getChild` from all\n * underlying `LogicNode` instances.\n * @param key The property key of the child.\n * @returns A `CompositeLogicNode` representing the composed child.\n */\n getChild(key: PropertyKey): LogicNode {\n return new CompositeLogicNode(this.all.flatMap((child) => child.getChild(key)));\n }\n\n /**\n * Checks whether the logic from a particular `AbstractLogicNodeBuilder` has been merged into this\n * node.\n * @param builder The builder to check for.\n * @returns True if the builder has been merged, false otherwise.\n */\n hasLogic(builder: AbstractLogicNodeBuilder): boolean {\n return this.all.some((node) => node.hasLogic(builder));\n }\n\n hasRules(): boolean {\n return this.all.some((node) => node.hasRules());\n }\n\n anyChildHasLogic(): boolean {\n return this.all.some((child) => child.anyChildHasLogic());\n }\n}\n\n/**\n * Gets all of the builders that contribute logic to the given child of the parent builder.\n * This function recursively traverses the builder hierarchy.\n * @param builder The parent `AbstractLogicNodeBuilder`.\n * @param key The property key of the child.\n * @returns An array of objects, each containing a `LogicNodeBuilder` for the child and any associated predicates.\n */\nfunction getAllChildBuilders(\n builder: AbstractLogicNodeBuilder,\n key: PropertyKey,\n): {builder: LogicNodeBuilder; predicates: Predicate[]}[] {\n if (builder instanceof LogicNodeBuilder) {\n return builder.all.flatMap(({builder, predicate}) => {\n const children = getAllChildBuilders(builder, key);\n if (predicate) {\n return children.map(({builder, predicates}) => ({\n builder,\n predicates: [...predicates, predicate],\n }));\n }\n return children;\n });\n } else if (builder instanceof NonMergeableLogicNodeBuilder) {\n return [\n // DYNAMIC logic always comes first for any individual `NonMergeableLogicNodeBuilder`.\n // This assumption is guaranteed by the behavior of `LogicNodeBuilder.getChild`.\n // Therefore we can return all of the DYNAMIC logic, followed by all of the property-specific\n // logic.\n ...(key !== DYNAMIC && builder.children.has(DYNAMIC)\n ? [{builder: builder.getChild(DYNAMIC), predicates: []}]\n : []),\n ...(builder.children.has(key) ? [{builder: builder.getChild(key), predicates: []}] : []),\n ];\n } else {\n throw new RuntimeError(\n RuntimeErrorCode.UNKNOWN_BUILDER_TYPE,\n ngDevMode && 'Unknown LogicNodeBuilder type',\n );\n }\n}\n\n/**\n * Creates the full `Logic` for a given builder.\n * This function handles different types of builders (`LogicNodeBuilder`, `NonMergeableLogicNodeBuilder`)\n * and applies the provided predicates.\n * @param builder The `AbstractLogicNodeBuilder` to process.\n * @param predicates Predicates to apply to the logic derived from the builder.\n * @param depth The depth in the field tree of the field which this logic applies to.\n * @returns The `Logic` instance.\n */\nfunction createLogic(\n builder: AbstractLogicNodeBuilder,\n predicates: BoundPredicate[],\n depth: number,\n): LogicContainer {\n const logic = new LogicContainer(predicates);\n if (builder instanceof LogicNodeBuilder) {\n const builtNodes = builder.all.map(\n ({builder, predicate}) =>\n new LeafLogicNode(\n builder,\n predicate ? [...predicates, bindLevel(predicate, depth)] : predicates,\n depth,\n ),\n );\n for (const node of builtNodes) {\n logic.mergeIn(node.logic);\n }\n } else if (builder instanceof NonMergeableLogicNodeBuilder) {\n logic.mergeIn(builder.logic);\n } else {\n throw new RuntimeError(\n RuntimeErrorCode.UNKNOWN_BUILDER_TYPE,\n ngDevMode && 'Unknown LogicNodeBuilder type',\n );\n }\n return logic;\n}\n\n/**\n * Create a bound version of the given predicate to a specific depth in the field tree.\n * This allows us to unambiguously know which `FieldContext` the predicate function should receive.\n *\n * This is of particular concern when a schema is applied recursively to itself. Since the schema is\n * only compiled once, each nested application adds the same predicate instance. We differentiate\n * these by recording the depth of the field they're bound to.\n *\n * @param predicate The unbound predicate\n * @param depth The depth of the field the predicate is bound to\n * @returns A bound predicate\n */\nfunction bindLevel(predicate: Predicate, depth: number): BoundPredicate {\n return {...predicate, depth: depth};\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport type {SchemaPath, SchemaPathRules} from '../api/types';\nimport type {Predicate} from './logic';\nimport {LogicNodeBuilder} from './logic_node';\nimport type {SchemaImpl} from './schema';\n\n/**\n * Special key which is used to retrieve the `FieldPathNode` instance from its `FieldPath` proxy wrapper.\n */\nconst PATH = Symbol('PATH');\n\n/**\n * A path in the schema on which logic is stored so that it can be added to the corresponding field\n * when the field is created.\n */\nexport class FieldPathNode {\n /** The root path node from which this path node is descended. */\n readonly root: FieldPathNode;\n\n /**\n * A map containing all child path nodes that have been created on this path.\n * Child path nodes are created automatically on first access if they do not exist already.\n */\n private readonly children = new Map<PropertyKey, FieldPathNode>();\n\n /**\n * A proxy that wraps the path node, allowing navigation to its child paths via property access.\n */\n readonly fieldPathProxy: SchemaPath<any> = new Proxy(\n this,\n FIELD_PATH_PROXY_HANDLER,\n ) as unknown as SchemaPath<any>;\n\n /**\n * For a root path node this will contain the root logic builder. For non-root nodes,\n * they determine their logic builder from their parent so this is undefined.\n */\n private readonly logicBuilder: LogicNodeBuilder | undefined;\n\n protected constructor(\n /** The property keys used to navigate from the root path to this path. */\n readonly keys: PropertyKey[],\n root: FieldPathNode | undefined,\n /** The parent of this path node. */\n private readonly parent: FieldPathNode | undefined,\n /** The key of this node in its parent. */\n private readonly keyInParent: PropertyKey | undefined,\n ) {\n this.root = root ?? this;\n if (!parent) {\n this.logicBuilder = LogicNodeBuilder.newRoot();\n }\n }\n\n /** The logic builder used to accumulate logic on this path node. */\n get builder(): LogicNodeBuilder {\n if (this.logicBuilder) {\n return this.logicBuilder;\n }\n return this.parent!.builder.getChild(this.keyInParent!);\n }\n\n /**\n * Gets the path node for the given child property key.\n * Child paths are created automatically on first access if they do not exist already.\n */\n getChild(key: PropertyKey): FieldPathNode {\n if (!this.children.has(key)) {\n this.children.set(key, new FieldPathNode([...this.keys, key], this.root, this, key));\n }\n return this.children.get(key)!;\n }\n\n /**\n * Merges in logic from another schema to this one.\n * @param other The other schema to merge in the logic from\n * @param predicate A predicate indicating when the merged in logic should be active.\n */\n mergeIn(other: SchemaImpl, predicate?: Predicate) {\n const path = other.compile();\n this.builder.mergeIn(path.builder, predicate);\n }\n\n /** Extracts the underlying path node from the given path proxy. */\n static unwrapFieldPath(formPath: SchemaPath<unknown, SchemaPathRules>): FieldPathNode {\n return (formPath as any)[PATH] as FieldPathNode;\n }\n\n /** Creates a new root path node to be passed in to a schema function. */\n static newRoot() {\n return new FieldPathNode([], undefined, undefined, undefined);\n }\n}\n\n/** Proxy handler which implements `FieldPath` on top of a `FieldPathNode`. */\nexport const FIELD_PATH_PROXY_HANDLER: ProxyHandler<FieldPathNode> = {\n get(node: FieldPathNode, property: string | symbol) {\n if (property === PATH) {\n return node;\n }\n\n return node.getChild(property).fieldPathProxy;\n },\n};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {ɵRuntimeError as RuntimeError} from '@angular/core';\nimport {RuntimeErrorCode} from '../errors';\n\nimport {SchemaPath, SchemaFn, SchemaOrSchemaFn} from '../api/types';\nimport {FieldPathNode} from './path_node';\n\n/**\n * Keeps track of the path node for the schema function that is currently being compiled. This is\n * used to detect erroneous references to a path node outside of the context of its schema function.\n * Do not set this directly, it is a context variable managed by `SchemaImpl.compile`.\n */\nlet currentCompilingNode: FieldPathNode | undefined = undefined;\n\n/**\n * A cache of all schemas compiled under the current root compilation. This is used to avoid doing\n * extra work when compiling a schema that reuses references to the same sub-schema. For example:\n *\n * ```ts\n * const sub = schema(p => ...);\n * const s = schema(p => {\n * apply(p.a, sub);\n * apply(p.b, sub);\n * });\n * ```\n *\n * This also ensures that we don't go into an infinite loop when compiling a schema that references\n * itself.\n *\n * Do not directly add or remove entries from this map, it is a context variable managed by\n * `SchemaImpl.compile` and `SchemaImpl.rootCompile`.\n */\nconst compiledSchemas = new Map<SchemaImpl, FieldPathNode>();\n\n/**\n * Implements the `Schema` concept.\n */\nexport class SchemaImpl {\n constructor(private schemaFn: SchemaFn<unknown>) {}\n\n /**\n * Compiles this schema within the current root compilation context. If the schema was previously\n * compiled within this context, we reuse the cached FieldPathNode, otherwise we create a new one\n * and cache it in the compilation context.\n */\n compile(): FieldPathNode {\n if (compiledSchemas.has(this)) {\n return compiledSchemas.get(this)!;\n }\n const path = FieldPathNode.newRoot();\n compiledSchemas.set(this, path);\n let prevCompilingNode = currentCompilingNode;\n try {\n currentCompilingNode = path;\n this.schemaFn(path.fieldPathProxy);\n } finally {\n // Use a try/finally to ensure we restore the previous root upon completion,\n // even if there are errors while compiling the schema.\n currentCompilingNode = prevCompilingNode;\n }\n return path;\n }\n\n /**\n * Creates a SchemaImpl from the given SchemaOrSchemaFn.\n */\n static create(schema: SchemaImpl | SchemaOrSchemaFn<any>) {\n if (schema instanceof SchemaImpl) {\n return schema;\n }\n return new SchemaImpl(schema as SchemaFn<unknown>);\n }\n\n /**\n * Compiles the given schema in a fresh compilation context. This clears the cached results of any\n * previous compilations.\n */\n static rootCompile(schema: SchemaImpl | SchemaOrSchemaFn<any> | undefined): FieldPathNode {\n try {\n compiledSchemas.clear();\n if (schema === undefined) {\n return FieldPathNode.newRoot();\n }\n if (schema instanceof SchemaImpl) {\n return schema.compile();\n }\n return new SchemaImpl(schema as SchemaFn<unknown>).compile();\n } finally {\n // Use a try/finally to ensure we properly reset the compilation context upon completion,\n // even if there are errors while compiling the schema.\n compiledSchemas.clear();\n }\n }\n}\n\n/** Checks if the given value is a schema or schema function. */\nexport function isSchemaOrSchemaFn(value: unknown): value is SchemaOrSchemaFn<unknown> {\n return value instanceof SchemaImpl || typeof value === 'function';\n}\n\n/** Checks that a path node belongs to the schema function currently being compiled. */\nexport function assertPathIsCurrent(path: SchemaPath<unknown>): void {\n if (currentCompilingNode !== FieldPathNode.unwrapFieldPath(path).root) {\n throw new RuntimeError(\n RuntimeErrorCode.PATH_OUTSIDE_SCHEMA,\n ngDevMode &&\n `A FieldPath can only be used directly within the Schema that owns it, **not** outside of it or within a sub-schema.`,\n );\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {type Signal} from '@angular/core';\nimport {FieldPathNode} from '../../schema/path_node';\nimport {assertPathIsCurrent} from '../../schema/schema';\nimport type {FieldState, LogicFn, PathKind, SchemaPath, SchemaPathRules} from '../types';\n\n/**\n * Sets a value for the {@link MetadataKey} for this field.\n *\n * This value is combined via a reduce operation defined by the particular key,\n * since multiple rules in the schema might set values for it.\n *\n * @param path The target path to set the metadata for.\n * @param key The metadata key\n * @param logic A function that receives the `FieldContext` and returns a value for the metadata.\n * @template TValue The type of value stored in the field the logic is bound to.\n * @template TKey The type of metadata key.\n * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)\n *\n * @see [Field metadata](guide/forms/signals/field-metadata)\n * @see [Setting values from a schema](guide/forms/signals/field-metadata#setting-values-from-a-schema)\n *\n * @category logic\n * @publicApi 22.0\n */\nexport function metadata<\n TValue,\n TKey extends MetadataKey<any, any, any>,\n TPathKind extends PathKind = PathKind.Root,\n>(\n path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>,\n key: TKey,\n logic: NoInfer<\n LogicFn<\n TValue,\n TKey extends LimitSelectionKey ? LimitKey<TValue> : MetadataSetterType<TKey>,\n TPathKind\n >\n >,\n): TKey {\n assertPathIsCurrent(path);\n\n const pathNode = FieldPathNode.unwrapFieldPath(path);\n pathNode.builder.addMetadataRule(key, logic);\n return key;\n}\n\n/**\n * A reducer that determines the accumulated value for a metadata key by reducing the individual\n * values contributed from `metadata()` rules.\n *\n * @template TAcc The accumulated type of the reduce operation.\n * @template TItem The type of the individual items that are reduced over.\n *\n * @see [Combining contributions with reducers](guide/forms/signals/field-metadata#combining-contributions-with-reducers)\n *\n * @publicApi 22.0\n */\nexport interface MetadataReducer<TAcc, TItem> {\n /** The reduce function. */\n reduce: (acc: TAcc, item: TItem) => TAcc;\n /** Gets the initial accumulated value. */\n getInitial: () => TAcc;\n}\nexport const MetadataReducer = {\n /** Creates a reducer that accumulates a list of its individual item values. */\n list<TItem>(): MetadataReducer<TItem[], TItem | undefined> {\n return {\n reduce: (acc, item) => (item === undefined ? acc : [...acc, item]),\n getInitial: () => [],\n };\n },\n\n /** Creates a reducer that accumulates the min of its individual item values. */\n min<T extends Date | number>(): MetadataReducer<T | undefined, T | undefined> {\n return {\n reduce: (acc, item) => {\n if (acc === undefined || item === undefined) {\n return acc ?? item;\n }\n return item < acc ? item : acc;\n },\n getInitial: () => undefined,\n };\n },\n\n /** Creates a reducer that accumulates a the max of its individual item values. */\n max<T extends Date | number>(): MetadataReducer<T | undefined, T | undefined> {\n return {\n reduce: (acc, item) => {\n if (acc === undefined || item === undefined) {\n return acc ?? item;\n }\n return item > acc ? item : acc;\n },\n getInitial: () => undefined,\n };\n },\n\n /** Creates a reducer that logically or's its accumulated value with each individual item value. */\n or(): MetadataReducer<boolean, boolean> {\n return {\n reduce: (prev, next) => prev || next,\n getInitial: () => false,\n };\n },\n\n /** Creates a reducer that logically and's its accumulated value with each individual item value. */\n and(): MetadataReducer<boolean, boolean> {\n return {\n reduce: (prev, next) => prev && next,\n getInitial: () => true,\n };\n },\n\n /** Creates a reducer that always takes the next individual item value as the accumulated value. */\n override,\n} as const;\n\nfunction override<T>(): MetadataReducer<T | undefined, T>;\nfunction override<T>(getInitial: () => T): MetadataReducer<T, T>;\nfunction override<T>(getInitial?: () => T): MetadataReducer<T | undefined, T> {\n return {\n reduce: (_, item) => item,\n getInitial: () => getInitial?.(),\n };\n}\n\n/**\n * A symbol used to tag a `MetadataKey` as representing an asynchronous validation resource.\n *\n * @see [Async validation](guide/forms/signals/validation#async-validation)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const IS_ASYNC_VALIDATION_RESOURCE: unique symbol = Symbol('IS_ASYNC_VALIDATION_RESOURCE');\n\n/**\n * Represents metadata that is aggregated from multiple parts according to the key's reducer\n * function. A value can be contributed to the aggregated value for a field using an\n * `metadata` rule in the schema. There may be multiple rules in a schema that contribute\n * values to the same `MetadataKey` of the same field.\n *\n * @template TRead The type read from the `FieldState` for this key\n * @template TWrite The type written to this key using the `metadata()` rule\n * @template TAcc The type of the reducer's accumulated value.\n *\n * @see [Field metadata](guide/forms/signals/field-metadata)\n *\n * @publicApi 22.0\n */\nexport class MetadataKey<TRead, TWrite, TAcc> {\n private brand!: (write: TWrite) => [TRead, TAcc];\n\n /** @internal */\n [IS_ASYNC_VALIDATION_RESOURCE]?: true;\n\n /** Use {@link createMetadataKey}. */\n protected constructor(\n readonly reducer: MetadataReducer<TAcc, TWrite>,\n readonly create: ((state: FieldState<unknown>, data: Signal<TAcc>) => TRead) | undefined,\n ) {}\n}\n\n/**\n * Represents metadata that is used to define a valid limit for a field.\n *\n * @template TLimit The type the limit value.\n *\n * @see [Validation constraints](guide/forms/signals/custom-controls#validation-constraints)\n *\n * @publicApi 22.0\n */\nexport type LimitKey<TLimit> = MetadataKey<\n Signal<NonNullable<TLimit> | undefined>,\n NonNullable<TLimit> | undefined,\n NonNullable<TLimit> | undefined\n>;\n\n/**\n * A symbol used to tag a `MetadataKey` as representing a limit selection key.\n */\ndeclare const LIMIT_SELECTION_KEY: unique symbol;\n\n/**\n * Used to select a {@link LimitKey}.\n *\n * This indirection allows rules to bind a {@link LimitKey} of a specific limit type (e.g. `number`\n * or `Date`) matching the field's type to a generic {@link MetadataKey}.\n *\n * @see [Validation constraints](guide/forms/signals/custom-controls#validation-constraints)\n *\n * @publicApi 22.0\n */\nexport type LimitSelectionKey = MetadataKey<\n Signal<LimitKey<unknown> | undefined>,\n LimitKey<unknown>,\n LimitKey<unknown> | undefined\n> & {\n [LIMIT_SELECTION_KEY]: true;\n};\n\n/**\n * Extracts the the type that can be set into the given metadata key type using the `metadata()` rule.\n *\n * @template TKey The `MetadataKey` type\n *\n * @see [Field metadata](guide/forms/signals/field-metadata)\n *\n * @publicApi 22.0\n */\nexport type MetadataSetterType<TKey> =\n TKey extends MetadataKey<any, infer TWrite, any> ? TWrite : never;\n\n/**\n * Creates a metadata key used to contain a computed value.\n * The last value set on a given field tree node overrides any previously set values.\n *\n * @template TWrite The type written to this key using the `metadata()` rule\n *\n * @see [Creating a metadata key](guide/forms/signals/field-metadata#creating-a-metadata-key)\n *\n * @publicApi 22.0\n */\nexport function createMetadataKey<TWrite>(): MetadataKey<\n Signal<TWrite | undefined>,\n TWrite,\n TWrite | undefined\n>;\n/**\n * Creates a metadata key used to contain a computed value.\n *\n * @param reducer The reducer used to combine individually set values into the final computed value.\n * @template TWrite The type written to this key using the `metadata()` rule\n * @template TAcc The type of the reducer's accumulated value.\n *\n * @see [Creating a metadata key](guide/forms/signals/field-metadata#creating-a-metadata-key)\n *\n * @publicApi 22.0\n */\nexport function createMetadataKey<TWrite, TAcc>(\n reducer: MetadataReducer<TAcc, TWrite>,\n): MetadataKey<Signal<TAcc>, TWrite, TAcc>;\nexport function createMetadataKey<TWrite, TAcc>(\n reducer?: MetadataReducer<TAcc, TWrite>,\n): MetadataKey<Signal<TAcc>, TWrite, TAcc> {\n return new (MetadataKey as new (\n reducer: MetadataReducer<TAcc, TWrite>,\n ) => MetadataKey<Signal<TAcc>, TWrite, TAcc>)(reducer ?? MetadataReducer.override<any>());\n}\n\n/**\n * Creates a metadata key that exposes a managed value based on the accumulated result of the values\n * written to the key. The accumulated value takes the last value set on a given field tree node,\n * overriding any previously set values.\n *\n * @param create A function that receives a signal of the accumulated value and returns the managed\n * value based on it. This function runs during the construction of the `FieldTree` node,\n * and runs in the injection context of that node.\n * @template TRead The type read from the `FieldState` for this key\n * @template TWrite The type written to this key using the `metadata()` rule\n *\n * @see [Attaching lifecycle-aware objects with managed metadata](guide/forms/signals/field-metadata#attaching-lifecycle-aware-objects-with-managed-metadata)\n *\n * @publicApi 22.0\n */\nexport function createManagedMetadataKey<TRead, TWrite>(\n create: (state: FieldState<unknown>, data: Signal<TWrite | undefined>) => TRead,\n): MetadataKey<TRead, TWrite, TWrite | undefined>;\n/**\n * Creates a metadata key that exposes a managed value based on the accumulated result of the values\n * written to the key.\n *\n * @param create A function that receives a signal of the accumulated value and returns the managed\n * value based on it. This function runs during the construction of the `FieldTree` node,\n * and runs in the injection context of that node.\n * @param reducer The reducer used to combine individual value written to the key,\n * this will determine the accumulated value that the create function receives.\n * @template TRead The type read from the `FieldState` for this key\n * @template TWrite The type written to this key using the `metadata()` rule\n * @template TAcc The type of the reducer's accumulated value.\n *\n * @see [Attaching lifecycle-aware objects with managed metadata](guide/forms/signals/field-metadata#attaching-lifecycle-aware-objects-with-managed-metadata)\n *\n * @publicApi 22.0\n */\nexport function createManagedMetadataKey<TRead, TWrite, TAcc>(\n create: (state: FieldState<unknown>, data: Signal<TAcc>) => TRead,\n reducer: MetadataReducer<TAcc, TWrite>,\n): MetadataKey<TRead, TWrite, TAcc>;\nexport function createManagedMetadataKey<TRead, TWrite, TAcc>(\n create: (state: FieldState<unknown>, data: Signal<TAcc>) => TRead,\n reducer?: MetadataReducer<TAcc, TWrite>,\n): MetadataKey<TRead, TWrite, TAcc> {\n return new (MetadataKey as new (\n reducer: MetadataReducer<TAcc, TWrite>,\n create: (state: FieldState<unknown>, data: Signal<TAcc>) => TRead,\n ) => MetadataKey<TRead, TWrite, TAcc>)(reducer ?? MetadataReducer.override<any>(), create);\n}\n\n/**\n * Creates a {@link LimitSelectionKey}.\n *\n * @see [Validation constraints](guide/forms/signals/custom-controls#validation-constraints)\n *\n * @publicApi 22.0\n */\nexport function createLimitSelectionKey(): LimitSelectionKey {\n return createMetadataKey() as LimitSelectionKey;\n}\n\n/**\n * A {@link MetadataKey} representing whether the field is required.\n *\n * @see [Required validation](guide/forms/signals/validation#required)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const REQUIRED: MetadataKey<Signal<boolean>, boolean, boolean> = createMetadataKey(\n MetadataReducer.or(),\n);\n\n/**\n * A {@link MetadataKey} that points to another key determining the minimum value of the field.\n *\n * This indirection allows different keys to be used for different types of values with their\n * own reducers, such as {@link MIN_DATE} and {@link MIN_NUMBER}.\n *\n * @see [Minimum and maximum validation](guide/forms/signals/validation#min-and-max)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MIN: LimitSelectionKey = createLimitSelectionKey();\n\n/**\n * A {@link MetadataKey} representing the minimum valid value of a date field.\n *\n * @see [Minimum and maximum validation](guide/forms/signals/validation#min-and-max)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MIN_DATE: LimitKey<Date> = createMetadataKey(MetadataReducer.max());\n\n/**\n * A {@link MetadataKey} representing the minimum valid value of a number field.\n *\n * @see [Minimum and maximum validation](guide/forms/signals/validation#min-and-max)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MIN_NUMBER: LimitKey<number> = createMetadataKey(MetadataReducer.max());\n\n/**\n * A {@link MetadataKey} that points to another key determining the maximum value of the field.\n *\n * This indirection allows different keys to be used for different types of values with their\n * own reducers, such as {@link MAX_DATE} and {@link MAX_NUMBER}.\n *\n * @see [Minimum and maximum validation](guide/forms/signals/validation#min-and-max)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MAX: LimitSelectionKey = createLimitSelectionKey();\n\n/**\n * A {@link MetadataKey} representing the maximum valid value of a date field.\n *\n * @see [Minimum and maximum validation](guide/forms/signals/validation#min-and-max)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MAX_DATE: LimitKey<Date> = createMetadataKey(MetadataReducer.min());\n\n/**\n * A {@link MetadataKey} representing the maximum valid value of a number field.\n *\n * @see [Minimum and maximum validation](guide/forms/signals/validation#min-and-max)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MAX_NUMBER: LimitKey<number> = createMetadataKey(MetadataReducer.min());\n\n/**\n * A {@link MetadataKey} representing the min length of the field.\n *\n * @see [Minimum and maximum length validation](guide/forms/signals/validation#minlength-and-maxlength)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MIN_LENGTH: LimitKey<number> = createMetadataKey(MetadataReducer.max());\n\n/**\n * A {@link MetadataKey} representing the max length of the field.\n *\n * @see [Minimum and maximum length validation](guide/forms/signals/validation#minlength-and-maxlength)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const MAX_LENGTH: LimitKey<number> = createMetadataKey(MetadataReducer.min());\n\n/**\n * A {@link MetadataKey} representing the patterns the field must match.\n *\n * @see [Pattern validation](guide/forms/signals/validation#pattern)\n *\n * @category validation\n * @publicApi 22.0\n */\nexport const PATTERN: MetadataKey<\n Signal<RegExp[]>,\n RegExp | undefined,\n RegExp[]\n> = createMetadataKey(MetadataReducer.list<RegExp>());\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * Checks shallow equality of two arrays.\n * Returns true if both are arrays and have the same elements in the same order.\n */\nexport function shallowArrayEquals<T>(\n a: readonly T[] | undefined,\n b: readonly T[] | undefined,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!Object.is(a[i], b[i])) return false;\n }\n return true;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal, untracked, ɵWritable} from '@angular/core';\nimport type {ValidationError} from '../api/rules/validation/validation_errors';\nimport type {ReadonlyFieldTree, TreeValidationResult, ValidationResult} from '../api/types';\nimport {isArray} from '../util/type_guards';\nimport type {FieldNode} from './node';\nimport {shortCircuitFalse} from './util';\nimport {shallowArrayEquals} from '../util/array';\n\n/**\n * Helper function taking validation state, and returning own state of the node.\n * @param state\n */\nexport function calculateValidationSelfStatus(\n state: ValidationState,\n): 'invalid' | 'unknown' | 'valid' {\n if (state.errors().length > 0) {\n return 'invalid';\n }\n if (state.pending()) {\n return 'unknown';\n }\n\n return 'valid';\n}\n\nexport interface ValidationState {\n /**\n * The full set of synchronous tree errors visible to this field. This includes ones that are\n * targeted at a descendant field rather than at this field.\n */\n rawSyncTreeErrors: Signal<ValidationError.WithFieldTree[]>;\n\n /**\n * The full set of synchronous errors for this field, including synchronous tree errors and submission\n * errors. Submission errors are considered \"synchronous\" because they are imperatively added. From\n * the perspective of the field state they are either there or not, they are never in a pending\n * state.\n */\n syncErrors: Signal<ValidationError.WithFieldTree[]>;\n\n /**\n * Whether the field is considered valid according solely to its synchronous validators.\n * Errors resulting from a previous submit attempt are also considered for this state.\n */\n syncValid: Signal<boolean>;\n\n /**\n * The full set of asynchronous tree errors visible to this field. This includes ones that are\n * targeted at a descendant field rather than at this field, as well as sentinel 'pending' values\n * indicating that the validator is still running and an error could still occur.\n */\n rawAsyncErrors: Signal<(ValidationError.WithFieldTree | 'pending')[]>;\n\n /**\n * The asynchronous tree errors visible to this field that are specifically targeted at this field\n * rather than a descendant. This also includes all 'pending' sentinel values, since those could\n * theoretically result in errors for this field.\n */\n asyncErrors: Signal<(ValidationError.WithFieldTree | 'pending')[]>;\n\n /**\n * The combined set of all errors that currently apply to this field.\n */\n errors: Signal<ValidationError.WithFieldTree[]>;\n\n parseErrors: Signal<ValidationError.WithFormField[]>;\n\n /**\n * The combined set of all errors that currently apply to this field and its descendants.\n */\n errorSummary: Signal<ValidationError.WithFieldTree[]>;\n\n /**\n * Whether this field has any asynchronous validators still pending.\n */\n pending: Signal<boolean>;\n\n /**\n * The validation status of the field.\n * - The status is 'valid' if neither the field nor any of its children has any errors or pending\n * validators.\n * - The status is 'invalid' if the field or any of its children has an error\n * (regardless of pending validators)\n * - The status is 'unknown' if neither the field nor any of its children has any errors,\n * but the field or any of its children does have a pending validator.\n *\n * A field is considered valid if *all* of the following are true:\n * - It has no errors or pending validators\n * - All of its children are considered valid\n * A field is considered invalid if *any* of the following are true:\n * - It has an error\n * - Any of its children is considered invalid\n * A field is considered to have unknown validity status if it is not valid or invalid.\n */\n status: Signal<'valid' | 'invalid' | 'unknown'>;\n /**\n * Whether the field is considered valid.\n *\n * A field is considered valid if *all* of the following are true:\n * - It has no errors or pending validators\n * - All of its children are considered valid\n *\n * Note: `!valid()` is *not* the same as `invalid()`. Both `valid()` and `invalid()` can be false\n * if there are currently no errors, but validators are still pending.\n */\n valid: Signal<boolean>;\n\n /**\n * Whether the field is considered invalid.\n *\n * A field is considered invalid if *any* of the following are true:\n * - It has an error\n * - Any of its children is considered invalid\n *\n * Note: `!invalid()` is *not* the same as `valid()`. Both `valid()` and `invalid()` can be false\n * if there are currently no errors, but validators are still pending.\n */\n invalid: Signal<boolean>;\n\n /**\n * Indicates whether validation should be skipped for this field because it is hidden, disabled,\n * or readonly.\n */\n shouldSkipValidation: Signal<boolean>;\n}\n\n/**\n * The validation state associated with a `FieldNode`.\n *\n * This class collects together various types of errors to represent the full validation state of\n * the field. There are 4 types of errors that need to be combined to determine validity:\n * 1. The synchronous errors produced by the schema logic.\n * 2. The synchronous tree errors produced by the schema logic. Tree errors may apply to a different\n * field than the one that the logic that produced them is bound to. They support targeting the\n * error at an arbitrary descendant field.\n * 3. The asynchronous tree errors produced by the schema logic. These work like synchronous tree\n * errors, except the error list may also contain a special sentinel value indicating that a\n * validator is still running.\n * 4. Server errors are not produced by the schema logic, but instead get imperatively added when a\n * form submit fails with errors.\n */\nexport class FieldValidationState implements ValidationState {\n constructor(readonly node: FieldNode) {}\n\n /**\n * The full set of synchronous tree errors visible to this field. This includes ones that are\n * targeted at a descendant field rather than at this field.\n */\n readonly rawSyncTreeErrors: Signal<ValidationError.WithFieldTree[]> = computed(\n () => {\n if (this.shouldSkipValidation()) {\n return [];\n }\n\n return [\n ...this.node.logicNode.logic.syncTreeErrors.compute(this.node.context),\n ...(this.node.structure.parent?.validationState.rawSyncTreeErrors() ?? []),\n ];\n },\n {equal: shallowArrayEquals},\n );\n\n /**\n * The full set of synchronous errors for this field, including synchronous tree errors and\n * submission errors. Submission errors are considered \"synchronous\" because they are imperatively\n * added. From the perspective of the field state they are either there or not, they are never in a\n * pending state.\n */\n readonly syncErrors: Signal<ValidationError.WithFieldTree[]> = computed(\n () => {\n // Short-circuit running validators if validation doesn't apply to this field.\n if (this.shouldSkipValidation()) {\n return [];\n }\n\n return [\n ...this.node.logicNode.logic.syncErrors.compute(this.node.context),\n ...this.syncTreeErrors(),\n ...normalizeErrors(this.node.submitState.submissionErrors()),\n ];\n },\n {equal: shallowArrayEquals},\n );\n\n /**\n * Whether the field is considered valid according solely to its synchronous validators.\n * Errors resulting from a previous submit attempt are also considered for this state.\n */\n readonly syncValid: Signal<boolean> = computed(() => {\n // Short-circuit checking children if validation doesn't apply to this field.\n if (this.shouldSkipValidation()) {\n return true;\n }\n\n return this.node.structure.reduceChildren(\n this.syncErrors().length === 0,\n (child, value) => value && child.validationState.syncValid(),\n shortCircuitFalse,\n );\n });\n\n /**\n * The synchronous tree errors visible to this field that are specifically targeted at this field\n * rather than a descendant.\n */\n readonly syncTreeErrors: Signal<ValidationError.WithFieldTree[]> = computed(\n () => this.rawSyncTreeErrors().filter((err) => err.fieldTree === this.node.fieldTree),\n {equal: shallowArrayEquals},\n );\n\n /**\n * The full set of asynchronous tree errors visible to this field. This includes ones that are\n * targeted at a descendant field rather than at this field, as well as sentinel 'pending' values\n * indicating that the validator is still running and an error could still occur.\n */\n readonly rawAsyncErrors: Signal<(ValidationError.WithFieldTree | 'pending')[]> = computed(\n () => {\n // Short-circuit running validators if validation doesn't apply to this field.\n if (this.shouldSkipValidation()) {\n return [];\n }\n\n return [\n // TODO: add field in `validateAsync` and remove this map\n ...this.node.logicNode.logic.asyncErrors.compute(this.node.context),\n // TODO: does it make sense to filter this to errors in this subtree?\n ...(this.node.structure.parent?.validationState.rawAsyncErrors() ?? []),\n ];\n },\n {equal: shallowArrayEquals},\n );\n\n /**\n * The asynchronous tree errors visible to this field that are specifically targeted at this field\n * rather than a descendant. This also includes all 'pending' sentinel values, since those could\n * theoretically result in errors for this field.\n */\n readonly asyncErrors: Signal<(ValidationError.WithFieldTree | 'pending')[]> = computed(\n () => {\n if (this.shouldSkipValidation()) {\n return [];\n }\n return this.rawAsyncErrors().filter(\n (err) => err === 'pending' || err.fieldTree === this.node.fieldTree,\n );\n },\n {equal: shallowArrayEquals},\n );\n\n readonly parseErrors: Signal<ValidationError.WithFormField[]> = computed(\n () => this.node.formFieldBindings().flatMap((field) => field.parseErrors()),\n {equal: shallowArrayEquals},\n );\n\n /**\n * The combined set of all errors that currently apply to this field.\n */\n readonly errors = computed(\n () => [\n ...this.parseErrors(),\n ...this.syncErrors(),\n ...this.asyncErrors().filter((err) => err !== 'pending'),\n ],\n {equal: shallowArrayEquals},\n );\n\n readonly errorSummary = computed(\n () => {\n const errors = this.node.structure.reduceChildren(this.errors(), (child, result) => [\n ...result,\n ...child.errorSummary(),\n ]);\n // Sort by DOM order on client-side only.\n if (typeof ngServerMode === 'undefined' || !ngServerMode) {\n untracked(() => errors.sort(compareErrorPosition));\n }\n return errors;\n },\n {equal: shallowArrayEquals},\n );\n\n /**\n * Whether this field has any asynchronous validators still pending.\n */\n readonly pending = computed(() =>\n this.node.structure.reduceChildren(\n this.asyncErrors().includes('pending'),\n (child, value) => value || child.validationState.pending(),\n ),\n );\n\n /**\n * The validation status of the field.\n * - The status is 'valid' if neither the field nor any of its children has any errors or pending\n * validators.\n * - The status is 'invalid' if the field or any of its children has an error\n * (regardless of pending validators)\n * - The status is 'unknown' if neither the field nor any of its children has any errors,\n * but the field or any of its children does have a pending validator.\n *\n * A field is considered valid if *all* of the following are true:\n * - It has no errors or pending validators\n * - All of its children are considered valid\n * A field is considered invalid if *any* of the following are true:\n * - It has an error\n * - Any of its children is considered invalid\n * A field is considered to have unknown validity status if it is not valid or invalid.\n */\n readonly status: Signal<'valid' | 'invalid' | 'unknown'> = computed(() => {\n // Short-circuit checking children if validation doesn't apply to this field.\n if (this.shouldSkipValidation()) {\n return 'valid';\n }\n let ownStatus = calculateValidationSelfStatus(this);\n\n return this.node.structure.reduceChildren<'valid' | 'invalid' | 'unknown'>(\n ownStatus,\n (child, value) => {\n if (value === 'invalid' || child.validationState.status() === 'invalid') {\n return 'invalid';\n } else if (value === 'unknown' || child.validationState.status() === 'unknown') {\n return 'unknown';\n }\n return 'valid';\n },\n (v) => v === 'invalid', // short-circuit on 'invalid'\n );\n });\n\n /**\n * Whether the field is considered valid.\n *\n * A field is considered valid if *all* of the following are true:\n * - It has no errors or pending validators\n * - All of its children are considered valid\n *\n * Note: `!valid()` is *not* the same as `invalid()`. Both `valid()` and `invalid()` can be false\n * if there are currently no errors, but validators are still pending.\n */\n readonly valid = computed(() => this.status() === 'valid');\n\n /**\n * Whether the field is considered invalid.\n *\n * A field is considered invalid if *any* of the following are true:\n * - It has an error\n * - Any of its children is considered invalid\n *\n * Note: `!invalid()` is *not* the same as `valid()`. Both `valid()` and `invalid()` can be false\n * if there are currently no errors, but validators are still pending.\n */\n readonly invalid = computed(() => this.status() === 'invalid');\n\n /**\n * Indicates whether validation should be skipped for this field because it is hidden, disabled,\n * or readonly.\n */\n readonly shouldSkipValidation = computed(\n () =>\n this.node.hidden() ||\n this.node.disabled() ||\n this.node.readonly() ||\n this.node.structure.isOrphaned(),\n );\n}\n\n/** Normalizes a validation result to a list of validation errors. */\nfunction normalizeErrors<T extends ValidationResult>(error: T | readonly T[]): readonly T[] {\n if (error === undefined) {\n return [];\n }\n\n if (isArray(error)) {\n return error as readonly T[];\n }\n\n return [error as T];\n}\n\n/**\n * Sets the given field on the given error(s) if it does not already have a field.\n * @param error The error(s) to add the field to\n * @param fieldTree The default field to add\n * @returns The passed in error(s), with its field set.\n */\nexport function addDefaultField<E extends ValidationError.WithOptionalFieldTree>(\n error: E,\n fieldTree: ReadonlyFieldTree<unknown>,\n): E & {fieldTree: ReadonlyFieldTree<unknown>};\nexport function addDefaultField<E extends ValidationError>(\n errors: TreeValidationResult<E>,\n fieldTree: ReadonlyFieldTree<unknown>,\n): ValidationResult<E & {fieldTree: ReadonlyFieldTree<unknown>}>;\nexport function addDefaultField<E extends ValidationError>(\n errors: TreeValidationResult<E>,\n fieldTree: ReadonlyFieldTree<unknown>,\n): ValidationResult<E & {fieldTree: ReadonlyFieldTree<unknown>}> {\n if (isArray(errors)) {\n for (const error of errors) {\n (error as ɵWritable<ValidationError.WithOptionalFieldTree>).fieldTree ??= fieldTree;\n }\n } else if (errors) {\n (errors as ɵWritable<ValidationError.WithOptionalFieldTree>).fieldTree ??= fieldTree;\n }\n return errors as ValidationResult<E & {fieldTree: ReadonlyFieldTree<unknown>}>;\n}\n\nfunction getFirstBoundElement(error: ValidationError.WithFieldTree) {\n if (error.formField) return error.formField.element;\n return error\n .fieldTree()\n .formFieldBindings()\n .reduce<HTMLElement | undefined>((el: HTMLElement | undefined, binding) => {\n if (!el || !binding.element) return el ?? binding.element;\n return el.compareDocumentPosition(binding.element) & Node.DOCUMENT_POSITION_PRECEDING\n ? binding.element\n : el;\n }, undefined);\n}\n\n/**\n * Compares the position of two validation errors by the position of their corresponding field\n * binding directive in the DOM.\n * - For errors with multiple field bindings, the earliest one in the DOM will be used for comparison.\n * - For errors that have no field bindings, they will be considered to come after all other errors.\n */\nfunction compareErrorPosition(\n a: ValidationError.WithFieldTree,\n b: ValidationError.WithFieldTree,\n): number {\n const aEl = getFirstBoundElement(a);\n const bEl = getFirstBoundElement(b);\n if (aEl === bEl) return 0;\n if (aEl === undefined || bEl === undefined) return aEl === undefined ? 1 : -1;\n return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport type {Signal} from '@angular/core';\nimport {createMetadataKey, MetadataKey} from '../api/rules/metadata';\nimport {Debouncer} from '../api/types';\n\n/**\n * A private {@link MetadataKey} used to aggregate `debounce()` rules.\n *\n * This will pick the last `debounce()` rule on a field that is currently applied, if conditional.\n */\nexport const DEBOUNCER: MetadataKey<\n Signal<Debouncer<any> | undefined> | undefined,\n Debouncer<any>,\n Debouncer<any> | undefined\n> = createMetadataKey();\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n computed,\n Signal,\n untracked,\n WritableSignal,\n ɵRuntimeError as RuntimeError,\n} from '@angular/core';\nimport {RuntimeErrorCode} from '../errors';\nimport {AbstractControl} from '@angular/forms';\nimport {\n CompatSchemaPath,\n CompatFieldState,\n FieldContext,\n ReadonlyCompatFieldState,\n ReadonlyFieldState,\n ReadonlyFieldTree,\n SchemaPath,\n SchemaPathRules,\n SchemaPathTree,\n} from '../api/types';\nimport {FieldPathNode} from '../schema/path_node';\nimport {isArray} from '../util/type_guards';\nimport type {FieldNode} from './node';\nimport {getBoundPathDepth} from './resolution';\n\n/**\n * `FieldContext` implementation, backed by a `FieldNode`.\n */\nexport class FieldNodeContext implements FieldContext<unknown> {\n /**\n * Cache of paths that have been resolved for this context.\n *\n * For each resolved path we keep track of a signal of field that it maps to rather than a static\n * field, since it theoretically could change. In practice for the current system it should not\n * actually change, as they only place we currently track fields moving within the parent\n * structure is for arrays, and paths do not currently support array indexing.\n */\n private readonly cache = new WeakMap<\n SchemaPath<unknown, SchemaPathRules>,\n Signal<ReadonlyFieldTree<unknown>>\n >();\n\n constructor(\n /** The field node this context corresponds to. */\n private readonly node: FieldNode,\n ) {\n // These methods are explicitly bound to the context instance so that they\n // safely retain their `this` reference if destructured by consumers\n // (e.g., during validation when `stateOf` or `fieldTreeOf` are extracted).\n this.fieldTreeOf = this.fieldTreeOf.bind(this);\n this.stateOf = this.stateOf.bind(this);\n }\n\n /**\n * Resolves a target path relative to this context.\n * @param target The path to resolve\n * @returns The field corresponding to the target path.\n */\n private resolve<U>(target: SchemaPath<U, SchemaPathRules>): ReadonlyFieldTree<U> {\n if (!this.cache.has(target)) {\n const resolver = computed<ReadonlyFieldTree<unknown>>(() => {\n const targetPathNode = FieldPathNode.unwrapFieldPath(target);\n\n // First, find the field where the root our target path was merged in.\n // We determine this by walking up the field tree from the current field and looking for\n // the place where the LogicNodeBuilder from the target path's root was merged in.\n // We always make sure to walk up at least as far as the depth of the path we were bound to.\n // This ensures that we do not accidentally match on the wrong application of a recursively\n // applied schema.\n let field: FieldNode | undefined = this.node;\n let stepsRemaining = getBoundPathDepth();\n while (stepsRemaining > 0 || !field.structure.logic.hasLogic(targetPathNode.root.builder)) {\n stepsRemaining--;\n field = field.structure.parent;\n if (field === undefined) {\n throw new RuntimeError(\n RuntimeErrorCode.PATH_NOT_IN_FIELD_TREE,\n ngDevMode && 'Path is not part of this field tree.',\n );\n }\n }\n\n // Now, we can navigate to the target field using the relative path in the target path node\n // to traverse down from the field we just found.\n for (let key of targetPathNode.keys) {\n field = field.structure.getChild(key);\n if (field === undefined) {\n throw new RuntimeError(\n RuntimeErrorCode.PATH_RESOLUTION_FAILED,\n ngDevMode &&\n `Cannot resolve path .${targetPathNode.keys.join('.')} relative to field ${[\n '<root>',\n ...this.node.structure.pathKeys(),\n ].join('.')}.`,\n );\n }\n }\n\n return field.fieldTree;\n });\n\n this.cache.set(target, resolver);\n }\n return this.cache.get(target)!() as ReadonlyFieldTree<U>;\n }\n\n get fieldTree(): ReadonlyFieldTree<unknown> {\n return this.node.fieldProxy;\n }\n\n get state(): ReadonlyFieldState<unknown> {\n return this.node;\n }\n\n get value(): WritableSignal<unknown> {\n return this.node.structure.value;\n }\n\n get key(): Signal<string> {\n return this.node.structure.keyInParent;\n }\n\n get pathKeys(): Signal<readonly string[]> {\n return this.node.structure.pathKeys;\n }\n\n readonly index = computed(() => {\n // Attempt to read the key first, this will throw an error if we're on a root field.\n const key = this.key();\n // Assert that the parent is actually an array.\n if (!isArray(untracked(this.node.structure.parent!.value))) {\n throw new RuntimeError(\n RuntimeErrorCode.PARENT_NOT_ARRAY,\n ngDevMode && 'Cannot access index, parent field is not an array.',\n );\n }\n // Return the key as a number if we are indeed inside an array field.\n return Number(key);\n });\n\n // Note: `fieldTreeOf` and `stateOf` are purposefully defined as overloaded class\n // methods rather than arrow-function properties. This allows their signatures\n // to successfully satisfy the complex, deferred conditional generic typings\n // required by the `RootFieldContext` interface.\n fieldTreeOf<PModel>(\n p: SchemaPathTree<PModel>,\n ): [PModel] extends [any] ? ReadonlyFieldTree<PModel> : never {\n return this.resolve<PModel>(p) as any;\n }\n\n stateOf<PControl extends AbstractControl>(\n p: CompatSchemaPath<PControl>,\n ): [PControl] extends [any] ? ReadonlyCompatFieldState<PControl> : never;\n stateOf<PValue>(\n p: SchemaPath<PValue, SchemaPathRules>,\n ): [PValue] extends [any] ? ReadonlyFieldState<PValue> : never;\n stateOf<TModel>(p: SchemaPath<TModel, SchemaPathRules> | CompatSchemaPath<any>): any {\n return this.resolve<TModel>(p as any)();\n }\n readonly valueOf = <TValue>(p: SchemaPath<TValue, SchemaPathRules>) => {\n const result = this.resolve(p)().value();\n\n if (result instanceof AbstractControl) {\n throw new RuntimeError(\n RuntimeErrorCode.ABSTRACT_CONTROL_IN_FORM,\n ngDevMode &&\n `Tried to read an 'AbstractControl' value from a 'form()'. Did you mean to use 'compatForm()' instead?`,\n );\n }\n return result;\n };\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n computed,\n runInInjectionContext,\n ɵRuntimeError as RuntimeError,\n untracked,\n ɵisInParamsFunction,\n ɵsetInParamsFunction,\n} from '@angular/core';\nimport {MetadataKey} from '../api/rules/metadata';\nimport {RuntimeErrorCode} from '../errors';\nimport type {FieldNode} from './node';\n\n/**\n * Tracks custom metadata associated with a `FieldNode`.\n */\nexport class FieldMetadataState {\n /** A map of all `MetadataKey` that have been defined for this field. */\n private readonly metadata = new Map<MetadataKey<unknown, unknown, unknown>, unknown>();\n\n constructor(private readonly node: FieldNode) {}\n\n /**\n * Force eager creation of managed keys,\n * as managed keys have a `create` function that needs to run during construction.\n */\n runMetadataCreateLifecycle(): void {\n if (!this.node.logicNode.logic.hasMetadataKeys()) {\n return;\n }\n\n const wasInParams = ɵisInParamsFunction();\n if (wasInParams) ɵsetInParamsFunction(false);\n try {\n untracked(() =>\n runInInjectionContext(this.node.structure.injector, () => {\n for (const key of this.node.logicNode.logic.getMetadataKeys()) {\n if (key.create) {\n const logic = this.node.logicNode.logic.getMetadata(key);\n const result = key.create!(\n this.node,\n computed(() => logic.compute(this.node.context)),\n );\n this.metadata.set(key, result);\n }\n }\n }),\n );\n } finally {\n if (wasInParams) ɵsetInParamsFunction(true);\n }\n }\n\n /** Gets the value of an `MetadataKey` for the field. */\n get<T>(key: MetadataKey<T, unknown, unknown>): T | undefined {\n // We create non-managed metadata lazily, the first time they are accessed.\n if (this.has(key)) {\n if (!this.metadata.has(key)) {\n if (key.create) {\n throw new RuntimeError(\n RuntimeErrorCode.MANAGED_METADATA_LAZY_CREATION,\n ngDevMode && 'Managed metadata cannot be created lazily',\n );\n }\n const logic = this.node.logicNode.logic.getMetadata(key);\n this.metadata.set(\n key,\n computed(() => logic.compute(this.node.context)),\n );\n }\n }\n return this.metadata.get(key) as T | undefined;\n }\n\n /** Checks whether the current metadata state has the given metadata key. */\n has(key: MetadataKey<any, any, any>): boolean {\n // Metadata keys get added to the map lazily, on first access,\n // so we can't rely on checking presence in the metadata map.\n // Instead we check if there is any logic for the given metadata key.\n return this.node.logicNode.logic.hasMetadata(key);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {untracked} from '@angular/core';\nimport {isArray, isObject} from '../util/type_guards';\nimport type {FieldNode} from './node';\nimport {FIELD_TREE} from '../api/symbols';\n\n/**\n * Proxy handler which implements `FieldTree<T>` on top of `FieldNode`.\n */\nexport const FIELD_PROXY_HANDLER: ProxyHandler<() => FieldNode> = {\n get(getTgt: () => FieldNode, property: string | symbol, receiver: Record<string, unknown>) {\n if (property === FIELD_TREE) {\n return true;\n }\n\n const tgt = getTgt();\n\n // First, check whether the requested property is a defined child node of this node.\n const child = tgt.structure.getChild(property);\n if (child !== undefined) {\n // If so, return the child node's `FieldTree` proxy, allowing the developer to continue\n // navigating the form structure.\n return child.fieldTree;\n }\n\n // Otherwise, we need to consider whether the properties they're accessing are related to array\n // iteration. We're specifically interested in `length`, but we only want to pass this through\n // if the value is actually an array.\n //\n // We untrack the value here to avoid spurious reactive notifications. In reality, we've already\n // incurred a dependency on the value via `tgt.getChild()` above.\n const value = untracked(tgt.value);\n\n if (isArray(value)) {\n // Allow access to the length for field arrays, it should be the same as the length of the data.\n if (property === 'length') {\n return (tgt.value() as Array<unknown>).length;\n }\n // Allow access to the iterator. This allows the user to spread the field array into a\n // standard array in order to call methods like `filter`, `map`, etc.\n if (property === Symbol.iterator) {\n return () => {\n // When creating an iterator, we need to account for reactivity. The iterator itself will\n // read things each time `.next()` is called, but that may happen outside of the context\n // where the iterator was created (e.g. with `@for`, actual diffing happens outside the\n // reactive context of the template).\n //\n // Instead, side-effectfully read the value here to ensure iterator creation is reactive.\n tgt.value();\n return Array.prototype[Symbol.iterator].apply(tgt.fieldTree);\n };\n }\n // Note: We can consider supporting additional array methods if we want in the future,\n // but they should be thoroughly tested. Just forwarding the method directly from the\n // `Array` prototype results in broken behavior for some methods like `map`.\n }\n\n if (isObject(value)) {\n // For object fields, allow iteration over their entries for convenience of use with `@for`.\n if (property === Symbol.iterator) {\n return function* () {\n for (const key in receiver) {\n yield [key, receiver[key]];\n }\n };\n }\n }\n\n // Otherwise, this property doesn't exist.\n return undefined;\n },\n\n getOwnPropertyDescriptor(getTgt: () => FieldNode, prop: string | symbol) {\n const value = untracked(getTgt().value) as Object;\n const desc = Reflect.getOwnPropertyDescriptor(value, prop);\n // In order for `Object.keys` to function properly, keys must be reported as configurable.\n if (desc && !desc.configurable) {\n desc.configurable = true;\n }\n return desc;\n },\n\n ownKeys(getTgt: () => FieldNode) {\n const value = untracked(getTgt().value);\n return typeof value === 'object' && value !== null ? Reflect.ownKeys(value) : [];\n },\n};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, Signal, untracked, WritableSignal} from '@angular/core';\nimport {SIGNAL} from '@angular/core/primitives/signals';\nimport {isArray} from './type_guards';\n\n/**\n * Creates a writable signal for a specific property on a source writeable signal.\n * @param source A writeable signal to derive from\n * @param prop A signal of a property key of the source value\n * @returns A writeable signal for the given property of the source value.\n * @template S The source value type\n * @template K The key type for S\n */\nexport function deepSignal<S, K extends keyof S>(\n source: WritableSignal<S>,\n prop: Signal<K>,\n): WritableSignal<S[K]> {\n // Memoize the property.\n const read = computed(() => source()[prop()]) as WritableSignal<S[K]>;\n\n read[SIGNAL] = source[SIGNAL];\n read.set = (value: S[K]) => {\n if (Object.is(untracked(read), value)) {\n return;\n }\n source.update((current) => valueForWrite(current, value, prop()) as S);\n };\n\n read.update = (fn: (current: S[K]) => S[K]) => {\n read.set(fn(untracked(read)));\n };\n read.asReadonly = () => read;\n\n return read;\n}\n\n/**\n * Gets an updated root value to use when setting a value on a deepSignal with the given path.\n * @param sourceValue The current value of the deepSignal's source.\n * @param newPropValue The value being written to the deepSignal's property\n * @param prop The deepSignal's property key\n * @returns An updated value for the deepSignal's source\n */\nfunction valueForWrite(sourceValue: unknown, newPropValue: unknown, prop: PropertyKey): unknown {\n if (isArray(sourceValue)) {\n const newValue = [...sourceValue];\n newValue[prop as number] = newPropValue;\n return newValue;\n } else {\n return {...(sourceValue as object), [prop]: newPropValue};\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n computed,\n DestroyableInjector,\n Injector,\n linkedSignal,\n ɵRuntimeError as RuntimeError,\n Signal,\n untracked,\n WritableSignal,\n} from '@angular/core';\n\nimport {RuntimeErrorCode} from '../errors';\n\nimport {LogicNode} from '../schema/logic_node';\nimport type {FieldPathNode} from '../schema/path_node';\nimport {deepSignal} from '../util/deep_signal';\nimport {isArray, isObject} from '../util/type_guards';\nimport type {FieldAdapter} from './field_adapter';\nimport type {FormFieldManager} from './manager';\nimport type {FieldNode, ParentFieldNode} from './node';\n\nconst ORPHAN_TOKEN = Symbol(typeof ngDevMode !== 'undefined' && ngDevMode ? 'ORPHAN_TOKEN' : '');\nconst FALSE_SIGNAL = computed(() => false);\n\n/**\n * Key by which a parent `FieldNode` tracks its children.\n *\n * Often this is the actual property key of the child, but in the case of arrays it could be a\n * tracking key allocated for the object.\n */\nexport type TrackingKey = PropertyKey & {__brand: 'FieldIdentity'};\nexport type ChildNodeCtor = (\n key: string,\n trackingKey: TrackingKey | undefined,\n isArray: boolean,\n) => FieldNode;\n\n/** Structural component of a `FieldNode` which tracks its path, parent, and children. */\nexport abstract class FieldNodeStructure {\n /**\n * Computed map of child fields, based on the current value of this field.\n *\n * This structure reacts to `this.value` and produces a new `ChildrenData` when the\n * value changes structurally (fields added/removed/moved).\n */\n protected abstract readonly childrenMap: Signal<ChildrenData | undefined>;\n\n abstract readonly isOrphaned: Signal<boolean>;\n\n /** The field's value. */\n abstract readonly value: WritableSignal<unknown>;\n\n /**\n * The key of this field in its parent field.\n * Attempting to read this for the root field will result in an error being thrown.\n */\n abstract readonly keyInParent: Signal<string>;\n\n /** The field manager responsible for managing this field. */\n abstract readonly fieldManager: FormFieldManager;\n\n /** The root field that this field descends from. */\n abstract readonly root: FieldNode;\n\n /** The list of property keys to follow to get from the `root` to this field. */\n abstract readonly pathKeys: Signal<readonly string[]>;\n\n /** The parent field of this field. */\n abstract readonly parent: FieldNode | undefined;\n\n readonly logic: LogicNode;\n readonly node: FieldNode;\n\n readonly createChildNode: ChildNodeCtor;\n\n /** Added to array elements for tracking purposes. */\n // TODO: given that we don't ever let a field move between parents, is it safe to just extract\n // this to a shared symbol for all fields, rather than having a separate one per parent?\n readonly identitySymbol = Symbol();\n\n /** Lazily initialized injector. Do not access directly, access via `injector` getter instead. */\n private _injector: DestroyableInjector | undefined = undefined;\n\n /** Cache whether any logic rules exist on children of this node. */\n private _anyChildHasLogic?: boolean;\n\n /** Lazily initialized injector. */\n get injector(): DestroyableInjector {\n this._injector ??= Injector.create({\n providers: [],\n parent: this.fieldManager.injector,\n }) as DestroyableInjector;\n return this._injector;\n }\n\n constructor(logic: LogicNode, node: FieldNode, createChildNode: ChildNodeCtor) {\n this.logic = logic;\n this.node = node;\n this.createChildNode = createChildNode;\n }\n\n /** Gets the child fields of this field. */\n children(): readonly FieldNode[] {\n this.ensureChildrenMap();\n const map = this.childrenMap();\n if (map === undefined) {\n return [];\n }\n return Array.from(map.byPropertyKey.values()).map((child) => untracked(child.reader)!);\n }\n\n /**\n * Gets only the child fields that have been materialized already.\n *\n * This is useful for iterating over children without triggering materialization of children\n * that haven't been accessed yet.\n *\n * Note: This method assumes it is called within an untracked context (or in a non-reactive context)\n * as it reads signals without wrapping them in `untracked()`.\n */\n materializedChildren(): readonly FieldNode[] {\n const map = this.childrenMap();\n if (map === undefined) {\n return [];\n }\n return Array.from(map.byPropertyKey.values()).map((child) => child.node);\n }\n\n /**\n * Internal method (cast to any in tests) to check if the children map has been materialized.\n * Useful for validating that fields without logic are lazily instantiated.\n *\n * @internal\n */\n _areChildrenMaterialized(): boolean {\n return untracked(this.childrenMap) !== undefined;\n }\n\n private ensureChildrenMap() {\n // If we're already materialized, there's nothing to do.\n if (this._areChildrenMaterialized()) {\n return;\n }\n\n // We force materialization by telling the linkedSignal to re-evaluate now, but treating\n // its source value as having changed, or rather skipping the lazy fast-path.\n untracked(() => {\n (this.childrenMap as WritableSignal<ChildrenData | undefined>).update((current) =>\n this.computeChildrenMap(this.value(), current, true),\n );\n });\n }\n\n /** Retrieve a child `FieldNode` of this node by property key. */\n getChild(key: PropertyKey): FieldNode | undefined {\n this.ensureChildrenMap();\n\n const strKey = key.toString();\n\n // Lookup the computed reader for this key in `childrenMap`. This lookup doesn't need to be\n // reactive since `childrenMap` guarantees it will always return the same `reader` for the same\n // `key`, so long as that key exists.\n let reader = untracked(this.childrenMap)?.byPropertyKey.get(strKey)?.reader;\n\n if (!reader) {\n // The key doesn't exist / doesn't have a child field associated with it. In this case, we\n // need to be clever. We want to return `undefined`, but also be notified by reactivity if the\n // field _does_ pop into existence later. Basically, we want to depend on a reader for a key\n // that doesn't exist.\n //\n // We do precisely that by creating an ephemeral reader which will be read and then dropped.\n // If we're in a reactive context, the ephemeral reader will live on in the dependencies of\n // that context and notify it if the field is later created. When the reactive context reruns,\n // it will again attempt the read which will call `getChild()`, which will then find the real\n // reader for that key.\n reader = this.createReader(strKey);\n }\n\n return reader();\n }\n\n /**\n * Perform a reduction over a field's children (if any) and return the result.\n *\n * Optionally, the reduction is short circuited based on the provided `shortCircuit` function.\n */\n reduceChildren<T>(\n initialValue: T,\n fn: (child: FieldNode, value: T) => T,\n shortCircuit?: (value: T) => boolean,\n ): T {\n const map = this.childrenMap();\n if (!map) {\n return initialValue;\n }\n\n let value = initialValue;\n for (const child of map.byPropertyKey.values()) {\n if (shortCircuit?.(value)) {\n break;\n }\n value = fn(untracked(child.reader)!, value);\n }\n return value;\n }\n\n /** Destroys the field when it is no longer needed. */\n destroy(): void {\n this.injector.destroy();\n }\n\n /**\n * Creates signals for keyInParent and isOrphaned status for a field node.\n */\n protected createKeyOrOrphanSignals(\n kind: 'child' | 'root',\n identityInParent: TrackingKey | undefined,\n initialKeyInParent: string | undefined,\n ): {keyInParent: Signal<string>; isOrphaned: Signal<boolean>} {\n if (kind === 'root') {\n return {keyInParent: ROOT_KEY_IN_PARENT, isOrphaned: FALSE_SIGNAL};\n }\n\n const parent = this.parent!;\n let lastKnownKey = initialKeyInParent!;\n\n const keyOrOrphan = computed(() => {\n if (parent.structure.isOrphaned()) {\n return ORPHAN_TOKEN;\n }\n\n const map = parent.structure.childrenMap();\n if (!map) {\n return ORPHAN_TOKEN;\n }\n\n // Fast path: check last known key\n const lastKnownChild = map.byPropertyKey.get(lastKnownKey);\n if (lastKnownChild && lastKnownChild.node === this.node) {\n return lastKnownKey;\n }\n\n if (identityInParent === undefined) {\n // Object property: if not at last known key, it's orphaned\n return ORPHAN_TOKEN;\n } else {\n // Array element: scan for node in childrenMap\n for (const [key, child] of map.byPropertyKey) {\n if (child.node === this.node) {\n return (lastKnownKey = key);\n }\n }\n return ORPHAN_TOKEN;\n }\n });\n\n const isOrphaned = computed(() => keyOrOrphan() === ORPHAN_TOKEN);\n\n const keyInParent = computed(() => {\n const key = keyOrOrphan();\n if (key === ORPHAN_TOKEN) {\n if (identityInParent === undefined) {\n throw new RuntimeError(\n RuntimeErrorCode.ORPHAN_FIELD_PROPERTY,\n ngDevMode &&\n `Orphan field, looking for property '${initialKeyInParent}' of ${getDebugName(\n parent,\n )}`,\n );\n } else {\n throw new RuntimeError(\n RuntimeErrorCode.ORPHAN_FIELD_NOT_FOUND,\n ngDevMode && `Orphan field, can't find element in array ${getDebugName(parent)}`,\n );\n }\n }\n return key;\n });\n\n return {keyInParent, isOrphaned};\n }\n\n protected createChildrenMap(): Signal<ChildrenData | undefined> {\n return linkedSignal({\n source: this.value,\n computation: (\n value: unknown,\n previous: {source: unknown; value: ChildrenData | undefined} | undefined,\n ): ChildrenData | undefined => this.computeChildrenMap(value, previous?.value, false),\n });\n }\n\n private computeChildrenMap(\n value: unknown,\n prevData: ChildrenData | undefined,\n forceMaterialize: boolean,\n ): ChildrenData | undefined {\n if (!isObject(value)) {\n // Non-object values have no children. This short-circuit path makes `childrenMap` fast\n // for primitive-valued fields.\n return undefined;\n }\n\n // Determine if we actually need to materialize children right now.\n // If not forced, and NO child has any logic rules, we can safely return `undefined`\n // to keep instantiation lazy. However, if `prevData` is already defined, we MUST\n // NOT return `undefined` or we will orphan the already instantiated children.\n if (!forceMaterialize && prevData === undefined) {\n // Check if any child of this field has logic rules. This check only needs to run once per\n // structure since the presence of schema logic rules is static across value changes.\n if (!(this._anyChildHasLogic ??= this.logic.anyChildHasLogic())) {\n return undefined;\n }\n }\n\n // Previous `ChildrenData` (immutable). This is also where we first initialize our map if\n // needed.\n prevData ??= {\n byPropertyKey: new Map(),\n };\n\n // The next `ChildrenData` object to be returned. Initialized lazily when we know there's\n // been a structural change to the model.\n let materializedChildren: MutableChildrenData | undefined;\n\n const parentIsArray = isArray(value);\n\n // Remove fields that have disappeared since the last time this map was computed.\n if (prevData !== undefined) {\n if (parentIsArray) {\n materializedChildren = maybeRemoveStaleArrayFields(prevData, value, this.identitySymbol);\n } else {\n materializedChildren = maybeRemoveStaleObjectFields(prevData, value);\n }\n }\n\n // Now, go through the values and add any new ones.\n for (const key of Object.keys(value)) {\n let trackingKey: TrackingKey | undefined = undefined;\n const childValue = value[key] as unknown;\n\n // Fields explicitly set to `undefined` are treated as if they don't exist.\n // This ensures that `{value: undefined}` and `{}` have the same behavior for their `value`\n // field.\n if (childValue === undefined) {\n // The value might have _become_ `undefined`, so we need to delete it here.\n if (prevData.byPropertyKey.has(key)) {\n materializedChildren ??= {...(prevData as MutableChildrenData)};\n materializedChildren.byPropertyKey.delete(key);\n }\n continue;\n }\n\n if (parentIsArray && isObject(childValue) && !isArray(childValue)) {\n // For object values in arrays, assign a synthetic identity. This will be used to\n // preserve the field instance even as this object moves around in the parent array.\n trackingKey = (childValue[this.identitySymbol] as TrackingKey) ??= Symbol(\n ngDevMode ? `id:${globalId++}` : '',\n ) as TrackingKey;\n }\n\n let childNode: FieldNode | undefined;\n\n if (trackingKey) {\n // If tracking is in use, then the `FieldNode` instance is always managed via its\n // tracking key. Create the instance if needed, or look it up otherwise.\n if (!prevData.byTrackingKey?.has(trackingKey)) {\n materializedChildren ??= {...(prevData as MutableChildrenData)};\n materializedChildren.byTrackingKey ??= new Map();\n\n materializedChildren.byTrackingKey.set(\n trackingKey,\n this.createChildNode(key, trackingKey, parentIsArray),\n );\n }\n\n // Note: materializedChildren ?? prevData is needed because we might have freshly instantiated\n // `byTrackingKey` only in `materializedChildren` above.\n childNode = (materializedChildren ?? prevData).byTrackingKey!.get(trackingKey)!;\n }\n\n // Next, make sure the `ChildData` for this key in `byPropertyKey` is up to date. We need\n // to consider two cases:\n //\n // 1. No record exists for this field (yet).\n // 2. A record does exist, but the field identity at this key has changed (only possible\n // when fields are tracked).\n const child = prevData.byPropertyKey.get(key);\n if (child === undefined) {\n // No record exists yet - create one.\n materializedChildren ??= {...(prevData as MutableChildrenData)};\n\n materializedChildren.byPropertyKey.set(key, {\n // TODO: creating a computed per-key is overkill when the field at a key can't change\n // (e.g. the value is not an array). Maybe this can be optimized?\n reader: this.createReader(key),\n // If tracking is in use, then it already created/found the `childNode` for this key.\n // Otherwise we create the child field here.\n node: childNode ?? this.createChildNode(key, trackingKey, parentIsArray),\n });\n } else if (childNode && childNode !== child.node) {\n // A record exists, but records the wrong `FieldNode`. Update it.\n materializedChildren ??= {...(prevData as MutableChildrenData)};\n child.node = childNode;\n }\n }\n\n return materializedChildren ?? prevData;\n }\n\n /**\n * Creates a \"reader\" computed for the given key.\n *\n * A reader is a computed signal that memoizes the access of the `FieldNode` stored at this key\n * (or returns `undefined` if no such field exists). Accessing fields via the reader ensures that\n * reactive consumers aren't notified unless the field at a key actually changes.\n */\n private createReader(key: string): Signal<FieldNode | undefined> {\n return computed(() => this.childrenMap()?.byPropertyKey.get(key)?.node);\n }\n}\n\n/** The structural component of a `FieldNode` that is the root of its field tree. */\nexport class RootFieldNodeStructure extends FieldNodeStructure {\n override get parent(): undefined {\n return undefined;\n }\n\n override get root(): FieldNode {\n return this.node;\n }\n\n override get pathKeys(): Signal<readonly string[]> {\n return ROOT_PATH_KEYS;\n }\n\n override get keyInParent(): Signal<string> {\n return ROOT_KEY_IN_PARENT;\n }\n\n override readonly isOrphaned = FALSE_SIGNAL;\n\n /** @internal */\n override readonly childrenMap: Signal<ChildrenData | undefined>;\n\n /**\n * Creates the structure for the root node of a field tree.\n *\n * @param node The full field node that this structure belongs to\n * @param pathNode The path corresponding to this node in the schema\n * @param logic The logic to apply to this field\n * @param fieldManager The field manager for this field\n * @param value The value signal for this field\n * @param adapter Adapter that knows how to create new fields and appropriate state.\n * @param createChildNode A factory function to create child nodes for this field.\n */\n constructor(\n /** The full field node that corresponds to this structure. */\n node: FieldNode,\n logic: LogicNode,\n override readonly fieldManager: FormFieldManager,\n override readonly value: WritableSignal<unknown>,\n createChildNode: ChildNodeCtor,\n ) {\n super(logic, node, createChildNode);\n this.childrenMap = this.createChildrenMap();\n }\n}\n\n/** The structural component of a child `FieldNode` within a field tree. */\nexport class ChildFieldNodeStructure extends FieldNodeStructure {\n override readonly root: FieldNode;\n override readonly pathKeys: Signal<readonly string[]>;\n override readonly keyInParent: Signal<string>;\n override readonly value: WritableSignal<unknown>;\n override readonly childrenMap: Signal<ChildrenData | undefined>;\n\n override readonly isOrphaned: Signal<boolean>;\n\n override get fieldManager(): FormFieldManager {\n return this.root.structure.fieldManager;\n }\n\n /**\n * Creates the structure for a child field node in a field tree.\n *\n * @param node The full field node that this structure belongs to\n * @param pathNode The path corresponding to this node in the schema\n * @param logic The logic to apply to this field\n * @param parent The parent field node for this node\n * @param identityInParent The identity used to track this field in its parent\n * @param initialKeyInParent The key of this field in its parent at the time of creation\n * @param adapter Adapter that knows how to create new fields and appropriate state.\n * @param createChildNode A factory function to create child nodes for this field.\n */\n constructor(\n node: FieldNode,\n override readonly logic: LogicNode,\n override readonly parent: ParentFieldNode,\n identityInParent: TrackingKey | undefined,\n initialKeyInParent: string,\n createChildNode: ChildNodeCtor,\n ) {\n super(logic, node, createChildNode);\n\n this.root = this.parent.structure.root;\n\n const signals = this.createKeyOrOrphanSignals('child', identityInParent, initialKeyInParent);\n\n this.isOrphaned = signals.isOrphaned;\n this.keyInParent = signals.keyInParent;\n\n this.pathKeys = computed(() => [...parent.structure.pathKeys(), this.keyInParent()]);\n\n this.value = deepSignal(this.parent.structure.value, this.keyInParent);\n this.childrenMap = this.createChildrenMap();\n this.fieldManager.structures.add(this);\n }\n}\n\n/** Global id used for tracking keys. */\nlet globalId = 0;\n\n/** Options passed when constructing a root field node. */\nexport interface RootFieldNodeOptions {\n /** Kind of node, used to differentiate root node options from child node options. */\n readonly kind: 'root';\n /** The path node corresponding to this field in the schema. */\n readonly pathNode: FieldPathNode;\n /** The logic to apply to this field. */\n readonly logic: LogicNode;\n /** The value signal for this field. */\n readonly value: WritableSignal<unknown>;\n /** The field manager for this field. */\n readonly fieldManager: FormFieldManager;\n /** This allows for more granular field and state management, and is currently used for compat. */\n readonly fieldAdapter: FieldAdapter;\n}\n\n/** Options passed when constructing a child field node. */\nexport interface ChildFieldNodeOptions {\n /** Kind of node, used to differentiate root node options from child node options. */\n readonly kind: 'child';\n /** The parent field node of this field. */\n readonly parent: ParentFieldNode;\n /** The path node corresponding to this field in the schema. */\n readonly pathNode: FieldPathNode;\n /** The logic to apply to this field. */\n readonly logic: LogicNode;\n /** The key of this field in its parent at the time of creation. */\n readonly initialKeyInParent: string;\n /** The identity used to track this field in its parent. */\n readonly identityInParent: TrackingKey | undefined;\n /** This allows for more granular field and state management, and is currently used for compat. */\n readonly fieldAdapter: FieldAdapter;\n}\n\n/** Options passed when constructing a field node. */\nexport type FieldNodeOptions = RootFieldNodeOptions | ChildFieldNodeOptions;\n\n/** A signal representing an empty list of path keys, used for root fields. */\nconst ROOT_PATH_KEYS = computed<readonly string[]>(() => []);\n\n/**\n * A signal representing a non-existent key of the field in its parent, used for root fields which\n * do not have a parent. This signal will throw if it is read.\n */\nconst ROOT_KEY_IN_PARENT = computed(() => {\n throw new RuntimeError(\n RuntimeErrorCode.ROOT_FIELD_NO_PARENT,\n ngDevMode && 'The top-level field in the form has no parent.',\n );\n});\n\n/** Gets a human readable name for a field node for use in error messages. */\nfunction getDebugName(node: FieldNode) {\n return `<root>.${node.structure.pathKeys().join('.')}`;\n}\n\ninterface MutableChildrenData {\n readonly byPropertyKey: Map<string, ChildData>;\n byTrackingKey?: Map<TrackingKey, FieldNode>;\n}\n\n/**\n * Derived data regarding child fields for a specific parent field.\n */\ninterface ChildrenData {\n /**\n * Tracks `ChildData` for each property key within the parent.\n */\n readonly byPropertyKey: ReadonlyMap<string, ChildData>;\n\n /**\n * Tracks the instance of child `FieldNode`s by their tracking key, which is always 1:1 with the\n * fields, even if they move around in the parent.\n */\n readonly byTrackingKey?: ReadonlyMap<TrackingKey, FieldNode>;\n}\n\n/**\n * Data for a specific child within a parent.\n */\ninterface ChildData {\n /**\n * A computed signal to access the `FieldNode` currently stored at a specific key.\n *\n * Because this is a computed, it only updates whenever the `FieldNode` at that key changes.\n * Because `ChildData` is always associated with a specific key via `ChildrenData.byPropertyKey`,\n * this computed gives a stable way to watch the field stored for a given property and only\n * receives notifications when that field changes.\n */\n readonly reader: Signal<FieldNode | undefined>;\n\n /**\n * The child `FieldNode` currently stored at this key.\n */\n node: FieldNode;\n}\n\nfunction maybeRemoveStaleArrayFields(\n prevData: ChildrenData,\n value: ReadonlyArray<unknown>,\n identitySymbol: PropertyKey,\n): MutableChildrenData | undefined {\n let data: MutableChildrenData | undefined;\n\n // TODO: we should be able to optimize this diff away in the fast case where nothing has\n // actually changed structurally.\n const oldKeys = new Set(prevData.byPropertyKey.keys());\n const oldTracking = prevData.byTrackingKey && new Set(prevData.byTrackingKey.keys());\n\n for (let i = 0; i < value.length; i++) {\n const childValue = value[i];\n oldKeys.delete(i.toString());\n if (oldTracking && isObject(childValue) && Object.hasOwn(childValue, identitySymbol)) {\n oldTracking.delete(childValue[identitySymbol] as TrackingKey);\n }\n }\n\n // `oldKeys` and `oldTracking` now contain stale keys and tracking keys, respectively.\n // Remove them from their corresponding maps.\n\n if (oldKeys.size > 0) {\n data ??= {...(prevData as MutableChildrenData)};\n for (const key of oldKeys) {\n data.byPropertyKey.delete(key);\n }\n }\n if (oldTracking && oldTracking.size > 0) {\n data ??= {...(prevData as MutableChildrenData)};\n for (const id of oldTracking) {\n data.byTrackingKey!.delete(id);\n }\n }\n\n return data;\n}\n\nfunction maybeRemoveStaleObjectFields(\n prevData: ChildrenData,\n value: Record<PropertyKey, unknown>,\n): MutableChildrenData | undefined {\n let data: MutableChildrenData | undefined;\n\n // For objects, we diff a bit differently, and use the value to check whether an old\n // property still exists on the object value.\n for (const key of prevData.byPropertyKey.keys()) {\n if (!Object.hasOwn(value, key)) {\n data ??= {...(prevData as MutableChildrenData)};\n data.byPropertyKey.delete(key);\n }\n }\n\n return data;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, linkedSignal, Signal, signal, WritableSignal} from '@angular/core';\nimport {ValidationError} from '../api/rules/validation/validation_errors';\nimport type {FieldNode} from './node';\n\n/**\n * State of a `FieldNode` that's associated with form submission.\n */\nexport class FieldSubmitState {\n /**\n * Whether this field was directly submitted (as opposed to indirectly by a parent field being submitted)\n * and is still in the process of submitting.\n */\n readonly selfSubmitting = signal<boolean>(false);\n\n /** Submission errors that are associated with this field. */\n readonly submissionErrors: WritableSignal<readonly ValidationError.WithFieldTree[]>;\n\n constructor(private readonly node: FieldNode) {\n this.submissionErrors = linkedSignal({\n source: this.node.structure.value,\n computation: () => [] as readonly ValidationError.WithFieldTree[],\n });\n }\n\n /**\n * Whether this form is currently in the process of being submitted.\n * Either because the field was submitted directly, or because a parent field was submitted.\n */\n readonly submitting: Signal<boolean> = computed(() => {\n return this.selfSubmitting() || (this.node.structure.parent?.submitting() ?? false);\n });\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n computed,\n linkedSignal,\n type Signal,\n untracked,\n type WritableSignal,\n type Resource,\n type WritableResource,\n} from '@angular/core';\nimport {\n MAX,\n MAX_LENGTH,\n type MetadataKey,\n MIN,\n MIN_LENGTH,\n PATTERN,\n REQUIRED,\n IS_ASYNC_VALIDATION_RESOURCE,\n} from '../api/rules/metadata';\nimport type {NgValidationError, ValidationError} from '../api/rules/validation/validation_errors';\nimport type {\n DisabledReason,\n FieldContext,\n FieldState,\n FieldTree,\n MarkAsTouchedOptions,\n} from '../api/types';\nimport type {FormField} from '../directive/form_field';\nimport {DYNAMIC} from '../schema/logic';\nimport {LogicNode} from '../schema/logic_node';\nimport {FieldPathNode} from '../schema/path_node';\nimport {FieldNodeContext} from './context';\nimport type {FieldAdapter} from './field_adapter';\nimport type {FormFieldManager} from './manager';\nimport {FieldMetadataState} from './metadata';\nimport {FIELD_PROXY_HANDLER} from './proxy';\nimport {FieldNodeState} from './state';\nimport {\n ChildFieldNodeStructure,\n type FieldNodeOptions,\n type FieldNodeStructure,\n RootFieldNodeStructure,\n type TrackingKey,\n} from './structure';\nimport {FieldSubmitState} from './submit';\nimport {ValidationState} from './validation';\n\nexport interface ControlValueSignal<T> extends WritableSignal<T> {\n rawSet(value: T): void;\n}\n\n/**\n * Internal node in the form tree for a given field.\n *\n * Field nodes have several responsibilities:\n * - They track instance state for the particular field (touched)\n * - They compute signals for derived state (valid, disabled, etc) based on their associated\n * `LogicNode`\n * - They act as the public API for the field (they implement the `FieldState` interface)\n * - They implement navigation of the form tree via `.parent` and `.getChild()`.\n *\n * This class is largely a wrapper that aggregates several smaller pieces that each manage a subset of\n * the responsibilities.\n */\nexport class FieldNode implements FieldState<unknown> {\n readonly structure: FieldNodeStructure;\n readonly validationState: ValidationState;\n readonly metadataState: FieldMetadataState;\n readonly nodeState: FieldNodeState;\n readonly submitState: FieldSubmitState;\n readonly fieldAdapter: FieldAdapter;\n readonly controlValue: ControlValueSignal<unknown>;\n\n private _context: FieldContext<unknown> | undefined = undefined;\n get context(): FieldContext<unknown> {\n return (this._context ??= new FieldNodeContext(this));\n }\n\n /**\n * Proxy to this node which allows navigation of the form graph below it.\n */\n readonly fieldProxy = new Proxy(() => this, FIELD_PROXY_HANDLER) as unknown as FieldTree<any>;\n private readonly pathNode: FieldPathNode;\n\n constructor(options: FieldNodeOptions) {\n this.pathNode = options.pathNode;\n this.fieldAdapter = options.fieldAdapter;\n this.structure = this.fieldAdapter.createStructure(this, options);\n this.validationState = this.fieldAdapter.createValidationState(this, options);\n this.nodeState = this.fieldAdapter.createNodeState(this, options);\n this.metadataState = new FieldMetadataState(this);\n this.submitState = new FieldSubmitState(this);\n this.controlValue = this.controlValueSignal();\n // We eagerly create metadata at the end of construction so that the node is fully constructed\n // before metadata creation logic runs (which may access other states on the node).\n this.metadataState.runMetadataCreateLifecycle();\n }\n\n focusBoundControl(options?: FocusOptions): void {\n this.getBindingForFocus()?.focus(options);\n }\n\n /**\n * Gets the Field directive binding that should be focused when the developer calls\n * `focusBoundControl` on this node.\n *\n * This will prioritize focusable bindings to this node, and if multiple exist, it will return\n * the first one in the DOM. If no focusable bindings exist on this node, it will return the\n * first focusable binding in the DOM for any descendant node of this one.\n */\n private getBindingForFocus():\n | (FormField<unknown> & {focus: (options?: FocusOptions) => void})\n | undefined {\n // First try to focus one of our own bindings.\n const own = this.formFieldBindings()\n .filter(\n (b): b is FormField<unknown> & {focus: (options?: FocusOptions) => void} =>\n b.focus !== undefined,\n )\n .reduce(\n firstInDom<FormField<unknown> & {focus: (options?: FocusOptions) => void}>,\n undefined,\n );\n if (own) return own;\n // Fallback to focusing the bound control for one of our children.\n return this.structure\n .children()\n .map((child) => child.getBindingForFocus())\n .reduce(firstInDom, undefined);\n }\n\n /**\n * The `AbortController` for the currently debounced sync, or `undefined` if there is none.\n *\n * This is used to cancel a pending debounced sync when {@link setControlValue} is called again\n * before the pending debounced sync resolves. It will also cancel any pending debounced sync\n * automatically when recomputed due to `value` being set directly from others sources.\n */\n private readonly pendingSync: WritableSignal<AbortController | undefined> = linkedSignal({\n source: () => this.value(),\n computation: (_source, previous) => {\n previous?.value?.abort();\n return undefined;\n },\n });\n\n get fieldTree(): FieldTree<unknown> {\n return this.fieldProxy;\n }\n\n get logicNode(): LogicNode {\n return this.structure.logic;\n }\n\n get value(): WritableSignal<unknown> {\n return this.structure.value;\n }\n\n get keyInParent(): Signal<string | number> {\n return this.structure.keyInParent;\n }\n\n get errors(): Signal<ValidationError.WithFieldTree[]> {\n return this.validationState.errors;\n }\n\n get parseErrors(): Signal<ValidationError.WithFormField[]> {\n return this.validationState.parseErrors;\n }\n\n get errorSummary(): Signal<ValidationError.WithFieldTree[]> {\n return this.validationState.errorSummary;\n }\n\n get pending(): Signal<boolean> {\n return this.validationState.pending;\n }\n\n get valid(): Signal<boolean> {\n return this.validationState.valid;\n }\n\n get invalid(): Signal<boolean> {\n return this.validationState.invalid;\n }\n\n get dirty(): Signal<boolean> {\n return this.nodeState.dirty;\n }\n\n get touched(): Signal<boolean> {\n return this.nodeState.touched;\n }\n\n get disabled(): Signal<boolean> {\n return this.nodeState.disabled;\n }\n\n get disabledReasons(): Signal<readonly DisabledReason[]> {\n return this.nodeState.disabledReasons;\n }\n\n get hidden(): Signal<boolean> {\n return this.nodeState.hidden;\n }\n\n get readonly(): Signal<boolean> {\n return this.nodeState.readonly;\n }\n\n get formFieldBindings(): Signal<readonly FormField<unknown>[]> {\n return this.nodeState.formFieldBindings;\n }\n\n get submitting(): Signal<boolean> {\n return this.submitState.submitting;\n }\n\n get name(): Signal<string> {\n return this.nodeState.name;\n }\n\n get max(): Signal<{} | undefined> | undefined {\n const maxKey = this.metadata(MAX)?.();\n return maxKey ? this.metadata(maxKey) : undefined;\n }\n\n get maxLength(): Signal<number | undefined> | undefined {\n return this.metadata(MAX_LENGTH);\n }\n\n get min(): Signal<{} | undefined> | undefined {\n const minKey = this.metadata(MIN)?.();\n return minKey ? this.metadata(minKey) : undefined;\n }\n\n get minLength(): Signal<number | undefined> | undefined {\n return this.metadata(MIN_LENGTH);\n }\n\n get pattern(): Signal<readonly RegExp[]> {\n return this.metadata(PATTERN) ?? EMPTY;\n }\n\n get required(): Signal<boolean> {\n return this.metadata(REQUIRED) ?? FALSE;\n }\n\n metadata<M>(key: MetadataKey<M, any, any>): M | undefined {\n return this.metadataState.get(key);\n }\n\n getError<K extends NgValidationError['kind']>(\n kind: K,\n ): (Extract<NgValidationError, {kind: K}> & ValidationError.WithFieldTree) | undefined;\n getError(kind: string): ValidationError.WithFieldTree | undefined;\n getError(kind: string): ValidationError.WithFieldTree | undefined {\n return this.errors().find((e) => e.kind === kind);\n }\n\n hasMetadata(key: MetadataKey<any, any, any>): boolean {\n return this.metadataState.has(key);\n }\n\n markAsTouched(options?: MarkAsTouchedOptions): void {\n if (this.structure.isOrphaned()) {\n return;\n }\n untracked(() => {\n this.markAsTouchedInternal(options);\n this.flushSync();\n });\n }\n\n markAsTouchedInternal(options?: MarkAsTouchedOptions): void {\n if (this.structure.isOrphaned()) {\n return;\n }\n if (this.validationState.shouldSkipValidation()) {\n return;\n }\n this.nodeState.markAsTouched();\n if (options?.skipDescendants) {\n return;\n }\n for (const child of this.structure.children()) {\n child.markAsTouchedInternal();\n }\n }\n\n /**\n * Marks this specific field as dirty.\n */\n markAsDirty(): void {\n this.nodeState.markAsDirty();\n }\n\n /**\n * Marks this specific field as pristine.\n */\n markAsPristine(): void {\n this.nodeState.markAsPristine();\n }\n\n /**\n * Marks this specific field as untouched.\n */\n markAsUntouched(): void {\n this.nodeState.markAsUntouched();\n }\n\n /**\n * Resets the {@link touched} and {@link dirty} state of the field and its descendants.\n *\n * Note this does not change the data model, which can be reset directly if desired.\n *\n * @param value Optional value to set to the form. If not passed, the value will not be changed.\n */\n reset(value?: unknown): void {\n untracked(() => this._reset(value));\n }\n\n private _reset(value?: unknown) {\n this.pendingSync()?.abort();\n\n if (value !== undefined) {\n this.value.set(value);\n }\n\n // controlValue is a linkedSignal that only auto-resets when value *changes*.\n // When the reset value equals the current value (or no value was passed),\n // controlValue retains the typed text. Force it to match value by setting\n // directly via the raw interface, which doesn't trigger a sync.\n this.controlValue.rawSet(this.value());\n\n this.nodeState.markAsUntouched();\n this.nodeState.markAsPristine();\n\n for (const binding of this.formFieldBindings()) {\n binding.reset();\n }\n\n for (const child of this.structure.materializedChildren()) {\n child._reset();\n }\n }\n\n /**\n * Reloads all asynchronous validators for this field and its descendants.\n */\n reloadValidation(): void {\n untracked(() => this._reloadValidation());\n }\n\n private _reloadValidation(): void {\n const keys = this.logicNode.logic.getMetadataKeys();\n for (const key of keys) {\n if (key[IS_ASYNC_VALIDATION_RESOURCE]) {\n const resource = this.metadata(key)! as Resource<unknown> &\n Partial<Pick<WritableResource<unknown>, 'reload'>>;\n resource.reload?.();\n }\n }\n\n for (const child of this.structure.children()) {\n child._reloadValidation();\n }\n }\n\n /**\n * Creates a linked signal that initiates a {@link debounceSync} when set.\n */\n private controlValueSignal(): ControlValueSignal<unknown> {\n const controlValue = linkedSignal(this.value) as ControlValueSignal<unknown>;\n\n controlValue.rawSet = controlValue.set;\n controlValue.set = (newValue) => {\n // We intentionally allow same-value updates here to ensure that setting the control value\n // (even to the same value) still marks the control as dirty.\n controlValue.rawSet(newValue);\n this.markAsDirty();\n this.debounceSync();\n };\n const rawUpdate = controlValue.update;\n controlValue.update = (updateFn) => {\n // We intentionally allow same-value updates here to ensure that updating the control value\n // (even to the same value) still marks the control as dirty.\n rawUpdate(updateFn);\n this.markAsDirty();\n this.debounceSync();\n };\n\n return controlValue;\n }\n\n /**\n * Synchronizes the {@link controlValue} with the {@link value} signal immediately.\n */\n private sync() {\n this.value.set(this.controlValue());\n }\n\n /**\n * If there is a pending sync, abort it and sync immediately.\n */\n private flushSync() {\n const pending = this.pendingSync();\n if (pending && !pending.signal.aborted) {\n pending.abort();\n this.sync();\n }\n }\n\n /**\n * Initiates a debounced {@link sync}.\n *\n * If a debouncer is configured, the synchronization will occur after the debouncer resolves. If\n * no debouncer is configured, the synchronization happens immediately. If {@link controlValue} is\n * updated again while a debounce is pending, the previous debounce operation is aborted in favor\n * of the new one.\n */\n private async debounceSync() {\n const debouncer = untracked(() => {\n this.pendingSync()?.abort();\n return this.nodeState.debouncer();\n });\n\n if (debouncer) {\n const controller = new AbortController();\n const promise = debouncer(controller.signal);\n if (promise) {\n this.pendingSync.set(controller);\n await promise;\n if (controller.signal.aborted) {\n return; // Do not sync if the debounce was aborted.\n }\n }\n }\n\n if (this.structure.isOrphaned()) {\n return;\n }\n\n this.sync();\n }\n\n /**\n * Creates a new root field node for a new form.\n */\n static newRoot<T>(\n fieldManager: FormFieldManager,\n value: WritableSignal<T>,\n pathNode: FieldPathNode,\n adapter: FieldAdapter,\n ): FieldNode {\n return adapter.newRoot(fieldManager, value, pathNode, adapter);\n }\n\n createStructure(options: FieldNodeOptions) {\n return options.kind === 'root'\n ? new RootFieldNodeStructure(\n this,\n options.logic,\n options.fieldManager,\n options.value,\n this.newChild.bind(this),\n )\n : new ChildFieldNodeStructure(\n this,\n options.logic,\n options.parent,\n options.identityInParent,\n options.initialKeyInParent,\n this.newChild.bind(this),\n );\n }\n\n private newChild(key: string, trackingId: TrackingKey | undefined, isArray: boolean): FieldNode {\n // Determine the logic for the field that we're defining.\n let childPath: FieldPathNode | undefined;\n let childLogic: LogicNode;\n if (isArray) {\n // Fields for array elements have their logic defined by the `element` mechanism.\n // TODO: other dynamic data\n childPath = this.pathNode.getChild(DYNAMIC);\n childLogic = this.structure.logic.getChild(DYNAMIC);\n } else {\n // Fields for plain properties exist in our logic node's child map.\n childPath = this.pathNode.getChild(key);\n childLogic = this.structure.logic.getChild(key);\n }\n\n return this.fieldAdapter.newChild({\n kind: 'child',\n parent: this as ParentFieldNode,\n pathNode: childPath,\n logic: childLogic,\n initialKeyInParent: key,\n identityInParent: trackingId,\n fieldAdapter: this.fieldAdapter,\n });\n }\n}\n\nconst EMPTY = computed(() => []);\nconst FALSE = computed(() => false);\n\n/**\n * Field node of a field that has children.\n * This simplifies and makes certain types cleaner.\n */\nexport interface ParentFieldNode extends FieldNode {\n readonly value: WritableSignal<Record<string, unknown>>;\n readonly structure: FieldNodeStructure & {value: WritableSignal<Record<string, unknown>>};\n}\n\n/** Given two elements, returns the one that appears earlier in the DOM. */\nfunction firstInDom<T extends FormField<unknown>>(\n a: T | undefined,\n b: T | undefined,\n): T | undefined {\n if (!a) return b;\n if (!b) return a;\n const position = a.element.compareDocumentPosition(b.element);\n return position & Node.DOCUMENT_POSITION_PRECEDING ? b : a;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {computed, signal, Signal} from '@angular/core';\nimport type {FormField} from '../directive/form_field';\nimport type {Debouncer, DisabledReason} from '../api/types';\nimport {DEBOUNCER} from './debounce';\nimport type {FieldNode} from './node';\nimport {shallowArrayEquals} from '../util/array';\nimport {shortCircuitTrue} from './util';\n\n/**\n * The non-validation and non-submit state associated with a `FieldNode`, such as touched and dirty\n * status, as well as derived logical state.\n */\nexport class FieldNodeState {\n /**\n * Indicates whether this field has been touched directly by the user (as opposed to indirectly by\n * touching a child field).\n *\n * A field is considered directly touched when a user stops editing it for the first time (i.e. on blur)\n */\n private readonly selfTouched = signal(false);\n\n /**\n * Indicates whether this field has been dirtied directly by the user (as opposed to indirectly by\n * dirtying a child field).\n *\n * A field is considered directly dirtied if a user changed the value of the field at least once.\n */\n private readonly selfDirty = signal(false);\n\n /**\n * Marks this specific field as touched.\n */\n markAsTouched(): void {\n this.selfTouched.set(true);\n }\n\n /**\n * Marks this specific field as dirty.\n */\n markAsDirty(): void {\n this.selfDirty.set(true);\n }\n\n /**\n * Marks this specific field as not dirty.\n */\n markAsPristine(): void {\n this.selfDirty.set(false);\n }\n\n /**\n * Marks this specific field as not touched.\n */\n markAsUntouched(): void {\n this.selfTouched.set(false);\n }\n\n /** The {@link FormField} directives that bind this field to a UI control. */\n readonly formFieldBindings = signal<readonly FormField<unknown>[]>([]);\n\n constructor(private readonly node: FieldNode) {}\n\n /**\n * Whether this field is considered dirty.\n *\n * A field is considered dirty if one of the following is true:\n * - It was directly dirtied and is interactive\n * - One of its children is considered dirty\n */\n readonly dirty: Signal<boolean> = computed(() => {\n const selfDirtyValue = this.selfDirty() && !this.isNonInteractive();\n return this.node.structure.reduceChildren(\n selfDirtyValue,\n (child, value) => value || child.nodeState.dirty(),\n shortCircuitTrue,\n );\n });\n\n /**\n * Whether this field is considered touched.\n *\n * A field is considered touched if one of the following is true:\n * - It was directly touched and is interactive\n * - One of its children is considered touched\n */\n readonly touched: Signal<boolean> = computed(() => {\n const selfTouchedValue = this.selfTouched() && !this.isNonInteractive();\n return this.node.structure.reduceChildren(\n selfTouchedValue,\n (child, value) => value || child.nodeState.touched(),\n shortCircuitTrue,\n );\n });\n\n /**\n * The reasons for this field's disablement. This includes disabled reasons for any parent field\n * that may have been disabled, indirectly causing this field to be disabled as well.\n * The `field` property of the `DisabledReason` can be used to determine which field ultimately\n * caused the disablement.\n */\n readonly disabledReasons: Signal<readonly DisabledReason[]> = computed(\n () => [\n ...(this.node.structure.parent?.nodeState.disabledReasons() ?? []),\n ...this.node.logicNode.logic.disabledReasons.compute(this.node.context),\n ],\n {equal: shallowArrayEquals},\n );\n\n /**\n * Whether this field is considered disabled.\n *\n * A field is considered disabled if one of the following is true:\n * - The schema contains logic that directly disabled it\n * - Its parent field is considered disabled\n */\n readonly disabled: Signal<boolean> = computed(() => !!this.disabledReasons().length);\n\n /**\n * Whether this field is considered readonly.\n *\n * A field is considered readonly if one of the following is true:\n * - The schema contains logic that directly made it readonly\n * - Its parent field is considered readonly\n */\n readonly readonly: Signal<boolean> = computed(\n () =>\n (this.node.structure.parent?.nodeState.readonly() ||\n this.node.logicNode.logic.readonly.compute(this.node.context)) ??\n false,\n );\n\n /**\n * Whether this field is considered hidden.\n *\n * A field is considered hidden if one of the following is true:\n * - The schema contains logic that directly hides it\n * - Its parent field is considered hidden\n */\n readonly hidden: Signal<boolean> = computed(\n () =>\n (this.node.structure.parent?.nodeState.hidden() ||\n this.node.logicNode.logic.hidden.compute(this.node.context)) ??\n false,\n );\n\n readonly name: Signal<string> = computed(() => {\n const parent = this.node.structure.parent;\n if (!parent) {\n return this.node.structure.fieldManager.rootName;\n }\n\n return `${parent.name()}.${this.node.structure.keyInParent()}`;\n });\n\n /**\n * An optional {@link Debouncer} factory for this field.\n */\n readonly debouncer: Signal<((signal: AbortSignal) => Promise<void> | void) | undefined> =\n computed(() => {\n if (this.node.logicNode.logic.hasMetadata(DEBOUNCER)) {\n const debouncerLogic = this.node.logicNode.logic.getMetadata(DEBOUNCER);\n const debouncer = debouncerLogic.compute(this.node.context);\n\n // Even if this field has a `debounce()` rule, it could be applied conditionally and currently\n // inactive, in which case `compute()` will return undefined.\n if (debouncer) {\n return (signal) => debouncer(this.node.context, signal);\n }\n }\n\n // Fallback to the parent's debouncer, if any. If there is no debouncer configured all the way\n // up to the root field, this simply returns `undefined` indicating that the operation should\n // not be debounced.\n return this.node.structure.parent?.nodeState.debouncer?.();\n });\n\n /** Whether this field is considered non-interactive.\n *\n * A field is considered non-interactive if one of the following is true:\n * - It is hidden\n * - It is disabled\n * - It is readonly\n */\n private readonly isNonInteractive = computed(\n () => this.hidden() || this.disabled() || this.readonly(),\n );\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {FieldPathNode} from '../schema/path_node';\n\nimport {WritableSignal} from '@angular/core';\nimport {FormFieldManager} from './manager';\nimport {FieldNode} from './node';\nimport {FieldNodeState} from './state';\nimport {ChildFieldNodeOptions, FieldNodeOptions, FieldNodeStructure} from './structure';\nimport {FieldValidationState, ValidationState} from './validation';\n\n/**\n * Adapter allowing customization of the creation logic for a field and its associated\n * structure and state.\n */\nexport interface FieldAdapter {\n /**\n * Creates a node structure.\n * @param node\n * @param options\n */\n createStructure(node: FieldNode, options: FieldNodeOptions): FieldNodeStructure;\n\n /**\n * Creates node validation state\n * @param param\n * @param options\n */\n createValidationState(param: FieldNode, options: FieldNodeOptions): ValidationState;\n\n /**\n * Creates node state.\n * @param param\n * @param options\n */\n createNodeState(param: FieldNode, options: FieldNodeOptions): FieldNodeState;\n\n /**\n * Creates a custom child node.\n * @param options\n */\n newChild(options: ChildFieldNodeOptions): FieldNode;\n\n /**\n * Creates a custom root node.\n * @param fieldManager\n * @param model\n * @param pathNode\n * @param adapter\n */\n newRoot<TValue>(\n fieldManager: FormFieldManager,\n model: WritableSignal<TValue>,\n pathNode: FieldPathNode,\n adapter: FieldAdapter,\n ): FieldNode;\n}\n\n/**\n * Basic adapter supporting standard form behavior.\n */\nexport class BasicFieldAdapter implements FieldAdapter {\n /**\n * Creates a new Root field node.\n * @param fieldManager\n * @param value\n * @param pathNode\n * @param adapter\n */\n newRoot<TValue>(\n fieldManager: FormFieldManager,\n value: WritableSignal<TValue>,\n pathNode: FieldPathNode,\n adapter: FieldAdapter,\n ): FieldNode {\n return new FieldNode({\n kind: 'root',\n fieldManager,\n value,\n pathNode,\n logic: pathNode.builder.build(),\n fieldAdapter: adapter,\n });\n }\n\n /**\n * Creates a new child field node.\n * @param options\n */\n newChild(options: ChildFieldNodeOptions): FieldNode {\n return new FieldNode(options);\n }\n\n /**\n * Creates a node state.\n * @param node\n */\n createNodeState(node: FieldNode): FieldNodeState {\n return new FieldNodeState(node);\n }\n\n /**\n * Creates a validation state.\n * @param node\n */\n createValidationState(node: FieldNode): ValidationState {\n return new FieldValidationState(node);\n }\n\n /**\n * Creates a node structure.\n * @param node\n * @param options\n */\n createStructure(node: FieldNode, options: FieldNodeOptions): FieldNodeStructure {\n return node.createStructure(options);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {APP_ID, effect, Injector, untracked} from '@angular/core';\nimport type {FormSubmitOptions} from '../api/types';\nimport type {FieldNodeStructure} from './structure';\n\n/**\n * Manages the collection of fields associated with a given `form`.\n *\n * Fields are created implicitly, through reactivity, and may create \"owned\" entities like effects\n * or resources. When a field is no longer connected to the form, these owned entities should be\n * destroyed, which is the job of the `FormFieldManager`.\n */\nexport class FormFieldManager {\n readonly injector: Injector;\n readonly rootName: string;\n readonly submitOptions: FormSubmitOptions<unknown, unknown> | undefined;\n\n constructor(\n injector: Injector,\n rootName: string | undefined,\n submitOptions: FormSubmitOptions<unknown, unknown> | undefined,\n ) {\n this.injector = injector;\n this.rootName = rootName ?? `${this.injector.get(APP_ID)}.form${nextFormId++}`;\n this.submitOptions = submitOptions;\n }\n\n /**\n * Contains all child field structures that have been created as part of the current form.\n * New child structures are automatically added when they are created.\n * Structures are destroyed and removed when they are no longer reachable from the root.\n */\n readonly structures = new Set<FieldNodeStructure>();\n\n /**\n * Creates an effect that runs when the form's structure changes and checks for structures that\n * have become unreachable to clean up.\n *\n * For example, consider a form wrapped around the following model: `signal([0, 1, 2])`.\n * This form would have 4 nodes as part of its structure tree.\n * One structure for the root array, and one structure for each element of the array.\n * Now imagine the data is updated: `model.set([0])`. In this case the structure for the first\n * element can still be reached from the root, but the structures for the second and third\n * elements are now orphaned and not connected to the root. Thus they will be destroyed.\n *\n * @param root The root field structure.\n */\n createFieldManagementEffect(root: FieldNodeStructure): void {\n effect(\n () => {\n const liveStructures = new Set<FieldNodeStructure>();\n this.markStructuresLive(root, liveStructures);\n\n // Destroy all nodes that are no longer live.\n for (const structure of this.structures) {\n if (!liveStructures.has(structure)) {\n this.structures.delete(structure);\n untracked(() => structure.destroy());\n }\n }\n },\n {injector: this.injector},\n );\n }\n\n /**\n * Collects all structures reachable from the given structure into the given set.\n *\n * @param structure The root structure\n * @param liveStructures The set of reachable structures to populate\n */\n private markStructuresLive(\n structure: FieldNodeStructure,\n liveStructures: Set<FieldNodeStructure>,\n ): void {\n liveStructures.add(structure);\n for (const child of structure.children()) {\n this.markStructuresLive(child.structure, liveStructures);\n }\n }\n}\n\nlet nextFormId = 0;\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {InjectionToken} from '@angular/core';\nimport {FieldTree} from '../api/types';\n\n/** A function to register a signal form as a WebMCP tool. */\nexport const REGISTER_WEBMCP_FORM = new InjectionToken<RegisterWebMcpForm>(\n typeof ngDevMode !== 'undefined' && ngDevMode ? 'REGISTER_WEBMCP_FORM' : '',\n);\n\n/**\n * Registers a Signal Form as a WebMCP tool.\n *\n * @param formTree The form to register.\n * @param options Configuration options for the tool.\n */\nexport type RegisterWebMcpForm = (\n form: FieldTree<unknown>,\n options: {name: string; description: string},\n) => Promise<void>;\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport type {WritableSignal} from '@angular/core';\nimport type {FormOptions} from '../api/structure';\nimport type {SchemaOrSchemaFn} from '../api/types';\nimport {FieldAdapter} from '../field/field_adapter';\nimport {isSchemaOrSchemaFn} from '../schema/schema';\n\n/**\n * Extracts the model, schema, and options from the arguments passed to `form()`.\n */\nexport function normalizeFormArgs<TModel>(\n args: any[],\n): [\n WritableSignal<TModel>,\n SchemaOrSchemaFn<TModel> | undefined,\n (FormOptions<TModel> & {adapter?: FieldAdapter}) | undefined,\n] {\n let model: WritableSignal<TModel>;\n let schema: SchemaOrSchemaFn<TModel> | undefined;\n let options: (FormOptions<TModel> & {adapter?: FieldAdapter}) | undefined;\n\n if (args.length === 3) {\n [model, schema, options] = args;\n } else if (args.length === 2) {\n if (isSchemaOrSchemaFn(args[1])) {\n [model, schema] = args;\n } else {\n [model, options] = args;\n }\n } else {\n [model] = args;\n }\n\n return [model, schema, options];\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n inject,\n Injector,\n runInInjectionContext,\n ɵRuntimeError as RuntimeError,\n untracked,\n WritableSignal,\n} from '@angular/core';\nimport {RuntimeErrorCode} from '../errors';\nimport {BasicFieldAdapter, FieldAdapter} from '../field/field_adapter';\nimport {FormFieldManager} from '../field/manager';\nimport {FieldNode} from '../field/node';\nimport {addDefaultField} from '../field/validation';\nimport {REGISTER_WEBMCP_FORM} from '../webmcp/tokens';\nimport {DYNAMIC} from '../schema/logic';\nimport {FieldPathNode} from '../schema/path_node';\nimport {assertPathIsCurrent, SchemaImpl} from '../schema/schema';\nimport {normalizeFormArgs} from '../util/normalize_form_args';\nimport {isArray} from '../util/type_guards';\nimport type {ValidationError} from './rules';\nimport type {\n FieldState,\n FieldTree,\n FormSubmitOptions,\n ItemType,\n LogicFn,\n OneOrMany,\n PathKind,\n Schema,\n SchemaFn,\n SchemaOrSchemaFn,\n SchemaPath,\n} from './types';\n\n/**\n * Options that may be specified when creating a form.\n *\n * @see [Signal Forms setup](guide/forms/signals/overview#setup)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport interface FormOptions<TModel> {\n /**\n * The injector to use for dependency injection. If this is not provided, the injector for the\n * current [injection context](guide/di/dependency-injection-context), will be used.\n */\n injector?: Injector;\n\n /** The name of the root form, used in generating name attributes for the fields. */\n name?: string;\n\n /**\n * Configuration options to expose this form as an experimental WebMCP AI agent tool.\n *\n * @experimental\n */\n experimentalWebMcpTool?: {\n /** The unique name of the WebMCP tool to create from this form. */\n name: string;\n\n /** A description of the tool's purpose and usage information. */\n description: string;\n };\n\n /** Options that define how to handle form submission. */\n submission?: FormSubmitOptions<TModel, unknown>;\n}\n\n/**\n * Creates a form wrapped around the given model data. A form is represented as simply a `FieldTree`\n * of the model data.\n *\n * `form` uses the given model as the source of truth and *does not* maintain its own copy of the\n * data. This means that updating the value on a `FieldState` updates the originally passed in model\n * as well.\n *\n * @example\n * ```ts\n * const nameModel = signal({first: '', last: ''});\n * const nameForm = form(nameModel);\n * nameForm.first().value.set('John');\n * nameForm().value(); // {first: 'John', last: ''}\n * nameModel(); // {first: 'John', last: ''}\n * ```\n *\n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n * @return A `FieldTree` representing a form around the data model.\n * @template TModel The type of the data model.\n *\n * @see [Creating models](guide/forms/signals/models#creating-models)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function form<TModel>(model: WritableSignal<TModel>): FieldTree<TModel>;\n\n/**\n * Creates a form wrapped around the given model data. A form is represented as simply a `FieldTree`\n * of the model data.\n *\n * `form` uses the given model as the source of truth and *does not* maintain its own copy of the\n * data. This means that updating the value on a `FieldState` updates the originally passed in model\n * as well.\n *\n * @example\n * ```ts\n * const nameModel = signal({first: '', last: ''});\n * const nameForm = form(nameModel);\n * nameForm.first().value.set('John');\n * nameForm().value(); // {first: 'John', last: ''}\n * nameModel(); // {first: 'John', last: ''}\n * ```\n *\n * The form can also be created with a schema, which is a set of rules that define the logic for the\n * form. The schema can be either a pre-defined schema created with the `schema` function, or a\n * function that builds the schema by binding logic to a parts of the field structure.\n *\n * @example\n * ```ts\n * const nameForm = form(signal({first: '', last: ''}), (name) => {\n * required(name.first);\n * pattern(name.last, /^[a-z]+$/i, {message: 'Alphabet characters only'});\n * });\n * nameForm().valid(); // false\n * nameForm().value.set({first: 'John', last: 'Doe'});\n * nameForm().valid(); // true\n * ```\n *\n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n * @param schemaOrOptions The second argument can be either\n * 1. A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.).\n * When passing a schema, the form options can be passed as a third argument if needed.\n * 2. The form options\n * @return A `FieldTree` representing a form around the data model\n * @template TValue The type of the data model.\n *\n * @see [Creating models](guide/forms/signals/models#creating-models)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function form<TModel>(\n model: WritableSignal<TModel>,\n schemaOrOptions: SchemaOrSchemaFn<TModel> | FormOptions<TModel>,\n): FieldTree<TModel>;\n\n/**\n * Creates a form wrapped around the given model data. A form is represented as simply a `FieldTree`\n * of the model data.\n *\n * `form` uses the given model as the source of truth and *does not* maintain its own copy of the\n * data. This means that updating the value on a `FieldState` updates the originally passed in model\n * as well.\n *\n * @example\n * ```ts\n * const nameModel = signal({first: '', last: ''});\n * const nameForm = form(nameModel);\n * nameForm.first().value.set('John');\n * nameForm().value(); // {first: 'John', last: ''}\n * nameModel(); // {first: 'John', last: ''}\n * ```\n *\n * The form can also be created with a schema, which is a set of rules that define the logic for the\n * form. The schema can be either a pre-defined schema created with the `schema` function, or a\n * function that builds the schema by binding logic to a parts of the field structure.\n *\n * @example\n * ```ts\n * const nameForm = form(signal({first: '', last: ''}), (name) => {\n * required(name.first);\n * validate(name.last, ({value}) => !/^[a-z]+$/i.test(value()) ? {kind: 'alphabet-only'} : undefined);\n * });\n * nameForm().valid(); // false\n * nameForm().value.set({first: 'John', last: 'Doe'});\n * nameForm().valid(); // true\n * ```\n *\n * @param model A writable signal that contains the model data for the form. The resulting field\n * structure will match the shape of the model and any changes to the form data will be written to\n * the model.\n * @param schema A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.)\n * @param options The form options\n * @return A `FieldTree` representing a form around the data model.\n * @template TModel The type of the data model.\n *\n * @see [Creating models](guide/forms/signals/models#creating-models)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function form<TModel>(\n model: WritableSignal<TModel>,\n schema: SchemaOrSchemaFn<TModel>,\n options: FormOptions<TModel>,\n): FieldTree<TModel>;\n\nexport function form<TModel>(...args: any[]): FieldTree<TModel> {\n const [model, schema, options] = normalizeFormArgs<TModel>(args);\n const injector = options?.injector ?? inject(Injector);\n const pathNode = runInInjectionContext(injector, () => SchemaImpl.rootCompile(schema));\n const fieldManager = new FormFieldManager(\n injector,\n options?.name,\n options?.submission as FormSubmitOptions<unknown, unknown> | undefined,\n );\n const adapter = options?.adapter ?? new BasicFieldAdapter();\n const fieldRoot = FieldNode.newRoot(fieldManager, model, pathNode, adapter);\n fieldManager.createFieldManagementEffect(fieldRoot.structure);\n\n // Register a WebMCP tool for the form if configured.\n const {experimentalWebMcpTool} = options ?? {};\n if (experimentalWebMcpTool) {\n const registerWebMcpForm = runInInjectionContext(injector, () =>\n inject(REGISTER_WEBMCP_FORM, {optional: true}),\n );\n if (registerWebMcpForm) {\n runInInjectionContext(injector, () =>\n registerWebMcpForm(fieldRoot.fieldTree, {\n name: experimentalWebMcpTool.name,\n description: experimentalWebMcpTool.description,\n }),\n );\n } else {\n if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n throw new Error(\n `Cannot register form \"${experimentalWebMcpTool.name}\" as a WebMCP tool. ` +\n `Make sure to use \\`provideExperimentalWebMcpForms()\\` in your application bootstrap configuration.`,\n );\n }\n }\n }\n\n return fieldRoot.fieldTree as FieldTree<TModel>;\n}\n\n/**\n * Applies a schema to each item of an array.\n *\n * @example\n * ```ts\n * const nameSchema = schema<{first: string, last: string}>((name) => {\n * required(name.first);\n * required(name.last);\n * });\n * const namesForm = form(signal([{first: '', last: ''}]), (names) => {\n * applyEach(names, nameSchema);\n * });\n * ```\n *\n * @param path The target path for an array field whose items the schema will be applied to.\n * @param schema A schema for an element of the array, or function that binds logic to an\n * element of the array.\n * @template TValue The data type of the item field to apply the schema to.\n *\n * @see [Array items with applyEach](guide/forms/signals/schemas#array-items-with-applyeach)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function applyEach<TValue extends ReadonlyArray<any>>(\n path: SchemaPath<TValue>,\n schema: NoInfer<SchemaOrSchemaFn<TValue[number], PathKind.Item>>,\n): void;\nexport function applyEach<TValue extends Object>(\n path: SchemaPath<TValue>,\n schema: NoInfer<SchemaOrSchemaFn<ItemType<TValue>, PathKind.Child>>,\n): void;\nexport function applyEach<TValue extends Object>(\n path: SchemaPath<TValue>,\n schema: NoInfer<SchemaOrSchemaFn<ItemType<TValue>, PathKind.Item>>,\n): void {\n assertPathIsCurrent(path);\n\n const elementPath = FieldPathNode.unwrapFieldPath(path).getChild(DYNAMIC).fieldPathProxy;\n apply(elementPath, schema as Schema<TValue>);\n}\n\n/**\n * Applies a predefined schema to a given `FieldPath`.\n *\n * @example\n * ```ts\n * const nameSchema = schema<{first: string, last: string}>((name) => {\n * required(name.first);\n * required(name.last);\n * });\n * const profileForm = form(signal({name: {first: '', last: ''}, age: 0}), (profile) => {\n * apply(profile.name, nameSchema);\n * });\n * ```\n *\n * @param path The target path to apply the schema to.\n * @param schema The schema to apply to the property\n * @template TValue The data type of the field to apply the schema to.\n *\n * @see [Using the schema with apply](guide/forms/signals/schemas#using-the-schema-with-apply)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function apply<TValue>(\n path: SchemaPath<TValue>,\n schema: NoInfer<SchemaOrSchemaFn<TValue>>,\n): void {\n assertPathIsCurrent(path);\n\n const pathNode = FieldPathNode.unwrapFieldPath(path);\n pathNode.mergeIn(SchemaImpl.create(schema));\n}\n\n/**\n * Conditionally applies a predefined schema to a given `FieldPath`.\n *\n * @param path The target path to apply the schema to.\n * @param logic A `LogicFn<T, boolean>` that returns `true` when the schema should be applied.\n * @param schema The schema to apply to the field when the `logic` function returns `true`.\n * @template TValue The data type of the field to apply the schema to.\n *\n * @see [Conditional schemas with applyWhen](guide/forms/signals/schemas#conditional-schemas-with-applywhen)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function applyWhen<TValue>(\n path: SchemaPath<TValue>,\n logic: LogicFn<TValue, boolean>,\n schema: NoInfer<SchemaOrSchemaFn<TValue>>,\n): void {\n assertPathIsCurrent(path);\n\n const pathNode = FieldPathNode.unwrapFieldPath(path);\n pathNode.mergeIn(SchemaImpl.create(schema), {fn: logic, path});\n}\n\n/**\n * Conditionally applies a predefined schema to a given `FieldPath`.\n *\n * @param path The target path to apply the schema to.\n * @param predicate A type guard that accepts a value `T` and returns `true` if `T` is of type\n * `TNarrowed`.\n * @param schema The schema to apply to the field when `predicate` returns `true`.\n * @template TValue The data type of the field to apply the schema to.\n * @template TNarrowed The data type of the schema (a narrowed type of TValue).\n *\n * @see [Type-narrowing with applyWhenValue](guide/forms/signals/schemas#type-narrowing-with-applywhenvalue)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function applyWhenValue<TValue, TNarrowed extends TValue>(\n path: SchemaPath<TValue>,\n predicate: (value: TValue) => value is TNarrowed,\n schema: SchemaOrSchemaFn<TNarrowed>,\n): void;\n\n/**\n * Conditionally applies a predefined schema to a given `FieldPath`.\n *\n * @param path The target path to apply the schema to.\n * @param predicate A function that accepts a value `T` and returns `true` when the schema\n * should be applied.\n * @param schema The schema to apply to the field when `predicate` returns `true`.\n * @template TValue The data type of the field to apply the schema to.\n *\n * @see [Type-narrowing with applyWhenValue](guide/forms/signals/schemas#type-narrowing-with-applywhenvalue)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function applyWhenValue<TValue>(\n path: SchemaPath<TValue>,\n predicate: (value: TValue) => boolean,\n schema: NoInfer<SchemaOrSchemaFn<TValue>>,\n): void;\n\nexport function applyWhenValue(\n path: SchemaPath<unknown>,\n predicate: (value: unknown) => boolean,\n schema: SchemaOrSchemaFn<unknown>,\n) {\n applyWhen(path, ({value}) => predicate(value()), schema);\n}\n\n/**\n * Submits a given `FieldTree` using the given action function and applies any submission errors\n * resulting from the action to the field. Submission errors returned by the `action` will be integrated\n * into the field as a `ValidationError` on the sub-field indicated by the `fieldTree` property of the\n * submission error.\n *\n * Concurrent submissions are prohibited. If a submit is already in progress for the given field or any\n * of its parents, subsequent calls to `submit` will return `false` immediately without running the action.\n *\n * @example\n * ```ts\n * async function registerNewUser(registrationForm: FieldTree<{username: string, password: string}>) {\n * const result = await myClient.registerNewUser(registrationForm().value());\n * if (result.errorCode === myClient.ErrorCode.USERNAME_TAKEN) {\n * return [{\n * fieldTree: registrationForm.username,\n * kind: 'server',\n * message: 'Username already taken'\n * }];\n * }\n * return undefined;\n * }\n *\n * const registrationForm = form(signal({username: 'god', password: ''}));\n * submit(registrationForm, {\n * action: async (f) => {\n * return registerNewUser(registrationForm);\n * }\n * });\n * registrationForm.username().errors(); // [{kind: 'server', message: 'Username already taken'}]\n * ```\n *\n * @param form The field to submit.\n * @param options Options for the submission.\n * @returns Whether the submission was successful.\n * @template TModel The data type of the field being submitted.\n *\n * @see [Form submission](guide/forms/signals/form-submission)\n *\n * @category submission\n * @publicApi 22.0\n */\nexport async function submit<TModel>(\n form: FieldTree<TModel>,\n options?: NoInfer<FormSubmitOptions<unknown, TModel>>,\n): Promise<boolean>;\nexport async function submit<TModel>(\n form: FieldTree<TModel>,\n action: NoInfer<FormSubmitOptions<unknown, TModel>['action']>,\n): Promise<boolean>;\nexport async function submit<TModel>(\n form: FieldTree<TModel>,\n options?: FormSubmitOptions<unknown, TModel> | FormSubmitOptions<unknown, TModel>['action'],\n): Promise<boolean> {\n const node = untracked(form) as FieldState<unknown> as FieldNode;\n\n if (untracked(node.submitState.submitting)) {\n return false;\n }\n\n const field = options === undefined ? node.structure.root.fieldProxy : form;\n const detail = {root: node.structure.root.fieldProxy, submitted: form};\n\n // Normalize options.\n options =\n typeof options === 'function'\n ? {action: options}\n : (options ?? node.structure.fieldManager.submitOptions);\n\n // Verify that an action was provided.\n const action = options?.action as FormSubmitOptions<unknown, unknown>['action'];\n if (!action) {\n throw new RuntimeError(\n RuntimeErrorCode.MISSING_SUBMIT_ACTION,\n (typeof ngDevMode === 'undefined' || ngDevMode) &&\n 'Cannot submit form with no submit action. Specify the action when creating the form, or as an additional argument to `submit()`.',\n );\n }\n\n node.markAsTouched();\n\n const onInvalid = options?.onInvalid as FormSubmitOptions<unknown, unknown>['onInvalid'];\n const shouldRun = shouldRunAction(node, options?.ignoreValidators);\n\n // Run the action (or alternatively the `onInvalid` callback)\n try {\n if (shouldRun) {\n node.submitState.selfSubmitting.set(true);\n const errors = await untracked(() => action?.(field, detail));\n errors && setSubmissionErrors(node, errors);\n return !errors || (isArray(errors) && errors.length === 0);\n } else {\n untracked(() => onInvalid?.(field, detail));\n }\n return false;\n } finally {\n node.submitState.selfSubmitting.set(false);\n }\n}\n\n/**\n * Creates a `Schema` that adds logic rules to a form.\n * @param fn A **non-reactive** function that sets up reactive logic rules for the form.\n * @returns A schema object that implements the given logic.\n * @template TValue The value type of a `FieldTree` that this schema binds to.\n *\n * @see [Create reusable schemas with schema](guide/forms/signals/schemas#create-reusable-schemas-with-schema)\n *\n * @category structure\n * @publicApi 22.0\n */\nexport function schema<TValue>(fn: SchemaFn<TValue>): Schema<TValue> {\n return SchemaImpl.create(fn) as unknown as Schema<TValue>;\n}\n\nfunction shouldRunAction(\n node: FieldNode,\n ignoreValidators?: FormSubmitOptions<unknown, unknown>['ignoreValidators'],\n) {\n switch (ignoreValidators) {\n case 'all':\n return true;\n case 'none':\n return untracked(node.valid);\n default: // Ignore pending validators by default (or specified 'pending').\n return !untracked(node.invalid);\n }\n}\n\n/**\n * Sets a list of submission errors to their individual fields.\n *\n * @param submittedField The field that was submitted, resulting in the errors.\n * @param errors The errors to set.\n */\nfunction setSubmissionErrors(\n submittedField: FieldNode,\n errors: OneOrMany<ValidationError.WithOptionalFieldTree>,\n) {\n if (!isArray(errors)) {\n errors = [errors];\n }\n const errorsByField = new Map<FieldNode, ValidationError.WithFieldTree[]>();\n for (const error of errors) {\n const errorWithField = addDefaultField(error, submittedField.fieldTree);\n const field = errorWithField.fieldTree() as FieldNode;\n let fieldErrors = errorsByField.get(field);\n if (!fieldErrors) {\n fieldErrors = [];\n errorsByField.set(field, fieldErrors);\n }\n fieldErrors.push(errorWithField);\n }\n for (const [field, fieldErrors] of errorsByField) {\n field.submitState.submissionErrors.set(fieldErrors);\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {AbstractControl, FormArray, FormGroup, ValidationErrors} from '@angular/forms';\nimport {ValidationError} from '../api/rules';\nimport {ReadonlyFieldTree} from '../api/types';\n\n/**\n * An error used for compat errors.\n *\n * @publicApi 22.0\n * @category interop\n */\nexport class CompatValidationError<T = unknown> implements ValidationError {\n readonly kind: string = 'compat';\n readonly control: AbstractControl;\n readonly fieldTree!: ReadonlyFieldTree<unknown>;\n readonly context: T;\n readonly message?: string;\n\n constructor({context, kind, control}: {context: T; kind: string; control: AbstractControl}) {\n this.context = context;\n this.kind = kind;\n this.control = control;\n }\n}\n\n/**\n * Converts signal forms validation errors to reactive forms ValidationErrors.\n *\n * @publicApi 22.0\n */\nexport function signalErrorsToValidationErrors(errors: ValidationError[]): ValidationErrors | null {\n if (errors.length === 0) {\n return null;\n }\n const errObj: ValidationErrors = {};\n for (const error of errors) {\n errObj[error.kind] = error instanceof CompatValidationError ? error.context : error;\n }\n return errObj;\n}\n\n/**\n * Converts reactive form validation error to signal forms CompatValidationError.\n * @param errors\n * @param control\n * @return list of errors.\n */\nexport function reactiveErrorsToSignalErrors(\n errors: ValidationErrors | null,\n control: AbstractControl,\n): CompatValidationError[] {\n if (errors === null) {\n return [];\n }\n\n return Object.entries(errors).map(([kind, context]) => {\n return new CompatValidationError({context, kind, control});\n });\n}\n\n/**\n * Extracts all reactive errors from a control and its children.\n * @param control\n * @return list of errors.\n */\nexport function extractNestedReactiveErrors(control: AbstractControl): CompatValidationError[] {\n const errors: CompatValidationError[] = [];\n\n if (control.errors) {\n errors.push(...reactiveErrorsToSignalErrors(control.errors, control));\n }\n\n if (control instanceof FormGroup || control instanceof FormArray) {\n for (const c of Object.values(control.controls)) {\n errors.push(...extractNestedReactiveErrors(c));\n }\n }\n\n return errors;\n}\n"],"names":["RuntimeError","ɵisInParamsFunction","ɵsetInParamsFunction"],"mappings":";;;;;;;;;;MAgBa,UAAU,kBAAkC,MAAM,CAAC,YAAY;;ACR5E,IAAI,cAAc,GAAG,CAAC;SAMN,iBAAiB,GAAA;AAC/B,EAAA,OAAO,cAAc;AACvB;AAgCM,SAAU,8BAA8B,CAC5C,EAAqB,EACrB,KAAa,EAAA;EAEb,OAAO,CAAC,GAAG,IAAO,KAAI;IACpB,IAAI;AACF,MAAA,cAAc,GAAG,KAAK;AACtB,MAAA,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;AACpB,IAAA,CAAA,SAAU;AACR,MAAA,cAAc,GAAG,CAAC;AACpB,IAAA;EACF,CAAC;AACH;;ACjDM,SAAU,iBAAiB,CAAC,KAAc,EAAA;AAC9C,EAAA,OAAO,CAAC,KAAK;AACf;AAGM,SAAU,gBAAgB,CAAC,KAAc,EAAA;AAC7C,EAAA,OAAO,KAAK;AACd;AASM,SAAU,sBAAsB,CAAC,OAAyB,EAAA;AAC9D,EAAA,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;AAC3B,IAAA,OAAO,OAAO,CAAC,YAAY,CAAC,QAAQ;AACtC,EAAA;EAEA,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ;AACzD;;ACtBM,SAAU,OAAO,CAAC,KAAc,EAAA;AACpC,EAAA,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AAC7B;AAKM,SAAU,QAAQ,CAAC,KAAc,EAAA;AACrC,EAAA,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,KAAK,KAAK,IAAI,IAAI;AACpF;;ACIO,MAAM,OAAO,GAAkB,MAAM,EAAE;AAG9C,MAAM,OAAO,GAAG,MAAM,EAAE;MAgDF,aAA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