0x1998 - MANAGER
Düzenlenen Dosya: pipelines.rn.esm.js.map
{"version":3,"file":"pipelines.rn.esm.js","sources":["../../src/core/options_util.ts","../../src/core/structured_pipeline.ts","../../src/util/proto.ts","../../src/lite-api/expressions.ts","../../src/core/pipeline-util.ts","../../src/lite-api/stage.ts","../../src/lite-api/pipeline-source.ts","../../src/lite-api/pipeline-result.ts","../../src/util/pipeline_util.ts","../../src/lite-api/pipeline.ts","../../src/lite-api/pipeline_impl.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ParseContext } from '../api/parse_context';\nimport { parseData } from '../lite-api/user_data_reader';\nimport { ObjectValue } from '../model/object_value';\nimport { FieldPath } from '../model/path';\nimport { ApiClientObjectMap, Value } from '../protos/firestore_proto_api';\nimport { isPlainObject } from '../util/input_validation';\nimport { mapToArray } from '../util/obj';\nexport type OptionsDefinitions = Record<string, OptionDefinition>;\nexport interface OptionDefinition {\n serverName: string;\n nestedOptions?: OptionsDefinitions;\n}\n\nexport class OptionsUtil {\n constructor(private optionDefinitions: OptionsDefinitions) {}\n\n private _getKnownOptions(\n options: Record<string, unknown>,\n context: ParseContext\n ): ObjectValue {\n const knownOptions: ObjectValue = ObjectValue.empty();\n\n // SERIALIZE KNOWN OPTIONS\n for (const knownOptionKey in this.optionDefinitions) {\n if (this.optionDefinitions.hasOwnProperty(knownOptionKey)) {\n const optionDefinition: OptionDefinition =\n this.optionDefinitions[knownOptionKey];\n\n if (knownOptionKey in options) {\n const optionValue: unknown = options[knownOptionKey];\n let protoValue: Value | undefined = undefined;\n\n if (optionDefinition.nestedOptions && isPlainObject(optionValue)) {\n const nestedUtil = new OptionsUtil(optionDefinition.nestedOptions);\n protoValue = {\n mapValue: {\n fields: nestedUtil.getOptionsProto(context, optionValue)\n }\n };\n } else if (optionValue) {\n protoValue = parseData(optionValue, context) ?? undefined;\n }\n\n if (protoValue) {\n knownOptions.set(\n FieldPath.fromServerFormat(optionDefinition.serverName),\n protoValue\n );\n }\n }\n }\n }\n\n return knownOptions;\n }\n\n getOptionsProto(\n context: ParseContext,\n knownOptions: Record<string, unknown>,\n optionsOverride?: Record<string, unknown>\n ): ApiClientObjectMap<Value> | undefined {\n const result: ObjectValue = this._getKnownOptions(knownOptions, context);\n\n // APPLY OPTIONS OVERRIDES\n if (optionsOverride) {\n const optionsMap = new Map(\n mapToArray(optionsOverride, (value, key) => [\n FieldPath.fromServerFormat(key),\n value !== undefined ? parseData(value, context) : null\n ])\n );\n result.setAll(optionsMap);\n }\n\n // Return MapValue from `result` or empty map value\n return result.value.mapValue.fields ?? {};\n }\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ParseContext } from '../api/parse_context';\nimport { UserData } from '../lite-api/user_data_reader';\nimport {\n ApiClientObjectMap,\n firestoreV1ApiClientInterfaces,\n Pipeline as PipelineProto,\n StructuredPipeline as StructuredPipelineProto\n} from '../protos/firestore_proto_api';\nimport { JsonProtoSerializer, ProtoSerializable } from '../remote/serializer';\n\nimport { OptionsUtil } from './options_util';\n\nexport class StructuredPipelineOptions implements UserData {\n proto: ApiClientObjectMap<firestoreV1ApiClientInterfaces.Value> | undefined;\n\n readonly optionsUtil = new OptionsUtil({\n indexMode: {\n serverName: 'index_mode'\n }\n });\n\n constructor(\n private _userOptions: Record<string, unknown> = {},\n private _optionsOverride: Record<string, unknown> = {}\n ) {}\n\n _readUserData(context: ParseContext): void {\n this.proto = this.optionsUtil.getOptionsProto(\n context,\n this._userOptions,\n this._optionsOverride\n );\n }\n}\n\nexport class StructuredPipeline\n implements ProtoSerializable<StructuredPipelineProto>\n{\n constructor(\n private pipeline: ProtoSerializable<PipelineProto>,\n private options: StructuredPipelineOptions\n ) {}\n\n _toProto(serializer: JsonProtoSerializer): StructuredPipelineProto {\n return {\n pipeline: this.pipeline._toProto(serializer),\n options: this.options.proto\n };\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ArrayValue as ProtoArrayValue,\n Function as ProtoFunction,\n LatLng as ProtoLatLng,\n MapValue as ProtoMapValue,\n Pipeline as ProtoPipeline,\n Timestamp as ProtoTimestamp,\n Value as ProtoValue\n} from '../protos/firestore_proto_api';\n\nimport { isPlainObject } from './input_validation';\n\n/* eslint @typescript-eslint/no-explicit-any: 0 */\n\nfunction isITimestamp(obj: any): obj is ProtoTimestamp {\n if (typeof obj !== 'object' || obj === null) {\n return false; // Must be a non-null object\n }\n if (\n 'seconds' in obj &&\n (obj.seconds === null ||\n typeof obj.seconds === 'number' ||\n typeof obj.seconds === 'string') &&\n 'nanos' in obj &&\n (obj.nanos === null || typeof obj.nanos === 'number')\n ) {\n return true;\n }\n\n return false;\n}\nfunction isILatLng(obj: any): obj is ProtoLatLng {\n if (typeof obj !== 'object' || obj === null) {\n return false; // Must be a non-null object\n }\n if (\n 'latitude' in obj &&\n (obj.latitude === null || typeof obj.latitude === 'number') &&\n 'longitude' in obj &&\n (obj.longitude === null || typeof obj.longitude === 'number')\n ) {\n return true;\n }\n\n return false;\n}\nfunction isIArrayValue(obj: any): obj is ProtoArrayValue {\n if (typeof obj !== 'object' || obj === null) {\n return false; // Must be a non-null object\n }\n if ('values' in obj && (obj.values === null || Array.isArray(obj.values))) {\n return true;\n }\n\n return false;\n}\nfunction isIMapValue(obj: any): obj is ProtoMapValue {\n if (typeof obj !== 'object' || obj === null) {\n return false; // Must be a non-null object\n }\n if ('fields' in obj && (obj.fields === null || isPlainObject(obj.fields))) {\n return true;\n }\n\n return false;\n}\nfunction isIFunction(obj: any): obj is ProtoFunction {\n if (typeof obj !== 'object' || obj === null) {\n return false; // Must be a non-null object\n }\n if (\n 'name' in obj &&\n (obj.name === null || typeof obj.name === 'string') &&\n 'args' in obj &&\n (obj.args === null || Array.isArray(obj.args))\n ) {\n return true;\n }\n\n return false;\n}\n\nfunction isIPipeline(obj: any): obj is ProtoPipeline {\n if (typeof obj !== 'object' || obj === null) {\n return false; // Must be a non-null object\n }\n if ('stages' in obj && (obj.stages === null || Array.isArray(obj.stages))) {\n return true;\n }\n\n return false;\n}\n\nexport function isFirestoreValue(obj: any): obj is ProtoValue {\n if (typeof obj !== 'object' || obj === null) {\n return false; // Must be a non-null object\n }\n\n // Check optional properties and their types\n if (\n ('nullValue' in obj &&\n (obj.nullValue === null || obj.nullValue === 'NULL_VALUE')) ||\n ('booleanValue' in obj &&\n (obj.booleanValue === null || typeof obj.booleanValue === 'boolean')) ||\n ('integerValue' in obj &&\n (obj.integerValue === null ||\n typeof obj.integerValue === 'number' ||\n typeof obj.integerValue === 'string')) ||\n ('doubleValue' in obj &&\n (obj.doubleValue === null || typeof obj.doubleValue === 'number')) ||\n ('timestampValue' in obj &&\n (obj.timestampValue === null || isITimestamp(obj.timestampValue))) ||\n ('stringValue' in obj &&\n (obj.stringValue === null || typeof obj.stringValue === 'string')) ||\n ('bytesValue' in obj &&\n (obj.bytesValue === null || obj.bytesValue instanceof Uint8Array)) ||\n ('referenceValue' in obj &&\n (obj.referenceValue === null ||\n typeof obj.referenceValue === 'string')) ||\n ('geoPointValue' in obj &&\n (obj.geoPointValue === null || isILatLng(obj.geoPointValue))) ||\n ('arrayValue' in obj &&\n (obj.arrayValue === null || isIArrayValue(obj.arrayValue))) ||\n ('mapValue' in obj &&\n (obj.mapValue === null || isIMapValue(obj.mapValue))) ||\n ('fieldReferenceValue' in obj &&\n (obj.fieldReferenceValue === null ||\n typeof obj.fieldReferenceValue === 'string')) ||\n ('functionValue' in obj &&\n (obj.functionValue === null || isIFunction(obj.functionValue))) ||\n ('pipelineValue' in obj &&\n (obj.pipelineValue === null || isIPipeline(obj.pipelineValue)))\n ) {\n return true;\n }\n\n return false;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirestoreError } from '../api';\nimport { ParseContext } from '../api/parse_context';\nimport {\n DOCUMENT_KEY_NAME,\n FieldPath as InternalFieldPath\n} from '../model/path';\nimport { Value as ProtoValue } from '../protos/firestore_proto_api';\nimport {\n JsonProtoSerializer,\n ProtoValueSerializable,\n toMapValue,\n toStringValue\n} from '../remote/serializer';\nimport { hardAssert } from '../util/assert';\nimport { isPlainObject } from '../util/input_validation';\nimport { isFirestoreValue } from '../util/proto';\nimport { isString } from '../util/types';\n\nimport { Bytes } from './bytes';\nimport { documentId as documentIdFieldPath, FieldPath } from './field_path';\nimport { vector } from './field_value_impl';\nimport { GeoPoint } from './geo_point';\nimport { DocumentReference } from './reference';\nimport { Timestamp } from './timestamp';\nimport { fieldPathFromArgument, parseData, UserData } from './user_data_reader';\nimport { VectorValue } from './vector_value';\n\n/**\n * @beta\n *\n * An enumeration of the different types of expressions.\n */\nexport type ExpressionType =\n | 'Field'\n | 'Constant'\n | 'Function'\n | 'AggregateFunction'\n | 'ListOfExpressions'\n | 'AliasedExpression';\n\n/**\n * @beta\n *\n * An enumeration of the different types generated by the Firestore backend.\n *\n * <ul>\n * <li>Numerics evaluate directly to backend representation (`int64` or `float64`), not JS `number`.</li>\n * <li>JavaScript `Date` and firestore `Timestamp` objects strictly evaluate to `'timestamp'`.</li>\n * <li>Advanced configurations parsing backend types (such as `decimal128`, `max_key` or `min_key` from BSON) are also incorporated in this union string type. Note that `decimal128` is a backend-only numeric type that the JavaScript SDK cannot create natively, but can be evaluated in pipelines.</li>\n * </ul>\n */\nexport type Type =\n | 'null'\n | 'array'\n | 'boolean'\n | 'bytes'\n | 'timestamp'\n | 'geo_point'\n | 'number'\n | 'int32'\n | 'int64'\n | 'float64'\n | 'decimal128'\n | 'map'\n | 'reference'\n | 'string'\n | 'vector'\n | 'max_key'\n | 'min_key'\n | 'object_id'\n | 'regex'\n | 'request_timestamp';\n\n/**\n * Converts a value to an Expression, Returning either a Constant, MapFunction,\n * ArrayFunction, or the input itself (if it's already an expression).\n *\n * @private\n * @internal\n * @param value\n */\nfunction valueToDefaultExpr(value: unknown): Expression {\n let result: Expression | undefined;\n if (value instanceof Expression) {\n return value;\n } else if (isPlainObject(value)) {\n result = _map(value as Record<string, unknown>, undefined);\n } else if (value instanceof Array) {\n result = array(value);\n } else {\n result = _constant(value, undefined);\n }\n\n return result;\n}\n\n/**\n * Converts a value to an Expression, Returning either a Constant, MapFunction,\n * ArrayFunction, or the input itself (if it's already an expression).\n *\n * @private\n * @internal\n * @param value\n */\nfunction vectorToExpr(value: VectorValue | number[] | Expression): Expression {\n if (value instanceof Expression) {\n return value;\n } else if (value instanceof VectorValue) {\n return constant(value);\n } else if (Array.isArray(value)) {\n return constant(vector(value));\n } else {\n throw new Error('Unsupported value: ' + typeof value);\n }\n}\n\n/**\n * Converts a value to an Expression, Returning either a Constant, MapFunction,\n * ArrayFunction, or the input itself (if it's already an expression).\n * If the input is a string, it is assumed to be a field name, and a\n * field(value) is returned.\n *\n * @private\n * @internal\n * @param value\n */\nfunction fieldOrExpression(value: unknown): Expression {\n if (isString(value)) {\n const result = field(value);\n return result;\n } else {\n return valueToDefaultExpr(value);\n }\n}\n\n/**\n * @beta\n *\n * Represents an expression that can be evaluated to a value within the execution of a {@link\n * @firebase/firestore/pipelines#Pipeline}.\n *\n * Expressions are the building blocks for creating complex queries and transformations in\n * Firestore pipelines. They can represent:\n *\n * - **Field references:** Access values from document fields.\n * - **Literals:** Represent constant values (strings, numbers, booleans).\n * - **Function calls:** Apply functions to one or more expressions.\n *\n * The `Expression` class provides a fluent API for building expressions. You can chain together\n * method calls to create complex expressions.\n */\nexport abstract class Expression implements ProtoValueSerializable, UserData {\n abstract readonly expressionType: ExpressionType;\n\n abstract readonly _methodName?: string;\n\n /**\n * @private\n * @internal\n */\n abstract _toProto(serializer: JsonProtoSerializer): ProtoValue;\n _protoValueType = 'ProtoValue' as const;\n\n /**\n * @private\n * @internal\n */\n abstract _readUserData(context: ParseContext): void;\n\n /**\n * Creates an expression that adds this expression to another expression.\n *\n * @example\n * ```typescript\n * // Add the value of the 'quantity' field and the 'reserve' field.\n * field(\"quantity\").add(field(\"reserve\"));\n * ```\n *\n * @param second - The expression or literal to add to this expression.\n * @param others - Optional additional expressions or literals to add to this expression.\n * @returns A new `Expression` representing the addition operation.\n */\n add(second: Expression | unknown): FunctionExpression {\n return new FunctionExpression(\n 'add',\n [this, valueToDefaultExpr(second)],\n 'add'\n );\n }\n\n /**\n * @beta\n * Wraps the expression in a [BooleanExpression].\n *\n * @returns A [BooleanExpression] representing the same expression.\n */\n asBoolean(): BooleanExpression {\n if (this instanceof BooleanExpression) {\n return this;\n } else if (this instanceof Constant) {\n return new BooleanConstant(this);\n } else if (this instanceof Field) {\n return new BooleanField(this);\n } else if (this instanceof FunctionExpression) {\n return new BooleanFunctionExpression(this);\n } else {\n throw new FirestoreError(\n 'invalid-argument',\n `Conversion of type ${typeof this} to BooleanExpression not supported.`\n );\n }\n }\n\n /**\n * @beta\n * Creates an expression that subtracts another expression from this expression.\n *\n * @example\n * ```typescript\n * // Subtract the 'discount' field from the 'price' field\n * field(\"price\").subtract(field(\"discount\"));\n * ```\n *\n * @param subtrahend - The expression to subtract from this expression.\n * @returns A new `Expression` representing the subtraction operation.\n */\n subtract(subtrahend: Expression): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that subtracts a constant value from this expression.\n *\n * @example\n * ```typescript\n * // Subtract 20 from the value of the 'total' field\n * field(\"total\").subtract(20);\n * ```\n *\n * @param subtrahend - The constant value to subtract.\n * @returns A new `Expression` representing the subtraction operation.\n */\n subtract(subtrahend: number): FunctionExpression;\n subtract(subtrahend: number | Expression): FunctionExpression {\n return new FunctionExpression(\n 'subtract',\n [this, valueToDefaultExpr(subtrahend)],\n 'subtract'\n );\n }\n\n /**\n * @beta\n * Creates an expression that multiplies this expression by another expression.\n *\n * @example\n * ```typescript\n * // Multiply the 'quantity' field by the 'price' field\n * field(\"quantity\").multiply(field(\"price\"));\n * ```\n *\n * @param second - The second expression or literal to multiply by.\n * @param others - Optional additional expressions or literals to multiply by.\n * @returns A new `Expression` representing the multiplication operation.\n */\n multiply(second: Expression | number): FunctionExpression {\n return new FunctionExpression(\n 'multiply',\n [this, valueToDefaultExpr(second)],\n 'multiply'\n );\n }\n\n /**\n * @beta\n * Creates an expression that divides this expression by another expression.\n *\n * @example\n * ```typescript\n * // Divide the 'total' field by the 'count' field\n * field(\"total\").divide(field(\"count\"));\n * ```\n *\n * @param divisor - The expression to divide by.\n * @returns A new `Expression` representing the division operation.\n */\n divide(divisor: Expression): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that divides this expression by a constant value.\n *\n * @example\n * ```typescript\n * // Divide the 'value' field by 10\n * field(\"value\").divide(10);\n * ```\n *\n * @param divisor - The constant value to divide by.\n * @returns A new `Expression` representing the division operation.\n */\n divide(divisor: number): FunctionExpression;\n divide(divisor: number | Expression): FunctionExpression {\n return new FunctionExpression(\n 'divide',\n [this, valueToDefaultExpr(divisor)],\n 'divide'\n );\n }\n\n /**\n * @beta\n * Creates an expression that calculates the modulo (remainder) of dividing this expression by another expression.\n *\n * @example\n * ```typescript\n * // Calculate the remainder of dividing the 'value' field by the 'divisor' field\n * field(\"value\").mod(field(\"divisor\"));\n * ```\n *\n * @param expression - The expression to divide by.\n * @returns A new `Expression` representing the modulo operation.\n */\n mod(expression: Expression): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that calculates the modulo (remainder) of dividing this expression by a constant value.\n *\n * @example\n * ```typescript\n * // Calculate the remainder of dividing the 'value' field by 10\n * field(\"value\").mod(10);\n * ```\n *\n * @param value - The constant value to divide by.\n * @returns A new `Expression` representing the modulo operation.\n */\n mod(value: number): FunctionExpression;\n mod(other: number | Expression): FunctionExpression {\n return new FunctionExpression(\n 'mod',\n [this, valueToDefaultExpr(other)],\n 'mod'\n );\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is equal to another expression.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is equal to 21\n * field(\"age\").equal(21);\n * ```\n *\n * @param expression - The expression to compare for equality.\n * @returns A new `Expression` representing the equality comparison.\n */\n equal(expression: Expression): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'city' field is equal to \"London\"\n * field(\"city\").equal(\"London\");\n * ```\n *\n * @param value - The constant value to compare for equality.\n * @returns A new `Expression` representing the equality comparison.\n */\n equal(value: unknown): BooleanExpression;\n equal(other: unknown): BooleanExpression {\n return new FunctionExpression(\n 'equal',\n [this, valueToDefaultExpr(other)],\n 'equal'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is not equal to another expression.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is not equal to \"completed\"\n * field(\"status\").notEqual(\"completed\");\n * ```\n *\n * @param expression - The expression to compare for inequality.\n * @returns A new `Expression` representing the inequality comparison.\n */\n notEqual(expression: Expression): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is not equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'country' field is not equal to \"USA\"\n * field(\"country\").notEqual(\"USA\");\n * ```\n *\n * @param value - The constant value to compare for inequality.\n * @returns A new `Expression` representing the inequality comparison.\n */\n notEqual(value: unknown): BooleanExpression;\n notEqual(other: unknown): BooleanExpression {\n return new FunctionExpression(\n 'not_equal',\n [this, valueToDefaultExpr(other)],\n 'notEqual'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is less than another expression.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is less than 'limit'\n * field(\"age\").lessThan(field('limit'));\n * ```\n *\n * @param experession - The expression to compare for less than.\n * @returns A new `Expression` representing the less than comparison.\n */\n lessThan(experession: Expression): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is less than a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'price' field is less than 50\n * field(\"price\").lessThan(50);\n * ```\n *\n * @param value - The constant value to compare for less than.\n * @returns A new `Expression` representing the less than comparison.\n */\n lessThan(value: unknown): BooleanExpression;\n lessThan(other: unknown): BooleanExpression {\n return new FunctionExpression(\n 'less_than',\n [this, valueToDefaultExpr(other)],\n 'lessThan'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is less than or equal to another\n * expression.\n *\n * @example\n * ```typescript\n * // Check if the 'quantity' field is less than or equal to 20\n * field(\"quantity\").lessThan(constant(20));\n * ```\n *\n * @param expression - The expression to compare for less than or equal to.\n * @returns A new `Expression` representing the less than or equal to comparison.\n */\n lessThanOrEqual(expression: Expression): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is less than or equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'score' field is less than or equal to 70\n * field(\"score\").lessThan(70);\n * ```\n *\n * @param value - The constant value to compare for less than or equal to.\n * @returns A new `Expression` representing the less than or equal to comparison.\n */\n lessThanOrEqual(value: unknown): BooleanExpression;\n lessThanOrEqual(other: unknown): BooleanExpression {\n return new FunctionExpression(\n 'less_than_or_equal',\n [this, valueToDefaultExpr(other)],\n 'lessThanOrEqual'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is greater than another expression.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is greater than the 'limit' field\n * field(\"age\").greaterThan(field(\"limit\"));\n * ```\n *\n * @param expression - The expression to compare for greater than.\n * @returns A new `Expression` representing the greater than comparison.\n */\n greaterThan(expression: Expression): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is greater than a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'price' field is greater than 100\n * field(\"price\").greaterThan(100);\n * ```\n *\n * @param value - The constant value to compare for greater than.\n * @returns A new `Expression` representing the greater than comparison.\n */\n greaterThan(value: unknown): BooleanExpression;\n greaterThan(other: unknown): BooleanExpression {\n return new FunctionExpression(\n 'greater_than',\n [this, valueToDefaultExpr(other)],\n 'greaterThan'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is greater than or equal to another\n * expression.\n *\n * @example\n * ```typescript\n * // Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1\n * field(\"quantity\").greaterThanOrEqual(field('requirement').add(1));\n * ```\n *\n * @param expression - The expression to compare for greater than or equal to.\n * @returns A new `Expression` representing the greater than or equal to comparison.\n */\n greaterThanOrEqual(expression: Expression): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is greater than or equal to a constant\n * value.\n *\n * @example\n * ```typescript\n * // Check if the 'score' field is greater than or equal to 80\n * field(\"score\").greaterThanOrEqual(80);\n * ```\n *\n * @param value - The constant value to compare for greater than or equal to.\n * @returns A new `Expression` representing the greater than or equal to comparison.\n */\n greaterThanOrEqual(value: unknown): BooleanExpression;\n greaterThanOrEqual(other: unknown): BooleanExpression {\n return new FunctionExpression(\n 'greater_than_or_equal',\n [this, valueToDefaultExpr(other)],\n 'greaterThanOrEqual'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that concatenates an array expression with one or more other arrays.\n *\n * @example\n * ```typescript\n * // Combine the 'items' array with another array field.\n * field(\"items\").arrayConcat(field(\"otherItems\"));\n * ```\n * @param secondArray - Second array expression or array literal to concatenate.\n * @param otherArrays - Optional additional array expressions or array literals to concatenate.\n * @returns A new `Expression` representing the concatenated array.\n */\n arrayConcat(\n secondArray: Expression | unknown[],\n ...otherArrays: Array<Expression | unknown[]>\n ): FunctionExpression {\n const elements = [secondArray, ...otherArrays];\n const exprValues = elements.map(value => valueToDefaultExpr(value));\n return new FunctionExpression(\n 'array_concat',\n [this, ...exprValues],\n 'arrayConcat'\n );\n }\n\n /**\n * @beta\n * Creates an expression that checks if an array contains a specific element.\n *\n * @example\n * ```typescript\n * // Check if the 'sizes' array contains the value from the 'selectedSize' field\n * field(\"sizes\").arrayContains(field(\"selectedSize\"));\n * ```\n *\n * @param expression - The element to search for in the array.\n * @returns A new `Expression` representing the 'array_contains' comparison.\n */\n arrayContains(expression: Expression): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if an array contains a specific value.\n *\n * @example\n * ```typescript\n * // Check if the 'colors' array contains \"red\"\n * field(\"colors\").arrayContains(\"red\");\n * ```\n *\n * @param value - The element to search for in the array.\n * @returns A new `Expression` representing the 'array_contains' comparison.\n */\n arrayContains(value: unknown): BooleanExpression;\n arrayContains(element: unknown): BooleanExpression {\n return new FunctionExpression(\n 'array_contains',\n [this, valueToDefaultExpr(element)],\n 'arrayContains'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if an array contains all the specified elements.\n *\n * @example\n * ```typescript\n * // Check if the 'tags' array contains both the value in field \"tag1\" and the literal value \"tag2\"\n * field(\"tags\").arrayContainsAll([field(\"tag1\"), \"tag2\"]);\n * ```\n *\n * @param values - The elements to check for in the array.\n * @returns A new `Expression` representing the 'array_contains_all' comparison.\n */\n arrayContainsAll(values: Array<Expression | unknown>): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if an array contains all the specified elements.\n *\n * @example\n * ```typescript\n * // Check if the 'tags' array contains both of the values from field \"tag1\" and the literal value \"tag2\"\n * field(\"tags\").arrayContainsAll(array([field(\"tag1\"), \"tag2\"]));\n * ```\n *\n * @param arrayExpression - The elements to check for in the array.\n * @returns A new `Expression` representing the 'array_contains_all' comparison.\n */\n arrayContainsAll(arrayExpression: Expression): BooleanExpression;\n arrayContainsAll(values: unknown[] | Expression): BooleanExpression {\n const normalizedExpr = Array.isArray(values)\n ? new ListOfExprs(values.map(valueToDefaultExpr), 'arrayContainsAll')\n : values;\n return new FunctionExpression(\n 'array_contains_all',\n [this, normalizedExpr],\n 'arrayContainsAll'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if an array contains any of the specified elements.\n *\n * @example\n * ```typescript\n * // Check if the 'categories' array contains either values from field \"cate1\" or \"cate2\"\n * field(\"categories\").arrayContainsAny([field(\"cate1\"), field(\"cate2\")]);\n * ```\n *\n * @param values - The elements to check for in the array.\n * @returns A new `Expression` representing the 'array_contains_any' comparison.\n */\n arrayContainsAny(values: Array<Expression | unknown>): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if an array contains any of the specified elements.\n *\n * @example\n * ```typescript\n * // Check if the 'groups' array contains either the value from the 'userGroup' field\n * // or the value \"guest\"\n * field(\"groups\").arrayContainsAny(array([field(\"userGroup\"), \"guest\"]));\n * ```\n *\n * @param arrayExpression - The elements to check for in the array.\n * @returns A new `Expression` representing the 'array_contains_any' comparison.\n */\n arrayContainsAny(arrayExpression: Expression): BooleanExpression;\n arrayContainsAny(\n values: Array<unknown | Expression> | Expression\n ): BooleanExpression {\n const normalizedExpr = Array.isArray(values)\n ? new ListOfExprs(values.map(valueToDefaultExpr), 'arrayContainsAny')\n : values;\n return new FunctionExpression(\n 'array_contains_any',\n [this, normalizedExpr],\n 'arrayContainsAny'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that reverses an array.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myArray' field.\n * field(\"myArray\").arrayReverse();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed array.\n */\n arrayReverse(): FunctionExpression {\n return new FunctionExpression('array_reverse', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that calculates the length of an array.\n *\n * @example\n * ```typescript\n * // Get the number of items in the 'cart' array\n * field(\"cart\").arrayLength();\n * ```\n *\n * @returns A new `Expression` representing the length of the array.\n */\n arrayLength(): FunctionExpression {\n return new FunctionExpression('array_length', [this], 'arrayLength');\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is equal to any of the provided values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'category' field is either \"Electronics\" or value of field 'primaryType'\n * field(\"category\").equalAny(\"Electronics\", field(\"primaryType\"));\n * ```\n *\n * @param values - The values or expressions to check against.\n * @returns A new `Expression` representing the 'IN' comparison.\n */\n equalAny(values: Array<Expression | unknown>): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is equal to any of the provided values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'category' field is either \"Electronics\" or value of field 'primaryType'\n * field(\"category\").equalAny(array([\"Electronics\", field(\"primaryType\")]));\n * ```\n *\n * @param arrayExpression - An expression that evaluates to an array of values to check against.\n * @returns A new `Expression` representing the 'IN' comparison.\n */\n equalAny(arrayExpression: Expression): BooleanExpression;\n equalAny(others: unknown[] | Expression): BooleanExpression {\n const exprOthers = Array.isArray(others)\n ? new ListOfExprs(others.map(valueToDefaultExpr), 'equalAny')\n : others;\n return new FunctionExpression(\n 'equal_any',\n [this, exprOthers],\n 'equalAny'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if this expression is not equal to any of the provided values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is neither \"pending\" nor the value of 'rejectedStatus'\n * field(\"status\").notEqualAny([\"pending\", field(\"rejectedStatus\")]);\n * ```\n *\n * @param values - The values or expressions to check against.\n * @returns A new `Expression` representing the 'notEqualAny' comparison.\n */\n notEqualAny(values: Array<Expression | unknown>): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if this expression is not equal to any of the values in the evaluated expression.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is not equal to any value in the field 'rejectedStatuses'\n * field(\"status\").notEqualAny(field('rejectedStatuses'));\n * ```\n *\n * @param arrayExpression - The values or expressions to check against.\n * @returns A new `Expression` representing the 'notEqualAny' comparison.\n */\n notEqualAny(arrayExpression: Expression): BooleanExpression;\n notEqualAny(others: unknown[] | Expression): BooleanExpression {\n const exprOthers = Array.isArray(others)\n ? new ListOfExprs(others.map(valueToDefaultExpr), 'notEqualAny')\n : others;\n return new FunctionExpression(\n 'not_equal_any',\n [this, exprOthers],\n 'notEqualAny'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if a field exists in the document.\n *\n * @example\n * ```typescript\n * // Check if the document has a field named \"phoneNumber\"\n * field(\"phoneNumber\").exists();\n * ```\n *\n * @returns A new `Expression` representing the 'exists' check.\n */\n exists(): BooleanExpression {\n return new FunctionExpression('exists', [this], 'exists').asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that calculates the character length of a string in UTF-8.\n *\n * @example\n * ```typescript\n * // Get the character length of the 'name' field in its UTF-8 form.\n * field(\"name\").charLength();\n * ```\n *\n * @returns A new `Expression` representing the length of the string.\n */\n charLength(): FunctionExpression {\n return new FunctionExpression('char_length', [this], 'charLength');\n }\n\n /**\n * @beta\n * Creates an expression that performs a case-sensitive string comparison.\n *\n * @example\n * ```typescript\n * // Check if the 'title' field contains the word \"guide\" (case-sensitive)\n * field(\"title\").like(\"%guide%\");\n * ```\n *\n * @param pattern - The pattern to search for. You can use \"%\" as a wildcard character.\n * @returns A new `Expression` representing the 'like' comparison.\n */\n like(pattern: string): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that performs a case-sensitive string comparison.\n *\n * @example\n * ```typescript\n * // Check if the 'title' field contains the word \"guide\" (case-sensitive)\n * field(\"title\").like(\"%guide%\");\n * ```\n *\n * @param pattern - The pattern to search for. You can use \"%\" as a wildcard character.\n * @returns A new `Expression` representing the 'like' comparison.\n */\n like(pattern: Expression): BooleanExpression;\n like(stringOrExpr: string | Expression): BooleanExpression {\n return new FunctionExpression(\n 'like',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'like'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if a string contains a specified regular expression as a\n * substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\" (case-insensitive)\n * field(\"description\").regexContains(\"(?i)example\");\n * ```\n *\n * @param pattern - The regular expression to use for the search.\n * @returns A new `Expression` representing the 'contains' comparison.\n */\n regexContains(pattern: string): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if a string contains a specified regular expression as a\n * substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains the regular expression stored in field 'regex'\n * field(\"description\").regexContains(field(\"regex\"));\n * ```\n *\n * @param pattern - The regular expression to use for the search.\n * @returns A new `Expression` representing the 'contains' comparison.\n */\n regexContains(pattern: Expression): BooleanExpression;\n regexContains(stringOrExpr: string | Expression): BooleanExpression {\n return new FunctionExpression(\n 'regex_contains',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'regexContains'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that returns the first substring of a string expression that matches\n * a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract the domain from an email address\n * field(\"email\").regexFind(\"@.+\")\n * ```\n *\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression find function.\n */\n regexFind(pattern: string): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that returns the first substring of a string expression that matches\n * a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract the domain from an email address\n * field(\"email\").regexFind(field(\"domain\"))\n * ```\n *\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression find function.\n */\n regexFind(pattern: Expression): FunctionExpression;\n regexFind(stringOrExpr: string | Expression): FunctionExpression {\n return new FunctionExpression(\n 'regex_find',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'regexFind'\n );\n }\n\n /**\n * @beta\n *\n * Creates an expression that evaluates to a list of all substrings in this string expression that\n * match a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract all hashtags from a post content field\n * field(\"content\").regexFindAll(\"#[A-Za-z0-9_]+\")\n * ```\n *\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} that evaluates to an array of matched substrings.\n */\n regexFindAll(pattern: string): FunctionExpression;\n\n /**\n * @beta\n *\n * Creates an expression that evaluates to a list of all substrings in this string expression that\n * match a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract all names from a post content field\n * field(\"content\").regexFindAll(field(\"names\"))\n * ```\n *\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} that evaluates to an array of matched substrings.\n */\n regexFindAll(pattern: Expression): FunctionExpression;\n regexFindAll(stringOrExpr: string | Expression): FunctionExpression {\n return new FunctionExpression(\n 'regex_find_all',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'regexFindAll'\n );\n }\n\n /**\n * @beta\n * Creates an expression that checks if a string matches a specified regular expression.\n *\n * @example\n * ```typescript\n * // Check if the 'email' field matches a valid email pattern\n * field(\"email\").regexMatch(\"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2,}\");\n * ```\n *\n * @param pattern - The regular expression to use for the match.\n * @returns A new `Expression` representing the regular expression match.\n */\n regexMatch(pattern: string): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if a string matches a specified regular expression.\n *\n * @example\n * ```typescript\n * // Check if the 'email' field matches a regular expression stored in field 'regex'\n * field(\"email\").regexMatch(field(\"regex\"));\n * ```\n *\n * @param pattern - The regular expression to use for the match.\n * @returns A new `Expression` representing the regular expression match.\n */\n regexMatch(pattern: Expression): BooleanExpression;\n regexMatch(stringOrExpr: string | Expression): BooleanExpression {\n return new FunctionExpression(\n 'regex_match',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'regexMatch'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if a string contains a specified substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\".\n * field(\"description\").stringContains(\"example\");\n * ```\n *\n * @param substring - The substring to search for.\n * @returns A new `Expression` representing the 'contains' comparison.\n */\n stringContains(substring: string): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if a string contains the string represented by another expression.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains the value of the 'keyword' field.\n * field(\"description\").stringContains(field(\"keyword\"));\n * ```\n *\n * @param expr - The expression representing the substring to search for.\n * @returns A new `Expression` representing the 'contains' comparison.\n */\n stringContains(expr: Expression): BooleanExpression;\n stringContains(stringOrExpr: string | Expression): BooleanExpression {\n return new FunctionExpression(\n 'string_contains',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'stringContains'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if a string starts with a given prefix.\n *\n * @example\n * ```typescript\n * // Check if the 'name' field starts with \"Mr.\"\n * field(\"name\").startsWith(\"Mr.\");\n * ```\n *\n * @param prefix - The prefix to check for.\n * @returns A new `Expression` representing the 'starts with' comparison.\n */\n startsWith(prefix: string): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if a string starts with a given prefix (represented as an\n * expression).\n *\n * @example\n * ```typescript\n * // Check if the 'fullName' field starts with the value of the 'firstName' field\n * field(\"fullName\").startsWith(field(\"firstName\"));\n * ```\n *\n * @param prefix - The prefix expression to check for.\n * @returns A new `Expression` representing the 'starts with' comparison.\n */\n startsWith(prefix: Expression): BooleanExpression;\n startsWith(stringOrExpr: string | Expression): BooleanExpression {\n return new FunctionExpression(\n 'starts_with',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'startsWith'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that checks if a string ends with a given postfix.\n *\n * @example\n * ```typescript\n * // Check if the 'filename' field ends with \".txt\"\n * field(\"filename\").endsWith(\".txt\");\n * ```\n *\n * @param suffix - The postfix to check for.\n * @returns A new `Expression` representing the 'ends with' comparison.\n */\n endsWith(suffix: string): BooleanExpression;\n\n /**\n * @beta\n * Creates an expression that checks if a string ends with a given postfix (represented as an\n * expression).\n *\n * @example\n * ```typescript\n * // Check if the 'url' field ends with the value of the 'extension' field\n * field(\"url\").endsWith(field(\"extension\"));\n * ```\n *\n * @param suffix - The postfix expression to check for.\n * @returns A new `Expression` representing the 'ends with' comparison.\n */\n endsWith(suffix: Expression): BooleanExpression;\n endsWith(stringOrExpr: string | Expression): BooleanExpression {\n return new FunctionExpression(\n 'ends_with',\n [this, valueToDefaultExpr(stringOrExpr)],\n 'endsWith'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that converts a string to lowercase.\n *\n * @example\n * ```typescript\n * // Convert the 'name' field to lowercase\n * field(\"name\").toLower();\n * ```\n *\n * @returns A new `Expression` representing the lowercase string.\n */\n toLower(): FunctionExpression {\n return new FunctionExpression('to_lower', [this], 'toLower');\n }\n\n /**\n * @beta\n * Creates an expression that converts a string to uppercase.\n *\n * @example\n * ```typescript\n * // Convert the 'title' field to uppercase\n * field(\"title\").toUpper();\n * ```\n *\n * @returns A new `Expression` representing the uppercase string.\n */\n toUpper(): FunctionExpression {\n return new FunctionExpression('to_upper', [this], 'toUpper');\n }\n\n /**\n * @beta\n * Creates an expression that removes leading and trailing characters from a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the 'userInput' field\n * field(\"userInput\").trim();\n *\n * // Trim quotes from the 'userInput' field\n * field(\"userInput\").trim('\"');\n * ```\n * @param valueToTrim - Optional This parameter is treated as a set of characters or bytes that will be\n * trimmed from the input. If not specified, then whitespace will be trimmed.\n * @returns A new `Expression` representing the trimmed string or byte array.\n */\n trim(valueToTrim?: string | Expression | Bytes): FunctionExpression {\n const args: Expression[] = [this];\n if (valueToTrim) {\n args.push(valueToDefaultExpr(valueToTrim));\n }\n return new FunctionExpression('trim', args, 'trim');\n }\n\n /**\n * @beta\n * Trims whitespace or a specified set of characters/bytes from the beginning of a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the beginning of the 'userInput' field\n * field(\"userInput\").ltrim();\n *\n * // Trim quotes from the beginning of the 'userInput' field\n * field(\"userInput\").ltrim('\"');\n * ```\n *\n * @param valueToTrim - Optional. A string or byte array containing the characters/bytes to trim.\n * If not specified, whitespace will be trimmed.\n * @returns A new `Expression` representing the trimmed string.\n */\n ltrim(valueToTrim?: string | Expression | Bytes): FunctionExpression {\n const args: Expression[] = [this];\n if (valueToTrim) {\n args.push(valueToDefaultExpr(valueToTrim));\n }\n return new FunctionExpression('ltrim', args, 'ltrim');\n }\n\n /**\n * @beta\n * Trims whitespace or a specified set of characters/bytes from the end of a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the end of the 'userInput' field\n * field(\"userInput\").rtrim();\n *\n * // Trim quotes from the end of the 'userInput' field\n * field(\"userInput\").rtrim('\"');\n * ```\n *\n * @param valueToTrim - Optional. A string or byte array containing the characters/bytes to trim.\n * If not specified, whitespace will be trimmed.\n * @returns A new `Expression` representing the trimmed string or byte array.\n */\n rtrim(valueToTrim?: string | Expression | Bytes): FunctionExpression {\n const args: Expression[] = [this];\n if (valueToTrim) {\n args.push(valueToDefaultExpr(valueToTrim));\n }\n return new FunctionExpression('rtrim', args, 'rtrim');\n }\n\n /**\n * @beta\n * Creates an expression that returns the data type of this expression's result, as a string.\n *\n * @remarks\n * This is evaluated on the backend. This means:\n * 1. Generic typed elements (like `array<string>`) evaluate strictly to the primitive `'array'`.\n * 2. Any custom `FirestoreDataConverter` mappings are ignored.\n * 3. For numeric values, the backend does not yield the JavaScript `\"number\"` type; it evaluates\n * precisely as `\"int64\"` or `\"float64\"`.\n * 4. For date or timestamp objects, the backend evaluates to `\"timestamp\"`.\n *\n * @example\n * ```typescript\n * // Get the data type of the value in field 'title'\n * field('title').type()\n * ```\n *\n * @returns A new `Expression` representing the data type.\n */\n type(): FunctionExpression {\n return new FunctionExpression('type', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that checks if the result of this expression is of the given type.\n *\n * @remarks Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data.\n *\n * @example\n * ```typescript\n * // Check if the 'price' field is specifically an integer (not just 'number')\n * field('price').isType('int64');\n * ```\n *\n * @param type - The type to check for.\n * @returns A new `BooleanExpression` that evaluates to true if the expression's result is of the given type, false otherwise.\n */\n isType(type: Type): BooleanExpression {\n return new FunctionExpression(\n 'is_type',\n [this, constant(type)],\n 'isType'\n ).asBoolean();\n }\n\n /**\n * @beta\n * Creates an expression that concatenates string expressions together.\n *\n * @example\n * ```typescript\n * // Combine the 'firstName', \" \", and 'lastName' fields into a single string\n * field(\"firstName\").stringConcat(constant(\" \"), field(\"lastName\"));\n * ```\n *\n * @param secondString - The additional expression or string literal to concatenate.\n * @param otherStrings - Optional additional expressions or string literals to concatenate.\n * @returns A new `Expression` representing the concatenated string.\n */\n stringConcat(\n secondString: Expression | string,\n ...otherStrings: Array<Expression | string>\n ): FunctionExpression {\n const elements = [secondString, ...otherStrings];\n const exprs = elements.map(valueToDefaultExpr);\n return new FunctionExpression(\n 'string_concat',\n [this, ...exprs],\n 'stringConcat'\n );\n }\n\n /**\n * @beta\n * Creates an expression that finds the index of the first occurrence of a substring or byte sequence.\n *\n * @example\n * ```typescript\n * // Find the index of \"foo\" in the 'text' field\n * field(\"text\").stringIndexOf(\"foo\");\n * ```\n *\n * @param search - The substring or byte sequence to search for.\n * @returns A new `Expression` representing the index of the first occurrence.\n */\n stringIndexOf(search: string | Expression | Bytes): FunctionExpression {\n return new FunctionExpression(\n 'string_index_of',\n [this, valueToDefaultExpr(search)],\n 'stringIndexOf'\n );\n }\n\n /**\n * @beta\n * Creates an expression that repeats a string or byte array a specified number of times.\n *\n * @example\n * ```typescript\n * // Repeat the 'label' field 3 times\n * field(\"label\").stringRepeat(3);\n * ```\n *\n * @param repetitions - The number of times to repeat the string or byte array.\n * @returns A new `Expression` representing the repeated string or byte array.\n */\n stringRepeat(repetitions: number | Expression): FunctionExpression {\n return new FunctionExpression(\n 'string_repeat',\n [this, valueToDefaultExpr(repetitions)],\n 'stringRepeat'\n );\n }\n\n /**\n * @beta\n * Creates an expression that replaces all occurrences of a substring or byte sequence with a replacement.\n *\n * @example\n * ```typescript\n * // Replace all occurrences of \"foo\" with \"bar\" in the 'text' field\n * field(\"text\").stringReplaceAll(\"foo\", \"bar\");\n * ```\n *\n * @param find - The substring or byte sequence to search for.\n * @param replacement - The replacement string or byte sequence.\n * @returns A new `Expression` representing the string or byte array with replacements.\n */\n stringReplaceAll(\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n ): FunctionExpression {\n return new FunctionExpression(\n 'string_replace_all',\n [this, valueToDefaultExpr(find), valueToDefaultExpr(replacement)],\n 'stringReplaceAll'\n );\n }\n\n /**\n * @beta\n * Creates an expression that replaces the first occurrence of a substring or byte sequence with a replacement.\n *\n * @example\n * ```typescript\n * // Replace the first occurrence of \"foo\" with \"bar\" in the 'text' field\n * field(\"text\").stringReplaceOne(\"foo\", \"bar\");\n * ```\n *\n * @param find - The substring or byte sequence to search for.\n * @param replacement - The replacement string or byte sequence.\n * @returns A new `Expression` representing the string or byte array with the replacement.\n */\n stringReplaceOne(\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n ): FunctionExpression {\n return new FunctionExpression(\n 'string_replace_one',\n [this, valueToDefaultExpr(find), valueToDefaultExpr(replacement)],\n 'stringReplaceOne'\n );\n }\n\n /**\n * @beta\n * Creates an expression that concatenates expression results together.\n *\n * @example\n * ```typescript\n * // Combine the 'firstName', ' ', and 'lastName' fields into a single value.\n * field(\"firstName\").concat(constant(\" \"), field(\"lastName\"));\n * ```\n *\n * @param second - The additional expression or literal to concatenate.\n * @param others - Optional additional expressions or literals to concatenate.\n * @returns A new `Expression` representing the concatenated value.\n */\n concat(\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n ): FunctionExpression {\n const elements = [second, ...others];\n const exprs = elements.map(valueToDefaultExpr);\n return new FunctionExpression('concat', [this, ...exprs], 'concat');\n }\n\n /**\n * @beta\n * Creates an expression that reverses this string expression.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myString' field.\n * field(\"myString\").reverse();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed string.\n */\n reverse(): FunctionExpression {\n return new FunctionExpression('reverse', [this], 'reverse');\n }\n\n /**\n * @beta\n * Creates an expression that calculates the length of this string expression in bytes.\n *\n * @example\n * ```typescript\n * // Calculate the length of the 'myString' field in bytes.\n * field(\"myString\").byteLength();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the string in bytes.\n */\n byteLength(): FunctionExpression {\n return new FunctionExpression('byte_length', [this], 'byteLength');\n }\n\n /**\n * @beta\n * Creates an expression that computes the ceiling of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the ceiling of the 'price' field.\n * field(\"price\").ceil();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the ceiling of the numeric value.\n */\n ceil(): FunctionExpression {\n return new FunctionExpression('ceil', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that computes the floor of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the floor of the 'price' field.\n * field(\"price\").floor();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the floor of the numeric value.\n */\n floor(): FunctionExpression {\n return new FunctionExpression('floor', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that computes the absolute value of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the absolute value of the 'price' field.\n * field(\"price\").abs();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the absolute value of the numeric value.\n */\n abs(): FunctionExpression {\n return new FunctionExpression('abs', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that computes e to the power of this expression.\n *\n * @example\n * ```typescript\n * // Compute e to the power of the 'value' field.\n * field(\"value\").exp();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the exp of the numeric value.\n */\n exp(): FunctionExpression {\n return new FunctionExpression('exp', [this]);\n }\n\n /**\n * @beta\n * Accesses a value from a map (object) field using the provided key.\n *\n * @example\n * ```typescript\n * // Get the 'city' value from the 'address' map field\n * field(\"address\").mapGet(\"city\");\n * ```\n *\n * @param subfield - The key to access in the map.\n * @returns A new `Expression` representing the value associated with the given key in the map.\n */\n mapGet(subfield: string): FunctionExpression {\n return new FunctionExpression(\n 'map_get',\n [this, constant(subfield)],\n 'mapGet'\n );\n }\n\n /**\n * @beta\n * Creates an expression that returns a new map with the specified entries added or updated.\n *\n * @remarks\n * Note that `mapSet` only performs shallow updates to the map. Setting a value to `null`\n * will retain the key with a `null` value. To remove a key entirely, use `mapRemove`.\n *\n * @example\n * ```typescript\n * // Set the 'city' to \"San Francisco\" in the 'address' map\n * field(\"address\").mapSet(\"city\", \"San Francisco\");\n * ```\n *\n * @param key - The key to set. Must be a string or a constant string expression.\n * @param value - The value to set.\n * @param moreKeyValues - Additional key-value pairs to set.\n * @returns A new `Expression` representing the map with the entries set.\n */\n mapSet(\n key: string | Expression,\n value: unknown,\n ...moreKeyValues: unknown[]\n ): FunctionExpression {\n const args = [\n this,\n valueToDefaultExpr(key),\n valueToDefaultExpr(value),\n ...moreKeyValues.map(valueToDefaultExpr)\n ];\n return new FunctionExpression('map_set', args, 'mapSet');\n }\n\n /**\n * @beta\n * Creates an expression that returns the keys of a map.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the keys of the 'address' map\n * field(\"address\").mapKeys();\n * ```\n *\n * @returns A new `Expression` representing the keys of the map.\n */\n mapKeys(): FunctionExpression {\n return new FunctionExpression('map_keys', [this], 'mapKeys');\n }\n\n /**\n * @beta\n * Creates an expression that returns the values of a map.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the values of the 'address' map\n * field(\"address\").mapValues();\n * ```\n *\n * @returns A new `Expression` representing the values of the map.\n */\n mapValues(): FunctionExpression {\n return new FunctionExpression('map_values', [this], 'mapValues');\n }\n\n /**\n * @beta\n * Creates an expression that returns the entries of a map as an array of maps,\n * where each map contains a `\"k\"` property for the key and a `\"v\"` property for the value.\n * For example: `[{ k: \"key1\", v: \"value1\" }, ...]`.\n *\n * @example\n * ```typescript\n * // Get the entries of the 'address' map\n * field(\"address\").mapEntries();\n * ```\n *\n * @returns A new `Expression` representing the entries of the map.\n */\n mapEntries(): FunctionExpression {\n return new FunctionExpression('map_entries', [this], 'mapEntries');\n }\n\n /**\n * @beta\n * Creates an aggregation that counts the number of stage inputs with valid evaluations of the\n * expression or field.\n *\n * @example\n * ```typescript\n * // Count the total number of products\n * field(\"productId\").count().as(\"totalProducts\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'count' aggregation.\n */\n count(): AggregateFunction {\n return AggregateFunction._create('count', [this], 'count');\n }\n\n /**\n * @beta\n * Creates an aggregation that calculates the sum of a numeric field across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Calculate the total revenue from a set of orders\n * field(\"orderAmount\").sum().as(\"totalRevenue\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'sum' aggregation.\n */\n sum(): AggregateFunction {\n return AggregateFunction._create('sum', [this], 'sum');\n }\n\n /**\n * @beta\n * Creates an aggregation that calculates the average (mean) of a numeric field across multiple\n * stage inputs.\n *\n * @example\n * ```typescript\n * // Calculate the average age of users\n * field(\"age\").average().as(\"averageAge\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'average' aggregation.\n */\n average(): AggregateFunction {\n return AggregateFunction._create('average', [this], 'average');\n }\n\n /**\n * @beta\n * Creates an aggregation that finds the minimum value of a field across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the lowest price of all products\n * field(\"price\").minimum().as(\"lowestPrice\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'minimum' aggregation.\n */\n minimum(): AggregateFunction {\n return AggregateFunction._create('minimum', [this], 'minimum');\n }\n\n /**\n * @beta\n * Creates an aggregation that finds the maximum value of a field across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the highest score in a leaderboard\n * field(\"score\").maximum().as(\"highestScore\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'maximum' aggregation.\n */\n maximum(): AggregateFunction {\n return AggregateFunction._create('maximum', [this], 'maximum');\n }\n\n /**\n * @beta\n * Creates an aggregation that finds the first value of an expression across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the first value of the 'rating' field\n * field(\"rating\").first().as(\"firstRating\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'first' aggregation.\n */\n first(): AggregateFunction {\n return AggregateFunction._create('first', [this], 'first');\n }\n\n /**\n * @beta\n * Creates an aggregation that finds the last value of an expression across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the last value of the 'rating' field\n * field(\"rating\").last().as(\"lastRating\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'last' aggregation.\n */\n last(): AggregateFunction {\n return AggregateFunction._create('last', [this], 'last');\n }\n\n /**\n * @beta\n * Creates an aggregation that collects all values of an expression across multiple stage inputs\n * into an array.\n *\n * @remarks\n * If the expression resolves to an absent value, it is converted to `null`.\n * The order of elements in the output array is not stable and shouldn't be relied upon.\n *\n * @example\n * ```typescript\n * // Collect all tags from books into an array\n * field(\"tags\").arrayAgg().as(\"allTags\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'array_agg' aggregation.\n */\n arrayAgg(): AggregateFunction {\n return AggregateFunction._create('array_agg', [this], 'arrayAgg');\n }\n\n /**\n * @beta\n * Creates an aggregation that collects all distinct values of an expression across multiple stage\n * inputs into an array.\n *\n * @remarks\n * If the expression resolves to an absent value, it is converted to `null`.\n * The order of elements in the output array is not stable and shouldn't be relied upon.\n *\n * @example\n * ```typescript\n * // Collect all distinct tags from books into an array\n * field(\"tags\").arrayAggDistinct().as(\"allDistinctTags\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'array_agg_distinct' aggregation.\n */\n arrayAggDistinct(): AggregateFunction {\n return AggregateFunction._create(\n 'array_agg_distinct',\n [this],\n 'arrayAggDistinct'\n );\n }\n\n /**\n * @beta\n * Creates an aggregation that counts the number of distinct values of the expression or field.\n *\n * @example\n * ```typescript\n * // Count the distinct number of products\n * field(\"productId\").countDistinct().as(\"distinctProducts\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'count_distinct' aggregation.\n */\n countDistinct(): AggregateFunction {\n return AggregateFunction._create('count_distinct', [this], 'countDistinct');\n }\n\n /**\n * @beta\n * Creates an expression that returns the larger value between this expression and another expression, based on Firestore's value type ordering.\n *\n * @example\n * ```typescript\n * // Returns the larger value between the 'timestamp' field and the current timestamp.\n * field(\"timestamp\").logicalMaximum(Function.currentTimestamp());\n * ```\n *\n * @param second - The second expression or literal to compare with.\n * @param others - Optional additional expressions or literals to compare with.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical maximum operation.\n */\n logicalMaximum(\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n ): FunctionExpression {\n const values = [second, ...others];\n return new FunctionExpression(\n 'maximum',\n [this, ...values.map(valueToDefaultExpr)],\n 'logicalMaximum'\n );\n }\n\n /**\n * @beta\n * Creates an expression that returns the smaller value between this expression and another expression, based on Firestore's value type ordering.\n *\n * @example\n * ```typescript\n * // Returns the smaller value between the 'timestamp' field and the current timestamp.\n * field(\"timestamp\").logicalMinimum(Function.currentTimestamp());\n * ```\n *\n * @param second - The second expression or literal to compare with.\n * @param others - Optional additional expressions or literals to compare with.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical minimum operation.\n */\n logicalMinimum(\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n ): FunctionExpression {\n const values = [second, ...others];\n return new FunctionExpression(\n 'minimum',\n [this, ...values.map(valueToDefaultExpr)],\n 'minimum'\n );\n }\n\n /**\n * @beta\n * Creates an expression that calculates the length (number of dimensions) of this Firestore Vector expression.\n *\n * @example\n * ```typescript\n * // Get the vector length (dimension) of the field 'embedding'.\n * field(\"embedding\").vectorLength();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the vector.\n */\n vectorLength(): FunctionExpression {\n return new FunctionExpression('vector_length', [this], 'vectorLength');\n }\n\n /**\n * @beta\n * Calculates the cosine distance between two vectors.\n *\n * @example\n * ```typescript\n * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field\n * field(\"userVector\").cosineDistance(field(\"itemVector\"));\n * ```\n *\n * @param vectorExpression - The other vector (represented as an Expression) to compare against.\n * @returns A new `Expression` representing the cosine distance between the two vectors.\n */\n cosineDistance(vectorExpression: Expression): FunctionExpression;\n /**\n * @beta\n * Calculates the Cosine distance between two vectors.\n *\n * @example\n * ```typescript\n * // Calculate the Cosine distance between the 'location' field and a target location\n * field(\"location\").cosineDistance(new VectorValue([37.7749, -122.4194]));\n * ```\n *\n * @param vector - The other vector (as a VectorValue) to compare against.\n * @returns A new `Expression` representing the Cosine* distance between the two vectors.\n */\n cosineDistance(vector: VectorValue | number[]): FunctionExpression;\n cosineDistance(\n other: Expression | VectorValue | number[]\n ): FunctionExpression {\n return new FunctionExpression(\n 'cosine_distance',\n [this, vectorToExpr(other)],\n 'cosineDistance'\n );\n }\n\n /**\n * @beta\n * Calculates the dot product between two vectors.\n *\n * @example\n * ```typescript\n * // Calculate the dot product between a feature vector and a target vector\n * field(\"features\").dotProduct([0.5, 0.8, 0.2]);\n * ```\n *\n * @param vectorExpression - The other vector (as an array of numbers) to calculate with.\n * @returns A new `Expression` representing the dot product between the two vectors.\n */\n dotProduct(vectorExpression: Expression): FunctionExpression;\n\n /**\n * @beta\n * Calculates the dot product between two vectors.\n *\n * @example\n * ```typescript\n * // Calculate the dot product between a feature vector and a target vector\n * field(\"features\").dotProduct(new VectorValue([0.5, 0.8, 0.2]));\n * ```\n *\n * @param vector - The other vector (as an array of numbers) to calculate with.\n * @returns A new `Expression` representing the dot product between the two vectors.\n */\n dotProduct(vector: VectorValue | number[]): FunctionExpression;\n dotProduct(other: Expression | VectorValue | number[]): FunctionExpression {\n return new FunctionExpression(\n 'dot_product',\n [this, vectorToExpr(other)],\n 'dotProduct'\n );\n }\n\n /**\n * @beta\n * Calculates the Euclidean distance between two vectors.\n *\n * @example\n * ```typescript\n * // Calculate the Euclidean distance between the 'location' field and a target location\n * field(\"location\").euclideanDistance([37.7749, -122.4194]);\n * ```\n *\n * @param vectorExpression - The other vector (as an array of numbers) to calculate with.\n * @returns A new `Expression` representing the Euclidean distance between the two vectors.\n */\n euclideanDistance(vectorExpression: Expression): FunctionExpression;\n\n /**\n * @beta\n * Calculates the Euclidean distance between two vectors.\n *\n * @example\n * ```typescript\n * // Calculate the Euclidean distance between the 'location' field and a target location\n * field(\"location\").euclideanDistance(new VectorValue([37.7749, -122.4194]));\n * ```\n *\n * @param vector - The other vector (as a VectorValue) to compare against.\n * @returns A new `Expression` representing the Euclidean distance between the two vectors.\n */\n euclideanDistance(vector: VectorValue | number[]): FunctionExpression;\n euclideanDistance(\n other: Expression | VectorValue | number[]\n ): FunctionExpression {\n return new FunctionExpression(\n 'euclidean_distance',\n [this, vectorToExpr(other)],\n 'euclideanDistance'\n );\n }\n\n /**\n * @beta\n * Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'microseconds' field as microseconds since epoch.\n * field(\"microseconds\").unixMicrosToTimestamp();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\n unixMicrosToTimestamp(): FunctionExpression {\n return new FunctionExpression(\n 'unix_micros_to_timestamp',\n [this],\n 'unixMicrosToTimestamp'\n );\n }\n\n /**\n * @beta\n * Creates an expression that converts this timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to microseconds since epoch.\n * field(\"timestamp\").timestampToUnixMicros();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of microseconds since epoch.\n */\n timestampToUnixMicros(): FunctionExpression {\n return new FunctionExpression(\n 'timestamp_to_unix_micros',\n [this],\n 'timestampToUnixMicros'\n );\n }\n\n /**\n * @beta\n * Creates an expression that interprets this expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'milliseconds' field as milliseconds since epoch.\n * field(\"milliseconds\").unixMillisToTimestamp();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\n unixMillisToTimestamp(): FunctionExpression {\n return new FunctionExpression(\n 'unix_millis_to_timestamp',\n [this],\n 'unixMillisToTimestamp'\n );\n }\n\n /**\n * @beta\n * Creates an expression that converts this timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to milliseconds since epoch.\n * field(\"timestamp\").timestampToUnixMillis();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of milliseconds since epoch.\n */\n timestampToUnixMillis(): FunctionExpression {\n return new FunctionExpression(\n 'timestamp_to_unix_millis',\n [this],\n 'timestampToUnixMillis'\n );\n }\n\n /**\n * @beta\n * Creates an expression that interprets this expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'seconds' field as seconds since epoch.\n * field(\"seconds\").unixSecondsToTimestamp();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\n unixSecondsToTimestamp(): FunctionExpression {\n return new FunctionExpression(\n 'unix_seconds_to_timestamp',\n [this],\n 'unixSecondsToTimestamp'\n );\n }\n\n /**\n * @beta\n * Creates an expression that converts this timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to seconds since epoch.\n * field(\"timestamp\").timestampToUnixSeconds();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of seconds since epoch.\n */\n timestampToUnixSeconds(): FunctionExpression {\n return new FunctionExpression(\n 'timestamp_to_unix_seconds',\n [this],\n 'timestampToUnixSeconds'\n );\n }\n\n /**\n * @beta\n * Creates an expression that adds a specified amount of time to this timestamp expression.\n *\n * @example\n * ```typescript\n * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field.\n * field(\"timestamp\").timestampAdd(field(\"unit\"), field(\"amount\"));\n * ```\n *\n * @param unit - The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'.\n * @param amount - The expression evaluates to amount of the unit.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\n timestampAdd(unit: Expression, amount: Expression): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that adds a specified amount of time to this timestamp expression.\n *\n * @example\n * ```typescript\n * // Add 1 day to the 'timestamp' field.\n * field(\"timestamp\").timestampAdd(\"day\", 1);\n * ```\n *\n * @param unit - The unit of time to add (e.g., \"day\", \"hour\").\n * @param amount - The amount of time to add.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\n timestampAdd(\n unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day',\n amount: number\n ): FunctionExpression;\n timestampAdd(\n unit:\n | Expression\n | 'microsecond'\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day',\n amount: Expression | number\n ): FunctionExpression {\n return new FunctionExpression(\n 'timestamp_add',\n [this, valueToDefaultExpr(unit), valueToDefaultExpr(amount)],\n 'timestampAdd'\n );\n }\n\n /**\n * @beta\n * Creates an expression that subtracts a specified amount of time from this timestamp expression.\n *\n * @example\n * ```typescript\n * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field.\n * field(\"timestamp\").timestampSubtract(field(\"unit\"), field(\"amount\"));\n * ```\n *\n * @param unit - The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'.\n * @param amount - The expression evaluates to amount of the unit.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\n timestampSubtract(unit: Expression, amount: Expression): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that subtracts a specified amount of time from this timestamp expression.\n *\n * @example\n * ```typescript\n * // Subtract 1 day from the 'timestamp' field.\n * field(\"timestamp\").timestampSubtract(\"day\", 1);\n * ```\n *\n * @param unit - The unit of time to subtract (e.g., \"day\", \"hour\").\n * @param amount - The amount of time to subtract.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\n timestampSubtract(\n unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day',\n amount: number\n ): FunctionExpression;\n timestampSubtract(\n unit:\n | Expression\n | 'microsecond'\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day',\n amount: Expression | number\n ): FunctionExpression {\n return new FunctionExpression(\n 'timestamp_subtract',\n [this, valueToDefaultExpr(unit), valueToDefaultExpr(amount)],\n 'timestampSubtract'\n );\n }\n\n /**\n * @beta\n *\n * Creates an expression that returns the document ID from a path.\n *\n * @example\n * ```typescript\n * // Get the document ID from a path.\n * field(\"__path__\").documentId();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the documentId operation.\n */\n documentId(): FunctionExpression {\n return new FunctionExpression('document_id', [this], 'documentId');\n }\n\n /**\n * @beta\n *\n * Creates an expression that returns a substring of the results of this expression.\n *\n * @param position - Index of the first character of the substring.\n * @param length - Length of the substring. If not provided, the substring will\n * end at the end of the input.\n */\n substring(position: number, length?: number): FunctionExpression;\n\n /**\n * @beta\n *\n * Creates an expression that returns a substring of the results of this expression.\n *\n * @param position - An expression returning the index of the first character of the substring.\n * @param length - An expression returning the length of the substring. If not provided the\n * substring will end at the end of the input.\n */\n substring(position: Expression, length?: Expression): FunctionExpression;\n substring(\n position: Expression | number,\n length?: Expression | number\n ): FunctionExpression {\n const positionExpr = valueToDefaultExpr(position);\n if (length === undefined) {\n return new FunctionExpression(\n 'substring',\n [this, positionExpr],\n 'substring'\n );\n } else {\n return new FunctionExpression(\n 'substring',\n [this, positionExpr, valueToDefaultExpr(length)],\n 'substring'\n );\n }\n }\n\n /**\n * @beta\n * Creates an expression that indexes into an array from the beginning or end\n * and returns the element. If the offset exceeds the array length, an error is\n * returned. A negative offset, starts from the end.\n *\n * @example\n * ```typescript\n * // Return the value in the 'tags' field array at index `1`.\n * field('tags').arrayGet(1);\n * ```\n *\n * @param offset - The index of the element to return.\n * @returns A new `Expression` representing the 'arrayGet' operation.\n */\n arrayGet(offset: number): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that indexes into an array from the beginning or end\n * and returns the element. If the offset exceeds the array length, an error is\n * returned. A negative offset, starts from the end.\n *\n * @example\n * ```typescript\n * // Return the value in the tags field array at index specified by field\n * // 'favoriteTag'.\n * field('tags').arrayGet(field('favoriteTag'));\n * ```\n *\n * @param offsetExpr - An `Expression` evaluating to the index of the element to return.\n * @returns A new `Expression` representing the 'arrayGet' operation.\n */\n arrayGet(offsetExpr: Expression): FunctionExpression;\n arrayGet(offset: Expression | number): FunctionExpression {\n return new FunctionExpression(\n 'array_get',\n [this, valueToDefaultExpr(offset)],\n 'arrayGet'\n );\n }\n\n /**\n * @beta\n *\n * Creates an expression that checks if a given expression produces an error.\n *\n * @example\n * ```typescript\n * // Check if the result of a calculation is an error\n * field(\"title\").arrayContains(1).isError();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#BooleanExpression} representing the 'isError' check.\n */\n isError(): BooleanExpression {\n return new FunctionExpression('is_error', [this], 'isError').asBoolean();\n }\n\n /**\n * @beta\n *\n * Creates an expression that returns the result of the `catchExpr` argument\n * if there is an error, else return the result of this expression.\n *\n * @example\n * ```typescript\n * // Returns the first item in the title field arrays, or returns\n * // the entire title field if the array is empty or the field is another type.\n * field(\"title\").arrayGet(0).ifError(field(\"title\"));\n * ```\n *\n * @param catchExpr - The catch expression that will be evaluated and\n * returned if this expression produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\n ifError(catchExpr: Expression): FunctionExpression;\n\n /**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of this expression.\n *\n * @example\n * ```typescript\n * // Returns the first item in the title field arrays, or returns\n * // \"Default Title\"\n * field(\"title\").arrayGet(0).ifError(\"Default Title\");\n * ```\n *\n * @param catchValue - The value that will be returned if this expression\n * produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\n ifError(catchValue: unknown): FunctionExpression;\n ifError(catchValue: unknown): FunctionExpression | BooleanExpression {\n const result = new FunctionExpression(\n 'if_error',\n [this, valueToDefaultExpr(catchValue)],\n 'ifError'\n );\n\n return catchValue instanceof BooleanExpression\n ? result.asBoolean()\n : result;\n }\n\n /**\n * @beta\n *\n * Creates an expression that returns `true` if the result of this expression\n * is absent. Otherwise, returns `false` even if the value is `null`.\n *\n * @example\n * ```typescript\n * // Check if the field `value` is absent.\n * field(\"value\").isAbsent();\n * @example\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#BooleanExpression} representing the 'isAbsent' check.\n */\n isAbsent(): BooleanExpression {\n return new FunctionExpression('is_absent', [this], 'isAbsent').asBoolean();\n }\n\n /**\n * @beta\n *\n * Creates an expression that removes a key from the map produced by evaluating this expression.\n *\n * @example\n * ```\n * // Removes the key 'baz' from the input map.\n * map({foo: 'bar', baz: true}).mapRemove('baz');\n * ```\n *\n * @param key - The name of the key to remove from the input map.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'mapRemove' operation.\n */\n mapRemove(key: string): FunctionExpression;\n /**\n * @beta\n *\n * Creates an expression that removes a key from the map produced by evaluating this expression.\n *\n * @example\n * ```\n * // Removes the key 'baz' from the input map.\n * map({foo: 'bar', baz: true}).mapRemove(constant('baz'));\n * @example\n * ```\n *\n * @param keyExpr - An expression that produces the name of the key to remove from the input map.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'mapRemove' operation.\n */\n mapRemove(keyExpr: Expression): FunctionExpression;\n mapRemove(stringExpr: Expression | string): FunctionExpression {\n return new FunctionExpression(\n 'map_remove',\n [this, valueToDefaultExpr(stringExpr)],\n 'mapRemove'\n );\n }\n\n /**\n * @beta\n *\n * Creates an expression that merges multiple map values.\n *\n * @example\n * ```\n * // Merges the map in the settings field with, a map literal, and a map in\n * // that is conditionally returned by another expression\n * field('settings').mapMerge({ enabled: true }, conditional(field('isAdmin'), { admin: true}, {})\n * ```\n *\n * @param secondMap - A required second map to merge. Represented as a literal or\n * an expression that returns a map.\n * @param otherMaps - Optional additional maps to merge. Each map is represented\n * as a literal or an expression that returns a map.\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'mapMerge' operation.\n */\n mapMerge(\n secondMap: Record<string, unknown> | Expression,\n ...otherMaps: Array<Record<string, unknown> | Expression>\n ): FunctionExpression {\n const secondMapExpr = valueToDefaultExpr(secondMap);\n const otherMapExprs = otherMaps.map(valueToDefaultExpr);\n return new FunctionExpression(\n 'map_merge',\n [this, secondMapExpr, ...otherMapExprs],\n 'mapMerge'\n );\n }\n\n /**\n * @beta\n * Creates an expression that returns the value of this expression raised to the power of another expression.\n *\n * @example\n * ```typescript\n * // Raise the value of the 'base' field to the power of the 'exponent' field.\n * field(\"base\").pow(field(\"exponent\"));\n * ```\n *\n * @param exponent - The expression to raise this expression to the power of.\n * @returns A new `Expression` representing the power operation.\n */\n pow(exponent: Expression): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that returns the value of this expression raised to the power of a constant value.\n *\n * @example\n * ```typescript\n * // Raise the value of the 'base' field to the power of 2.\n * field(\"base\").pow(2);\n * ```\n *\n * @param exponent - The constant value to raise this expression to the power of.\n * @returns A new `Expression` representing the power operation.\n */\n pow(exponent: number): FunctionExpression;\n pow(exponent: number | Expression): FunctionExpression {\n return new FunctionExpression('pow', [this, valueToDefaultExpr(exponent)]);\n }\n\n /**\n * @beta\n * Creates an expression that truncates the numeric value to an integer.\n *\n * @example\n * ```typescript\n * // Truncate the 'rating' field\n * field(\"rating\").trunc();\n * ```\n *\n * @returns A new `Expression` representing the truncated value.\n */\n trunc(): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that truncates a numeric value to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Truncate the value of the 'rating' field to two decimal places.\n * field(\"rating\").trunc(2);\n * ```\n *\n * @param decimalPlaces - A constant specifying the truncation precision in decimal places.\n * @returns A new `Expression` representing the truncated value.\n */\n trunc(decimalPlaces: number): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that truncates a numeric value to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Truncate the value of the 'rating' field to two decimal places.\n * field(\"rating\").trunc(constant(2));\n * ```\n *\n * @param decimalPlaces - An expression specifying the truncation precision in decimal places.\n * @returns A new `Expression` representing the truncated value.\n */\n trunc(decimalPlaces: Expression): FunctionExpression;\n trunc(decimalPlaces?: number | Expression): FunctionExpression {\n if (decimalPlaces === undefined) {\n return new FunctionExpression('trunc', [this]);\n } else {\n return new FunctionExpression(\n 'trunc',\n [this, valueToDefaultExpr(decimalPlaces)],\n 'trunc'\n );\n }\n }\n\n /**\n * @beta\n * Creates an expression that rounds a numeric value to the nearest whole number.\n *\n * @example\n * ```typescript\n * // Round the value of the 'price' field.\n * field(\"price\").round();\n * ```\n *\n * @returns A new `Expression` representing the rounded value.\n */\n round(): FunctionExpression;\n /**\n * @beta\n * Creates an expression that rounds a numeric value to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Round the value of the 'price' field to two decimal places.\n * field(\"price\").round(2);\n * ```\n *\n * @param decimalPlaces - A constant specifying the rounding precision in decimal places.\n *\n * @returns A new `Expression` representing the rounded value.\n */\n round(decimalPlaces: number): FunctionExpression;\n /**\n * @beta\n * Creates an expression that rounds a numeric value to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Round the value of the 'price' field to two decimal places.\n * field(\"price\").round(constant(2));\n * ```\n *\n * @param decimalPlaces - An expression specifying the rounding precision in decimal places.\n *\n * @returns A new `Expression` representing the rounded value.\n */\n round(decimalPlaces: Expression): FunctionExpression;\n round(decimalPlaces?: number | Expression): FunctionExpression {\n if (decimalPlaces === undefined) {\n return new FunctionExpression('round', [this]);\n } else {\n return new FunctionExpression(\n 'round',\n [this, valueToDefaultExpr(decimalPlaces)],\n 'round'\n );\n }\n }\n\n /**\n * @beta\n * Creates an expression that returns the collection ID from a path.\n *\n * @example\n * ```typescript\n * // Get the collection ID from a path.\n * field(\"__path__\").collectionId();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the collectionId operation.\n */\n collectionId(): FunctionExpression {\n return new FunctionExpression('collection_id', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that calculates the length of a string, array, map, vector, or bytes.\n *\n * @example\n * ```typescript\n * // Get the length of the 'name' field.\n * field(\"name\").length();\n *\n * // Get the number of items in the 'cart' array.\n * field(\"cart\").length();\n * ```\n *\n * @returns A new `Expression` representing the length of the string, array, map, vector, or bytes.\n */\n length(): FunctionExpression {\n return new FunctionExpression('length', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that computes the natural logarithm of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the natural logarithm of the 'value' field.\n * field(\"value\").ln();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the natural logarithm of the numeric value.\n */\n ln(): FunctionExpression {\n return new FunctionExpression('ln', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that computes the square root of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the square root of the 'value' field.\n * field(\"value\").sqrt();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the square root of the numeric value.\n */\n sqrt(): FunctionExpression {\n return new FunctionExpression('sqrt', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that reverses a string.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myString' field.\n * field(\"myString\").stringReverse();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed string.\n */\n stringReverse(): FunctionExpression {\n return new FunctionExpression('string_reverse', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that returns the `elseValue` argument if this expression results in an absent value, else\n * return the result of the this expression evaluation.\n *\n * @example\n * ```typescript\n * // Returns the value of the optional field 'optional_field', or returns 'default_value'\n * // if the field is absent.\n * field(\"optional_field\").ifAbsent(\"default_value\")\n * ```\n *\n * @param elseValue - The value that will be returned if this Expression evaluates to an absent value.\n * @returns A new [Expression] representing the ifAbsent operation.\n */\n ifAbsent(elseValue: unknown): Expression;\n\n /**\n * @beta\n * Creates an expression that returns the `elseValue` argument if this expression results in an absent value, else\n * return the result of this expression evaluation.\n *\n * ```typescript\n * // Returns the value of the optional field 'optional_field', or if that is\n * // absent, then returns the value of the field `\n * field(\"optional_field\").ifAbsent(field('default_field'))\n * ```\n *\n * @param elseExpression - The Expression that will be evaluated if this Expression evaluates to an absent value.\n * @returns A new [Expression] representing the ifAbsent operation.\n */\n ifAbsent(elseExpression: unknown): Expression;\n\n ifAbsent(elseValueOrExpression: Expression | unknown): Expression {\n return new FunctionExpression(\n 'if_absent',\n [this, valueToDefaultExpr(elseValueOrExpression)],\n 'ifAbsent'\n );\n }\n\n /**\n * @beta\n * Creates an expression that joins the elements of an array into a string.\n *\n * @example\n * ```typescript\n * // Join the elements of the 'tags' field with the delimiter from the 'separator' field.\n * field(\"tags\").join(field(\"separator\"))\n * ```\n *\n * @param delimiterExpression - The expression that evaluates to the delimiter string.\n * @returns A new Expression representing the join operation.\n */\n join(delimiterExpression: Expression): Expression;\n\n /**\n * @beta\n * Creates an expression that joins the elements of an array field into a string.\n *\n * @example\n * ```typescript\n * // Join the elements of the 'tags' field with a comma and space.\n * field(\"tags\").join(\", \")\n * ```\n *\n * @param delimiter - The string to use as a delimiter.\n * @returns A new Expression representing the join operation.\n */\n join(delimiter: string): Expression;\n\n join(delimeterValueOrExpression: string | Expression): Expression {\n return new FunctionExpression(\n 'join',\n [this, valueToDefaultExpr(delimeterValueOrExpression)],\n 'join'\n );\n }\n\n /**\n * @beta\n * Creates an expression that computes the base-10 logarithm of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the base-10 logarithm of the 'value' field.\n * field(\"value\").log10();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the base-10 logarithm of the numeric value.\n */\n log10(): FunctionExpression {\n return new FunctionExpression('log10', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that computes the sum of the elements in an array.\n *\n * @example\n * ```typescript\n * // Compute the sum of the elements in the 'scores' field.\n * field(\"scores\").arraySum();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the sum of the elements in the array.\n */\n arraySum(): FunctionExpression {\n return new FunctionExpression('sum', [this]);\n }\n\n /**\n * @beta\n * Creates an expression that splits the result of this expression into an\n * array of substrings based on the provided delimiter.\n *\n * @example\n * ```typescript\n * // Split the 'scoresCsv' field on delimiter ','\n * field('scoresCsv').split(',')\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the split function.\n */\n split(delimiter: string): FunctionExpression;\n\n /**\n * @beta\n * Creates an expression that splits the result of this expression into an\n * array of substrings based on the provided delimiter.\n *\n * @example\n * ```typescript\n * // Split the 'scores' field on delimiter ',' or ':' depending on the stored format\n * field('scores').split(conditional(field('format').equal('csv'), constant(','), constant(':'))\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the split function.\n */\n split(delimiter: Expression): FunctionExpression;\n split(delimiter: string | Expression): FunctionExpression {\n return new FunctionExpression('split', [\n this,\n valueToDefaultExpr(delimiter)\n ]);\n }\n\n /**\n * Creates an expression that truncates a timestamp to a specified granularity.\n *\n * @example\n * ```typescript\n * // Truncate the 'createdAt' timestamp to the beginning of the day.\n * field('createdAt').timestampTruncate('day')\n * ```\n *\n * @param granularity - The granularity to truncate to.\n * @param timezone - The timezone to use for truncation. Valid values are from\n * the TZ database (e.g., \"America/Los_Angeles\") or in the format \"Etc/GMT-1\".\n * @returns A new `Expression` representing the truncated timestamp.\n */\n timestampTruncate(\n granularity: TimeGranularity,\n timezone?: string | Expression\n ): FunctionExpression;\n\n /**\n * Creates an expression that truncates a timestamp to a specified granularity.\n *\n * @example\n * ```typescript\n * // Truncate the 'createdAt' timestamp to the granularity specified in the field 'granularity'.\n * field('createdAt').timestampTruncate(field('granularity'))\n * ```\n *\n * @param granularity - The granularity to truncate to.\n * @param timezone - The timezone to use for truncation. Valid values are from\n * the TZ database (e.g., \"America/Los_Angeles\") or in the format \"Etc/GMT-1\".\n * @returns A new `Expression` representing the truncated timestamp.\n */\n timestampTruncate(\n granularity: Expression,\n timezone?: string | Expression\n ): FunctionExpression;\n timestampTruncate(\n granularity: TimeGranularity | Expression,\n timezone?: string | Expression\n ): FunctionExpression {\n const internalGranularity = isString(granularity)\n ? granularity.toLowerCase()\n : granularity;\n\n const args = [this, valueToDefaultExpr(internalGranularity)];\n if (timezone) {\n args.push(valueToDefaultExpr(timezone));\n }\n return new FunctionExpression('timestamp_trunc', args);\n }\n\n // TODO(new-expression): Add new expression method definitions above this line\n\n /**\n * @beta\n * Creates an {@link @firebase/firestore/pipelines#Ordering} that sorts documents in ascending order based on this expression.\n *\n * @example\n * ```typescript\n * // Sort documents by the 'name' field in ascending order\n * pipeline().collection(\"users\")\n * .sort(field(\"name\").ascending());\n * ```\n *\n * @returns A new `Ordering` for ascending sorting.\n */\n ascending(): Ordering {\n return ascending(this);\n }\n\n /**\n * @beta\n * Creates an {@link @firebase/firestore/pipelines#Ordering} that sorts documents in descending order based on this expression.\n *\n * @example\n * ```typescript\n * // Sort documents by the 'createdAt' field in descending order\n * firestore.pipeline().collection(\"users\")\n * .sort(field(\"createdAt\").descending());\n * ```\n *\n * @returns A new `Ordering` for descending sorting.\n */\n descending(): Ordering {\n return descending(this);\n }\n\n /**\n * @beta\n * Assigns an alias to this expression.\n *\n * Aliases are useful for renaming fields in the output of a stage or for giving meaningful\n * names to calculated values.\n *\n * @example\n * ```typescript\n * // Calculate the total price and assign it the alias \"totalPrice\" and add it to the output.\n * firestore.pipeline().collection(\"items\")\n * .addFields(field(\"price\").multiply(field(\"quantity\")).as(\"totalPrice\"));\n * ```\n *\n * @param name - The alias to assign to this expression.\n * @returns A new {@link @firebase/firestore/pipelines#AliasedExpression} that wraps this\n * expression and associates it with the provided alias.\n */\n as(name: string): AliasedExpression {\n return new AliasedExpression(this, name, 'as');\n }\n}\n\n/**\n * @beta\n * Specify time granularity for expressions.\n */\nexport type TimeGranularity =\n | 'microsecond'\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day'\n | 'week'\n | 'week(monday)'\n | 'week(tuesday)'\n | 'week(wednesday)'\n | 'week(thursday)'\n | 'week(friday)'\n | 'week(saturday)'\n | 'week(sunday)'\n | 'isoWeek'\n | 'month'\n | 'quarter'\n | 'year'\n | 'isoYear';\n\n/**\n * @beta\n *\n * An interface that represents a selectable expression.\n */\nexport interface Selectable {\n selectable: true;\n /**\n * @private\n * @internal\n */\n readonly alias: string;\n /**\n * @private\n * @internal\n */\n readonly expr: Expression;\n}\n\n/**\n * @beta\n *\n * A class that represents an aggregate function.\n */\nexport class AggregateFunction implements ProtoValueSerializable, UserData {\n exprType: ExpressionType = 'AggregateFunction';\n\n /**\n * @internal\n */\n _methodName?: string;\n\n constructor(private name: string, private params: Expression[]) {}\n\n /**\n * @internal\n * @private\n */\n static _create(\n name: string,\n params: Expression[],\n methodName: string\n ): AggregateFunction {\n const af = new AggregateFunction(name, params);\n af._methodName = methodName;\n\n return af;\n }\n\n /**\n * @beta\n * Assigns an alias to this AggregateFunction. The alias specifies the name that\n * the aggregated value will have in the output document.\n *\n * @example\n * ```typescript\n * // Calculate the average price of all items and assign it the alias \"averagePrice\".\n * firestore.pipeline().collection(\"items\")\n * .aggregate(field(\"price\").average().as(\"averagePrice\"));\n * ```\n *\n * @param name - The alias to assign to this AggregateFunction.\n * @returns A new {@link @firebase/firestore/pipelines#AliasedAggregate} that wraps this\n * AggregateFunction and associates it with the provided alias.\n */\n as(name: string): AliasedAggregate {\n return new AliasedAggregate(this, name, 'as');\n }\n\n /**\n * @private\n * @internal\n */\n _toProto(serializer: JsonProtoSerializer): ProtoValue {\n return {\n functionValue: {\n name: this.name,\n args: this.params.map(p => p._toProto(serializer))\n }\n };\n }\n\n _protoValueType = 'ProtoValue' as const;\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n context = this._methodName\n ? context.contextWith({ methodName: this._methodName })\n : context;\n this.params.forEach(expr => {\n return expr._readUserData(context);\n });\n }\n}\n\n/**\n * @beta\n *\n * An AggregateFunction with alias.\n */\nexport class AliasedAggregate implements UserData {\n constructor(\n readonly aggregate: AggregateFunction,\n readonly alias: string,\n readonly _methodName: string | undefined\n ) {}\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n this.aggregate._readUserData(context);\n }\n}\n\n/**\n * @beta\n */\nexport class AliasedExpression implements Selectable, UserData {\n exprType: ExpressionType = 'AliasedExpression';\n selectable = true as const;\n\n constructor(\n readonly expr: Expression,\n readonly alias: string,\n readonly _methodName: string | undefined\n ) {}\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n this.expr._readUserData(context);\n }\n}\n\n/**\n * @internal\n */\nclass ListOfExprs extends Expression implements UserData {\n expressionType: ExpressionType = 'ListOfExpressions';\n\n constructor(\n private exprs: Expression[],\n readonly _methodName: string | undefined\n ) {\n super();\n }\n\n /**\n * @private\n * @internal\n */\n _toProto(serializer: JsonProtoSerializer): ProtoValue {\n return {\n arrayValue: {\n values: this.exprs.map(p => p._toProto(serializer)!)\n }\n };\n }\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n this.exprs.forEach((expr: Expression) => expr._readUserData(context));\n }\n}\n\n/**\n * @beta\n *\n * Represents a reference to a field in a Firestore document, or outputs of a {@link @firebase/firestore/pipelines#Pipeline} stage.\n *\n * <p>Field references are used to access document field values in expressions and to specify fields\n * for sorting, filtering, and projecting data in Firestore pipelines.\n *\n * <p>You can create a `Field` instance using the static {@link @firebase/firestore/pipelines#field} method:\n *\n * @example\n * ```typescript\n * // Create a Field instance for the 'name' field\n * const nameField = field(\"name\");\n *\n * // Create a Field instance for a nested field 'address.city'\n * const cityField = field(\"address.city\");\n * ```\n */\nexport class Field extends Expression implements Selectable {\n readonly expressionType: ExpressionType = 'Field';\n selectable = true as const;\n\n /**\n * @internal\n * @private\n * @hideconstructor\n * @param fieldPath\n */\n constructor(\n private fieldPath: InternalFieldPath,\n readonly _methodName: string | undefined\n ) {\n super();\n }\n\n get fieldName(): string {\n return this.fieldPath.canonicalString();\n }\n\n get alias(): string {\n return this.fieldName;\n }\n\n get expr(): Expression {\n return this;\n }\n\n /**\n * @private\n * @internal\n */\n _toProto(serializer: JsonProtoSerializer): ProtoValue {\n return {\n fieldReferenceValue: this.fieldPath.canonicalString()\n };\n }\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {}\n}\n\n/**\n * @beta\n * Creates a {@link @firebase/firestore/pipelines#Field} instance representing the field at the given path.\n *\n * The path can be a simple field name (e.g., \"name\") or a dot-separated path to a nested field\n * (e.g., \"address.city\").\n *\n * @example\n * ```typescript\n * // Create a Field instance for the 'title' field\n * const titleField = field(\"title\");\n *\n * // Create a Field instance for a nested field 'author.firstName'\n * const authorFirstNameField = field(\"author.firstName\");\n * ```\n *\n * @param name - The path to the field.\n * @returns A new {@link @firebase/firestore/pipelines#Field} instance representing the specified field.\n */\nexport function field(name: string): Field;\n\n/**\n * @beta\n * Creates a {@link @firebase/firestore/pipelines#Field} instance representing the field at the given path.\n *\n * @param path - A FieldPath specifying the field.\n * @returns A new {@link @firebase/firestore/pipelines#Field} instance representing the specified field.\n */\nexport function field(path: FieldPath): Field;\nexport function field(nameOrPath: string | FieldPath): Field {\n return _field(nameOrPath, 'field');\n}\n\nexport function _field(\n nameOrPath: string | FieldPath,\n methodName: string | undefined\n): Field {\n if (typeof nameOrPath === 'string') {\n if (DOCUMENT_KEY_NAME === nameOrPath) {\n return new Field(documentIdFieldPath()._internalPath, methodName);\n }\n return new Field(fieldPathFromArgument('field', nameOrPath), methodName);\n } else {\n return new Field(nameOrPath._internalPath, methodName);\n }\n}\n\n/**\n * @internal\n *\n * Represents a constant value that can be used in a Firestore pipeline expression.\n *\n * You can create a `Constant` instance using the static {@link @firebase/firestore/pipelines#field} method:\n *\n * @example\n * ```typescript\n * // Create a Constant instance for the number 10\n * const ten = constant(10);\n *\n * // Create a Constant instance for the string \"hello\"\n * const hello = constant(\"hello\");\n * ```\n */\nexport class Constant extends Expression {\n readonly expressionType: ExpressionType = 'Constant';\n\n private _protoValue?: ProtoValue;\n\n /**\n * @private\n * @internal\n * @hideconstructor\n * @param value - The value of the constant.\n */\n constructor(\n private value: unknown,\n readonly _methodName: string | undefined\n ) {\n super();\n }\n\n /**\n * @private\n * @internal\n */\n static _fromProto(value: ProtoValue): Constant {\n const result = new Constant(value, undefined);\n result._protoValue = value;\n return result;\n }\n\n /**\n * @private\n * @internal\n */\n _toProto(_: JsonProtoSerializer): ProtoValue {\n hardAssert(\n this._protoValue !== undefined,\n 0x00ed,\n 'Value of this constant has not been serialized to proto value'\n );\n return this._protoValue;\n }\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n context = this._methodName\n ? context.contextWith({ methodName: this._methodName })\n : context;\n if (isFirestoreValue(this._protoValue)) {\n return;\n } else {\n this._protoValue = parseData(this.value, context)!;\n }\n }\n}\n\n/**\n * @beta\n * Creates a `Constant` instance for a number value.\n *\n * @param value - The number value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: number): Expression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a string value.\n *\n * @param value - The string value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: string): Expression;\n\n/**\n * @beta\n * Creates a `BooleanExpression` instance for a boolean value.\n *\n * @param value - The boolean value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: boolean): BooleanExpression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a null value.\n *\n * @param value - The null value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: null): Expression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a GeoPoint value.\n *\n * @param value - The GeoPoint value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: GeoPoint): Expression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a Timestamp value.\n *\n * @param value - The Timestamp value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: Timestamp): Expression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a Date value.\n *\n * @param value - The Date value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: Date): Expression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a Bytes value.\n *\n * @param value - The Bytes value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: Bytes): Expression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a DocumentReference value.\n *\n * @param value - The DocumentReference value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: DocumentReference): Expression;\n\n/**\n * Creates a `Constant` instance for a Firestore proto value.\n * For internal use only.\n * @private\n * @internal\n * @param value - The Firestore proto value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: ProtoValue): Expression;\n\n/**\n * @beta\n * Creates a `Constant` instance for a VectorValue value.\n *\n * @param value - The VectorValue value.\n * @returns A new `Constant` instance.\n */\nexport function constant(value: VectorValue): Expression;\n\nexport function constant(value: unknown): Expression | BooleanExpression {\n return _constant(value, 'constant');\n}\n\n/**\n * @internal\n * @private\n * @param value\n * @param methodName\n */\nexport function _constant(\n value: unknown,\n methodName: string | undefined\n): Constant | BooleanExpression {\n const c = new Constant(value, methodName);\n if (typeof value === 'boolean') {\n return new BooleanConstant(c);\n } else {\n return c;\n }\n}\n\n/**\n * Internal only\n * @internal\n * @private\n */\nexport class MapValue extends Expression {\n constructor(\n private plainObject: Map<string, Expression>,\n readonly _methodName: string | undefined\n ) {\n super();\n }\n\n expressionType: ExpressionType = 'Constant';\n\n _readUserData(context: ParseContext): void {\n context = this._methodName\n ? context.contextWith({ methodName: this._methodName })\n : context;\n this.plainObject.forEach(expr => {\n expr._readUserData(context);\n });\n }\n\n _toProto(serializer: JsonProtoSerializer): ProtoValue {\n return toMapValue(serializer, this.plainObject);\n }\n}\n\n/**\n * @beta\n *\n * This class defines the base class for Firestore {@link @firebase/firestore/pipelines#Pipeline} functions, which can be evaluated within pipeline\n * execution.\n *\n * Typically, you would not use this class or its children directly. Use either the functions like {@link @firebase/firestore/pipelines#and}, {@link @firebase/firestore/pipelines#(equal:1)},\n * or the methods on {@link @firebase/firestore/pipelines#Expression} ({@link @firebase/firestore/pipelines#Expression.(equal:1)}, {@link @firebase/firestore/pipelines#Expression.(lessThan:1)}, etc.) to construct new Function instances.\n */\nexport class FunctionExpression extends Expression {\n readonly expressionType: ExpressionType = 'Function';\n\n constructor(name: string, params: Expression[]);\n constructor(\n name: string,\n params: Expression[],\n _methodName: string | undefined\n );\n constructor(\n private name: string,\n private params: Expression[],\n readonly _methodName?: string\n ) {\n super();\n }\n\n /**\n * @private\n * @internal\n */\n _toProto(serializer: JsonProtoSerializer): ProtoValue {\n return {\n functionValue: {\n name: this.name,\n args: this.params.map(p => p._toProto(serializer))\n }\n };\n }\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n context = this._methodName\n ? context.contextWith({ methodName: this._methodName })\n : context;\n this.params.forEach(expr => {\n return expr._readUserData(context);\n });\n }\n}\n\n/**\n * @beta\n *\n * An interface that represents a filter condition.\n */\nexport abstract class BooleanExpression extends Expression {\n abstract get _expr(): Expression;\n\n get _methodName(): string | undefined {\n return this._expr._methodName;\n }\n\n /**\n * @beta\n * Creates an aggregation that finds the count of input documents satisfying\n * this boolean expression.\n *\n * @example\n * ```typescript\n * // Find the count of documents with a score greater than 90\n * field(\"score\").greaterThan(90).countIf().as(\"highestScore\");\n * ```\n *\n * @returns A new `AggregateFunction` representing the 'countIf' aggregation.\n */\n countIf(): AggregateFunction {\n return AggregateFunction._create('count_if', [this], 'countIf');\n }\n\n /**\n * @beta\n * Creates an expression that negates this boolean expression.\n *\n * @example\n * ```typescript\n * // Find documents where the 'tags' field does not contain 'completed'\n * field(\"tags\").arrayContains(\"completed\").not();\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the negated filter condition.\n */\n not(): BooleanExpression {\n return new FunctionExpression('not', [this], 'not').asBoolean();\n }\n\n /**\n * @beta\n * Creates a conditional expression that evaluates to the 'then' expression\n * if `this` expression evaluates to `true`,\n * or evaluates to the 'else' expression if `this` expressions evaluates `false`.\n *\n * @example\n * ```typescript\n * // If 'age' is greater than 18, return \"Adult\"; otherwise, return \"Minor\".\n * field(\"age\").greaterThanOrEqual(18).conditional(constant(\"Adult\"), constant(\"Minor\"));\n * ```\n *\n * @param thenExpr - The expression to evaluate if the condition is true.\n * @param elseExpr - The expression to evaluate if the condition is false.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the conditional expression.\n */\n conditional(thenExpr: Expression, elseExpr: Expression): FunctionExpression {\n return new FunctionExpression(\n 'conditional',\n [this, thenExpr, elseExpr],\n 'conditional'\n );\n }\n\n /**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of this expression.\n *\n * @example\n * ```typescript\n * // Create an expression that protects against a divide by zero error\n * // but always returns a boolean expression.\n * constant(50).divide('length').gt(1).ifError(constant(false));\n * ```\n *\n * @param catchValue - The value that will be returned if this expression\n * produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\n ifError(catchValue: BooleanExpression): BooleanExpression;\n\n /**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of this expression.\n *\n * @example\n * ```typescript\n * // Create an expression that protects against a divide by zero error\n * // but always returns a boolean expression.\n * constant(50).divide('length').gt(1).ifError(false);\n * ```\n *\n * @param catchValue - The value that will be returned if this expression\n * produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\n ifError(catchValue: boolean): BooleanExpression;\n\n /**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of this expression.\n *\n * @example\n * ```typescript\n * // Create an expression that protects against a divide by zero error.\n * constant(50).divide('length').gt(1).ifError(constant(0));\n * ```\n *\n * @param catchValue - The value that will be returned if this expression\n * produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\n ifError(catchValue: Expression): FunctionExpression;\n\n /**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of this expression.\n *\n * @example\n * ```typescript\n * // Create an expression that protects against a divide by zero error.\n * constant(50).divide('length').gt(1).ifError(0);\n * ```\n *\n * @param catchValue - The value that will be returned if this expression\n * produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\n ifError(catchValue: unknown): FunctionExpression;\n ifError(catchValue: unknown): unknown {\n const normalizedCatchValue = valueToDefaultExpr(catchValue);\n const expr = new FunctionExpression(\n 'if_error',\n [this, normalizedCatchValue],\n 'ifError'\n );\n\n return normalizedCatchValue instanceof BooleanExpression\n ? expr.asBoolean()\n : expr;\n }\n\n /**\n * @private\n * @internal\n */\n _toProto(serializer: JsonProtoSerializer): ProtoValue {\n return this._expr._toProto(serializer);\n }\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n this._expr._readUserData(context);\n }\n}\n\nexport class BooleanFunctionExpression extends BooleanExpression {\n readonly expressionType: ExpressionType = 'Function';\n constructor(readonly _expr: FunctionExpression) {\n super();\n }\n}\n\nexport class BooleanConstant extends BooleanExpression {\n readonly expressionType: ExpressionType = 'Constant';\n constructor(readonly _expr: Constant) {\n super();\n }\n}\n\nexport class BooleanField extends BooleanExpression {\n readonly expressionType: ExpressionType = 'Field';\n constructor(readonly _expr: Field) {\n super();\n }\n}\n\n/**\n * @beta\n * Creates an aggregation that counts the number of stage inputs where the provided\n * boolean expression evaluates to true.\n *\n * @example\n * ```typescript\n * // Count the number of documents where 'is_active' field equals true\n * countIf(field(\"is_active\").equal(true)).as(\"numActiveDocuments\");\n * ```\n *\n * @param booleanExpr - The boolean expression to evaluate on each input.\n * @returns A new `AggregateFunction` representing the 'countIf' aggregation.\n */\nexport function countIf(booleanExpr: BooleanExpression): AggregateFunction {\n return booleanExpr.countIf();\n}\n\n/**\n * @beta\n * Creates an expression that indexes into an array from the beginning or end\n * and return the element. If the offset exceeds the array length, an error is\n * returned. A negative offset, starts from the end.\n *\n * @example\n * ```typescript\n * // Return the value in the tags field array at index 1.\n * arrayGet('tags', 1);\n * ```\n *\n * @param arrayField - The name of the array field.\n * @param offset - The index of the element to return.\n * @returns A new `Expression` representing the 'arrayGet' operation.\n */\nexport function arrayGet(\n arrayField: string,\n offset: number\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that indexes into an array from the beginning or end\n * and return the element. If the offset exceeds the array length, an error is\n * returned. A negative offset, starts from the end.\n *\n * @example\n * ```typescript\n * // Return the value in the tags field array at index specified by field\n * // 'favoriteTag'.\n * arrayGet('tags', field('favoriteTag'));\n * ```\n *\n * @param arrayField - The name of the array field.\n * @param offsetExpr - An `Expression` evaluating to the index of the element to return.\n * @returns A new `Expression` representing the 'arrayGet' operation.\n */\nexport function arrayGet(\n arrayField: string,\n offsetExpr: Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that indexes into an array from the beginning or end\n * and return the element. If the offset exceeds the array length, an error is\n * returned. A negative offset, starts from the end.\n *\n * @example\n * ```typescript\n * // Return the value in the tags field array at index 1.\n * arrayGet(field('tags'), 1);\n * ```\n *\n * @param arrayExpression - An `Expression` evaluating to an array.\n * @param offset - The index of the element to return.\n * @returns A new `Expression` representing the 'arrayGet' operation.\n */\nexport function arrayGet(\n arrayExpression: Expression,\n offset: number\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that indexes into an array from the beginning or end\n * and return the element. If the offset exceeds the array length, an error is\n * returned. A negative offset, starts from the end.\n *\n * @example\n * ```typescript\n * // Return the value in the tags field array at index specified by field\n * // 'favoriteTag'.\n * arrayGet(field('tags'), field('favoriteTag'));\n * ```\n *\n * @param arrayExpression - An `Expression` evaluating to an array.\n * @param offsetExpr - An `Expression` evaluating to the index of the element to return.\n * @returns A new `Expression` representing the 'arrayGet' operation.\n */\nexport function arrayGet(\n arrayExpression: Expression,\n offsetExpr: Expression\n): FunctionExpression;\nexport function arrayGet(\n array: Expression | string,\n offset: Expression | number\n): FunctionExpression {\n return fieldOrExpression(array).arrayGet(valueToDefaultExpr(offset));\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if a given expression produces an error.\n *\n * @example\n * ```typescript\n * // Check if the result of a calculation is an error\n * isError(field(\"title\").arrayContains(1));\n * ```\n *\n * @param value - The expression to check.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'isError' check.\n */\nexport function isError(value: Expression): BooleanExpression {\n return value.isError().asBoolean();\n}\n\n/**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of the `try` argument evaluation.\n *\n * This overload is useful when a BooleanExpression is required.\n *\n * @example\n * ```typescript\n * // Create an expression that protects against a divide by zero error\n * // but always returns a boolean expression.\n * ifError(constant(50).divide('length').gt(1), constant(false));\n * ```\n *\n * @param tryExpr - The try expression.\n * @param catchExpr - The catch expression that will be evaluated and\n * returned if the tryExpr produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\nexport function ifError(\n tryExpr: BooleanExpression,\n catchExpr: BooleanExpression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of the `try` argument evaluation.\n *\n * @example\n * ```typescript\n * // Returns the first item in the title field arrays, or returns\n * // the entire title field if the array is empty or the field is another type.\n * ifError(field(\"title\").arrayGet(0), field(\"title\"));\n * ```\n *\n * @param tryExpr - The try expression.\n * @param catchExpr - The catch expression that will be evaluated and\n * returned if the tryExpr produces an error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\nexport function ifError(\n tryExpr: Expression,\n catchExpr: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the `catch` argument if there is an\n * error, else return the result of the `try` argument evaluation.\n *\n * @example\n * ```typescript\n * // Returns the first item in the title field arrays, or returns\n * // \"Default Title\"\n * ifError(field(\"title\").arrayGet(0), \"Default Title\");\n * ```\n *\n * @param tryExpr - The try expression.\n * @param catchValue - The value that will be returned if the tryExpr produces an\n * error.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ifError' operation.\n */\nexport function ifError(\n tryExpr: Expression,\n catchValue: unknown\n): FunctionExpression;\n\nexport function ifError(\n tryExpr: Expression,\n catchValue: unknown\n): FunctionExpression | BooleanExpression {\n if (\n tryExpr instanceof BooleanExpression &&\n catchValue instanceof BooleanExpression\n ) {\n return tryExpr.ifError(catchValue).asBoolean();\n } else {\n return tryExpr.ifError(valueToDefaultExpr(catchValue));\n }\n}\n\n/**\n * @beta\n *\n * Creates an expression that returns `true` if a value is absent. Otherwise,\n * returns `false` even if the value is `null`.\n *\n * @example\n * ```typescript\n * // Check if the field `value` is absent.\n * isAbsent(field(\"value\"));\n * ```\n *\n * @param value - The expression to check.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'isAbsent' check.\n */\nexport function isAbsent(value: Expression): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns `true` if a field is absent. Otherwise,\n * returns `false` even if the field value is `null`.\n *\n * @example\n * ```typescript\n * // Check if the field `value` is absent.\n * isAbsent(\"value\");\n * ```\n *\n * @param field - The field to check.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'isAbsent' check.\n */\nexport function isAbsent(field: string): BooleanExpression;\nexport function isAbsent(value: Expression | string): BooleanExpression {\n return fieldOrExpression(value).isAbsent();\n}\n\n/**\n * @beta\n *\n * Creates an expression that removes a key from the map at the specified field name.\n *\n * @example\n * ```\n * // Removes the key 'city' field from the map in the address field of the input document.\n * mapRemove('address', 'city');\n * ```\n *\n * @param mapField - The name of a field containing a map value.\n * @param key - The name of the key to remove from the input map.\n */\nexport function mapRemove(mapField: string, key: string): FunctionExpression;\n/**\n * @beta\n *\n * Creates an expression that removes a key from the map produced by evaluating an expression.\n *\n * @example\n * ```\n * // Removes the key 'baz' from the input map.\n * mapRemove(map({foo: 'bar', baz: true}), 'baz');\n * @example\n * ```\n *\n * @param mapExpr - An expression return a map value.\n * @param key - The name of the key to remove from the input map.\n */\nexport function mapRemove(mapExpr: Expression, key: string): FunctionExpression;\n/**\n * @beta\n *\n * Creates an expression that removes a key from the map at the specified field name.\n *\n * @example\n * ```\n * // Removes the key 'city' field from the map in the address field of the input document.\n * mapRemove('address', constant('city'));\n * ```\n *\n * @param mapField - The name of a field containing a map value.\n * @param keyExpr - An expression that produces the name of the key to remove from the input map.\n */\nexport function mapRemove(\n mapField: string,\n keyExpr: Expression\n): FunctionExpression;\n/**\n * @beta\n *\n * Creates an expression that removes a key from the map produced by evaluating an expression.\n *\n * @example\n * ```\n * // Removes the key 'baz' from the input map.\n * mapRemove(map({foo: 'bar', baz: true}), constant('baz'));\n * @example\n * ```\n *\n * @param mapExpr - An expression return a map value.\n * @param keyExpr - An expression that produces the name of the key to remove from the input map.\n */\nexport function mapRemove(\n mapExpr: Expression,\n keyExpr: Expression\n): FunctionExpression;\n\nexport function mapRemove(\n mapExpr: Expression | string,\n stringExpr: Expression | string\n): FunctionExpression {\n return fieldOrExpression(mapExpr).mapRemove(valueToDefaultExpr(stringExpr));\n}\n\n/**\n * @beta\n *\n * Creates an expression that merges multiple map values.\n *\n * @example\n * ```\n * // Merges the map in the settings field with, a map literal, and a map in\n * // that is conditionally returned by another expression\n * mapMerge('settings', { enabled: true }, conditional(field('isAdmin'), { admin: true}, {})\n * ```\n *\n * @param mapField - Name of a field containing a map value that will be merged.\n * @param secondMap - A required second map to merge. Represented as a literal or\n * an expression that returns a map.\n * @param otherMaps - Optional additional maps to merge. Each map is represented\n * as a literal or an expression that returns a map.\n */\nexport function mapMerge(\n mapField: string,\n secondMap: Record<string, unknown> | Expression,\n ...otherMaps: Array<Record<string, unknown> | Expression>\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that merges multiple map values.\n *\n * @example\n * ```\n * // Merges the map in the settings field with, a map literal, and a map in\n * // that is conditionally returned by another expression\n * mapMerge(field('settings'), { enabled: true }, conditional(field('isAdmin'), { admin: true}, {})\n * ```\n *\n * @param firstMap - An expression or literal map value that will be merged.\n * @param secondMap - A required second map to merge. Represented as a literal or\n * an expression that returns a map.\n * @param otherMaps - Optional additional maps to merge. Each map is represented\n * as a literal or an expression that returns a map.\n */\nexport function mapMerge(\n firstMap: Record<string, unknown> | Expression,\n secondMap: Record<string, unknown> | Expression,\n ...otherMaps: Array<Record<string, unknown> | Expression>\n): FunctionExpression;\n\nexport function mapMerge(\n firstMap: string | Record<string, unknown> | Expression,\n secondMap: Record<string, unknown> | Expression,\n ...otherMaps: Array<Record<string, unknown> | Expression>\n): FunctionExpression {\n const secondMapExpr = valueToDefaultExpr(secondMap);\n const otherMapExprs = otherMaps.map(valueToDefaultExpr);\n return fieldOrExpression(firstMap).mapMerge(secondMapExpr, ...otherMapExprs);\n}\n\n/**\n * @beta\n *\n * Creates an expression that returns the document ID from a path.\n *\n * @example\n * ```typescript\n * // Get the document ID from a path.\n * documentId(myDocumentReference);\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the documentId operation.\n */\nexport function documentId(\n documentPath: string | DocumentReference\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the document ID from a path.\n *\n * @example\n * ```typescript\n * // Get the document ID from a path.\n * documentId(field(\"__path__\"));\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the documentId operation.\n */\nexport function documentId(documentPathExpr: Expression): FunctionExpression;\n\nexport function documentId(\n documentPath: Expression | string | DocumentReference\n): FunctionExpression {\n // @ts-ignore\n const documentPathExpr = valueToDefaultExpr(documentPath);\n return documentPathExpr.documentId();\n}\n\n/**\n * @beta\n *\n * Creates an expression that returns a substring of a string or byte array.\n *\n * @param field - The name of a field containing a string or byte array to compute the substring from.\n * @param position - Index of the first character of the substring.\n * @param length - Length of the substring.\n */\nexport function substring(\n field: string,\n position: number,\n length?: number\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns a substring of a string or byte array.\n *\n * @param input - An expression returning a string or byte array to compute the substring from.\n * @param position - Index of the first character of the substring.\n * @param length - Length of the substring.\n */\nexport function substring(\n input: Expression,\n position: number,\n length?: number\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns a substring of a string or byte array.\n *\n * @param field - The name of a field containing a string or byte array to compute the substring from.\n * @param position - An expression that returns the index of the first character of the substring.\n * @param length - An expression that returns the length of the substring.\n */\nexport function substring(\n field: string,\n position: Expression,\n length?: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns a substring of a string or byte array.\n *\n * @param input - An expression returning a string or byte array to compute the substring from.\n * @param position - An expression that returns the index of the first character of the substring.\n * @param length - An expression that returns the length of the substring.\n */\nexport function substring(\n input: Expression,\n position: Expression,\n length?: Expression\n): FunctionExpression;\n\nexport function substring(\n field: Expression | string,\n position: Expression | number,\n length?: Expression | number\n): FunctionExpression {\n const fieldExpr = fieldOrExpression(field);\n const positionExpr = valueToDefaultExpr(position);\n const lengthExpr =\n length === undefined ? undefined : valueToDefaultExpr(length);\n return fieldExpr.substring(positionExpr, lengthExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that adds two expressions together.\n *\n * @example\n * ```typescript\n * // Add the value of the 'quantity' field and the 'reserve' field.\n * add(field(\"quantity\"), field(\"reserve\"));\n * ```\n *\n * @param first - The first expression to add.\n * @param second - The second expression or literal to add.\n * @param others - Optional other expressions or literals to add.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the addition operation.\n */\nexport function add(\n first: Expression,\n second: Expression | unknown\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that adds a field's value to an expression.\n *\n * @example\n * ```typescript\n * // Add the value of the 'quantity' field and the 'reserve' field.\n * add(\"quantity\", field(\"reserve\"));\n * ```\n *\n * @param fieldName - The name of the field containing the value to add.\n * @param second - The second expression or literal to add.\n * @param others - Optional other expressions or literals to add.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the addition operation.\n */\nexport function add(\n fieldName: string,\n second: Expression | unknown\n): FunctionExpression;\n\nexport function add(\n first: Expression | string,\n second: Expression | unknown\n): FunctionExpression {\n return fieldOrExpression(first).add(valueToDefaultExpr(second));\n}\n\n/**\n * @beta\n *\n * Creates an expression that subtracts two expressions.\n *\n * @example\n * ```typescript\n * // Subtract the 'discount' field from the 'price' field\n * subtract(field(\"price\"), field(\"discount\"));\n * ```\n *\n * @param left - The expression to subtract from.\n * @param right - The expression to subtract.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the subtraction operation.\n */\nexport function subtract(\n left: Expression,\n right: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that subtracts a constant value from an expression.\n *\n * @example\n * ```typescript\n * // Subtract the constant value 2 from the 'value' field\n * subtract(field(\"value\"), 2);\n * ```\n *\n * @param expression - The expression to subtract from.\n * @param value - The constant value to subtract.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the subtraction operation.\n */\nexport function subtract(\n expression: Expression,\n value: unknown\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that subtracts an expression from a field's value.\n *\n * @example\n * ```typescript\n * // Subtract the 'discount' field from the 'price' field\n * subtract(\"price\", field(\"discount\"));\n * ```\n *\n * @param fieldName - The field name to subtract from.\n * @param expression - The expression to subtract.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the subtraction operation.\n */\nexport function subtract(\n fieldName: string,\n expression: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that subtracts a constant value from a field's value.\n *\n * @example\n * ```typescript\n * // Subtract 20 from the value of the 'total' field\n * subtract(\"total\", 20);\n * ```\n *\n * @param fieldName - The field name to subtract from.\n * @param value - The constant value to subtract.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the subtraction operation.\n */\nexport function subtract(fieldName: string, value: unknown): FunctionExpression;\nexport function subtract(\n left: Expression | string,\n right: Expression | unknown\n): FunctionExpression {\n const normalizedLeft = typeof left === 'string' ? field(left) : left;\n const normalizedRight = valueToDefaultExpr(right);\n return normalizedLeft.subtract(normalizedRight);\n}\n\n/**\n * @beta\n *\n * Creates an expression that multiplies two expressions together.\n *\n * @example\n * ```typescript\n * // Multiply the 'quantity' field by the 'price' field\n * multiply(field(\"quantity\"), field(\"price\"));\n * ```\n *\n * @param first - The first expression to multiply.\n * @param second - The second expression or literal to multiply.\n * @param others - Optional additional expressions or literals to multiply.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the multiplication operation.\n */\nexport function multiply(\n first: Expression,\n second: Expression | unknown\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that multiplies a field's value by an expression.\n *\n * @example\n * ```typescript\n * // Multiply the 'quantity' field by the 'price' field\n * multiply(\"quantity\", field(\"price\"));\n * ```\n *\n * @param fieldName - The name of the field containing the value to add.\n * @param second - The second expression or literal to add.\n * @param others - Optional other expressions or literals to add.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the multiplication operation.\n */\nexport function multiply(\n fieldName: string,\n second: Expression | unknown\n): FunctionExpression;\n\nexport function multiply(\n first: Expression | string,\n second: Expression | unknown\n): FunctionExpression {\n return fieldOrExpression(first).multiply(valueToDefaultExpr(second));\n}\n\n/**\n * @beta\n *\n * Creates an expression that divides two expressions.\n *\n * @example\n * ```typescript\n * // Divide the 'total' field by the 'count' field\n * divide(field(\"total\"), field(\"count\"));\n * ```\n *\n * @param left - The expression to be divided.\n * @param right - The expression to divide by.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the division operation.\n */\nexport function divide(left: Expression, right: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that divides an expression by a constant value.\n *\n * @example\n * ```typescript\n * // Divide the 'value' field by 10\n * divide(field(\"value\"), 10);\n * ```\n *\n * @param expression - The expression to be divided.\n * @param value - The constant value to divide by.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the division operation.\n */\nexport function divide(\n expression: Expression,\n value: unknown\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that divides a field's value by an expression.\n *\n * @example\n * ```typescript\n * // Divide the 'total' field by the 'count' field\n * divide(\"total\", field(\"count\"));\n * ```\n *\n * @param fieldName - The field name to be divided.\n * @param expressions - The expression to divide by.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the division operation.\n */\nexport function divide(\n fieldName: string,\n expressions: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that divides a field's value by a constant value.\n *\n * @example\n * ```typescript\n * // Divide the 'value' field by 10\n * divide(\"value\", 10);\n * ```\n *\n * @param fieldName - The field name to be divided.\n * @param value - The constant value to divide by.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the division operation.\n */\nexport function divide(fieldName: string, value: unknown): FunctionExpression;\nexport function divide(\n left: Expression | string,\n right: Expression | unknown\n): FunctionExpression {\n const normalizedLeft = typeof left === 'string' ? field(left) : left;\n const normalizedRight = valueToDefaultExpr(right);\n return normalizedLeft.divide(normalizedRight);\n}\n\n/**\n * @beta\n *\n * Creates an expression that calculates the modulo (remainder) of dividing two expressions.\n *\n * @example\n * ```typescript\n * // Calculate the remainder of dividing 'field1' by 'field2'.\n * mod(field(\"field1\"), field(\"field2\"));\n * ```\n *\n * @param left - The dividend expression.\n * @param right - The divisor expression.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the modulo operation.\n */\nexport function mod(left: Expression, right: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that calculates the modulo (remainder) of dividing an expression by a constant.\n *\n * @example\n * ```typescript\n * // Calculate the remainder of dividing 'field1' by 5.\n * mod(field(\"field1\"), 5);\n * ```\n *\n * @param expression - The dividend expression.\n * @param value - The divisor constant.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the modulo operation.\n */\nexport function mod(expression: Expression, value: unknown): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that calculates the modulo (remainder) of dividing a field's value by an expression.\n *\n * @example\n * ```typescript\n * // Calculate the remainder of dividing 'field1' by 'field2'.\n * mod(\"field1\", field(\"field2\"));\n * ```\n *\n * @param fieldName - The dividend field name.\n * @param expression - The divisor expression.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the modulo operation.\n */\nexport function mod(\n fieldName: string,\n expression: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that calculates the modulo (remainder) of dividing a field's value by a constant.\n *\n * @example\n * ```typescript\n * // Calculate the remainder of dividing 'field1' by 5.\n * mod(\"field1\", 5);\n * ```\n *\n * @param fieldName - The dividend field name.\n * @param value - The divisor constant.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the modulo operation.\n */\nexport function mod(fieldName: string, value: unknown): FunctionExpression;\nexport function mod(\n left: Expression | string,\n right: Expression | unknown\n): FunctionExpression {\n const normalizedLeft = typeof left === 'string' ? field(left) : left;\n const normalizedRight = valueToDefaultExpr(right);\n return normalizedLeft.mod(normalizedRight);\n}\n\n/**\n * @beta\n *\n * Creates an expression that creates a Firestore map value from an input object.\n *\n * @example\n * ```typescript\n * // Create a map from the input object and reference the 'baz' field value from the input document.\n * map({foo: 'bar', baz: Field.of('baz')}).as('data');\n * ```\n *\n * @param elements - The input map to evaluate in the expression.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the map function.\n */\nexport function map(elements: Record<string, unknown>): FunctionExpression {\n return _map(elements, 'map');\n}\nexport function _map(\n elements: Record<string, unknown>,\n methodName: string | undefined\n): FunctionExpression {\n const result: Expression[] = [];\n for (const key in elements) {\n if (Object.prototype.hasOwnProperty.call(elements, key)) {\n const value = elements[key];\n result.push(constant(key));\n result.push(valueToDefaultExpr(value));\n }\n }\n return new FunctionExpression('map', result, 'map');\n}\n\n/**\n * Internal use only\n * Converts a plainObject to a mapValue in the proto representation,\n * rather than a functionValue+map that is the result of the map(...) function.\n * This behaves different from constant(plainObject) because it\n * traverses the input object, converts values in the object to expressions,\n * and calls _readUserData on each of these expressions.\n * @private\n * @internal\n * @param plainObject\n */\nexport function _mapValue(plainObject: Record<string, unknown>): MapValue {\n const result: Map<string, Expression> = new Map<string, Expression>();\n for (const key in plainObject) {\n if (Object.prototype.hasOwnProperty.call(plainObject, key)) {\n const value = plainObject[key];\n result.set(key, valueToDefaultExpr(value));\n }\n }\n return new MapValue(result, undefined);\n}\n\n/**\n * @beta\n *\n * Creates an expression that creates a Firestore array value from an input array.\n *\n * @example\n * ```typescript\n * // Create an array value from the input array and reference the 'baz' field value from the input document.\n * array(['bar', Field.of('baz')]).as('foo');\n * ```\n *\n * @param elements - The input array to evaluate in the expression.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the array function.\n */\nexport function array(elements: unknown[]): FunctionExpression {\n return _array(elements, 'array');\n}\nexport function _array(\n elements: unknown[],\n methodName: string | undefined\n): FunctionExpression {\n return new FunctionExpression(\n 'array',\n elements.map(element => valueToDefaultExpr(element)),\n methodName\n );\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if two expressions are equal.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is equal to an expression\n * equal(field(\"age\"), field(\"minAge\").add(10));\n * ```\n *\n * @param left - The first expression to compare.\n * @param right - The second expression to compare.\n * @returns A new `Expression` representing the equality comparison.\n */\nexport function equal(left: Expression, right: Expression): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is equal to 21\n * equal(field(\"age\"), 21);\n * ```\n *\n * @param expression - The expression to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the equality comparison.\n */\nexport function equal(\n expression: Expression,\n value: unknown\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is equal to an expression.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is equal to the 'limit' field\n * equal(\"age\", field(\"limit\"));\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param expression - The expression to compare to.\n * @returns A new `Expression` representing the equality comparison.\n */\nexport function equal(\n fieldName: string,\n expression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'city' field is equal to string constant \"London\"\n * equal(\"city\", \"London\");\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the equality comparison.\n */\nexport function equal(fieldName: string, value: unknown): BooleanExpression;\nexport function equal(\n left: Expression | string,\n right: unknown\n): BooleanExpression {\n const leftExpr = left instanceof Expression ? left : field(left);\n const rightExpr = valueToDefaultExpr(right);\n return leftExpr.equal(rightExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if two expressions are not equal.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is not equal to field 'finalState'\n * notEqual(field(\"status\"), field(\"finalState\"));\n * ```\n *\n * @param left - The first expression to compare.\n * @param right - The second expression to compare.\n * @returns A new `Expression` representing the inequality comparison.\n */\nexport function notEqual(\n left: Expression,\n right: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is not equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is not equal to \"completed\"\n * notEqual(field(\"status\"), \"completed\");\n * ```\n *\n * @param expression - The expression to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the inequality comparison.\n */\nexport function notEqual(\n expression: Expression,\n value: unknown\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is not equal to an expression.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is not equal to the value of 'expectedStatus'\n * notEqual(\"status\", field(\"expectedStatus\"));\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param expression - The expression to compare to.\n * @returns A new `Expression` representing the inequality comparison.\n */\nexport function notEqual(\n fieldName: string,\n expression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is not equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'country' field is not equal to \"USA\"\n * notEqual(\"country\", \"USA\");\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the inequality comparison.\n */\nexport function notEqual(fieldName: string, value: unknown): BooleanExpression;\nexport function notEqual(\n left: Expression | string,\n right: unknown\n): BooleanExpression {\n const leftExpr = left instanceof Expression ? left : field(left);\n const rightExpr = valueToDefaultExpr(right);\n return leftExpr.notEqual(rightExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if the first expression is less than the second expression.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is less than 30\n * lessThan(field(\"age\"), field(\"limit\"));\n * ```\n *\n * @param left - The first expression to compare.\n * @param right - The second expression to compare.\n * @returns A new `Expression` representing the less than comparison.\n */\nexport function lessThan(\n left: Expression,\n right: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is less than a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is less than 30\n * lessThan(field(\"age\"), 30);\n * ```\n *\n * @param expression - The expression to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the less than comparison.\n */\nexport function lessThan(\n expression: Expression,\n value: unknown\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is less than an expression.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is less than the 'limit' field\n * lessThan(\"age\", field(\"limit\"));\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param expression - The expression to compare to.\n * @returns A new `Expression` representing the less than comparison.\n */\nexport function lessThan(\n fieldName: string,\n expression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is less than a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'price' field is less than 50\n * lessThan(\"price\", 50);\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the less than comparison.\n */\nexport function lessThan(fieldName: string, value: unknown): BooleanExpression;\nexport function lessThan(\n left: Expression | string,\n right: unknown\n): BooleanExpression {\n const leftExpr = left instanceof Expression ? left : field(left);\n const rightExpr = valueToDefaultExpr(right);\n return leftExpr.lessThan(rightExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if the first expression is less than or equal to the second\n * expression.\n *\n * @example\n * ```typescript\n * // Check if the 'quantity' field is less than or equal to 20\n * lessThan(field(\"quantity\"), field(\"limit\"));\n * ```\n *\n * @param left - The first expression to compare.\n * @param right - The second expression to compare.\n * @returns A new `Expression` representing the less than or equal to comparison.\n */\nexport function lessThanOrEqual(\n left: Expression,\n right: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is less than or equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'quantity' field is less than or equal to 20\n * lessThan(field(\"quantity\"), 20);\n * ```\n *\n * @param expression - The expression to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the less than or equal to comparison.\n */\nexport function lessThanOrEqual(\n expression: Expression,\n value: unknown\n): BooleanExpression;\n\n/**\n * @beta\n * Creates an expression that checks if a field's value is less than or equal to an expression.\n *\n * @example\n * ```typescript\n * // Check if the 'quantity' field is less than or equal to the 'limit' field\n * lessThan(\"quantity\", field(\"limit\"));\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param expression - The expression to compare to.\n * @returns A new `Expression` representing the less than or equal to comparison.\n */\nexport function lessThanOrEqual(\n fieldName: string,\n expression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is less than or equal to a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'score' field is less than or equal to 70\n * lessThan(\"score\", 70);\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the less than or equal to comparison.\n */\nexport function lessThanOrEqual(\n fieldName: string,\n value: unknown\n): BooleanExpression;\nexport function lessThanOrEqual(\n left: Expression | string,\n right: unknown\n): BooleanExpression {\n const leftExpr = left instanceof Expression ? left : field(left);\n const rightExpr = valueToDefaultExpr(right);\n return leftExpr.lessThanOrEqual(rightExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if the first expression is greater than the second\n * expression.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is greater than 18\n * greaterThan(field(\"age\"), Constant(9).add(9));\n * ```\n *\n * @param left - The first expression to compare.\n * @param right - The second expression to compare.\n * @returns A new `Expression` representing the greater than comparison.\n */\nexport function greaterThan(\n left: Expression,\n right: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is greater than a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is greater than 18\n * greaterThan(field(\"age\"), 18);\n * ```\n *\n * @param expression - The expression to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the greater than comparison.\n */\nexport function greaterThan(\n expression: Expression,\n value: unknown\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is greater than an expression.\n *\n * @example\n * ```typescript\n * // Check if the value of field 'age' is greater than the value of field 'limit'\n * greaterThan(\"age\", field(\"limit\"));\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param expression - The expression to compare to.\n * @returns A new `Expression` representing the greater than comparison.\n */\nexport function greaterThan(\n fieldName: string,\n expression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is greater than a constant value.\n *\n * @example\n * ```typescript\n * // Check if the 'price' field is greater than 100\n * greaterThan(\"price\", 100);\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the greater than comparison.\n */\nexport function greaterThan(\n fieldName: string,\n value: unknown\n): BooleanExpression;\nexport function greaterThan(\n left: Expression | string,\n right: unknown\n): BooleanExpression {\n const leftExpr = left instanceof Expression ? left : field(left);\n const rightExpr = valueToDefaultExpr(right);\n return leftExpr.greaterThan(rightExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if the first expression is greater than or equal to the\n * second expression.\n *\n * @example\n * ```typescript\n * // Check if the 'quantity' field is greater than or equal to the field \"threshold\"\n * greaterThanOrEqual(field(\"quantity\"), field(\"threshold\"));\n * ```\n *\n * @param left - The first expression to compare.\n * @param right - The second expression to compare.\n * @returns A new `Expression` representing the greater than or equal to comparison.\n */\nexport function greaterThanOrEqual(\n left: Expression,\n right: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is greater than or equal to a constant\n * value.\n *\n * @example\n * ```typescript\n * // Check if the 'quantity' field is greater than or equal to 10\n * greaterThanOrEqual(field(\"quantity\"), 10);\n * ```\n *\n * @param expression - The expression to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the greater than or equal to comparison.\n */\nexport function greaterThanOrEqual(\n expression: Expression,\n value: unknown\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is greater than or equal to an expression.\n *\n * @example\n * ```typescript\n * // Check if the value of field 'age' is greater than or equal to the value of field 'limit'\n * greaterThanOrEqual(\"age\", field(\"limit\"));\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param value - The expression to compare to.\n * @returns A new `Expression` representing the greater than or equal to comparison.\n */\nexport function greaterThanOrEqual(\n fieldName: string,\n value: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is greater than or equal to a constant\n * value.\n *\n * @example\n * ```typescript\n * // Check if the 'score' field is greater than or equal to 80\n * greaterThanOrEqual(\"score\", 80);\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param value - The constant value to compare to.\n * @returns A new `Expression` representing the greater than or equal to comparison.\n */\nexport function greaterThanOrEqual(\n fieldName: string,\n value: unknown\n): BooleanExpression;\nexport function greaterThanOrEqual(\n left: Expression | string,\n right: unknown\n): BooleanExpression {\n const leftExpr = left instanceof Expression ? left : field(left);\n const rightExpr = valueToDefaultExpr(right);\n return leftExpr.greaterThanOrEqual(rightExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that concatenates an array expression with other arrays.\n *\n * @example\n * ```typescript\n * // Combine the 'items' array with two new item arrays\n * arrayConcat(field(\"items\"), [field(\"newItems\"), field(\"otherItems\")]);\n * ```\n *\n * @param firstArray - The first array expression to concatenate to.\n * @param secondArray - The second array expression or array literal to concatenate to.\n * @param otherArrays - Optional additional array expressions or array literals to concatenate.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the concatenated array.\n */\nexport function arrayConcat(\n firstArray: Expression,\n secondArray: Expression | unknown[],\n ...otherArrays: Array<Expression | unknown[]>\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that concatenates a field's array value with other arrays.\n *\n * @example\n * ```typescript\n * // Combine the 'items' array with two new item arrays\n * arrayConcat(\"items\", [field(\"newItems\"), field(\"otherItems\")]);\n * ```\n *\n * @param firstArrayField - The first array to concatenate to.\n * @param secondArray - The second array expression or array literal to concatenate to.\n * @param otherArrays - Optional additional array expressions or array literals to concatenate.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the concatenated array.\n */\nexport function arrayConcat(\n firstArrayField: string,\n secondArray: Expression | unknown[],\n ...otherArrays: Array<Expression | unknown[]>\n): FunctionExpression;\n\nexport function arrayConcat(\n firstArray: Expression | string,\n secondArray: Expression | unknown[],\n ...otherArrays: Array<Expression | unknown[]>\n): FunctionExpression {\n const exprValues = otherArrays.map(element => valueToDefaultExpr(element));\n return fieldOrExpression(firstArray).arrayConcat(\n fieldOrExpression(secondArray),\n ...exprValues\n );\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if an array expression contains a specific element.\n *\n * @example\n * ```typescript\n * // Check if the 'colors' array contains the value of field 'selectedColor'\n * arrayContains(field(\"colors\"), field(\"selectedColor\"));\n * ```\n *\n * @param array - The array expression to check.\n * @param element - The element to search for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.\n */\nexport function arrayContains(\n array: Expression,\n element: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an array expression contains a specific element.\n *\n * @example\n * ```typescript\n * // Check if the 'colors' array contains \"red\"\n * arrayContains(field(\"colors\"), \"red\");\n * ```\n *\n * @param array - The array expression to check.\n * @param element - The element to search for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.\n */\nexport function arrayContains(\n array: Expression,\n element: unknown\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's array value contains a specific element.\n *\n * @example\n * ```typescript\n * // Check if the 'colors' array contains the value of field 'selectedColor'\n * arrayContains(\"colors\", field(\"selectedColor\"));\n * ```\n *\n * @param fieldName - The field name to check.\n * @param element - The element to search for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.\n */\nexport function arrayContains(\n fieldName: string,\n element: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's array value contains a specific value.\n *\n * @example\n * ```typescript\n * // Check if the 'colors' array contains \"red\"\n * arrayContains(\"colors\", \"red\");\n * ```\n *\n * @param fieldName - The field name to check.\n * @param element - The element to search for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains' comparison.\n */\nexport function arrayContains(\n fieldName: string,\n element: unknown\n): BooleanExpression;\nexport function arrayContains(\n array: Expression | string,\n element: unknown\n): BooleanExpression {\n const arrayExpr = fieldOrExpression(array);\n const elementExpr = valueToDefaultExpr(element);\n return arrayExpr.arrayContains(elementExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if an array expression contains any of the specified\n * elements.\n *\n * @example\n * ```typescript\n * // Check if the 'categories' array contains either values from field \"cate1\" or \"Science\"\n * arrayContainsAny(field(\"categories\"), [field(\"cate1\"), \"Science\"]);\n * ```\n *\n * @param array - The array expression to check.\n * @param values - The elements to check for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.\n */\nexport function arrayContainsAny(\n array: Expression,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's array value contains any of the specified\n * elements.\n *\n * @example\n * ```typescript\n * // Check if the 'groups' array contains either the value from the 'userGroup' field\n * // or the value \"guest\"\n * arrayContainsAny(\"categories\", [field(\"cate1\"), \"Science\"]);\n * ```\n *\n * @param fieldName - The field name to check.\n * @param values - The elements to check for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.\n */\nexport function arrayContainsAny(\n fieldName: string,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an array expression contains any of the specified\n * elements.\n *\n * @example\n * ```typescript\n * // Check if the 'categories' array contains either values from field \"cate1\" or \"Science\"\n * arrayContainsAny(field(\"categories\"), array([field(\"cate1\"), \"Science\"]));\n * ```\n *\n * @param array - The array expression to check.\n * @param values - An expression that evaluates to an array, whose elements to check for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.\n */\nexport function arrayContainsAny(\n array: Expression,\n values: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's array value contains any of the specified\n * elements.\n *\n * @example\n * ```typescript\n * // Check if the 'groups' array contains either the value from the 'userGroup' field\n * // or the value \"guest\"\n * arrayContainsAny(\"categories\", array([field(\"cate1\"), \"Science\"]));\n * ```\n *\n * @param fieldName - The field name to check.\n * @param values - An expression that evaluates to an array, whose elements to check for in the array field.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_any' comparison.\n */\nexport function arrayContainsAny(\n fieldName: string,\n values: Expression\n): BooleanExpression;\nexport function arrayContainsAny(\n array: Expression | string,\n values: unknown[] | Expression\n): BooleanExpression {\n // @ts-ignore implementation accepts both types\n return fieldOrExpression(array).arrayContainsAny(values);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if an array expression contains all the specified elements.\n *\n * @example\n * ```typescript\n * // Check if the \"tags\" array contains all of the values: \"SciFi\", \"Adventure\", and the value from field \"tag1\"\n * arrayContainsAll(field(\"tags\"), [field(\"tag1\"), constant(\"SciFi\"), \"Adventure\"]);\n * ```\n *\n * @param array - The array expression to check.\n * @param values - The elements to check for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.\n */\nexport function arrayContainsAll(\n array: Expression,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's array value contains all the specified values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'tags' array contains both of the values from field 'tag1', the value \"SciFi\", and \"Adventure\"\n * arrayContainsAll(\"tags\", [field(\"tag1\"), \"SciFi\", \"Adventure\"]);\n * ```\n *\n * @param fieldName - The field name to check.\n * @param values - The elements to check for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.\n */\nexport function arrayContainsAll(\n fieldName: string,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an array expression contains all the specified elements.\n *\n * @example\n * ```typescript\n * // Check if the \"tags\" array contains all of the values: \"SciFi\", \"Adventure\", and the value from field \"tag1\"\n * arrayContainsAll(field(\"tags\"), [field(\"tag1\"), constant(\"SciFi\"), \"Adventure\"]);\n * ```\n *\n * @param array - The array expression to check.\n * @param arrayExpression - The elements to check for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.\n */\nexport function arrayContainsAll(\n array: Expression,\n arrayExpression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's array value contains all the specified values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'tags' array contains both of the values from field 'tag1', the value \"SciFi\", and \"Adventure\"\n * arrayContainsAll(\"tags\", [field(\"tag1\"), \"SciFi\", \"Adventure\"]);\n * ```\n *\n * @param fieldName - The field name to check.\n * @param arrayExpression - The elements to check for in the array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'array_contains_all' comparison.\n */\nexport function arrayContainsAll(\n fieldName: string,\n arrayExpression: Expression\n): BooleanExpression;\nexport function arrayContainsAll(\n array: Expression | string,\n values: unknown[] | Expression\n): BooleanExpression {\n // @ts-ignore implementation accepts both types\n return fieldOrExpression(array).arrayContainsAll(values);\n}\n\n/**\n * @beta\n *\n * Creates an expression that calculates the length of an array in a specified field.\n *\n * @example\n * ```typescript\n * // Get the number of items in field 'cart'\n * arrayLength('cart');\n * ```\n *\n * @param fieldName - The name of the field containing an array to calculate the length of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the array.\n */\nexport function arrayLength(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that calculates the length of an array expression.\n *\n * @example\n * ```typescript\n * // Get the number of items in the 'cart' array\n * arrayLength(field(\"cart\"));\n * ```\n *\n * @param array - The array expression to calculate the length of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the array.\n */\nexport function arrayLength(array: Expression): FunctionExpression;\nexport function arrayLength(array: Expression | string): FunctionExpression {\n return fieldOrExpression(array).arrayLength();\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression, when evaluated, is equal to any of the provided values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'category' field is either \"Electronics\" or value of field 'primaryType'\n * equalAny(field(\"category\"), [constant(\"Electronics\"), field(\"primaryType\")]);\n * ```\n *\n * @param expression - The expression whose results to compare.\n * @param values - The values to check against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'IN' comparison.\n */\nexport function equalAny(\n expression: Expression,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is equal to any of the provided values.\n *\n * @example\n * ```typescript\n * // Check if the 'category' field is set to a value in the disabledCategories field\n * equalAny(field(\"category\"), field('disabledCategories'));\n * ```\n *\n * @param expression - The expression whose results to compare.\n * @param arrayExpression - An expression that evaluates to an array, whose elements to check for equality to the input.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'IN' comparison.\n */\nexport function equalAny(\n expression: Expression,\n arrayExpression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is equal to any of the provided values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'category' field is either \"Electronics\" or value of field 'primaryType'\n * equalAny(\"category\", [constant(\"Electronics\"), field(\"primaryType\")]);\n * ```\n *\n * @param fieldName - The field to compare.\n * @param values - The values to check against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'IN' comparison.\n */\nexport function equalAny(\n fieldName: string,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is equal to any of the provided values or\n * expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'category' field is either \"Electronics\" or value of field 'primaryType'\n * equalAny(\"category\", [\"Electronics\", field(\"primaryType\")]);\n * ```\n *\n * @param fieldName - The field to compare.\n * @param arrayExpression - An expression that evaluates to an array, whose elements to check for equality to the input field.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'IN' comparison.\n */\nexport function equalAny(\n fieldName: string,\n arrayExpression: Expression\n): BooleanExpression;\nexport function equalAny(\n element: Expression | string,\n values: unknown[] | Expression\n): BooleanExpression {\n // @ts-ignore implementation accepts both types\n return fieldOrExpression(element).equalAny(values);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is not equal to any of the provided values\n * or expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is neither \"pending\" nor the value of 'rejectedStatus'\n * notEqualAny(field(\"status\"), [\"pending\", field(\"rejectedStatus\")]);\n * ```\n *\n * @param element - The expression to compare.\n * @param values - The values to check against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'NOT IN' comparison.\n */\nexport function notEqualAny(\n element: Expression,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is not equal to any of the provided values\n * or expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is neither \"pending\" nor the value of 'rejectedStatus'\n * notEqualAny(\"status\", [constant(\"pending\"), field(\"rejectedStatus\")]);\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param values - The values to check against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'NOT IN' comparison.\n */\nexport function notEqualAny(\n fieldName: string,\n values: Array<Expression | unknown>\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if an expression is not equal to any of the provided values\n * or expressions.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is neither \"pending\" nor the value of the field 'rejectedStatus'\n * notEqualAny(field(\"status\"), [\"pending\", field(\"rejectedStatus\")]);\n * ```\n *\n * @param element - The expression to compare.\n * @param arrayExpression - The values to check against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'NOT IN' comparison.\n */\nexport function notEqualAny(\n element: Expression,\n arrayExpression: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value is not equal to any of the values in the evaluated expression.\n *\n * @example\n * ```typescript\n * // Check if the 'status' field is not equal to any value in the field 'rejectedStatuses'\n * notEqualAny(\"status\", field(\"rejectedStatuses\"));\n * ```\n *\n * @param fieldName - The field name to compare.\n * @param arrayExpression - The values to check against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'NOT IN' comparison.\n */\nexport function notEqualAny(\n fieldName: string,\n arrayExpression: Expression\n): BooleanExpression;\n\nexport function notEqualAny(\n element: Expression | string,\n values: unknown[] | Expression\n): BooleanExpression {\n // @ts-ignore implementation accepts both types\n return fieldOrExpression(element).notEqualAny(values);\n}\n\n/**\n * @beta\n *\n * Creates an expression that performs a logical 'XOR' (exclusive OR) operation on multiple BooleanExpressions.\n *\n * @example\n * ```typescript\n * // Check if only one of the conditions is true: 'age' greater than 18, 'city' is \"London\",\n * // or 'status' is \"active\".\n * const condition = xor(\n * greaterThan(\"age\", 18),\n * equal(\"city\", \"London\"),\n * equal(\"status\", \"active\"));\n * ```\n *\n * @param first - The first condition.\n * @param second - The second condition.\n * @param additionalConditions - Additional conditions to 'XOR' together.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical 'XOR' operation.\n */\nexport function xor(\n first: BooleanExpression,\n second: BooleanExpression,\n ...additionalConditions: BooleanExpression[]\n): BooleanExpression {\n return new FunctionExpression(\n 'xor',\n [first, second, ...additionalConditions],\n 'xor'\n ).asBoolean();\n}\n\n/**\n * @beta\n *\n * Creates a conditional expression that evaluates to a 'then' expression if a condition is true\n * and an 'else' expression if the condition is false.\n *\n * @example\n * ```typescript\n * // If 'age' is greater than 18, return \"Adult\"; otherwise, return \"Minor\".\n * conditional(\n * greaterThan(\"age\", 18), constant(\"Adult\"), constant(\"Minor\"));\n * ```\n *\n * @param condition - The condition to evaluate.\n * @param thenExpr - The expression to evaluate if the condition is true.\n * @param elseExpr - The expression to evaluate if the condition is false.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the conditional expression.\n */\nexport function conditional(\n condition: BooleanExpression,\n thenExpr: Expression,\n elseExpr: Expression\n): FunctionExpression {\n return new FunctionExpression(\n 'conditional',\n [condition, thenExpr, elseExpr],\n 'conditional'\n );\n}\n\n/**\n * @beta\n *\n * Creates an expression that negates a filter condition.\n *\n * @example\n * ```typescript\n * // Find documents where the 'completed' field is NOT true\n * not(equal(\"completed\", true));\n * ```\n *\n * @param booleanExpr - The filter condition to negate.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the negated filter condition.\n */\nexport function not(booleanExpr: BooleanExpression): BooleanExpression {\n return booleanExpr.not();\n}\n\n/**\n * @beta\n *\n * Creates an expression that returns the largest value between multiple input\n * expressions or literal values. Based on Firestore's value type ordering.\n *\n * @example\n * ```typescript\n * // Returns the largest value between the 'field1' field, the 'field2' field,\n * // and 1000\n * logicalMaximum(field(\"field1\"), field(\"field2\"), 1000);\n * ```\n *\n * @param first - The first operand expression.\n * @param second - The second expression or literal.\n * @param others - Optional additional expressions or literals.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical maximum operation.\n */\nexport function logicalMaximum(\n first: Expression,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the largest value between multiple input\n * expressions or literal values. Based on Firestore's value type ordering.\n *\n * @example\n * ```typescript\n * // Returns the largest value between the 'field1' field, the 'field2' field,\n * // and 1000.\n * logicalMaximum(\"field1\", field(\"field2\"), 1000);\n * ```\n *\n * @param fieldName - The first operand field name.\n * @param second - The second expression or literal.\n * @param others - Optional additional expressions or literals.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical maximum operation.\n */\nexport function logicalMaximum(\n fieldName: string,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression;\n\nexport function logicalMaximum(\n first: Expression | string,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression {\n return fieldOrExpression(first).logicalMaximum(\n valueToDefaultExpr(second),\n ...others.map(value => valueToDefaultExpr(value))\n );\n}\n\n/**\n * @beta\n *\n * Creates an expression that returns the smallest value between multiple input\n * expressions and literal values. Based on Firestore's value type ordering.\n *\n * @example\n * ```typescript\n * // Returns the smallest value between the 'field1' field, the 'field2' field,\n * // and 1000.\n * logicalMinimum(field(\"field1\"), field(\"field2\"), 1000);\n * ```\n *\n * @param first - The first operand expression.\n * @param second - The second expression or literal.\n * @param others - Optional additional expressions or literals.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical minimum operation.\n */\nexport function logicalMinimum(\n first: Expression,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the smallest value between a field's value\n * and other input expressions or literal values.\n * Based on Firestore's value type ordering.\n *\n * @example\n * ```typescript\n * // Returns the smallest value between the 'field1' field, the 'field2' field,\n * // and 1000.\n * logicalMinimum(\"field1\", field(\"field2\"), 1000);\n * ```\n *\n * @param fieldName - The first operand field name.\n * @param second - The second expression or literal.\n * @param others - Optional additional expressions or literals.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical minimum operation.\n */\nexport function logicalMinimum(\n fieldName: string,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression;\n\nexport function logicalMinimum(\n first: Expression | string,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression {\n return fieldOrExpression(first).logicalMinimum(\n valueToDefaultExpr(second),\n ...others.map(value => valueToDefaultExpr(value))\n );\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field exists.\n *\n * @example\n * ```typescript\n * // Check if the document has a field named \"phoneNumber\"\n * exists(field(\"phoneNumber\"));\n * ```\n *\n * @param value - An expression evaluates to the name of the field to check.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'exists' check.\n */\nexport function exists(value: Expression): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field exists.\n *\n * @example\n * ```typescript\n * // Check if the document has a field named \"phoneNumber\"\n * exists(\"phoneNumber\");\n * ```\n *\n * @param fieldName - The field name to check.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'exists' check.\n */\nexport function exists(fieldName: string): BooleanExpression;\nexport function exists(valueOrField: Expression | string): BooleanExpression {\n return fieldOrExpression(valueOrField).exists();\n}\n\n/**\n * @beta\n *\n * Creates an expression that reverses a string.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myString' field.\n * reverse(field(\"myString\"));\n * ```\n *\n * @param stringExpression - An expression evaluating to a string value, which will be reversed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed string.\n */\nexport function reverse(stringExpression: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that reverses a string value in the specified field.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myString' field.\n * reverse(\"myString\");\n * ```\n *\n * @param field - The name of the field representing the string to reverse.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed string.\n */\nexport function reverse(field: string): FunctionExpression;\nexport function reverse(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).reverse();\n}\n\n/**\n * @beta\n *\n * Creates an expression that calculates the byte length of a string in UTF-8, or just the length of a Blob.\n *\n * @example\n * ```typescript\n * // Calculate the length of the 'myString' field in bytes.\n * byteLength(field(\"myString\"));\n * ```\n *\n * @param expr - The expression representing the string.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the string in bytes.\n */\nexport function byteLength(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob.\n *\n * @example\n * ```typescript\n * // Calculate the length of the 'myString' field in bytes.\n * byteLength(\"myString\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the string in bytes.\n */\nexport function byteLength(fieldName: string): FunctionExpression;\nexport function byteLength(expr: Expression | string): FunctionExpression {\n const normalizedExpr = fieldOrExpression(expr);\n return normalizedExpr.byteLength();\n}\n\n/**\n * @beta\n * Creates an expression that reverses an array.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myArray' field.\n * arrayReverse(\"myArray\");\n * ```\n *\n * @param fieldName - The name of the field to reverse.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed array.\n */\nexport function arrayReverse(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that reverses an array.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myArray' field.\n * arrayReverse(field(\"myArray\"));\n * ```\n *\n * @param arrayExpression - An expression evaluating to an array value, which will be reversed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed array.\n */\nexport function arrayReverse(arrayExpression: Expression): FunctionExpression;\nexport function arrayReverse(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).arrayReverse();\n}\n\n/**\n * @beta\n * Creates an expression that computes e to the power of the expression's result.\n *\n * @example\n * ```typescript\n * // Compute e to the power of 2.\n * exp(constant(2));\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the exp of the numeric value.\n */\nexport function exp(expression: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that computes e to the power of the expression's result.\n *\n * @example\n * ```typescript\n * // Compute e to the power of the 'value' field.\n * exp('value');\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the exp of the numeric value.\n */\nexport function exp(fieldName: string): FunctionExpression;\n\nexport function exp(\n expressionOrFieldName: Expression | string\n): FunctionExpression {\n return fieldOrExpression(expressionOrFieldName).exp();\n}\n\n/**\n * @beta\n * Creates an expression that computes the ceiling of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the ceiling of the 'price' field.\n * ceil(\"price\");\n * ```\n *\n * @param fieldName - The name of the field to compute the ceiling of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the ceiling of the numeric value.\n */\nexport function ceil(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that computes the ceiling of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the ceiling of the 'price' field.\n * ceil(field(\"price\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which the ceiling will be computed for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the ceiling of the numeric value.\n */\nexport function ceil(expression: Expression): FunctionExpression;\nexport function ceil(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).ceil();\n}\n\n/**\n * @beta\n * Creates an expression that computes the floor of a numeric value.\n *\n * @param expr - The expression to compute the floor of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the floor of the numeric value.\n */\nexport function floor(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that computes the floor of a numeric value.\n *\n * @param fieldName - The name of the field to compute the floor of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the floor of the numeric value.\n */\nexport function floor(fieldName: string): FunctionExpression;\nexport function floor(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).floor();\n}\n\n/**\n * @beta\n * Creates an aggregation that counts the number of distinct values of a field.\n *\n * @param expr - The expression or field to count distinct values of.\n * @returns A new `AggregateFunction` representing the 'count_distinct' aggregation.\n */\nexport function countDistinct(expr: Expression | string): AggregateFunction {\n return fieldOrExpression(expr).countDistinct();\n}\n\n/**\n * @beta\n *\n * Creates an expression that calculates the character length of a string field in UTF8.\n *\n * @example\n * ```typescript\n * // Get the character length of the 'name' field in UTF-8.\n * strLength(\"name\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the string.\n */\nexport function charLength(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that calculates the character length of a string expression in UTF-8.\n *\n * @example\n * ```typescript\n * // Get the character length of the 'name' field in UTF-8.\n * strLength(field(\"name\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to calculate the length of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the string.\n */\nexport function charLength(stringExpression: Expression): FunctionExpression;\nexport function charLength(value: Expression | string): FunctionExpression {\n const valueExpr = fieldOrExpression(value);\n return valueExpr.charLength();\n}\n\n/**\n * @beta\n *\n * Creates an expression that performs a case-sensitive wildcard string comparison against a\n * field.\n *\n * @example\n * ```typescript\n * // Check if the 'title' field contains the string \"guide\"\n * like(\"title\", \"%guide%\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param pattern - The pattern to search for. You can use \"%\" as a wildcard character.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'like' comparison.\n */\nexport function like(fieldName: string, pattern: string): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that performs a case-sensitive wildcard string comparison against a\n * field.\n *\n * @example\n * ```typescript\n * // Check if the 'title' field contains the string \"guide\"\n * like(\"title\", field(\"pattern\"));\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param pattern - The pattern to search for. You can use \"%\" as a wildcard character.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'like' comparison.\n */\nexport function like(fieldName: string, pattern: Expression): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that performs a case-sensitive wildcard string comparison.\n *\n * @example\n * ```typescript\n * // Check if the 'title' field contains the string \"guide\"\n * like(field(\"title\"), \"%guide%\");\n * ```\n *\n * @param stringExpression - The expression representing the string to perform the comparison on.\n * @param pattern - The pattern to search for. You can use \"%\" as a wildcard character.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'like' comparison.\n */\nexport function like(\n stringExpression: Expression,\n pattern: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that performs a case-sensitive wildcard string comparison.\n *\n * @example\n * ```typescript\n * // Check if the 'title' field contains the string \"guide\"\n * like(field(\"title\"), field(\"pattern\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to perform the comparison on.\n * @param pattern - The pattern to search for. You can use \"%\" as a wildcard character.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'like' comparison.\n */\nexport function like(\n stringExpression: Expression,\n pattern: Expression\n): BooleanExpression;\nexport function like(\n left: Expression | string,\n pattern: Expression | string\n): BooleanExpression {\n const leftExpr = fieldOrExpression(left);\n const patternExpr = valueToDefaultExpr(pattern);\n return leftExpr.like(patternExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string field contains a specified regular expression as\n * a substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\" (case-insensitive)\n * regexContains(\"description\", \"(?i)example\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param pattern - The regular expression to use for the search.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function regexContains(\n fieldName: string,\n pattern: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string field contains a specified regular expression as\n * a substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\" (case-insensitive)\n * regexContains(\"description\", field(\"pattern\"));\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param pattern - The regular expression to use for the search.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function regexContains(\n fieldName: string,\n pattern: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression contains a specified regular\n * expression as a substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\" (case-insensitive)\n * regexContains(field(\"description\"), \"(?i)example\");\n * ```\n *\n * @param stringExpression - The expression representing the string to perform the comparison on.\n * @param pattern - The regular expression to use for the search.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function regexContains(\n stringExpression: Expression,\n pattern: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression contains a specified regular\n * expression as a substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\" (case-insensitive)\n * regexContains(field(\"description\"), field(\"pattern\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to perform the comparison on.\n * @param pattern - The regular expression to use for the search.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function regexContains(\n stringExpression: Expression,\n pattern: Expression\n): BooleanExpression;\nexport function regexContains(\n left: Expression | string,\n pattern: Expression | string\n): BooleanExpression {\n const leftExpr = fieldOrExpression(left);\n const patternExpr = valueToDefaultExpr(pattern);\n return leftExpr.regexContains(patternExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that returns the first substring of a string field that matches a\n * specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract the domain name from an email field\n * regexFind(\"email\", \"@[A-Za-z0-9.-]+\");\n * ```\n *\n * @param fieldName - The name of the field containing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression find function.\n */\nexport function regexFind(\n fieldName: string,\n pattern: string\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the first substring of a string field that matches a\n * specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract a substring from 'email' based on a pattern stored in another field\n * regexFind(\"email\", field(\"pattern\"));\n * ```\n *\n * @param fieldName - The name of the field containing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression find function.\n */\nexport function regexFind(\n fieldName: string,\n pattern: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the first substring of a string expression that matches\n * a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract the domain from a lower-cased email address\n * regexFind(field(\"email\"), \"@[A-Za-z0-9.-]+\");\n * ```\n *\n * @param stringExpression - The expression representing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression find function.\n */\nexport function regexFind(\n stringExpression: Expression,\n pattern: string\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that returns the first substring of a string expression that matches\n * a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract a substring based on a dynamic pattern field\n * regexFind(field(\"email\"), field(\"pattern\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression find function.\n */\nexport function regexFind(\n stringExpression: Expression,\n pattern: Expression\n): FunctionExpression;\nexport function regexFind(\n left: Expression | string,\n pattern: Expression | string\n): FunctionExpression {\n const leftExpr = fieldOrExpression(left);\n const patternExpr = valueToDefaultExpr(pattern);\n return leftExpr.regexFind(patternExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that evaluates to a list of all substrings in a string field that\n * match a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract all hashtags from a post content field\n * regexFindAll(\"content\", \"#[A-Za-z0-9_]+\");\n * ```\n *\n * @param fieldName - The name of the field containing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#FunctionExpression} that evaluates to an array of matched substrings.\n */\nexport function regexFindAll(\n fieldName: string,\n pattern: string\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that evaluates to a list of all substrings in a string field that\n * match a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract all matches from 'content' based on a pattern stored in another field\n * regexFindAll(\"content\", field(\"pattern\"));\n * ```\n *\n * @param fieldName - The name of the field containing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#FunctionExpression} that evaluates to an array of matched substrings.\n */\nexport function regexFindAll(\n fieldName: string,\n pattern: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that evaluates to a list of all substrings in a string expression\n * that match a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract all mentions from a lower-cased comment\n * regexFindAll(field(\"comment\"), \"@[A-Za-z0-9_]+\");\n * ```\n *\n * @param stringExpression - The expression representing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#FunctionExpression} that evaluates to an array of matched substrings.\n */\nexport function regexFindAll(\n stringExpression: Expression,\n pattern: string\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that evaluates to a list of all substrings in a string expression\n * that match a specified regular expression.\n *\n * This expression uses the {@link https://github.com/google/re2/wiki/Syntax | RE2} regular expression syntax.\n *\n * @example\n * ```typescript\n * // Extract all matches based on a dynamic pattern expression\n * regexFindAll(field(\"comment\"), field(\"pattern\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to search.\n * @param pattern - The regular expression to search for.\n * @returns A new {@link @firebase/firestore/pipelines#FunctionExpression} that evaluates to an array of matched substrings.\n */\nexport function regexFindAll(\n stringExpression: Expression,\n pattern: Expression\n): FunctionExpression;\nexport function regexFindAll(\n left: Expression | string,\n pattern: Expression | string\n): FunctionExpression {\n const leftExpr = fieldOrExpression(left);\n const patternExpr = valueToDefaultExpr(pattern);\n return leftExpr.regexFindAll(patternExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string field matches a specified regular expression.\n *\n * @example\n * ```typescript\n * // Check if the 'email' field matches a valid email pattern\n * regexMatch(\"email\", \"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2,}\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param pattern - The regular expression to use for the match.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression match.\n */\nexport function regexMatch(\n fieldName: string,\n pattern: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string field matches a specified regular expression.\n *\n * @example\n * ```typescript\n * // Check if the 'email' field matches a valid email pattern\n * regexMatch(\"email\", field(\"pattern\"));\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param pattern - The regular expression to use for the match.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression match.\n */\nexport function regexMatch(\n fieldName: string,\n pattern: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression matches a specified regular\n * expression.\n *\n * @example\n * ```typescript\n * // Check if the 'email' field matches a valid email pattern\n * regexMatch(field(\"email\"), \"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\\\.[A-Za-z]{2,}\");\n * ```\n *\n * @param stringExpression - The expression representing the string to match against.\n * @param pattern - The regular expression to use for the match.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression match.\n */\nexport function regexMatch(\n stringExpression: Expression,\n pattern: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression matches a specified regular\n * expression.\n *\n * @example\n * ```typescript\n * // Check if the 'email' field matches a valid email pattern\n * regexMatch(field(\"email\"), field(\"pattern\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to match against.\n * @param pattern - The regular expression to use for the match.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the regular expression match.\n */\nexport function regexMatch(\n stringExpression: Expression,\n pattern: Expression\n): BooleanExpression;\nexport function regexMatch(\n left: Expression | string,\n pattern: Expression | string\n): BooleanExpression {\n const leftExpr = fieldOrExpression(left);\n const patternExpr = valueToDefaultExpr(pattern);\n return leftExpr.regexMatch(patternExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string field contains a specified substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\".\n * stringContains(\"description\", \"example\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param substring - The substring to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function stringContains(\n fieldName: string,\n substring: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string field contains a substring specified by an expression.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains the value of the 'keyword' field.\n * stringContains(\"description\", field(\"keyword\"));\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @param substring - The expression representing the substring to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function stringContains(\n fieldName: string,\n substring: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression contains a specified substring.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains \"example\".\n * stringContains(field(\"description\"), \"example\");\n * ```\n *\n * @param stringExpression - The expression representing the string to perform the comparison on.\n * @param substring - The substring to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function stringContains(\n stringExpression: Expression,\n substring: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression contains a substring specified by another expression.\n *\n * @example\n * ```typescript\n * // Check if the 'description' field contains the value of the 'keyword' field.\n * stringContains(field(\"description\"), field(\"keyword\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to perform the comparison on.\n * @param substring - The expression representing the substring to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'contains' comparison.\n */\nexport function stringContains(\n stringExpression: Expression,\n substring: Expression\n): BooleanExpression;\nexport function stringContains(\n left: Expression | string,\n substring: Expression | string\n): BooleanExpression {\n const leftExpr = fieldOrExpression(left);\n const substringExpr = valueToDefaultExpr(substring);\n return leftExpr.stringContains(substringExpr);\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value starts with a given prefix.\n *\n * @example\n * ```typescript\n * // Check if the 'name' field starts with \"Mr.\"\n * startsWith(\"name\", \"Mr.\");\n * ```\n *\n * @param fieldName - The field name to check.\n * @param prefix - The prefix to check for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'starts with' comparison.\n */\nexport function startsWith(\n fieldName: string,\n prefix: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value starts with a given prefix.\n *\n * @example\n * ```typescript\n * // Check if the 'fullName' field starts with the value of the 'firstName' field\n * startsWith(\"fullName\", field(\"firstName\"));\n * ```\n *\n * @param fieldName - The field name to check.\n * @param prefix - The expression representing the prefix.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'starts with' comparison.\n */\nexport function startsWith(\n fieldName: string,\n prefix: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression starts with a given prefix.\n *\n * @example\n * ```typescript\n * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with \"Mr.\"\n * startsWith(field(\"fullName\"), \"Mr.\");\n * ```\n *\n * @param stringExpression - The expression to check.\n * @param prefix - The prefix to check for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'starts with' comparison.\n */\nexport function startsWith(\n stringExpression: Expression,\n prefix: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression starts with a given prefix.\n *\n * @example\n * ```typescript\n * // Check if the result of concatenating 'firstName' and 'lastName' fields starts with \"Mr.\"\n * startsWith(field(\"fullName\"), field(\"prefix\"));\n * ```\n *\n * @param stringExpression - The expression to check.\n * @param prefix - The prefix to check for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'starts with' comparison.\n */\nexport function startsWith(\n stringExpression: Expression,\n prefix: Expression\n): BooleanExpression;\nexport function startsWith(\n expr: Expression | string,\n prefix: Expression | string\n): BooleanExpression {\n return fieldOrExpression(expr).startsWith(valueToDefaultExpr(prefix));\n}\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value ends with a given postfix.\n *\n * @example\n * ```typescript\n * // Check if the 'filename' field ends with \".txt\"\n * endsWith(\"filename\", \".txt\");\n * ```\n *\n * @param fieldName - The field name to check.\n * @param suffix - The postfix to check for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ends with' comparison.\n */\nexport function endsWith(fieldName: string, suffix: string): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a field's value ends with a given postfix.\n *\n * @example\n * ```typescript\n * // Check if the 'url' field ends with the value of the 'extension' field\n * endsWith(\"url\", field(\"extension\"));\n * ```\n *\n * @param fieldName - The field name to check.\n * @param suffix - The expression representing the postfix.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ends with' comparison.\n */\nexport function endsWith(\n fieldName: string,\n suffix: Expression\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression ends with a given postfix.\n *\n * @example\n * ```typescript\n * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with \"Jr.\"\n * endsWith(field(\"fullName\"), \"Jr.\");\n * ```\n *\n * @param stringExpression - The expression to check.\n * @param suffix - The postfix to check for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ends with' comparison.\n */\nexport function endsWith(\n stringExpression: Expression,\n suffix: string\n): BooleanExpression;\n\n/**\n * @beta\n *\n * Creates an expression that checks if a string expression ends with a given postfix.\n *\n * @example\n * ```typescript\n * // Check if the result of concatenating 'firstName' and 'lastName' fields ends with \"Jr.\"\n * endsWith(field(\"fullName\"), constant(\"Jr.\"));\n * ```\n *\n * @param stringExpression - The expression to check.\n * @param suffix - The postfix to check for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the 'ends with' comparison.\n */\nexport function endsWith(\n stringExpression: Expression,\n suffix: Expression\n): BooleanExpression;\nexport function endsWith(\n expr: Expression | string,\n suffix: Expression | string\n): BooleanExpression {\n return fieldOrExpression(expr).endsWith(valueToDefaultExpr(suffix));\n}\n\n/**\n * @beta\n *\n * Creates an expression that converts a string field to lowercase.\n *\n * @example\n * ```typescript\n * // Convert the 'name' field to lowercase\n * toLower(\"name\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the lowercase string.\n */\nexport function toLower(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that converts a string expression to lowercase.\n *\n * @example\n * ```typescript\n * // Convert the 'name' field to lowercase\n * toLower(field(\"name\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to convert to lowercase.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the lowercase string.\n */\nexport function toLower(stringExpression: Expression): FunctionExpression;\nexport function toLower(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).toLower();\n}\n\n/**\n * @beta\n *\n * Creates an expression that converts a string field to uppercase.\n *\n * @example\n * ```typescript\n * // Convert the 'title' field to uppercase\n * toUpper(\"title\");\n * ```\n *\n * @param fieldName - The name of the field containing the string.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the uppercase string.\n */\nexport function toUpper(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that converts a string expression to uppercase.\n *\n * @example\n * ```typescript\n * // Convert the 'title' field to uppercase\n * toUppercase(field(\"title\"));\n * ```\n *\n * @param stringExpression - The expression representing the string to convert to uppercase.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the uppercase string.\n */\nexport function toUpper(stringExpression: Expression): FunctionExpression;\nexport function toUpper(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).toUpper();\n}\n\n/**\n * @beta\n *\n * Creates an expression that removes leading and trailing whitespace from a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the 'userInput' field\n * trim(\"userInput\");\n *\n * // Trim quotes from the 'userInput' field\n * trim(\"userInput\", '\"');\n * ```\n *\n * @param fieldName - The name of the field containing the string or byte array.\n * @param valueToTrim - Optional This parameter is treated as a set of characters or bytes that will be\n * trimmed from the input. If not specified, then whitespace will be trimmed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the trimmed string.\n */\nexport function trim(\n fieldName: string,\n valueToTrim?: string | Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that removes leading and trailing characters from a string or byte array expression.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the 'userInput' field\n * trim(field(\"userInput\"));\n *\n * // Trim quotes from the 'userInput' field\n * trim(field(\"userInput\"), '\"');\n * ```\n *\n * @param stringExpression - The expression representing the string or byte array to trim.\n * @param valueToTrim - Optional This parameter is treated as a set of characters or bytes that will be\n * trimmed from the input. If not specified, then whitespace will be trimmed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the trimmed string or byte array.\n */\nexport function trim(\n stringExpression: Expression,\n valueToTrim?: string | Expression\n): FunctionExpression;\nexport function trim(\n expr: Expression | string,\n valueToTrim?: string | Expression\n): FunctionExpression {\n return fieldOrExpression(expr).trim(valueToTrim);\n}\n\n/**\n * @beta\n * Trims whitespace or a specified set of characters/bytes from the beginning of a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the beginning of the 'userInput' field\n * ltrim(field(\"userInput\"));\n *\n * // Trim quotes from the beginning of the 'userInput' field\n * ltrim(field(\"userInput\"), '\"');\n * ```\n *\n * @param fieldName - The name of the field containing the string or byte array.\n * @param valueToTrim - Optional. A string or byte array containing the characters/bytes to trim.\n * If not specified, whitespace will be trimmed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the trimmed string or byte array.\n */\nexport function ltrim(\n fieldName: string,\n valueToTrim?: string | Expression | Bytes\n): FunctionExpression;\n\n/**\n * @beta\n * Trims whitespace or a specified set of characters/bytes from the beginning of a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the beginning of the 'userInput' field\n * ltrim(field(\"userInput\"));\n *\n * // Trim quotes from the beginning of the 'userInput' field\n * ltrim(field(\"userInput\"), '\"');\n * ```\n *\n * @param expression - The expression representing the string or byte array.\n * @param valueToTrim - Optional. A string or byte array containing the characters/bytes to trim.\n * If not specified, whitespace will be trimmed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the trimmed string or byte array.\n */\nexport function ltrim(\n expression: Expression,\n valueToTrim?: string | Expression | Bytes\n): FunctionExpression;\nexport function ltrim(\n expr: Expression | string,\n valueToTrim?: string | Expression | Bytes\n): FunctionExpression {\n return fieldOrExpression(expr).ltrim(valueToTrim);\n}\n\n/**\n * @beta\n * Trims whitespace or a specified set of characters/bytes from the end of a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the end of the 'userInput' field\n * rtrim(field(\"userInput\"));\n *\n * // Trim quotes from the end of the 'userInput' field\n * rtrim(field(\"userInput\"), '\"');\n * ```\n *\n * @param fieldName - The name of the field containing the string or byte array.\n * @param valueToTrim - Optional. A string or byte array containing the characters/bytes to trim.\n * If not specified, whitespace will be trimmed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the trimmed string or byte array.\n */\nexport function rtrim(\n fieldName: string,\n valueToTrim?: string | Expression | Bytes\n): FunctionExpression;\n\n/**\n * @beta\n * Trims whitespace or a specified set of characters/bytes from the end of a string or byte array.\n *\n * @example\n * ```typescript\n * // Trim whitespace from the end of the 'userInput' field\n * rtrim(field(\"userInput\"));\n *\n * // Trim quotes from the end of the 'userInput' field\n * rtrim(field(\"userInput\"), '\"');\n * ```\n *\n * @param expression - The expression representing the string or byte array.\n * @param valueToTrim - Optional. A string or byte array containing the characters/bytes to trim.\n * If not specified, whitespace will be trimmed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the trimmed string or byte array.\n */\nexport function rtrim(\n expression: Expression,\n valueToTrim?: string | Expression | Bytes\n): FunctionExpression;\nexport function rtrim(\n expr: Expression | string,\n valueToTrim?: string | Expression | Bytes\n): FunctionExpression {\n return fieldOrExpression(expr).rtrim(valueToTrim);\n}\n\n/**\n * @beta\n * Creates an expression that returns the data type of the data in the specified field.\n *\n * @remarks\n * String inputs passed iteratively to this global function act as `field()` path lookups.\n * If you wish to pass a string literal value, it must be wrapped: `type(constant(\"my_string\"))`.\n *\n * @example\n * ```typescript\n * // Get the data type of the value in field 'title'\n * type('title')\n * ```\n *\n * @returns A new `Expression` representing the data type.\n */\nexport function type(fieldName: string): FunctionExpression;\n/**\n * @beta\n * Creates an expression that returns the data type of an expression's result.\n *\n * @example\n * ```typescript\n * // Get the data type of a conditional expression\n * type(conditional(exists('foo'), constant(1), constant(true)))\n * ```\n *\n * @returns A new `Expression` representing the data type.\n */\nexport function type(expression: Expression): FunctionExpression;\nexport function type(\n fieldNameOrExpression: string | Expression\n): FunctionExpression {\n return fieldOrExpression(fieldNameOrExpression).type();\n}\n\n/**\n * @beta\n * Creates an expression that checks if the value in the specified field is of the given type.\n *\n * @remarks Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data.\n *\n * @example\n * ```typescript\n * // Check if the 'price' field is a floating point number (evaluating to true inside pipeline conditionals)\n * isType('price', 'float64');\n * ```\n *\n * @param fieldName - The name of the field to check.\n * @param type - The type to check for.\n * @returns A new `BooleanExpression` that evaluates to true if the field's value is of the given type, false otherwise.\n */\nexport function isType(fieldName: string, type: Type): BooleanExpression;\n\n/**\n * @beta\n * Creates an expression that checks if the result of an expression is of the given type.\n *\n * @remarks Null or undefined fields evaluate to skip/error. Use `ifAbsent()` / `isAbsent()` to evaluate missing data.\n *\n * @example\n * ```typescript\n * // Check if the result of a calculation is a number\n * isType(add('count', 1), 'number')\n * ```\n *\n * @param expression - The expression to check.\n * @param type - The type to check for.\n * @returns A new `BooleanExpression` that evaluates to true if the expression's result is of the given type, false otherwise.\n */\nexport function isType(expression: Expression, type: Type): BooleanExpression;\nexport function isType(\n fieldNameOrExpression: string | Expression,\n type: Type\n): BooleanExpression {\n return fieldOrExpression(fieldNameOrExpression).isType(type);\n}\n\n/**\n * @beta\n *\n * Creates an expression that concatenates string functions, fields or constants together.\n *\n * @example\n * ```typescript\n * // Combine the 'firstName', \" \", and 'lastName' fields into a single string\n * stringConcat(\"firstName\", \" \", field(\"lastName\"));\n * ```\n *\n * @param fieldName - The field name containing the initial string value.\n * @param secondString - An expression or string literal to concatenate.\n * @param otherStrings - Optional additional expressions or literals (typically strings) to concatenate.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the concatenated string.\n */\nexport function stringConcat(\n fieldName: string,\n secondString: Expression | string,\n ...otherStrings: Array<Expression | string>\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that concatenates string expressions together.\n *\n * @example\n * ```typescript\n * // Combine the 'firstName', \" \", and 'lastName' fields into a single string\n * stringConcat(field(\"firstName\"), \" \", field(\"lastName\"));\n * ```\n *\n * @param firstString - The initial string expression to concatenate to.\n * @param secondString - An expression or string literal to concatenate.\n * @param otherStrings - Optional additional expressions or literals (typically strings) to concatenate.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the concatenated string.\n */\nexport function stringConcat(\n firstString: Expression,\n secondString: Expression | string,\n ...otherStrings: Array<Expression | string>\n): FunctionExpression;\nexport function stringConcat(\n first: string | Expression,\n second: string | Expression,\n ...elements: Array<string | Expression>\n): FunctionExpression {\n return fieldOrExpression(first).stringConcat(\n valueToDefaultExpr(second),\n ...elements.map(valueToDefaultExpr)\n );\n}\n\n/**\n * @beta\n * Creates an expression that finds the index of the first occurrence of a substring or byte sequence.\n *\n * @example\n * ```typescript\n * // Find the index of \"foo\" in the 'text' field\n * stringIndexOf(\"text\", \"foo\");\n * ```\n *\n * @param fieldName - The name of the field containing the string or byte array.\n * @param search - The substring or byte sequence to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the index of the first occurrence.\n */\nexport function stringIndexOf(\n fieldName: string,\n search: string | Expression | Bytes\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that finds the index of the first occurrence of a substring or byte sequence.\n *\n * @example\n * ```typescript\n * // Find the index of \"foo\" in the 'text' field\n * stringIndexOf(field(\"text\"), \"foo\");\n * ```\n *\n * @param expression - The expression representing the string or byte array.\n * @param search - The substring or byte sequence to search for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the index of the first occurrence.\n */\nexport function stringIndexOf(\n expression: Expression,\n search: string | Expression | Bytes\n): FunctionExpression;\nexport function stringIndexOf(\n expr: Expression | string,\n search: string | Expression | Bytes\n): FunctionExpression {\n return fieldOrExpression(expr).stringIndexOf(search);\n}\n\n/**\n * @beta\n * Creates an expression that repeats a string or byte array a specified number of times.\n *\n * @example\n * ```typescript\n * // Repeat the 'label' field 3 times\n * stringRepeat(\"label\", 3);\n * ```\n *\n * @param fieldName - The name of the field containing the string or byte array.\n * @param repetitions - The number of times to repeat the string or byte array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the repeated string or byte array.\n */\nexport function stringRepeat(\n fieldName: string,\n repetitions: number | Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that repeats a string or byte array a specified number of times.\n *\n * @example\n * ```typescript\n * // Repeat the 'label' field 3 times\n * stringRepeat(field(\"label\"), 3);\n * ```\n *\n * @param expression - The expression representing the string or byte array.\n * @param repetitions - The number of times to repeat the string or byte array.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the repeated string or byte array.\n */\nexport function stringRepeat(\n expression: Expression,\n repetitions: number | Expression\n): FunctionExpression;\nexport function stringRepeat(\n expr: Expression | string,\n repetitions: number | Expression\n): FunctionExpression {\n return fieldOrExpression(expr).stringRepeat(repetitions);\n}\n\n/**\n * @beta\n * Creates an expression that replaces all occurrences of a substring or byte sequence with a replacement.\n *\n * @example\n * ```typescript\n * // Replace all occurrences of \"foo\" with \"bar\" in the 'text' field\n * stringReplaceAll(\"text\", \"foo\", \"bar\");\n * ```\n *\n * @param fieldName - The name of the field containing the string or byte array.\n * @param find - The substring or byte sequence to search for.\n * @param replacement - The replacement string or byte sequence.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the string or byte array with replacements.\n */\nexport function stringReplaceAll(\n fieldName: string,\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that replaces all occurrences of a substring or byte sequence with a replacement.\n *\n * @example\n * ```typescript\n * // Replace all occurrences of \"foo\" with \"bar\" in the 'text' field\n * stringReplaceAll(field(\"text\"), \"foo\", \"bar\");\n * ```\n *\n * @param expression - The expression representing the string or byte array.\n * @param find - The substring or byte sequence to search for.\n * @param replacement - The replacement string or byte sequence.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the string or byte array with replacements.\n */\nexport function stringReplaceAll(\n expression: Expression,\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n): FunctionExpression;\nexport function stringReplaceAll(\n expr: Expression | string,\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n): FunctionExpression {\n return fieldOrExpression(expr).stringReplaceAll(find, replacement);\n}\n\n/**\n * @beta\n * Creates an expression that replaces the first occurrence of a substring or byte sequence with a replacement.\n *\n * @example\n * ```typescript\n * // Replace the first occurrence of \"foo\" with \"bar\" in the 'text' field\n * stringReplaceOne(\"text\", \"foo\", \"bar\");\n * ```\n *\n * @param fieldName - The name of the field containing the string or byte array.\n * @param find - The substring or byte sequence to search for.\n * @param replacement - The replacement string or byte sequence.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the string or byte array with the replacement.\n */\nexport function stringReplaceOne(\n fieldName: string,\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that replaces the first occurrence of a substring or byte sequence with a replacement.\n *\n * @example\n * ```typescript\n * // Replace the first occurrence of \"foo\" with \"bar\" in the 'text' field\n * stringReplaceOne(field(\"text\"), \"foo\", \"bar\");\n * ```\n *\n * @param expression - The expression representing the string or byte array.\n * @param find - The substring or byte sequence to search for.\n * @param replacement - The replacement string or byte sequence.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the string or byte array with the replacement.\n */\nexport function stringReplaceOne(\n expression: Expression,\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n): FunctionExpression;\nexport function stringReplaceOne(\n expr: Expression | string,\n find: string | Expression | Bytes,\n replacement: string | Expression | Bytes\n): FunctionExpression {\n return fieldOrExpression(expr).stringReplaceOne(find, replacement);\n}\n\n/**\n * @beta\n *\n * Accesses a value from a map (object) field using the provided key.\n *\n * @example\n * ```typescript\n * // Get the 'city' value from the 'address' map field\n * mapGet(\"address\", \"city\");\n * ```\n *\n * @param fieldName - The field name of the map field.\n * @param subField - The key to access in the map.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the value associated with the given key in the map.\n */\nexport function mapGet(fieldName: string, subField: string): FunctionExpression;\n\n/**\n * @beta\n *\n * Accesses a value from a map (object) expression using the provided key.\n *\n * @example\n * ```typescript\n * // Get the 'city' value from the 'address' map field\n * mapGet(field(\"address\"), \"city\");\n * ```\n *\n * @param mapExpression - The expression representing the map.\n * @param subField - The key to access in the map.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the value associated with the given key in the map.\n */\nexport function mapGet(\n mapExpression: Expression,\n subField: string\n): FunctionExpression;\nexport function mapGet(\n fieldOrExpr: string | Expression,\n subField: string\n): FunctionExpression {\n return fieldOrExpression(fieldOrExpr).mapGet(subField);\n}\n\n/**\n * @beta\n * Creates an expression that returns a new map with the specified entries added or updated.\n *\n * @remarks\n * This only performs shallow updates to the map. Setting a value to `null`\n * will retain the key with a `null` value. To remove a key entirely, use `mapRemove`.\n *\n * @example\n * ```typescript\n * // Set the 'city' to 'San Francisco' in the 'address' map field\n * mapSet(\"address\", \"city\", \"San Francisco\");\n * ```\n *\n * @param mapField - The map field to set entries in.\n * @param key - The key to set. Must be a string or a constant string expression.\n * @param value - The value to set.\n * @param moreKeyValues - Additional key-value pairs to set.\n * @returns A new `Expression` representing the map with the entries set.\n */\nexport function mapSet(\n mapField: string,\n key: string | Expression,\n value: unknown,\n ...moreKeyValues: unknown[]\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns a new map with the specified entries added or updated.\n *\n * @remarks\n * This only performs shallow updates to the map. Setting a value to `null`\n * will retain the key with a `null` value. To remove a key entirely, use `mapRemove`.\n *\n * @example\n * ```typescript\n * // Set the 'city' to \"San Francisco\"\n * mapSet(map({\"state\": \"California\"}), \"city\", \"San Francisco\");\n * ```\n *\n * @param mapExpression - The expression representing the map.\n * @param key - The key to set. Must be a string or a constant string expression.\n * @param value - The value to set.\n * @param moreKeyValues - Additional key-value pairs to set.\n * @returns A new `Expression` representing the map with the entries set.\n */\nexport function mapSet(\n mapExpression: Expression,\n key: string | Expression,\n value: unknown,\n ...moreKeyValues: unknown[]\n): FunctionExpression;\nexport function mapSet(\n fieldOrExpr: string | Expression,\n key: string | Expression,\n value: unknown,\n ...moreKeyValues: unknown[]\n): FunctionExpression {\n return fieldOrExpression(fieldOrExpr).mapSet(key, value, ...moreKeyValues);\n}\n\n/**\n * @beta\n * Creates an expression that returns the keys of a map.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the keys of the 'address' map field\n * mapKeys(\"address\");\n * ```\n *\n * @param mapField - The map field to get the keys of.\n * @returns A new `Expression` representing the keys of the map.\n */\nexport function mapKeys(mapField: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns the keys of a map.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the keys of the map expression\n * mapKeys(map({\"city\": \"San Francisco\"}));\n * ```\n *\n * @param mapExpression - The expression representing the map to get the keys of.\n * @returns A new `Expression` representing the keys of the map.\n */\nexport function mapKeys(mapExpression: Expression): FunctionExpression;\nexport function mapKeys(fieldOrExpr: string | Expression): FunctionExpression {\n return fieldOrExpression(fieldOrExpr).mapKeys();\n}\n\n/**\n * @beta\n * Creates an expression that returns the values of a map.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the values of the 'address' map field\n * mapValues(\"address\");\n * ```\n *\n * @param mapField - The map field to get the values of.\n * @returns A new `Expression` representing the values of the map.\n */\nexport function mapValues(mapField: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns the values of a map.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the values of the map expression\n * mapValues(map({\"city\": \"San Francisco\"}));\n * ```\n *\n * @param mapExpression - The expression representing the map to get the values of.\n * @returns A new `Expression` representing the values of the map.\n */\nexport function mapValues(mapExpression: Expression): FunctionExpression;\nexport function mapValues(\n fieldOrExpr: string | Expression\n): FunctionExpression {\n return fieldOrExpression(fieldOrExpr).mapValues();\n}\n\n/**\n * @beta\n * Creates an expression that returns the entries of a map as an array of maps,\n * where each map contains a `\"k\"` property for the key and a `\"v\"` property for the value.\n * For example: `[{ k: \"key1\", v: \"value1\" }, ...]`.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the entries of the 'address' map field\n * mapEntries(\"address\");\n * ```\n *\n * @param mapField - The map field to get the entries of.\n * @returns A new `Expression` representing the entries of the map.\n */\nexport function mapEntries(mapField: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns the entries of a map as an array of maps,\n * where each map contains a `\"k\"` property for the key and a `\"v\"` property for the value.\n * For example: `[{ k: \"key1\", v: \"value1\" }, ...]`.\n *\n * @remarks\n * While the backend generally preserves insertion order, relying on the\n * order of the output array is not guaranteed and should be avoided.\n *\n * @example\n * ```typescript\n * // Get the entries of the map expression\n * mapEntries(map({\"city\": \"San Francisco\"}));\n * ```\n *\n * @param mapExpression - The expression representing the map to get the entries of.\n * @returns A new `Expression` representing the entries of the map.\n */\nexport function mapEntries(mapExpression: Expression): FunctionExpression;\nexport function mapEntries(\n fieldOrExpr: string | Expression\n): FunctionExpression {\n return fieldOrExpression(fieldOrExpr).mapEntries();\n}\n\n/**\n * @beta\n *\n * Creates an aggregation that counts the total number of stage inputs.\n *\n * @example\n * ```typescript\n * // Count the total number of input documents\n * countAll().as(\"totalDocument\");\n * ```\n *\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'countAll' aggregation.\n */\nexport function countAll(): AggregateFunction {\n return AggregateFunction._create('count', [], 'count');\n}\n\n/**\n * @beta\n *\n * Creates an aggregation that counts the number of stage inputs with valid evaluations of the\n * provided expression.\n *\n * @example\n * ```typescript\n * // Count the number of items where the price is greater than 10\n * count(field(\"price\").greaterThan(10)).as(\"expensiveItemCount\");\n * ```\n *\n * @param expression - The expression to count.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'count' aggregation.\n */\nexport function count(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n * Creates an aggregation that counts the number of stage inputs where the input field exists.\n *\n * @example\n * ```typescript\n * // Count the total number of products\n * count(\"productId\").as(\"totalProducts\");\n * ```\n *\n * @param fieldName - The name of the field to count.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'count' aggregation.\n */\nexport function count(fieldName: string): AggregateFunction;\nexport function count(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).count();\n}\n\n/**\n * @beta\n *\n * Creates an aggregation that calculates the sum of values from an expression across multiple\n * stage inputs.\n *\n * @example\n * ```typescript\n * // Calculate the total revenue from a set of orders\n * sum(field(\"orderAmount\")).as(\"totalRevenue\");\n * ```\n *\n * @param expression - The expression to sum up.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'sum' aggregation.\n */\nexport function sum(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n *\n * Creates an aggregation that calculates the sum of a field's values across multiple stage\n * inputs.\n *\n * @example\n * ```typescript\n * // Calculate the total revenue from a set of orders\n * sum(\"orderAmount\").as(\"totalRevenue\");\n * ```\n *\n * @param fieldName - The name of the field containing numeric values to sum up.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'sum' aggregation.\n */\nexport function sum(fieldName: string): AggregateFunction;\nexport function sum(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).sum();\n}\n\n/**\n * @beta\n *\n * Creates an aggregation that calculates the average (mean) of values from an expression across\n * multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Calculate the average age of users\n * average(field(\"age\")).as(\"averageAge\");\n * ```\n *\n * @param expression - The expression representing the values to average.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'average' aggregation.\n */\nexport function average(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n *\n * Creates an aggregation that calculates the average (mean) of a field's values across multiple\n * stage inputs.\n *\n * @example\n * ```typescript\n * // Calculate the average age of users\n * average(\"age\").as(\"averageAge\");\n * ```\n *\n * @param fieldName - The name of the field containing numeric values to average.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'average' aggregation.\n */\nexport function average(fieldName: string): AggregateFunction;\nexport function average(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).average();\n}\n\n/**\n * @beta\n *\n * Creates an aggregation that finds the minimum value of an expression across multiple stage\n * inputs.\n *\n * @example\n * ```typescript\n * // Find the lowest price of all products\n * minimum(field(\"price\")).as(\"lowestPrice\");\n * ```\n *\n * @param expression - The expression to find the minimum value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'minimum' aggregation.\n */\nexport function minimum(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n *\n * Creates an aggregation that finds the minimum value of a field across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the lowest price of all products\n * minimum(\"price\").as(\"lowestPrice\");\n * ```\n *\n * @param fieldName - The name of the field to find the minimum value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'minimum' aggregation.\n */\nexport function minimum(fieldName: string): AggregateFunction;\nexport function minimum(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).minimum();\n}\n\n/**\n * @beta\n *\n * Creates an aggregation that finds the maximum value of an expression across multiple stage\n * inputs.\n *\n * @example\n * ```typescript\n * // Find the highest score in a leaderboard\n * maximum(field(\"score\")).as(\"highestScore\");\n * ```\n *\n * @param expression - The expression to find the maximum value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'maximum' aggregation.\n */\nexport function maximum(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n *\n * Creates an aggregation that finds the maximum value of a field across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the highest score in a leaderboard\n * maximum(\"score\").as(\"highestScore\");\n * ```\n *\n * @param fieldName - The name of the field to find the maximum value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'maximum' aggregation.\n */\nexport function maximum(fieldName: string): AggregateFunction;\nexport function maximum(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).maximum();\n}\n\n/**\n * @beta\n * Creates an aggregation that finds the first value of an expression across multiple stage\n * inputs.\n *\n * @example\n * ```typescript\n * // Find the first value of the 'rating' field\n * first(field(\"rating\")).as(\"firstRating\");\n * ```\n *\n * @param expression - The expression to find the first value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'first' aggregation.\n */\nexport function first(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n * Creates an aggregation that finds the first value of a field across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the first value of the 'rating' field\n * first(\"rating\").as(\"firstRating\");\n * ```\n *\n * @param fieldName - The name of the field to find the first value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'first' aggregation.\n */\nexport function first(fieldName: string): AggregateFunction;\nexport function first(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).first();\n}\n\n/**\n * @beta\n * Creates an aggregation that finds the last value of an expression across multiple stage\n * inputs.\n *\n * @example\n * ```typescript\n * // Find the last value of the 'rating' field\n * last(field(\"rating\")).as(\"lastRating\");\n * ```\n *\n * @param expression - The expression to find the last value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'last' aggregation.\n */\nexport function last(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n * Creates an aggregation that finds the last value of a field across multiple stage inputs.\n *\n * @example\n * ```typescript\n * // Find the last value of the 'rating' field\n * last(\"rating\").as(\"lastRating\");\n * ```\n *\n * @param fieldName - The name of the field to find the last value of.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'last' aggregation.\n */\nexport function last(fieldName: string): AggregateFunction;\nexport function last(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).last();\n}\n\n/**\n * @beta\n * Creates an aggregation that collects all values of an expression across multiple stage\n * inputs into an array.\n *\n * @remarks\n * If the expression resolves to an absent value, it is converted to `null`.\n * The order of elements in the output array is not stable and shouldn't be relied upon.\n *\n * @example\n * ```typescript\n * // Collect all tags from books into an array\n * arrayAgg(field(\"tags\")).as(\"allTags\");\n * ```\n *\n * @param expression - The expression to collect values from.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg' aggregation.\n */\nexport function arrayAgg(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n * Creates an aggregation that collects all values of a field across multiple stage inputs\n * into an array.\n *\n * @remarks\n * If the expression resolves to an absent value, it is converted to `null`.\n * The order of elements in the output array is not stable and shouldn't be relied upon.\n *\n * @example\n * ```typescript\n * // Collect all tags from books into an array\n * arrayAgg(\"tags\").as(\"allTags\");\n * ```\n *\n * @param fieldName - The name of the field to collect values from.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg' aggregation.\n */\nexport function arrayAgg(fieldName: string): AggregateFunction;\nexport function arrayAgg(value: Expression | string): AggregateFunction {\n return fieldOrExpression(value).arrayAgg();\n}\n\n/**\n * @beta\n * Creates an aggregation that collects all distinct values of an expression across multiple stage\n * inputs into an array.\n *\n * @remarks\n * If the expression resolves to an absent value, it is converted to `null`.\n * The order of elements in the output array is not stable and shouldn't be relied upon.\n *\n * @example\n * ```typescript\n * // Collect all distinct tags from books into an array\n * arrayAggDistinct(field(\"tags\")).as(\"allDistinctTags\");\n * ```\n *\n * @param expression - The expression to collect values from.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg_distinct' aggregation.\n */\nexport function arrayAggDistinct(expression: Expression): AggregateFunction;\n\n/**\n * @beta\n * Creates an aggregation that collects all distinct values of a field across multiple stage inputs\n * into an array.\n *\n * @remarks\n * If the expression resolves to an absent value, it is converted to `null`.\n * The order of elements in the output array is not stable and shouldn't be relied upon.\n *\n * @example\n * ```typescript\n * // Collect all distinct tags from books into an array\n * arrayAggDistinct(\"tags\").as(\"allDistinctTags\");\n * ```\n *\n * @param fieldName - The name of the field to collect values from.\n * @returns A new {@link @firebase/firestore/pipelines#AggregateFunction} representing the 'array_agg_distinct' aggregation.\n */\nexport function arrayAggDistinct(fieldName: string): AggregateFunction;\nexport function arrayAggDistinct(\n value: Expression | string\n): AggregateFunction {\n return fieldOrExpression(value).arrayAggDistinct();\n}\n\n/**\n * @beta\n *\n * Calculates the Cosine distance between a field's vector value and a literal vector value.\n *\n * @example\n * ```typescript\n * // Calculate the Cosine distance between the 'location' field and a target location\n * cosineDistance(\"location\", [37.7749, -122.4194]);\n * ```\n *\n * @param fieldName - The name of the field containing the first vector.\n * @param vector - The other vector (as an array of doubles) or {@link VectorValue} to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the Cosine distance between the two vectors.\n */\nexport function cosineDistance(\n fieldName: string,\n vector: number[] | VectorValue\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the Cosine distance between a field's vector value and a vector expression.\n *\n * @example\n * ```typescript\n * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field\n * cosineDistance(\"userVector\", field(\"itemVector\"));\n * ```\n *\n * @param fieldName - The name of the field containing the first vector.\n * @param vectorExpression - The other vector (represented as an `Expression`) to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the cosine distance between the two vectors.\n */\nexport function cosineDistance(\n fieldName: string,\n vectorExpression: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the Cosine distance between a vector expression and a vector literal.\n *\n * @example\n * ```typescript\n * // Calculate the cosine distance between the 'location' field and a target location\n * cosineDistance(field(\"location\"), [37.7749, -122.4194]);\n * ```\n *\n * @param vectorExpression - The first vector (represented as an `Expression`) to compare against.\n * @param vector - The other vector (as an array of doubles or VectorValue) to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the cosine distance between the two vectors.\n */\nexport function cosineDistance(\n vectorExpression: Expression,\n vector: number[] | VectorValue\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the Cosine distance between two vector expressions.\n *\n * @example\n * ```typescript\n * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field\n * cosineDistance(field(\"userVector\"), field(\"itemVector\"));\n * ```\n *\n * @param vectorExpression - The first vector (represented as an `Expression`) to compare against.\n * @param otherVectorExpression - The other vector (represented as an `Expression`) to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the cosine distance between the two vectors.\n */\nexport function cosineDistance(\n vectorExpression: Expression,\n otherVectorExpression: Expression\n): FunctionExpression;\nexport function cosineDistance(\n expr: Expression | string,\n other: Expression | number[] | VectorValue\n): FunctionExpression {\n const expr1 = fieldOrExpression(expr);\n const expr2 = vectorToExpr(other);\n return expr1.cosineDistance(expr2);\n}\n\n/**\n * @beta\n *\n * Calculates the dot product between a field's vector value and a double array.\n *\n * @example\n * ```typescript\n * // Calculate the dot product distance between a feature vector and a target vector\n * dotProduct(\"features\", [0.5, 0.8, 0.2]);\n * ```\n *\n * @param fieldName - The name of the field containing the first vector.\n * @param vector - The other vector (as an array of doubles or VectorValue) to calculate with.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the dot product between the two vectors.\n */\nexport function dotProduct(\n fieldName: string,\n vector: number[] | VectorValue\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the dot product between a field's vector value and a vector expression.\n *\n * @example\n * ```typescript\n * // Calculate the dot product distance between two document vectors: 'docVector1' and 'docVector2'\n * dotProduct(\"docVector1\", field(\"docVector2\"));\n * ```\n *\n * @param fieldName - The name of the field containing the first vector.\n * @param vectorExpression - The other vector (represented as an `Expression`) to calculate with.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the dot product between the two vectors.\n */\nexport function dotProduct(\n fieldName: string,\n vectorExpression: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the dot product between a vector expression and a double array.\n *\n * @example\n * ```typescript\n * // Calculate the dot product between a feature vector and a target vector\n * dotProduct(field(\"features\"), [0.5, 0.8, 0.2]);\n * ```\n *\n * @param vectorExpression - The first vector (represented as an `Expression`) to calculate with.\n * @param vector - The other vector (as an array of doubles or VectorValue) to calculate with.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the dot product between the two vectors.\n */\nexport function dotProduct(\n vectorExpression: Expression,\n vector: number[] | VectorValue\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the dot product between two vector expressions.\n *\n * @example\n * ```typescript\n * // Calculate the dot product between two document vectors: 'docVector1' and 'docVector2'\n * dotProduct(field(\"docVector1\"), field(\"docVector2\"));\n * ```\n *\n * @param vectorExpression - The first vector (represented as an `Expression`) to calculate with.\n * @param otherVectorExpression - The other vector (represented as an `Expression`) to calculate with.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the dot product between the two vectors.\n */\nexport function dotProduct(\n vectorExpression: Expression,\n otherVectorExpression: Expression\n): FunctionExpression;\nexport function dotProduct(\n expr: Expression | string,\n other: Expression | number[] | VectorValue\n): FunctionExpression {\n const expr1 = fieldOrExpression(expr);\n const expr2 = vectorToExpr(other);\n return expr1.dotProduct(expr2);\n}\n\n/**\n * @beta\n *\n * Calculates the Euclidean distance between a field's vector value and a double array.\n *\n * @example\n * ```typescript\n * // Calculate the Euclidean distance between the 'location' field and a target location\n * euclideanDistance(\"location\", [37.7749, -122.4194]);\n * ```\n *\n * @param fieldName - The name of the field containing the first vector.\n * @param vector - The other vector (as an array of doubles or VectorValue) to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the Euclidean distance between the two vectors.\n */\nexport function euclideanDistance(\n fieldName: string,\n vector: number[] | VectorValue\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the Euclidean distance between a field's vector value and a vector expression.\n *\n * @example\n * ```typescript\n * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB'\n * euclideanDistance(\"pointA\", field(\"pointB\"));\n * ```\n *\n * @param fieldName - The name of the field containing the first vector.\n * @param vectorExpression - The other vector (represented as an `Expression`) to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the Euclidean distance between the two vectors.\n */\nexport function euclideanDistance(\n fieldName: string,\n vectorExpression: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the Euclidean distance between a vector expression and a double array.\n *\n * @example\n * ```typescript\n * // Calculate the Euclidean distance between the 'location' field and a target location\n *\n * euclideanDistance(field(\"location\"), [37.7749, -122.4194]);\n * ```\n *\n * @param vectorExpression - The first vector (represented as an `Expression`) to compare against.\n * @param vector - The other vector (as an array of doubles or VectorValue) to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the Euclidean distance between the two vectors.\n */\nexport function euclideanDistance(\n vectorExpression: Expression,\n vector: number[] | VectorValue\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Calculates the Euclidean distance between two vector expressions.\n *\n * @example\n * ```typescript\n * // Calculate the Euclidean distance between two vector fields: 'pointA' and 'pointB'\n * euclideanDistance(field(\"pointA\"), field(\"pointB\"));\n * ```\n *\n * @param vectorExpression - The first vector (represented as an `Expression`) to compare against.\n * @param otherVectorExpression - The other vector (represented as an `Expression`) to compare against.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the Euclidean distance between the two vectors.\n */\nexport function euclideanDistance(\n vectorExpression: Expression,\n otherVectorExpression: Expression\n): FunctionExpression;\nexport function euclideanDistance(\n expr: Expression | string,\n other: Expression | number[] | VectorValue\n): FunctionExpression {\n const expr1 = fieldOrExpression(expr);\n const expr2 = vectorToExpr(other);\n return expr1.euclideanDistance(expr2);\n}\n\n/**\n * @beta\n *\n * Creates an expression that calculates the length of a Firestore Vector.\n *\n * @example\n * ```typescript\n * // Get the vector length (dimension) of the field 'embedding'.\n * vectorLength(field(\"embedding\"));\n * ```\n *\n * @param vectorExpression - The expression representing the Firestore Vector.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the array.\n */\nexport function vectorLength(vectorExpression: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that calculates the length of a Firestore Vector represented by a field.\n *\n * @example\n * ```typescript\n * // Get the vector length (dimension) of the field 'embedding'.\n * vectorLength(\"embedding\");\n * ```\n *\n * @param fieldName - The name of the field representing the Firestore Vector.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the length of the array.\n */\nexport function vectorLength(fieldName: string): FunctionExpression;\nexport function vectorLength(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).vectorLength();\n}\n\n/**\n * @beta\n *\n * Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'microseconds' field as microseconds since epoch.\n * unixMicrosToTimestamp(field(\"microseconds\"));\n * ```\n *\n * @param expr - The expression representing the number of microseconds since epoch.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\nexport function unixMicrosToTimestamp(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'microseconds' field as microseconds since epoch.\n * unixMicrosToTimestamp(\"microseconds\");\n * ```\n *\n * @param fieldName - The name of the field representing the number of microseconds since epoch.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\nexport function unixMicrosToTimestamp(fieldName: string): FunctionExpression;\nexport function unixMicrosToTimestamp(\n expr: Expression | string\n): FunctionExpression {\n return fieldOrExpression(expr).unixMicrosToTimestamp();\n}\n\n/**\n * @beta\n *\n * Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to microseconds since epoch.\n * timestampToUnixMicros(field(\"timestamp\"));\n * ```\n *\n * @param expr - The expression representing the timestamp.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of microseconds since epoch.\n */\nexport function timestampToUnixMicros(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to microseconds since epoch.\n * timestampToUnixMicros(\"timestamp\");\n * ```\n *\n * @param fieldName - The name of the field representing the timestamp.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of microseconds since epoch.\n */\nexport function timestampToUnixMicros(fieldName: string): FunctionExpression;\nexport function timestampToUnixMicros(\n expr: Expression | string\n): FunctionExpression {\n return fieldOrExpression(expr).timestampToUnixMicros();\n}\n\n/**\n * @beta\n *\n * Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'milliseconds' field as milliseconds since epoch.\n * unixMillisToTimestamp(field(\"milliseconds\"));\n * ```\n *\n * @param expr - The expression representing the number of milliseconds since epoch.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\nexport function unixMillisToTimestamp(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'milliseconds' field as milliseconds since epoch.\n * unixMillisToTimestamp(\"milliseconds\");\n * ```\n *\n * @param fieldName - The name of the field representing the number of milliseconds since epoch.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\nexport function unixMillisToTimestamp(fieldName: string): FunctionExpression;\nexport function unixMillisToTimestamp(\n expr: Expression | string\n): FunctionExpression {\n const normalizedExpr = fieldOrExpression(expr);\n return normalizedExpr.unixMillisToTimestamp();\n}\n\n/**\n * @beta\n *\n * Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to milliseconds since epoch.\n * timestampToUnixMillis(field(\"timestamp\"));\n * ```\n *\n * @param expr - The expression representing the timestamp.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of milliseconds since epoch.\n */\nexport function timestampToUnixMillis(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to milliseconds since epoch.\n * timestampToUnixMillis(\"timestamp\");\n * ```\n *\n * @param fieldName - The name of the field representing the timestamp.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of milliseconds since epoch.\n */\nexport function timestampToUnixMillis(fieldName: string): FunctionExpression;\nexport function timestampToUnixMillis(\n expr: Expression | string\n): FunctionExpression {\n const normalizedExpr = fieldOrExpression(expr);\n return normalizedExpr.timestampToUnixMillis();\n}\n\n/**\n * @beta\n *\n * Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'seconds' field as seconds since epoch.\n * unixSecondsToTimestamp(field(\"seconds\"));\n * ```\n *\n * @param expr - The expression representing the number of seconds since epoch.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\nexport function unixSecondsToTimestamp(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC)\n * and returns a timestamp.\n *\n * @example\n * ```typescript\n * // Interpret the 'seconds' field as seconds since epoch.\n * unixSecondsToTimestamp(\"seconds\");\n * ```\n *\n * @param fieldName - The name of the field representing the number of seconds since epoch.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the timestamp.\n */\nexport function unixSecondsToTimestamp(fieldName: string): FunctionExpression;\nexport function unixSecondsToTimestamp(\n expr: Expression | string\n): FunctionExpression {\n const normalizedExpr = fieldOrExpression(expr);\n return normalizedExpr.unixSecondsToTimestamp();\n}\n\n/**\n * @beta\n *\n * Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to seconds since epoch.\n * timestampToUnixSeconds(field(\"timestamp\"));\n * ```\n *\n * @param expr - The expression representing the timestamp.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of seconds since epoch.\n */\nexport function timestampToUnixSeconds(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).\n *\n * @example\n * ```typescript\n * // Convert the 'timestamp' field to seconds since epoch.\n * timestampToUnixSeconds(\"timestamp\");\n * ```\n *\n * @param fieldName - The name of the field representing the timestamp.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the number of seconds since epoch.\n */\nexport function timestampToUnixSeconds(fieldName: string): FunctionExpression;\nexport function timestampToUnixSeconds(\n expr: Expression | string\n): FunctionExpression {\n const normalizedExpr = fieldOrExpression(expr);\n return normalizedExpr.timestampToUnixSeconds();\n}\n\n/**\n * @beta\n *\n * Creates an expression that adds a specified amount of time to a timestamp.\n *\n * @example\n * ```typescript\n * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field.\n * timestampAdd(field(\"timestamp\"), field(\"unit\"), field(\"amount\"));\n * ```\n *\n * @param timestamp - The expression representing the timestamp.\n * @param unit - The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'.\n * @param amount - The expression evaluates to amount of the unit.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\nexport function timestampAdd(\n timestamp: Expression,\n unit: Expression,\n amount: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that adds a specified amount of time to a timestamp.\n *\n * @example\n * ```typescript\n * // Add 1 day to the 'timestamp' field.\n * timestampAdd(field(\"timestamp\"), \"day\", 1);\n * ```\n *\n * @param timestamp - The expression representing the timestamp.\n * @param unit - The unit of time to add (e.g., \"day\", \"hour\").\n * @param amount - The amount of time to add.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\nexport function timestampAdd(\n timestamp: Expression,\n unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day',\n amount: number\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that adds a specified amount of time to a timestamp represented by a field.\n *\n * @example\n * ```typescript\n * // Add 1 day to the 'timestamp' field.\n * timestampAdd(\"timestamp\", \"day\", 1);\n * ```\n *\n * @param fieldName - The name of the field representing the timestamp.\n * @param unit - The unit of time to add (e.g., \"day\", \"hour\").\n * @param amount - The amount of time to add.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\nexport function timestampAdd(\n fieldName: string,\n unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day',\n amount: number\n): FunctionExpression;\nexport function timestampAdd(\n timestamp: Expression | string,\n unit:\n | Expression\n | 'microsecond'\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day',\n amount: Expression | number\n): FunctionExpression {\n const normalizedTimestamp = fieldOrExpression(timestamp);\n const normalizedUnit = valueToDefaultExpr(unit);\n const normalizedAmount = valueToDefaultExpr(amount);\n return normalizedTimestamp.timestampAdd(normalizedUnit, normalizedAmount);\n}\n\n/**\n * @beta\n *\n * Creates an expression that subtracts a specified amount of time from a timestamp.\n *\n * @example\n * ```typescript\n * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field.\n * timestampSubtract(field(\"timestamp\"), field(\"unit\"), field(\"amount\"));\n * ```\n *\n * @param timestamp - The expression representing the timestamp.\n * @param unit - The expression evaluates to unit of time, must be one of 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day'.\n * @param amount - The expression evaluates to amount of the unit.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\nexport function timestampSubtract(\n timestamp: Expression,\n unit: Expression,\n amount: Expression\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that subtracts a specified amount of time from a timestamp.\n *\n * @example\n * ```typescript\n * // Subtract 1 day from the 'timestamp' field.\n * timestampSubtract(field(\"timestamp\"), \"day\", 1);\n * ```\n *\n * @param timestamp - The expression representing the timestamp.\n * @param unit - The unit of time to subtract (e.g., \"day\", \"hour\").\n * @param amount - The amount of time to subtract.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\nexport function timestampSubtract(\n timestamp: Expression,\n unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day',\n amount: number\n): FunctionExpression;\n\n/**\n * @beta\n *\n * Creates an expression that subtracts a specified amount of time from a timestamp represented by a field.\n *\n * @example\n * ```typescript\n * // Subtract 1 day from the 'timestamp' field.\n * timestampSubtract(\"timestamp\", \"day\", 1);\n * ```\n *\n * @param fieldName - The name of the field representing the timestamp.\n * @param unit - The unit of time to subtract (e.g., \"day\", \"hour\").\n * @param amount - The amount of time to subtract.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the resulting timestamp.\n */\nexport function timestampSubtract(\n fieldName: string,\n unit: 'microsecond' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day',\n amount: number\n): FunctionExpression;\nexport function timestampSubtract(\n timestamp: Expression | string,\n unit:\n | Expression\n | 'microsecond'\n | 'millisecond'\n | 'second'\n | 'minute'\n | 'hour'\n | 'day',\n amount: Expression | number\n): FunctionExpression {\n const normalizedTimestamp = fieldOrExpression(timestamp);\n const normalizedUnit = valueToDefaultExpr(unit);\n const normalizedAmount = valueToDefaultExpr(amount);\n return normalizedTimestamp.timestampSubtract(\n normalizedUnit,\n normalizedAmount\n );\n}\n\n/**\n * @beta\n *\n * Creates an expression that evaluates to the current server timestamp.\n *\n * @example\n * ```typescript\n * // Get the current server timestamp\n * currentTimestamp()\n * ```\n *\n * @returns A new Expression representing the current server timestamp.\n */\nexport function currentTimestamp(): FunctionExpression {\n return new FunctionExpression('current_timestamp', [], 'currentTimestamp');\n}\n\n/**\n * @beta\n *\n * Creates an expression that performs a logical 'AND' operation on multiple filter conditions.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is greater than 18 AND the 'city' field is \"London\" AND\n * // the 'status' field is \"active\"\n * const condition = and(greaterThan(\"age\", 18), equal(\"city\", \"London\"), equal(\"status\", \"active\"));\n * ```\n *\n * @param first - The first filter condition.\n * @param second - The second filter condition.\n * @param more - Additional filter conditions to 'AND' together.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical 'AND' operation.\n */\nexport function and(\n first: BooleanExpression,\n second: BooleanExpression,\n ...more: BooleanExpression[]\n): BooleanExpression {\n return new FunctionExpression(\n 'and',\n [first, second, ...more],\n 'and'\n ).asBoolean();\n}\n\n/**\n * @beta\n *\n * Creates an expression that performs a logical 'OR' operation on multiple filter conditions.\n *\n * @example\n * ```typescript\n * // Check if the 'age' field is greater than 18 OR the 'city' field is \"London\" OR\n * // the 'status' field is \"active\"\n * const condition = or(greaterThan(\"age\", 18), equal(\"city\", \"London\"), equal(\"status\", \"active\"));\n * ```\n *\n * @param first - The first filter condition.\n * @param second - The second filter condition.\n * @param more - Additional filter conditions to 'OR' together.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logical 'OR' operation.\n */\nexport function or(\n first: BooleanExpression,\n second: BooleanExpression,\n ...more: BooleanExpression[]\n): BooleanExpression {\n return new FunctionExpression(\n 'or',\n [first, second, ...more],\n 'xor'\n ).asBoolean();\n}\n\n/**\n * @beta\n * Creates an expression that returns the value of the base expression raised to the power of the exponent expression.\n *\n * @example\n * ```typescript\n * // Raise the value of the 'base' field to the power of the 'exponent' field.\n * pow(field(\"base\"), field(\"exponent\"));\n * ```\n *\n * @param base - The expression to raise to the power of the exponent.\n * @param exponent - The expression to raise the base to the power of.\n * @returns A new `Expression` representing the power operation.\n */\nexport function pow(base: Expression, exponent: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns the value of the base expression raised to the power of the exponent.\n *\n * @example\n * ```typescript\n * // Raise the value of the 'base' field to the power of 2.\n * pow(field(\"base\"), 2);\n * ```\n *\n * @param base - The expression to raise to the power of the exponent.\n * @param exponent - The constant value to raise the base to the power of.\n * @returns A new `Expression` representing the power operation.\n */\nexport function pow(base: Expression, exponent: number): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns the value of the base field raised to the power of the exponent expression.\n *\n * @example\n * ```typescript\n * // Raise the value of the 'base' field to the power of the 'exponent' field.\n * pow(\"base\", field(\"exponent\"));\n * ```\n *\n * @param base - The name of the field to raise to the power of the exponent.\n * @param exponent - The expression to raise the base to the power of.\n * @returns A new `Expression` representing the power operation.\n */\nexport function pow(base: string, exponent: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns the value of the base field raised to the power of the exponent.\n *\n * @example\n * ```typescript\n * // Raise the value of the 'base' field to the power of 2.\n * pow(\"base\", 2);\n * ```\n *\n * @param base - The name of the field to raise to the power of the exponent.\n * @param exponent - The constant value to raise the base to the power of.\n * @returns A new `Expression` representing the power operation.\n */\nexport function pow(base: string, exponent: number): FunctionExpression;\nexport function pow(\n base: Expression | string,\n exponent: Expression | number\n): FunctionExpression {\n return fieldOrExpression(base).pow(exponent as number);\n}\n\n/**\n * @beta\n *\n * Creates an expression that generates a random number between 0.0 and 1.0 but not including 1.0.\n *\n * @example\n * ```typescript\n * // Generate a random number between 0.0 and 1.0.\n * rand();\n * ```\n *\n * @returns A new `Expression` representing the rand operation.\n */\nexport function rand(): FunctionExpression {\n return new FunctionExpression('rand', [], 'rand');\n}\n\n/**\n * @beta\n * Creates an expression that rounds a numeric value to the nearest whole number.\n *\n * @example\n * ```typescript\n * // Round the value of the 'price' field.\n * round(\"price\");\n * ```\n *\n * @param fieldName - The name of the field to round.\n * @returns A new `Expression` representing the rounded value.\n */\nexport function round(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that rounds a numeric value to the nearest whole number.\n *\n * @example\n * ```typescript\n * // Round the value of the 'price' field.\n * round(field(\"price\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which will be rounded.\n * @returns A new `Expression` representing the rounded value.\n */\nexport function round(expression: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that rounds a numeric value to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Round the value of the 'price' field to two decimal places.\n * round(\"price\", 2);\n * ```\n *\n * @param fieldName - The name of the field to round.\n * @param decimalPlaces - A constant or expression specifying the rounding precision in decimal places.\n * @returns A new `Expression` representing the rounded value.\n */\nexport function round(\n fieldName: string,\n decimalPlaces: number | Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that rounds a numeric value to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Round the value of the 'price' field to two decimal places.\n * round(field(\"price\"), constant(2));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which will be rounded.\n * @param decimalPlaces - A constant or expression specifying the rounding precision in decimal places.\n * @returns A new `Expression` representing the rounded value.\n */\nexport function round(\n expression: Expression,\n decimalPlaces: number | Expression\n): FunctionExpression;\nexport function round(\n expr: Expression | string,\n decimalPlaces?: number | Expression\n): FunctionExpression {\n if (decimalPlaces === undefined) {\n return fieldOrExpression(expr).round();\n } else {\n return fieldOrExpression(expr).round(valueToDefaultExpr(decimalPlaces));\n }\n}\n\n/**\n * @beta\n * Creates an expression that truncates the numeric value of a field to an integer.\n *\n * @example\n * ```typescript\n * // Truncate the value of the 'rating' field\n * trunc(\"rating\");\n * ```\n *\n * @param fieldName - The name of the field containing the number to truncate.\n * @returns A new `Expression` representing the truncated value.\n */\nexport function trunc(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that truncates the numeric value of an expression to an integer.\n *\n * @example\n * ```typescript\n * // Truncate the value of the 'rating' field.\n * trunc(field(\"rating\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which will be truncated.\n * @returns A new `Expression` representing the truncated value.\n */\nexport function trunc(expression: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that truncates a numeric expression to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Truncate the value of the 'rating' field to two decimal places.\n * trunc(\"rating\", 2);\n * ```\n *\n * @param fieldName - The name of the field to truncate.\n * @param decimalPlaces - A constant or expression specifying the truncation precision in decimal places.\n * @returns A new `Expression` representing the truncated value.\n */\nexport function trunc(\n fieldName: string,\n decimalPlaces: number | Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that truncates a numeric value to the specified number of decimal places.\n *\n * @example\n * ```typescript\n * // Truncate the value of the 'rating' field to two decimal places.\n * trunc(field(\"rating\"), constant(2));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which will be truncated.\n * @param decimalPlaces - A constant or expression specifying the truncation precision in decimal places.\n * @returns A new `Expression` representing the truncated value.\n */\nexport function trunc(\n expression: Expression,\n decimalPlaces: number | Expression\n): FunctionExpression;\nexport function trunc(\n expr: Expression | string,\n decimalPlaces?: number | Expression\n): FunctionExpression {\n if (decimalPlaces === undefined) {\n return fieldOrExpression(expr).trunc();\n } else {\n return fieldOrExpression(expr).trunc(valueToDefaultExpr(decimalPlaces));\n }\n}\n\n/**\n * @beta\n * Creates an expression that returns the collection ID from a path.\n *\n * @example\n * ```typescript\n * // Get the collection ID from a path.\n * collectionId(\"__name__\");\n * ```\n *\n * @param fieldName - The name of the field to get the collection ID from.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the collectionId operation.\n */\nexport function collectionId(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that returns the collection ID from a path.\n *\n * @example\n * ```typescript\n * // Get the collection ID from a path.\n * collectionId(field(\"__name__\"));\n * ```\n *\n * @param expression - An expression evaluating to a path, which the collection ID will be extracted from.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the collectionId operation.\n */\nexport function collectionId(expression: Expression): FunctionExpression;\nexport function collectionId(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).collectionId();\n}\n\n/**\n * @beta\n * Creates an expression that calculates the length of a string, array, map, vector, or bytes.\n *\n * @example\n * ```typescript\n * // Get the length of the 'name' field.\n * length(\"name\");\n *\n * // Get the number of items in the 'cart' array.\n * length(\"cart\");\n * ```\n *\n * @param fieldName - The name of the field to calculate the length of.\n * @returns A new `Expression` representing the length of the string, array, map, vector, or bytes.\n */\nexport function length(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that calculates the length of a string, array, map, vector, or bytes.\n *\n * @example\n * ```typescript\n * // Get the length of the 'name' field.\n * length(field(\"name\"));\n *\n * // Get the number of items in the 'cart' array.\n * length(field(\"cart\"));\n * ```\n *\n * @param expression - An expression evaluating to a string, array, map, vector, or bytes, which the length will be calculated for.\n * @returns A new `Expression` representing the length of the string, array, map, vector, or bytes.\n */\nexport function length(expression: Expression): FunctionExpression;\nexport function length(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).length();\n}\n\n/**\n * @beta\n * Creates an expression that computes the natural logarithm of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the natural logarithm of the 'value' field.\n * ln(\"value\");\n * ```\n *\n * @param fieldName - The name of the field to compute the natural logarithm of.\n * @returns A new `Expression` representing the natural logarithm of the numeric value.\n */\nexport function ln(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that computes the natural logarithm of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the natural logarithm of the 'value' field.\n * ln(field(\"value\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which the natural logarithm will be computed for.\n * @returns A new `Expression` representing the natural logarithm of the numeric value.\n */\nexport function ln(expression: Expression): FunctionExpression;\nexport function ln(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).ln();\n}\n\n/**\n * @beta\n * Creates an expression that computes the logarithm of an expression to a given base.\n *\n * @example\n * ```typescript\n * // Compute the logarithm of the 'value' field with base 10.\n * log(field(\"value\"), 10);\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which the logarithm will be computed for.\n * @param base - The base of the logarithm.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logarithm of the numeric value.\n */\nexport function log(expression: Expression, base: number): FunctionExpression;\n/**\n * @beta\n * Creates an expression that computes the logarithm of an expression to a given base.\n *\n * @example\n * ```typescript\n * // Compute the logarithm of the 'value' field with the base in the 'base' field.\n * log(field(\"value\"), field(\"base\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which the logarithm will be computed for.\n * @param base - The base of the logarithm.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logarithm of the numeric value.\n */\nexport function log(\n expression: Expression,\n base: Expression\n): FunctionExpression;\n/**\n * @beta\n * Creates an expression that computes the logarithm of a field to a given base.\n *\n * @example\n * ```typescript\n * // Compute the logarithm of the 'value' field with base 10.\n * log(\"value\", 10);\n * ```\n *\n * @param fieldName - The name of the field to compute the logarithm of.\n * @param base - The base of the logarithm.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logarithm of the numeric value.\n */\nexport function log(fieldName: string, base: number): FunctionExpression;\n/**\n * @beta\n * Creates an expression that computes the logarithm of a field to a given base.\n *\n * @example\n * ```typescript\n * // Compute the logarithm of the 'value' field with the base in the 'base' field.\n * log(\"value\", field(\"base\"));\n * ```\n *\n * @param fieldName - The name of the field to compute the logarithm of.\n * @param base - The base of the logarithm.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the logarithm of the numeric value.\n */\nexport function log(fieldName: string, base: Expression): FunctionExpression;\nexport function log(\n expr: Expression | string,\n base: number | Expression\n): FunctionExpression {\n return new FunctionExpression('log', [\n fieldOrExpression(expr),\n valueToDefaultExpr(base)\n ]);\n}\n\n/**\n * @beta\n * Creates an expression that computes the square root of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the square root of the 'value' field.\n * sqrt(field(\"value\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which the square root will be computed for.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the square root of the numeric value.\n */\nexport function sqrt(expression: Expression): FunctionExpression;\n/**\n * @beta\n * Creates an expression that computes the square root of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the square root of the 'value' field.\n * sqrt(\"value\");\n * ```\n *\n * @param fieldName - The name of the field to compute the square root of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the square root of the numeric value.\n */\nexport function sqrt(fieldName: string): FunctionExpression;\nexport function sqrt(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).sqrt();\n}\n\n/**\n * @beta\n * Creates an expression that reverses a string.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myString' field.\n * strReverse(field(\"myString\"));\n * ```\n *\n * @param stringExpression - An expression evaluating to a string value, which will be reversed.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed string.\n */\nexport function stringReverse(stringExpression: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that reverses a string value in the specified field.\n *\n * @example\n * ```typescript\n * // Reverse the value of the 'myString' field.\n * strReverse(\"myString\");\n * ```\n *\n * @param field - The name of the field representing the string to reverse.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the reversed string.\n */\nexport function stringReverse(field: string): FunctionExpression;\nexport function stringReverse(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).stringReverse();\n}\n\n/**\n * @beta\n * Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.\n *\n * @example\n * ```typescript\n * // Concatenate the 'firstName' and 'lastName' fields with a space in between.\n * concat(field(\"firstName\"), \" \", field(\"lastName\"))\n * ```\n *\n * @param first - The first expressions to concatenate.\n * @param second - The second literal or expression to concatenate.\n * @param others - Additional literals or expressions to concatenate.\n * @returns A new `Expression` representing the concatenation.\n */\nexport function concat(\n first: Expression,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.\n *\n * @example\n * ```typescript\n * // Concatenate a field with a literal string.\n * concat(field(\"firstName\"), \"Doe\")\n * ```\n *\n * @param fieldName - The name of a field to concatenate.\n * @param second - The second literal or expression to concatenate.\n * @param others - Additional literal or expressions to concatenate.\n * @returns A new `Expression` representing the concatenation.\n */\nexport function concat(\n fieldName: string,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression;\n\nexport function concat(\n fieldNameOrExpression: string | Expression,\n second: Expression | unknown,\n ...others: Array<Expression | unknown>\n): FunctionExpression {\n return new FunctionExpression('concat', [\n fieldOrExpression(fieldNameOrExpression),\n valueToDefaultExpr(second),\n ...others.map(valueToDefaultExpr)\n ]);\n}\n\n/**\n * @beta\n * Creates an expression that computes the absolute value of a numeric value.\n *\n * @param expr - The expression to compute the absolute value of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the absolute value of the numeric value.\n */\nexport function abs(expr: Expression): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that computes the absolute value of a numeric value.\n *\n * @param fieldName - The field to compute the absolute value of.\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the absolute value of the numeric value.\n */\nexport function abs(fieldName: string): FunctionExpression;\nexport function abs(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).abs();\n}\n\n/**\n * @beta\n * Creates an expression that returns the `elseExpr` argument if `ifExpr` is absent, else return\n * the result of the `ifExpr` argument evaluation.\n *\n * @example\n * ```typescript\n * // Returns the value of the optional field 'optional_field', or returns 'default_value'\n * // if the field is absent.\n * ifAbsent(field(\"optional_field\"), constant(\"default_value\"))\n * ```\n *\n * @param ifExpr - The expression to check for absence.\n * @param elseExpr - The expression that will be evaluated and returned if [ifExpr] is absent.\n * @returns A new Expression representing the ifAbsent operation.\n */\nexport function ifAbsent(ifExpr: Expression, elseExpr: Expression): Expression;\n\n/**\n * @beta\n * Creates an expression that returns the `elseValue` argument if `ifExpr` is absent, else\n * return the result of the `ifExpr` argument evaluation.\n *\n * @example\n * ```typescript\n * // Returns the value of the optional field 'optional_field', or returns 'default_value'\n * // if the field is absent.\n * ifAbsent(field(\"optional_field\"), \"default_value\")\n * ```\n *\n * @param ifExpr - The expression to check for absence.\n * @param elseValue - The value that will be returned if `ifExpr` evaluates to an absent value.\n * @returns A new [Expression] representing the ifAbsent operation.\n */\nexport function ifAbsent(ifExpr: Expression, elseValue: unknown): Expression;\n\n/**\n * @beta\n * Creates an expression that returns the `elseExpr` argument if `ifFieldName` is absent, else\n * return the value of the field.\n *\n * @example\n * ```typescript\n * // Returns the value of the optional field 'optional_field', or returns the value of\n * // 'default_field' if 'optional_field' is absent.\n * ifAbsent(\"optional_field\", field(\"default_field\"))\n * ```\n *\n * @param ifFieldName - The field to check for absence.\n * @param elseExpr - The expression that will be evaluated and returned if `ifFieldName` is\n * absent.\n * @returns A new Expression representing the ifAbsent operation.\n */\nexport function ifAbsent(ifFieldName: string, elseExpr: Expression): Expression;\n\n/**\n * @beta\n * Creates an expression that returns the `elseValue` argument if `ifFieldName` is absent, else\n * return the value of the field.\n *\n * @example\n * ```typescript\n * // Returns the value of the optional field 'optional_field', or returns 'default_value'\n * // if the field is absent.\n * ifAbsent(\"optional_field\", \"default_value\")\n * ```\n *\n * @param ifFieldName - The field to check for absence.\n * @param elseValue - The value that will be returned if [ifFieldName] is absent.\n * @returns A new Expression representing the ifAbsent operation.\n */\nexport function ifAbsent(\n ifFieldName: string | Expression,\n elseValue: Expression | unknown\n): Expression;\nexport function ifAbsent(\n fieldNameOrExpression: string | Expression,\n elseValue: Expression | unknown\n): Expression {\n return fieldOrExpression(fieldNameOrExpression).ifAbsent(\n valueToDefaultExpr(elseValue)\n );\n}\n\n/**\n * @beta\n * Creates an expression that joins the elements of an array into a string.\n *\n * @example\n * ```typescript\n * // Join the elements of the 'tags' field with a comma and space.\n * join(\"tags\", \", \")\n * ```\n *\n * @param arrayFieldName - The name of the field containing the array.\n * @param delimiter - The string to use as a delimiter.\n * @returns A new Expression representing the join operation.\n */\nexport function join(arrayFieldName: string, delimiter: string): Expression;\n\n/**\n * @beta\n * Creates an expression that joins the elements of an array into a string.\n *\n * @example\n * ```typescript\n * // Join an array of string using the delimiter from the 'separator' field.\n * join(array(['foo', 'bar']), field(\"separator\"))\n * ```\n *\n * @param arrayExpression - An expression that evaluates to an array.\n * @param delimiterExpression - The expression that evaluates to the delimiter string.\n * @returns A new Expression representing the join operation.\n */\nexport function join(\n arrayExpression: Expression,\n delimiterExpression: Expression\n): Expression;\n\n/**\n * @beta\n * Creates an expression that joins the elements of an array into a string.\n *\n * @example\n * ```typescript\n * // Join the elements of the 'tags' field with a comma and space.\n * join(field(\"tags\"), \", \")\n * ```\n *\n * @param arrayExpression - An expression that evaluates to an array.\n * @param delimiter - The string to use as a delimiter.\n * @returns A new Expression representing the join operation.\n */\nexport function join(\n arrayExpression: Expression,\n delimiter: string\n): Expression;\n\n/**\n * @beta\n * Creates an expression that joins the elements of an array into a string.\n *\n * @example\n * ```typescript\n * // Join the elements of the 'tags' field with the delimiter from the 'separator' field.\n * join('tags', field(\"separator\"))\n * ```\n *\n * @param arrayFieldName - The name of the field containing the array.\n * @param delimiterExpression - The expression that evaluates to the delimiter string.\n * @returns A new Expression representing the join operation.\n */\nexport function join(\n arrayFieldName: string,\n delimiterExpression: Expression\n): Expression;\nexport function join(\n fieldNameOrExpression: string | Expression,\n delimiterValueOrExpression: Expression | string\n): Expression {\n return fieldOrExpression(fieldNameOrExpression).join(\n valueToDefaultExpr(delimiterValueOrExpression)\n );\n}\n\n/**\n * @beta\n * Creates an expression that computes the base-10 logarithm of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the base-10 logarithm of the 'value' field.\n * log10(\"value\");\n * ```\n *\n * @param fieldName - The name of the field to compute the base-10 logarithm of.\n * @returns A new `Expression` representing the base-10 logarithm of the numeric value.\n */\nexport function log10(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that computes the base-10 logarithm of a numeric value.\n *\n * @example\n * ```typescript\n * // Compute the base-10 logarithm of the 'value' field.\n * log10(field(\"value\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric value, which the base-10 logarithm will be computed for.\n * @returns A new `Expression` representing the base-10 logarithm of the numeric value.\n */\nexport function log10(expression: Expression): FunctionExpression;\nexport function log10(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).log10();\n}\n\n/**\n * @beta\n * Creates an expression that computes the sum of the elements in an array.\n *\n * @example\n * ```typescript\n * // Compute the sum of the elements in the 'scores' field.\n * arraySum(\"scores\");\n * ```\n *\n * @param fieldName - The name of the field to compute the sum of.\n * @returns A new `Expression` representing the sum of the elements in the array.\n */\nexport function arraySum(fieldName: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that computes the sum of the elements in an array.\n *\n * @example\n * ```typescript\n * // Compute the sum of the elements in the 'scores' field.\n * arraySum(field(\"scores\"));\n * ```\n *\n * @param expression - An expression evaluating to a numeric array, which the sum will be computed for.\n * @returns A new `Expression` representing the sum of the elements in the array.\n */\nexport function arraySum(expression: Expression): FunctionExpression;\nexport function arraySum(expr: Expression | string): FunctionExpression {\n return fieldOrExpression(expr).arraySum();\n}\n\n/**\n * @beta\n * Creates an expression that splits the value of a field on the provided delimiter.\n *\n * @example\n * ```typescript\n * // Split the 'scoresCsv' field on delimiter ','\n * split('scoresCsv', ',')\n * ```\n *\n * @param fieldName - Split the value in this field.\n * @param delimiter - Split on this delimiter.\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the split function.\n */\nexport function split(fieldName: string, delimiter: string): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that splits the value of a field on the provided delimiter.\n *\n * @example\n * ```typescript\n * // Split the 'scores' field on delimiter ',' or ':' depending on the stored format\n * split('scores', conditional(field('format').equal('csv'), constant(','), constant(':'))\n * ```\n *\n * @param fieldName - Split the value in this field.\n * @param delimiter - Split on this delimiter returned by evaluating this expression.\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the split function.\n */\nexport function split(\n fieldName: string,\n delimiter: Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that splits a string into an array of substrings based on the provided delimiter.\n *\n * @example\n * ```typescript\n * // Split the 'scoresCsv' field on delimiter ','\n * split(field('scoresCsv'), ',')\n * ```\n *\n * @param expression - Split the result of this expression.\n * @param delimiter - Split on this delimiter.\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the split function.\n */\nexport function split(\n expression: Expression,\n delimiter: string\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that splits a string into an array of substrings based on the provided delimiter.\n *\n * @example\n * ```typescript\n * // Split the 'scores' field on delimiter ',' or ':' depending on the stored format\n * split(field('scores'), conditional(field('format').equal('csv'), constant(','), constant(':'))\n * ```\n *\n * @param expression - Split the result of this expression.\n * @param delimiter - Split on this delimiter returned by evaluating this expression.\n *\n * @returns A new {@link @firebase/firestore/pipelines#Expression} representing the split function.\n */\nexport function split(\n expression: Expression,\n delimiter: Expression\n): FunctionExpression;\nexport function split(\n fieldNameOrExpression: string | Expression,\n delimiter: string | Expression\n): FunctionExpression {\n return fieldOrExpression(fieldNameOrExpression).split(\n valueToDefaultExpr(delimiter)\n );\n}\n\n/**\n * @beta\n * Creates an expression that truncates a timestamp to a specified granularity.\n *\n * @example\n * ```typescript\n * // Truncate the 'createdAt' timestamp to the beginning of the day.\n * field('createdAt').timestampTruncate('day')\n * ```\n *\n * @param fieldName - Truncate the timestamp value contained in this field.\n * @param granularity - The granularity to truncate to.\n * @param timezone - The timezone to use for truncation. Valid values are from\n * the TZ database (e.g., \"America/Los_Angeles\") or in the format \"Etc/GMT-1\".\n * @returns A new `Expression` representing the truncated timestamp.\n */\nexport function timestampTruncate(\n fieldName: string,\n granularity: TimeGranularity,\n timezone?: string | Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that truncates a timestamp to a specified granularity.\n *\n * @example\n * ```typescript\n * // Truncate the 'createdAt' timestamp to the granularity specified in the field 'granularity'.\n * field('createdAt').timestampTruncate(field('granularity'))\n * ```\n *\n * @param fieldName - Truncate the timestamp value contained in this field.\n * @param granularity - The granularity to truncate to.\n * @param timezone - The timezone to use for truncation. Valid values are from\n * the TZ database (e.g., \"America/Los_Angeles\") or in the format \"Etc/GMT-1\".\n * @returns A new `Expression` representing the truncated timestamp.\n */\nexport function timestampTruncate(\n fieldName: string,\n granularity: Expression,\n timezone?: string | Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that truncates a timestamp to a specified granularity.\n *\n * @example\n * ```typescript\n * // Truncate the 'createdAt' timestamp to the beginning of the day.\n * field('createdAt').timestampTruncate('day')\n * ```\n *\n * @param timestampExpression - Truncate the timestamp value that is returned by this expression.\n * @param granularity - The granularity to truncate to.\n * @param timezone - The timezone to use for truncation. Valid values are from\n * the TZ database (e.g., \"America/Los_Angeles\") or in the format \"Etc/GMT-1\".\n * @returns A new `Expression` representing the truncated timestamp.\n */\nexport function timestampTruncate(\n timestampExpression: Expression,\n granularity: TimeGranularity,\n timezone?: string | Expression\n): FunctionExpression;\n\n/**\n * @beta\n * Creates an expression that truncates a timestamp to a specified granularity.\n *\n * @example\n * ```typescript\n * // Truncate the 'createdAt' timestamp to the granularity specified in the field 'granularity'.\n * field('createdAt').timestampTruncate(field('granularity'))\n * ```\n *\n * @param timestampExpression - Truncate the timestamp value that is returned by this expression.\n * @param granularity - The granularity to truncate to.\n * @param timezone - The timezone to use for truncation. Valid values are from\n * the TZ database (e.g., \"America/Los_Angeles\") or in the format \"Etc/GMT-1\".\n * @returns A new `Expression` representing the truncated timestamp.\n */\nexport function timestampTruncate(\n timestampExpression: Expression,\n granularity: Expression,\n timezone?: string | Expression\n): FunctionExpression;\nexport function timestampTruncate(\n fieldNameOrExpression: string | Expression,\n granularity: TimeGranularity | Expression,\n timezone?: string | Expression\n): FunctionExpression {\n const internalGranularity = isString(granularity)\n ? valueToDefaultExpr(granularity.toLowerCase())\n : granularity;\n return fieldOrExpression(fieldNameOrExpression).timestampTruncate(\n internalGranularity,\n timezone\n );\n}\n\n// TODO(new-expression): Add new top-level expression function definitions above this line\n\n/**\n * @beta\n *\n * Creates an {@link @firebase/firestore/pipelines#Ordering} that sorts documents in ascending order based on an expression.\n *\n * @example\n * ```typescript\n * // Sort documents by the 'name' field in lowercase in ascending order\n * firestore.pipeline().collection(\"users\")\n * .sort(ascending(field(\"name\").toLower()));\n * ```\n *\n * @param expr - The expression to create an ascending ordering for.\n * @returns A new `Ordering` for ascending sorting.\n */\nexport function ascending(expr: Expression): Ordering;\n\n/**\n * @beta\n *\n * Creates an {@link @firebase/firestore/pipelines#Ordering} that sorts documents in ascending order based on a field.\n *\n * @example\n * ```typescript\n * // Sort documents by the 'name' field in ascending order\n * firestore.pipeline().collection(\"users\")\n * .sort(ascending(\"name\"));\n * ```\n *\n * @param fieldName - The field to create an ascending ordering for.\n * @returns A new `Ordering` for ascending sorting.\n */\nexport function ascending(fieldName: string): Ordering;\nexport function ascending(field: Expression | string): Ordering {\n return new Ordering(fieldOrExpression(field), 'ascending', 'ascending');\n}\n\n/**\n * @beta\n *\n * Creates an {@link @firebase/firestore/pipelines#Ordering} that sorts documents in descending order based on an expression.\n *\n * @example\n * ```typescript\n * // Sort documents by the 'name' field in lowercase in descending order\n * firestore.pipeline().collection(\"users\")\n * .sort(descending(field(\"name\").toLower()));\n * ```\n *\n * @param expr - The expression to create a descending ordering for.\n * @returns A new `Ordering` for descending sorting.\n */\nexport function descending(expr: Expression): Ordering;\n\n/**\n * @beta\n *\n * Creates an {@link @firebase/firestore/pipelines#Ordering} that sorts documents in descending order based on a field.\n *\n * @example\n * ```typescript\n * // Sort documents by the 'name' field in descending order\n * firestore.pipeline().collection(\"users\")\n * .sort(descending(\"name\"));\n * ```\n *\n * @param fieldName - The field to create a descending ordering for.\n * @returns A new `Ordering` for descending sorting.\n */\nexport function descending(fieldName: string): Ordering;\nexport function descending(field: Expression | string): Ordering {\n return new Ordering(fieldOrExpression(field), 'descending', 'descending');\n}\n\n/**\n * @beta\n *\n * Represents an ordering criterion for sorting documents in a Firestore pipeline.\n *\n * You create `Ordering` instances using the `ascending` and `descending` helper functions.\n */\nexport class Ordering implements ProtoValueSerializable, UserData {\n constructor(\n public readonly expr: Expression,\n public readonly direction: 'ascending' | 'descending',\n readonly _methodName: string | undefined\n ) {}\n\n /**\n * @private\n * @internal\n */\n _toProto(serializer: JsonProtoSerializer): ProtoValue {\n return {\n mapValue: {\n fields: {\n direction: toStringValue(this.direction),\n expression: this.expr._toProto(serializer)\n }\n }\n };\n }\n\n /**\n * @private\n * @internal\n */\n _readUserData(context: ParseContext): void {\n this.expr._readUserData(context);\n }\n\n _protoValueType: 'ProtoValue' = 'ProtoValue';\n}\n\nexport function isSelectable(val: unknown): val is Selectable {\n const candidate = val as Selectable;\n return (\n candidate.selectable && isString(candidate.alias) && isExpr(candidate.expr)\n );\n}\n\nexport function isOrdering(val: unknown): val is Ordering {\n const candidate = val as Ordering;\n return (\n isExpr(candidate.expr) &&\n (candidate.direction === 'ascending' ||\n candidate.direction === 'descending')\n );\n}\n\nexport function isAliasedAggregate(val: unknown): val is AliasedAggregate {\n const candidate = val as AliasedAggregate;\n return (\n isString(candidate.alias) &&\n candidate.aggregate instanceof AggregateFunction\n );\n}\n\nexport function isExpr(val: unknown): val is Expression {\n return val instanceof Expression;\n}\n\nexport function isBooleanExpr(val: unknown): val is BooleanExpression {\n return val instanceof BooleanExpression;\n}\n\nexport function isField(val: unknown): val is Field {\n return val instanceof Field;\n}\n\nexport function toField(value: string | Field): Field {\n if (isString(value)) {\n const result = field(value);\n return result;\n } else {\n return value as Field;\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Firestore } from '../lite-api/database';\nimport {\n Constant,\n BooleanExpression,\n and,\n or,\n Ordering,\n lessThan,\n greaterThan,\n field\n} from '../lite-api/expressions';\nimport { Pipeline } from '../lite-api/pipeline';\nimport { doc } from '../lite-api/reference';\nimport { fail } from '../util/assert';\n\nimport { Bound } from './bound';\nimport {\n CompositeFilter as CompositeFilterInternal,\n CompositeOperator,\n FieldFilter as FieldFilterInternal,\n Filter as FilterInternal,\n Operator\n} from './filter';\nimport { Direction } from './order_by';\nimport {\n isCollectionGroupQuery,\n isDocumentQuery,\n LimitType,\n Query,\n queryNormalizedOrderBy\n} from './query';\n\n/* eslint @typescript-eslint/no-explicit-any: 0 */\n\nexport function toPipelineBooleanExpr(f: FilterInternal): BooleanExpression {\n if (f instanceof FieldFilterInternal) {\n const fieldValue = field(f.field.toString());\n // Comparison filters\n const value = f.value;\n switch (f.op) {\n case Operator.LESS_THAN:\n return and(\n fieldValue.exists(),\n fieldValue.lessThan(Constant._fromProto(value))\n );\n case Operator.LESS_THAN_OR_EQUAL:\n return and(\n fieldValue.exists(),\n fieldValue.lessThanOrEqual(Constant._fromProto(value))\n );\n case Operator.GREATER_THAN:\n return and(\n fieldValue.exists(),\n fieldValue.greaterThan(Constant._fromProto(value))\n );\n case Operator.GREATER_THAN_OR_EQUAL:\n return and(\n fieldValue.exists(),\n fieldValue.greaterThanOrEqual(Constant._fromProto(value))\n );\n case Operator.EQUAL:\n return and(\n fieldValue.exists(),\n fieldValue.equal(Constant._fromProto(value))\n );\n case Operator.NOT_EQUAL:\n return fieldValue.notEqual(Constant._fromProto(value));\n case Operator.ARRAY_CONTAINS:\n return and(\n fieldValue.exists(),\n fieldValue.arrayContains(Constant._fromProto(value))\n );\n case Operator.IN: {\n const values = value?.arrayValue?.values?.map((val: any) =>\n Constant._fromProto(val)\n );\n if (!values) {\n return and(fieldValue.exists(), fieldValue.equalAny([]));\n } else if (values.length === 1) {\n return and(fieldValue.exists(), fieldValue.equal(values[0]));\n } else {\n return and(fieldValue.exists(), fieldValue.equalAny(values));\n }\n }\n case Operator.ARRAY_CONTAINS_ANY: {\n const values = value?.arrayValue?.values?.map((val: any) =>\n Constant._fromProto(val)\n );\n return and(fieldValue.exists(), fieldValue.arrayContainsAny(values!));\n }\n case Operator.NOT_IN: {\n const values = value?.arrayValue?.values?.map((val: any) =>\n Constant._fromProto(val)\n );\n if (!values) {\n return fieldValue.notEqualAny([]);\n } else if (values.length === 1) {\n return fieldValue.notEqual(values[0]);\n } else {\n return fieldValue.notEqualAny(values);\n }\n }\n default:\n fail(0x9047, 'Unexpected operator');\n }\n } else if (f instanceof CompositeFilterInternal) {\n switch (f.op) {\n case CompositeOperator.AND: {\n const conditions = f.getFilters().map(f => toPipelineBooleanExpr(f));\n return and(conditions[0], conditions[1], ...conditions.slice(2));\n }\n case CompositeOperator.OR: {\n const conditions = f.getFilters().map(f => toPipelineBooleanExpr(f));\n return or(conditions[0], conditions[1], ...conditions.slice(2));\n }\n default:\n fail(0x89ea, 'Unexpected operator');\n }\n }\n\n throw new Error(`Failed to convert filter to pipeline conditions: ${f}`);\n}\n\nfunction reverseOrderings(orderings: Ordering[]): Ordering[] {\n return orderings.map(\n o =>\n new Ordering(\n o.expr,\n o.direction === 'ascending' ? 'descending' : 'ascending',\n undefined\n )\n );\n}\n\nexport function toPipeline(query: Query, db: Firestore): Pipeline {\n let pipeline: Pipeline;\n if (isCollectionGroupQuery(query)) {\n pipeline = db.pipeline().collectionGroup(query.collectionGroup!);\n } else if (isDocumentQuery(query)) {\n pipeline = db.pipeline().documents([doc(db, query.path.canonicalString())]);\n } else {\n pipeline = db.pipeline().collection(query.path.canonicalString());\n }\n\n // filters\n for (const filter of query.filters) {\n pipeline = pipeline.where(toPipelineBooleanExpr(filter));\n }\n\n // orders\n const orders = queryNormalizedOrderBy(query);\n const existsConditions = query.explicitOrderBy.map(order =>\n field(order.field.canonicalString()).exists()\n );\n if (existsConditions.length > 0) {\n const condition =\n existsConditions.length === 1\n ? existsConditions[0]\n : and(\n existsConditions[0],\n existsConditions[1],\n ...existsConditions.slice(2)\n );\n pipeline = pipeline.where(condition);\n }\n\n const orderings = orders.map(order =>\n order.dir === Direction.ASCENDING\n ? field(order.field.canonicalString()).ascending()\n : field(order.field.canonicalString()).descending()\n );\n\n if (orderings.length > 0) {\n if (query.limitType === LimitType.Last) {\n const actualOrderings = reverseOrderings(orderings);\n pipeline = pipeline.sort(actualOrderings[0], ...actualOrderings.slice(1));\n // cursors\n if (query.startAt !== null) {\n pipeline = pipeline.where(\n whereConditionsFromCursor(query.startAt, orderings, 'after')\n );\n }\n\n if (query.endAt !== null) {\n pipeline = pipeline.where(\n whereConditionsFromCursor(query.endAt, orderings, 'before')\n );\n }\n\n pipeline = pipeline.limit(query.limit!);\n pipeline = pipeline.sort(orderings[0], ...orderings.slice(1));\n } else {\n pipeline = pipeline.sort(orderings[0], ...orderings.slice(1));\n if (query.startAt !== null) {\n pipeline = pipeline.where(\n whereConditionsFromCursor(query.startAt, orderings, 'after')\n );\n }\n if (query.endAt !== null) {\n pipeline = pipeline.where(\n whereConditionsFromCursor(query.endAt, orderings, 'before')\n );\n }\n\n if (query.limit !== null) {\n pipeline = pipeline.limit(query.limit);\n }\n }\n }\n\n return pipeline;\n}\n\nfunction whereConditionsFromCursor(\n bound: Bound,\n orderings: Ordering[],\n position: 'before' | 'after'\n): BooleanExpression {\n // The filterFunc is either greater than or less than\n const filterFunc = position === 'before' ? lessThan : greaterThan;\n const cursors = bound.position.map(value => Constant._fromProto(value));\n const size = cursors.length;\n\n let field = orderings[size - 1].expr;\n let value = cursors[size - 1];\n\n // Add condition for last bound\n let condition: BooleanExpression = filterFunc(field, value);\n if (bound.inclusive) {\n // When the cursor bound is inclusive, then the last bound\n // can be equal to the value, otherwise it's not equal\n condition = or(condition, field.equal(value));\n }\n\n // Iterate backwards over the remaining bounds, adding\n // a condition for each one\n for (let i = size - 2; i >= 0; i--) {\n field = orderings[i].expr;\n value = cursors[i];\n\n // For each field in the orderings, the condition is either\n // a) lt|gt the cursor value,\n // b) or equal the cursor value and lt|gt the cursor values for other fields\n condition = or(\n filterFunc(field, value),\n and(field.equal(value), condition)\n );\n }\n\n return condition;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ParseContext } from '../api/parse_context';\nimport { OptionsUtil } from '../core/options_util';\nimport {\n ApiClientObjectMap,\n firestoreV1ApiClientInterfaces,\n Stage as ProtoStage\n} from '../protos/firestore_proto_api';\nimport { toNumber } from '../remote/number_serializer';\nimport {\n JsonProtoSerializer,\n ProtoSerializable,\n toMapValue,\n toPipelineValue,\n toStringValue\n} from '../remote/serializer';\nimport { hardAssert } from '../util/assert';\n\nimport {\n AggregateFunction,\n BooleanExpression,\n Expression,\n Field,\n field,\n Ordering\n} from './expressions';\nimport { Pipeline } from './pipeline';\nimport { StageOptions } from './stage_options';\nimport { isUserData, UserData } from './user_data_reader';\n\n/**\n * @beta\n */\nexport abstract class Stage implements ProtoSerializable<ProtoStage>, UserData {\n /**\n * Store optionsProto parsed by _readUserData.\n * @private\n * @internal\n * @protected\n */\n protected optionsProto:\n | ApiClientObjectMap<firestoreV1ApiClientInterfaces.Value>\n | undefined = undefined;\n protected knownOptions: Record<string, unknown>;\n protected rawOptions?: Record<string, unknown>;\n\n constructor(options: StageOptions) {\n ({ rawOptions: this.rawOptions, ...this.knownOptions } = options);\n }\n\n _readUserData(context: ParseContext): void {\n this.optionsProto = this._optionsUtil.getOptionsProto(\n context,\n this.knownOptions,\n this.rawOptions\n );\n }\n\n _toProto(_: JsonProtoSerializer): ProtoStage {\n return {\n name: this._name,\n options: this.optionsProto\n };\n }\n\n abstract get _optionsUtil(): OptionsUtil;\n abstract get _name(): string;\n}\n\n/**\n * @beta\n */\nexport class AddFields extends Stage {\n get _name(): string {\n return 'add_fields';\n }\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private fields: Map<string, Expression>, options: StageOptions) {\n super(options);\n }\n\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [toMapValue(serializer, this.fields)]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.fields, context);\n }\n}\n\n/**\n * @beta\n */\nexport class RemoveFields extends Stage {\n get _name(): string {\n return 'remove_fields';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private fields: Field[], options: StageOptions) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: this.fields.map(f => f._toProto(serializer))\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.fields, context);\n }\n}\n\n/**\n * @beta\n */\nexport class Aggregate extends Stage {\n get _name(): string {\n return 'aggregate';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(\n private groups: Map<string, Expression>,\n private accumulators: Map<string, AggregateFunction>,\n options: StageOptions\n ) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [\n toMapValue(serializer, this.accumulators),\n toMapValue(serializer, this.groups)\n ]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.groups, context);\n readUserDataHelper(this.accumulators, context);\n }\n}\n\n/**\n * @beta\n */\nexport class Distinct extends Stage {\n get _name(): string {\n return 'distinct';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private groups: Map<string, Expression>, options: StageOptions) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [toMapValue(serializer, this.groups)]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.groups, context);\n }\n}\n\n/**\n * @beta\n */\nexport class CollectionSource extends Stage {\n get _name(): string {\n return 'collection';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({\n forceIndex: {\n serverName: 'force_index'\n }\n });\n }\n\n private formattedCollectionPath: string;\n\n constructor(collection: string, options: StageOptions) {\n super(options);\n\n // prepend slash to collection string\n this.formattedCollectionPath = collection.startsWith('/')\n ? collection\n : '/' + collection;\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [{ referenceValue: this.formattedCollectionPath }]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n }\n}\n\n/**\n * @beta\n */\nexport class CollectionGroupSource extends Stage {\n get _name(): string {\n return 'collection_group';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({\n forceIndex: {\n serverName: 'force_index'\n }\n });\n }\n\n constructor(private collectionId: string, options: StageOptions) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [{ referenceValue: '' }, { stringValue: this.collectionId }]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n }\n}\n\n/**\n * @beta\n */\nexport class DatabaseSource extends Stage {\n get _name(): string {\n return 'database';\n }\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer)\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n }\n}\n\n/**\n * @beta\n */\nexport class DocumentsSource extends Stage {\n get _name(): string {\n return 'documents';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n private formattedPaths: string[];\n\n constructor(docPaths: string[], options: StageOptions) {\n super(options);\n this.formattedPaths = docPaths.map(path =>\n path.startsWith('/') ? path : '/' + path\n );\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: this.formattedPaths.map(p => {\n return { referenceValue: p };\n })\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n }\n}\n\n/**\n * @beta\n */\nexport class Where extends Stage {\n get _name(): string {\n return 'where';\n }\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private condition: BooleanExpression, options: StageOptions) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [this.condition._toProto(serializer)]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.condition, context);\n }\n}\n\n/**\n * @beta\n */\nexport class FindNearest extends Stage {\n get _name(): string {\n return 'find_nearest';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({\n limit: {\n serverName: 'limit'\n },\n distanceField: {\n serverName: 'distance_field'\n }\n });\n }\n\n constructor(\n private vectorValue: Expression,\n private field: Field,\n private distanceMeasure: 'euclidean' | 'cosine' | 'dot_product',\n options: StageOptions\n ) {\n super(options);\n }\n\n /**\n * @private\n * @internal\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [\n this.field._toProto(serializer),\n this.vectorValue._toProto(serializer),\n toStringValue(this.distanceMeasure)\n ]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.vectorValue, context);\n readUserDataHelper(this.field, context);\n }\n}\n\n/**\n * @beta\n */\nexport class Limit extends Stage {\n get _name(): string {\n return 'limit';\n }\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private limit: number, options: StageOptions) {\n hardAssert(\n !isNaN(limit) && limit !== Infinity && limit !== -Infinity,\n 0x882c,\n 'Invalid limit value'\n );\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [toNumber(serializer, this.limit)]\n };\n }\n}\n\n/**\n * @beta\n */\nexport class Offset extends Stage {\n get _name(): string {\n return 'offset';\n }\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private offset: number, options: StageOptions) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [toNumber(serializer, this.offset)]\n };\n }\n}\n\n/**\n * @beta\n */\nexport class Select extends Stage {\n get _name(): string {\n return 'select';\n }\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(\n private selections: Map<string, Expression>,\n options: StageOptions\n ) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [toMapValue(serializer, this.selections)]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.selections, context);\n }\n}\n\n/**\n * @beta\n */\nexport class Sort extends Stage {\n get _name(): string {\n return 'sort';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private orderings: Ordering[], options: StageOptions) {\n super(options);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: this.orderings.map(o => o._toProto(serializer))\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.orderings, context);\n }\n}\n\n/**\n * @beta\n */\nexport class Sample extends Stage {\n get _name(): string {\n return 'sample';\n }\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(\n private rate: number,\n private mode: 'percent' | 'documents',\n options: StageOptions\n ) {\n super(options);\n }\n\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [toNumber(serializer, this.rate)!, toStringValue(this.mode)!]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n }\n}\n\n/**\n * @beta\n */\nexport class Union extends Stage {\n get _name(): string {\n return 'union';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private other: Pipeline, options: StageOptions) {\n super(options);\n }\n\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [toPipelineValue(this.other._toProto(serializer))]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n }\n}\n\n/**\n * @beta\n */\nexport class Unnest extends Stage {\n get _name(): string {\n return 'unnest';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({\n indexField: {\n serverName: 'index_field'\n }\n });\n }\n\n constructor(\n private alias: string,\n private expr: Expression,\n options: StageOptions\n ) {\n super(options);\n }\n\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [\n this.expr._toProto(serializer),\n field(this.alias)._toProto(serializer)\n ]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.expr, context);\n }\n}\n\n/**\n * @beta\n */\nexport class Replace extends Stage {\n static readonly MODE = 'full_replace';\n\n get _name(): string {\n return 'replace_with';\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n\n constructor(private map: Expression, options: StageOptions) {\n super(options);\n }\n\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n ...super._toProto(serializer),\n args: [this.map._toProto(serializer), toStringValue(Replace.MODE)]\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.map, context);\n }\n}\n\n/**\n * @beta\n */\nexport class RawStage extends Stage {\n /**\n * @private\n * @internal\n */\n constructor(\n private name: string,\n private params: Array<AggregateFunction | Expression>,\n rawOptions: Record<string, unknown>\n ) {\n super({ rawOptions });\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(serializer: JsonProtoSerializer): ProtoStage {\n return {\n name: this.name,\n args: this.params.map(o => o._toProto(serializer)),\n options: this.optionsProto\n };\n }\n\n _readUserData(context: ParseContext): void {\n super._readUserData(context);\n readUserDataHelper(this.params, context);\n }\n\n get _name(): string {\n return this.name;\n }\n\n get _optionsUtil(): OptionsUtil {\n return new OptionsUtil({});\n }\n}\n\n/**\n * Helper to read user data across a number of different formats.\n * @param name - Name of the calling function. Used for error messages when invalid user data is encountered.\n * @param expressionMap\n * @returns the expressionMap argument.\n * @private\n */\nfunction readUserDataHelper<\n T extends Map<string, UserData> | UserData[] | UserData\n>(expressionMap: T, context: ParseContext): T {\n if (isUserData(expressionMap)) {\n expressionMap._readUserData(context);\n } else if (Array.isArray(expressionMap)) {\n expressionMap.forEach(readableData => readableData._readUserData(context));\n } else {\n expressionMap.forEach(expr => expr._readUserData(context));\n }\n return expressionMap;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DatabaseId } from '../core/database_info';\nimport { toPipeline } from '../core/pipeline-util';\nimport { Code, FirestoreError } from '../util/error';\nimport { isString } from '../util/types';\n\nimport { Pipeline } from './pipeline';\nimport {\n CollectionReference,\n DocumentReference,\n isCollectionReference,\n Query\n} from './reference';\nimport {\n CollectionGroupSource,\n CollectionSource,\n DatabaseSource,\n DocumentsSource,\n Stage\n} from './stage';\nimport {\n CollectionGroupStageOptions,\n CollectionStageOptions,\n DatabaseStageOptions,\n DocumentsStageOptions\n} from './stage_options';\nimport { UserDataReader, UserDataSource } from './user_data_reader';\n\n/**\n * @beta\n * Provides the entry point for defining the data source of a Firestore {@link @firebase/firestore/pipelines#Pipeline}.\n *\n * Use the methods of this class (e.g., {@link @firebase/firestore/pipelines#PipelineSource.(collection:1)}, {@link @firebase/firestore/pipelines#PipelineSource.(collectionGroup:1)},\n * {@link @firebase/firestore/pipelines#PipelineSource.(database:1)}, or {@link @firebase/firestore/pipelines#PipelineSource.(documents:1)}) to specify the initial data\n * for your pipeline, such as a collection, a collection group, the entire database, or a set of specific documents.\n */\nexport class PipelineSource<PipelineType> {\n /**\n * @internal\n * @private\n * @param databaseId\n * @param userDataReader\n * @param _createPipeline\n */\n constructor(\n private databaseId: DatabaseId,\n private userDataReader: UserDataReader,\n /**\n * @internal\n * @private\n */\n public _createPipeline: (stages: Stage[]) => PipelineType\n ) {}\n\n /**\n * @beta\n * Returns all documents from the entire collection. The collection can be nested.\n * @param collection - Name or reference to the collection that will be used as the Pipeline source.\n */\n collection(collection: string | CollectionReference): PipelineType;\n /**\n * @beta\n * Returns all documents from the entire collection. The collection can be nested.\n * @param options - Options defining how this CollectionStage is evaluated.\n */\n collection(options: CollectionStageOptions): PipelineType;\n collection(\n collectionOrOptions: string | CollectionReference | CollectionStageOptions\n ): PipelineType {\n // Process argument union(s) from method overloads\n const options =\n isString(collectionOrOptions) ||\n isCollectionReference(collectionOrOptions)\n ? {}\n : collectionOrOptions;\n const collectionRefOrString =\n isString(collectionOrOptions) ||\n isCollectionReference(collectionOrOptions)\n ? collectionOrOptions\n : collectionOrOptions.collection;\n\n // Validate that a user provided reference is for the same Firestore DB\n if (isCollectionReference(collectionRefOrString)) {\n this._validateReference(collectionRefOrString);\n }\n\n // Convert user land convenience types to internal types\n const normalizedCollection = isString(collectionRefOrString)\n ? (collectionRefOrString as string)\n : collectionRefOrString.path;\n\n // Create stage object\n const stage = new CollectionSource(normalizedCollection, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'collection'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._createPipeline([stage]);\n }\n\n /**\n * @beta\n * Returns all documents from a collection ID regardless of the parent.\n * @param collectionId - ID of the collection group to use as the Pipeline source.\n */\n collectionGroup(collectionId: string): PipelineType;\n /**\n * @beta\n * Returns all documents from a collection ID regardless of the parent.\n * @param options - Options defining how this CollectionGroupStage is evaluated.\n */\n collectionGroup(options: CollectionGroupStageOptions): PipelineType;\n collectionGroup(\n collectionIdOrOptions: string | CollectionGroupStageOptions\n ): PipelineType {\n // Process argument union(s) from method overloads\n let collectionId: string;\n let options: {};\n if (isString(collectionIdOrOptions)) {\n collectionId = collectionIdOrOptions;\n options = {};\n } else {\n ({ collectionId, ...options } = collectionIdOrOptions);\n }\n\n // Create stage object\n const stage = new CollectionGroupSource(collectionId, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'collectionGroup'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._createPipeline([stage]);\n }\n\n /**\n * @beta\n * Returns all documents from the entire database.\n */\n database(): PipelineType;\n /**\n * @beta\n * Returns all documents from the entire database.\n * @param options - Options defining how a DatabaseStage is evaluated.\n */\n database(options: DatabaseStageOptions): PipelineType;\n database(options?: DatabaseStageOptions): PipelineType {\n // Process argument union(s) from method overloads\n options = options ?? {};\n\n // Create stage object\n const stage = new DatabaseSource(options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'database'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._createPipeline([stage]);\n }\n\n /**\n * @beta\n * Set the pipeline's source to the documents specified by the given paths and DocumentReferences.\n *\n * @param docs - An array of paths and DocumentReferences specifying the individual documents that will be the source of this pipeline.\n * The converters for these DocumentReferences will be ignored and not have an effect on this pipeline.\n *\n * @throws `FirestoreError` Thrown if any of the provided DocumentReferences target a different project or database than the pipeline.\n */\n documents(docs: Array<string | DocumentReference>): PipelineType;\n\n /**\n * @beta\n * Set the pipeline's source to the documents specified by the given paths and DocumentReferences.\n *\n * @param options - Options defining how this DocumentsStage is evaluated.\n *\n * @throws `FirestoreError` Thrown if any of the provided DocumentReferences target a different project or database than the pipeline.\n */\n documents(options: DocumentsStageOptions): PipelineType;\n documents(\n docsOrOptions: Array<string | DocumentReference> | DocumentsStageOptions\n ): PipelineType {\n // Process argument union(s) from method overloads\n let options: {};\n let docs: Array<string | DocumentReference>;\n if (Array.isArray(docsOrOptions)) {\n docs = docsOrOptions;\n options = {};\n } else {\n ({ docs, ...options } = docsOrOptions);\n }\n\n // Validate that all user provided references are for the same Firestore DB\n docs\n .filter(v => v instanceof DocumentReference)\n .forEach(dr => this._validateReference(dr as DocumentReference));\n\n // Convert user land convenience types to internal types\n const normalizedDocs: string[] = docs.map(doc =>\n isString(doc) ? doc : doc.path\n );\n\n // Create stage object\n const stage = new DocumentsSource(normalizedDocs, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'documents'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._createPipeline([stage]);\n }\n\n /**\n * @beta\n * Convert the given Query into an equivalent Pipeline.\n *\n * @param query - A Query to be converted into a Pipeline.\n *\n * @throws `FirestoreError` Thrown if any of the provided DocumentReferences target a different project or database than the pipeline.\n */\n createFrom(query: Query): Pipeline {\n return toPipeline(query._query, query.firestore);\n }\n\n _validateReference(reference: CollectionReference | DocumentReference): void {\n const refDbId = reference.firestore._databaseId;\n if (!refDbId.isEqual(this.databaseId)) {\n throw new FirestoreError(\n Code.INVALID_ARGUMENT,\n `Invalid ${\n reference instanceof CollectionReference\n ? 'CollectionReference'\n : 'DocumentReference'\n }. ` +\n `The project ID (\"${refDbId.projectId}\") or the database (\"${refDbId.database}\") does not match ` +\n `the project ID (\"${this.databaseId.projectId}\") and database (\"${this.databaseId.database}\") of the target database of this Pipeline.`\n );\n }\n }\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ObjectValue } from '../model/object_value';\nimport { firestoreV1ApiClientInterfaces } from '../protos/firestore_proto_api';\nimport { isOptionalEqual } from '../util/misc';\n\nimport { Field, isField } from './expressions';\nimport { FieldPath } from './field_path';\nimport { Pipeline } from './pipeline';\nimport { DocumentData, DocumentReference, refEqual } from './reference';\nimport { Timestamp } from './timestamp';\nimport { fieldPathFromArgument } from './user_data_reader';\nimport { AbstractUserDataWriter } from './user_data_writer';\n\n/**\n * @beta\n * Represents the results of a Firestore pipeline execution.\n *\n * A `PipelineSnapshot` contains zero or more {@link @firebase/firestore/pipelines#PipelineResult} objects\n * representing the documents returned by a pipeline query. It provides methods\n * to iterate over the documents and access metadata about the query results.\n *\n * @example\n * ```typescript\n * const snapshot: PipelineSnapshot = await firestore\n * .pipeline()\n * .collection('myCollection')\n * .where(field('value').greaterThan(10))\n * .execute();\n *\n * snapshot.results.forEach(doc => {\n * console.log(doc.id, '=>', doc.data());\n * });\n * ```\n */\nexport class PipelineSnapshot {\n private readonly _pipeline: Pipeline;\n private readonly _executionTime: Timestamp | undefined;\n private readonly _results: PipelineResult[];\n constructor(\n pipeline: Pipeline,\n results: PipelineResult[],\n executionTime?: Timestamp\n ) {\n this._pipeline = pipeline;\n this._executionTime = executionTime;\n this._results = results;\n }\n\n /**\n * @beta An array of all the results in the `PipelineSnapshot`.\n */\n get results(): PipelineResult[] {\n return this._results;\n }\n\n /**\n * @beta\n * The time at which the pipeline producing this result is executed.\n *\n * @readonly\n *\n */\n get executionTime(): Timestamp {\n if (this._executionTime === undefined) {\n throw new Error(\n \"'executionTime' is expected to exist, but it is undefined\"\n );\n }\n return this._executionTime;\n }\n}\n\n/**\n * @beta\n *\n * A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the\n * {@link @firebase/firestore/pipelines#PipelineResult.data} or {@link @firebase/firestore/pipelines#PipelineResult.(get:1)} methods.\n *\n * <p>If the PipelineResult represents a non-document result, `ref` will return a undefined\n * value.\n */\nexport class PipelineResult<AppModelType = DocumentData> {\n private readonly _userDataWriter: AbstractUserDataWriter;\n\n private readonly _createTime: Timestamp | undefined;\n private readonly _updateTime: Timestamp | undefined;\n\n /**\n * @internal\n * @private\n */\n readonly _ref: DocumentReference | undefined;\n\n /**\n * @internal\n * @private\n */\n readonly _fields: ObjectValue;\n\n /**\n * @private\n * @internal\n *\n * @param userDataWriter - The serializer used to encode/decode protobuf.\n * @param ref - The reference to the document.\n * @param fields - The fields of the Firestore `Document` Protobuf backing\n * this document.\n * @param createTime - The time when the document was created if the result is a document, undefined otherwise.\n * @param updateTime - The time when the document was last updated if the result is a document, undefined otherwise.\n */\n constructor(\n userDataWriter: AbstractUserDataWriter,\n fields: ObjectValue,\n ref?: DocumentReference,\n createTime?: Timestamp,\n updateTime?: Timestamp\n ) {\n this._ref = ref;\n this._userDataWriter = userDataWriter;\n this._createTime = createTime;\n this._updateTime = updateTime;\n this._fields = fields;\n }\n\n /**\n * @beta\n * The reference of the document, if it is a document; otherwise `undefined`.\n */\n get ref(): DocumentReference | undefined {\n return this._ref;\n }\n\n /**\n * @beta\n * The ID of the document for which this PipelineResult contains data, if it is a document; otherwise `undefined`.\n *\n * @readonly\n *\n */\n get id(): string | undefined {\n return this._ref?.id;\n }\n\n /**\n * @beta\n * The time the document was created. Undefined if this result is not a document.\n *\n * @readonly\n */\n get createTime(): Timestamp | undefined {\n return this._createTime;\n }\n\n /**\n * @beta\n * The time the document was last updated (at the time the snapshot was\n * generated). Undefined if this result is not a document.\n *\n * @readonly\n */\n get updateTime(): Timestamp | undefined {\n return this._updateTime;\n }\n\n /**\n * @beta\n * Retrieves all fields in the result as an object.\n *\n * @returns An object containing all fields in the document or\n * 'undefined' if the document doesn't exist.\n *\n * @example\n * ```\n * let p = firestore.pipeline().collection('col');\n *\n * p.execute().then(results => {\n * let data = results[0].data();\n * console.log(`Retrieved data: ${JSON.stringify(data)}`);\n * });\n * ```\n */\n data(): AppModelType {\n return this._userDataWriter.convertValue(\n this._fields.value\n ) as AppModelType;\n }\n\n /**\n * @internal\n * @private\n *\n * Retrieves all fields in the result as a proto value.\n *\n * @returns An `Object` containing all fields in the result.\n */\n _fieldsProto(): { [key: string]: firestoreV1ApiClientInterfaces.Value } {\n // Return a cloned value to prevent manipulation of the Snapshot's data\n return this._fields.clone().value.mapValue.fields!;\n }\n\n /**\n * @beta\n * Retrieves the field specified by `field`.\n *\n * @param field - The field path\n * (e.g. 'foo' or 'foo.bar') to a specific field.\n * @returns The data at the specified field location or `undefined` if no\n * such field exists.\n *\n * @example\n * ```\n * let p = firestore.pipeline().collection('col');\n *\n * p.execute().then(results => {\n * let field = results[0].get('a.b');\n * console.log(`Retrieved field value: ${field}`);\n * });\n * ```\n */\n // We deliberately use `any` in the external API to not impose type-checking\n // on end users.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get(fieldPath: string | FieldPath | Field): any {\n if (this._fields === undefined) {\n return undefined;\n }\n if (isField(fieldPath)) {\n fieldPath = fieldPath.fieldName;\n }\n\n const value = this._fields.field(\n fieldPathFromArgument('DocumentSnapshot.get', fieldPath)\n );\n if (value !== null) {\n return this._userDataWriter.convertValue(value);\n }\n }\n}\n\n/**\n * @beta\n * Test equality of two PipelineResults.\n * @param left - First PipelineResult to compare.\n * @param right - Second PipelineResult to compare.\n */\nexport function pipelineResultEqual(\n left: PipelineResult,\n right: PipelineResult\n): boolean {\n if (left === right) {\n return true;\n }\n\n return (\n isOptionalEqual(left._ref, right._ref, refEqual) &&\n isOptionalEqual(left._fields, right._fields, (l, r) => l.isEqual(r))\n );\n}\n","/**\n * @license\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FirestoreError, vector } from '../api';\nimport {\n _constant,\n AggregateFunction,\n AliasedAggregate,\n array,\n constant,\n Expression,\n AliasedExpression,\n field,\n Field,\n map,\n Selectable\n} from '../lite-api/expressions';\nimport { VectorValue } from '../lite-api/vector_value';\n\nimport { fail } from './assert';\nimport { isPlainObject } from './input_validation';\nimport { isFirestoreValue } from './proto';\nimport { isString } from './types';\n\nexport function selectablesToMap(\n selectables: Array<Selectable | string>\n): Map<string, Expression> {\n const result = new Map<string, Expression>();\n for (const selectable of selectables) {\n let alias: string;\n let expression: Expression;\n if (typeof selectable === 'string') {\n alias = selectable as string;\n expression = field(selectable);\n } else if (selectable instanceof Field) {\n alias = selectable.alias;\n expression = selectable.expr;\n } else if (selectable instanceof AliasedExpression) {\n alias = selectable.alias;\n expression = selectable.expr;\n } else {\n fail(0x5319, '`selectable` has an unsupported type', { selectable });\n }\n\n if (result.get(alias) !== undefined) {\n throw new FirestoreError(\n 'invalid-argument',\n `Duplicate alias or field '${alias}'`\n );\n }\n\n result.set(alias, expression);\n }\n return result;\n}\n\nexport function aliasedAggregateToMap(\n aliasedAggregatees: AliasedAggregate[]\n): Map<string, AggregateFunction> {\n return aliasedAggregatees.reduce(\n (map: Map<string, AggregateFunction>, selectable: AliasedAggregate) => {\n if (map.get(selectable.alias) !== undefined) {\n throw new FirestoreError(\n 'invalid-argument',\n `Duplicate alias or field '${selectable.alias}'`\n );\n }\n\n map.set(selectable.alias, selectable.aggregate as AggregateFunction);\n return map;\n },\n new Map() as Map<string, AggregateFunction>\n );\n}\n\n/**\n * Converts a value to an Expression, Returning either a Constant, MapFunction,\n * ArrayFunction, or the input itself (if it's already an expression).\n *\n * @private\n * @internal\n * @param value\n */\nexport function vectorToExpr(\n value: VectorValue | number[] | Expression\n): Expression {\n if (value instanceof Expression) {\n return value;\n } else if (value instanceof VectorValue) {\n const result = constant(value);\n return result;\n } else if (Array.isArray(value)) {\n const result = constant(vector(value));\n return result;\n } else {\n throw new Error('Unsupported value: ' + typeof value);\n }\n}\n\n/**\n * Converts a value to an Expression, Returning either a Constant, MapFunction,\n * ArrayFunction, or the input itself (if it's already an expression).\n * If the input is a string, it is assumed to be a field name, and a\n * field(value) is returned.\n *\n * @private\n * @internal\n * @param value\n */\nexport function fieldOrExpression(value: unknown): Expression {\n if (isString(value)) {\n const result = field(value);\n return result;\n } else {\n return valueToDefaultExpr(value);\n }\n}\n/**\n * Converts a value to an Expression, Returning either a Constant, MapFunction,\n * ArrayFunction, or the input itself (if it's already an expression).\n *\n * @private\n * @internal\n * @param value\n */\nexport function valueToDefaultExpr(value: unknown): Expression {\n let result: Expression | undefined;\n if (isFirestoreValue(value)) {\n return constant(value);\n }\n if (value instanceof Expression) {\n return value;\n } else if (isPlainObject(value)) {\n result = map(value as Record<string, unknown>);\n } else if (value instanceof Array) {\n result = array(value);\n } else {\n result = _constant(value, undefined);\n }\n\n return result;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Pipeline as ProtoPipeline,\n Stage as ProtoStage\n} from '../protos/firestore_proto_api';\nimport { JsonProtoSerializer, ProtoSerializable } from '../remote/serializer';\nimport { isPlainObject } from '../util/input_validation';\nimport {\n aliasedAggregateToMap,\n fieldOrExpression,\n selectablesToMap,\n vectorToExpr\n} from '../util/pipeline_util';\nimport { isNumber, isString } from '../util/types';\n\nimport { Firestore } from './database';\nimport {\n _mapValue,\n AggregateFunction,\n AliasedAggregate,\n BooleanExpression,\n _constant,\n Expression,\n Field,\n field,\n Ordering,\n Selectable,\n _field,\n isSelectable,\n isField,\n isBooleanExpr,\n isAliasedAggregate,\n toField,\n isOrdering,\n isExpr\n} from './expressions';\nimport {\n AddFields,\n Aggregate,\n Distinct,\n FindNearest,\n RawStage,\n Limit,\n Offset,\n RemoveFields,\n Replace,\n Sample,\n Select,\n Sort,\n Stage,\n Union,\n Unnest,\n Where\n} from './stage';\nimport {\n AddFieldsStageOptions,\n AggregateStageOptions,\n DistinctStageOptions,\n FindNearestStageOptions,\n LimitStageOptions,\n OffsetStageOptions,\n RemoveFieldsStageOptions,\n ReplaceWithStageOptions,\n SampleStageOptions,\n SelectStageOptions,\n SortStageOptions,\n StageOptions,\n UnionStageOptions,\n UnnestStageOptions,\n WhereStageOptions\n} from './stage_options';\nimport { UserDataReader, UserDataSource } from './user_data_reader';\nimport { AbstractUserDataWriter } from './user_data_writer';\n\n/**\n * @beta\n *\n * The Pipeline class provides a flexible and expressive framework for building complex data\n * transformation and query pipelines for Firestore.\n *\n * A pipeline takes data sources, such as Firestore collections or collection groups, and applies\n * a series of stages that are chained together. Each stage takes the output from the previous stage\n * (or the data source) and produces an output for the next stage (or as the final output of the\n * pipeline).\n *\n * Expressions can be used within each stage to filter and transform data through the stage.\n *\n * NOTE: The chained stages do not prescribe exactly how Firestore will execute the pipeline.\n * Instead, Firestore only guarantees that the result is the same as if the chained stages were\n * executed in order.\n *\n * Usage Examples:\n *\n * @example\n * ```typescript\n * const db: Firestore; // Assumes a valid firestore instance.\n *\n * // Example 1: Select specific fields and rename 'rating' to 'bookRating'\n * const results1 = await execute(db.pipeline()\n * .collection(\"books\")\n * .select(\"title\", \"author\", field(\"rating\").as(\"bookRating\")));\n *\n * // Example 2: Filter documents where 'genre' is \"Science Fiction\" and 'published' is after 1950\n * const results2 = await execute(db.pipeline()\n * .collection(\"books\")\n * .where(and(field(\"genre\").eq(\"Science Fiction\"), field(\"published\").gt(1950))));\n *\n * // Example 3: Calculate the average rating of books published after 1980\n * const results3 = await execute(db.pipeline()\n * .collection(\"books\")\n * .where(field(\"published\").gt(1980))\n * .aggregate(avg(field(\"rating\")).as(\"averageRating\")));\n * ```\n */\nexport class Pipeline implements ProtoSerializable<ProtoPipeline> {\n /**\n * @internal\n * @private\n * @param _db\n * @param userDataReader\n * @param _userDataWriter\n * @param stages\n */\n constructor(\n /**\n * @internal\n * @private\n */\n public _db: Firestore,\n /**\n * @internal\n * @private\n */\n private userDataReader: UserDataReader,\n /**\n * @internal\n * @private\n */\n public _userDataWriter: AbstractUserDataWriter,\n /**\n * @internal\n * @private\n */\n private stages: Stage[]\n ) {}\n\n /**\n * @beta\n * Adds new fields to outputs from previous stages.\n *\n * This stage allows you to compute values on-the-fly based on existing data from previous\n * stages or constants. You can use this to create new fields or overwrite existing ones (if there\n * is name overlaps).\n *\n * The added fields are defined using {@link @firebase/firestore/pipelines#Selectable}s, which can be:\n *\n * - {@link @firebase/firestore/pipelines#Field}: References an existing document field.\n * - {@link @firebase/firestore/pipelines#Expression}: Either a literal value (see {@link @firebase/firestore/pipelines#(constant:1)}) or a computed value\n * with an assigned alias using {@link @firebase/firestore/pipelines#Expression.(as:1)}.\n *\n * Example:\n *\n * @example\n * ```typescript\n * firestore.pipeline().collection(\"books\")\n * .addFields(\n * field(\"rating\").as(\"bookRating\"), // Rename 'rating' to 'bookRating'\n * add(5, field(\"quantity\")).as(\"totalCost\") // Calculate 'totalCost'\n * );\n * ```\n *\n * @param field - The first field to add to the documents, specified as a {@link @firebase/firestore/pipelines#Selectable}.\n * @param additionalFields - Optional additional fields to add to the documents, specified as {@link @firebase/firestore/pipelines#Selectable}s.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n addFields(field: Selectable, ...additionalFields: Selectable[]): Pipeline;\n /**\n * @beta\n * Adds new fields to outputs from previous stages.\n *\n * This stage allows you to compute values on-the-fly based on existing data from previous\n * stages or constants. You can use this to create new fields or overwrite existing ones (if there\n * is name overlaps).\n *\n * The added fields are defined using {@link @firebase/firestore/pipelines#Selectable}s, which can be:\n *\n * - {@link @firebase/firestore/pipelines#Field}: References an existing document field.\n * - {@link @firebase/firestore/pipelines#Expression}: Either a literal value (see {@link @firebase/firestore/pipelines#(constant:1)}) or a computed value\n * with an assigned alias using {@link @firebase/firestore/pipelines#Expression.(as:1)}.\n *\n * Example:\n *\n * @example\n * ```typescript\n * firestore.pipeline().collection(\"books\")\n * .addFields(\n * field(\"rating\").as(\"bookRating\"), // Rename 'rating' to 'bookRating'\n * add(5, field(\"quantity\")).as(\"totalCost\") // Calculate 'totalCost'\n * );\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n addFields(options: AddFieldsStageOptions): Pipeline;\n addFields(\n fieldOrOptions: Selectable | AddFieldsStageOptions,\n ...additionalFields: Selectable[]\n ): Pipeline {\n // Process argument union(s) from method overloads\n let fields: Selectable[];\n let options: {};\n if (isSelectable(fieldOrOptions)) {\n fields = [fieldOrOptions, ...additionalFields];\n options = {};\n } else {\n ({ fields, ...options } = fieldOrOptions);\n }\n\n // Convert user land convenience types to internal types\n const normalizedFields: Map<string, Expression> = selectablesToMap(fields);\n\n // Create stage object\n const stage = new AddFields(normalizedFields, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'addFields'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Remove fields from outputs of previous stages.\n *\n * Example:\n *\n * @example\n * ```typescript\n * firestore.pipeline().collection('books')\n * // removes field 'rating' and 'cost' from the previous stage outputs.\n * .removeFields(\n * field('rating'),\n * 'cost'\n * );\n * ```\n *\n * @param fieldValue - The first field to remove.\n * @param additionalFields - Optional additional fields to remove.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n removeFields(\n fieldValue: Field | string,\n ...additionalFields: Array<Field | string>\n ): Pipeline;\n /**\n * @beta\n * Remove fields from outputs of previous stages.\n *\n * Example:\n *\n * @example\n * ```typescript\n * firestore.pipeline().collection('books')\n * // removes field 'rating' and 'cost' from the previous stage outputs.\n * .removeFields(\n * field('rating'),\n * 'cost'\n * );\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n removeFields(options: RemoveFieldsStageOptions): Pipeline;\n removeFields(\n fieldValueOrOptions: Field | string | RemoveFieldsStageOptions,\n ...additionalFields: Array<Field | string>\n ): Pipeline {\n // Process argument union(s) from method overloads\n const options =\n isField(fieldValueOrOptions) || isString(fieldValueOrOptions)\n ? {}\n : fieldValueOrOptions;\n const fields: Array<Field | string> =\n isField(fieldValueOrOptions) || isString(fieldValueOrOptions)\n ? [fieldValueOrOptions, ...additionalFields]\n : fieldValueOrOptions.fields;\n\n // Convert user land convenience types to internal types\n const convertedFields: Field[] = fields.map(f =>\n isString(f) ? field(f) : (f as Field)\n );\n\n // Create stage object\n const stage = new RemoveFields(convertedFields, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n stage._readUserData(\n this.userDataReader.createContext(UserDataSource.Argument, 'removeFields')\n );\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Selects or creates a set of fields from the outputs of previous stages.\n *\n * <p>The selected fields are defined using {@link @firebase/firestore/pipelines#Selectable} expressions, which can be:\n *\n * <ul>\n * <li>`string` : Name of an existing field</li>\n * <li>{@link @firebase/firestore/pipelines#Field}: References an existing field.</li>\n * <li>{@link @firebase/firestore/pipelines#AliasedExpression}: Represents the result of a function with an assigned alias name using\n * {@link @firebase/firestore/pipelines#Expression.(as:1)}</li>\n * </ul>\n *\n * <p>If no selections are provided, the output of this stage is empty. Use {@link\n * @firebase/firestore/pipelines#Pipeline.(addFields:1)} instead if only additions are\n * desired.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * db.pipeline().collection(\"books\")\n * .select(\n * \"firstName\",\n * field(\"lastName\"),\n * field(\"address\").toUppercase().as(\"upperAddress\"),\n * );\n * ```\n *\n * @param selection - The first field to include in the output documents, specified as {@link\n * @firebase/firestore/pipelines#Selectable} expression or string value representing the field name.\n * @param additionalSelections - Optional additional fields to include in the output documents, specified as {@link\n * @firebase/firestore/pipelines#Selectable} expressions or `string` values representing field names.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n select(\n selection: Selectable | string,\n ...additionalSelections: Array<Selectable | string>\n ): Pipeline;\n /**\n * @beta\n * Selects or creates a set of fields from the outputs of previous stages.\n *\n * <p>The selected fields are defined using {@link @firebase/firestore/pipelines#Selectable} expressions, which can be:\n *\n * <ul>\n * <li>`string`: Name of an existing field</li>\n * <li>{@link @firebase/firestore/pipelines#Field}: References an existing field.</li>\n * <li>{@link @firebase/firestore/pipelines#AliasedExpression}: Represents the result of a function with an assigned alias name using\n * {@link @firebase/firestore/pipelines#Expression.(as:1)}</li>\n * </ul>\n *\n * <p>If no selections are provided, the output of this stage is empty. Use {@link\n * @firebase/firestore/pipelines#Pipeline.(addFields:1)} instead if only additions are\n * desired.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * db.pipeline().collection(\"books\")\n * .select(\n * \"firstName\",\n * field(\"lastName\"),\n * field(\"address\").toUppercase().as(\"upperAddress\"),\n * );\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n select(options: SelectStageOptions): Pipeline;\n select(\n selectionOrOptions: Selectable | string | SelectStageOptions,\n ...additionalSelections: Array<Selectable | string>\n ): Pipeline {\n // Process argument union(s) from method overloads\n const options =\n isSelectable(selectionOrOptions) || isString(selectionOrOptions)\n ? {}\n : selectionOrOptions;\n\n const selections: Array<Selectable | string> =\n isSelectable(selectionOrOptions) || isString(selectionOrOptions)\n ? [selectionOrOptions, ...additionalSelections]\n : selectionOrOptions.selections;\n\n // Convert user land convenience types to internal types\n const normalizedSelections: Map<string, Expression> =\n selectablesToMap(selections);\n\n // Create stage object\n const stage = new Select(normalizedSelections, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'select'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Filters the documents from previous stages to only include those matching the specified {@link\n * @firebase/firestore/pipelines#BooleanExpression}.\n *\n * <p>This stage allows you to apply conditions to the data, similar to a \"WHERE\" clause in SQL.\n * You can filter documents based on their field values, using implementations of {@link\n * @firebase/firestore/pipelines#BooleanExpression}, typically including but not limited to:\n *\n * <ul>\n * <li>field comparators: {@link @firebase/firestore/pipelines#Expression.(equal:1)}, {@link @firebase/firestore/pipelines#Expression.(lessThan:1)}, {@link\n * @firebase/firestore/pipelines#Expression.(greaterThan:1)}, etc.</li>\n * <li>logical operators: {@link @firebase/firestore/pipelines#Expression.(and:1)}, {@link @firebase/firestore/pipelines#Expression.(or:1)}, {@link @firebase/firestore/pipelines#Expression.(not:1)}, etc.</li>\n * <li>advanced functions: {@link @firebase/firestore/pipelines#Expression.(regexMatch:1)}, {@link\n * @firebase/firestore/pipelines#Expression.(arrayContains:1)}, etc.</li>\n * </ul>\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * firestore.pipeline().collection(\"books\")\n * .where(\n * and(\n * gt(field(\"rating\"), 4.0), // Filter for ratings greater than 4.0\n * field(\"genre\").eq(\"Science Fiction\") // Equivalent to gt(\"genre\", \"Science Fiction\")\n * )\n * );\n * ```\n *\n * @param condition - The {@link @firebase/firestore/pipelines#BooleanExpression} to apply.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n where(condition: BooleanExpression): Pipeline;\n /**\n * @beta\n * Filters the documents from previous stages to only include those matching the specified {@link\n * @firebase/firestore/pipelines#BooleanExpression}.\n *\n * <p>This stage allows you to apply conditions to the data, similar to a \"WHERE\" clause in SQL.\n * You can filter documents based on their field values, using implementations of {@link\n * @firebase/firestore/pipelines#BooleanExpression}, typically including but not limited to:\n *\n * <ul>\n * <li>field comparators: {@link @firebase/firestore/pipelines#Expression.(eq:1)}, {@link @firebase/firestore/pipelines#Expression.(lt:1)} (less than), {@link\n * @firebase/firestore/pipelines#Expression.(greaterThan:1)}, etc.</li>\n * <li>logical operators: {@link @firebase/firestore/pipelines#Expression.(and:1)}, {@link @firebase/firestore/pipelines#Expression.(or:1)}, {@link @firebase/firestore/pipelines#Expression.(not:1)}, etc.</li>\n * <li>advanced functions: {@link @firebase/firestore/pipelines#Expression.(regexMatch:1)}, {@link\n * @firebase/firestore/pipelines#Expression.(arrayContains:1)}, etc.</li>\n * </ul>\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * firestore.pipeline().collection(\"books\")\n * .where(\n * and(\n * gt(field(\"rating\"), 4.0), // Filter for ratings greater than 4.0\n * field(\"genre\").eq(\"Science Fiction\") // Equivalent to gt(\"genre\", \"Science Fiction\")\n * )\n * );\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n where(options: WhereStageOptions): Pipeline;\n where(conditionOrOptions: BooleanExpression | WhereStageOptions): Pipeline {\n // Process argument union(s) from method overloads\n const options = isBooleanExpr(conditionOrOptions) ? {} : conditionOrOptions;\n const condition: BooleanExpression = isBooleanExpr(conditionOrOptions)\n ? conditionOrOptions\n : conditionOrOptions.condition;\n\n // Create stage object\n const stage = new Where(condition, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'where'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Skips the first `offset` number of documents from the results of previous stages.\n *\n * <p>This stage is useful for implementing pagination in your pipelines, allowing you to retrieve\n * results in chunks. It is typically used in conjunction with {@link @firebase/firestore/pipelines#Pipeline.limit} to control the\n * size of each page.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Retrieve the second page of 20 results\n * firestore.pipeline().collection('books')\n * .sort(field('published').descending())\n * .offset(20) // Skip the first 20 results\n * .limit(20); // Take the next 20 results\n * ```\n *\n * @param offset - The number of documents to skip.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n offset(offset: number): Pipeline;\n /**\n * @beta\n * Skips the first `offset` number of documents from the results of previous stages.\n *\n * <p>This stage is useful for implementing pagination in your pipelines, allowing you to retrieve\n * results in chunks. It is typically used in conjunction with {@link @firebase/firestore/pipelines#Pipeline.limit} to control the\n * size of each page.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Retrieve the second page of 20 results\n * firestore.pipeline().collection('books')\n * .sort(field('published').descending())\n * .offset(20) // Skip the first 20 results\n * .limit(20); // Take the next 20 results\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n offset(options: OffsetStageOptions): Pipeline;\n offset(offsetOrOptions: number | OffsetStageOptions): Pipeline {\n // Process argument union(s) from method overloads\n let options: {};\n let offset: number;\n if (isNumber(offsetOrOptions)) {\n options = {};\n offset = offsetOrOptions;\n } else {\n options = offsetOrOptions;\n offset = offsetOrOptions.offset;\n }\n\n // Create stage object\n const stage = new Offset(offset, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'offset'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Limits the maximum number of documents returned by previous stages to `limit`.\n *\n * <p>This stage is particularly useful when you want to retrieve a controlled subset of data from\n * a potentially large result set. It's often used for:\n *\n * <ul>\n * <li>**Pagination:** In combination with {@link @firebase/firestore/pipelines#Pipeline.offset} to retrieve specific pages of\n * results.</li>\n * <li>**Limiting Data Retrieval:** To prevent excessive data transfer and improve performance,\n * especially when dealing with large collections.</li>\n * </ul>\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Limit the results to the top 10 highest-rated books\n * firestore.pipeline().collection('books')\n * .sort(field('rating').descending())\n * .limit(10);\n * ```\n *\n * @param limit - The maximum number of documents to return.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n limit(limit: number): Pipeline;\n /**\n * @beta\n * Limits the maximum number of documents returned by previous stages to `limit`.\n *\n * <p>This stage is particularly useful when you want to retrieve a controlled subset of data from\n * a potentially large result set. It's often used for:\n *\n * <ul>\n * <li>**Pagination:** In combination with {@link @firebase/firestore/pipelines#Pipeline.offset} to retrieve specific pages of\n * results.</li>\n * <li>**Limiting Data Retrieval:** To prevent excessive data transfer and improve performance,\n * especially when dealing with large collections.</li>\n * </ul>\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Limit the results to the top 10 highest-rated books\n * firestore.pipeline().collection('books')\n * .sort(field('rating').descending())\n * .limit(10);\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n limit(options: LimitStageOptions): Pipeline;\n limit(limitOrOptions: number | LimitStageOptions): Pipeline {\n // Process argument union(s) from method overloads\n const options = isNumber(limitOrOptions) ? {} : limitOrOptions;\n const limit: number = isNumber(limitOrOptions)\n ? limitOrOptions\n : limitOrOptions.limit;\n\n // Create stage object\n const stage = new Limit(limit, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'limit'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Returns a set of distinct values from the inputs to this stage.\n *\n * This stage runs through the results from previous stages to include only results with\n * unique combinations of {@link @firebase/firestore/pipelines#Expression} values ({@link @firebase/firestore/pipelines#Field}, {@link @firebase/firestore/pipelines#AliasedExpression}, etc).\n *\n * The parameters to this stage are defined using {@link @firebase/firestore/pipelines#Selectable} expressions or strings:\n *\n * - `string`: Name of an existing field\n * - {@link @firebase/firestore/pipelines#Field}: References an existing document field.\n * - {@link @firebase/firestore/pipelines#AliasedExpression}: Represents the result of a function with an assigned alias name\n * using {@link @firebase/firestore/pipelines#Expression.(as:1)}.\n *\n * Example:\n *\n * @example\n * ```typescript\n * // Get a list of unique author names in uppercase and genre combinations.\n * firestore.pipeline().collection(\"books\")\n * .distinct(toUppercase(field(\"author\")).as(\"authorName\"), field(\"genre\"), \"publishedAt\")\n * .select(\"authorName\");\n * ```\n *\n * @param group - The {@link @firebase/firestore/pipelines#Selectable} expression or field name to consider when determining\n * distinct value combinations.\n * @param additionalGroups - Optional additional {@link @firebase/firestore/pipelines#Selectable} expressions to consider when determining distinct\n * value combinations or strings representing field names.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n distinct(\n group: string | Selectable,\n ...additionalGroups: Array<string | Selectable>\n ): Pipeline;\n /**\n * @beta\n * Returns a set of distinct values from the inputs to this stage.\n *\n * This stage runs through the results from previous stages to include only results with\n * unique combinations of {@link @firebase/firestore/pipelines#Expression} values ({@link @firebase/firestore/pipelines#Field}, {@link @firebase/firestore/pipelines#AliasedExpression}, etc).\n *\n * The parameters to this stage are defined using {@link @firebase/firestore/pipelines#Selectable} expressions or strings:\n *\n * - `string`: Name of an existing field\n * - {@link @firebase/firestore/pipelines#Field}: References an existing document field.\n * - {@link @firebase/firestore/pipelines#AliasedExpression}: Represents the result of a function with an assigned alias name\n * using {@link @firebase/firestore/pipelines#Expression.(as:1)}.\n *\n * Example:\n *\n * @example\n * ```typescript\n * // Get a list of unique author names in uppercase and genre combinations.\n * firestore.pipeline().collection(\"books\")\n * .distinct(toUppercase(field(\"author\")).as(\"authorName\"), field(\"genre\"), \"publishedAt\")\n * .select(\"authorName\");\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n distinct(options: DistinctStageOptions): Pipeline;\n distinct(\n groupOrOptions: string | Selectable | DistinctStageOptions,\n ...additionalGroups: Array<string | Selectable>\n ): Pipeline {\n // Process argument union(s) from method overloads\n const options =\n isString(groupOrOptions) || isSelectable(groupOrOptions)\n ? {}\n : groupOrOptions;\n const groups: Array<string | Selectable> =\n isString(groupOrOptions) || isSelectable(groupOrOptions)\n ? [groupOrOptions, ...additionalGroups]\n : groupOrOptions.groups;\n\n // Convert user land convenience types to internal types\n const convertedGroups: Map<string, Expression> = selectablesToMap(groups);\n\n // Create stage object\n const stage = new Distinct(convertedGroups, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'distinct'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Performs aggregation operations on the documents from previous stages.\n *\n * <p>This stage allows you to calculate aggregate values over a set of documents. You define the\n * aggregations to perform using {@link @firebase/firestore/pipelines#AliasedAggregate} expressions which are typically results of\n * calling {@link @firebase/firestore/pipelines#Expression.(as:1)} on {@link @firebase/firestore/pipelines#AggregateFunction} instances.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Calculate the average rating and the total number of books\n * firestore.pipeline().collection(\"books\")\n * .aggregate(\n * field(\"rating\").avg().as(\"averageRating\"),\n * countAll().as(\"totalBooks\")\n * );\n * ```\n *\n * @param accumulator - The first {@link @firebase/firestore/pipelines#AliasedAggregate}, wrapping an {@link @firebase/firestore/pipelines#AggregateFunction}\n * and providing a name for the accumulated results.\n * @param additionalAccumulators - Optional additional {@link @firebase/firestore/pipelines#AliasedAggregate}, each wrapping an {@link @firebase/firestore/pipelines#AggregateFunction}\n * and providing a name for the accumulated results.\n * @returns A new Pipeline object with this stage appended to the stage list.\n */\n aggregate(\n accumulator: AliasedAggregate,\n ...additionalAccumulators: AliasedAggregate[]\n ): Pipeline;\n /**\n * @beta\n * Performs optionally grouped aggregation operations on the documents from previous stages.\n *\n * <p>This stage allows you to calculate aggregate values over a set of documents, optionally\n * grouped by one or more fields or functions. You can specify:\n *\n * <ul>\n * <li>**Grouping Fields or Functions:** One or more fields or functions to group the documents\n * by. For each distinct combination of values in these fields, a separate group is created.\n * If no grouping fields are provided, a single group containing all documents is used. Not\n * specifying groups is the same as putting the entire inputs into one group.</li>\n * <li>**Accumulators:** One or more accumulation operations to perform within each group. These\n * are defined using {@link @firebase/firestore/pipelines#AliasedAggregate} expressions, which are typically created by\n * calling {@link @firebase/firestore/pipelines#Expression.(as:1)} on {@link @firebase/firestore/pipelines#AggregateFunction} instances. Each aggregation\n * calculates a value (e.g., sum, average, count) based on the documents within its group.</li>\n * </ul>\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Calculate the average rating for each genre.\n * firestore.pipeline().collection(\"books\")\n * .aggregate({\n * accumulators: [avg(field(\"rating\")).as(\"avg_rating\")]\n * groups: [\"genre\"]\n * });\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage\n * list.\n */\n aggregate(options: AggregateStageOptions): Pipeline;\n aggregate(\n targetOrOptions: AliasedAggregate | AggregateStageOptions,\n ...rest: AliasedAggregate[]\n ): Pipeline {\n // Process argument union(s) from method overloads\n const options = isAliasedAggregate(targetOrOptions) ? {} : targetOrOptions;\n const accumulators: AliasedAggregate[] = isAliasedAggregate(targetOrOptions)\n ? [targetOrOptions, ...rest]\n : targetOrOptions.accumulators;\n const groups: Array<Selectable | string> = isAliasedAggregate(\n targetOrOptions\n )\n ? []\n : targetOrOptions.groups ?? [];\n\n // Convert user land convenience types to internal types\n const convertedAccumulators: Map<string, AggregateFunction> =\n aliasedAggregateToMap(accumulators);\n const convertedGroups: Map<string, Expression> = selectablesToMap(groups);\n\n // Create stage object\n const stage = new Aggregate(\n convertedGroups,\n convertedAccumulators,\n options\n );\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'aggregate'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Performs a vector proximity search on the documents from the previous stage, returning the\n * K-nearest documents based on the specified query `vectorValue` and `distanceMeasure`. The\n * returned documents will be sorted in order from nearest to furthest from the query `vectorValue`.\n *\n * <p>Example:\n *\n * ```typescript\n * // Find the 10 most similar books based on the book description.\n * const bookDescription = \"Lorem ipsum...\";\n * const queryVector: number[] = ...; // compute embedding of `bookDescription`\n *\n * firestore.pipeline().collection(\"books\")\n * .findNearest({\n * field: 'embedding',\n * vectorValue: queryVector,\n * distanceMeasure: 'euclidean',\n * limit: 10, // optional\n * distanceField: 'computedDistance' // optional\n * });\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n findNearest(options: FindNearestStageOptions): Pipeline {\n // Convert user land convenience types to internal types\n const field = toField(options.field);\n const vectorValue = vectorToExpr(options.vectorValue);\n const distanceField = options.distanceField\n ? toField(options.distanceField)\n : undefined;\n const internalOptions = {\n distanceField,\n limit: options.limit,\n rawOptions: options.rawOptions\n };\n\n // Create stage object\n const stage = new FindNearest(\n vectorValue,\n field,\n options.distanceMeasure,\n internalOptions\n );\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'addFields'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Sorts the documents from previous stages based on one or more {@link @firebase/firestore/pipelines#Ordering} criteria.\n *\n * <p>This stage allows you to order the results of your pipeline. You can specify multiple {@link\n * @firebase/firestore/pipelines#Ordering} instances to sort by multiple fields in ascending or descending order. If documents\n * have the same value for a field used for sorting, the next specified ordering will be used. If\n * all orderings result in equal comparison, the documents are considered equal and the order is\n * unspecified.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Sort books by rating in descending order, and then by title in ascending order for books\n * // with the same rating\n * firestore.pipeline().collection(\"books\")\n * .sort(\n * Ordering.of(field(\"rating\")).descending(),\n * Ordering.of(field(\"title\")) // Ascending order is the default\n * );\n * ```\n *\n * @param ordering - The first {@link @firebase/firestore/pipelines#Ordering} instance specifying the sorting criteria.\n * @param additionalOrderings - Optional additional {@link @firebase/firestore/pipelines#Ordering} instances specifying the additional sorting criteria.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n sort(ordering: Ordering, ...additionalOrderings: Ordering[]): Pipeline;\n /**\n * @beta\n * Sorts the documents from previous stages based on one or more {@link @firebase/firestore/pipelines#Ordering} criteria.\n *\n * <p>This stage allows you to order the results of your pipeline. You can specify multiple {@link\n * @firebase/firestore/pipelines#Ordering} instances to sort by multiple fields in ascending or descending order. If documents\n * have the same value for a field used for sorting, the next specified ordering will be used. If\n * all orderings result in equal comparison, the documents are considered equal and the order is\n * unspecified.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Sort books by rating in descending order, and then by title in ascending order for books\n * // with the same rating\n * firestore.pipeline().collection(\"books\")\n * .sort(\n * Ordering.of(field(\"rating\")).descending(),\n * Ordering.of(field(\"title\")) // Ascending order is the default\n * );\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n sort(options: SortStageOptions): Pipeline;\n sort(\n orderingOrOptions: Ordering | SortStageOptions,\n ...additionalOrderings: Ordering[]\n ): Pipeline {\n // Process argument union(s) from method overloads\n const options = isOrdering(orderingOrOptions) ? {} : orderingOrOptions;\n const orderings: Ordering[] = isOrdering(orderingOrOptions)\n ? [orderingOrOptions, ...additionalOrderings]\n : orderingOrOptions.orderings;\n\n // Create stage object\n const stage = new Sort(orderings, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'sort'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Fully overwrites all fields in a document with those coming from a nested map.\n *\n * <p>This stage allows you to emit a map value as a document. Each key of the map becomes a field\n * on the document that contains the corresponding value.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Input.\n * // {\n * // 'name': 'John Doe Jr.',\n * // 'parents': {\n * // 'father': 'John Doe Sr.',\n * // 'mother': 'Jane Doe'\n * // }\n * // }\n *\n * // Emit parents as document.\n * firestore.pipeline().collection('people').replaceWith('parents');\n *\n * // Output\n * // {\n * // 'father': 'John Doe Sr.',\n * // 'mother': 'Jane Doe'\n * // }\n * ```\n *\n * @param fieldName - The {@link @firebase/firestore/pipelines#Field} field containing the nested map.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n replaceWith(fieldName: string): Pipeline;\n /**\n * @beta\n * Fully overwrites all fields in a document with those coming from a map.\n *\n * <p>This stage allows you to emit a map value as a document. Each key of the map becomes a field\n * on the document that contains the corresponding value.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Input.\n * // {\n * // 'name': 'John Doe Jr.',\n * // 'parents': {\n * // 'father': 'John Doe Sr.',\n * // 'mother': 'Jane Doe'\n * // }\n * // }\n *\n * // Emit parents as document.\n * firestore.pipeline().collection('people').replaceWith(map({\n * foo: 'bar',\n * info: {\n * name: field('name')\n * }\n * }));\n *\n * // Output\n * // {\n * // 'father': 'John Doe Sr.',\n * // 'mother': 'Jane Doe'\n * // }\n * ```\n *\n * @param expr - An {@link @firebase/firestore/pipelines#Expression} that when returned evaluates to a map.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n replaceWith(expr: Expression): Pipeline;\n /**\n * @beta\n * Fully overwrites all fields in a document with those coming from a map.\n *\n * <p>This stage allows you to emit a map value as a document. Each key of the map becomes a field\n * on the document that contains the corresponding value.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Input.\n * // {\n * // 'name': 'John Doe Jr.',\n * // 'parents': {\n * // 'father': 'John Doe Sr.',\n * // 'mother': 'Jane Doe'\n * // }\n * // }\n *\n * // Emit parents as document.\n * firestore.pipeline().collection('people').replaceWith(map({\n * foo: 'bar',\n * info: {\n * name: field('name')\n * }\n * }));\n *\n * // Output\n * // {\n * // 'father': 'John Doe Sr.',\n * // 'mother': 'Jane Doe'\n * // }\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n replaceWith(options: ReplaceWithStageOptions): Pipeline;\n replaceWith(\n valueOrOptions: Expression | string | ReplaceWithStageOptions\n ): Pipeline {\n // Process argument union(s) from method overloads\n const options =\n isString(valueOrOptions) || isExpr(valueOrOptions) ? {} : valueOrOptions;\n const fieldNameOrExpr: string | Expression =\n isString(valueOrOptions) || isExpr(valueOrOptions)\n ? valueOrOptions\n : valueOrOptions.map;\n\n // Convert user land convenience types to internal types\n const mapExpr = fieldOrExpression(fieldNameOrExpr);\n\n // Create stage object\n const stage = new Replace(mapExpr, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'replaceWith'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Performs a pseudo-random sampling of the documents from the previous stage.\n *\n * <p>This stage will filter documents pseudo-randomly. The parameter specifies how number of\n * documents to be returned.\n *\n * <p>Examples:\n *\n * @example\n * ```typescript\n * // Sample 25 books, if available.\n * firestore.pipeline().collection('books')\n * .sample(25);\n * ```\n *\n * @param documents - The number of documents to sample.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n sample(documents: number): Pipeline;\n\n /**\n * @beta\n * Performs a pseudo-random sampling of the documents from the previous stage.\n *\n * <p>This stage will filter documents pseudo-randomly. The 'options' parameter specifies how\n * sampling will be performed. See {@link @firebase/firestore/pipelines#SampleStageOptions} for more information.\n *\n * @example\n * ```typescript\n * // Sample 10 books, if available.\n * firestore.pipeline().collection(\"books\")\n * .sample({ documents: 10 });\n *\n * // Sample 50% of books.\n * firestore.pipeline().collection(\"books\")\n * .sample({ percentage: 0.5 });\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n sample(options: SampleStageOptions): Pipeline;\n sample(documentsOrOptions: number | SampleStageOptions): Pipeline {\n // Process argument union(s) from method overloads\n const options = isNumber(documentsOrOptions) ? {} : documentsOrOptions;\n let rate: number;\n let mode: 'documents' | 'percent';\n if (isNumber(documentsOrOptions)) {\n rate = documentsOrOptions;\n mode = 'documents';\n } else if (isNumber(documentsOrOptions.documents)) {\n rate = documentsOrOptions.documents;\n mode = 'documents';\n } else {\n rate = documentsOrOptions.percentage!;\n mode = 'percent';\n }\n\n // Create stage object\n const stage = new Sample(rate, mode, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'sample'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Performs union of all documents from two pipelines, including duplicates.\n *\n * <p>This stage will pass through documents from previous stage, and also pass through documents\n * from previous stage of the `other` {@link @firebase/firestore/pipelines#Pipeline} given in parameter. The order of documents\n * emitted from this stage is undefined.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Emit documents from books collection and magazines collection.\n * firestore.pipeline().collection('books')\n * .union(firestore.pipeline().collection('magazines'));\n * ```\n *\n * @param other - The other {@link @firebase/firestore/pipelines#Pipeline} that is part of union.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n union(other: Pipeline): Pipeline;\n /**\n * @beta\n * Performs union of all documents from two pipelines, including duplicates.\n *\n * <p>This stage will pass through documents from previous stage, and also pass through documents\n * from previous stage of the `other` {@link @firebase/firestore/pipelines#Pipeline} given in parameter. The order of documents\n * emitted from this stage is undefined.\n *\n * <p>Example:\n *\n * @example\n * ```typescript\n * // Emit documents from books collection and magazines collection.\n * firestore.pipeline().collection('books')\n * .union(firestore.pipeline().collection('magazines'));\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n union(options: UnionStageOptions): Pipeline;\n union(otherOrOptions: Pipeline | UnionStageOptions): Pipeline {\n // Process argument union(s) from method overloads\n let options: {};\n let otherPipeline: Pipeline;\n if (isPipeline(otherOrOptions)) {\n options = {};\n otherPipeline = otherOrOptions;\n } else {\n ({ other: otherPipeline, ...options } = otherOrOptions);\n }\n\n // Create stage object\n const stage = new Union(otherPipeline, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'union'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Produces a document for each element in an input array.\n *\n * For each previous stage document, this stage will emit zero or more augmented documents. The\n * input array specified by the `selectable` parameter, will emit an augmented document for each input array element. The input array element will\n * augment the previous stage document by setting the `alias` field with the array element value.\n *\n * When `selectable` evaluates to a non-array value (ex: number, null, absent), then the stage becomes a no-op for\n * the current input document, returning it as is with the `alias` field absent.\n *\n * No documents are emitted when `selectable` evaluates to an empty array.\n *\n * Example:\n *\n * @example\n * ```typescript\n * // Input:\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tags\": [ \"comedy\", \"space\", \"adventure\" ], ... }\n *\n * // Emit a book document for each tag of the book.\n * firestore.pipeline().collection(\"books\")\n * .unnest(field(\"tags\").as('tag'), 'tagIndex');\n *\n * // Output:\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tag\": \"comedy\", \"tagIndex\": 0, ... }\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tag\": \"space\", \"tagIndex\": 1, ... }\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tag\": \"adventure\", \"tagIndex\": 2, ... }\n * ```\n *\n * @param selectable - A selectable expression defining the field to unnest and the alias to use for each un-nested element in the output documents.\n * @param indexField - An optional string value specifying the field path to write the offset (starting at zero) into the array the un-nested element is from\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n unnest(selectable: Selectable, indexField?: string): Pipeline;\n /**\n * @beta\n * Produces a document for each element in an input array.\n *\n * For each previous stage document, this stage will emit zero or more augmented documents. The\n * input array specified by the `selectable` parameter, will emit an augmented document for each input array element. The input array element will\n * augment the previous stage document by setting the `alias` field with the array element value.\n *\n * When `selectable` evaluates to a non-array value (ex: number, null, absent), then the stage becomes a no-op for\n * the current input document, returning it as is with the `alias` field absent.\n *\n * No documents are emitted when `selectable` evaluates to an empty array.\n *\n * Example:\n *\n * @example\n * ```typescript\n * // Input:\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tags\": [ \"comedy\", \"space\", \"adventure\" ], ... }\n *\n * // Emit a book document for each tag of the book.\n * firestore.pipeline().collection(\"books\")\n * .unnest(field(\"tags\").as('tag'), 'tagIndex');\n *\n * // Output:\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tag\": \"comedy\", \"tagIndex\": 0, ... }\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tag\": \"space\", \"tagIndex\": 1, ... }\n * // { \"title\": \"The Hitchhiker's Guide to the Galaxy\", \"tag\": \"adventure\", \"tagIndex\": 2, ... }\n * ```\n *\n * @param options - An object that specifies required and optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n unnest(options: UnnestStageOptions): Pipeline;\n unnest(\n selectableOrOptions: Selectable | UnnestStageOptions,\n indexField?: string\n ): Pipeline {\n // Process argument union(s) from method overloads\n let options: { indexField?: Field } & StageOptions;\n let selectable: Selectable;\n let indexFieldName: string | undefined;\n if (isSelectable(selectableOrOptions)) {\n options = {};\n selectable = selectableOrOptions;\n indexFieldName = indexField;\n } else {\n ({\n selectable,\n indexField: indexFieldName,\n ...options\n } = selectableOrOptions);\n }\n\n // Convert user land convenience types to internal types\n const alias = selectable.alias;\n const expr = selectable.expr as Expression;\n if (isString(indexFieldName)) {\n options.indexField = _field(indexFieldName, 'unnest');\n }\n\n // Create stage object\n const stage = new Unnest(alias, expr, options);\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'unnest'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @beta\n * Adds a raw stage to the pipeline.\n *\n * <p>This method provides a flexible way to extend the pipeline's functionality by adding custom\n * stages. Each raw stage is defined by a unique `name` and a set of `params` that control its\n * behavior.\n *\n * <p>Example (Assuming there is no 'where' stage available in SDK):\n *\n * @example\n * ```typescript\n * // Assume we don't have a built-in 'where' stage\n * firestore.pipeline().collection('books')\n * .rawStage('where', [field('published').lt(1900)]) // Custom 'where' stage\n * .select('title', 'author');\n * ```\n *\n * @param name - The unique name of the raw stage to add.\n * @param params - A list of parameters to configure the raw stage's behavior.\n * @param options - An object of key value pairs that specifies optional parameters for the stage.\n * @returns A new {@link @firebase/firestore/pipelines#Pipeline} object with this stage appended to the stage list.\n */\n rawStage(\n name: string,\n params: unknown[],\n options?: { [key: string]: Expression | unknown }\n ): Pipeline {\n // Convert user land convenience types to internal types\n const expressionParams = params.map((value: unknown) => {\n if (value instanceof Expression) {\n return value;\n } else if (value instanceof AggregateFunction) {\n return value;\n } else if (isPlainObject(value)) {\n return _mapValue(value as Record<string, unknown>);\n } else {\n return _constant(value, 'rawStage');\n }\n });\n\n // Create stage object\n const stage = new RawStage(name, expressionParams, options ?? {});\n\n // User data must be read in the context of the API method to\n // provide contextual errors\n const parseContext = this.userDataReader.createContext(\n UserDataSource.Argument,\n 'rawStage'\n );\n stage._readUserData(parseContext);\n\n // Add stage to the pipeline\n return this._addStage(stage);\n }\n\n /**\n * @internal\n * @private\n */\n _toProto(jsonProtoSerializer: JsonProtoSerializer): ProtoPipeline {\n const stages: ProtoStage[] = this.stages.map(stage =>\n stage._toProto(jsonProtoSerializer)\n );\n return { stages };\n }\n\n private _addStage(stage: Stage): Pipeline {\n const copy = this.stages.map(s => s);\n copy.push(stage);\n return this.newPipeline(\n this._db,\n this.userDataReader,\n this._userDataWriter,\n copy\n );\n }\n\n /**\n * @internal\n * @private\n * @param db\n * @param userDataReader\n * @param userDataWriter\n * @param stages\n * @protected\n */\n protected newPipeline(\n db: Firestore,\n userDataReader: UserDataReader,\n userDataWriter: AbstractUserDataWriter,\n stages: Stage[]\n ): Pipeline {\n return new Pipeline(db, userDataReader, userDataWriter, stages);\n }\n}\n\nexport function isPipeline(val: unknown): val is Pipeline {\n return val instanceof Pipeline;\n}\n","/**\n * @license\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n StructuredPipeline,\n StructuredPipelineOptions\n} from '../core/structured_pipeline';\nimport { invokeExecutePipeline } from '../remote/datastore';\n\nimport { getDatastore } from './components';\nimport { Firestore } from './database';\nimport { Pipeline } from './pipeline';\nimport { PipelineResult, PipelineSnapshot } from './pipeline-result';\nimport { PipelineSource } from './pipeline-source';\nimport { DocumentReference } from './reference';\nimport { LiteUserDataWriter } from './reference_impl';\nimport { Stage } from './stage';\nimport {\n newUserDataReader,\n UserDataReader,\n UserDataSource\n} from './user_data_reader';\n\ndeclare module './database' {\n interface Firestore {\n /**\n * @beta\n * Creates and returns a new PipelineSource, which allows specifying the source stage of a {@link @firebase/firestore/pipelines#Pipeline}.\n *\n * @example\n * ```\n * let myPipeline: Pipeline = firestore.pipeline().collection('books');\n * ```\n */\n pipeline(): PipelineSource<Pipeline>;\n }\n}\n\n/**\n * @beta\n * Executes this pipeline and returns a Promise to represent the asynchronous operation.\n *\n * The returned Promise can be used to track the progress of the pipeline execution\n * and retrieve the results (or handle any errors) asynchronously.\n *\n * The pipeline results are returned as a {@link @firebase/firestore/pipelines#PipelineSnapshot} that contains\n * a list of {@link @firebase/firestore/pipelines#PipelineResult} objects. Each {@link @firebase/firestore/pipelines#PipelineResult} typically\n * represents a single key/value map that has passed through all the\n * stages of the pipeline, however this might differ depending on the stages involved in the\n * pipeline. For example:\n *\n * <ul>\n * <li>If there are no stages or only transformation stages, each {@link @firebase/firestore/pipelines#PipelineResult}\n * represents a single document.</li>\n * <li>If there is an aggregation, only a single {@link @firebase/firestore/pipelines#PipelineResult} is returned,\n * representing the aggregated results over the entire dataset .</li>\n * <li>If there is an aggregation stage with grouping, each {@link @firebase/firestore/pipelines#PipelineResult} represents a\n * distinct group and its associated aggregated values.</li>\n * </ul>\n *\n * @example\n * ```typescript\n * const snapshot: PipelineSnapshot = await execute(firestore.pipeline().collection(\"books\")\n * .where(gt(field(\"rating\"), 4.5))\n * .select(\"title\", \"author\", \"rating\"));\n *\n * const results: PipelineResults = snapshot.results;\n * ```\n *\n * @param pipeline - The pipeline to execute.\n * @returns A Promise representing the asynchronous pipeline execution.\n */\nexport function execute(pipeline: Pipeline): Promise<PipelineSnapshot> {\n const datastore = getDatastore(pipeline._db);\n\n const udr = new UserDataReader(\n pipeline._db._databaseId,\n /* ignoreUndefinedProperties */ true\n );\n const context = udr.createContext(UserDataSource.Argument, 'execute');\n\n const structuredPipelineOptions = new StructuredPipelineOptions({}, {});\n structuredPipelineOptions._readUserData(context);\n\n const structuredPipeline: StructuredPipeline = new StructuredPipeline(\n pipeline,\n structuredPipelineOptions\n );\n\n return invokeExecutePipeline(datastore, structuredPipeline).then(result => {\n // Get the execution time from the first result.\n // firestoreClientExecutePipeline returns at least one PipelineStreamElement\n // even if the returned document set is empty.\n const executionTime =\n result.length > 0 ? result[0].executionTime?.toTimestamp() : undefined;\n\n const docs = result\n // Currently ignore any response from ExecutePipeline that does\n // not contain any document data in the `fields` property.\n .filter(element => !!element.fields)\n .map(\n element =>\n new PipelineResult(\n pipeline._userDataWriter,\n element.fields!,\n element.key?.path\n ? new DocumentReference(pipeline._db, null, element.key)\n : undefined,\n element.createTime?.toTimestamp(),\n element.updateTime?.toTimestamp()\n )\n );\n\n return new PipelineSnapshot(pipeline, docs, executionTime);\n });\n}\n\n/**\n * @beta\n * Creates and returns a new PipelineSource, which allows specifying the source stage of a {@link @firebase/firestore/pipelines#Pipeline}.\n *\n * @example\n * ```\n * let myPipeline: Pipeline = firestore.pipeline().collection('books');\n * ```\n */\nFirestore.prototype.pipeline = function (): PipelineSource<Pipeline> {\n const userDataWriter = new LiteUserDataWriter(this);\n const userDataReader = newUserDataReader(this);\n return new PipelineSource<Pipeline>(\n this._databaseId,\n userDataReader,\n (stages: Stage[]) => {\n return new Pipeline(this, userDataReader, userDataWriter, stages);\n }\n );\n};\n"],"names":["OptionsUtil","constructor","optionDefinitions","this","_getKnownOptions","options","context","knownOptions","ObjectValue","empty","__PRIVATE_knownOptionKey","hasOwnProperty","__PRIVATE_optionDefinition","__PRIVATE_optionValue","__PRIVATE_protoValue","nestedOptions","__PRIVATE_isPlainObject","mapValue","fields","getOptionsProto","__PRIVATE_parseData","undefined","set","FieldPath","fromServerFormat","serverName","optionsOverride","result","__PRIVATE_optionsMap","Map","__PRIVATE_mapToArray","value","key","setAll","__PRIVATE_StructuredPipelineOptions","__PRIVATE__userOptions","__PRIVATE__optionsOverride","__PRIVATE_optionsUtil","indexMode","_readUserData","proto","StructuredPipeline","pipeline","_toProto","serializer","__PRIVATE_isFirestoreValue","obj","nullValue","booleanValue","integerValue","doubleValue","timestampValue","__PRIVATE_isITimestamp","seconds","nanos","stringValue","bytesValue","Uint8Array","referenceValue","geoPointValue","__PRIVATE_isILatLng","latitude","longitude","arrayValue","__PRIVATE_isIArrayValue","values","Array","isArray","__PRIVATE_isIMapValue","fieldReferenceValue","functionValue","__PRIVATE_isIFunction","name","args","pipelineValue","__PRIVATE_isIPipeline","stages","__PRIVATE_valueToDefaultExpr","Expression","__PRIVATE__map","array","__PRIVATE__constant","__PRIVATE_vectorToExpr","VectorValue","constant","vector","Error","__PRIVATE_fieldOrExpression","__PRIVATE_isString","field","_protoValueType","add","second","FunctionExpression","asBoolean","BooleanExpression","Constant","__PRIVATE_BooleanConstant","Field","__PRIVATE_BooleanField","__PRIVATE_BooleanFunctionExpression","FirestoreError","subtract","subtrahend","multiply","divide","divisor","mod","other","equal","notEqual","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","arrayConcat","secondArray","otherArrays","__PRIVATE_exprValues","map","arrayContains","element","arrayContainsAll","__PRIVATE_normalizedExpr","__PRIVATE_ListOfExprs","arrayContainsAny","arrayReverse","arrayLength","equalAny","others","__PRIVATE_exprOthers","notEqualAny","exists","charLength","like","__PRIVATE_stringOrExpr","regexContains","regexFind","regexFindAll","regexMatch","stringContains","startsWith","endsWith","toLower","toUpper","trim","valueToTrim","push","ltrim","rtrim","type","isType","stringConcat","secondString","otherStrings","__PRIVATE_exprs","stringIndexOf","search","stringRepeat","repetitions","stringReplaceAll","find","replacement","stringReplaceOne","concat","reverse","byteLength","ceil","floor","abs","exp","mapGet","subfield","mapSet","moreKeyValues","mapKeys","mapValues","mapEntries","count","AggregateFunction","_create","sum","average","minimum","maximum","first","last","arrayAgg","arrayAggDistinct","countDistinct","logicalMaximum","logicalMinimum","vectorLength","cosineDistance","dotProduct","euclideanDistance","unixMicrosToTimestamp","timestampToUnixMicros","unixMillisToTimestamp","timestampToUnixMillis","unixSecondsToTimestamp","timestampToUnixSeconds","timestampAdd","unit","amount","timestampSubtract","documentId","substring","position","length","__PRIVATE_positionExpr","arrayGet","offset","isError","ifError","catchValue","isAbsent","mapRemove","__PRIVATE_stringExpr","mapMerge","secondMap","otherMaps","__PRIVATE_secondMapExpr","__PRIVATE_otherMapExprs","pow","exponent","trunc","decimalPlaces","round","collectionId","ln","sqrt","stringReverse","ifAbsent","__PRIVATE_elseValueOrExpression","join","__PRIVATE_delimeterValueOrExpression","log10","arraySum","split","delimiter","timestampTruncate","granularity","timezone","toLowerCase","ascending","descending","as","AliasedExpression","params","exprType","methodName","__PRIVATE_af","_methodName","AliasedAggregate","p","contextWith","forEach","expr","aggregate","alias","selectable","super","expressionType","fieldPath","fieldName","canonicalString","nameOrPath","_field","__PRIVATE_DOCUMENT_KEY_NAME","__PRIVATE_documentIdFieldPath","_internalPath","__PRIVATE_fieldPathFromArgument","_fromProto","_protoValue","_","__PRIVATE_hardAssert","c","MapValue","__PRIVATE_plainObject","__PRIVATE_toMapValue","_expr","countIf","not","conditional","thenExpr","elseExpr","__PRIVATE_normalizedCatchValue","booleanExpr","tryExpr","mapExpr","firstMap","documentPath","__PRIVATE_fieldExpr","__PRIVATE_lengthExpr","left","right","__PRIVATE_normalizedLeft","__PRIVATE_normalizedRight","elements","Object","prototype","call","__PRIVATE__array","__PRIVATE_leftExpr","__PRIVATE_rightExpr","firstArray","__PRIVATE_arrayExpr","__PRIVATE_elementExpr","xor","additionalConditions","condition","__PRIVATE_valueOrField","__PRIVATE_expressionOrFieldName","pattern","__PRIVATE_patternExpr","__PRIVATE_substringExpr","prefix","suffix","__PRIVATE_fieldNameOrExpression","__PRIVATE_fieldOrExpr","subField","countAll","__PRIVATE_expr1","__PRIVATE_expr2","timestamp","__PRIVATE_normalizedTimestamp","__PRIVATE_normalizedUnit","__PRIVATE_normalizedAmount","currentTimestamp","and","more","or","base","rand","log","elseValue","__PRIVATE_delimiterValueOrExpression","__PRIVATE_internalGranularity","Ordering","direction","__PRIVATE_toStringValue","expression","__PRIVATE_isSelectable","val","candidate","__PRIVATE_isExpr","__PRIVATE_isOrdering","__PRIVATE_isAliasedAggregate","__PRIVATE_isBooleanExpr","__PRIVATE_isField","__PRIVATE_toField","__PRIVATE_toPipelineBooleanExpr","f","__PRIVATE_FieldFilterInternal","fieldValue","toString","op","fail","__PRIVATE_CompositeFilterInternal","__PRIVATE_conditions","getFilters","slice","__PRIVATE_toPipeline","query","db","__PRIVATE_isCollectionGroupQuery","collectionGroup","__PRIVATE_isDocumentQuery","documents","doc","path","collection","filter","filters","where","__PRIVATE_orders","__PRIVATE_queryNormalizedOrderBy","__PRIVATE_existsConditions","explicitOrderBy","order","orderings","dir","limitType","__PRIVATE_actualOrderings","__PRIVATE_reverseOrderings","o","sort","startAt","__PRIVATE_whereConditionsFromCursor","endAt","limit","bound","__PRIVATE_filterFunc","__PRIVATE_cursors","size","inclusive","__PRIVATE_i","Stage","optionsProto","rawOptions","_optionsUtil","_name","__PRIVATE_AddFields","__PRIVATE_readUserDataHelper","__PRIVATE_RemoveFields","__PRIVATE_Aggregate","groups","accumulators","__PRIVATE_Distinct","__PRIVATE_CollectionSource","forceIndex","__PRIVATE_formattedCollectionPath","__PRIVATE_CollectionGroupSource","__PRIVATE_DatabaseSource","__PRIVATE_DocumentsSource","__PRIVATE_docPaths","__PRIVATE_formattedPaths","__PRIVATE_Where","__PRIVATE_FindNearest","distanceField","vectorValue","distanceMeasure","__PRIVATE_Limit","isNaN","Infinity","toNumber","__PRIVATE_Offset","__PRIVATE_Select","selections","__PRIVATE_Sort","__PRIVATE_Sample","rate","mode","__PRIVATE_Union","__PRIVATE_toPipelineValue","__PRIVATE_Unnest","indexField","__PRIVATE_Replace","__PRIVATE_MODE","__PRIVATE_RawStage","__PRIVATE_expressionMap","__PRIVATE_isUserData","__PRIVATE_readableData","PipelineSource","databaseId","userDataReader","_createPipeline","__PRIVATE_collectionOrOptions","__PRIVATE_isCollectionReference","__PRIVATE_collectionRefOrString","_validateReference","__PRIVATE_normalizedCollection","__PRIVATE_stage","__PRIVATE_parseContext","createContext","__PRIVATE_collectionIdOrOptions","database","__PRIVATE_docsOrOptions","docs","v","DocumentReference","__PRIVATE_dr","__PRIVATE_normalizedDocs","createFrom","_query","firestore","reference","__PRIVATE_refDbId","_databaseId","isEqual","Code","INVALID_ARGUMENT","CollectionReference","projectId","PipelineSnapshot","results","executionTime","_pipeline","_executionTime","_results","PipelineResult","userDataWriter","ref","createTime","updateTime","_ref","_userDataWriter","_createTime","_updateTime","_fields","id","data","convertValue","_fieldsProto","clone","get","__PRIVATE_selectablesToMap","__PRIVATE_selectables","Pipeline","_db","addFields","__PRIVATE_fieldOrOptions","additionalFields","__PRIVATE_normalizedFields","_addStage","removeFields","__PRIVATE_fieldValueOrOptions","__PRIVATE_convertedFields","select","__PRIVATE_selectionOrOptions","additionalSelections","__PRIVATE_normalizedSelections","__PRIVATE_conditionOrOptions","__PRIVATE_offsetOrOptions","__PRIVATE_isNumber","__PRIVATE_limitOrOptions","distinct","__PRIVATE_groupOrOptions","additionalGroups","__PRIVATE_convertedGroups","__PRIVATE_targetOrOptions","__PRIVATE_rest","__PRIVATE_convertedAccumulators","__PRIVATE_aliasedAggregateToMap","__PRIVATE_aliasedAggregatees","reduce","findNearest","__PRIVATE_internalOptions","__PRIVATE_orderingOrOptions","additionalOrderings","replaceWith","__PRIVATE_valueOrOptions","sample","__PRIVATE_documentsOrOptions","percentage","union","__PRIVATE_otherOrOptions","__PRIVATE_otherPipeline","__PRIVATE_isPipeline","unnest","__PRIVATE_selectableOrOptions","__PRIVATE_indexFieldName","rawStage","__PRIVATE_expressionParams","__PRIVATE__mapValue","jsonProtoSerializer","copy","s","newPipeline","execute","datastore","__PRIVATE_getDatastore","UserDataReader","__PRIVATE_structuredPipelineOptions","structuredPipeline","__PRIVATE_invokeExecutePipeline","then","toTimestamp","Firestore","__PRIVATE_LiteUserDataWriter","__PRIVATE_newUserDataReader"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;UA8BaA;IACX,WAAAC,CAAoBC;QAAAC,KAAiBD,oBAAjBA;AAAyC;IAErD,gBAAAE,CACNC,GACAC;QAEA,MAAMC,IAA4BC,EAAYC;;gBAG9C,KAAK,MAAMC,KAAkBP,KAAKD,mBAChC,IAAIC,KAAKD,kBAAkBS,eAAeD,IAAiB;YACzD,MAAME,IACJT,KAAKD,kBAAkBQ;YAEzB,IAAIA,KAAkBL,GAAS;gBAC7B,MAAMQ,IAAuBR,EAAQK;gBACrC,IAAII;gBAEJ,IAAIF,EAAiBG,iBAAiBC,EAAcH,IAAc;oBAEhEC,IAAa;wBACXG,UAAU;4BACRC,QAHe,IAAIlB,YAAYY,EAAiBG,eAG7BI,gBAAgBb,GAASO;;;AAGjD,uBAAUA,MACTC,IAAaM,EAAUP,GAAaP,WAAYe;gBAG9CP,KACFP,EAAae,IACXC,EAAUC,iBAAiBZ,EAAiBa,aAC5CX;AAGL;AACF;QAGH,OAAOP;AACR;IAED,eAAAY,CACEb,GACAC,GACAmB;QAEA,MAAMC,IAAsBxB,KAAKC,iBAAiBG,GAAcD;;gBAGhE,IAAIoB,GAAiB;YACnB,MAAME,IAAa,IAAIC,IACrBC,EAAWJ,IAAiB,CAACK,GAAOC,MAAQ,EAC1CT,EAAUC,iBAAiBQ,SACjBX,MAAVU,IAAsBX,EAAUW,GAAOzB,KAAW;YAGtDqB,EAAOM,OA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