{"version":3,"file":"1.mjs","sources":["../src/values/Path.ts","../src/values/dateHelpers.ts","../src/values/utils.ts","../src/values/StreamValue.ts","../src/evaluator/equality.ts","../src/evaluator/matching.ts","../src/evaluator/ordering.ts","../src/evaluator/operators.ts","../src/evaluator/scope.ts","../src/evaluator/evaluate.ts","../src/evaluator/constantEvaluate.ts","../src/nodeTypes.ts","../src/evaluator/functions/array.ts","../src/evaluator/functions/dateTime.ts","../src/evaluator/keyPath.ts","../src/evaluator/selector.ts","../src/evaluator/functions/diff.ts","../src/evaluator/functions/delta.ts","../src/evaluator/functions/documents.ts","../src/evaluator/functions/geo.ts","../src/evaluator/functions/string.ts","../src/evaluator/functions/global.ts","../src/evaluator/functions/math.ts","../src/evaluator/functions/media.ts","../src/evaluator/pt.ts","../src/evaluator/functions/pt.ts","../src/evaluator/functions/releases.ts","../src/evaluator/functions/sanity.ts","../src/evaluator/functions/text.ts","../src/evaluator/functions/user.ts","../src/evaluator/scoring.ts","../src/evaluator/functions/pipeFunctions.ts","../src/evaluator/functions/index.ts","../src/markProcessor.ts","../src/rawParser.js","../src/traversal.ts","../src/walk.ts","../src/parser.ts","../src/typeEvaluator/optimizations.ts","../src/typeEvaluator/types.ts","../src/typeEvaluator/typeHelpers.ts","../src/typeEvaluator/booleans.ts","../src/typeEvaluator/functions.ts","../src/typeEvaluator/matching.ts","../src/typeEvaluator/narrowing.ts","../src/typeEvaluator/scope.ts","../src/typeEvaluator/typeEvaluate.ts"],"sourcesContent":["function escapeRegExp(string: string) {\n  return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\nfunction pathRegExp(pattern: string) {\n  const re = []\n  for (const part of pattern.split('.')) {\n    if (part === '*') {\n      re.push('[^.]+')\n    } else if (part === '**') {\n      re.push('.*')\n    } else {\n      re.push(escapeRegExp(part))\n    }\n  }\n\n  return new RegExp(`^${re.join('.')}$`)\n}\n\nexport class Path {\n  private pattern: string\n  private patternRe: RegExp\n\n  constructor(pattern: string) {\n    this.pattern = pattern\n    this.patternRe = pathRegExp(pattern)\n  }\n\n  matches(str: string): boolean {\n    return this.patternRe.test(str)\n  }\n\n  toJSON(): string {\n    return this.pattern\n  }\n}\n","const RFC3339_REGEX = /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|([-+]\\d{2}:\\d{2}))$/\n\nexport function parseRFC3339(str: string): Date | null {\n  if (RFC3339_REGEX.test(str)) {\n    return new Date(str)\n  }\n  return null\n}\n\nexport function formatRFC3339(d: Date): string {\n  const year = addLeadingZero(d.getUTCFullYear(), 4)\n  const month = addLeadingZero(d.getUTCMonth() + 1, 2)\n  const day = addLeadingZero(d.getUTCDate(), 2)\n  const hour = addLeadingZero(d.getUTCHours(), 2)\n  const minute = addLeadingZero(d.getUTCMinutes(), 2)\n  const second = addLeadingZero(d.getUTCSeconds(), 2)\n\n  let fractionalSecond = ''\n  const millis = d.getMilliseconds()\n  if (millis != 0) {\n    fractionalSecond = `.${addLeadingZero(millis, 3)}`\n  }\n\n  return `${year}-${month}-${day}T${hour}:${minute}:${second}${fractionalSecond}Z`\n}\n\ntype Stringer = {\n  toString(): string\n}\n\nfunction addLeadingZero(num: Stringer, targetLength: number) {\n  let str = num.toString()\n  while (str.length < targetLength) {\n    str = `0${str}`\n  }\n  return str\n}\n","import {formatRFC3339, parseRFC3339} from './dateHelpers'\nimport {Path} from './Path'\nimport {StreamValue} from './StreamValue'\nimport type {\n  AnyStaticValue,\n  ArrayValue,\n  BooleanValue,\n  DateTimeValue,\n  GroqType,\n  NullValue,\n  PathValue,\n  StringValue,\n  Value,\n} from './types'\n\nexport class StaticValue<P, T extends GroqType> {\n  data: P\n  type: T\n\n  constructor(data: P, type: T) {\n    this.data = data\n    this.type = type\n  }\n\n  isArray(): boolean {\n    return this.type === 'array'\n  }\n\n  // eslint-disable-next-line require-await\n  async get(): Promise<any> {\n    return this.data\n  }\n\n  asStatic(): this {\n    return this\n  }\n\n  [Symbol.asyncIterator](): Generator<Value, void, unknown> {\n    if (Array.isArray(this.data)) {\n      return (function* (data) {\n        for (const element of data) {\n          yield fromJS(element)\n        }\n      })(this.data)\n    }\n    throw new Error(`Cannot iterate over: ${this.type}`)\n  }\n}\n\nexport const NULL_VALUE: NullValue = new StaticValue(null, 'null')\nexport const TRUE_VALUE: BooleanValue = new StaticValue(true, 'boolean')\nexport const FALSE_VALUE: BooleanValue = new StaticValue(false, 'boolean')\n\nexport class DateTime {\n  date: Date\n\n  constructor(date: Date) {\n    this.date = date\n  }\n\n  static parseToValue(str: string): DateTimeValue | NullValue {\n    const date = parseRFC3339(str)\n    if (date) {\n      return new StaticValue(new DateTime(date), 'datetime')\n    }\n    return NULL_VALUE\n  }\n\n  equals(other: DateTime): boolean {\n    return this.date.getTime() == other.date.getTime()\n  }\n\n  add(secs: number): DateTime {\n    const copy = new Date(this.date.getTime())\n    copy.setTime(copy.getTime() + secs * 1000)\n    return new DateTime(copy)\n  }\n\n  difference(other: DateTime): number {\n    return (this.date.getTime() - other.date.getTime()) / 1000\n  }\n\n  compareTo(other: DateTime): number {\n    return this.date.getTime() - other.date.getTime()\n  }\n\n  toString(): string {\n    return formatRFC3339(this.date)\n  }\n\n  toJSON(): string {\n    return this.toString()\n  }\n}\n\nexport function fromNumber(num: number): AnyStaticValue {\n  if (Number.isFinite(num)) {\n    return new StaticValue(num, 'number')\n  }\n  return NULL_VALUE\n}\n\nexport function fromString(str: string): StringValue {\n  return new StaticValue(str, 'string')\n}\n\nexport function fromDateTime(dt: DateTime): Value {\n  return new StaticValue(dt, 'datetime')\n}\n\nexport function fromPath(path: Path): PathValue {\n  return new StaticValue(path, 'path')\n}\n\nfunction isIterator(obj?: Iterator<any>) {\n  return obj && typeof obj.next === 'function'\n}\n\nexport function fromArray(val: unknown[]): ArrayValue {\n  return new StaticValue(val, 'array')\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function fromJS(val: any): Value {\n  if (isIterator(val)) {\n    return new StreamValue(async function* () {\n      for await (const value of val) {\n        yield fromJS(value)\n      }\n    })\n  } else if (val === null || val === undefined) {\n    return NULL_VALUE\n  }\n  return new StaticValue(val, getType(val)) as any\n}\n\n/**\n * Returns a normalized JavaScript value. This eliminates internal values\n * such as DateTime and Path by turning them into the JSON representation.\n */\nexport function toJS(val: AnyStaticValue): unknown {\n  const normalized = maybeNormalize(val.data)\n  if (normalized === undefined) return val.data\n  return normalized\n}\n\n/**\n * maybeNormalize eliminates custom values such as DateTime and Path.\n * This method returns `undefined` in the scenario where the data contains no\n * custom values and the data is already normalized.\n */\nfunction maybeNormalize(data: unknown): unknown | undefined {\n  if (data === null || typeof data === 'undefined') return undefined\n\n  if (Array.isArray(data)) {\n    let result: undefined | unknown[]\n    for (let i = 0; i < data.length; i++) {\n      let normalized = maybeNormalize(data[i])\n      if (normalized !== undefined && result === undefined) {\n        // This is the first value which had to be converted.\n        result = data.slice(0, i)\n      }\n\n      if (result !== undefined) {\n        if (normalized === undefined) normalized = data[i]\n        result.push(normalized)\n      }\n    }\n\n    return result\n  }\n\n  if (typeof data === 'object') {\n    if ('toJSON' in data && typeof data.toJSON === 'function') {\n      return data.toJSON()\n    }\n\n    const entries = Object.entries(data)\n    let result: undefined | Record<string, unknown>\n\n    for (let i = 0; i < entries.length; i++) {\n      const [key, value] = entries[i]!\n      let normalized = maybeNormalize(value)\n      if (normalized !== undefined && result === undefined) {\n        // This is the first value which had to be converted.\n        result = Object.fromEntries(entries.slice(0, i))\n      }\n\n      if (result !== undefined) {\n        if (normalized === undefined) normalized = value\n        result[key] = normalized\n      }\n    }\n\n    return result\n  }\n\n  return undefined\n}\n\n/**\n * Returns the type of the value.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function getType(data: any): GroqType {\n  if (data === null || typeof data === 'undefined') {\n    return 'null'\n  }\n  if (Array.isArray(data)) {\n    return 'array'\n  }\n  if (data instanceof Path) {\n    return 'path'\n  }\n  if (data instanceof DateTime) {\n    return 'datetime'\n  }\n  return typeof data as GroqType\n}\n","import type {ArrayValue, Value} from './types'\nimport {StaticValue} from './utils'\n\nexport class StreamValue {\n  type: 'stream' = 'stream'\n  private generator: () => AsyncGenerator<Value, void, unknown>\n  private ticker: Promise<void> | null\n  private isDone: boolean\n  private data: Value[]\n\n  constructor(generator: () => AsyncGenerator<Value, void, unknown>) {\n    this.generator = generator\n    this.ticker = null\n    this.isDone = false\n    this.data = []\n  }\n\n  // eslint-disable-next-line class-methods-use-this\n  isArray(): boolean {\n    return true\n  }\n\n  async get(): Promise<any[]> {\n    const result = []\n    for await (const value of this) {\n      result.push(await value.get())\n    }\n    return result\n  }\n\n  async asStatic(): Promise<ArrayValue> {\n    return new StaticValue(await this.get(), 'array')\n  }\n\n  async *[Symbol.asyncIterator](): AsyncGenerator<Value, void, unknown> {\n    let i = 0\n    while (true) {\n      for (; i < this.data.length; i++) {\n        yield this.data[i]\n      }\n\n      if (this.isDone) {\n        return\n      }\n\n      await this._nextTick()\n    }\n  }\n\n  _nextTick(): Promise<void> {\n    if (this.ticker) {\n      return this.ticker\n    }\n\n    let currentResolver: (value?: void | PromiseLike<void> | undefined) => void\n    let currentRejector: (reason?: any) => void\n    const setupTicker = () => {\n      this.ticker = new Promise((resolve, reject) => {\n        currentResolver = resolve\n        currentRejector = reject\n      })\n    }\n\n    const tick = () => {\n      currentResolver()\n      setupTicker()\n    }\n\n    const fetch = async () => {\n      try {\n        for await (const value of this.generator()) {\n          this.data.push(value)\n          tick()\n        }\n\n        this.isDone = true\n        tick()\n      } catch (error) {\n        currentRejector(error)\n      }\n    }\n\n    setupTicker()\n    fetch()\n    return this.ticker!\n  }\n}\n","import type {Value} from '../values'\n\nexport function isEqual(a: Value, b: Value): boolean {\n  if (\n    (a.type === 'string' && b.type === 'string') ||\n    (a.type === 'boolean' && b.type === 'boolean') ||\n    (a.type === 'null' && b.type === 'null') ||\n    (a.type === 'number' && b.type === 'number')\n  ) {\n    return a.data === b.data\n  }\n\n  if (a.type === 'datetime' && b.type === 'datetime') {\n    return a.data.equals(b.data)\n  }\n\n  return false\n}\n\nexport function deepEqual(a: any, b: any): boolean {\n  if (a === null || b === null) return a === b\n  const typeOfA = typeof a\n  const typeOfB = typeof b\n  if (typeOfA === 'undefined' && typeOfB === 'undefined') return true\n  if (typeOfA === 'function' && typeOfB === 'function') return a === b\n  if (typeOfA === 'object' && typeOfB === 'object') {\n    const keysOfA = Object.keys(a)\n    const keysOfB = Object.keys(b)\n    if (keysOfA.length !== keysOfB.length) return false\n    for (const key of keysOfA) {\n      if (!deepEqual(a[key], b[key])) return false\n    }\n    return true\n  }\n  return a === b\n}\n","import type {Value} from '../values'\n\nconst CHARS = /([^!@#$%^&*(),\\\\/?\";:{}|[\\]+<>\\s-])+/g\nconst CHARS_WITH_WILDCARD = /([^!@#$%^&(),\\\\/?\";:{}|[\\]+<>\\s-])+/g\nconst EDGE_CHARS = /(\\b\\.+|\\.+\\b)/g\nconst MAX_TERM_LENGTH = 1024\n\nexport type Token = string\n\nexport type Pattern = (tokens: Token[]) => boolean\n\nexport function matchText(tokens: Token[], patterns: Pattern[]): boolean {\n  if (tokens.length === 0 || patterns.length === 0) {\n    return false\n  }\n\n  return patterns.every((pattern) => pattern(tokens))\n}\n\nexport function matchTokenize(text: string): Token[] {\n  return text.replace(EDGE_CHARS, '').match(CHARS) || []\n}\n\nexport function matchAnalyzePattern(text: string): Pattern[] {\n  const termsRe = matchPatternRegex(text)\n  return termsRe.map((re) => (tokens: Token[]) => tokens.some((token) => re.test(token)))\n}\n\nexport function matchPatternRegex(text: string): RegExp[] {\n  const terms = text.replace(EDGE_CHARS, '').match(CHARS_WITH_WILDCARD) || []\n  return terms.map(\n    (term) => new RegExp(`^${term.slice(0, MAX_TERM_LENGTH).replace(/\\*/g, '.*')}$`, 'i'),\n  )\n}\n\nexport type GatheredText<T> = {\n  parts: T[]\n  /** This is true if all of the values in the array were strings. */\n  success: boolean\n}\n\nexport function gatherText<T>(\n  value: Value,\n  flatMap: (str: string) => T[],\n): Promise<GatheredText<T>> | GatheredText<T> {\n  if (value.type === 'string') {\n    return {parts: flatMap(value.data), success: true}\n  }\n\n  if (value.type === 'array') {\n    let success = true\n    const parts: T[] = []\n\n    for (const part of value.data) {\n      if (typeof part === 'string') {\n        parts.push(...flatMap(part))\n      } else {\n        success = false\n      }\n    }\n\n    return {parts, success}\n  }\n\n  if (value.type === 'stream') {\n    return (async () => {\n      let success = true\n      const parts: T[] = []\n\n      for await (const part of value) {\n        if (part.type === 'string') {\n          parts.push(...flatMap(part.data))\n        } else {\n          success = false\n        }\n      }\n      return {parts, success}\n    })()\n  }\n\n  return {parts: [], success: false}\n}\n","import {getType, type GroqType} from '../values'\n\nconst TYPE_ORDER: {[key in GroqType]?: number} = {\n  datetime: 1,\n  number: 2,\n  string: 3,\n  boolean: 4,\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function partialCompare(a: any, b: any): null | number {\n  const aType = getType(a)\n  const bType = getType(b)\n\n  if (aType !== bType) {\n    return null\n  }\n\n  switch (aType) {\n    case 'number':\n    case 'boolean':\n      return a - b\n    case 'string':\n      if (a < b) return -1\n      if (a > b) return 1\n      return 0\n    case 'datetime':\n      return a.compareTo(b)\n    default:\n      return null\n  }\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport function totalCompare(a: any, b: any): number {\n  const aType = getType(a)\n  const bType = getType(b)\n\n  const aTypeOrder = TYPE_ORDER[aType] || 100\n  const bTypeOrder = TYPE_ORDER[bType] || 100\n\n  if (aTypeOrder !== bTypeOrder) {\n    return aTypeOrder - bTypeOrder\n  }\n\n  let result = partialCompare(a, b)\n  if (result === null) {\n    result = 0\n  }\n  return result\n}\n","import type {OpCall} from '../nodeTypes'\nimport {\n  FALSE_VALUE,\n  fromDateTime,\n  fromJS,\n  fromNumber,\n  fromString,\n  NULL_VALUE,\n  StreamValue,\n  TRUE_VALUE,\n  type Value,\n} from '../values'\nimport {isEqual} from './equality'\nimport {\n  type GatheredText,\n  gatherText,\n  matchAnalyzePattern,\n  matchText,\n  matchTokenize,\n  type Pattern,\n  type Token,\n} from './matching'\nimport {partialCompare} from './ordering'\n\ntype GroqOperatorFn = (left: Value, right: Value) => Value | PromiseLike<Value>\n\nexport const operators: {[key in OpCall]: GroqOperatorFn} = {\n  '==': function eq(left, right) {\n    return isEqual(left, right) ? TRUE_VALUE : FALSE_VALUE\n  },\n\n  '!=': function neq(left, right) {\n    return isEqual(left, right) ? FALSE_VALUE : TRUE_VALUE\n  },\n\n  '>': function gt(left, right) {\n    if (left.type === 'stream' || right.type === 'stream') return NULL_VALUE\n    const result = partialCompare(left.data, right.data)\n\n    if (result === null) {\n      return NULL_VALUE\n    }\n    return result > 0 ? TRUE_VALUE : FALSE_VALUE\n  },\n\n  '>=': function gte(left, right) {\n    if (left.type === 'stream' || right.type === 'stream') return NULL_VALUE\n    const result = partialCompare(left.data, right.data)\n\n    if (result === null) {\n      return NULL_VALUE\n    }\n    return result >= 0 ? TRUE_VALUE : FALSE_VALUE\n  },\n\n  '<': function lt(left, right) {\n    if (left.type === 'stream' || right.type === 'stream') return NULL_VALUE\n    const result = partialCompare(left.data, right.data)\n\n    if (result === null) {\n      return NULL_VALUE\n    }\n    return result < 0 ? TRUE_VALUE : FALSE_VALUE\n  },\n\n  '<=': function lte(left, right) {\n    if (left.type === 'stream' || right.type === 'stream') return NULL_VALUE\n    const result = partialCompare(left.data, right.data)\n\n    if (result === null) {\n      return NULL_VALUE\n    }\n    return result <= 0 ? TRUE_VALUE : FALSE_VALUE\n  },\n\n  // eslint-disable-next-line func-name-matching\n  'in': function inop(left, right) {\n    if (right.type === 'path') {\n      if (left.type !== 'string') {\n        return NULL_VALUE\n      }\n\n      return right.data.matches(left.data) ? TRUE_VALUE : FALSE_VALUE\n    }\n\n    if (right.type === 'array') {\n      for (const b of right.data) {\n        if (isEqual(left, fromJS(b))) {\n          return TRUE_VALUE\n        }\n      }\n\n      return FALSE_VALUE\n    }\n\n    if (right.type === 'stream') {\n      return (async () => {\n        for await (const b of right) {\n          if (isEqual(left, b)) {\n            return TRUE_VALUE\n          }\n        }\n\n        return FALSE_VALUE\n      })()\n    }\n\n    return NULL_VALUE\n  },\n\n  'match': function match(left, right) {\n    const tokens = gatherText(left, (part) => matchTokenize(part))\n    const patterns = gatherText(right, (part) => matchAnalyzePattern(part))\n\n    const process = (tokens: GatheredText<Token>, patterns: GatheredText<Pattern>) => {\n      if (!patterns.success) {\n        return FALSE_VALUE\n      }\n\n      const matched = matchText(tokens.parts, patterns.parts)\n\n      return matched ? TRUE_VALUE : FALSE_VALUE\n    }\n\n    if ('then' in tokens || 'then' in patterns) {\n      return (async () => process(await tokens, await patterns))()\n    }\n\n    return process(tokens, patterns)\n  },\n\n  '+': function plus(left, right) {\n    if (left.type === 'datetime' && right.type === 'number') {\n      return fromDateTime(left.data.add(right.data))\n    }\n\n    if (left.type === 'number' && right.type === 'datetime') {\n      return fromDateTime(right.data.add(left.data))\n    }\n\n    if (left.type === 'number' && right.type === 'number') {\n      return fromNumber(left.data + right.data)\n    }\n\n    if (left.type === 'string' && right.type === 'string') {\n      return fromString(left.data + right.data)\n    }\n\n    if (left.type === 'object' && right.type === 'object') {\n      return fromJS({...left.data, ...right.data})\n    }\n\n    if (left.type === 'array' && right.type === 'array') {\n      return fromJS(left.data.concat(right.data))\n    }\n\n    if (left.isArray() && right.isArray()) {\n      return new StreamValue(async function* () {\n        for await (const val of left) {\n          yield val\n        }\n\n        for await (const val of right) {\n          yield val\n        }\n      })\n    }\n\n    return NULL_VALUE\n  },\n\n  '-': function minus(left, right) {\n    if (left.type === 'datetime' && right.type === 'number') {\n      return fromDateTime(left.data.add(-right.data))\n    }\n\n    if (left.type === 'datetime' && right.type === 'datetime') {\n      return fromNumber(left.data.difference(right.data))\n    }\n\n    if (left.type === 'number' && right.type === 'number') {\n      return fromNumber(left.data - right.data)\n    }\n\n    return NULL_VALUE\n  },\n\n  '*': numericOperator((a, b) => a * b),\n  '/': numericOperator((a, b) => a / b),\n  '%': numericOperator((a, b) => a % b),\n  '**': numericOperator((a, b) => Math.pow(a, b)),\n}\n\nfunction numericOperator(impl: (a: number, b: number) => number): GroqOperatorFn {\n  return function (left, right) {\n    if (left.type === 'number' && right.type === 'number') {\n      const result = impl(left.data, right.data)\n      return fromNumber(result)\n    }\n\n    return NULL_VALUE\n  }\n}\n","import type {Value} from '../values'\nimport type {Context} from './types'\n\nexport class Scope {\n  public params: Record<string, unknown>\n  public source: Value\n  public value: Value\n  public parent: Scope | null\n  public context: Context\n  public isHidden = false\n\n  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n  constructor(\n    params: Record<string, unknown>,\n    source: Value,\n    value: Value,\n    context: Context,\n    parent: Scope | null,\n  ) {\n    this.params = params\n    this.source = source\n    this.value = value\n    this.context = context\n    this.parent = parent\n  }\n\n  createNested(value: Value): Scope {\n    if (this.isHidden) {\n      return new Scope(this.params, this.source, value, this.context, this.parent)\n    }\n    return new Scope(this.params, this.source, value, this.context, this)\n  }\n\n  createHidden(value: Value): Scope {\n    const result = this.createNested(value)\n    result.isHidden = true\n    return result\n  }\n}\n","import type {ExprNode} from '../nodeTypes'\nimport {\n  type AnyStaticValue,\n  FALSE_VALUE,\n  fromArray,\n  fromJS,\n  fromNumber,\n  NULL_VALUE,\n  type ObjectValue,\n  StreamValue,\n  TRUE_VALUE,\n  type Value,\n} from '../values'\nimport {operators} from './operators'\nimport {partialCompare} from './ordering'\nimport {Scope} from './scope'\nimport type {EvaluateOptions, Executor} from './types'\n\nexport function evaluate(node: ExprNode, scope: Scope): Value | PromiseLike<Value> {\n  return executeAsync(node, scope)\n}\n\nexport function executeSync(node: ExprNode, scope: Scope): AnyStaticValue {\n  const exec = EXECUTORS[node.type]\n  return exec.executeSync(node as any, scope)\n}\n\nexport function executeAsync(node: ExprNode, scope: Scope): Promise<Value> {\n  const exec = EXECUTORS[node.type]\n  return exec.executeAsync(node as any, scope)\n}\n\ntype NarrowNode<T, N> = T extends {type: N} ? T : never\n\ntype ExecutorMap = {\n  [key in ExprNode['type']]: Executor<NarrowNode<ExprNode, key>>\n}\n\n/**\n * Defines an executor which is only valid in `evaluateAsync`.\n *\n * @deprecated This is a temporary helper. Over time we want everything to be both sync and async.\n **/\nexport function asyncOnlyExecutor<N = ExprNode>(\n  executeAsync: (node: N, scope: Scope) => Promise<Value>,\n): Executor<N> {\n  return {\n    executeSync() {\n      throw new Error('executeSync not supported')\n    },\n    executeAsync,\n  }\n}\n\nexport function constantExecutor<N = ExprNode>(fn: (node: N, scope: Scope) => Value): Executor<N> {\n  return {\n    executeSync(node, scope) {\n      const value = fn(node, scope)\n      if (value.type === 'stream') throw new Error('Stream encountered in evaluateSync')\n      return value\n    },\n    async executeAsync(node, scope) {\n      return fn(node, scope)\n    },\n  }\n}\n\nexport function mappedExecutor<N = ExprNode>(\n  map: (node: N) => ExprNode[],\n  reduce: (node: N, ...values: AnyStaticValue[]) => Value,\n): Executor<N> {\n  return {\n    executeSync(node, scope) {\n      const nodes = map(node)\n      const values = nodes.map((node) => executeSync(node, scope))\n      const value = reduce(node, ...values)\n      if (value.type === 'stream')\n        throw new Error('Stream/iterator not supported in synchronous mode')\n      return value\n    },\n    async executeAsync(node, scope) {\n      const nodes = map(node)\n      const values = await Promise.all(\n        nodes.map((node) => executeAsync(node, scope).then((value) => value.asStatic())),\n      )\n      return reduce(node, ...values)\n    },\n  }\n}\n\nexport const STOP_ITERATOR = Symbol()\n\n/**\n * An executor for procesing an array into a single value.\n *\n * @param map Returns a set of nodes which will be executed.\n * @param init Called once to produce an internal state.\n * @param reduce Called per item in the array.\n * @param wrap Turns the state into a static value.\n */\nexport function arrayReducerExecutor<N = ExprNode, State = unknown>(\n  map: (node: N) => {array: ExprNode; args?: ExprNode[]},\n  init: (node: N, ...args: AnyStaticValue[]) => State,\n  reduce: (\n    node: N,\n    state: State,\n    item: unknown,\n    ...args: AnyStaticValue[]\n  ) => State | typeof STOP_ITERATOR,\n  wrap: (state: State) => AnyStaticValue,\n): Executor<N> {\n  return {\n    executeSync(node, scope) {\n      const {array: arrayNode, args: argNodes = []} = map(node)\n      const arr = executeSync(arrayNode, scope)\n      if (arr.type !== 'array') return NULL_VALUE\n      const args = argNodes.map((node) => executeSync(node, scope))\n      let state = init(node, ...args)\n      for (const item of arr.data) {\n        const result = reduce(node, state, item, ...args)\n        if (result === STOP_ITERATOR) return NULL_VALUE\n        state = result\n      }\n      return wrap(state)\n    },\n    async executeAsync(node, scope) {\n      const {array: arrayNode, args: argNodes = []} = map(node)\n      const arr = await executeAsync(arrayNode, scope)\n      if (arr.type !== 'array' && arr.type !== 'stream') return NULL_VALUE\n\n      const args = await Promise.all(\n        argNodes.map((node) => executeAsync(node, scope).then((v) => v.asStatic())),\n      )\n\n      let state = init(node, ...args)\n\n      if (arr.type === 'stream') {\n        for await (const item of arr) {\n          const result = reduce(node, state, await item.get(), ...args)\n          if (result === STOP_ITERATOR) return NULL_VALUE\n          state = result\n        }\n      } else {\n        for (const item of arr.data) {\n          const result = reduce(node, state, item, ...args)\n          if (result === STOP_ITERATOR) return NULL_VALUE\n          state = result\n        }\n      }\n\n      return wrap(state)\n    },\n  }\n}\n\n/**\n * An executor which processes an array and returns another array.\n */\nexport function arrayExecutor<N = ExprNode, S = undefined>(\n  map: (node: N) => {array: ExprNode; inner?: ExprNode; state?: S},\n  reduce: (node: N, item: unknown, inner: unknown, state?: S) => Iterable<unknown>,\n  {hidden = false}: {hidden?: boolean} = {},\n): Executor<N> {\n  return {\n    executeSync(node, scope) {\n      const mapping = map(node)\n      const arr = executeSync(mapping.array, scope)\n      if (arr.type !== 'array') return NULL_VALUE\n      const result: unknown[] = []\n      for (const item of arr.data) {\n        let inner: unknown\n        if (mapping.inner) {\n          const newScope = hidden\n            ? scope.createHidden(fromJS(item))\n            : scope.createNested(fromJS(item))\n          inner = executeSync(mapping.inner, newScope).data\n        }\n        for (const entry of reduce(node, item, inner, mapping.state)) {\n          result.push(entry)\n        }\n      }\n      return fromArray(result)\n    },\n\n    async executeAsync(node, scope) {\n      const mapping = map(node)\n      const arr = await executeAsync(mapping.array, scope)\n      if (!arr.isArray()) return NULL_VALUE\n\n      return new StreamValue(async function* () {\n        for await (const item of arr) {\n          let inner: unknown\n          if (mapping.inner) {\n            const newScope = hidden ? scope.createHidden(item) : scope.createNested(item)\n            const innerValue = await executeAsync(mapping.inner, newScope)\n            inner = await innerValue.get()\n          }\n          for (const entry of reduce(node, await item.get(), inner, mapping.state)) {\n            yield fromJS(entry)\n          }\n        }\n      })\n    },\n  }\n}\n\nconst EXECUTORS: ExecutorMap = {\n  This: constantExecutor((_, scope) => {\n    return scope.value\n  }),\n\n  SelectorNested: constantExecutor(() => {\n    throw new Error('Unexpected node type: SelectorNested')\n  }),\n\n  SelectorFuncCall: constantExecutor(() => {\n    throw new Error('Unexpected node type: SelectorFuncCall')\n  }),\n\n  Everything: constantExecutor((_, scope) => {\n    return scope.source\n  }),\n\n  Parameter: constantExecutor(({name}, scope) => {\n    return fromJS(scope.params[name])\n  }),\n\n  Context: constantExecutor(({key}, scope) => {\n    if (key === 'before' || key === 'after') {\n      const value = scope.context[key]\n      return value || NULL_VALUE\n    }\n    throw new Error(`unknown context key: ${key}`)\n  }),\n\n  Parent: constantExecutor(({n}, scope) => {\n    let current = scope\n    for (let i = 0; i < n; i++) {\n      if (!current.parent) {\n        return NULL_VALUE\n      }\n\n      current = current.parent\n    }\n    return current.value\n  }),\n\n  OpCall: {\n    async executeAsync({op, left, right}, scope) {\n      const func = operators[op]\n      if (!func) {\n        throw new Error(`Unknown operator: ${op}`)\n      }\n      const leftValue = await executeAsync(left, scope)\n      const rightValue = await executeAsync(right, scope)\n\n      return func(leftValue, rightValue)\n    },\n    executeSync({op, left, right}, scope) {\n      const func = operators[op]\n      if (!func) {\n        throw new Error(`Unknown operator: ${op}`)\n      }\n      const leftValue = executeSync(left, scope)\n      const rightValue = executeSync(right, scope)\n\n      const result = func(leftValue, rightValue)\n      if ('then' in result || result.type === 'stream')\n        throw new Error(`Operator ${op} not possible in evaluteSync`)\n      return result\n    },\n  },\n\n  Select: {\n    executeSync({alternatives, fallback}, scope) {\n      for (const alt of alternatives) {\n        const altCond = executeSync(alt.condition, scope)\n        if (altCond.type === 'boolean' && altCond.data === true) {\n          return executeSync(alt.value, scope)\n        }\n      }\n\n      if (fallback) {\n        return executeSync(fallback, scope)\n      }\n\n      return NULL_VALUE\n    },\n\n    async executeAsync({alternatives, fallback}, scope) {\n      for (const alt of alternatives) {\n        const altCond = await executeAsync(alt.condition, scope)\n        if (altCond.type === 'boolean' && altCond.data === true) {\n          return executeAsync(alt.value, scope)\n        }\n      }\n\n      if (fallback) {\n        return executeAsync(fallback, scope)\n      }\n\n      return NULL_VALUE\n    },\n  },\n\n  InRange: mappedExecutor(\n    ({base, left, right}) => [base, left, right],\n    ({isInclusive}, value, leftValue, rightValue) => {\n      const leftCmp = partialCompare(value.data, leftValue.data)\n      if (leftCmp === null) {\n        return NULL_VALUE\n      }\n      const rightCmp = partialCompare(value.data, rightValue.data)\n      if (rightCmp === null) {\n        return NULL_VALUE\n      }\n\n      if (isInclusive) {\n        return leftCmp >= 0 && rightCmp <= 0 ? TRUE_VALUE : FALSE_VALUE\n      }\n\n      return leftCmp >= 0 && rightCmp < 0 ? TRUE_VALUE : FALSE_VALUE\n    },\n  ),\n\n  Filter: arrayExecutor(\n    ({base, expr}) => ({array: base, inner: expr}),\n    function* (_, elem, inner) {\n      if (inner === true) yield elem\n    },\n  ),\n\n  Projection: {\n    executeSync({base, expr}, scope) {\n      const baseValue = executeSync(base, scope)\n\n      if (baseValue.type !== 'object') {\n        return NULL_VALUE\n      }\n\n      const newScope = scope.createNested(baseValue)\n      return executeSync(expr, newScope)\n    },\n\n    async executeAsync({base, expr}, scope) {\n      const baseValue = await executeAsync(base, scope)\n      if (baseValue.type !== 'object') {\n        return NULL_VALUE\n      }\n\n      const newScope = scope.createNested(baseValue)\n      return executeAsync(expr, newScope)\n    },\n  },\n\n  FuncCall: {\n    executeAsync({func, args}, scope) {\n      return func.executeAsync(args, scope)\n    },\n\n    executeSync({func, args}, scope) {\n      return func.executeSync(args, scope)\n    },\n  },\n\n  PipeFuncCall: {\n    async executeAsync({func, base, args}, scope) {\n      const baseValue = await executeAsync(base, scope)\n      if (baseValue.type !== 'stream' && baseValue.type !== 'array') return NULL_VALUE\n      return func.executeAsync({base: baseValue, args}, scope)\n    },\n\n    executeSync({func, base, args}, scope) {\n      const baseValue = executeSync(base, scope)\n      if (baseValue.type !== 'array') return NULL_VALUE\n      return func.executeSync({base: baseValue, args}, scope)\n    },\n  },\n\n  AccessAttribute: mappedExecutor(\n    ({base}) => [base || {type: 'This'}],\n    ({name}, value) => {\n      if (value.type === 'object') {\n        if (value.data.hasOwnProperty(name)) {\n          return fromJS(value.data[name]) as ObjectValue\n        }\n      }\n\n      return NULL_VALUE\n    },\n  ),\n\n  AccessElement: mappedExecutor(\n    ({base}) => [base],\n    ({index}, baseValue) => {\n      if (baseValue.type !== 'array') return NULL_VALUE\n      const data = baseValue.data\n      const finalIndex = index < 0 ? index + data.length : index\n      return fromJS(data[finalIndex])\n    },\n  ),\n\n  Slice: mappedExecutor(\n    ({base}) => [base],\n    ({left, right, isInclusive}, baseValue) => {\n      if (baseValue.type !== 'array') {\n        return NULL_VALUE\n      }\n\n      // OPT: Here we can optimize when either indices are >= 0\n      const array = baseValue.data\n\n      let leftIdx = left\n      let rightIdx = right\n\n      // Handle negative index\n      if (leftIdx < 0) {\n        leftIdx = array.length + leftIdx\n      }\n      if (rightIdx < 0) {\n        rightIdx = array.length + rightIdx\n      }\n\n      // Convert from inclusive to exclusive index\n      if (isInclusive) {\n        rightIdx++\n      }\n\n      if (leftIdx < 0) {\n        leftIdx = 0\n      }\n      if (rightIdx < 0) {\n        rightIdx = 0\n      }\n\n      // Note: At this point the indices might point out-of-bound, but\n      // .slice handles this correctly.\n\n      return fromArray(array.slice(leftIdx, rightIdx))\n    },\n  ),\n\n  Deref: {\n    executeSync({base}, scope) {\n      const value = executeSync(base, scope)\n\n      if (value.type !== 'object') {\n        return NULL_VALUE\n      }\n\n      const id = value.data['_ref']\n      if (typeof id !== 'string') {\n        return NULL_VALUE\n      }\n\n      if (scope.context.dereference) {\n        const value = scope.context.dereference({_ref: id})\n        if (value && typeof value === 'object' && 'then' in value) {\n          throw new Error('Dereference returned promise in synchronous mode')\n        }\n\n        return fromJS(value) as AnyStaticValue\n      }\n\n      if (scope.source.type !== 'array') {\n        return NULL_VALUE\n      }\n\n      for (const doc of scope.source.data) {\n        if (doc && typeof doc === 'object' && '_id' in doc && id === doc['_id']) {\n          return fromJS(doc) as ObjectValue\n        }\n      }\n\n      return NULL_VALUE\n    },\n\n    async executeAsync({base}, scope) {\n      const value = await executeAsync(base, scope)\n\n      if (!scope.source.isArray()) {\n        return NULL_VALUE\n      }\n\n      if (value.type !== 'object') {\n        return NULL_VALUE\n      }\n\n      const id = value.data['_ref']\n      if (typeof id !== 'string') {\n        return NULL_VALUE\n      }\n\n      if (scope.context.dereference) {\n        return fromJS(await scope.context.dereference({_ref: id}))\n      }\n\n      for await (const doc of scope.source) {\n        if (doc.type === 'object' && id === doc.data['_id']) {\n          return doc\n        }\n      }\n\n      return NULL_VALUE\n    },\n  },\n\n  Value: constantExecutor(({value}) => {\n    return fromJS(value)\n  }),\n\n  Group: {\n    executeSync({base}, scope) {\n      return executeSync(base, scope)\n    },\n    executeAsync({base}, scope) {\n      return executeAsync(base, scope)\n    },\n  },\n\n  Object: {\n    executeSync({attributes}, scope) {\n      const result: {[key: string]: any} = {}\n      for (const attr of attributes) {\n        const attrType = attr.type\n        switch (attr.type) {\n          case 'ObjectAttributeValue': {\n            const value = executeSync(attr.value, scope)\n            result[attr.name] = value.data\n            break\n          }\n\n          case 'ObjectConditionalSplat': {\n            const cond = executeSync(attr.condition, scope)\n            if (cond.type !== 'boolean' || cond.data === false) {\n              continue\n            }\n\n            const value = executeSync(attr.value, scope)\n            if (value.type === 'object') {\n              Object.assign(result, value.data)\n            }\n            break\n          }\n\n          case 'ObjectSplat': {\n            const value = executeSync(attr.value, scope)\n            if (value.type === 'object') {\n              Object.assign(result, value.data)\n            }\n            break\n          }\n\n          default:\n            throw new Error(`Unknown node type: ${attrType}`)\n        }\n      }\n      return fromJS(result) as ObjectValue\n    },\n\n    async executeAsync({attributes}, scope) {\n      const result: {[key: string]: any} = {}\n      for (const attr of attributes) {\n        const attrType = attr.type\n        switch (attr.type) {\n          case 'ObjectAttributeValue': {\n            const value = await executeAsync(attr.value, scope)\n            result[attr.name] = await value.get()\n            break\n          }\n\n          case 'ObjectConditionalSplat': {\n            const cond = await executeAsync(attr.condition, scope)\n            if (cond.type !== 'boolean' || cond.data === false) {\n              continue\n            }\n\n            const value = await executeAsync(attr.value, scope)\n            if (value.type === 'object') {\n              Object.assign(result, value.data)\n            }\n            break\n          }\n\n          case 'ObjectSplat': {\n            const value = await executeAsync(attr.value, scope)\n            if (value.type === 'object') {\n              Object.assign(result, value.data)\n            }\n            break\n          }\n\n          default:\n            throw new Error(`Unknown node type: ${attrType}`)\n        }\n      }\n      return fromJS(result)\n    },\n  },\n\n  Array: {\n    executeSync({elements}, scope) {\n      const result = []\n      for (const element of elements) {\n        const value = executeSync(element.value, scope)\n        if (element.isSplat) {\n          if (value.type === 'array') {\n            for (const v of value.data) {\n              result.push(v)\n            }\n          }\n        } else {\n          result.push(value.data)\n        }\n      }\n\n      return fromArray(result)\n    },\n\n    async executeAsync({elements}, scope) {\n      return new StreamValue(async function* () {\n        for (const element of elements) {\n          const value = await executeAsync(element.value, scope)\n          if (element.isSplat) {\n            if (value.isArray()) {\n              for await (const v of value) {\n                yield v\n              }\n            }\n          } else {\n            yield value\n          }\n        }\n      })\n    },\n  },\n\n  Tuple: constantExecutor(() => {\n    throw new Error('tuples can not be evaluated')\n  }),\n\n  Or: mappedExecutor(\n    ({left, right}) => [left, right],\n    (_, leftValue, rightValue) => {\n      if (leftValue.type === 'boolean') {\n        if (leftValue.data === true) {\n          return TRUE_VALUE\n        }\n      }\n\n      if (rightValue.type === 'boolean') {\n        if (rightValue.data === true) {\n          return TRUE_VALUE\n        }\n      }\n\n      if (leftValue.type !== 'boolean' || rightValue.type !== 'boolean') {\n        return NULL_VALUE\n      }\n\n      return FALSE_VALUE\n    },\n  ),\n\n  And: mappedExecutor(\n    ({left, right}) => [left, right],\n    (_, leftValue, rightValue) => {\n      if (leftValue.type === 'boolean') {\n        if (leftValue.data === false) {\n          return FALSE_VALUE\n        }\n      }\n\n      if (rightValue.type === 'boolean') {\n        if (rightValue.data === false) {\n          return FALSE_VALUE\n        }\n      }\n\n      if (leftValue.type !== 'boolean' || rightValue.type !== 'boolean') {\n        return NULL_VALUE\n      }\n\n      return TRUE_VALUE\n    },\n  ),\n\n  Not: mappedExecutor(\n    ({base}) => [base],\n    (_, value) => {\n      if (value.type !== 'boolean') {\n        return NULL_VALUE\n      }\n      return value.data ? FALSE_VALUE : TRUE_VALUE\n    },\n  ),\n\n  Neg: mappedExecutor(\n    ({base}) => [base],\n    (_, value) => {\n      if (value.type !== 'number') {\n        return NULL_VALUE\n      }\n      return fromNumber(-value.data)\n    },\n  ),\n\n  Pos: mappedExecutor(\n    ({base}) => [base],\n    (_, value) => {\n      if (value.type !== 'number') {\n        return NULL_VALUE\n      }\n      return fromNumber(value.data)\n    },\n  ),\n\n  Asc: constantExecutor(() => NULL_VALUE),\n  Desc: constantExecutor(() => NULL_VALUE),\n\n  ArrayCoerce: {\n    executeSync({base}, scope) {\n      const value = executeSync(base, scope)\n      return value.isArray() ? value : NULL_VALUE\n    },\n\n    async executeAsync({base}, scope) {\n      const value = await executeAsync(base, scope)\n      return value.isArray() ? value : NULL_VALUE\n    },\n  },\n\n  Map: arrayExecutor(\n    ({base, expr}) => ({array: base, inner: expr}),\n    function* (_, _item, inner) {\n      yield inner\n    },\n    {hidden: true},\n  ),\n\n  FlatMap: arrayExecutor(\n    ({base, expr}) => ({array: base, inner: expr}),\n    function* (_, _item, inner) {\n      if (Array.isArray(inner)) {\n        for (const innerInner of inner) {\n          yield innerInner\n        }\n      } else {\n        yield inner\n      }\n    },\n    {hidden: true},\n  ),\n}\n\n/**\n * Evaluates a query.\n * @internal\n */\nexport function evaluateQuery(\n  tree: ExprNode,\n  options: EvaluateOptions = {},\n): Value | PromiseLike<Value> {\n  return executeAsync(tree, scopeFromOptions(options))\n}\n\n/**\n * Evaluates a query synchronously.\n *\n * This currently only supports a tiny subset of the GROQ language.\n * @internal\n */\nexport function evaluateQuerySync(tree: ExprNode, options: EvaluateOptions = {}): AnyStaticValue {\n  return executeSync(tree, scopeFromOptions(options))\n}\n\nfunction scopeFromOptions(options: EvaluateOptions): Scope {\n  const root = fromJS(options.root)\n  const dataset = fromJS(options.dataset)\n  const params: {[key: string]: any} = {...options.params}\n\n  return new Scope(\n    params,\n    dataset,\n    root,\n    {\n      timestamp: options.timestamp || new Date(),\n      identity: options.identity === undefined ? 'me' : options.identity,\n      sanity: options.sanity,\n      after: options.after ? fromJS(options.after) : null,\n      before: options.before ? fromJS(options.before) : null,\n      dereference: options.dereference,\n    },\n    null,\n  )\n}\n","import type {ExprNode} from '../nodeTypes'\nimport {type AnyStaticValue, NULL_VALUE} from '../values'\nimport {executeSync} from './evaluate'\nimport {Scope} from './scope'\n\nfunction canConstantEvaluate(node: ExprNode): boolean {\n  switch (node.type) {\n    case 'Group':\n      return canConstantEvaluate(node.base)\n    case 'Value':\n    case 'Parameter':\n      return true\n    case 'Pos':\n    case 'Neg':\n      return canConstantEvaluate(node.base)\n    case 'OpCall':\n      switch (node.op) {\n        case '+':\n        case '-':\n        case '*':\n        case '/':\n        case '%':\n        case '**':\n          return canConstantEvaluate(node.left) && canConstantEvaluate(node.right)\n        default:\n          return false\n      }\n    default:\n      return false\n  }\n}\n\nconst DUMMY_SCOPE = new Scope(\n  {},\n  NULL_VALUE,\n  NULL_VALUE,\n  {timestamp: new Date(0), identity: 'me', before: null, after: null},\n  null,\n)\n\nexport function tryConstantEvaluate(node: ExprNode): AnyStaticValue | null {\n  if (!canConstantEvaluate(node)) {\n    return null\n  }\n\n  return constantEvaluate(node)\n}\n\nfunction constantEvaluate(node: ExprNode): AnyStaticValue {\n  return executeSync(node, DUMMY_SCOPE)\n}\n","import type {GroqFunction, GroqPipeFunction} from './evaluator/functions'\n\n/** Any sort of node which appears as syntax */\nexport type SyntaxNode = ExprNode | ArrayElementNode | ObjectAttributeNode | SelectAlternativeNode\n\nexport type ObjectAttributeNode =\n  | ObjectAttributeValueNode\n  | ObjectConditionalSplatNode\n  | ObjectSplatNode\n\n/**\n * A node which can be evaluated into a value.\n * @public\n */\nexport type ExprNode =\n  | AccessAttributeNode\n  | AccessElementNode\n  | AndNode\n  | ArrayNode\n  | ArrayCoerceNode\n  | AscNode\n  | ContextNode\n  | DerefNode\n  | DescNode\n  | EverythingNode\n  | FilterNode\n  | FlatMapNode\n  | FuncCallNode\n  | GroupNode\n  | InRangeNode\n  | MapNode\n  | NegNode\n  | NotNode\n  | ObjectNode\n  | OpCallNode\n  | OrNode\n  | ParameterNode\n  | ParentNode\n  | PipeFuncCallNode\n  | PosNode\n  | ProjectionNode\n  | SelectNode\n  | SelectorNode\n  | SliceNode\n  | ThisNode\n  | TupleNode\n  | ValueNode\n\nexport type OpCall =\n  | '=='\n  | '!='\n  | '>'\n  | '>='\n  | '<'\n  | '<='\n  | '+'\n  | '-'\n  | '*'\n  | '/'\n  | '%'\n  | '**'\n  | 'in'\n  | 'match'\n\n/** The base interface for SyntaxNode. */\nexport interface BaseNode {\n  type: string\n}\n\nexport interface AndNode extends BaseNode {\n  type: 'And'\n  left: ExprNode\n  right: ExprNode\n}\n\nexport interface ArrayElementNode extends BaseNode {\n  type: 'ArrayElement'\n  value: ExprNode\n  isSplat: boolean\n}\n\nexport interface ArrayNode extends BaseNode {\n  type: 'Array'\n  elements: ArrayElementNode[]\n}\n\nexport interface ArrayCoerceNode<Base = ExprNode> extends BaseNode {\n  type: 'ArrayCoerce'\n  base: Base\n}\n\nexport interface AscNode extends BaseNode {\n  type: 'Asc'\n  base: ExprNode\n}\n\nexport interface ContextNode extends BaseNode {\n  type: 'Context'\n  key: string\n}\n\nexport interface DerefNode extends BaseNode {\n  type: 'Deref'\n  base: ExprNode\n}\n\nexport interface DescNode extends BaseNode {\n  type: 'Desc'\n  base: ExprNode\n}\n\nexport interface EverythingNode extends BaseNode {\n  type: 'Everything'\n}\n\nexport interface FuncCallNode extends BaseNode {\n  type: 'FuncCall'\n  func: GroqFunction\n  namespace: string\n  name: string\n  args: ExprNode[]\n}\n\nexport interface GroupNode<Base = ExprNode> extends BaseNode {\n  type: 'Group'\n  base: Base\n}\n\nexport interface InRangeNode extends BaseNode {\n  type: 'InRange'\n  base: ExprNode\n  left: ExprNode\n  right: ExprNode\n  isInclusive: boolean\n}\n\nexport interface NegNode extends BaseNode {\n  type: 'Neg'\n  base: ExprNode\n}\n\nexport interface NotNode extends BaseNode {\n  type: 'Not'\n  base: ExprNode\n}\n\nexport interface ObjectAttributeValueNode extends BaseNode {\n  type: 'ObjectAttributeValue'\n  name: string\n  value: ExprNode\n}\n\nexport interface ObjectConditionalSplatNode extends BaseNode {\n  type: 'ObjectConditionalSplat'\n  condition: ExprNode\n  value: ExprNode\n}\n\nexport interface ObjectNode extends BaseNode {\n  type: 'Object'\n  attributes: ObjectAttributeNode[]\n}\n\nexport interface ObjectSplatNode extends BaseNode {\n  type: 'ObjectSplat'\n  value: ExprNode\n}\n\nexport interface OpCallNode extends BaseNode {\n  type: 'OpCall'\n  op: OpCall\n  left: ExprNode\n  right: ExprNode\n}\n\nexport interface OrNode extends BaseNode {\n  type: 'Or'\n  left: ExprNode\n  right: ExprNode\n}\n\nexport interface ParameterNode extends BaseNode {\n  type: 'Parameter'\n  name: string\n}\n\nexport interface ParentNode extends BaseNode {\n  type: 'Parent'\n  n: number\n}\n\nexport interface PipeFuncCallNode extends BaseNode {\n  type: 'PipeFuncCall'\n  func: GroqPipeFunction\n  base: ExprNode\n  name: string\n  args: ExprNode[]\n}\n\nexport interface PosNode extends BaseNode {\n  type: 'Pos'\n  base: ExprNode\n}\n\nexport interface SelectAlternativeNode extends BaseNode {\n  type: 'SelectAlternative'\n  condition: ExprNode\n  value: ExprNode\n}\n\nexport interface SelectNode extends BaseNode {\n  type: 'Select'\n  alternatives: SelectAlternativeNode[]\n  fallback?: ExprNode\n}\n\nexport type SelectorNode =\n  | AccessAttributeNode<SelectorNode>\n  | SelectorFuncCallNode\n  | GroupNode<SelectorNode>\n  | TupleNode<SelectorNode>\n  | ArrayCoerceNode<SelectorNode>\n  | FilterNode<SelectorNode>\n  | SelectorNestedNode\nexport function isSelectorNode(node: BaseNode): node is SelectorNode {\n  return [\n    'AccessAttribute',\n    'SelectorFuncCall',\n    'Group',\n    'Tuple',\n    'ArrayCoerce',\n    'Filter',\n    'SelectorNested',\n  ].includes(node.type)\n}\n\nexport interface SelectorFuncCallNode extends BaseNode {\n  type: 'SelectorFuncCall'\n  name: 'anywhere'\n  arg: ExprNode\n}\n\nexport type SelectorNested =\n  | AccessAttributeNode<SelectorNode>\n  | ArrayCoerceNode<SelectorNode>\n  | FilterNode<SelectorNode>\n  | GroupNode<SelectorNode>\n  | TupleNode<SelectorNode>\nexport function isSelectorNested(node: BaseNode): node is SelectorNested {\n  return ['AccessAttribute', 'ArrayCoerce', 'Filter', 'Group', 'Tuple', 'SelectorNested'].includes(\n    node.type,\n  )\n}\n\nexport interface SelectorNestedNode extends BaseNode {\n  type: 'SelectorNested'\n  base: SelectorNode\n  nested: SelectorNested\n}\n\nexport interface ThisNode extends BaseNode {\n  type: 'This'\n}\n\nexport interface TupleNode<Base = ExprNode> extends BaseNode {\n  type: 'Tuple'\n  members: Array<Base>\n}\n\nexport interface ValueNode<P = any> {\n  type: 'Value'\n  value: P\n}\n\nexport interface FunctionDeclarationNode {\n  type: 'FuncDeclaration'\n  namespace: string\n  name: string\n  params: ParameterNode[]\n  body: ExprNode\n}\n\nexport interface FlatMapNode extends BaseNode {\n  type: 'FlatMap'\n  base: ExprNode\n  expr: ExprNode\n}\n\nexport interface MapNode extends BaseNode {\n  type: 'Map'\n  base: ExprNode\n  expr: ExprNode\n}\n\nexport interface AccessAttributeNode<T = ExprNode> extends BaseNode {\n  type: 'AccessAttribute'\n  base?: T\n  name: string\n}\n\nexport interface AccessElementNode extends BaseNode {\n  type: 'AccessElement'\n  base: ExprNode\n  index: number\n}\n\nexport interface SliceNode extends BaseNode {\n  type: 'Slice'\n  base: ExprNode\n  left: number\n  right: number\n  isInclusive: boolean\n}\n\nexport interface FilterNode<Base = ExprNode> extends BaseNode {\n  type: 'Filter'\n  base: Base\n  expr: ExprNode\n}\n\nexport interface ProjectionNode extends BaseNode {\n  type: 'Projection'\n  base: ExprNode\n  expr: ExprNode\n}\n","import {FALSE_VALUE, fromJS, fromString, getType, NULL_VALUE, TRUE_VALUE} from '../../values'\nimport {isEqual} from '../equality'\nimport {arrayExecutor, mappedExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst array: FunctionSet = {}\n\narray['join'] = mappedExecutor(\n  (args) => args,\n  (_, arr, sep) => {\n    if (arr.type !== 'array') {\n      return NULL_VALUE\n    }\n    if (sep.type !== 'string') {\n      return NULL_VALUE\n    }\n    let buf = ''\n    let needSep = false\n    for (const elem of arr.data) {\n      if (needSep) {\n        buf += sep.data\n      }\n      switch (getType(elem)) {\n        case 'number':\n        case 'string':\n        case 'boolean':\n        case 'datetime':\n          buf += `${elem}`\n          break\n        default:\n          return NULL_VALUE\n      }\n      needSep = true\n    }\n    return fromString(buf)\n  },\n)\narray['join'].arity = 2\n\narray['compact'] = arrayExecutor(\n  ([array]) => ({array: array!}),\n  function* (_, item) {\n    if (item !== null) yield item\n  },\n)\narray['compact'].arity = 1\n\narray['unique'] = arrayExecutor(\n  (args) => ({array: args[0]!, state: new Set()}),\n  function* (_node, iter, _inner, added) {\n    switch (getType(iter)) {\n      case 'number':\n      case 'string':\n      case 'boolean':\n      case 'datetime':\n        if (!added!.has(iter)) {\n          added!.add(iter)\n          yield iter\n        }\n        break\n      default:\n        yield iter\n    }\n  },\n)\narray['unique'].arity = 1\n\narray['intersects'] = mappedExecutor(\n  (args) => args,\n  (_, arr1, arr2) => {\n    // Intersects returns true if the two arrays have at least one element in common. Only\n    // primitives are supported; non-primitives are ignored.\n    if (arr1.type !== 'array' || arr2.type !== 'array') {\n      return NULL_VALUE\n    }\n\n    for (const v1 of arr1.data) {\n      for (const v2 of arr2.data) {\n        if (isEqual(fromJS(v1), fromJS(v2))) {\n          return TRUE_VALUE\n        }\n      }\n    }\n\n    return FALSE_VALUE\n  },\n)\narray['intersects'].arity = 2\n\nexport default array\n","import {DateTime, fromDateTime} from '../../values'\nimport {constantExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst dateTime: FunctionSet = {}\ndateTime['now'] = constantExecutor((_, scope) =>\n  fromDateTime(new DateTime(scope.context.timestamp)),\n)\ndateTime['now'].arity = 0\n\nexport default dateTime\n","import {fromJS, type Value} from '../values'\nimport {deepEqual} from './equality'\nimport type {KeyPath} from './types'\n\nexport async function valueAtPath(arg: Value, keyPath: KeyPath): Promise<any> {\n  function tryAccessor(arg: any, accessor: string | number): any | undefined {\n    try {\n      return arg[accessor]\n    } catch {\n      // ignore the error\n      return undefined\n    }\n  }\n\n  let current = await arg.get()\n  for (const part of keyPath) {\n    current = tryAccessor(current, part)\n    if (!current) break\n  }\n  return current\n}\n\nexport function startsWith(keyPath: KeyPath, prefix: KeyPath): boolean {\n  return prefix.every((item, index) => keyPath[index] === item)\n}\n\nexport async function* diffKeyPaths(before: Value, after: Value): AsyncGenerator<KeyPath> {\n  // a queue of paths to investigate for differences\n  const currPaths: KeyPath[] = [[]]\n  while (currPaths.length > 0) {\n    const currPath: KeyPath = currPaths.shift() || []\n    const b = fromJS(await valueAtPath(before, currPath))\n    const a = fromJS(await valueAtPath(after, currPath))\n\n    if (a.type !== b.type) {\n      yield currPath\n    } else if (\n      (a.type === 'string' && b.type === 'string') ||\n      (a.type === 'boolean' && b.type === 'boolean') ||\n      (a.type === 'null' && b.type === 'null') ||\n      (a.type === 'number' && b.type === 'number')\n    ) {\n      if (a.data !== b.data) yield currPath\n    } else if (a.type === 'datetime' && b.type === 'datetime') {\n      if (!a.data.equals(b.data)) yield currPath\n    } else if (a.type === 'object' && b.type === 'object') {\n      if (!deepEqual(a.data, b.data)) {\n        const aKeys = Object.keys(a.data)\n        const bKeys = Object.keys(b.data)\n        const keys = new Set(aKeys.concat(bKeys))\n        keys.forEach((key) => {\n          currPaths.push([...currPath, key])\n        })\n      }\n    } else if (a.type === 'array' && b.type === 'array') {\n      if (a.data.length !== b.data.length) {\n        yield currPath\n      } else if (!deepEqual(a.data, b.data)) {\n        for (let i = 0; i < b.data.length; i++) {\n          currPaths.push([...currPath, i])\n        }\n      }\n    } else if (a.type === 'stream' && b.type === 'stream') {\n      const arrayA = await a.get()\n      const arrayB = await b.get()\n\n      if (arrayA.length !== arrayB.length) {\n        yield currPath\n      } else if (!deepEqual(arrayA, arrayB)) {\n        for (let i = 0; i < arrayB.length; i++) {\n          currPaths.push([...currPath, i])\n        }\n      }\n    }\n  }\n}\n","import type {ExprNode, FilterNode, SelectorNode} from '../nodeTypes'\nimport {fromJS, type Value} from '../values'\nimport {evaluate} from './evaluate'\nimport {valueAtPath} from './keyPath'\nimport type {Scope} from './scope'\nimport type {KeyPath} from './types'\n\nexport async function evaluateSelector(\n  node: SelectorNode,\n  value: Value,\n  scope: Scope,\n): Promise<KeyPath[]> {\n  switch (node.type) {\n    case 'Group':\n      return await evaluateSelector(node.base, value, scope)\n    case 'Tuple':\n      const tuplePaths: Array<KeyPath> = []\n      for (const member of node.members) {\n        const memberPaths = await evaluateSelector(member, value, scope)\n        tuplePaths.push(...memberPaths)\n      }\n      return tuplePaths\n    case 'AccessAttribute':\n      if (node.base) {\n        const accessPaths = await evaluateSelector(node.base, value, scope)\n        return accessPaths.map((path) => [...path, node.name])\n      }\n\n      return [[node.name]]\n    case 'ArrayCoerce': {\n      const paths = await evaluateSelector(node.base, value, scope)\n\n      const arrayPaths: KeyPath[] = []\n      for (const keyPath of paths) {\n        const innerValue = await valueAtPath(value, keyPath)\n\n        if (Array.isArray(innerValue)) {\n          for (let i = 0; i < innerValue.length; i++) {\n            arrayPaths.push([...keyPath, i])\n          }\n        }\n      }\n\n      return arrayPaths\n    }\n    case 'Filter': {\n      const paths = await evaluateSelector(node.base, value, scope)\n\n      // create a special filter to use the current value by making the base `this`\n      const filter: FilterNode = {\n        ...node,\n        base: {type: 'This'},\n      }\n\n      const arrayPaths: KeyPath[] = []\n      for (const keyPath of paths) {\n        const innerValue = await valueAtPath(value, keyPath)\n        if (Array.isArray(innerValue)) {\n          for (let i = 0; i < innerValue.length; i++) {\n            const item = innerValue[i]\n            const nestedScope = scope.createNested(fromJS([item]))\n            const result = await evaluate(filter, nestedScope)\n            const matched = await result.get()\n            if (matched.length > 0) arrayPaths.push([...keyPath, i])\n          }\n        }\n      }\n\n      return arrayPaths\n    }\n    case 'SelectorFuncCall': {\n      return anywhere(node.arg, scope.createHidden(value))\n    }\n    case 'SelectorNested': {\n      const {base, nested: expr} = node\n\n      const paths = await evaluateSelector(base, value, scope)\n      const nestedPaths: KeyPath[] = []\n      for (const keyPath of paths) {\n        const innerValue = await valueAtPath(value, keyPath)\n\n        switch (expr.type) {\n          case 'AccessAttribute':\n          case 'ArrayCoerce':\n          case 'Filter':\n            const accessPaths = await evaluateSelector(expr, fromJS(innerValue), scope)\n            for (let i = 0; i < accessPaths.length; i++) {\n              nestedPaths.push([...keyPath, ...accessPaths[i]])\n            }\n            break\n\n          case 'Group':\n            const innerResult = await evaluateSelector(expr.base, fromJS(innerValue), scope)\n            for (const innerKeyPath of innerResult) {\n              nestedPaths.push([...keyPath, ...innerKeyPath])\n            }\n            break\n\n          case 'Tuple':\n            for (const inner of expr.members) {\n              const innerResult = await evaluateSelector(inner, fromJS(innerValue), scope)\n              for (const innerKeyPath of innerResult) {\n                nestedPaths.push([...keyPath, ...innerKeyPath])\n              }\n            }\n        }\n      }\n      return nestedPaths\n    }\n  }\n}\n\nasync function anywhere(expr: ExprNode, scope: Scope, base: KeyPath = []): Promise<KeyPath[]> {\n  const value = scope.value\n\n  const pathList: KeyPath[] = []\n  if (value.isArray()) {\n    const arr: any[] = await value.get()\n    for (let i = 0; i < arr.length; i++) {\n      const subPaths = await anywhere(expr, scope.createHidden(fromJS(arr[i])), [...base, i])\n      pathList.push(...subPaths)\n    }\n  } else if (value.type === 'object') {\n    const result = await evaluate(expr, scope)\n    if (result.type === 'boolean' && result.data === true) {\n      pathList.push(base)\n    }\n\n    for (const key of Object.keys(value.data)) {\n      const subPaths = await anywhere(expr, scope.createHidden(fromJS(value.data[key])), [\n        ...base,\n        key,\n      ])\n      pathList.push(...subPaths)\n    }\n  }\n\n  return pathList\n}\n","import {isSelectorNode, type SelectorNode} from '../../nodeTypes'\nimport {type BooleanValue, FALSE_VALUE, TRUE_VALUE, type Value} from '../../values'\nimport {deepEqual} from '../equality'\nimport {asyncOnlyExecutor, executeAsync} from '../evaluate'\nimport {diffKeyPaths, startsWith, valueAtPath} from '../keyPath'\nimport type {Scope} from '../scope'\nimport {evaluateSelector} from '../selector'\nimport type {FunctionSet} from '.'\n\nexport async function changedAny(\n  before: Value,\n  after: Value,\n  selector: SelectorNode,\n  scope: Scope,\n): Promise<BooleanValue> {\n  const beforeSelectorScope = scope.createHidden(before)\n  const beforePaths = await evaluateSelector(\n    selector,\n    beforeSelectorScope.value,\n    beforeSelectorScope,\n  )\n  const afterSelectorScope = scope.createHidden(after)\n  const afterPaths = await evaluateSelector(selector, afterSelectorScope.value, afterSelectorScope)\n  if (beforePaths.length !== afterPaths.length) {\n    return TRUE_VALUE\n  }\n\n  for (const path of beforePaths) {\n    for (let i = 0; i < path.length; i++) {\n      if (typeof path[i] === 'number') {\n        const slice = path.slice(0, i)\n        const beforeArr = await valueAtPath(before, slice)\n        const afterArr = await valueAtPath(after, slice)\n\n        if (\n          !Array.isArray(beforeArr) ||\n          !Array.isArray(afterArr) ||\n          beforeArr.length !== afterArr.length\n        ) {\n          return TRUE_VALUE\n        }\n      }\n    }\n\n    const beforeValue = await valueAtPath(before, path)\n    const afterValue = await valueAtPath(after, path)\n\n    if (!deepEqual(beforeValue, afterValue)) {\n      return TRUE_VALUE\n    }\n  }\n\n  return FALSE_VALUE\n}\n\nexport async function changedOnly(\n  before: Value,\n  after: Value,\n  selector: SelectorNode,\n  scope: Scope,\n): Promise<BooleanValue> {\n  const beforeSelectorScope = scope.createHidden(before)\n  const selectedPaths = await evaluateSelector(\n    selector,\n    beforeSelectorScope.value,\n    beforeSelectorScope,\n  )\n\n  for await (const diffPath of diffKeyPaths(before, after)) {\n    let found = false\n    for (const selectedPath of selectedPaths) {\n      // it matches if the diff path starts with the selected path\n      const match = startsWith(diffPath, selectedPath)\n      if (match) {\n        found = true\n        break\n      }\n    }\n    if (!found) {\n      return FALSE_VALUE\n    }\n  }\n\n  return TRUE_VALUE\n}\n\nconst diff: FunctionSet = {}\ndiff['changedAny'] = asyncOnlyExecutor(async (args, scope) => {\n  const lhs = args[0]\n  const rhs = args[1]\n  const selector = args[2]\n  if (!isSelectorNode(selector)) throw new Error('changedAny third argument must be a selector')\n\n  const before = await executeAsync(lhs, scope)\n  const after = await executeAsync(rhs, scope)\n\n  return changedAny(before, after, selector, scope)\n})\ndiff['changedAny'].arity = 3\n\ndiff['changedOnly'] = asyncOnlyExecutor(async (args, scope) => {\n  const lhs = args[0]\n  const rhs = args[1]\n  const selector = args[2]\n  if (!isSelectorNode(selector)) throw new Error('changedOnly third argument must be a selector')\n\n  const before = await executeAsync(lhs, scope)\n  const after = await executeAsync(rhs, scope)\n\n  return changedOnly(before, after, selector, scope)\n})\ndiff['changedOnly'].arity = 3\n\nexport default diff\n","import {isSelectorNode} from '../../nodeTypes'\nimport {fromString, NULL_VALUE} from '../../values'\nimport {asyncOnlyExecutor, constantExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\nimport {changedAny, changedOnly} from './diff'\n\nconst delta: FunctionSet = {}\n// eslint-disable-next-line require-await\ndelta['operation'] = constantExecutor((_, scope) => {\n  const hasBefore = scope.context.before !== null\n  const hasAfter = scope.context.after !== null\n\n  if (hasBefore && hasAfter) {\n    return fromString('update')\n  }\n\n  if (hasAfter) {\n    return fromString('create')\n  }\n\n  if (hasBefore) {\n    return fromString('delete')\n  }\n\n  return NULL_VALUE\n})\n\ndelta['changedAny'] = asyncOnlyExecutor(async (args, scope) => {\n  const before = scope.context.before || NULL_VALUE\n  const after = scope.context.after || NULL_VALUE\n  const selector = args[0]\n  if (!isSelectorNode(selector)) throw new Error('changedAny first argument must be a selector')\n\n  return changedAny(before, after, selector, scope)\n})\ndelta['changedAny'].arity = 1\ndelta['changedAny'].mode = 'delta'\n\ndelta['changedOnly'] = asyncOnlyExecutor(async (args, scope) => {\n  const before = scope.context.before || NULL_VALUE\n  const after = scope.context.after || NULL_VALUE\n  const selector = args[0]\n  if (!isSelectorNode(selector)) throw new Error('changedOnly first argument must be a selector')\n\n  return changedOnly(before, after, selector, scope)\n})\ndelta['changedOnly'].arity = 1\ndelta['changedOnly'].mode = 'delta'\n\nexport default delta\n","import {constantExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst documents: FunctionSet = {}\ndocuments['get'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\ndocuments['incomingRefCount'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\ndocuments['incomingGlobalDocumentReferenceCount'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\nexport default documents\n","import {constantExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst geo: FunctionSet = {}\ngeo['latLng'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\ngeo['contains'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\ngeo['intersects'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\ngeo['distance'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\n\nexport default geo\n","import {FALSE_VALUE, fromArray, fromString, NULL_VALUE, TRUE_VALUE} from '../../values'\nimport {mappedExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst string: FunctionSet = {}\n\nstring['lower'] = mappedExecutor(\n  (args) => args,\n  (_, value) => {\n    if (value.type !== 'string') {\n      return NULL_VALUE\n    }\n\n    return fromString(value.data.toLowerCase())\n  },\n)\nstring['lower'].arity = 1\n\nstring['upper'] = mappedExecutor(\n  (args) => args,\n  (_, value) => {\n    if (value.type !== 'string') {\n      return NULL_VALUE\n    }\n\n    return fromString(value.data.toUpperCase())\n  },\n)\nstring['upper'].arity = 1\n\nstring['split'] = mappedExecutor(\n  (args) => args,\n  (_, str, sep) => {\n    if (str.type !== 'string') {\n      return NULL_VALUE\n    }\n    if (sep.type !== 'string') {\n      return NULL_VALUE\n    }\n\n    if (str.data.length === 0) {\n      return fromArray([])\n    }\n    if (sep.data.length === 0) {\n      // This uses a Unicode codepoint splitting algorithm\n      return fromArray(Array.from(str.data))\n    }\n    return fromArray(str.data.split(sep.data))\n  },\n)\nstring['split'].arity = 2\n\nstring['startsWith'] = mappedExecutor(\n  (args) => args,\n  (_, str, prefix) => {\n    if (str.type !== 'string') {\n      return NULL_VALUE\n    }\n\n    if (prefix.type !== 'string') {\n      return NULL_VALUE\n    }\n\n    return str.data.startsWith(prefix.data) ? TRUE_VALUE : FALSE_VALUE\n  },\n)\nstring['startsWith'].arity = 2\n\nexport default string\n","import {\n  DateTime,\n  FALSE_VALUE,\n  fromNumber,\n  fromPath,\n  fromString,\n  getType,\n  NULL_VALUE,\n  Path,\n  TRUE_VALUE,\n} from '../../values'\nimport {\n  arrayReducerExecutor,\n  constantExecutor,\n  executeAsync,\n  executeSync,\n  mappedExecutor,\n} from '../evaluate'\nimport type {FunctionSet} from '.'\nimport string from './string'\n\n// underscored to not collide with environments like jest that give variables named `global` special treatment\nconst _global: FunctionSet = {}\n\n// eslint-disable-next-line require-await\n// eslint-disable-next-line require-await\n_global['anywhere'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\n\n_global['anywhere'].arity = 1\n\n_global['coalesce'] = {\n  async executeAsync(args, scope) {\n    for (const arg of args) {\n      const value = await executeAsync(arg, scope)\n      if (value.type !== 'null') {\n        return value\n      }\n    }\n    return NULL_VALUE\n  },\n\n  executeSync(args, scope) {\n    for (const arg of args) {\n      const value = executeSync(arg, scope)\n      if (value.type !== 'null') {\n        return value\n      }\n    }\n    return NULL_VALUE\n  },\n}\n\n_global['count'] = arrayReducerExecutor(\n  (args) => ({array: args[0]!}),\n  () => 0,\n  (_, count) => count + 1,\n  fromNumber,\n)\n_global['count'].arity = 1\n\n_global['dateTime'] = mappedExecutor(\n  (args) => args,\n  (_, val) => {\n    if (val.type === 'datetime') {\n      return val\n    }\n    if (val.type !== 'string') {\n      return NULL_VALUE\n    }\n    return DateTime.parseToValue(val.data)\n  },\n)\n_global['dateTime'].arity = 1\n\n_global['defined'] = mappedExecutor(\n  (args) => args,\n  (_, inner) => {\n    return inner.type === 'null' ? FALSE_VALUE : TRUE_VALUE\n  },\n)\n_global['defined'].arity = 1\n\n// eslint-disable-next-line require-await\n_global['identity'] = constantExecutor((_args, scope) => {\n  return fromString(scope.context.identity)\n})\n_global['identity'].arity = 0\n\n_global['length'] = mappedExecutor(\n  (args) => args,\n  (_, inner) => {\n    if (inner.type === 'string') {\n      return fromNumber(countUTF8(inner.data))\n    }\n\n    if (inner.type === 'array') {\n      return fromNumber(inner.data.length)\n    }\n\n    return NULL_VALUE\n  },\n)\n_global['length'].arity = 1\n\n_global['path'] = mappedExecutor(\n  (args) => args,\n  (_, inner) => {\n    if (inner.type !== 'string') {\n      return NULL_VALUE\n    }\n\n    return fromPath(new Path(inner.data))\n  },\n)\n_global['path'].arity = 1\n\n_global['string'] = mappedExecutor(\n  (args) => args,\n  (_, value) => {\n    switch (value.type) {\n      case 'number':\n      case 'string':\n      case 'boolean':\n      case 'datetime':\n        return fromString(`${value.data}`)\n      default:\n        return NULL_VALUE\n    }\n  },\n)\n_global['string'].arity = 1\n\n_global['references'] = mappedExecutor(\n  (args) => [{type: 'This'}, ...args],\n  (_, scopeValue, ...args) => {\n    const pathSet = new Set<string>()\n    for (const path of args) {\n      if (path.type === 'string') {\n        pathSet.add(path.data)\n      } else if (path.type === 'array') {\n        for (const elem of path.data) {\n          if (typeof elem === 'string') {\n            pathSet.add(elem)\n          }\n        }\n      }\n    }\n\n    if (pathSet.size === 0) {\n      return FALSE_VALUE\n    }\n\n    return hasReference(scopeValue, pathSet) ? TRUE_VALUE : FALSE_VALUE\n  },\n)\n_global['references'].arity = (c) => c >= 1\n\n_global['round'] = mappedExecutor(\n  (args) => args,\n  (_, value, precValue) => {\n    if (value.type !== 'number') {\n      return NULL_VALUE\n    }\n\n    const num = value.data\n    let prec = 0\n\n    if (precValue) {\n      if (precValue.type !== 'number' || precValue.data < 0 || !Number.isInteger(precValue.data)) {\n        return NULL_VALUE\n      }\n      prec = precValue.data\n    }\n\n    if (prec === 0) {\n      if (num < 0) {\n        // JavaScript's round() function will always rounds towards positive infinity (-3.5 -> -3).\n        // The behavior we're interested in is to \"round half away from zero\".\n        return fromNumber(-Math.round(-num))\n      }\n      return fromNumber(Math.round(num))\n    }\n    return fromNumber(Number(num.toFixed(prec)))\n  },\n)\n_global['round'].arity = (count) => count >= 1 && count <= 2\n\n// eslint-disable-next-line require-await\n_global['now'] = constantExecutor((_args, scope) => {\n  return fromString(scope.context.timestamp.toISOString())\n})\n_global['now'].arity = 0\n\n// eslint-disable-next-line require-await\n_global['boost'] = constantExecutor(() => {\n  // This should be handled by the scoring function.\n  throw new Error('unexpected boost call')\n})\n\n_global['boost'].arity = 2\n\n_global['lower'] = string['lower']\n_global['upper'] = string['upper']\n\nfunction countUTF8(str: string): number {\n  let count = 0\n  for (let i = 0; i < str.length; i++) {\n    const code = str.charCodeAt(i)\n    if (code >= 0xd800 && code <= 0xdbff) {\n      // High surrogate. Don't count this.\n      // By only counting the low surrogate we will correctly\n      // count the number of UTF-8 code points.\n      continue\n    }\n    count++\n  }\n  return count\n}\n\nfunction hasReference(value: any, pathSet: Set<string>): boolean {\n  switch (getType(value)) {\n    case 'array':\n      for (const v of value) {\n        if (hasReference(v, pathSet)) {\n          return true\n        }\n      }\n      break\n    case 'object':\n      if (value._ref) {\n        return pathSet.has(value._ref)\n      }\n      for (const v of Object.values(value)) {\n        if (hasReference(v, pathSet)) {\n          return true\n        }\n      }\n      break\n    default:\n  }\n  return false\n}\n\nexport default _global\n","import {fromNumber, NULL_VALUE} from '../../values'\nimport {arrayReducerExecutor, STOP_ITERATOR} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst math: FunctionSet = {}\nmath['min'] = arrayReducerExecutor(\n  (args) => ({array: args[0]!}),\n  () => undefined as undefined | number,\n  (_, n, item) => {\n    if (item === null) return n\n    if (typeof item !== 'number') return STOP_ITERATOR\n    if (n === undefined || item < n) return item\n    return n\n  },\n  (n) => (n === undefined ? NULL_VALUE : fromNumber(n)),\n)\nmath['min'].arity = 1\n\nmath['max'] = arrayReducerExecutor(\n  (args) => ({array: args[0]!}),\n  () => undefined as undefined | number,\n  (_, n, item) => {\n    if (item === null) return n\n    if (typeof item !== 'number') return STOP_ITERATOR\n    if (n === undefined || item > n) return item\n    return n\n  },\n  (n) => (n === undefined ? NULL_VALUE : fromNumber(n)),\n)\nmath['max'].arity = 1\n\nmath['sum'] = arrayReducerExecutor(\n  (args) => ({array: args[0]!}),\n  () => 0,\n  (_, n, item) => {\n    if (item === null) return n\n    if (typeof item !== 'number') return STOP_ITERATOR\n    return n + item\n  },\n  fromNumber,\n)\nmath['sum'].arity = 1\n\nmath['avg'] = arrayReducerExecutor(\n  (args) => ({array: args[0]!}),\n  () => ({count: 0, sum: 0}),\n  (_, {count, sum}, item) => {\n    if (item === null) return {count, sum}\n    if (typeof item !== 'number') return STOP_ITERATOR\n    return {count: count + 1, sum: sum + item}\n  },\n  ({count, sum}) => (count === 0 ? NULL_VALUE : fromNumber(sum / count)),\n)\nmath['avg'].arity = 1\n\nexport default math\n","import {constantExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst media: FunctionSet = {}\nmedia['aspect'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\nmedia['aspect'].arity = 2\n\nexport default media\n","import type {AnyStaticValue} from '../values'\n\nexport function portableTextContent(value: AnyStaticValue): string | null {\n  if (value.type === 'object') {\n    return blockText(value.data)\n  } else if (value.type === 'array') {\n    const texts = arrayText(value.data)\n    if (texts.length > 0) {\n      return texts.join('\\n\\n')\n    }\n  }\n\n  return null\n}\n\nfunction arrayText(value: unknown[], result: string[] = []): string[] {\n  for (const block of value) {\n    if (Array.isArray(block)) {\n      arrayText(block, result)\n    } else if (typeof block === 'object' && block) {\n      const text = blockText(block as Record<string, unknown>)\n      if (text !== null) result.push(text)\n    }\n  }\n\n  return result\n}\n\nfunction blockText(obj: Record<string, unknown>): string | null {\n  if (typeof obj['_type'] !== 'string') return null\n  const children = obj['children']\n  if (!Array.isArray(children)) return null\n\n  let result = ''\n  for (const child of children) {\n    if (\n      child &&\n      typeof child === 'object' &&\n      typeof child._type === 'string' &&\n      child._type === 'span' &&\n      typeof child.text === 'string'\n    ) {\n      result += child.text\n    }\n  }\n  return result\n}\n","import {fromString, NULL_VALUE} from '../../values'\nimport {mappedExecutor} from '../evaluate'\nimport {portableTextContent} from '../pt'\nimport type {FunctionSet} from '.'\n\nconst pt: FunctionSet = {}\npt['text'] = mappedExecutor(\n  (args) => args,\n  (_, value) => {\n    const text = portableTextContent(value)\n\n    if (text === null) {\n      return NULL_VALUE\n    }\n\n    return fromString(text)\n  },\n)\n\npt['text'].arity = 1\n\nexport default pt\n","import {arrayExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst releases: FunctionSet = {}\n\n// eslint-disable-next-line require-await\nreleases['all'] = arrayExecutor(\n  () => ({array: {type: 'Everything'}}),\n  function* (_, value) {\n    if (\n      typeof value === 'object' &&\n      value &&\n      '_type' in value &&\n      value._type === 'system.release'\n    ) {\n      yield value\n    }\n  },\n)\nreleases['all'].arity = 0\n\nexport default releases\n","import {FALSE_VALUE, fromString, NULL_VALUE, TRUE_VALUE} from '../../values'\nimport {constantExecutor, mappedExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst sanity: FunctionSet = {}\nsanity['projectId'] = constantExecutor((_, scope) => {\n  if (scope.context.sanity) {\n    return fromString(scope.context.sanity.projectId)\n  }\n\n  return NULL_VALUE\n})\nsanity['dataset'] = constantExecutor((_, scope) => {\n  if (scope.context.sanity) {\n    return fromString(scope.context.sanity.dataset)\n  }\n\n  return NULL_VALUE\n})\n\n// eslint-disable-next-line require-await\nsanity['versionOf'] = mappedExecutor(\n  ([value]) => [value!, {type: 'This'}],\n  (_, value, val) => {\n    if (value.type !== 'string') return NULL_VALUE\n    const baseId = value.data\n\n    if (val.type !== 'object') return NULL_VALUE\n    if (typeof val.data['_id'] !== 'string') return NULL_VALUE\n\n    // published document\n    if (val.data['_id'] === baseId) return TRUE_VALUE\n\n    const components = val.data['_id'].split('.')\n\n    // draft document\n    if (\n      components.length >= 2 &&\n      components[0] === 'drafts' &&\n      components.slice(1).join('.') === baseId\n    ) {\n      return TRUE_VALUE\n    }\n\n    // version document\n    if (\n      components.length >= 3 &&\n      components[0] === 'versions' &&\n      components.slice(2).join('.') === baseId\n    ) {\n      return TRUE_VALUE\n    }\n\n    return FALSE_VALUE\n  },\n)\nsanity['versionOf'].arity = 1\n\n// eslint-disable-next-line require-await\nsanity['partOfRelease'] = mappedExecutor(\n  (args) => [args[0]!, {type: 'This'}],\n  (_, value, val) => {\n    if (value.type !== 'string') return NULL_VALUE\n    const baseId = value.data\n\n    if (val.type !== 'object') return NULL_VALUE\n\n    if (typeof val.data['_id'] !== 'string') return NULL_VALUE\n\n    const components = val.data['_id'].split('.')\n    if (components.length >= 3 && components[0] === 'versions' && components[1] === baseId) {\n      return TRUE_VALUE\n    }\n\n    return FALSE_VALUE\n  },\n)\nsanity['partOfRelease'].arity = 1\n\nexport default sanity\n","import {constantExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\n/**\n * Text query function - no-op implementation.\n *\n * groq-js has no search engine, but we provide this no-op implementation\n * to avoid throwing errors when parsing queries that use text::query().\n */\nconst text: FunctionSet = {}\ntext['query'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\ntext['query'].arity = 1\n\ntext['semanticSimilarity'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\ntext['semanticSimilarity'].arity = 1\n\nexport default text\n","import {constantExecutor} from '../evaluate'\nimport type {FunctionSet} from '.'\n\nconst user: FunctionSet = {}\nuser['attributes'] = constantExecutor(() => {\n  throw new Error('not implemented')\n})\nexport default user\n","import type {ExprNode} from '../nodeTypes'\nimport type {Value} from '../values'\nimport {executeAsync, executeSync} from './evaluate'\nimport {\n  type GatheredText,\n  gatherText,\n  matchPatternRegex,\n  matchTokenize,\n  type Token,\n} from './matching'\nimport {Scope} from './scope'\n\n// BM25 similarity constants\nconst BM25k = 1.2\n\nexport async function evaluateScoreAsync(node: ExprNode, scope: Scope): Promise<number> {\n  if (node.type === 'OpCall' && node.op === 'match') {\n    return evaluateMatchScoreAsync(node.left, node.right, scope)\n  }\n\n  if (node.type === 'FuncCall' && node.name === 'boost') {\n    const innerScore = await evaluateScoreAsync(node.args[0]!, scope)\n    const boost = await executeAsync(node.args[1]!, scope)\n    if (boost.type === 'number' && innerScore > 0) {\n      return innerScore + boost.data\n    }\n\n    return 0\n  }\n\n  switch (node.type) {\n    case 'Or': {\n      const leftScore = await evaluateScoreAsync(node.left, scope)\n      const rightScore = await evaluateScoreAsync(node.right, scope)\n      return leftScore + rightScore\n    }\n    case 'And': {\n      const leftScore = await evaluateScoreAsync(node.left, scope)\n      const rightScore = await evaluateScoreAsync(node.right, scope)\n      if (leftScore === 0 || rightScore === 0) return 0\n      return leftScore + rightScore\n    }\n    default: {\n      const res = await executeAsync(node, scope)\n      return res.type === 'boolean' && res.data === true ? 1 : 0\n    }\n  }\n}\n\nexport function evaluateScoreSync(node: ExprNode, scope: Scope): number {\n  if (node.type === 'OpCall' && node.op === 'match') {\n    return evaluateMatchScoreSync(node.left, node.right, scope)\n  }\n\n  if (node.type === 'FuncCall' && node.name === 'boost') {\n    const innerScore = evaluateScoreSync(node.args[0]!, scope)\n    const boost = executeSync(node.args[1]!, scope)\n    if (boost.type === 'number' && innerScore > 0) {\n      return innerScore + boost.data\n    }\n\n    return 0\n  }\n\n  switch (node.type) {\n    case 'Or': {\n      const leftScore = evaluateScoreSync(node.left, scope)\n      const rightScore = evaluateScoreSync(node.right, scope)\n      return leftScore + rightScore\n    }\n    case 'And': {\n      const leftScore = evaluateScoreSync(node.left, scope)\n      const rightScore = evaluateScoreSync(node.right, scope)\n      if (leftScore === 0 || rightScore === 0) return 0\n      return leftScore + rightScore\n    }\n    default: {\n      const res = executeSync(node, scope)\n      return res.type === 'boolean' && res.data === true ? 1 : 0\n    }\n  }\n}\n\nfunction evaluateMatchScoreSync(left: ExprNode, right: ExprNode, scope: Scope): number {\n  const text = executeSync(left, scope)\n  const pattern = executeSync(right, scope)\n  const result = processMatchScore(text, pattern)\n  if (typeof result === 'number') return result\n  throw new Error('Found synchronous value in match()')\n}\n\nasync function evaluateMatchScoreAsync(\n  left: ExprNode,\n  right: ExprNode,\n  scope: Scope,\n): Promise<number> {\n  const text = await executeAsync(left, scope)\n  const pattern = await executeAsync(right, scope)\n  return processMatchScore(text, pattern)\n}\n\nfunction processMatchScore(text: Value, pattern: Value): Promise<number> | number {\n  const tokens = gatherText(text, (part) => matchTokenize(part))\n  const terms = gatherText(pattern, (part) => matchPatternRegex(part))\n\n  const process = (tokens: GatheredText<Token>, terms: GatheredText<RegExp>): number => {\n    if (!terms.success) return 0\n\n    if (tokens.parts.length === 0 || terms.parts.length === 0) {\n      return 0\n    }\n\n    let score = 0\n\n    for (const re of terms.parts) {\n      const freq = tokens.parts.reduce((c, token) => c + (re.test(token) ? 1 : 0), 0)\n      score += (freq * (BM25k + 1)) / (freq + BM25k)\n    }\n\n    return score\n  }\n\n  if ('then' in tokens || 'then' in terms) {\n    return (async () => process(await tokens, await terms))()\n  }\n\n  return process(tokens, terms)\n}\n","import type {ExprNode} from '../../nodeTypes'\nimport {fromArray, fromJS, getType} from '../../values'\nimport {executeAsync, executeSync} from '../evaluate'\nimport {totalCompare} from '../ordering'\nimport {evaluateScoreAsync, evaluateScoreSync} from '../scoring'\nimport type {GroqPipeFunction, WithOptions} from '.'\n\ntype ObjectWithScore = Record<string, unknown> & {_score: number}\n\ntype Direction = 'asc' | 'desc'\ntype AuxItem = [unknown, number, ...unknown[]]\n\nfunction extractOrderArgs(args: ExprNode[]): {mappers: ExprNode[]; directions: Direction[]} {\n  const mappers = []\n  const directions: Direction[] = []\n\n  for (let mapper of args) {\n    let direction: Direction = 'asc'\n\n    if (mapper.type === 'Desc') {\n      direction = 'desc'\n      mapper = mapper.base\n    } else if (mapper.type === 'Asc') {\n      mapper = mapper.base\n    }\n\n    mappers.push(mapper)\n    directions.push(direction)\n  }\n  return {mappers, directions}\n}\n\nfunction sortArray(aux: AuxItem[], directions: Direction[]): unknown[] {\n  aux.sort((aTuple, bTuple) => {\n    for (let i = 0; i < directions.length; i++) {\n      let c = totalCompare(aTuple[i + 2], bTuple[i + 2])\n      if (directions[i] === 'desc') {\n        c = -c\n      }\n      if (c !== 0) {\n        return c\n      }\n    }\n    // Fallback to sorting on the original index for stable sorting.\n    return aTuple[1] - bTuple[1]\n  })\n\n  return aux.map((v) => v[0])\n}\n\nconst pipeFunctions: {[key: string]: WithOptions<GroqPipeFunction>} = {}\n\npipeFunctions['order'] = {\n  executeSync({base, args}, scope) {\n    const {mappers, directions} = extractOrderArgs(args)\n    const aux: AuxItem[] = []\n\n    let idx = 0\n    const n = directions.length\n\n    for (const value of base.data) {\n      const newScope = scope.createNested(fromJS(value))\n      const tuple: AuxItem = [value, idx]\n      for (let i = 0; i < n; i++) {\n        const result = executeSync(mappers[i]!, newScope)\n        tuple.push(result.data)\n      }\n      aux.push(tuple)\n      idx++\n    }\n\n    return fromArray(sortArray(aux, directions))\n  },\n\n  async executeAsync({base, args}, scope) {\n    const {mappers, directions} = extractOrderArgs(args)\n    const aux: AuxItem[] = []\n\n    let idx = 0\n    const n = directions.length\n\n    for await (const value of base) {\n      const newScope = scope.createNested(value)\n      const tuple: AuxItem = [await value.get(), idx]\n      for (let i = 0; i < n; i++) {\n        const result = await executeAsync(mappers[i]!, newScope)\n        tuple.push(await result.get())\n      }\n      aux.push(tuple)\n      idx++\n    }\n\n    return fromArray(sortArray(aux, directions))\n  },\n}\npipeFunctions['order'].arity = (count) => count >= 1\n\n// eslint-disable-next-line require-await\n// eslint-disable-next-line require-await\npipeFunctions['score'] = {\n  async executeAsync({base, args}, scope) {\n    // Anything that isn't an object should be sorted first.\n    const unknown: Array<any> = []\n    const scored: Array<ObjectWithScore> = []\n\n    for await (const value of base) {\n      if (value.type !== 'object') {\n        unknown.push(await value.get())\n        continue\n      }\n\n      const newScope = scope.createNested(value)\n      let valueScore = typeof value.data['_score'] === 'number' ? value.data['_score'] : 0\n\n      for (const arg of args) {\n        valueScore += await evaluateScoreAsync(arg, newScope)\n      }\n\n      const newObject = Object.assign({}, value.data, {_score: valueScore})\n      scored.push(newObject)\n    }\n\n    scored.sort((a, b) => b._score - a._score)\n    return fromJS(scored)\n  },\n  executeSync({base, args}, scope) {\n    // Anything that isn't an object should be sorted first.\n    const unknown: Array<any> = []\n    const scored: Array<ObjectWithScore> = []\n\n    for (const value of base.data) {\n      if (getType(value) !== 'object') {\n        unknown.push(value)\n        continue\n      }\n\n      const valueObj = value as Record<string, unknown>\n\n      const newScope = scope.createNested(fromJS(value))\n      let valueScore = typeof valueObj['_score'] === 'number' ? valueObj['_score'] : 0\n\n      for (const arg of args) {\n        valueScore += evaluateScoreSync(arg, newScope)\n      }\n\n      const newObject = Object.assign({}, valueObj, {_score: valueScore})\n      scored.push(newObject)\n    }\n\n    scored.sort((a, b) => b._score - a._score)\n    return fromArray(scored)\n  },\n}\npipeFunctions['score'].arity = (count) => count >= 1\n\nexport default pipeFunctions\n","import {type ExprNode} from '../../nodeTypes'\nimport {type ArrayValue, StreamValue} from '../../values'\nimport type {Executor} from '../types'\nimport array from './array'\nimport dateTime from './dateTime'\nimport delta from './delta'\nimport diff from './diff'\nimport documents from './documents'\nimport geo from './geo'\nimport _global from './global'\nimport math from './math'\nimport media from './media'\nimport pt from './pt'\nimport releases from './releases'\nimport sanity from './sanity'\nimport string from './string'\nimport text from './text'\nimport user from './user'\n\nexport {default as pipeFunctions} from './pipeFunctions'\n\n/** @public */\nexport type GroqFunctionArg = ExprNode\n\n/** @internal */\nexport type WithOptions<T> = T & {\n  arity?: GroqFunctionArity\n  mode?: 'normal' | 'delta'\n}\n\nexport type GroqFunctionArity = number | ((count: number) => boolean)\n\n/** @public */\nexport type GroqFunction = Executor<GroqFunctionArg[]>\n\nexport type FunctionSet = Record<string, WithOptions<GroqFunction> | undefined>\n\nexport type NamespaceSet = Record<string, FunctionSet | undefined>\n\nexport type GroqPipeFunction = Executor<\n  {base: ArrayValue | StreamValue; args: ExprNode[]},\n  {base: ArrayValue; args: ExprNode[]}\n>\n\nexport const namespaces: NamespaceSet = {\n  global: _global,\n  string,\n  array,\n  pt,\n  delta,\n  diff,\n  media,\n  sanity,\n  math,\n  dateTime,\n  releases,\n  text,\n  geo,\n  documents,\n  user,\n}\n","import type {CustomFunctions} from './rawParser'\nimport type {ParseOptions} from './types'\n\nexport type MarkName =\n  | 'add'\n  | 'and'\n  | 'arr_expr'\n  | 'array_end'\n  | 'array_splat'\n  | 'array'\n  | 'asc'\n  | 'attr_ident'\n  | 'comp'\n  | 'dblparent'\n  | 'deref_field'\n  | 'deref'\n  | 'desc'\n  | 'div'\n  | 'exc_range'\n  | 'filter'\n  | 'float'\n  | 'func_args_end'\n  | 'func_call'\n  | 'func_decl'\n  | 'ident'\n  | 'inc_range'\n  | 'integer'\n  | 'mod'\n  | 'mul'\n  | 'neg'\n  | 'not'\n  | 'object_end'\n  | 'object_expr'\n  | 'object_pair'\n  | 'object_splat_this'\n  | 'object_splat'\n  | 'object'\n  | 'or'\n  | 'pair'\n  | 'param'\n  | 'paren'\n  | 'parent'\n  | 'pipecall'\n  | 'pos'\n  | 'pow'\n  | 'project'\n  | 'sci'\n  | 'star'\n  | 'str_begin'\n  | 'sub'\n  | 'this'\n\nexport interface Mark {\n  name: string\n  position: number\n}\n\nexport type FunctionId = `${string}::${string}`\n\nexport type MarkVisitor<T> = Record<string, MarkVisitorFunc<T>>\nexport type MarkVisitorFunc<T> = (p: MarkProcessor, mark: Mark) => T\n\nexport class MarkProcessor {\n  private _string: string\n  private marks: Mark[]\n  private index: number\n  customFunctions: CustomFunctions\n  parseOptions: ParseOptions\n  allowBoost = false\n\n  constructor(\n    string: string,\n    marks: Mark[],\n    customFunctions: CustomFunctions,\n    parseOptions: ParseOptions,\n  ) {\n    this._string = string\n    this.marks = marks\n    this.customFunctions = customFunctions\n    this.index = 0\n    this.parseOptions = parseOptions\n  }\n\n  hasMark(pos = 0): boolean {\n    return this.index + pos < this.marks.length\n  }\n\n  getMark(pos = 0): Mark {\n    return this.marks[this.index + pos]\n  }\n\n  shift(): void {\n    this.index += 1\n  }\n\n  process<T>(visitor: MarkVisitor<T>): T {\n    const mark = this.marks[this.index]\n    this.shift()\n    const func = visitor[mark.name]\n    if (!func) {\n      throw new Error(`Unknown handler: ${mark.name}`)\n    }\n    return func.call(visitor, this, mark)\n  }\n\n  processString(): string {\n    this.shift()\n    return this.processStringEnd()\n  }\n\n  processStringEnd(): string {\n    const prev = this.marks[this.index - 1]\n    const curr = this.marks[this.index]\n    this.shift()\n    return this.string.slice(prev.position, curr.position)\n  }\n\n  slice(len: number): string {\n    const pos = this.marks[this.index].position\n    return this.string.slice(pos, pos + len)\n  }\n\n  get string(): string {\n    return this._string\n  }\n}\n","'use strict'\n\nconst WS = /^([\\t\\n\\v\\f\\r \\u0085\\u00A0]|(\\/\\/[^\\n]*\\n))+/\nconst NUM = /^\\d+/\nconst IDENT = /^[a-zA-Z_][a-zA-Z_0-9]*/\n\n// Precedence levels for binary operators:\nconst PREC_PAIR = 1\nconst PREC_OR = 2\nconst PREC_AND = 3\nconst PREC_COMP = 4\nconst PREC_ORDER = 4\nconst PREC_ADD = 6\nconst PREC_SUB = 6\nconst PREC_MUL = 7\nconst PREC_DIV = 7\nconst PREC_MOD = 7\nconst PREC_POW = 8\n\n// Precedence levels for prefix operators:\nconst PREC_POS = 10\nconst PREC_NOT = 10\nconst PREC_NEG = 8\n\nfunction parse(str) {\n  let pos = 0\n  pos = skipWS(str, pos)\n\n  let customFunctions = {}\n\n  // Parse function declarations first\n  while (pos < str.length && str.substring(pos, pos + 2) === 'fn') {\n    let funcResult = parseFunctionDeclaration(str, pos)\n    if (funcResult.type === 'error') return funcResult\n    customFunctions[`${funcResult.namespace}::${funcResult.name}`] = funcResult\n    pos = skipWS(str, funcResult.position)\n  }\n\n  // Parse the main query expression\n  let result = parseExpr(str, pos, 0)\n  if (result.type === 'error') return result\n  pos = skipWS(str, result.position)\n\n  if (pos !== str.length) {\n    if (result.failPosition) {\n      pos = result.failPosition - 1\n    }\n    return {type: 'error', message: 'Unexpected end of query', position: pos}\n  }\n  delete result.position\n  delete result.failPosition\n  result.customFunctions = customFunctions\n  return result\n}\n\nfunction parseExpr(str, pos, level) {\n  // In this function we parse precedence \"manually\" by having two variables:\n  //\n  // `level` is the minimum precedence level we want to parse at. If this is\n  // e.g. 7 then this function will not parse `3 + 4` (since addition is at 6),\n  // but instead just return `1` and leave ` + 5` remaining. We use this so that\n  // while handling the RHS of the multiplication in `1 + 2 * 3 + 4` we only parse `3`.\n  //\n  // `lhsLevel` is the precedence level of the currently parsed expression on\n  // the left-hand side. This is mainly used to handle non-associativeness.\n\n  // This means that you'll see code like:\n  // - `if (level > PREC_XXX) break`: Operator is at this precedence level.\n  // - `if (lhsLevel < PREC_XXX) break`: Operator is left-associative.\n  // - `if (lhsLevel <= PREC_XXX) break`: Operator is right/non-associative.\n  // - `parseExpr(str, pos, PREC_XXX + 1)`: Operator is left/non-assoicate.\n  // - `parseExpr(str, pos, PREC_XXX)`: Operator is right-assoicate.\n\n  let startPos = pos\n  let token = str[pos]\n  let marks\n\n  switch (token) {\n    case '+': {\n      let rhs = parseExpr(str, skipWS(str, pos + 1), PREC_POS)\n      if (rhs.type === 'error') return rhs\n      marks = [{name: 'pos', position: startPos}].concat(rhs.marks)\n      pos = rhs.position\n      break\n    }\n    case '-': {\n      let rhs = parseExpr(str, skipWS(str, pos + 1), PREC_NEG)\n      if (rhs.type === 'error') return rhs\n      marks = [{name: 'neg', position: startPos}].concat(rhs.marks)\n      pos = rhs.position\n      break\n    }\n    case '(': {\n      let result = parseGroupOrTuple(str, pos)\n      if (result.type === 'error') return result\n\n      pos = result.position\n      marks = result.marks\n\n      break\n    }\n    case '!': {\n      let rhs = parseExpr(str, skipWS(str, pos + 1), PREC_NOT)\n      if (rhs.type === 'error') return rhs\n      marks = [{name: 'not', position: startPos}].concat(rhs.marks)\n      pos = rhs.position\n      break\n    }\n    case '{': {\n      let result = parseObject(str, pos)\n      if (result.type === 'error') return result\n      marks = result.marks\n      pos = result.position\n      break\n    }\n    case '[':\n      marks = [{name: 'array', position: pos}]\n      pos = skipWS(str, pos + 1)\n\n      if (str[pos] !== ']') {\n        while (true) {\n          if (str.slice(pos, pos + 3) === '...') {\n            marks.push({name: 'array_splat', position: pos})\n            pos = skipWS(str, pos + 3)\n          }\n\n          let res = parseExpr(str, pos, 0)\n          if (res.type === 'error') return res\n          marks = marks.concat(res.marks)\n          pos = res.position\n          pos = skipWS(str, pos)\n          if (str[pos] !== ',') break\n          pos = skipWS(str, pos + 1)\n          if (str[pos] === ']') break\n        }\n      }\n\n      if (str[pos] === ']') {\n        pos++\n        marks.push({name: 'array_end', position: pos})\n      } else {\n        return {type: 'error', message: 'Expected \"]\" after array expression', position: pos}\n      }\n\n      break\n    case \"'\":\n    case '\"': {\n      let result = parseString(str, pos)\n      if (result.type === 'error') return result\n      marks = result.marks\n      pos = result.position\n      break\n    }\n    case '^': {\n      pos++\n      marks = []\n      while (str[pos] === '.' && str[pos + 1] === '^') {\n        marks.push({name: 'dblparent', position: startPos})\n        pos += 2\n      }\n      marks.push({name: 'parent', position: startPos})\n      break\n    }\n    case '@':\n      marks = [{name: 'this', position: startPos}]\n      pos++\n      break\n    case '*':\n      marks = [{name: 'everything', position: startPos}]\n      pos++\n      break\n    case '$': {\n      let identLen = parseRegex(str, pos + 1, IDENT)\n      if (identLen) {\n        pos += 1 + identLen\n        marks = [\n          {name: 'param', position: startPos},\n          {name: 'ident', position: startPos + 1},\n          {name: 'ident_end', position: pos},\n        ]\n      }\n      break\n    }\n    default: {\n      let numLen = parseRegex(str, pos, NUM)\n      if (numLen) {\n        pos += numLen\n        let name = 'integer'\n\n        if (str[pos] === '.') {\n          let fracLen = parseRegex(str, pos + 1, NUM)\n          if (fracLen) {\n            name = 'float'\n            pos += 1 + fracLen\n          }\n        }\n\n        if (str[pos] === 'e' || str[pos] === 'E') {\n          name = 'sci'\n          pos++\n          if (str[pos] === '+' || str[pos] === '-') {\n            pos++\n          }\n          let expLen = parseRegex(str, pos, NUM)\n          if (!expLen) return {type: 'error', message: 'Exponent must be a number', position: pos}\n          pos += expLen\n        }\n\n        marks = [\n          {name, position: startPos},\n          {name: name + '_end', position: pos},\n        ]\n\n        break\n      }\n\n      let identLen = parseRegex(str, pos, IDENT)\n      if (identLen) {\n        pos += identLen\n        switch (str[pos]) {\n          case ':':\n          case '(': {\n            let result = parseFuncCall(str, startPos, pos)\n            if (result.type === 'error') return result\n            marks = result.marks\n            pos = result.position\n            break\n          }\n          default: {\n            marks = [\n              {name: 'this_attr', position: startPos},\n              {name: 'ident', position: startPos},\n              {name: 'ident_end', position: pos},\n            ]\n          }\n        }\n\n        break\n      }\n    }\n  }\n\n  if (!marks) {\n    return {type: 'error', message: 'Expected expression', position: pos}\n  }\n\n  let lhsLevel = 12\n  let trav\n\n  loop: while (true) {\n    let innerPos = skipWS(str, pos)\n    if (innerPos === str.length) {\n      pos = innerPos\n      break\n    }\n\n    trav = parseTraversal(str, innerPos)\n    if (trav.type === 'success') {\n      marks.unshift({name: 'traverse', position: startPos})\n      while (trav.type === 'success') {\n        marks = marks.concat(trav.marks)\n        pos = trav.position\n        trav = parseTraversal(str, skipWS(str, pos))\n      }\n      marks.push({name: 'traversal_end', position: pos})\n      continue\n    } // ignore if type === 'error'\n\n    let token = str[innerPos]\n    switch (token) {\n      case '=': {\n        let nextToken = str[innerPos + 1]\n        switch (nextToken) {\n          case '>': {\n            // =>\n            if (level > PREC_PAIR || lhsLevel <= PREC_PAIR) break loop\n            let rhs = parseExpr(str, skipWS(str, innerPos + 2), PREC_PAIR)\n            if (rhs.type === 'error') return rhs\n            marks = marks.concat(rhs.marks)\n            marks.unshift({name: 'pair', position: startPos})\n            pos = rhs.position\n            lhsLevel = PREC_PAIR\n            break\n          }\n          case '=': {\n            // ==\n            if (level > PREC_COMP || lhsLevel <= PREC_COMP) break loop\n            let rhs = parseExpr(str, skipWS(str, innerPos + 2), PREC_COMP + 1)\n            if (rhs.type === 'error') return rhs\n            marks.unshift({name: 'comp', position: startPos})\n            marks.push({name: 'op', position: innerPos}, {name: 'op_end', position: innerPos + 2})\n            marks = marks.concat(rhs.marks)\n            pos = rhs.position\n            lhsLevel = PREC_COMP\n            break\n          }\n          default:\n            break loop\n        }\n        break\n      }\n      case '+': {\n        if (level > PREC_ADD || lhsLevel < PREC_ADD) break loop\n        let rhs = parseExpr(str, skipWS(str, innerPos + 1), PREC_ADD + 1)\n        if (rhs.type === 'error') return rhs\n        marks = marks.concat(rhs.marks)\n        marks.unshift({name: 'add', position: startPos})\n        pos = rhs.position\n        lhsLevel = PREC_ADD\n        break\n      }\n      case '-': {\n        if (level > PREC_SUB || lhsLevel < PREC_SUB) break loop\n        let rhs = parseExpr(str, skipWS(str, innerPos + 1), PREC_SUB + 1)\n        if (rhs.type === 'error') return rhs\n        marks = marks.concat(rhs.marks)\n        marks.unshift({name: 'sub', position: startPos})\n        pos = rhs.position\n        lhsLevel = PREC_SUB\n        break\n      }\n      case '*': {\n        if (str[innerPos + 1] === '*') {\n          // **\n          if (level > PREC_POW || lhsLevel <= PREC_POW) break loop\n          let rhs = parseExpr(str, skipWS(str, innerPos + 2), PREC_POW)\n          if (rhs.type === 'error') return rhs\n          marks = marks.concat(rhs.marks)\n          marks.unshift({name: 'pow', position: startPos})\n          pos = rhs.position\n          lhsLevel = PREC_POW\n          break\n        }\n\n        // *\n        if (level > PREC_MUL || lhsLevel < PREC_MUL) break loop\n        let rhs = parseExpr(str, skipWS(str, innerPos + 1), PREC_MUL + 1)\n        if (rhs.type === 'error') return rhs\n        marks = marks.concat(rhs.marks)\n        marks.unshift({name: 'mul', position: startPos})\n        pos = rhs.position\n        lhsLevel = PREC_MUL\n        break\n      }\n      case '/': {\n        if (level > PREC_DIV || lhsLevel < PREC_DIV) break loop\n        let rhs = parseExpr(str, skipWS(str, innerPos + 1), PREC_DIV + 1)\n        if (rhs.type === 'error') return rhs\n        marks = marks.concat(rhs.marks)\n        marks.unshift({name: 'div', position: startPos})\n        pos = rhs.position\n        lhsLevel = PREC_DIV\n        break\n      }\n      case '%': {\n        if (level > PREC_MOD || lhsLevel < PREC_MOD) break loop\n        let rhs = parseExpr(str, skipWS(str, innerPos + 1), PREC_MOD + 1)\n        if (rhs.type === 'error') return rhs\n        marks = marks.concat(rhs.marks)\n        marks.unshift({name: 'mod', position: startPos})\n        pos = rhs.position\n        lhsLevel = PREC_MOD\n        break\n      }\n      case '<':\n      case '>': {\n        if (level > PREC_COMP || lhsLevel <= PREC_COMP) break loop\n        let nextPos = innerPos + 1\n        if (str[nextPos] === '=') {\n          nextPos++\n        }\n        let rhs = parseExpr(str, skipWS(str, nextPos), PREC_COMP + 1)\n        if (rhs.type === 'error') return rhs\n        marks.unshift({name: 'comp', position: startPos})\n        marks.push({name: 'op', position: innerPos}, {name: 'op_end', position: nextPos})\n        marks = marks.concat(rhs.marks)\n        pos = rhs.position\n        lhsLevel = PREC_COMP\n        break\n      }\n      case '|': {\n        if (str[innerPos + 1] === '|') {\n          // ||\n          if (level > PREC_OR || lhsLevel < PREC_OR) break loop\n          let rhs = parseExpr(str, skipWS(str, innerPos + 2), PREC_OR + 1)\n          if (rhs.type === 'error') return rhs\n          marks = marks.concat(rhs.marks)\n          marks.unshift({name: 'or', position: startPos})\n          pos = rhs.position\n          lhsLevel = PREC_OR\n        } else {\n          if (level > 11 || lhsLevel < 11) break loop\n          // pipe call\n          let identPos = skipWS(str, innerPos + 1)\n          let identLen = parseRegex(str, identPos, IDENT)\n          if (!identLen) return {type: 'error', message: 'Expected identifier', position: identPos}\n          pos = identPos + identLen\n          if (str[pos] === '(' || str[pos] === ':') {\n            let result = parseFuncCall(str, identPos, pos)\n            if (result.type === 'error') return result\n            marks = marks.concat(result.marks)\n            marks.unshift({name: 'pipecall', position: startPos})\n            pos = result.position\n            lhsLevel = 11\n          }\n        }\n        break\n      }\n      case '&': {\n        // &&\n        if (str[innerPos + 1] != '&') break loop\n        if (level > PREC_AND || lhsLevel < PREC_AND) break loop\n        let rhs = parseExpr(str, skipWS(str, innerPos + 2), PREC_AND + 1)\n        if (rhs.type === 'error') return rhs\n        marks = marks.concat(rhs.marks)\n        marks.unshift({name: 'and', position: startPos})\n        pos = rhs.position\n        lhsLevel = PREC_AND\n        break\n      }\n      case '!': {\n        // !=\n        if (str[innerPos + 1] !== '=') break loop\n        if (level > PREC_COMP || lhsLevel <= PREC_COMP) break loop\n        let rhs = parseExpr(str, skipWS(str, innerPos + 2), PREC_COMP + 1)\n        if (rhs.type === 'error') return rhs\n        marks.unshift({name: 'comp', position: startPos})\n        marks.push({name: 'op', position: innerPos}, {name: 'op_end', position: innerPos + 2})\n        marks = marks.concat(rhs.marks)\n        pos = rhs.position\n        lhsLevel = PREC_COMP\n        break\n      }\n      case 'd': {\n        // desc\n        if (str.slice(innerPos, innerPos + 4) !== 'desc') break loop\n        if (level > PREC_ORDER || lhsLevel < PREC_ORDER) break loop\n        marks.unshift({name: 'desc', position: startPos})\n        pos = innerPos + 4\n        lhsLevel = PREC_ORDER\n        break\n      }\n      case 'a': {\n        // asc\n        if (str.slice(innerPos, innerPos + 3) !== 'asc') break loop\n        if (level > PREC_ORDER || lhsLevel < PREC_ORDER) break loop\n        marks.unshift({name: 'asc', position: startPos})\n        pos = innerPos + 3\n        lhsLevel = PREC_ORDER\n        break\n      }\n      default: {\n        let ident = parseRegexStr(str, innerPos, IDENT)\n        switch (ident) {\n          case 'in': {\n            if (level > PREC_COMP || lhsLevel <= PREC_COMP) break loop\n\n            pos = skipWS(str, innerPos + 2)\n\n            let isGroup = false\n\n            if (str[pos] === '(') {\n              isGroup = true\n              pos = skipWS(str, pos + 1)\n            }\n\n            let rangePos = pos\n            let result = parseExpr(str, pos, PREC_COMP + 1)\n            if (result.type === 'error') return result\n\n            pos = skipWS(str, result.position)\n\n            if (str[pos] === '.' && str[pos + 1] === '.') {\n              // LHS in RANGE\n              let type = 'inc_range'\n              if (str[pos + 2] === '.') {\n                type = 'exc_range'\n                pos = skipWS(str, pos + 3)\n              } else {\n                pos = skipWS(str, pos + 2)\n              }\n\n              let rhs = parseExpr(str, pos, PREC_COMP + 1)\n              if (rhs.type === 'error') return rhs\n              marks.unshift({name: 'in_range', position: startPos})\n              marks = marks.concat({name: type, position: rangePos}, result.marks, rhs.marks)\n              pos = rhs.position\n            } else {\n              // LHS in RHS\n              marks.unshift({name: 'comp', position: startPos})\n              marks.push({name: 'op', position: innerPos}, {name: 'op_end', position: innerPos + 2})\n              marks = marks.concat(result.marks)\n            }\n\n            if (isGroup) {\n              pos = skipWS(str, pos)\n              if (str[pos] !== ')')\n                return {type: 'error', message: 'Expected \")\" in group', position: pos}\n              pos++\n            }\n\n            lhsLevel = PREC_COMP\n            break\n          }\n          case 'match': {\n            // match operator\n            if (level > PREC_COMP || lhsLevel <= PREC_COMP) break loop\n            let rhs = parseExpr(str, skipWS(str, innerPos + 5), PREC_COMP + 1)\n            if (rhs.type === 'error') return rhs\n            marks.unshift({name: 'comp', position: startPos})\n            marks.push({name: 'op', position: innerPos}, {name: 'op_end', position: innerPos + 5})\n            marks = marks.concat(rhs.marks)\n            pos = rhs.position\n            lhsLevel = 4\n            break\n          }\n          default: {\n            break loop\n          }\n        }\n      }\n    }\n  }\n\n  let failPosition = trav?.type === 'error' && trav.position\n\n  return {type: 'success', marks, position: pos, failPosition}\n}\n\nfunction parseGroupOrTuple(str, pos) {\n  const startPos = pos\n  let marks\n  let rhs = parseExpr(str, skipWS(str, pos + 1), 0)\n  if (rhs.type === 'error') return rhs\n  pos = skipWS(str, rhs.position)\n  switch (str[pos]) {\n    case ',': {\n      // Tuples\n      marks = [{name: 'tuple', position: startPos}].concat(rhs.marks)\n      pos = skipWS(str, pos + 1)\n      while (true) {\n        rhs = parseExpr(str, pos, 0)\n        if (rhs.type === 'error') return rhs\n        marks.push(...rhs.marks)\n        pos = skipWS(str, rhs.position)\n        if (str[pos] !== ',') break\n        pos = skipWS(str, pos + 1)\n      }\n      if (str[pos] !== ')')\n        return {type: 'error', message: 'Expected \")\" after tuple expression', position: pos}\n      pos++\n      marks.push({name: 'tuple_end', position: pos})\n      break\n    }\n    case ')': {\n      pos++\n      marks = [{name: 'group', position: startPos}].concat(rhs.marks)\n      break\n    }\n    default:\n      return {type: 'error', message: `Unexpected character \"${str[pos]}\"`, position: pos}\n  }\n\n  return {type: 'success', marks, position: pos}\n}\n\nfunction parseTraversal(str, pos) {\n  let startPos = pos\n  switch (str[pos]) {\n    case '.': {\n      pos = skipWS(str, pos + 1)\n\n      // allow tuples/groups in a traversal for selectors\n      if (str[pos] === '(') {\n        return parseGroupOrTuple(str, pos)\n      }\n\n      let identStart = pos\n      let identLen = parseRegex(str, pos, IDENT)\n      if (!identLen) return {type: 'error', message: 'Expected identifier after \".\"', position: pos}\n      pos += identLen\n\n      return {\n        type: 'success',\n        marks: [\n          {name: 'attr_access', position: startPos},\n          {name: 'ident', position: identStart},\n          {name: 'ident_end', position: pos},\n        ],\n        position: pos,\n      }\n    }\n    case '-':\n      if (str[pos + 1] !== '>')\n        return {type: 'error', message: 'Expected \">\" in reference', position: pos}\n      // ->\n\n      let marks = [{name: 'deref', position: startPos}]\n      pos += 2\n\n      let identPos = skipWS(str, pos)\n      let identLen = parseRegex(str, identPos, IDENT)\n      if (identLen) {\n        pos = identPos + identLen\n        marks.push(\n          {name: 'deref_attr', position: identPos},\n          {name: 'ident', position: identPos},\n          {name: 'ident_end', position: pos},\n        )\n      }\n\n      return {\n        type: 'success',\n        marks,\n        position: pos,\n      }\n    case '[': {\n      pos = skipWS(str, pos + 1)\n\n      if (str[pos] === ']') {\n        return {\n          type: 'success',\n          marks: [{name: 'array_postfix', position: startPos}],\n          position: pos + 1,\n        }\n      }\n\n      let rangePos = pos\n      let result = parseExpr(str, pos, 0)\n      if (result.type === 'error') return result\n\n      pos = skipWS(str, result.position)\n\n      if (str[pos] === '.' && str[pos + 1] === '.') {\n        let type = 'inc_range'\n        if (str[pos + 2] === '.') {\n          type = 'exc_range'\n          pos += 3\n        } else {\n          pos += 2\n        }\n\n        pos = skipWS(str, pos)\n        let rhs = parseExpr(str, pos, 0)\n        if (rhs.type === 'error') return rhs\n        pos = skipWS(str, rhs.position)\n        if (str[pos] !== ']')\n          return {type: 'error', message: 'Expected \"]\" after array expression', position: pos}\n\n        return {\n          type: 'success',\n          marks: [\n            {name: 'slice', position: startPos},\n            {name: type, position: rangePos},\n          ].concat(result.marks, rhs.marks),\n          position: pos + 1,\n        }\n      }\n\n      if (str[pos] !== ']')\n        return {type: 'error', message: 'Expected \"]\" after array expression', position: pos}\n\n      return {\n        type: 'success',\n        marks: [{name: 'square_bracket', position: startPos}].concat(result.marks),\n        position: pos + 1,\n      }\n    }\n    case '|': {\n      pos = skipWS(str, pos + 1)\n      if (str[pos] === '{') {\n        let result = parseObject(str, pos)\n        if (result.type === 'error') return result\n        result.marks.unshift({name: 'projection', position: startPos})\n        return result\n      }\n      break\n    }\n    case '{': {\n      let result = parseObject(str, pos)\n      if (result.type === 'error') return result\n      result.marks.unshift({name: 'projection', position: startPos})\n      return result\n    }\n  }\n\n  return {type: 'error', message: 'Unexpected character in traversal', position: pos}\n}\n\nfunction parseFuncCall(str, startPos, pos) {\n  let marks = []\n\n  marks.push({name: 'func_call', position: startPos})\n\n  if (str[pos] === ':' && str[pos + 1] === ':') {\n    marks.push({name: 'namespace', position: startPos})\n    marks.push({name: 'ident', position: startPos}, {name: 'ident_end', position: pos})\n    pos = skipWS(str, pos + 2)\n    let nameLen = parseRegex(str, pos, IDENT)\n    if (!nameLen) return {type: 'error', message: 'Expected function name', position: pos}\n    marks.push({name: 'ident', position: pos}, {name: 'ident_end', position: pos + nameLen})\n    pos = skipWS(str, pos + nameLen)\n    if (str[pos] !== '(')\n      return {type: 'error', message: 'Expected \"(\" after function name', position: pos}\n    pos++\n    // Consume any whitespace in front of the function argument.\n    pos = skipWS(str, pos)\n  } else {\n    marks.push({name: 'ident', position: startPos}, {name: 'ident_end', position: pos})\n    pos = skipWS(str, pos + 1)\n  }\n\n  let lastPos = pos\n\n  if (str[pos] !== ')') {\n    while (true) {\n      let result = parseExpr(str, pos, 0)\n      if (result.type === 'error') return result\n      marks = marks.concat(result.marks)\n      lastPos = result.position\n      pos = skipWS(str, result.position)\n\n      if (str[pos] !== ',') break\n      pos = skipWS(str, pos + 1)\n      // Also allow trailing commas\n      if (str[pos] === ')') break\n    }\n  }\n\n  if (str[pos] !== ')') {\n    return {type: 'error', message: 'Expected \")\" after function arguments', position: pos}\n  }\n\n  // NOTE: a bit arbitrary the func_args_end points comes before the whitespace.\n  marks.push({name: 'func_args_end', position: lastPos})\n\n  return {\n    type: 'success',\n    marks,\n    position: pos + 1,\n  }\n}\n\nfunction parseObject(str, pos) {\n  let marks = [{name: 'object', position: pos}]\n  pos = skipWS(str, pos + 1)\n\n  loop: while (str[pos] !== '}') {\n    let pairPos = pos\n\n    if (str.slice(pos, pos + 3) === '...') {\n      pos = skipWS(str, pos + 3)\n      if (str[pos] !== '}' && str[pos] !== ',') {\n        let expr = parseExpr(str, pos, 0)\n        if (expr.type === 'error') return expr\n        marks.push({name: 'object_splat', position: pairPos})\n        marks = marks.concat(expr.marks)\n        pos = expr.position\n      } else {\n        marks.push({name: 'object_splat_this', position: pairPos})\n      }\n    } else {\n      let expr = parseExpr(str, pos, 0)\n      if (expr.type === 'error') return expr\n      let nextPos = skipWS(str, expr.position)\n      if (expr.marks[0].name === 'str' && str[nextPos] === ':') {\n        let value = parseExpr(str, skipWS(str, nextPos + 1), 0)\n        if (value.type === 'error') return value\n        marks.push({name: 'object_pair', position: pairPos})\n        marks = marks.concat(expr.marks, value.marks)\n        pos = value.position\n      } else {\n        marks = marks.concat({name: 'object_expr', position: pos}, expr.marks)\n        pos = expr.position\n      }\n    }\n    pos = skipWS(str, pos)\n    if (str[pos] !== ',') break\n    pos = skipWS(str, pos + 1)\n  }\n\n  if (str[pos] !== '}') {\n    return {type: 'error', message: 'Expected \"}\" after object', position: pos}\n  }\n\n  pos++\n  marks.push({name: 'object_end', position: pos})\n  return {type: 'success', marks, position: pos}\n}\n\nfunction parseString(str, pos) {\n  let token = str[pos]\n  pos = pos + 1\n  const marks = [{name: 'str', position: pos}]\n  str: for (; ; pos++) {\n    if (pos > str.length) return {type: 'error', message: 'Unexpected end of query', position: pos}\n\n    switch (str[pos]) {\n      case token: {\n        marks.push({name: 'str_end', position: pos})\n        pos++\n        break str\n      }\n      case '\\\\': {\n        marks.push({name: 'str_pause', position: pos})\n        if (str[pos + 1] === 'u') {\n          if (str[pos + 2] === '{') {\n            marks.push({name: 'unicode_hex', position: pos + 3})\n            pos = str.indexOf('}', pos + 3)\n            marks.push({name: 'unicode_hex_end', position: pos})\n          } else {\n            marks.push({name: 'unicode_hex', position: pos + 2})\n            marks.push({name: 'unicode_hex_end', position: pos + 6})\n            pos += 5\n          }\n        } else {\n          marks.push({name: 'single_escape', position: pos + 1})\n          pos += 1\n        }\n        marks.push({name: 'str_start', position: pos + 1})\n      }\n    }\n  }\n\n  return {type: 'success', marks, position: pos}\n}\n\nfunction skipWS(str, pos) {\n  return pos + parseRegex(str, pos, WS)\n}\n\n/**\n * Parses a regex at a position and returns the number of characters that was matched.\n */\nfunction parseRegex(str, pos, re) {\n  let m = re.exec(str.slice(pos))\n  return m ? m[0].length : 0\n}\n\n/**\n * Parses a regex at a position and returns matched string.\n */\nfunction parseRegexStr(str, pos, re) {\n  let m = re.exec(str.slice(pos))\n  return m ? m[0] : null\n}\n\n/**\n * Parses a function declaration: fn namespace::name(params) = body;\n */\nfunction parseFunctionDeclaration(str, startPos) {\n  let pos = startPos\n  let marks = []\n  let namespace = ''\n  let name = ''\n\n  // Parse \"fn\"\n  if (str.substring(pos, pos + 2) !== 'fn') {\n    return {\n      type: 'success',\n      position: pos,\n      marks: marks,\n    }\n  }\n  marks.push({name: 'func_decl', position: startPos})\n\n  pos = skipWS(str, pos + 2)\n\n  let identStart = pos\n  namespace = parseRegexStr(str, pos, IDENT)\n  if (!namespace) {\n    return {type: 'error', message: 'Expected function name', position: pos}\n  }\n  marks.push(\n    {name: 'ident', position: identStart},\n    {name: 'ident_end', position: pos + namespace.length},\n  )\n  pos = skipWS(str, pos + namespace.length)\n\n  // Check for \"::\"\n  if (str.substring(pos, pos + 2) !== '::') {\n    return {type: 'error', message: 'Expected \"::\" after namespace', position: pos}\n  }\n\n  pos = skipWS(str, pos + 2)\n  name = parseRegexStr(str, pos, IDENT)\n  if (!name) {\n    return {type: 'error', message: 'Expected function name', position: pos}\n  }\n  marks.push({name: 'ident', position: pos}, {name: 'ident_end', position: pos + name.length})\n  pos = skipWS(str, pos + name.length)\n\n  if (str[pos] !== '(') {\n    return {type: 'error', message: 'Expected \"(\"', position: pos}\n  }\n  pos = skipWS(str, pos + 1)\n\n  // Parse parameters\n  while (pos < str.length && str[pos] !== ')') {\n    // Parse parameter (should start with $)\n    if (str[pos] !== '$') {\n      return {type: 'error', message: 'Parameter should start with \"$\"', position: pos}\n    }\n    const startPos = pos\n    pos++\n\n    const paramName = parseRegexStr(str, pos, IDENT)\n    if (!paramName) {\n      return {type: 'error', message: 'Expected function name', position: pos}\n    }\n    pos += paramName.length\n    marks.push(\n      {name: 'param', position: startPos},\n      {name: 'ident', position: startPos + 1},\n      {name: 'ident_end', position: pos},\n    )\n    pos = skipWS(str, pos)\n\n    // Check for comma\n    if (str[pos] === ',') {\n      pos = skipWS(str, pos + 1)\n    } else if (str[pos] !== ')') {\n      return {type: 'error', message: 'Expected \",\" or \")\"', position: pos}\n    }\n  }\n\n  if (str[pos] !== ')') {\n    return {type: 'error', message: 'Expected \")\"', position: pos}\n  }\n  marks.push({name: 'func_params_end', position: pos})\n  pos = skipWS(str, pos + 1)\n\n  if (str[pos] !== '=') {\n    return {type: 'error', message: 'Expected \"=\"', position: pos}\n  }\n  pos = skipWS(str, pos + 1)\n\n  // Parse function body (expression)\n  let bodyResult = parseExpr(str, pos, 0)\n  if (bodyResult.type === 'error') return bodyResult\n  marks = marks.concat(bodyResult.marks)\n  pos = skipWS(str, bodyResult.position)\n\n  // Parse \";\"\n  if (str[pos] !== ';') {\n    return {type: 'error', message: 'Expected \";\" after function declaration', position: pos}\n  }\n  pos++\n\n  return {\n    type: 'success',\n    position: pos,\n    marks: marks,\n    namespace,\n    name,\n  }\n}\n\nexport {parse}\n","/* eslint-disable camelcase */\nimport type {ExprNode} from './nodeTypes'\n\nexport type Traversal = (base: ExprNode) => ExprNode\n\n/**\n * Join combines two traversals, returning a mapper which is the result of first\n * applying `a` and then applying `b`.\n */\nfunction join(a: Traversal, b: Traversal): Traversal {\n  return (base: ExprNode) => b(a(base))\n}\n\n/**\n * Map returns a new mapper which will the inner mappe to each element of the array.\n */\nfunction map(inner: Traversal): Traversal {\n  return (base: ExprNode) => ({type: 'Map', base, expr: inner({type: 'This'})})\n}\n\nfunction flatMap(inner: Traversal): Traversal {\n  return (base: ExprNode) => ({type: 'FlatMap', base, expr: inner({type: 'This'})})\n}\n\nexport type TraversalResult = {\n  type: 'a-a' | 'a-b' | 'b-a' | 'b-b'\n  build: Traversal\n}\n\nexport function traverseArray(build: Traversal, right: TraversalResult | null): TraversalResult {\n  if (!right) {\n    return {\n      type: 'a-a',\n      build: build,\n    }\n  }\n\n  switch (right.type) {\n    case 'a-a':\n      return {\n        type: 'a-a',\n        build: join(build, right.build),\n      }\n\n    case 'a-b':\n      return {\n        type: 'a-b',\n        build: join(build, right.build),\n      }\n\n    case 'b-b':\n      return {\n        type: 'a-a',\n        build: join(build, map(right.build)),\n      }\n\n    case 'b-a':\n      return {\n        type: 'a-a',\n        build: join(build, flatMap(right.build)),\n      }\n\n    default:\n      throw new Error(`unknown type: ${right.type}`)\n  }\n}\n\nexport function traversePlain(mapper: Traversal, right: TraversalResult | null): TraversalResult {\n  if (!right) {\n    return {\n      type: 'b-b',\n      build: mapper,\n    }\n  }\n\n  switch (right.type) {\n    case 'a-a':\n    case 'b-a':\n      return {\n        type: 'b-a',\n        build: join(mapper, right.build),\n      }\n\n    case 'a-b':\n    case 'b-b':\n      return {\n        type: 'b-b',\n        build: join(mapper, right.build),\n      }\n\n    default:\n      throw new Error(`unknown type: ${right.type}`)\n  }\n}\n\nexport function traverseElement(mapper: Traversal, right: TraversalResult | null): TraversalResult {\n  if (!right) {\n    return {\n      type: 'a-b',\n      build: mapper,\n    }\n  }\n\n  switch (right.type) {\n    case 'a-a':\n    case 'b-a':\n      return {\n        type: 'a-a',\n        build: join(mapper, right.build),\n      }\n\n    case 'a-b':\n    case 'b-b':\n      return {\n        type: 'a-b',\n        build: join(mapper, right.build),\n      }\n\n    default:\n      throw new Error(`unknown type: ${right.type}`)\n  }\n}\n\nexport function traverseProjection(\n  mapper: Traversal,\n  right: TraversalResult | null,\n): TraversalResult {\n  if (!right) {\n    return {\n      type: 'b-b',\n      build: mapper,\n    }\n  }\n\n  switch (right.type) {\n    case 'a-a':\n      return {\n        type: 'a-a',\n        build: join(map(mapper), right.build),\n      }\n    case 'a-b':\n      return {\n        type: 'a-b',\n        build: join(map(mapper), right.build),\n      }\n    case 'b-a':\n      return {\n        type: 'b-a',\n        build: join(mapper, right.build),\n      }\n    case 'b-b':\n      return {\n        type: 'b-b',\n        build: join(mapper, right.build),\n      }\n    default:\n      throw new Error(`unknown type: ${right.type}`)\n  }\n}\n","import {type ExprNode, type SelectorNode} from './nodeTypes'\n\n// eslint-disable-next-line complexity\nexport function walkValidateCustomFunction<T extends ExprNode | SelectorNode>(\n  node: T,\n  level: number = 0,\n): T {\n  switch (node.type) {\n    case 'Projection': {\n      return {\n        ...node,\n        base: walkValidateCustomFunction(node.base, level),\n        expr: walkValidateCustomFunction(node.expr, level + 1),\n      }\n    }\n    case 'Filter': {\n      return {\n        ...node,\n        base: walkValidateCustomFunction(node.base, level),\n        expr: walkValidateCustomFunction(node.expr, level + 1),\n      }\n    }\n    case 'Parent': {\n      if (level - node.n < 0) {\n        throw new Error(\n          `Invalid use of parent operator (^). No parent n ${node.n} at level ${level}.`,\n        )\n      }\n      return node\n    }\n    case 'Parameter': {\n      throw new Error(\n        `Function parameters are not allowed outside function declarations: ${node.name}`,\n      )\n    }\n\n    case 'Array':\n      return {\n        ...node,\n        elements: node.elements.map((el) => ({\n          ...el,\n          value: walkValidateCustomFunction(el.value, level),\n        })),\n      }\n    case 'PipeFuncCall': {\n      return {\n        ...node,\n        base: walkValidateCustomFunction(node.base, level),\n        args: node.args.map((arg) => walkValidateCustomFunction(arg, level)),\n      }\n    }\n\n    case 'Object':\n      return {\n        ...node,\n        attributes: node.attributes.map((attr) => {\n          switch (attr.type) {\n            case 'ObjectAttributeValue':\n              return {\n                ...attr,\n                value: walkValidateCustomFunction(attr.value, level),\n              }\n            case 'ObjectConditionalSplat':\n              return {\n                ...attr,\n                condition: walkValidateCustomFunction(attr.condition, level),\n                value: walkValidateCustomFunction(attr.value, level),\n              }\n            case 'ObjectSplat':\n              return {\n                ...attr,\n                value: walkValidateCustomFunction(attr.value, level),\n              }\n            default:\n              return attr\n          }\n        }),\n      }\n\n    case 'FlatMap':\n    case 'Map': {\n      return {\n        ...node,\n        expr: walkValidateCustomFunction(node.expr, level),\n        base: walkValidateCustomFunction(node.base, level),\n      }\n    }\n    case 'FuncCall': {\n      return {\n        ...node,\n        args: node.args.map((arg) => walkValidateCustomFunction(arg, level)),\n      }\n    }\n    case 'Tuple': {\n      return {\n        ...node,\n        members: node.members.map((member) => walkValidateCustomFunction(member, level)),\n      }\n    }\n\n    case 'Select': {\n      const alternatives = node.alternatives.map((alt) => ({\n        ...alt,\n        condition: walkValidateCustomFunction(alt.condition, level),\n        value: walkValidateCustomFunction(alt.value, level),\n      }))\n      if (node.fallback) {\n        return {\n          ...node,\n          alternatives,\n          fallback: walkValidateCustomFunction(node.fallback, level),\n        }\n      }\n      return {\n        ...node,\n        alternatives,\n      }\n    }\n    case 'SelectorNested':\n      return {\n        ...node,\n        base: walkValidateCustomFunction(node.base, level),\n        nested: walkValidateCustomFunction(node.nested, level),\n      }\n    case 'SelectorFuncCall':\n      return {\n        ...node,\n        arg: walkValidateCustomFunction(node.arg, level),\n      }\n\n    case 'AccessAttribute':\n    case 'AccessElement':\n    case 'ArrayCoerce':\n    case 'Asc':\n    case 'Desc':\n    case 'Deref':\n    case 'Group':\n    case 'Neg':\n    case 'Not':\n    case 'Slice':\n    case 'Pos': {\n      if (!node.base) {\n        return node\n      }\n      return {\n        ...node,\n        base: walkValidateCustomFunction(node.base, level),\n      }\n    }\n\n    case 'InRange':\n      return {\n        ...node,\n        base: walkValidateCustomFunction(node.base, level),\n        left: walkValidateCustomFunction(node.left, level),\n        right: walkValidateCustomFunction(node.right, level),\n      }\n    case 'OpCall':\n    case 'And':\n    case 'Or':\n      return {\n        ...node,\n        left: walkValidateCustomFunction(node.left, level),\n        right: walkValidateCustomFunction(node.right, level),\n      }\n\n    case 'Everything':\n    case 'This':\n    case 'Value':\n    case 'Context': {\n      return node\n    }\n\n    default: {\n      // @ts-expect-error - we want to ensure we handle all node types\n      throw new Error(`Handle all cases: ${node.type}`)\n    }\n  }\n}\n","/* eslint-disable camelcase */\nimport {tryConstantEvaluate} from './evaluator'\nimport {type GroqFunctionArity, namespaces, pipeFunctions} from './evaluator/functions'\nimport {MarkProcessor, type MarkVisitor} from './markProcessor'\nimport {\n  type ArrayElementNode,\n  type ExprNode,\n  type FuncCallNode,\n  type FunctionDeclarationNode,\n  isSelectorNested,\n  type ObjectAttributeNode,\n  type ObjectSplatNode,\n  type OpCall,\n  type ParameterNode,\n  type ParentNode,\n  type SelectNode,\n  type SelectorNode,\n} from './nodeTypes'\nimport {type CustomFunctions, parse as rawParse} from './rawParser'\nimport {\n  type TraversalResult,\n  traverseArray,\n  traverseElement,\n  traversePlain,\n  traverseProjection,\n} from './traversal'\nimport type {ParseOptions} from './types'\nimport {walkValidateCustomFunction} from './walk'\n\ntype EscapeSequences = \"'\" | '\"' | '\\\\' | '/' | 'b' | 'f' | 'n' | 'r' | 't'\n\nconst ESCAPE_SEQUENCE: {[key in EscapeSequences]: string} = {\n  \"'\": \"'\",\n  '\"': '\"',\n  '\\\\': '\\\\',\n  '/': '/',\n  'b': '\\b',\n  'f': '\\f',\n  'n': '\\n',\n  'r': '\\r',\n  't': '\\t',\n}\n\ntype TraverseFunc = (right: TraversalResult | null) => TraversalResult\n\nfunction expandHex(str: string): string {\n  const charCode = parseInt(str, 16)\n  return String.fromCharCode(charCode)\n}\n\nclass GroqQueryError extends Error {\n  public override name = 'GroqQueryError'\n}\n\nfunction createExpressionBuilder(recursion: Set<string> = new Set()): MarkVisitor<ExprNode> {\n  const exprBuilder: MarkVisitor<ExprNode> = {\n    group(p) {\n      const inner = p.process(exprBuilder)\n      return {\n        type: 'Group',\n        base: inner,\n      }\n    },\n\n    everything() {\n      return {type: 'Everything'}\n    },\n\n    this() {\n      return {type: 'This'}\n    },\n\n    parent() {\n      return {\n        type: 'Parent',\n        n: 1,\n      }\n    },\n\n    dblparent(p) {\n      const next = p.process(exprBuilder) as ParentNode\n      return {\n        type: 'Parent',\n        n: next.n + 1,\n      }\n    },\n\n    traverse(p) {\n      const base = p.process(exprBuilder)\n      const traversalList: Array<TraverseFunc> = []\n      while (p.getMark().name !== 'traversal_end') {\n        traversalList.push(p.process(TRAVERSE_BUILDER))\n      }\n      p.shift()\n      let traversal: TraversalResult | null = null\n      for (let i = traversalList.length - 1; i >= 0; i--) {\n        traversal = traversalList[i](traversal)\n      }\n      if (base.type === 'Everything' || base.type === 'Array' || base.type === 'PipeFuncCall') {\n        traversal = traverseArray((val) => val, traversal)\n      }\n      if (traversal === null) throw new Error('BUG: unexpected empty traversal')\n      return traversal.build(base)\n    },\n\n    this_attr(p) {\n      const name = p.processString()\n\n      if (name === 'null') {\n        return {type: 'Value', value: null}\n      }\n      if (name === 'true') {\n        return {type: 'Value', value: true}\n      }\n      if (name === 'false') {\n        return {type: 'Value', value: false}\n      }\n\n      return {\n        type: 'AccessAttribute',\n        name,\n      }\n    },\n\n    neg(p) {\n      const base = p.process(exprBuilder)\n\n      return {\n        type: 'Neg',\n        base,\n      }\n    },\n\n    pos(p) {\n      const base = p.process(exprBuilder)\n\n      return {\n        type: 'Pos',\n        base,\n      }\n    },\n\n    add(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'OpCall',\n        op: '+',\n        left,\n        right,\n      }\n    },\n\n    sub(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'OpCall',\n        op: '-',\n        left,\n        right,\n      }\n    },\n\n    mul(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'OpCall',\n        op: '*',\n        left,\n        right,\n      }\n    },\n\n    div(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'OpCall',\n        op: '/',\n        left,\n        right,\n      }\n    },\n\n    mod(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'OpCall',\n        op: '%',\n        left,\n        right,\n      }\n    },\n\n    pow(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'OpCall',\n        op: '**',\n        left,\n        right,\n      }\n    },\n\n    comp(p) {\n      const left = p.process(exprBuilder)\n      const op = p.processString() as OpCall\n      const right = p.process(exprBuilder)\n      return {\n        type: 'OpCall',\n        op: op,\n        left: left,\n        right: right,\n      }\n    },\n\n    in_range(p) {\n      const base = p.process(exprBuilder)\n      const isInclusive = p.getMark().name === 'inc_range'\n      p.shift()\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'InRange',\n        base,\n        left,\n        right,\n        isInclusive,\n      }\n    },\n\n    str(p) {\n      let value = ''\n      // eslint-disable-next-line no-labels\n      loop: while (p.hasMark()) {\n        const mark = p.getMark()\n        switch (mark.name) {\n          case 'str_end':\n            value += p.processStringEnd()\n            // eslint-disable-next-line no-labels\n            break loop\n          case 'str_pause':\n            value += p.processStringEnd()\n            break\n          case 'str_start':\n            p.shift()\n            break\n          case 'single_escape': {\n            const char = p.slice(1)\n            p.shift()\n            value += ESCAPE_SEQUENCE[char as EscapeSequences]\n            break\n          }\n          case 'unicode_hex':\n            p.shift()\n            value += expandHex(p.processStringEnd())\n            break\n          default:\n            throw new Error(`unexpected mark: ${mark.name}`)\n        }\n      }\n      return {type: 'Value', value}\n    },\n\n    integer(p) {\n      const strValue = p.processStringEnd()\n      return {\n        type: 'Value',\n        value: Number(strValue),\n      }\n    },\n\n    float(p) {\n      const strValue = p.processStringEnd()\n      return {\n        type: 'Value',\n        value: Number(strValue),\n      }\n    },\n\n    sci(p) {\n      const strValue = p.processStringEnd()\n      return {\n        type: 'Value',\n        value: Number(strValue),\n      }\n    },\n\n    object(p) {\n      const attributes: ObjectAttributeNode[] = []\n      while (p.getMark().name !== 'object_end') {\n        attributes.push(p.process(OBJECT_BUILDER))\n      }\n      p.shift()\n\n      return {\n        type: 'Object',\n        attributes,\n      }\n    },\n\n    array(p) {\n      const elements: ArrayElementNode[] = []\n      while (p.getMark().name !== 'array_end') {\n        let isSplat = false\n        if (p.getMark().name === 'array_splat') {\n          isSplat = true\n          p.shift()\n        }\n        const value = p.process(exprBuilder)\n        elements.push({\n          type: 'ArrayElement',\n          value,\n          isSplat,\n        })\n      }\n      p.shift()\n      return {\n        type: 'Array',\n        elements: elements,\n      }\n    },\n\n    tuple(p) {\n      const members: ExprNode[] = []\n      while (p.getMark().name !== 'tuple_end') {\n        members.push(p.process(exprBuilder))\n      }\n      p.shift()\n      return {\n        type: 'Tuple',\n        members,\n      }\n    },\n\n    func_call(p) {\n      let namespace = 'global'\n      if (p.getMark().name === 'namespace') {\n        p.shift()\n        namespace = p.processString()\n      }\n\n      const name = p.processString()\n      if (namespace === 'global' && name === 'select') {\n        const result: SelectNode = {\n          type: 'Select',\n          alternatives: [],\n        }\n\n        while (p.getMark().name !== 'func_args_end') {\n          if (p.getMark().name === 'pair') {\n            if (result.fallback) throw new GroqQueryError(`unexpected argument to select()`)\n            p.shift()\n            const condition = p.process(exprBuilder)\n            const value = p.process(exprBuilder)\n            result.alternatives.push({\n              type: 'SelectAlternative',\n              condition,\n              value,\n            })\n          } else {\n            if (result.fallback) throw new GroqQueryError(`unexpected argument to select()`)\n            const value = p.process(exprBuilder)\n            result.fallback = value\n          }\n        }\n        p.shift()\n        return result\n      }\n\n      const args: ExprNode[] = []\n\n      while (p.getMark().name !== 'func_args_end') {\n        if (argumentShouldBeSelector(namespace, name, args.length)) {\n          args.push(p.process(SELECTOR_BUILDER))\n        } else {\n          args.push(p.process(exprBuilder))\n        }\n      }\n\n      p.shift()\n\n      if (namespace === 'global' && (name === 'before' || name === 'after')) {\n        if (p.parseOptions.mode === 'delta') {\n          return {\n            type: 'Context',\n            key: name,\n          }\n        }\n      }\n\n      if (namespace === 'global' && name === 'boost' && !p.allowBoost)\n        throw new GroqQueryError('unexpected boost')\n\n      const customFunction = p.customFunctions[`${namespace}::${name}`]\n      if (customFunction !== undefined) {\n        const FUNCTION_DECL_BUILDER = createFunctionDeclarationBuilder(recursion)\n\n        const processor = new MarkProcessor(p.string, customFunction.marks, p.customFunctions, {})\n        const funcDecl = processor.process(FUNCTION_DECL_BUILDER)\n        validateArity(name, funcDecl.params.length, args.length)\n        return mapCustomFunction(\n          funcDecl.body,\n          (body) => walkValidateCustomFunction(body),\n          (parameterNode) => resolveFunctionParameter(parameterNode, funcDecl.params, args),\n        )\n      }\n\n      const funcs = namespaces[namespace]\n      if (!funcs) {\n        throw new GroqQueryError(`Undefined namespace: ${namespace}`)\n      }\n\n      const func = funcs[name]\n      if (!func) {\n        throw new GroqQueryError(`Undefined function: ${name}`)\n      }\n      if (func.arity !== undefined) {\n        validateArity(name, func.arity, args.length)\n      }\n\n      if (func.mode !== undefined && func.mode !== p.parseOptions.mode) {\n        throw new GroqQueryError(`Undefined function: ${name}`)\n      }\n\n      return {\n        type: 'FuncCall',\n        namespace,\n        name,\n        args,\n        func,\n      }\n    },\n\n    pipecall(p) {\n      const base = p.process(exprBuilder)\n      p.shift() // Remove the func_call\n\n      let namespace = 'global'\n      if (p.getMark().name === 'namespace') {\n        p.shift()\n        namespace = p.processString()\n      }\n      if (namespace !== 'global') {\n        throw new GroqQueryError(`Undefined namespace: ${namespace}`)\n      }\n\n      const name = p.processString()\n      const args: ExprNode[] = []\n\n      const oldAllowBoost = p.allowBoost\n      if (name === 'score') {\n        // Only allow boost inside a score expression\n        p.allowBoost = true\n      }\n\n      for (;;) {\n        const markName = p.getMark().name\n        if (markName === 'func_args_end') {\n          break\n        }\n\n        if (name === 'order') {\n          if (markName === 'asc') {\n            p.shift()\n            args.push({type: 'Asc', base: p.process(exprBuilder)})\n            continue\n          } else if (markName === 'desc') {\n            p.shift()\n            args.push({type: 'Desc', base: p.process(exprBuilder)})\n            continue\n          }\n        }\n\n        args.push(p.process(exprBuilder))\n      }\n      p.shift()\n\n      p.allowBoost = oldAllowBoost\n\n      const func = pipeFunctions[name]\n      if (!func) {\n        throw new GroqQueryError(`Undefined pipe function: ${name}`)\n      }\n      if (func.arity) {\n        validateArity(name, func.arity, args.length)\n      }\n\n      return {\n        type: 'PipeFuncCall',\n        func,\n        base,\n        name,\n        args,\n      }\n    },\n\n    pair() {\n      throw new GroqQueryError(`unexpected =>`)\n    },\n\n    and(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'And',\n        left,\n        right,\n      }\n    },\n\n    or(p) {\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n      return {\n        type: 'Or',\n        left,\n        right,\n      }\n    },\n\n    not(p) {\n      const base = p.process(exprBuilder)\n      return {\n        type: 'Not',\n        base,\n      }\n    },\n\n    asc() {\n      throw new GroqQueryError('unexpected asc')\n    },\n\n    desc() {\n      throw new GroqQueryError('unexpected desc')\n    },\n\n    param(p) {\n      const name = p.processString()\n\n      if (p.parseOptions.params && p.parseOptions.params.hasOwnProperty(name)) {\n        return {\n          type: 'Value',\n          value: p.parseOptions.params[name],\n        }\n      }\n\n      return {\n        type: 'Parameter',\n        name,\n      }\n    },\n  }\n\n  const OBJECT_BUILDER: MarkVisitor<ObjectAttributeNode> = {\n    object_expr(p) {\n      if (p.getMark().name === 'pair') {\n        p.shift()\n        const condition = p.process(exprBuilder)\n        const value = p.process(exprBuilder)\n\n        return {\n          type: 'ObjectConditionalSplat',\n          condition,\n          value,\n        }\n      }\n\n      const value = p.process(exprBuilder)\n\n      return {\n        type: 'ObjectAttributeValue',\n        name: extractPropertyKey(value),\n        value,\n      }\n    },\n\n    object_pair(p) {\n      const name = p.process(exprBuilder)\n      if (name.type !== 'Value') throw new Error('name must be string')\n\n      const value = p.process(exprBuilder)\n      return {\n        type: 'ObjectAttributeValue',\n        name: name.value,\n        value: value,\n      }\n    },\n\n    object_splat(p): ObjectSplatNode {\n      const value = p.process(exprBuilder)\n\n      return {\n        type: 'ObjectSplat',\n        value,\n      }\n    },\n\n    object_splat_this(): ObjectSplatNode {\n      return {\n        type: 'ObjectSplat',\n        value: {type: 'This'},\n      }\n    },\n  }\n\n  const TRAVERSE_BUILDER: MarkVisitor<TraverseFunc> = {\n    square_bracket(p) {\n      const expr = p.process(exprBuilder)\n\n      const value = tryConstantEvaluate(expr)\n      if (value && value.type === 'number') {\n        return (right) =>\n          traverseElement((base) => ({type: 'AccessElement', base, index: value.data}), right)\n      }\n\n      if (value && value.type === 'string') {\n        return (right) =>\n          traversePlain((base) => ({type: 'AccessAttribute', base, name: value.data}), right)\n      }\n\n      return (right) =>\n        traverseArray(\n          (base) => ({\n            type: 'Filter',\n            base,\n            expr,\n          }),\n          right,\n        )\n    },\n\n    slice(p) {\n      const isInclusive = p.getMark().name === 'inc_range'\n      p.shift()\n\n      const left = p.process(exprBuilder)\n      const right = p.process(exprBuilder)\n\n      const leftValue = tryConstantEvaluate(left)\n      const rightValue = tryConstantEvaluate(right)\n\n      if (\n        !leftValue ||\n        !rightValue ||\n        leftValue.type !== 'number' ||\n        rightValue.type !== 'number'\n      ) {\n        throw new GroqQueryError('slicing must use constant numbers')\n      }\n\n      return (rhs) =>\n        traverseArray(\n          (base) => ({\n            type: 'Slice',\n            base,\n            left: leftValue.data,\n            right: rightValue.data,\n            isInclusive,\n          }),\n          rhs,\n        )\n    },\n\n    projection(p) {\n      const obj = p.process(exprBuilder)\n      return (right) =>\n        traverseProjection((base) => ({type: 'Projection', base: base, expr: obj}), right)\n    },\n\n    attr_access(p) {\n      const name = p.processString()\n\n      return (right) => traversePlain((base) => ({type: 'AccessAttribute', base, name}), right)\n    },\n\n    deref(p) {\n      let attr: string | null = null\n\n      if (p.getMark().name === 'deref_attr') {\n        p.shift()\n        attr = p.processString()\n      }\n\n      const wrap = (base: ExprNode): ExprNode =>\n        attr ? {type: 'AccessAttribute', base, name: attr} : base\n\n      return (right) =>\n        traversePlain(\n          (base) =>\n            wrap({\n              type: 'Deref',\n              base,\n            }),\n          right,\n        )\n    },\n\n    array_postfix() {\n      return (right) => traverseArray((base) => ({type: 'ArrayCoerce', base}), right)\n    },\n  }\n\n  const SELECTOR_BUILDER: MarkVisitor<SelectorNode> = {\n    group(p) {\n      return p.process(SELECTOR_BUILDER)\n    },\n\n    everything() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    this() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    parent() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    dblparent() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    traverse(p) {\n      let node: SelectorNode = p.process(SELECTOR_BUILDER)\n      while (p.getMark().name !== 'traversal_end') {\n        if (p.getMark().name === 'array_postfix') {\n          p.shift()\n\n          node = {type: 'ArrayCoerce', base: node}\n        } else if (p.getMark().name === 'square_bracket') {\n          p.shift()\n\n          const expr = p.process(exprBuilder)\n\n          const value = tryConstantEvaluate(expr)\n          if (value && value.type === 'number') {\n            throw new Error('Invalid array access expression')\n          } else if (value && value.type === 'string') {\n            node = {type: 'AccessAttribute', base: node, name: value.data}\n          } else {\n            node = {type: 'Filter', base: node, expr}\n          }\n        } else if (p.getMark().name === 'attr_access') {\n          p.shift()\n          const name = p.processString()\n          node = {type: 'AccessAttribute', base: node, name}\n        } else if (p.getMark().name === 'tuple' || p.getMark().name === 'group') {\n          const selector = p.process(SELECTOR_BUILDER)\n          if (!isSelectorNested(selector))\n            throw new Error(`Unexpected result parsing nested selector: ${selector.type}`)\n          node = {type: 'SelectorNested', base: node, nested: selector}\n        } else {\n          throw new Error('Invalid selector syntax')\n        }\n      }\n      p.shift()\n      return node\n    },\n\n    this_attr(p) {\n      const name = p.processString()\n      return {type: 'AccessAttribute', name}\n    },\n\n    attr_access() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    neg() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    pos() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    add() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    sub() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    mul() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    div() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    mod() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    pow() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    comp() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    in_range() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    str() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    integer() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    float() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    sci() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    object() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    array() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    tuple(p) {\n      const selectors: Array<SelectorNode> = []\n      while (p.getMark().name !== 'tuple_end') {\n        selectors.push(p.process(SELECTOR_BUILDER))\n      }\n      p.shift()\n\n      return {type: 'Tuple', members: selectors}\n    },\n\n    func_call(p, mark) {\n      const func = exprBuilder['func_call'](p, mark) as FuncCallNode\n      if (func.name === 'anywhere' && func.args.length === 1) {\n        return {\n          type: 'SelectorFuncCall',\n          name: 'anywhere',\n          arg: func.args[0],\n        }\n      }\n\n      throw new Error('Invalid selector syntax')\n    },\n\n    pipecall() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    pair() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    and() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    or() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    not() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    asc() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    desc() {\n      throw new Error('Invalid selector syntax')\n    },\n\n    param() {\n      throw new Error('Invalid selector syntax')\n    },\n  }\n\n  return exprBuilder\n}\n\nfunction extractPropertyKey(node: ExprNode): string {\n  if (node.type === 'AccessAttribute' && !node.base) {\n    return node.name\n  }\n\n  if (\n    node.type === 'PipeFuncCall' ||\n    node.type === 'Deref' ||\n    node.type === 'Map' ||\n    node.type === 'Projection' ||\n    node.type === 'Slice' ||\n    node.type === 'Filter' ||\n    node.type === 'AccessElement' ||\n    node.type === 'ArrayCoerce' ||\n    node.type === 'Group'\n  ) {\n    return extractPropertyKey(node.base)\n  }\n\n  throw new GroqQueryError(`Cannot determine property key for type: ${node.type}`)\n}\n\nfunction validateArity(name: string, arity: GroqFunctionArity, count: number) {\n  if (typeof arity === 'number') {\n    if (count !== arity) {\n      throw new GroqQueryError(\n        `Incorrect number of arguments to function ${name}(). Expected ${arity}, got ${count}.`,\n      )\n    }\n  } else if (arity) {\n    if (!arity(count)) {\n      throw new GroqQueryError(`Incorrect number of arguments to function ${name}().`)\n    }\n  }\n}\n\nfunction resolveFunctionParameter(parameter: ExprNode, params: ParameterNode[], args: ExprNode[]) {\n  if (parameter.type !== 'Parameter') {\n    throw new GroqQueryError(`Expected parameter node, got ${parameter.type}`)\n  }\n  const index = params.findIndex((p) => p.name === parameter.name)\n  if (index === -1) {\n    throw new GroqQueryError(`Missing argument for parameter ${parameter.name} in function call`)\n  }\n  return args[index]\n}\n\n/**\n * The function body is one of the forms:\n * - $param{…}\n * - $param->{…}\n * - $param[]{…}\n * - $param[]->{…}\n *\n * https://github.com/sanity-io/go-groq/blob/b7fb57f5aefe080becff9e3522c0b7b52a79ffd0/parser/internal/parserv2/parser.go#L975-L981\n */\nfunction mapCustomFunction(\n  body: ExprNode,\n  bodyMapper: (body: ExprNode) => ExprNode,\n  parameterMapper: (body: ParameterNode) => ExprNode = (n) => n,\n): ExprNode {\n  if (body.type === 'Projection') {\n    if (body.base.type === 'Parameter') {\n      return {\n        type: 'Projection',\n        base: parameterMapper(body.base),\n        expr: bodyMapper(body.expr),\n      }\n    }\n\n    if (body.base.type === 'Deref') {\n      if (body.base.base.type === 'Parameter') {\n        return {\n          type: 'Projection',\n          base: {\n            type: 'Deref',\n            base: parameterMapper(body.base.base),\n          },\n          expr: bodyMapper(body.expr),\n        }\n      }\n    }\n  }\n\n  if (body.type === 'Map' && body.base.type === 'ArrayCoerce') {\n    if (body.base.base.type === 'Parameter') {\n      return {\n        type: 'Map',\n        base: {\n          type: 'ArrayCoerce',\n          base: parameterMapper(body.base.base),\n        },\n        expr: bodyMapper(body.expr),\n      }\n    }\n  }\n  throw new GroqQueryError(`Unexpected function body, must be a projection. Got \"${body.type}\"`)\n}\n\nfunction argumentShouldBeSelector(namespace: string, functionName: string, argCount: number) {\n  const functionsRequiringSelectors = ['changedAny', 'changedOnly']\n\n  return namespace == 'diff' && argCount == 2 && functionsRequiringSelectors.includes(functionName)\n}\n\nclass GroqSyntaxError extends Error {\n  public position: number\n  public override name = 'GroqSyntaxError'\n\n  constructor(position: number, detail: string) {\n    super(`Syntax error in GROQ query at position ${position}${detail ? `: ${detail}` : ''}`)\n    this.position = position\n  }\n}\n\n/**\n * Parses a GROQ query and returns a tree structure.\n */\nexport function parse(input: string, options: ParseOptions = {}): ExprNode {\n  const result = rawParse(input)\n  if (result.type === 'error') {\n    throw new GroqSyntaxError(result.position, result.message)\n  }\n  validateCustomFunctions(input, result.customFunctions)\n\n  const processor = new MarkProcessor(input, result.marks, result.customFunctions, options)\n  const exprBuilder = createExpressionBuilder()\n  return processor.process(exprBuilder)\n}\n\nfunction createFunctionDeclarationBuilder(\n  recursion: Set<string> = new Set(),\n): MarkVisitor<FunctionDeclarationNode> {\n  return {\n    func_decl(p) {\n      const namespace = p.processString()\n      const name = p.processString()\n      const functionId: string = `${namespace}::${name}`\n      if (recursion.has(functionId)) {\n        throw new GroqQueryError(`Recursive function definition detected for ${functionId}`)\n      }\n\n      const exprBuilder = createExpressionBuilder(new Set([...recursion, functionId]))\n\n      const params: ParameterNode[] = []\n      while (p.getMark().name !== 'func_params_end') {\n        const param = p.process(exprBuilder)\n        if (param.type !== 'Parameter') throw new Error('expected parameter')\n        params.push(param)\n      }\n\n      if (params.length !== 1) {\n        throw new GroqQueryError('Custom functions can only have one parameter')\n      }\n\n      p.shift() // func_params_end\n\n      const body = p.process(exprBuilder)\n\n      return {\n        type: 'FuncDeclaration',\n        namespace,\n        name,\n        params,\n        body,\n      } satisfies FunctionDeclarationNode\n    },\n  } satisfies MarkVisitor<FunctionDeclarationNode>\n}\nfunction validateCustomFunctions(query: string, customFunctions: CustomFunctions) {\n  for (const functionId in customFunctions) {\n    if (!customFunctions.hasOwnProperty(functionId)) continue\n    const customFunction = customFunctions[functionId]\n    const processor = new MarkProcessor(query, customFunction.marks, customFunctions, {})\n\n    const FUNCTION_DECL_BUILDER = createFunctionDeclarationBuilder()\n    const funcDecl = processor.process(FUNCTION_DECL_BUILDER)\n    mapCustomFunction(funcDecl.body, (body) => walkValidateCustomFunction(body))\n  }\n}\n","import {isDateTime} from './typeHelpers'\nimport type {TypeNode} from './types'\n\nconst {compare} = new Intl.Collator('en')\nfunction typeNodesSorter(a: TypeNode, b: TypeNode): number {\n  if (a.type === 'null') {\n    return 1\n  }\n  return compare(hashField(a), hashField(b))\n}\n\nconst hashCache = new WeakMap<TypeNode, string>()\n\nexport function hashField(field: TypeNode): string {\n  if (hashCache.has(field)) {\n    return hashCache.get(field)!\n  }\n  const hash = calculateFieldHash(field)\n  hashCache.set(field, hash)\n  return hash\n}\n\nfunction calculateFieldHash(field: TypeNode): string {\n  switch (field.type) {\n    case 'number':\n    case 'boolean': {\n      if (field.value !== undefined) {\n        return `${field.type}(${field.value})`\n      }\n\n      return `${field.type}`\n    }\n\n    case 'string':\n      if (isDateTime(field) && field.value !== undefined) {\n        return `${field.type}(${field.value}):datetime`\n      }\n\n      if (isDateTime(field)) {\n        return `${field.type}:datetime`\n      }\n\n      if (field.value !== undefined) {\n        return `${field.type}(${field.value})`\n      }\n\n      return `${field.type}`\n\n    case 'null':\n    case 'unknown': {\n      return field.type\n    }\n\n    case 'array': {\n      return `${field.type}(${hashField(field.of)})`\n    }\n\n    case 'object': {\n      const attributes = Object.entries(field.attributes)\n      attributes.sort(([a], [b]) => compare(a, b)) // sort them by name\n      return `${field.type}:(${attributes\n        .map(\n          ([key, value]) =>\n            `${key}:${hashField(value.value)}(${value.optional ? 'optional' : 'non-optional'})`,\n        )\n        .join(',')}):ref-${field.dereferencesTo}:${field.rest ? hashField(field.rest) : 'no-rest'}`\n    }\n\n    case 'union': {\n      const sorted = [...field.of]\n      sorted.sort(typeNodesSorter)\n      return `${field.type}(${sorted.map(hashField).join(',')})`\n    }\n\n    case 'inline': {\n      return `${field.type}(${field.name})`\n    }\n\n    default: {\n      // @ts-expect-error - we should never reach this, make sure we cover all type cases\n      return field.type\n    }\n  }\n}\n\nexport function removeDuplicateTypeNodes(typeNodes: TypeNode[]): TypeNode[] {\n  const seenTypes = new Set<string>()\n  const newTypeNodes = []\n\n  const sortedTypeNodes = [...typeNodes]\n  sortedTypeNodes.sort(typeNodesSorter)\n\n  for (const typeNode of sortedTypeNodes) {\n    const hash = hashField(typeNode)\n    if (hash === null) {\n      newTypeNodes.push(typeNode)\n      continue\n    }\n    if (seenTypes.has(hash)) {\n      continue\n    }\n\n    seenTypes.add(hash)\n    newTypeNodes.push(typeNode)\n  }\n\n  return newTypeNodes\n}\n\nexport function optimizeUnions(field: TypeNode): TypeNode {\n  if (field.type === 'union') {\n    if (field.of.length === 0) {\n      return field\n    }\n\n    field.of = removeDuplicateTypeNodes(field.of)\n\n    if (field.of.length === 1) {\n      return optimizeUnions(field.of[0])\n    }\n\n    // flatten union\n    for (let idx = 0; field.of.length > idx; idx++) {\n      const subField = field.of[idx]\n      if (subField.type === 'union') {\n        field.of.splice(idx, 1, ...subField.of)\n        idx--\n        continue\n      }\n\n      field.of[idx] = optimizeUnions(subField)\n    }\n\n    field.of.sort((a, b) => {\n      if (a.type === 'null') {\n        return 1\n      }\n      return compare(hashField(a), hashField(b))\n    })\n\n    return field\n  }\n\n  if (field.type === 'array') {\n    field.of = optimizeUnions(field.of)\n    return field\n  }\n\n  if (field.type === 'object') {\n    for (const idx in field.attributes) {\n      if (!Object.hasOwn(field.attributes, idx)) {\n        continue\n      }\n\n      field.attributes[idx].value = optimizeUnions(field.attributes[idx].value)\n    }\n    return field\n  }\n\n  return field\n}\n","/** Represents a document structure with a fixed type 'document', a name, and a collection of attributes.*/\nexport interface Document {\n  /** can be used to identify the type of the node, in this case it's always 'document' */\n  type: 'document'\n  /** the name of the document */\n  name: string\n  /** Attributes is defined by a key-value pair where the key is a string and the value is an ObjectAttribute. */\n  attributes: Record<string, ObjectAttribute>\n}\n\n/** Defines a type declaration with a specific name and a value that describes the structure of the type using a TypeNode. */\nexport interface TypeDeclaration {\n  /** can be used to identify the type of the node, in this case it's always 'type' */\n  type: 'type'\n  /** the name of the type */\n  name: string\n  /** the value that describes the structure of the type */\n  value: TypeNode\n}\n\n/** A schema consisting of a list of Document or TypeDeclaration items, allowing for complex type definitions. */\nexport type Schema = (Document | TypeDeclaration)[]\n\n/** Symbol to mark a string type as a datetime */\nexport const STRING_TYPE_DATETIME = Symbol('groq-js.type.string_datetime')\n\n/** Describes a type node for string values, optionally including a value. If a value is provided it will always be the given string value. */\nexport interface StringTypeNode {\n  /** can be used to identify the type of the node, in this case it's always 'string' */\n  type: 'string'\n  /** an optional value of the string, if provided it will always be the given string value */\n  value?: string\n  /** marks this string as a datetime type for arithmetic operations */\n  [STRING_TYPE_DATETIME]?: true\n}\n\n/** Describes a type node for number values, optionally including a value. If a value is provided it will always be the given numeric value.*/\nexport interface NumberTypeNode {\n  /** can be used to identify the type of the node, in this case it's always 'number' */\n  type: 'number'\n  /** an optional value of the number, if provided it will always be the given numeric value */\n  value?: number\n}\n\n/** Describes a type node for boolean values, optionally including a value. If a value is provided it will always be the given boolean value. */\nexport interface BooleanTypeNode {\n  /** can be used to identify the type of the node, in this case it's always 'boolean' */\n  type: 'boolean'\n  /** an optional value of the boolean, if provided it will always be the given boolean value */\n  value?: boolean\n}\n\n/** Union of any primitive type nodes. */\nexport type PrimitiveTypeNode = StringTypeNode | NumberTypeNode | BooleanTypeNode\n\n/** Describes a type node for null values, always being the null value. */\nexport interface NullTypeNode {\n  /** can be used to identify the type of the node, in this case it's always 'null' */\n  type: 'null'\n}\n\n/** Describes a type node for inline values, including a name that references another type. */\nexport interface InlineTypeNode {\n  /** can be used to identify the type of the node, in this case it's always 'inline' */\n  type: 'inline'\n  /** the name of the referenced type */\n  name: string\n}\n\n/**\n * Describes a type node for object values, including a collection of attributes and an optional rest value.\n * The rest value can be another ObjectTypeNode, an UnknownTypeNode, or an InlineTypeNode.\n * If the rest value is an ObjectTypeNode, it means that the object can have additional attributes.\n * If the rest value is an UnknownTypeNode, the entire object is unknown.\n * If the rest value is an InlineTypeNode, it means that the object has additional attributes from the referenced type.\n */\nexport interface ObjectTypeNode<T extends TypeNode = TypeNode> {\n  /** can be used to identify the type of the node, in this case it's always 'object' */\n  type: 'object'\n  /** a collection of attributes */\n  attributes: Record<string, ObjectAttribute<T>>\n  /** an optional rest value */\n  rest?: ObjectTypeNode | UnknownTypeNode | InlineTypeNode\n  /* an optional reference to the document this object dereferences to */\n  dereferencesTo?: string\n}\n\n/** Describes a type node for object attributes, including a type and an optional flag for being optional. */\nexport interface ObjectAttribute<T extends TypeNode = TypeNode> {\n  /** can be used to identify the type of the node, in this case it's always 'objectAttribute' */\n  type: 'objectAttribute'\n  /** the type of the attribute */\n  value: T\n  /** an optional flag if the attribute is optional set on the object */\n  optional?: boolean\n}\n\n/** Describes a type node for union values. */\nexport interface UnionTypeNode<T extends TypeNode = TypeNode> {\n  /** can be used to identify the type of the node, in this case it's always 'union' */\n  type: 'union'\n  /** a collection of types */\n  of: T[]\n}\n\n/** Describes a type node for array values. */\nexport interface ArrayTypeNode<T extends TypeNode = TypeNode> {\n  /** can be used to identify the type of the node, in this case it's always 'array' */\n  type: 'array'\n  /** the type of the array elements */\n  of: T\n}\n\n/** Describes a type node for unknown value. */\nexport type UnknownTypeNode = {\n  /** can be used to identify the type of the node, in this case it's always 'unknown' */\n  type: 'unknown'\n}\n\n/** All possible type nodes. */\nexport type TypeNode =\n  | ObjectTypeNode\n  | StringTypeNode\n  | NullTypeNode\n  | NumberTypeNode\n  | BooleanTypeNode\n  | ArrayTypeNode\n  | UnionTypeNode\n  | InlineTypeNode\n  | UnknownTypeNode\n","import type {ExprNode} from '../nodeTypes'\nimport {optimizeUnions} from './optimizations'\nimport type {Scope} from './scope'\nimport {\n  type ArrayTypeNode,\n  type BooleanTypeNode,\n  type InlineTypeNode,\n  type NullTypeNode,\n  type NumberTypeNode,\n  type ObjectAttribute,\n  type ObjectTypeNode,\n  STRING_TYPE_DATETIME,\n  type StringTypeNode,\n  type TypeNode,\n  type UnionTypeNode,\n  type UnknownTypeNode,\n} from './types'\n\n/**\n * createReferenceTypeNode creates a ObjectTypeNode representing a reference type\n * it adds required attributes for a reference type.\n * @param name - The name of the reference type\n * @param inArray - Whether the reference is in an array\n * @returns A ObjectTypeNode representing a reference type\n * @internal\n */\nexport function createReferenceTypeNode(name: string, inArray: boolean = false): ObjectTypeNode {\n  const attributes: Record<string, ObjectAttribute> = {\n    _ref: {\n      type: 'objectAttribute',\n      value: {\n        type: 'string',\n      },\n    },\n    _type: {\n      type: 'objectAttribute',\n      value: {\n        type: 'string',\n        value: 'reference',\n      },\n    },\n    _weak: {\n      type: 'objectAttribute',\n      value: {\n        type: 'boolean',\n      },\n      optional: true,\n    },\n  }\n\n  if (inArray) {\n    attributes['_key'] = {\n      type: 'objectAttribute',\n      value: {\n        type: 'string',\n      },\n    } satisfies ObjectAttribute\n  }\n\n  return {\n    type: 'object',\n    attributes,\n    dereferencesTo: name,\n  } satisfies ObjectTypeNode\n}\n\nexport function createObject(\n  attributes: Record<string, ObjectAttribute<TypeNode>>,\n): ObjectTypeNode {\n  return {\n    type: 'object',\n    attributes,\n  } satisfies ObjectTypeNode\n}\n\nexport function createObjectAttribute(\n  value: TypeNode,\n  optional?: boolean,\n): ObjectAttribute<TypeNode> {\n  if (optional === undefined) {\n    return {\n      type: 'objectAttribute',\n      value,\n    } satisfies ObjectAttribute<TypeNode>\n  }\n\n  return {\n    type: 'objectAttribute',\n    value,\n    optional,\n  } satisfies ObjectAttribute<TypeNode>\n}\n\nexport function nullUnion(node: TypeNode): TypeNode {\n  if (node.type === 'union') {\n    return unionOf(...node.of, {type: 'null'})\n  }\n\n  return unionOf(node, {type: 'null'})\n}\n\nexport function unionOf(...nodes: TypeNode[]): TypeNode {\n  if (nodes.length === 1) {\n    return nodes[0]\n  }\n  return {\n    type: 'union',\n    of: nodes,\n  } satisfies UnionTypeNode\n}\n\nexport function dateTimeString(): StringTypeNode {\n  return {\n    type: 'string',\n    [STRING_TYPE_DATETIME]: true,\n  }\n}\n\nexport type ConcreteTypeNode =\n  | BooleanTypeNode\n  | NullTypeNode\n  | NumberTypeNode\n  | StringTypeNode\n  | ArrayTypeNode\n  | ObjectTypeNode\n\nexport function resolveInline(node: TypeNode, scope: Scope): Exclude<TypeNode, InlineTypeNode> {\n  if (node.type === 'inline') {\n    const resolvedInline = scope.context.lookupTypeDeclaration(node)\n    return resolveInline(resolvedInline, scope)\n  }\n\n  return node\n}\n\n/**\n * mapNode extracts either a _concrete type_ OR an _unknown type_ from a type node, applies the mapping\n * function to it and returns. Most notably, this will work through unions\n * (applying the mapping function for each variant) and inline (resolving the\n * reference).\n **/\nexport function mapNode<T extends TypeNode = TypeNode>(\n  node: TypeNode,\n  scope: Scope,\n  mapper: (node: ConcreteTypeNode | UnknownTypeNode) => T,\n  mergeUnions: (nodes: TypeNode[]) => TypeNode = (nodes) =>\n    optimizeUnions({type: 'union', of: nodes}),\n): TypeNode {\n  switch (node.type) {\n    case 'boolean':\n    case 'array':\n    case 'null':\n    case 'object':\n    case 'string':\n    case 'number':\n    case 'unknown':\n      return mapper(node)\n    case 'union':\n      return mergeUnions(node.of.map((inner) => mapNode(inner, scope, mapper), mergeUnions))\n    case 'inline': {\n      const resolvedInline = resolveInline(node, scope)\n      return mapNode(resolvedInline, scope, mapper, mergeUnions)\n    }\n    default:\n      // @ts-expect-error - all types should be handled\n      throw new Error(`Unknown type: ${node.type}`)\n  }\n}\n\nexport function isFuncCall(node: ExprNode, name: string): boolean {\n  if (node.type === 'Group') {\n    return isFuncCall(node.base, name)\n  }\n\n  return node.type === 'FuncCall' && `${node.namespace}::${node.name}` === name\n}\n\nexport function isString(\n  node: TypeNode,\n): node is StringTypeNode & {[STRING_TYPE_DATETIME]?: undefined} {\n  if (node.type === 'string' && !node[STRING_TYPE_DATETIME]) return true\n  return false\n}\n\nexport function isDateTime(\n  node: TypeNode,\n): node is StringTypeNode & {[STRING_TYPE_DATETIME]: true} {\n  if (node.type === 'string' && node[STRING_TYPE_DATETIME]) return true\n  return false\n}\n\nexport function containsDateTime(node: TypeNode): boolean {\n  if (isDateTime(node)) return true\n  if (node.type === 'array') {\n    if (isDateTime(node.of)) return true\n    if (node.of.type === 'union') {\n      return node.of.of.some((member) => isDateTime(member))\n    }\n  }\n  return false\n}\n\nexport function createGeoJson(type: 'Point' | 'LineString' | 'Polygon' = 'Point'): ObjectTypeNode {\n  let coordinateAttribute: ArrayTypeNode = {\n    type: 'array',\n    of: {\n      type: 'number',\n    },\n  }\n  if (type === 'LineString') {\n    coordinateAttribute = {\n      type: 'array',\n      of: {\n        type: 'array',\n        of: {\n          type: 'number',\n        },\n      },\n    } satisfies ArrayTypeNode\n  }\n  if (type === 'Polygon') {\n    coordinateAttribute = {\n      type: 'array',\n      of: {\n        type: 'array',\n        of: {\n          type: 'array',\n          of: {\n            type: 'number',\n          },\n        },\n      },\n    }\n  }\n  return {\n    type: 'object',\n    attributes: {\n      type: {\n        type: 'objectAttribute',\n        value: {\n          type: 'string',\n          value: type,\n        },\n      },\n      coordinates: {\n        type: 'objectAttribute',\n        value: coordinateAttribute,\n      },\n    },\n  } satisfies ObjectTypeNode\n}\n","import type {Scope} from './scope'\nimport {nullUnion, resolveInline} from './typeHelpers'\nimport type {TypeNode} from './types'\n\ntype BooleanInterpretation = {\n  canBeTrue: boolean\n  canBeFalse: boolean\n  canBeNull: boolean\n}\n\n/**\n * booleanValue takes a TypeNode and returns a BooleanInterpretation.\n * BooleanInterpretation is a matrix of three booleans:\n * - canBeTrue: whether the TypeNode can resolve to true\n * - canBeFalse: whether the TypeNode can resolve to false\n * - canBeNull: whether the TypeNode can resolve to null\n * This is a helper method intended to determine the possible values of a boolean expression.\n * When resolving a boolean expression, we might not be able to determine the exact value of the expression,\n * but we can determine the possible values of the expression, Multiple values can be true at the same time.\n *\n * @param node - The TypeNode to evaluate\n * @returns BooleanInterpretation\n * @internal\n */\nexport function booleanValue(node: TypeNode, scope: Scope): BooleanInterpretation {\n  switch (node.type) {\n    case 'unknown': {\n      return {canBeTrue: true, canBeFalse: true, canBeNull: true}\n    }\n    case 'boolean': {\n      if (node.value === true) {\n        return {canBeTrue: true, canBeFalse: false, canBeNull: false}\n      }\n      if (node.value === false) {\n        return {canBeTrue: false, canBeFalse: true, canBeNull: false}\n      }\n\n      return {canBeTrue: true, canBeFalse: true, canBeNull: false}\n    }\n    case 'union': {\n      const value = {canBeTrue: false, canBeFalse: false, canBeNull: false}\n      for (const sub of node.of) {\n        const match = booleanValue(sub, scope)\n        if (match.canBeNull) {\n          value.canBeNull = true\n        }\n        if (match.canBeTrue) {\n          value.canBeTrue = true\n        }\n        if (match.canBeFalse) {\n          value.canBeFalse = true\n        }\n      }\n      return value\n    }\n    case 'inline': {\n      const resolved = resolveInline(node, scope)\n      return booleanValue(resolved, scope)\n    }\n    case 'null':\n    case 'string':\n    case 'number':\n    case 'object':\n    case 'array': {\n      return {canBeTrue: false, canBeFalse: false, canBeNull: true}\n    }\n    default: {\n      // @ts-expect-error - we should have handled all cases\n      throw new Error(`unknown node type ${node.type}`)\n    }\n  }\n}\n\nexport function booleanOr(\n  left: BooleanInterpretation,\n  right: BooleanInterpretation,\n): BooleanInterpretation {\n  // If either side can only be true, the expression can only be true, so we short-circuit\n  if (left.canBeTrue && !left.canBeFalse && !left.canBeNull) return left\n  if (right.canBeTrue && !right.canBeFalse && !right.canBeNull) return right\n\n  return {\n    // Either side can be true for the expression to be true\n    canBeTrue: left.canBeTrue || right.canBeTrue,\n    // Both sides must be false for the expression to be false\n    canBeFalse: left.canBeFalse && right.canBeFalse,\n    // if either side can be null, the expression can be null if the other side can't only be true\n    canBeNull: left.canBeNull || right.canBeNull,\n  }\n}\n\nexport function booleanAnd(\n  left: BooleanInterpretation,\n  right: BooleanInterpretation,\n): BooleanInterpretation {\n  // If either side can only be fales, the expression can only be false, so we short-circuit\n  if (left.canBeFalse && !left.canBeTrue && !left.canBeNull) return left\n  if (right.canBeFalse && !right.canBeTrue && !right.canBeNull) return right\n\n  return {\n    // Both sides must be true for the expression to be true\n    canBeTrue: left.canBeTrue && right.canBeTrue,\n    // if either side can be false, the expression can be false\n    canBeFalse: left.canBeFalse || right.canBeFalse,\n    // if either side can be null, the expression can be null\n    canBeNull: left.canBeNull || right.canBeNull,\n  }\n}\n\nexport function booleanInterpretationToTypeNode(bool: BooleanInterpretation): TypeNode {\n  if (bool.canBeTrue) {\n    if (bool.canBeFalse) {\n      if (bool.canBeNull) {\n        return nullUnion({type: 'boolean'})\n      }\n      return {type: 'boolean'}\n    }\n    if (bool.canBeNull) {\n      return nullUnion({type: 'boolean', value: true})\n    }\n    return {type: 'boolean', value: true}\n  }\n\n  if (bool.canBeFalse) {\n    if (bool.canBeNull) {\n      return nullUnion({type: 'boolean', value: false})\n    }\n    return {type: 'boolean', value: false}\n  }\n  return {type: 'null'}\n}\n","/* eslint-disable max-statements */\nimport type {FuncCallNode} from '../nodeTypes'\nimport {optimizeUnions} from './optimizations'\nimport type {Scope} from './scope'\nimport {walk} from './typeEvaluate'\nimport {createGeoJson, dateTimeString, isString, mapNode, nullUnion} from './typeHelpers'\nimport {type NullTypeNode, type TypeNode} from './types'\n\nfunction unionWithoutNull(unionTypeNode: TypeNode): TypeNode {\n  if (unionTypeNode.type === 'union') {\n    return {\n      type: 'union',\n      of: unionTypeNode.of.filter((type) => type.type !== 'null'),\n    }\n  }\n  return unionTypeNode\n}\n\n// eslint-disable-next-line complexity\nexport function handleFuncCallNode(node: FuncCallNode, scope: Scope): TypeNode {\n  switch (`${node.namespace}.${node.name}`) {\n    case 'array.compact': {\n      const arg = walk({node: node.args[0], scope})\n\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion({type: 'array', of: {type: 'unknown'}})\n        }\n        if (arg.type !== 'array') {\n          return {type: 'null'}\n        }\n\n        const of = mapNode(arg.of, scope, (of) => of)\n        return {\n          type: 'array',\n          of: unionWithoutNull(of),\n        }\n      })\n    }\n\n    case 'array.join': {\n      const arrayArg = walk({node: node.args[0], scope})\n      const sepArg = walk({node: node.args[1], scope})\n\n      return mapNode(arrayArg, scope, (arrayArg) =>\n        mapNode(sepArg, scope, (sepArg) => {\n          if (arrayArg.type === 'unknown' || sepArg.type === 'unknown') {\n            return nullUnion({type: 'string'})\n          }\n          if (arrayArg.type !== 'array' || !isString(sepArg)) {\n            return {type: 'null'}\n          }\n\n          return mapNode(arrayArg.of, scope, (of) => {\n            if (of.type === 'unknown') {\n              return nullUnion({type: 'string'})\n            }\n            // we can only join strings, numbers, and booleans\n            if (of.type !== 'string' && of.type !== 'number' && of.type !== 'boolean') {\n              return {type: 'null'}\n            }\n\n            return {type: 'string'}\n          })\n        }),\n      )\n    }\n\n    case 'array.unique': {\n      const arg = walk({node: node.args[0], scope})\n\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion({type: 'array', of: {type: 'unknown'}})\n        }\n        if (arg.type !== 'array') {\n          return {type: 'null'}\n        }\n\n        return arg\n      })\n    }\n\n    case 'array.intersects': {\n      const arg1 = walk({node: node.args[0], scope})\n      const arg2 = walk({node: node.args[1], scope})\n\n      return mapNode(arg1, scope, (arg1) =>\n        mapNode(arg2, scope, (arg2) => {\n          if (arg1.type !== 'array') {\n            return {type: 'null'}\n          }\n\n          if (arg2.type !== 'array') {\n            return {type: 'null'}\n          }\n\n          return {type: 'boolean'}\n        }),\n      )\n    }\n\n    case 'global.lower': {\n      const arg = walk({node: node.args[0], scope})\n\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion({type: 'string'})\n        }\n        if (!isString(arg)) {\n          return {type: 'null'}\n        }\n        if (arg.value !== undefined) {\n          return {\n            type: 'string',\n            value: arg.value.toLowerCase(),\n          }\n        }\n        return {type: 'string'}\n      })\n    }\n    case 'global.upper': {\n      const arg = walk({node: node.args[0], scope})\n\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion({type: 'string'})\n        }\n        if (!isString(arg)) {\n          return {type: 'null'}\n        }\n        if (arg.value !== undefined) {\n          return {\n            type: 'string',\n            value: arg.value.toUpperCase(),\n          }\n        }\n        return {type: 'string'}\n      })\n    }\n    case 'dateTime.now': {\n      return dateTimeString()\n    }\n    case 'global.now': {\n      return {type: 'string'}\n    }\n    case 'global.defined': {\n      const arg = walk({node: node.args[0], scope})\n      return mapNode(arg, scope, (node) => {\n        if (node.type === 'unknown') {\n          return {type: 'boolean'}\n        }\n\n        return {type: 'boolean', value: node.type !== 'null'}\n      })\n    }\n    case 'global.path': {\n      const arg = walk({node: node.args[0], scope})\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion({type: 'string'})\n        }\n\n        if (arg.type === 'string') {\n          return {type: 'string'}\n        }\n\n        return {type: 'null'}\n      })\n    }\n    case 'global.coalesce': {\n      if (node.args.length === 0) {\n        return {type: 'null'} satisfies NullTypeNode\n      }\n      const typeNodes: TypeNode[] = []\n      let canBeNull = true\n      for (const arg of node.args) {\n        const argNode = optimizeUnions(walk({node: arg, scope}))\n\n        // Check if all types are null\n        const allNull =\n          argNode.type === 'null' ||\n          (argNode.type === 'union' && argNode.of.every((t) => t.type === 'null'))\n\n        // Can the argument be null, if all is null, unknown, or if its a union with at least one null or unknown\n        canBeNull =\n          allNull ||\n          argNode.type === 'unknown' ||\n          (argNode.type === 'union' &&\n            argNode.of.some((t) => t.type === 'null' || t.type === 'unknown'))\n\n        // As long as some type is not null or unknown, we add it to the union, but skip nulls\n        if (!allNull) {\n          typeNodes.push(unionWithoutNull(argNode))\n        }\n\n        // If we have a type that can't be null, we can break.\n        if (!canBeNull) {\n          break\n        }\n      }\n\n      // If the last argument can be null, we add null to the union\n      if (canBeNull) {\n        typeNodes.push({type: 'null'} satisfies NullTypeNode)\n      }\n\n      return {\n        type: 'union',\n        of: typeNodes,\n      }\n    }\n\n    case 'global.count': {\n      const arg = walk({node: node.args[0], scope})\n\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion({type: 'string'})\n        }\n\n        if (arg.type === 'array') {\n          return {type: 'number'}\n        }\n\n        return {type: 'null'} satisfies NullTypeNode\n      })\n    }\n\n    case 'global.dateTime': {\n      const arg = walk({node: node.args[0], scope})\n\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion(dateTimeString())\n        }\n\n        if (arg.type === 'string') {\n          // we don't know whether the string is a valid date or not, so we return a [null, string]-union\n          return nullUnion(dateTimeString())\n        }\n\n        return {type: 'null'} satisfies NullTypeNode\n      })\n    }\n\n    case 'global.length': {\n      const arg = walk({node: node.args[0], scope})\n\n      return mapNode(arg, scope, (arg) => {\n        if (arg.type === 'unknown') {\n          return nullUnion({type: 'number'})\n        }\n        if (arg.type === 'array' || isString(arg)) {\n          return {type: 'number'}\n        }\n\n        return {type: 'null'}\n      })\n    }\n\n    case 'global.references': {\n      return {type: 'boolean'}\n    }\n\n    case 'global.round': {\n      const numNode = walk({node: node.args[0], scope})\n\n      return mapNode(numNode, scope, (num) => {\n        if (num.type === 'unknown') {\n          return nullUnion({type: 'number'})\n        }\n\n        if (num.type !== 'number') {\n          return {type: 'null'}\n        }\n        if (node.args.length === 2) {\n          const precisionNode = walk({node: node.args[1], scope})\n          return mapNode(precisionNode, scope, (precision) => {\n            if (precision.type === 'unknown') {\n              return nullUnion({type: 'number'})\n            }\n\n            if (precision.type !== 'number') {\n              return {type: 'null'}\n            }\n\n            return {type: 'number'}\n          })\n        }\n\n        return {type: 'number'}\n      })\n    }\n\n    case 'global.string': {\n      const arg = walk({node: node.args[0], scope})\n      return mapNode(arg, scope, (node) => {\n        if (node.type === 'unknown') {\n          return nullUnion({type: 'string'})\n        }\n\n        if (node.type === 'string' || node.type === 'number' || node.type === 'boolean') {\n          if (node.value) {\n            return {\n              type: 'string',\n              value: node.value.toString(),\n            }\n          }\n\n          return {\n            type: 'string',\n          }\n        }\n\n        return {type: 'null'}\n      })\n    }\n\n    case 'math.sum': {\n      const values = walk({node: node.args[0], scope})\n      // use mapNode to get concrete resolved value, it will also handle cases where the value is a union\n      return mapNode(values, scope, (node) => {\n        if (node.type === 'unknown') {\n          return nullUnion({type: 'number'})\n        }\n\n        // Aggregate functions can only be applied to arrays\n        if (node.type !== 'array') {\n          return {type: 'null'}\n        }\n\n        // Resolve the concrete type of the array elements\n        return mapNode(node.of, scope, (node) => {\n          if (node.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n\n          // Math functions can only be applied to numbers, but we should also ignore nulls\n          if (node.type === 'number' || node.type === 'null') {\n            return {type: 'number'}\n          }\n          return {type: 'null'}\n        })\n      })\n    }\n\n    case 'math.avg': {\n      const values = walk({node: node.args[0], scope})\n      // use mapNode to get concrete resolved value, it will also handle cases where the value is a union\n      return mapNode(values, scope, (node) => {\n        if (node.type === 'unknown') {\n          return nullUnion({type: 'number'})\n        }\n\n        // Aggregate functions can only be applied to arrays\n        if (node.type !== 'array') {\n          return {type: 'null'}\n        }\n        // Resolve the concrete type of the array elements\n        return mapNode(node.of, scope, (node) => {\n          if (node.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n\n          // Math functions can only be applied to numbers\n          if (node.type === 'number') {\n            return {type: 'number'}\n          }\n          return {type: 'null'}\n        })\n      })\n    }\n\n    case 'math.max':\n    case 'math.min': {\n      const values = walk({node: node.args[0], scope})\n      // use mapNode to get concrete resolved value, it will also handle cases where the value is a union\n      return mapNode(values, scope, (node) => {\n        if (node.type === 'unknown') {\n          return nullUnion({type: 'number'})\n        }\n\n        // Aggregate functions can only be applied to arrays\n        if (node.type !== 'array') {\n          return {type: 'null'}\n        }\n\n        // Resolve the concrete type of the array elements\n        return mapNode(node.of, scope, (node) => {\n          if (node.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n\n          // Math functions can only be applied to numbers\n          if (node.type === 'number') {\n            return node\n          }\n          return {type: 'null'}\n        })\n      })\n    }\n\n    case 'pt.text': {\n      if (node.args.length === 0) {\n        return {type: 'null'} satisfies NullTypeNode\n      }\n      return {\n        type: 'string',\n      }\n    }\n\n    case 'string.startsWith': {\n      const strTypeNode = walk({node: node.args[0], scope})\n      const prefixTypeNode = walk({node: node.args[1], scope})\n      return mapNode(strTypeNode, scope, (strNode) => {\n        return mapNode(prefixTypeNode, scope, (prefixNode) => {\n          if (strNode.type === 'unknown' || prefixNode.type === 'unknown') {\n            return nullUnion({type: 'boolean'})\n          }\n\n          if (strNode.type !== 'string' || prefixNode.type !== 'string') {\n            return {type: 'null'}\n          }\n\n          return {type: 'boolean'}\n        })\n      })\n    }\n    case 'string.split': {\n      const strTypeNode = walk({node: node.args[0], scope})\n      const sepTypeNode = walk({node: node.args[1], scope})\n      return mapNode(strTypeNode, scope, (strNode) => {\n        return mapNode(sepTypeNode, scope, (sepNode) => {\n          if (strNode.type === 'unknown' || sepNode.type === 'unknown') {\n            return nullUnion({type: 'array', of: {type: 'string'}})\n          }\n\n          if (strNode.type !== 'string' || sepNode.type !== 'string') {\n            return {type: 'null'}\n          }\n\n          return {type: 'array', of: {type: 'string'}}\n        })\n      })\n    }\n    case 'geo.latLng': {\n      const latTypeNode = walk({node: node.args[0], scope})\n      const lngTypeNode = walk({node: node.args[1], scope})\n      return mapNode(latTypeNode, scope, (latNode) => {\n        return mapNode(lngTypeNode, scope, (lngNode) => {\n          if (latNode.type == 'unknown' || lngNode.type == 'unknown') {\n            return nullUnion(createGeoJson())\n          }\n          if (latNode.type !== 'number' || lngNode.type !== 'number') {\n            return {type: 'null'}\n          }\n\n          return nullUnion(createGeoJson())\n        })\n      })\n    }\n    case 'geo.contains': {\n      return nullUnion({type: 'boolean'})\n    }\n    case 'geo.intersects': {\n      return nullUnion({type: 'boolean'})\n    }\n    case 'geo.distance': {\n      return nullUnion({type: 'number'})\n    }\n    case 'sanity.projectId':\n    case 'sanity.dataset': {\n      return nullUnion({type: 'string'})\n    }\n    case 'sanity.versionOf': {\n      const typeNode = walk({node: node.args[0], scope})\n      return mapNode(typeNode, scope, (typeNode) => {\n        if (typeNode.type === 'unknown') {\n          return nullUnion({type: 'boolean'})\n        }\n        if (typeNode.type !== 'string') {\n          return {type: 'null'}\n        }\n        return {type: 'boolean'}\n      })\n    }\n    case 'sanity.partOfRelease': {\n      const typeNode = walk({node: node.args[0], scope})\n      return mapNode(typeNode, scope, (typeNode) => {\n        if (typeNode.type === 'unknown') {\n          return nullUnion({type: 'boolean'})\n        }\n\n        if (typeNode.type !== 'string') {\n          return {type: 'null'}\n        }\n        return {type: 'boolean'}\n      })\n    }\n    case 'documents.get': {\n      const typeNode = walk({node: node.args[0], scope})\n      return mapNode(typeNode, scope, (typeNode) => {\n        if (typeNode.type === 'unknown') {\n          return typeNode\n        }\n\n        if (typeNode.type !== 'object') {\n          return {type: 'null'}\n        }\n\n        return {type: 'unknown'}\n      })\n    }\n    case 'documents.incomingRefCount': {\n      return {type: 'number'}\n    }\n    case 'documents.incomingGlobalDocumentReferenceCount': {\n      return {type: 'number'}\n    }\n    case 'media.aspect': {\n      return mapNode(walk({node: node.args[0], scope}), scope, (fieldNode) => {\n        if (fieldNode.type === 'null') {\n          return {type: 'null'}\n        }\n\n        return mapNode(walk({node: node.args[1], scope}), scope, (aspectNode) => {\n          if (aspectNode.type !== 'string') {\n            return {type: 'null'}\n          }\n\n          return {type: 'unknown'}\n        })\n      })\n    }\n    case 'user.attributes': {\n      return {type: 'unknown'}\n    }\n    default: {\n      return {type: 'unknown'}\n    }\n  }\n}\n","import {\n  matchAnalyzePattern,\n  matchText,\n  matchTokenize,\n  type Pattern,\n  type Token,\n} from '../evaluator/matching'\nimport type {ConcreteTypeNode} from './typeHelpers'\n\nexport function match(left: ConcreteTypeNode, right: ConcreteTypeNode): boolean | undefined {\n  let tokens: Token[] = []\n  let patterns: Pattern[] = []\n  if (left.type === 'string') {\n    if (left.value === undefined) {\n      return undefined\n    }\n    tokens = tokens.concat(matchTokenize(left.value))\n  }\n  if (left.type === 'array') {\n    if (left.of.type === 'unknown') {\n      return undefined\n    }\n    if (left.of.type === 'string') {\n      // eslint-disable-next-line max-depth\n      if (left.of.value === undefined) {\n        return undefined\n      }\n\n      tokens = tokens.concat(matchTokenize(left.of.value))\n    }\n    if (left.of.type === 'union') {\n      // eslint-disable-next-line max-depth\n      for (const node of left.of.of) {\n        // eslint-disable-next-line max-depth\n        if (node.type === 'string' && node.value !== undefined) {\n          tokens = tokens.concat(matchTokenize(node.value))\n        }\n      }\n    }\n  }\n\n  if (right.type === 'string') {\n    if (right.value === undefined) {\n      return undefined\n    }\n    patterns = patterns.concat(matchAnalyzePattern(right.value))\n  }\n  if (right.type === 'array') {\n    if (right.of.type === 'unknown') {\n      return undefined\n    }\n    if (right.of.type === 'string') {\n      // eslint-disable-next-line max-depth\n      if (right.of.value === undefined) {\n        return undefined\n      }\n      patterns = patterns.concat(matchAnalyzePattern(right.of.value))\n    }\n    if (right.of.type === 'union') {\n      // eslint-disable-next-line max-depth\n      for (const node of right.of.of) {\n        // eslint-disable-next-line max-depth\n        if (node.type === 'string') {\n          // eslint-disable-next-line max-depth\n          if (node.value === undefined) {\n            return undefined\n          }\n          patterns = patterns.concat(matchAnalyzePattern(node.value))\n        }\n\n        // eslint-disable-next-line max-depth\n        if (node.type !== 'string') {\n          return false\n        }\n      }\n    }\n  }\n  return matchText(tokens, patterns)\n}\n","import type {ExprNode} from '../nodeTypes'\nimport {createObjectAttribute, unionOf} from './typeHelpers'\nimport type {NullTypeNode, ObjectAttribute, ObjectTypeNode, TypeNode} from './types'\n\n/**\n * Represents a narrowing assertion extracted from a condition expression.\n * - 'defined': The path must be non-null (e.g., from `defined(x)` or `x != null`)\n * - 'notDefined': The path must be null (e.g., from `!defined(x)` or `x == null`)\n * - 'equals': The path must equal a specific value (e.g., from `x == \"foo\"`)\n */\ntype NarrowingAssertion =\n  | {\n      path: string[]\n      action: 'defined'\n    }\n  | {\n      path: string[]\n      action: 'notDefined'\n    }\n  | {\n      path: string[]\n      action: 'equals'\n      value: TypeNode\n    }\n\n/**\n * Extracts an attribute path from an AccessAttribute expression.\n * Returns the path as an array of attribute names, or null if not a simple attribute access.\n */\nfunction extractAttributePath(node: ExprNode): string[] | null {\n  if (node.type === 'AccessAttribute') {\n    if (node.base) {\n      const basePath = extractAttributePath(node.base)\n      if (basePath) {\n        return [...basePath, node.name]\n      }\n      return null\n    }\n    return [node.name]\n  }\n  if (node.type === 'Group') {\n    return extractAttributePath(node.base)\n  }\n  return null\n}\n\n/**\n * Extracts a literal type value from a Value node.\n */\nfunction extractLiteralType(node: ExprNode): TypeNode | null {\n  if (node.type === 'Value') {\n    if (typeof node.value === 'string') {\n      return {type: 'string', value: node.value}\n    }\n    if (typeof node.value === 'number') {\n      return {type: 'number', value: node.value}\n    }\n    if (typeof node.value === 'boolean') {\n      return {type: 'boolean', value: node.value}\n    }\n    if (node.value === null) {\n      return {type: 'null'}\n    }\n  }\n  return null\n}\n\n/**\n * Extracts narrowing assertions from a condition expression.\n * These assertions describe what must be true about attribute paths for the condition to be true.\n */\nexport function extractNarrowingAssertions(\n  expr: ExprNode,\n  negated: boolean = false,\n): NarrowingAssertion[] {\n  switch (expr.type) {\n    case 'Group':\n      return extractNarrowingAssertions(expr.base, negated)\n\n    case 'Not':\n      return extractNarrowingAssertions(expr.base, !negated)\n\n    case 'And': {\n      if (negated) {\n        // !(A && B) doesn't give us useful assertions\n        return []\n      }\n      // A && B: both must be true, so we can collect assertions from both\n      return [\n        ...extractNarrowingAssertions(expr.left, negated),\n        ...extractNarrowingAssertions(expr.right, negated),\n      ]\n    }\n\n    case 'Or': {\n      if (!negated) {\n        // A || B: either can be true, so we can't assert anything specific\n        return []\n      }\n      // !(A || B) = !A && !B\n      return [\n        ...extractNarrowingAssertions(expr.left, negated),\n        ...extractNarrowingAssertions(expr.right, negated),\n      ]\n    }\n\n    case 'FuncCall': {\n      // Handle defined() function\n      if (expr.namespace === 'global' && expr.name === 'defined' && expr.args.length === 1) {\n        const path = extractAttributePath(expr.args[0])\n        if (path) {\n          return [\n            {\n              path,\n              action: negated ? 'notDefined' : 'defined',\n            },\n          ]\n        }\n      }\n      return []\n    }\n\n    case 'OpCall': {\n      const leftPath = extractAttributePath(expr.left)\n      const rightPath = extractAttributePath(expr.right)\n      const leftLiteral = extractLiteralType(expr.left)\n      const rightLiteral = extractLiteralType(expr.right)\n\n      if (expr.op === '==' || expr.op === '!=') {\n        const isEquality = expr.op === '=='\n        const effectiveEquality = negated ? !isEquality : isEquality\n\n        // path == null or null == path\n        if (leftPath && rightLiteral?.type === 'null') {\n          return [\n            {\n              path: leftPath,\n              action: effectiveEquality ? 'notDefined' : 'defined',\n            },\n          ]\n        }\n        if (rightPath && leftLiteral?.type === 'null') {\n          return [\n            {\n              path: rightPath,\n              action: effectiveEquality ? 'notDefined' : 'defined',\n            },\n          ]\n        }\n\n        // path == literal (where literal is not null)\n        if (effectiveEquality) {\n          if (leftPath && rightLiteral && rightLiteral.type !== 'null') {\n            return [\n              {\n                path: leftPath,\n                action: 'equals',\n                value: rightLiteral,\n              },\n            ]\n          }\n          if (rightPath && leftLiteral && leftLiteral.type !== 'null') {\n            return [\n              {\n                path: rightPath,\n                action: 'equals',\n                value: leftLiteral,\n              },\n            ]\n          }\n        }\n      }\n      return []\n    }\n\n    default:\n      return []\n  }\n}\n\n/**\n * Applies narrowing assertions to an object type.\n * @param isOptionalPath - Whether we're already within an optional path (parent was optional)\n */\nfunction applyAssertionsToObject(\n  node: ObjectTypeNode,\n  assertions: NarrowingAssertion[],\n  currentDepth: number = 0,\n  isOptionalPath: boolean = false,\n): ObjectTypeNode | NullTypeNode {\n  const narrowedAttributes: Record<string, ObjectAttribute> = {}\n  let hasChanges = false\n\n  for (const [name, attr] of Object.entries(node.attributes)) {\n    // Find assertions that apply to this attribute at this depth\n    const matchingAssertions = assertions.filter((a) => a.path[currentDepth] === name)\n\n    if (matchingAssertions.length > 0) {\n      // Track if this path is optional (either this attr or a parent is optional)\n      const thisPathIsOptional = isOptionalPath || attr.optional === true\n\n      // Check for terminal assertions (path ends at this attribute)\n      const terminalAssertions = matchingAssertions.filter(\n        (a) => a.path.length === currentDepth + 1,\n      )\n\n      // Check for deeper assertions (path continues past this attribute)\n      const deeperAssertions = matchingAssertions.filter((a) => a.path.length > currentDepth + 1)\n\n      let newAttr = attr\n\n      let shouldRemoveAttr = false\n      for (const assertion of terminalAssertions) {\n        switch (assertion.action) {\n          case 'defined': {\n            // Remove optionality and null from union\n            if (newAttr.optional) {\n              newAttr = createObjectAttribute(newAttr.value)\n              hasChanges = true\n            }\n            // Remove null from union if present\n            if (newAttr.value.type === 'union') {\n              const nonNullTypes = newAttr.value.of.filter((t) => t.type !== 'null')\n              if (nonNullTypes.length !== newAttr.value.of.length) {\n                newAttr = createObjectAttribute(unionOf(...nonNullTypes))\n                hasChanges = true\n              }\n            }\n            break\n          }\n          case 'notDefined': {\n            // Only narrow to null if the attribute itself is optional\n            // If the attribute is required (not optional), asserting it's null is impossible,\n            // so we should remove it from the type entirely\n            // Note: we check attr.optional, not thisPathIsOptional, because a required field\n            // inside an optional parent still can't be null when the parent exists\n            if (attr.optional === true) {\n              newAttr = createObjectAttribute({type: 'null'})\n              hasChanges = true\n            } else {\n              // Required field can't be null - remove it from the type\n              shouldRemoveAttr = true\n              hasChanges = true\n            }\n            break\n          }\n          case 'equals': {\n            // Only narrow to specific value if the path is optional\n            // For required fields, we just filter documents, not narrow types\n            newAttr = createObjectAttribute(assertion.value)\n            hasChanges = true\n            break\n          }\n          default:\n            // @ts-expect-error -- exhaustive switch\n            throw new Error(`Unhandled assertion action: ${assertion.action.toString()}`)\n        }\n      }\n\n      // Handle deeper assertions recursively\n      if (deeperAssertions.length > 0) {\n        // When we have deeper assertions (e.g., defined(optionalObject.subfield)),\n        // the parent attribute must exist, so remove optionality\n        if (attr.optional) {\n          newAttr = createObjectAttribute(newAttr.value)\n          hasChanges = true\n        }\n\n        if (newAttr.value.type === 'object') {\n          const narrowedValue = applyAssertionsToObject(\n            newAttr.value,\n            deeperAssertions,\n            currentDepth + 1,\n            thisPathIsOptional,\n          )\n          if (narrowedValue !== newAttr.value) {\n            newAttr = createObjectAttribute(narrowedValue)\n            hasChanges = true\n          }\n        } else if (newAttr.value.type === 'union') {\n          // Handle union types - narrow each object in the union\n          const originalOf = newAttr.value.of\n          const narrowedOf = originalOf.map((t) => {\n            if (t.type === 'object') {\n              return applyAssertionsToObject(\n                t,\n                deeperAssertions,\n                currentDepth + 1,\n                thisPathIsOptional,\n              )\n            }\n            return t\n          })\n\n          // Remove nulls when narrowing nested paths (only if this path is optional)\n          const nonNullTypes = narrowedOf.filter((t) => t.type !== 'null')\n          if (thisPathIsOptional && nonNullTypes.length !== narrowedOf.length) {\n            newAttr = createObjectAttribute(unionOf(...nonNullTypes))\n            hasChanges = true\n          } else if (narrowedOf.some((t, i) => t !== originalOf[i])) {\n            // Some objects were narrowed\n            newAttr = createObjectAttribute(unionOf(...narrowedOf))\n            hasChanges = true\n          }\n        }\n      }\n\n      if (!shouldRemoveAttr) {\n        narrowedAttributes[name] = newAttr\n      }\n    } else {\n      narrowedAttributes[name] = attr\n    }\n  }\n\n  if (!hasChanges) {\n    return node\n  }\n\n  return {\n    ...node,\n    attributes: narrowedAttributes,\n  }\n}\n\n/**\n * Applies narrowing assertions to a type node.\n */\nexport function narrowNode(node: TypeNode, assertions: NarrowingAssertion[]): TypeNode {\n  if (assertions.length === 0) {\n    return node\n  }\n  if (node.type === 'object') {\n    return applyAssertionsToObject(node, assertions)\n  }\n  if (node.type === 'union') {\n    return unionOf(...node.of.map((n) => narrowNode(n, assertions)))\n  }\n  return node\n}\n","import debug from 'debug'\n\nimport type {InlineTypeNode, NullTypeNode, Schema, TypeNode, UnionTypeNode} from './types'\n\nconst $trace = debug('typeEvaluator:scope:trace')\n$trace.log = console.log.bind(console) // eslint-disable-line no-console\n\nexport class Context {\n  readonly schema: Schema\n\n  constructor(schema: Schema) {\n    this.schema = schema\n  }\n\n  lookupRef(refTo: string): TypeNode {\n    for (const val of this.schema) {\n      if (val.type === 'document') {\n        if (val.name === refTo) {\n          return {\n            type: 'object',\n            attributes: val.attributes,\n          }\n        }\n      }\n    }\n    return {type: 'null'} satisfies NullTypeNode\n  }\n\n  lookupTypeDeclaration(alias: InlineTypeNode): TypeNode {\n    for (const val of this.schema) {\n      if (val.type === 'type') {\n        if (val.name === alias.name) {\n          return val.value\n        }\n      }\n    }\n    return {type: 'null'} satisfies NullTypeNode\n  }\n}\n\nexport class Scope {\n  public value: UnionTypeNode\n  public parent: Scope | undefined\n  public context: Context\n  public isHidden: boolean\n\n  constructor(value: TypeNode[], parent?: Scope, context?: Context) {\n    this.value = {type: 'union', of: value} satisfies UnionTypeNode\n    this.parent = parent\n    this.context = context || parent?.context || new Context([])\n    this.isHidden = false\n  }\n\n  createNested(value: TypeNode[]): Scope {\n    if (this.isHidden) {\n      return new Scope(value, this.parent, this.context)\n    }\n    return new Scope(value, this, this.context)\n  }\n\n  createHidden(value: TypeNode[]): Scope {\n    const result = this.createNested(value)\n    result.isHidden = true\n    return result\n  }\n}\n","import debug from 'debug'\n\nimport type {\n  AccessAttributeNode,\n  AccessElementNode,\n  AndNode,\n  ArrayCoerceNode,\n  ArrayNode,\n  DerefNode,\n  EverythingNode,\n  ExprNode,\n  FilterNode,\n  FlatMapNode,\n  MapNode,\n  NegNode,\n  NotNode,\n  ObjectConditionalSplatNode,\n  ObjectNode,\n  ObjectSplatNode,\n  OpCall,\n  OpCallNode,\n  OrNode,\n  ParentNode,\n  PosNode,\n  ProjectionNode,\n  SelectNode,\n  SliceNode,\n  ValueNode,\n} from '../nodeTypes'\nimport {booleanAnd, booleanInterpretationToTypeNode, booleanOr, booleanValue} from './booleans'\nimport {handleFuncCallNode} from './functions'\nimport {match} from './matching'\nimport {extractNarrowingAssertions, narrowNode} from './narrowing'\nimport {optimizeUnions} from './optimizations'\nimport {Context, Scope} from './scope'\nimport {\n  containsDateTime,\n  dateTimeString,\n  isDateTime,\n  isFuncCall,\n  isString,\n  mapNode,\n  nullUnion,\n  resolveInline,\n} from './typeHelpers'\nimport {\n  type ArrayTypeNode,\n  type BooleanTypeNode,\n  type Document,\n  type NullTypeNode,\n  type NumberTypeNode,\n  type ObjectAttribute,\n  type ObjectTypeNode,\n  type PrimitiveTypeNode,\n  type Schema,\n  type StringTypeNode,\n  type TypeNode,\n  type UnionTypeNode,\n  type UnknownTypeNode,\n} from './types'\n\nconst $trace = debug('typeEvaluator:evaluate:trace')\n$trace.log = console.log.bind(console) // eslint-disable-line no-console\n// log to stdout\nconst $debug = debug('typeEvaluator:evaluate:debug')\n// log to stdout\n$debug.log = console.log.bind(console) // eslint-disable-line no-console\nconst $warn = debug('typeEvaluator:evaluate:warn')\n\n/**\n * Evaluates the type of a query and schema.\n *\n * @param ast - The query ast to evaluate.\n * @param schema - The schemas to use for type evaluation.\n * @returns The type of the query.\n * @beta\n */\nexport function typeEvaluate(ast: ExprNode, schema: Schema): TypeNode {\n  $debug('evaluateQueryType.ast %O', ast)\n  $debug('evaluateQueryType.schema %O', schema)\n  const parsed = walk({\n    node: ast,\n    scope: new Scope([], undefined, new Context(schema)),\n  })\n\n  $trace('evaluateQueryType.parsed %O', parsed)\n  const optimized = optimizeUnions(parsed)\n  $debug('evaluateQueryType.optimized %O', optimized)\n\n  return optimized\n}\n\nfunction mapDeref(node: TypeNode, scope: Scope): TypeNode {\n  return mapNode(node, scope, (base) => {\n    if (base.type === 'array') {\n      return {\n        type: 'array',\n        of: mapDeref(base.of, scope),\n      }\n    }\n\n    if (base.type === 'object') {\n      if (base.dereferencesTo !== undefined) {\n        return scope.context.lookupRef(base.dereferencesTo)\n      }\n\n      if (base.rest !== undefined) {\n        return mapDeref(resolveInline(base.rest, scope), scope)\n      }\n    }\n\n    return {type: 'null'}\n  })\n}\n\nfunction handleDerefNode(node: DerefNode, scope: Scope): TypeNode {\n  $trace('deref.node %O', node)\n  const derefedNode = mapDeref(walk({node: node.base, scope}), scope)\n  $trace('deref.derefedNode %O', derefedNode)\n\n  return derefedNode\n}\n\nfunction handleObjectSplatNode(\n  attr: ObjectSplatNode | ObjectConditionalSplatNode,\n  scope: Scope,\n): TypeNode {\n  const value = walk({node: attr.value, scope})\n  $trace('object.splat.value %O', value)\n  return mapNode(value, scope, (node) => {\n    // splatting over unknown is unknown, we can't know what the attributes are\n    if (node.type === 'unknown') {\n      return {type: 'unknown'}\n    }\n    // splatting over a non-object is a no-op\n    if (node.type !== 'object') {\n      return {type: 'object', attributes: {}}\n    }\n\n    const attributes: Record<string, ObjectAttribute> = {}\n    for (const name in node.attributes) {\n      if (!node.attributes.hasOwnProperty(name)) {\n        continue\n      }\n      attributes[name] = node.attributes[name]\n    }\n\n    if (node.rest !== undefined) {\n      // Rest is either an object, inline, or unknown - we need to resolve it if it's an inline\n      const resolvedRest = resolveInline(node.rest, scope)\n\n      // if the rest is unknown the entire object is unknown\n      if (resolvedRest.type === 'unknown') {\n        return {type: 'unknown'}\n      }\n      if (resolvedRest.type !== 'object') {\n        return {type: 'null'}\n      }\n      for (const name in resolvedRest.attributes) {\n        // eslint-disable-next-line\n        if (!resolvedRest.attributes.hasOwnProperty(name)) {\n          continue\n        }\n        attributes[name] = resolvedRest.attributes[name]\n      }\n    }\n    return {type: 'object', attributes}\n  })\n}\n\n// eslint-disable-next-line max-statements, complexity\nfunction handleObjectNode(node: ObjectNode, scope: Scope): TypeNode {\n  $trace('object.node %O', node)\n\n  if (node.attributes.length === 0) {\n    return {\n      type: 'object',\n      attributes: {},\n    } satisfies ObjectTypeNode\n  }\n\n  // let attributes we a entry of [name, value] or null. We need to keep track of nulls to handle conditional splats\n  // since we care about the order of the attributes. Later attribute keys will overwrite earlier ones.\n  const objectAttributes: [number, string, ObjectAttribute][] = []\n\n  const splatVariants: [number, ObjectTypeNode | UnionTypeNode<ObjectTypeNode>][] = []\n\n  // We keep track of conditional splats separately, since we need to merge them into an object or an union of objects at the end.\n  // keep track of the index of the conditional splat to be able to merge the attributes correctly.\n  const conditionalVariants: [number, UnionTypeNode<ObjectTypeNode>][] = []\n\n  for (const [idx, attr] of node.attributes.entries()) {\n    if (attr.type === 'ObjectAttributeValue') {\n      const attributeNode = walk({node: attr.value, scope})\n      objectAttributes.push([\n        idx,\n        attr.name,\n        {\n          type: 'objectAttribute',\n          value: attributeNode,\n        },\n      ])\n      continue\n    }\n\n    if (attr.type === 'ObjectSplat') {\n      const attributeNode = handleObjectSplatNode(attr, scope)\n      $trace('object.splat.result %O', attributeNode)\n      switch (attributeNode.type) {\n        case 'object': {\n          splatVariants.push([idx, attributeNode])\n          continue\n        }\n        case 'union': {\n          for (const node of attributeNode.of) {\n            // if one of the nodes is unknown we mark the entire object as unknown as we can't infer the type of the object\n            // eslint-disable-next-line max-depth\n            if (node.type === 'unknown') {\n              return node\n            }\n          }\n          splatVariants.push([idx, attributeNode as UnionTypeNode<ObjectTypeNode>])\n          continue\n        }\n        default: {\n          return {type: 'unknown'}\n        }\n      }\n    }\n\n    if (attr.type === 'ObjectConditionalSplat') {\n      const condition = booleanValue(walk({node: attr.condition, scope}), scope)\n      $trace('object.conditional.splat.condition %O', condition)\n      // condition is never met, skip this attribute\n      if (condition.canBeTrue === false) {\n        continue\n      }\n\n      const attributeNode = handleObjectSplatNode(attr, scope)\n      $trace('object.conditional.splat.result %O', attributeNode)\n      // condition is always met, we can treat this as a normal splat\n      if (condition.canBeFalse === false && condition.canBeNull === false) {\n        switch (attributeNode.type) {\n          case 'object': {\n            splatVariants.push([idx, attributeNode])\n            continue\n          }\n          case 'union': {\n            // eslint-disable-next-line max-depth\n            for (const node of attributeNode.of) {\n              // eslint-disable-next-line max-depth\n              if (node.type !== 'object') {\n                return {type: 'unknown'}\n              }\n            }\n            splatVariants.push([idx, attributeNode as UnionTypeNode<ObjectTypeNode>])\n            continue\n          }\n          default: {\n            return {type: 'unknown'}\n          }\n        }\n      }\n\n      const variant = mapNode(attributeNode, scope, (attributeNode) => {\n        $trace('object.conditional.splat.result.concrete %O', attributeNode)\n        if (attributeNode.type !== 'object') {\n          return {type: 'unknown'}\n        }\n\n        return {\n          type: 'object',\n          attributes: attributeNode.attributes,\n        } satisfies ObjectTypeNode\n      })\n\n      if (variant.type === 'union') {\n        for (const node of variant.of) {\n          // We can only splat objects, so we bail out if we encounter a non-object node.\n          // eslint-disable-next-line max-depth\n          if (node.type !== 'object') {\n            return {type: 'unknown'}\n          }\n        }\n        variant.of.push({type: 'object', attributes: {}} as ObjectTypeNode) // add an empty object to the union, since it's conditional\n        conditionalVariants.push([idx, variant as UnionTypeNode<ObjectTypeNode>])\n        continue\n      }\n      // If the variant is not an object or a union of objects, we bail out early.\n      if (variant.type !== 'object') {\n        return {type: 'unknown'}\n      }\n\n      conditionalVariants.push([\n        idx,\n        {\n          type: 'union',\n          of: [{type: 'object', attributes: {}}, variant],\n        },\n      ])\n      continue\n    }\n\n    // @ts-expect-error - we should have handled all cases of ObjectAttributeNode\n    throw new Error(`Unknown object attribute type: ${attr.type}`)\n  }\n\n  const guaranteedAttributes: [number, string, ObjectAttribute<TypeNode>][] = []\n  guaranteedAttributes.push(...objectAttributes)\n\n  for (const [idx, splatNode] of splatVariants) {\n    if (splatNode.type === 'object') {\n      for (const name in splatNode.attributes) {\n        if (!splatNode.attributes.hasOwnProperty(name)) {\n          continue\n        }\n        const attribute = splatNode.attributes[name]\n        guaranteedAttributes.push([idx, name, attribute])\n      }\n      continue\n    }\n\n    // it's a union of objects, so we keep this as a conditional variant\n    conditionalVariants.push([idx, splatNode])\n  }\n\n  // make sure they are sorted from lowest index to highest, this ensures that\n  // attributes with a higher index overwrite attributes with a lower index.\n  guaranteedAttributes.sort(([a], [b]) => a - b)\n\n  // If we have no conditional variants, we can just return the object with the guaranteed attributes.\n  if (conditionalVariants.length === 0) {\n    return {\n      type: 'object',\n      attributes: Object.fromEntries(\n        guaranteedAttributes.map(([, name, attribute]) => [name, attribute]),\n      ),\n    } satisfies ObjectTypeNode\n  }\n\n  // matrix should be a result of if given we have variants [a,b,c] this would lead to a union of [a, a|b, a|c, a|b|c, b|c, c, {EMPTY}]\n  // if it's given we have variants A + [a|b|c] this would lead to a union of [Aa, Aa|Ab, Aa|Ac, Aa|Ab|Ac, Ab|Ac, Ac, A]\n  const matrix: (ObjectTypeNode | UnionTypeNode<ObjectTypeNode>)[] = []\n\n  for (const [unionIdx, union] of conditionalVariants) {\n    const unionGuaranteedBefore: [number, string, ObjectAttribute][] = []\n    const unionGuaranteedAfter: [number, string, ObjectAttribute][] = []\n\n    // Collect all guaranteed attributes before and after the conditional variant.\n    for (const [guaranteedIndex, name, attribute] of guaranteedAttributes) {\n      if (guaranteedIndex < unionIdx) {\n        unionGuaranteedBefore.push([guaranteedIndex, name, attribute])\n      }\n      if (guaranteedIndex > unionIdx) {\n        unionGuaranteedAfter.push([guaranteedIndex, name, attribute])\n      }\n    }\n\n    // build a map of variants from other conditions.\n    const allVariantsAttributes: [number, Record<string, ObjectAttribute>[]][] = []\n    for (const [conditionalVariantIdx, otherUnion] of conditionalVariants) {\n      // We need to build a matrix of all possible combinations of the attributes of the other variants.\n      // start with an empty object, since it's condtional.\n      const variantAttributes: Record<string, ObjectAttribute>[] = []\n      for (const node of otherUnion.of) {\n        variantAttributes.push(node.attributes)\n      }\n      allVariantsAttributes.push([conditionalVariantIdx, variantAttributes])\n    }\n\n    /* eslint-disable max-depth */\n    for (const node of union.of) {\n      matrix.push({\n        type: 'object',\n        attributes: {\n          ...Object.fromEntries(\n            unionGuaranteedBefore.map(([, name, attribute]) => [name, attribute]),\n          ),\n          ...node.attributes,\n          ...Object.fromEntries(\n            unionGuaranteedAfter.map(([, name, attribute]) => [name, attribute]),\n          ),\n        },\n      } satisfies ObjectTypeNode)\n\n      for (const [outerIdx, outerAttributes] of allVariantsAttributes) {\n        for (const outer of outerAttributes) {\n          for (const [innerIdx, innerAttributes] of allVariantsAttributes) {\n            if (outerIdx === innerIdx) {\n              continue\n            }\n\n            for (const inner of innerAttributes) {\n              const _before = [...unionGuaranteedBefore]\n              const _after = [...unionGuaranteedAfter]\n\n              for (const name in outer) {\n                if (!outer.hasOwnProperty(name)) {\n                  continue\n                }\n\n                if (outerIdx === unionIdx) {\n                  continue\n                }\n\n                if (outerIdx < unionIdx) {\n                  _before.push([outerIdx, name, outer[name]])\n                }\n\n                if (outerIdx > unionIdx) {\n                  _after.push([outerIdx, name, outer[name]])\n                }\n              }\n\n              for (const name in inner) {\n                if (!inner.hasOwnProperty(name)) {\n                  continue\n                }\n                if (outerIdx === unionIdx) {\n                  continue\n                }\n\n                if (innerIdx < unionIdx) {\n                  _before.push([innerIdx, name, inner[name]])\n                }\n\n                if (innerIdx > unionIdx) {\n                  _after.push([innerIdx, name, inner[name]])\n                }\n              }\n              _before.sort(([a], [b]) => a - b)\n              _after.sort(([a], [b]) => a - b)\n\n              const before: Record<string, ObjectAttribute> = Object.fromEntries(\n                _before.map(([, name, attribute]) => [name, attribute]),\n              )\n\n              const after: Record<string, ObjectAttribute> = Object.fromEntries(\n                _after.map(([, name, attribute]) => [name, attribute]),\n              )\n\n              matrix.push({\n                type: 'object',\n                attributes: {\n                  ...before,\n                  ...node.attributes,\n                  ...after,\n                },\n              })\n            }\n          }\n        }\n      }\n    }\n    /* eslint-disable max-depth */\n  }\n\n  return optimizeUnions({\n    type: 'union',\n    of: matrix,\n  })\n}\n\n// eslint-disable-next-line max-statements\nfunction handleOpCallNode(node: OpCallNode, scope: Scope): TypeNode {\n  $trace('opcall.node %O', node)\n  const lhs = walk({node: node.left, scope})\n  const rhs = walk({node: node.right, scope})\n  return mapNode(lhs, scope, (left) =>\n    // eslint-disable-next-line complexity, max-statements\n    mapNode(rhs, scope, (right) => {\n      $trace('opcall.node.concrete \"%s\" %O', node.op, {left, right})\n\n      switch (node.op) {\n        case '==': {\n          // == always returns a boolean, no matter the compared types.\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return {type: 'boolean'}\n          }\n          if (left.type !== right.type) {\n            return {\n              type: 'boolean',\n              value: false,\n            } satisfies BooleanTypeNode\n          }\n          if (left.type === 'null') {\n            return {\n              type: 'boolean',\n              value: true,\n            } satisfies BooleanTypeNode\n          }\n          if (!isPrimitiveTypeNode(left) || !isPrimitiveTypeNode(right)) {\n            return {\n              type: 'boolean',\n              value: false,\n            } satisfies BooleanTypeNode\n          }\n          return {\n            type: 'boolean',\n            value: evaluateComparison(node.op, left, right),\n          } satisfies BooleanTypeNode\n        }\n        case '!=': {\n          // != always returns a boolean, no matter the compared types.\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return {type: 'boolean'}\n          }\n          if (left.type !== right.type) {\n            return {\n              type: 'boolean',\n              value: true,\n            } satisfies BooleanTypeNode\n          }\n          if (left.type === 'null') {\n            return {\n              type: 'boolean',\n              value: false,\n            } satisfies BooleanTypeNode\n          }\n          if (!isPrimitiveTypeNode(left) || !isPrimitiveTypeNode(right)) {\n            return {\n              type: 'boolean',\n              value: true,\n            } satisfies BooleanTypeNode\n          }\n\n          let value = evaluateComparison('==', left, right)\n          if (value !== undefined) value = !value\n          return {\n            type: 'boolean',\n            value,\n          } satisfies BooleanTypeNode\n        }\n        case '>':\n        case '>=':\n        case '<':\n        case '<=': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return nullUnion({type: 'boolean'})\n          }\n          if (left.type !== right.type) {\n            return {type: 'null'} satisfies NullTypeNode\n          }\n          // we represent datetimes as the string type, but can only compare them if both/none are the datetime subtype\n          if (left.type === 'string' && right.type === 'string') {\n            if (isDateTime(left) !== isDateTime(right)) {\n              return {type: 'null'} satisfies NullTypeNode\n            }\n          }\n          if (!isPrimitiveTypeNode(left) || !isPrimitiveTypeNode(right)) {\n            return {type: 'null'} satisfies NullTypeNode\n          }\n          return {\n            type: 'boolean',\n            value: evaluateComparison(node.op, left, right),\n          } satisfies BooleanTypeNode\n        }\n        case 'in': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return nullUnion({type: 'boolean'})\n          }\n          if (right.type !== 'array') {\n            // Special case for global::path, since it can be used with in operator, but the type returned otherwise is a string\n            if (isFuncCall(node.right, 'global::path')) {\n              return {type: 'boolean'}\n            }\n            return {type: 'null'}\n          }\n          if (!isPrimitiveTypeNode(left) && left.type !== 'null') {\n            return {\n              type: 'boolean',\n              value: false,\n            } satisfies BooleanTypeNode\n          }\n          return mapNode(right.of, scope, (arrayTypeNode) => {\n            if (arrayTypeNode.type === 'unknown') {\n              return nullUnion({type: 'boolean'})\n            }\n\n            if (left.type === 'null') {\n              return {\n                type: 'boolean',\n                value: arrayTypeNode.type === 'null',\n              } satisfies BooleanTypeNode\n            }\n\n            if (left.value === undefined) {\n              return {\n                type: 'boolean',\n              } satisfies BooleanTypeNode\n            }\n            if (isPrimitiveTypeNode(arrayTypeNode)) {\n              if (arrayTypeNode.value === undefined) {\n                return {\n                  type: 'boolean',\n                } satisfies BooleanTypeNode\n              }\n\n              return {\n                type: 'boolean',\n                value: left.value === arrayTypeNode.value,\n              } satisfies BooleanTypeNode\n            }\n\n            return {\n              type: 'boolean',\n              value: false,\n            } satisfies BooleanTypeNode\n          })\n        }\n        case 'match': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            // match always returns a boolean, no matter the compared types.\n            return {type: 'boolean'}\n          }\n          // datetime values are not handled by gatherText in the evaluator,\n          // so match always returns false for datetime operands\n          // This includes arrays containing datetime values\n          if (containsDateTime(left) || containsDateTime(right)) {\n            return {type: 'boolean', value: false} satisfies BooleanTypeNode\n          }\n          return {\n            type: 'boolean',\n            value: match(left, right),\n          } satisfies BooleanTypeNode\n        }\n        case '+': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            // + is ambiguous without the concrete types of the operands, so we return unknown and leave the excersise to the caller\n            return {type: 'unknown'}\n          }\n          if (isDateTime(left) && right.type === 'number') {\n            return dateTimeString()\n          }\n          if (left.type === 'number' && isDateTime(right)) {\n            return dateTimeString()\n          }\n          if (isString(left) && isString(right)) {\n            return {\n              type: 'string',\n              value:\n                left.value !== undefined && right.value !== undefined\n                  ? left.value + right.value\n                  : undefined,\n            }\n          }\n          if (left.type === 'number' && right.type === 'number') {\n            return {\n              type: 'number',\n              value:\n                left.value !== undefined && right.value !== undefined\n                  ? left.value + right.value\n                  : undefined,\n            }\n          }\n          if (left.type === 'array' && right.type === 'array') {\n            return {\n              type: 'array',\n              of: {\n                type: 'union',\n                of: [left.of, right.of],\n              },\n            } satisfies ArrayTypeNode\n          }\n          if (left.type === 'object' && right.type === 'object') {\n            return {\n              type: 'object',\n              attributes: {...left.attributes, ...right.attributes},\n            } satisfies ObjectTypeNode\n          }\n          return {type: 'null'}\n        }\n        case '-': {\n          if (isDateTime(left) && isDateTime(right)) {\n            return {type: 'number'}\n          }\n          // datetime - unknown could be datetime (if unknown is number) or number (if unknown is datetime)\n          if (isDateTime(left) && right.type === 'unknown') {\n            return nullUnion({\n              type: 'union',\n              of: [{type: 'number'}, dateTimeString()],\n            })\n          }\n          // datetime - number -> datetime\n          if (isDateTime(left) && right.type === 'number') {\n            return dateTimeString()\n          }\n          // unknown - unknown could be number (if both are datetime or number) or datetime (if datetime - number)\n          if (left.type === 'unknown') {\n            return nullUnion({\n              type: 'union',\n              of: [{type: 'number'}, dateTimeString()],\n            })\n          }\n          if (right.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n          if (left.type === 'number' && right.type === 'number') {\n            return {\n              type: 'number',\n              value:\n                left.value !== undefined && right.value !== undefined\n                  ? left.value - right.value\n                  : undefined,\n            }\n          }\n          return {type: 'null'}\n        }\n        case '*': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n          if (left.type === 'number' && right.type === 'number') {\n            return {\n              type: 'number',\n              value:\n                left.value !== undefined && right.value !== undefined\n                  ? left.value * right.value\n                  : undefined,\n            }\n          }\n          return {type: 'null'}\n        }\n        case '/': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n          if (left.type === 'number' && right.type === 'number') {\n            return {\n              type: 'number',\n              value:\n                left.value !== undefined && right.value !== undefined\n                  ? left.value / right.value\n                  : undefined,\n            }\n          }\n          return {type: 'null'}\n        }\n        case '**': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n          if (left.type === 'number' && right.type === 'number') {\n            return {\n              type: 'number',\n              value:\n                left.value !== undefined && right.value !== undefined\n                  ? left.value ** right.value\n                  : undefined,\n            }\n          }\n          return {type: 'null'}\n        }\n        case '%': {\n          if (left.type === 'unknown' || right.type === 'unknown') {\n            return nullUnion({type: 'number'})\n          }\n          if (left.type === 'number' && right.type === 'number') {\n            return {\n              type: 'number',\n              value:\n                left.value !== undefined && right.value !== undefined\n                  ? left.value % right.value\n                  : undefined,\n            }\n          }\n          return {type: 'null'}\n        }\n        default: {\n          // TS only: make sure we handle all cases\n          node.op satisfies never\n\n          return {\n            type: 'unknown',\n          } satisfies UnknownTypeNode\n        }\n      }\n    }),\n  )\n}\n\nfunction handleSelectNode(node: SelectNode, scope: Scope): TypeNode {\n  const values: TypeNode[] = []\n  let guaranteed = false\n  for (const alternative of node.alternatives) {\n    const conditionValue = walk({node: alternative.condition, scope})\n    const conditionScope = resolveFilter(alternative.condition, scope)\n    if (conditionScope.type === 'union' && conditionScope.of.length > 0) {\n      values.push(walk({node: alternative.value, scope: scope.createHidden(conditionScope.of)}))\n    }\n    if (conditionValue.type === 'boolean' && conditionValue.value === true) {\n      guaranteed = true\n    }\n  }\n  if (node.fallback && !guaranteed) {\n    values.push(walk({node: node.fallback, scope}))\n  }\n  if (values.length === 0) {\n    return {type: 'null'} satisfies NullTypeNode\n  }\n\n  return {\n    type: 'union',\n    of: values,\n  } satisfies UnionTypeNode\n}\n\nfunction handleArrayCoerceNode(node: ArrayCoerceNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  $trace('arrayCoerce.base %O', base)\n  return mapArray(base, scope, (base) => base)\n}\nfunction handleFlatMap(node: FlatMapNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  return mapArray(base, scope, (base) => {\n    const inner = walk({node: node.expr, scope: scope.createHidden([base.of])})\n\n    return mapNode(\n      inner,\n      scope,\n      (inner) => {\n        if (inner.type === 'array') {\n          return inner\n        }\n\n        return {type: 'array', of: inner}\n      },\n      (nodes) => {\n        const inner: TypeNode[] = []\n        for (const node of nodes) {\n          // Bail out early if we've detected an unknown.\n          if (node.type === 'unknown') return {type: 'array', of: node}\n          // The mapper above ensures that all types returned are arrays.\n          if (node.type !== 'array') throw new Error(`Unexpected type: ${node.type}`)\n          inner.push(node.of)\n        }\n        return {\n          type: 'array',\n          of: optimizeUnions({type: 'union', of: inner}),\n        }\n      },\n    )\n  })\n}\nfunction handleMap(node: MapNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  $trace('map.base %O', base)\n\n  return mapArray(base, scope, (base) => {\n    return {\n      type: 'array',\n      of: walk({node: node.expr, scope: scope.createHidden([base.of])}),\n    }\n  })\n}\n\nfunction handleProjectionNode(node: ProjectionNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  $trace('projection.base %O', base)\n\n  return mapObject(base, scope, (base) =>\n    walk({node: node.expr, scope: scope.createNested([base])}),\n  )\n}\n\nfunction createFilterScope(base: TypeNode, scope: Scope): Scope {\n  if (base.type === 'array') {\n    if (base.of.type === 'union') {\n      return scope.createNested(base.of.of)\n    }\n    return scope.createNested([base.of])\n  }\n\n  return scope.createNested([base])\n}\nfunction handleFilterNode(node: FilterNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  $trace('filter.base %O', base)\n\n  return mapNode(base, scope, (base) => {\n    $trace('filter.resolving %O', base)\n    if (base.type === 'null') {\n      return base\n    }\n\n    const resolved = resolveFilter(node.expr, createFilterScope(base, scope))\n    $trace('filter.resolved %O', resolved)\n\n    return {\n      type: 'array',\n      of: resolved,\n    }\n  })\n}\n\nexport function handleAccessAttributeNode(node: AccessAttributeNode, scope: Scope): TypeNode {\n  let attributeBase: TypeNode = scope.value\n  if (node.base) {\n    attributeBase = walk({node: node.base, scope})\n  }\n\n  $trace('accessAttribute.base %s %O', node.name, attributeBase)\n  return handleAccessAttributeBase(attributeBase, node.name, scope)\n}\n\nfunction handleAccessAttributeBase(base: TypeNode, name: string, scope: Scope): TypeNode {\n  return mapObject(base, scope, (base) => {\n    $trace(`Looking for attribute \"%s\" in object %O`, name, base)\n\n    const attribute = base.attributes[name]\n    if (attribute !== undefined) {\n      $debug(`accessAttribute.attribute found ${name} %O`, attribute)\n      if (attribute.optional) {\n        return nullUnion(attribute.value)\n      }\n\n      return attribute.value\n    }\n\n    if (base.rest) {\n      return handleAccessAttributeBase(base.rest, name, scope)\n    }\n    $warn(`attribute \"${name}\" not found in object`)\n    return {type: 'null'}\n  })\n}\n\nfunction handleAccessElementNode(node: AccessElementNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  $trace('accessElement.base %O', base)\n  return mapArray(base, scope, (base) => nullUnion(base.of))\n}\n\nfunction handleArrayNode(node: ArrayNode, scope: Scope): TypeNode {\n  const of: TypeNode[] = []\n  for (const el of node.elements) {\n    const node = walk({node: el.value, scope})\n    if (el.isSplat) {\n      // if we are splatting a non-array, we ignore it since it would result in no values\n      if (node.type !== 'array') {\n        continue\n      }\n\n      of.push(node.of)\n    } else {\n      of.push(node)\n    }\n  }\n  return {\n    type: 'array',\n    of: {\n      type: 'union',\n      of,\n    } satisfies UnionTypeNode,\n  } satisfies ArrayTypeNode\n}\n\nfunction handleValueNode(node: ValueNode, scope: Scope): TypeNode {\n  if (node.value === null) {\n    return {type: 'null'} satisfies NullTypeNode\n  }\n  switch (typeof node.value) {\n    case 'string':\n      return {\n        type: 'string',\n        value: node.value,\n      } satisfies StringTypeNode\n    case 'number':\n      return {\n        type: 'number',\n        value: node.value,\n      } satisfies NumberTypeNode\n    case 'boolean':\n      return {\n        type: 'boolean',\n        value: node.value,\n      } satisfies BooleanTypeNode\n    case 'object':\n      if (node.value === null) {\n        return {type: 'null'} satisfies NullTypeNode\n      }\n      if (Array.isArray(node.value)) {\n        return {\n          type: 'array',\n          of: {\n            type: 'union',\n            of: node.value.map((value) => walk({node: {type: 'Value', value}, scope})),\n          },\n        } satisfies ArrayTypeNode\n      }\n      return {\n        type: 'object',\n        attributes: Object.fromEntries(\n          Object.entries(node.value).map(([key, value]) => [\n            key,\n            {\n              type: 'objectAttribute',\n              value: walk({node: {type: 'Value', value}, scope}),\n            },\n          ]),\n        ),\n      } satisfies ObjectTypeNode\n    default:\n      return {type: 'unknown'} satisfies UnknownTypeNode\n  }\n}\n\nfunction handleSlice(node: SliceNode, scope: Scope): TypeNode {\n  $trace('slice.node %O', node)\n  const base = walk({node: node.base, scope})\n  return mapArray(base, scope, (base) => base)\n}\n\nfunction handleParentNode({n}: ParentNode, scope: Scope): TypeNode {\n  $trace('handle.parent.currentScope %d %O', n, scope)\n\n  let current: Scope | undefined = scope\n  for (let i = 0; i < n; i++) {\n    // make sure we are not in a hidden scope\n    while (current?.isHidden) {\n      current = current.parent\n    }\n    current = current?.parent\n  }\n  $trace('handle.parent.newScope %d %O', n, current)\n\n  if (!current) {\n    return {type: 'null'} satisfies NullTypeNode\n  }\n\n  if (current.value.of.length === 0) {\n    return {type: 'null'} satisfies NullTypeNode\n  }\n\n  return current.value\n}\n\nfunction handleNotNode(node: NotNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  return mapNode(base, scope, (base) => {\n    if (base.type === 'unknown') {\n      return nullUnion({type: 'boolean'})\n    }\n\n    if (base.type === 'boolean') {\n      if (base.value !== undefined) {\n        return {type: 'boolean', value: base.value === false}\n      }\n      return {type: 'boolean'}\n    }\n\n    return {type: 'null'}\n  })\n}\n\nfunction handleNegNode(node: NegNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  return mapNode(base, scope, (base) => {\n    if (base.type === 'unknown') {\n      return nullUnion({type: 'number'})\n    }\n\n    if (base.type !== 'number') {\n      return {type: 'null'}\n    }\n    if (base.value !== undefined) {\n      return {type: 'number', value: -base.value}\n    }\n    return base\n  })\n}\nfunction handlePosNode(node: PosNode, scope: Scope): TypeNode {\n  const base = walk({node: node.base, scope})\n  return mapNode(base, scope, (base) => {\n    if (base.type === 'unknown') {\n      return nullUnion({type: 'number'})\n    }\n    if (base.type !== 'number') {\n      return {type: 'null'}\n    }\n    return base\n  })\n}\n\nfunction handleEverythingNode(_: EverythingNode, scope: Scope): TypeNode {\n  return {\n    type: 'array',\n    of: {\n      type: 'union',\n      of: scope.context.schema\n        .filter((obj): obj is Document => obj.type === 'document')\n        .map((doc) => ({\n          type: 'object',\n          attributes: doc.attributes,\n        })),\n    },\n  } satisfies ArrayTypeNode<UnionTypeNode<ObjectTypeNode>>\n}\n\nfunction handleAndNode(node: AndNode, scope: Scope): TypeNode {\n  const left = walk({node: node.left, scope})\n  const right = walk({node: node.right, scope})\n  return mapNode(left, scope, (lhs) =>\n    mapNode(right, scope, (rhs) => {\n      const value = booleanAnd(booleanValue(lhs, scope), booleanValue(rhs, scope))\n\n      return booleanInterpretationToTypeNode(value)\n    }),\n  )\n}\n\nfunction handleOrNode(node: OrNode, scope: Scope): TypeNode {\n  const left = walk({node: node.left, scope})\n  const right = walk({node: node.right, scope})\n  return mapNode(left, scope, (lhs) =>\n    mapNode(right, scope, (rhs) => {\n      const value = booleanOr(booleanValue(lhs, scope), booleanValue(rhs, scope))\n\n      return booleanInterpretationToTypeNode(value)\n    }),\n  )\n}\n\nconst OVERRIDE_TYPE_SYMBOL = Symbol('groq-js.type')\n\n/**\n * `overrideTypeForNode` overrides the inferred type for a specific node: The\n * type evaluator will ignore its built-in logic and instead _always_ return\n * this type. This is intended to be used for testing.\n * @internal - This is only exported for testing purposes.\n */\nexport function overrideTypeForNode(node: ExprNode, type: TypeNode): void {\n  ;(node as any)[OVERRIDE_TYPE_SYMBOL] = type\n}\n\n/**\n * Walks through the AST and evaluates the type of each node.\n *\n * @param node - The AST node to evaluate.\n * @param scope - The current scope.\n * @returns The evaluated type of the node.\n * @internal\n */\n// eslint-disable-next-line complexity\nexport function walk({node, scope}: {node: ExprNode; scope: Scope}): TypeNode {\n  if (OVERRIDE_TYPE_SYMBOL in node) {\n    return node[OVERRIDE_TYPE_SYMBOL] as TypeNode\n  }\n\n  switch (node.type) {\n    // Filtering, traversal & projections\n    case 'Map': {\n      return handleMap(node, scope)\n    }\n    case 'Projection': {\n      return handleProjectionNode(node, scope)\n    }\n    case 'Filter': {\n      return handleFilterNode(node, scope)\n    }\n    case 'AccessAttribute': {\n      return optimizeUnions(handleAccessAttributeNode(node, scope))\n    }\n    case 'AccessElement': {\n      return handleAccessElementNode(node, scope)\n    }\n    case 'ArrayCoerce': {\n      return handleArrayCoerceNode(node, scope)\n    }\n    case 'FlatMap': {\n      return handleFlatMap(node, scope)\n    }\n\n    // Operations\n    case 'OpCall': {\n      return handleOpCallNode(node, scope)\n    }\n\n    case 'And': {\n      return handleAndNode(node, scope)\n    }\n\n    case 'Or': {\n      return handleOrNode(node, scope)\n    }\n\n    case 'Select': {\n      return handleSelectNode(node, scope)\n    }\n    case 'PipeFuncCall': {\n      return walk({node: node.base, scope})\n    }\n\n    // Values\n    case 'Deref': {\n      return handleDerefNode(node, scope)\n    }\n    case 'Object': {\n      return handleObjectNode(node, scope)\n    }\n    case 'Value': {\n      return handleValueNode(node, scope)\n    }\n    case 'Array': {\n      return handleArrayNode(node, scope)\n    }\n\n    // Special cases\n    case 'Everything': {\n      return handleEverythingNode(node, scope)\n    }\n\n    case 'This': {\n      $trace('this %O', scope.value)\n      return scope.value\n    }\n\n    case 'Parent': {\n      return handleParentNode(node, scope)\n    }\n    case 'FuncCall': {\n      return handleFuncCallNode(node, scope)\n    }\n    case 'Group': {\n      return walk({node: node.base, scope})\n    }\n    case 'Not': {\n      return handleNotNode(node, scope)\n    }\n    case 'Parameter': {\n      return {\n        type: 'unknown',\n      }\n    }\n\n    case 'Slice': {\n      return handleSlice(node, scope)\n    }\n    case 'Neg': {\n      return handleNegNode(node, scope)\n    }\n    case 'Pos': {\n      return handlePosNode(node, scope)\n    }\n    // everything else\n    case 'Asc':\n    case 'Desc':\n    case 'Context':\n    case 'Tuple':\n    case 'SelectorFuncCall':\n    case 'SelectorNested':\n    case 'InRange': {\n      return {type: 'unknown'}\n    }\n\n    default: {\n      // @ts-expect-error - we should have handled all cases\n      throw new Error(`unknown node type ${node.type}`)\n    }\n  }\n}\n\nfunction isPrimitiveTypeNode(node: TypeNode): node is PrimitiveTypeNode {\n  return node.type === 'string' || node.type === 'number' || node.type === 'boolean'\n}\n\nfunction evaluateComparison(\n  opcall: OpCall,\n  left: PrimitiveTypeNode,\n  right: PrimitiveTypeNode,\n): boolean | undefined {\n  if (left.value === undefined || right.value === undefined) {\n    return undefined\n  }\n  switch (opcall) {\n    case '==': {\n      return left.value === right.value\n    }\n    case '<': {\n      return left.value < right.value\n    }\n    case '<=': {\n      return left.value <= right.value\n    }\n    case '>': {\n      return left.value > right.value\n    }\n    case '>=': {\n      return left.value >= right.value\n    }\n    default: {\n      throw new Error(`unknown comparison operator ${opcall}`)\n    }\n  }\n}\n\n// eslint-disable-next-line complexity, max-statements\nfunction resolveFilter(expr: ExprNode, scope: Scope): UnionTypeNode {\n  $trace('resolveFilter.expr %O', expr)\n  const filtered: TypeNode[] = []\n\n  // Extract narrowing assertions from the filter expression\n  const assertions = extractNarrowingAssertions(expr)\n\n  for (const node of scope.value.of) {\n    // Create a new scope with the current scopes parent as the parent.\n    // It's only a temporary scope since we only want to resolve the condition\n    // and check if the result can be true.\n    const subScope = scope.createHidden([node])\n    const cond = walk({node: expr, scope: subScope})\n    const boolResult = booleanValue(cond, subScope)\n\n    if (!boolResult.canBeTrue) {\n      // Condition is definitely false for this type, filter it out\n      continue\n    }\n\n    if (boolResult.canBeFalse && assertions.length > 0) {\n      // Condition is uncertain (can be both true and false).\n      // Apply the extracted assertions to narrow the type.\n      const narrowedNode = narrowNode(node, assertions)\n      const narrowedScope = scope.createHidden([narrowedNode])\n      const narrowedCond = walk({node: expr, scope: narrowedScope})\n      const narrowedBoolResult = booleanValue(narrowedCond, narrowedScope)\n\n      if (narrowedBoolResult.canBeTrue && !narrowedBoolResult.canBeFalse) {\n        // Narrowing makes the condition definitely true, use the narrowed type\n        filtered.push(narrowedNode)\n      } else {\n        // Narrowing doesn't help or makes it false, keep original type\n        filtered.push(node)\n      }\n    } else {\n      // Condition is definitely true for this type, or no assertions to apply, keep it as-is\n      filtered.push(node)\n    }\n  }\n\n  $trace(\n    `resolveFilter ${expr.type === 'OpCall' ? `${expr.type}/${expr.op}` : expr.type} %O`,\n    filtered,\n  )\n  return {type: 'union', of: filtered}\n}\n\nfunction mapArray(\n  node: TypeNode,\n  scope: Scope,\n  mapper: (node: ArrayTypeNode) => TypeNode,\n): TypeNode {\n  return mapNode(node, scope, (base) => {\n    if (base.type === 'unknown') {\n      return base\n    }\n    if (base.type === 'array') {\n      return mapper(base)\n    }\n    return {type: 'null'}\n  })\n}\n\nfunction mapObject(\n  node: TypeNode,\n  scope: Scope,\n  mapper: (node: ObjectTypeNode) => TypeNode,\n): TypeNode {\n  return mapNode(node, scope, (base) => {\n    if (base.type === 'unknown') {\n      return base\n    }\n    if (base.type === 'object') {\n      return mapper(base)\n    }\n    return {type: 'null'}\n  })\n}\n"],"names":["string","text","flatMap","tokens","patterns","executeAsync","map","node","array","value","Scope","arg","innerResult","terms","parse","rhs","identLen","startPos","rawParse","match","of","arrayArg","sepArg","arg1","arg2","typeNode","$trace","attributeNode","base","inner"],"mappings":";;AAAA,SAAS,aAAaA,SAAgB;AAC7B,SAAAA,QAAO,QAAQ,uBAAuB,MAAM;AACrD;AAEA,SAAS,WAAW,SAAiB;AACnC,QAAM,KAAK,CAAC;AACD,aAAA,QAAQ,QAAQ,MAAM,GAAG;AAC9B,aAA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