{"version":3,"file":"cursors.mjs","names":["CursorError","CursorConfigurationError","bounds","maxPlaintextBytes","encoder","decoder","identifier","createEnvironmentCursorCodec","encoded","currentKeyId","parsed","createCursorCodec","id","key","hexToBytes","version","keys","config","entries","transport","raw","payload","cipher","aessiv","aad","binding","namespace","bytesToHex","token","parts","keyId","plaintext","json","createScopedCursorCodec","checkDescriptors","options","scope","jsonToValue","canonicalConvexBytes","parse","synchronousCursorParser","encode","value","validate","copies","active","attempts","synchronous","result","attempt","copy","args","z","descriptors","definition","Constructor","node","child","descriptor","getter","get","owned","schema","depth","item","jsonToConvex","ancestors","nodes","visit","current","array","names","name","field","table","principal","policyVersion","engineVersion","registryVersion","order","part"],"sources":["../../src/querying/cursors.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-runtime-typeof, anti-slop/no-unknown-parameters -- Cursor transport and canonical values are explicit validation boundaries. */\nimport { aessiv } from '@noble/ciphers/aes.js'\nimport { bytesToHex, hexToBytes } from '@noble/ciphers/utils.js'\nimport { jsonToConvex, type Value, type JSONValue } from 'convex/values'\nimport { z } from 'zod'\nimport type { ManagedScope } from './security'\nimport { canonicalConvexBytes } from '../modules/contracts/idempotency'\n\n/** Private engine contract. Bindings must come from trusted normalized engine state, never query args. */\nexport interface CursorBinding {\n\treadonly table: string\n\treadonly index?: string | null\n\treadonly order: 'asc' | 'desc'\n\treadonly clientFilters: Value\n\treadonly serverFilters: Value\n\treadonly relationPath: readonly string[]\n\treadonly parent?: string | null\n\treadonly principal: string\n\treadonly tenant?: string | null\n\treadonly policyVersion: string\n\treadonly engineVersion: string\n\treadonly registryVersion: string\n\t/** Deliberately excluded from authenticated identity. */\n\treadonly pageSize?: number\n}\nexport interface CursorCodecConfig {\n\treadonly version: string\n\treadonly currentKeyId: string\n\treadonly keys: Readonly<Record<string, Uint8Array>>\n}\nexport class CursorError extends Error {\n\treadonly _tag = 'CursorError'\n\treadonly code = 'invalid-cursor'\n\tconstructor() {\n\t\tsuper('Invalid cursor')\n\t\tthis.name = 'CursorError'\n\t}\n}\nexport class CursorConfigurationError extends Error {\n\treadonly _tag = 'CursorConfigurationError'\n\tconstructor() {\n\t\tsuper('Invalid cursor server configuration')\n\t\tthis.name = 'CursorConfigurationError'\n\t}\n}\n\nconst bounds = Object.freeze({\n\tmaxDepth: 24,\n\tmaxNodes: 2048,\n\tmaxBytes: 16384,\n\tmaxArrayLength: 512,\n\tmaxObjectFields: 128,\n})\nconst maxPlaintextBytes = 8192\n// JSON string encoding preserves even lone UTF-16 surrogates without lossy UTF-8 replacement.\nconst maxPayloadBytes = maxPlaintextBytes * 6 + 2\nconst maxCiphertextBytes = maxPayloadBytes + 16\nconst maxTokenLength = maxCiphertextBytes * 2 + 70\nconst encoder = new TextEncoder()\nconst decoder = new TextDecoder('utf-8', { fatal: true })\nconst identifier = /^[A-Za-z0-9_-]{1,32}$/\n\n/** Private lazy server configuration. Call only at the first pagination boundary. */\nexport function createEnvironmentCursorCodec() {\n\ttry {\n\t\tconst encoded = process.env.CVX_QUERY_CURSOR_KEYS_JSON\n\t\tconst currentKeyId = process.env.CVX_QUERY_CURSOR_CURRENT_KEY_ID\n\t\tif (!encoded || !currentKeyId) throw new CursorConfigurationError()\n\t\tconst parsed: unknown = JSON.parse(encoded)\n\t\tif (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))\n\t\t\tthrow new CursorConfigurationError()\n\t\tconst keys = Object.fromEntries(\n\t\t\tObject.entries(parsed).map(([id, key]) => {\n\t\t\t\tif (typeof key !== 'string' || !/^[0-9a-fA-F]{128}$/.test(key))\n\t\t\t\t\tthrow new CursorConfigurationError()\n\t\t\t\treturn [id, hexToBytes(key)]\n\t\t\t}),\n\t\t)\n\t\treturn createCursorCodec({ version: '1', currentKeyId, keys })\n\t} catch {\n\t\t// Parsing/runtime failures must never expose key material or environment values.\n\t\tthrow new CursorConfigurationError()\n\t}\n}\n\n/**\n * Deterministic RFC 5297 AES-SIV: equal plaintext and binding leak equality.\n * One navigation-boundary family permits native split/continue tokens in start/end\n * slots. Relation identity remains in the binding. No nonce/randomness or plaintext fallback. Opening is not authorization: the engine\n * must recheck current policy on every future request, including nested continuations.\n */\nexport function createCursorCodec(config: CursorCodecConfig) {\n\tlet version: string, currentKeyId: string\n\tconst keys = new Map<string, Uint8Array>()\n\ttry {\n\t\tversion = config.version\n\t\tcurrentKeyId = config.currentKeyId\n\t\tif (\n\t\t\ttypeof version !== 'string' ||\n\t\t\ttypeof currentKeyId !== 'string' ||\n\t\t\t!identifier.test(version) ||\n\t\t\t!identifier.test(currentKeyId)\n\t\t)\n\t\t\tthrow new CursorConfigurationError()\n\t\tconst entries = Object.entries(config.keys)\n\t\tif (!entries.length) throw new CursorConfigurationError()\n\t\tfor (const [id, key] of entries) {\n\t\t\tif (!identifier.test(id) || !(key instanceof Uint8Array) || key.byteLength !== 64)\n\t\t\t\tthrow new CursorConfigurationError()\n\t\t\tkeys.set(id, Uint8Array.from(key))\n\t\t}\n\t\tif (!keys.has(currentKeyId)) throw new CursorConfigurationError()\n\t} catch {\n\t\tthrow new CursorConfigurationError()\n\t}\n\tfunction transport(namespace: 'pc' | 'cc') {\n\t\treturn Object.freeze({\n\t\t\tseal(raw: string, binding: CursorBinding): string {\n\t\t\t\ttry {\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof raw !== 'string' ||\n\t\t\t\t\t\traw.length > maxPlaintextBytes ||\n\t\t\t\t\t\tencoder.encode(raw).length > maxPlaintextBytes\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new CursorError()\n\t\t\t\t\tconst payload = encoder.encode(JSON.stringify(raw))\n\t\t\t\t\tconst cipher = aessiv(\n\t\t\t\t\t\tkeys.get(currentKeyId)!,\n\t\t\t\t\t\taad(version, currentKeyId, binding, namespace),\n\t\t\t\t\t)\n\t\t\t\t\treturn `${namespace}.${version}.${currentKeyId}.${bytesToHex(cipher.encrypt(payload))}`\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new CursorError()\n\t\t\t\t}\n\t\t\t},\n\t\t\topen(token: string, binding: CursorBinding): string {\n\t\t\t\ttry {\n\t\t\t\t\tif (typeof token !== 'string' || token.length > maxTokenLength) throw new CursorError()\n\t\t\t\t\tconst parts = token.split('.')\n\t\t\t\t\tif (\n\t\t\t\t\t\tparts.length !== 4 ||\n\t\t\t\t\t\tparts[0] !== namespace ||\n\t\t\t\t\t\tparts[1] !== version ||\n\t\t\t\t\t\t!identifier.test(parts[2]!)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new CursorError()\n\t\t\t\t\tconst keyId = parts[2]!,\n\t\t\t\t\t\tencoded = parts[3]!,\n\t\t\t\t\t\tkey = keys.get(keyId)\n\t\t\t\t\tif (\n\t\t\t\t\t\t!key ||\n\t\t\t\t\t\tencoded.length < 36 ||\n\t\t\t\t\t\tencoded.length > maxCiphertextBytes * 2 ||\n\t\t\t\t\t\tencoded.length % 2 ||\n\t\t\t\t\t\t!/^[0-9a-f]+$/.test(encoded)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new CursorError()\n\t\t\t\t\tconst cipher = aessiv(key, aad(version, keyId, binding, namespace))\n\t\t\t\t\tconst plaintext = cipher.decrypt(hexToBytes(encoded))\n\t\t\t\t\tif (plaintext.length > maxPayloadBytes) throw new CursorError()\n\t\t\t\t\tconst json = decoder.decode(plaintext)\n\t\t\t\t\tconst raw: unknown = JSON.parse(json)\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof raw !== 'string' ||\n\t\t\t\t\t\traw.length > maxPlaintextBytes ||\n\t\t\t\t\t\tencoder.encode(raw).length > maxPlaintextBytes ||\n\t\t\t\t\t\tJSON.stringify(raw) !== json\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new CursorError()\n\t\t\t\t\treturn raw\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new CursorError()\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n\treturn Object.freeze({ ...transport('pc'), custom: transport('cc') })\n}\n\n/** Server-derived binding supplements managed scope; opening never grants row access. */\nexport interface ScopedCursorOptions<S extends z.ZodType<Value>> {\n\treadonly domain: string\n\treadonly bind: Value\n\t/** Synchronous schema, applied on seal AND open. Outputs must be bounded Convex values. */\n\treadonly schema: S\n}\n/** Integrity only: consumers must recheck current authorization on every request. */\nexport interface ScopedCursorCodec<S extends z.ZodType<Value>> {\n\tseal(payload: z.input<S>): string\n\topen(token: string): z.output<S>\n}\n\n/** Internal construction uses the configured engine's already captured key ring. */\nexport function createScopedCursorCodec<S extends z.ZodType<Value>>(\n\ttransport: ReturnType<typeof createCursorCodec>['custom'],\n\tscope: ManagedScope & { readonly policyVersion: string },\n\toptions: ScopedCursorOptions<S>,\n): ScopedCursorCodec<S> {\n\ttry {\n\t\tcheckDescriptors(options.bind)\n\t\tif (typeof options.domain !== 'string' || !options.domain.length || options.domain.length > 256)\n\t\t\tthrow new CursorError()\n\t\t// Snapshot bind bytes before returning: later caller mutation cannot change identity.\n\t\tconst binding: CursorBinding = {\n\t\t\ttable: options.domain,\n\t\t\torder: 'asc',\n\t\t\tprincipal: 'custom',\n\t\t\tpolicyVersion: scope.policyVersion,\n\t\t\tengineVersion: 'custom-1',\n\t\t\tregistryVersion: 'custom-1',\n\t\t\trelationPath: [],\n\t\t\tclientFilters: jsonToValue(JSON.parse(canonicalConvexBytes(options.bind, bounds))),\n\t\t\tserverFilters: { ...scope },\n\t\t}\n\t\t// Validate the combined identity even before any seal/open call.\n\t\taad('1', 'validation', binding, 'cc')\n\t\tconst parse = synchronousCursorParser(options.schema)\n\t\tfunction encode(value: unknown): string {\n\t\t\tcheckDescriptors(value)\n\t\t\treturn canonicalConvexBytes(value, { ...bounds, maxBytes: maxPlaintextBytes })\n\t\t}\n\t\tfunction validate(value: unknown): z.output<S> {\n\t\t\tencode(value)\n\t\t\tconst parsed = parse(value)\n\t\t\tencode(parsed)\n\t\t\treturn parsed\n\t\t}\n\t\treturn Object.freeze({\n\t\t\tseal(payload: z.input<S>): string {\n\t\t\t\ttry {\n\t\t\t\t\t// Validate output too, but retain input bytes so open applies transforms once.\n\t\t\t\t\tvalidate(payload)\n\t\t\t\t\treturn transport.seal(encode(payload), binding)\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new CursorError()\n\t\t\t\t}\n\t\t\t},\n\t\t\topen(token: string): z.output<S> {\n\t\t\t\ttry {\n\t\t\t\t\tconst raw = transport.open(token, binding)\n\t\t\t\t\tconst value = jsonToValue(JSON.parse(raw))\n\t\t\t\t\tif (encode(value) !== raw) throw new CursorError()\n\t\t\t\t\treturn validate(value)\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new CursorError()\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t} catch {\n\t\tthrow new CursorError()\n\t}\n}\n\n/**\n * Zod's sync parser throws AFTER starting async callbacks, losing their promises.\n * Rebuild an owned graph so callback results are contained before Zod sees them.\n * Uses Zod 4's definition/constructor seam (also used by its clone utility).\n */\n/* oxlint-disable anti-slop/no-unknown-returns, anti-slop/no-known-value-widening -- The private walker preserves heterogeneous Zod definitions and callback results until their installed constructor restores the schema contract. */\nfunction synchronousCursorParser<S extends z.ZodType>(schema: S): (value: unknown) => z.output<S> {\n\tconst copies = new WeakMap<object, unknown>()\n\tconst active = new WeakSet<object>()\n\tconst attempts = new Set<{ asynchronous: boolean }>()\n\tfunction synchronous(result: unknown): unknown {\n\t\tif (\n\t\t\tresult !== null &&\n\t\t\t(typeof result === 'object' || typeof result === 'function') &&\n\t\t\t'then' in result &&\n\t\t\ttypeof result.then === 'function'\n\t\t) {\n\t\t\tfor (const attempt of attempts) attempt.asynchronous = true\n\t\t\t// Attach before throwing, including foreign promises and ordinary functions\n\t\t\t// returning promises. Never propagate the callback's rejection details.\n\t\t\tvoid Promise.resolve(result).catch(() => {})\n\t\t\tthrow new CursorError()\n\t\t}\n\t\treturn result\n\t}\n\tfunction copy(value: unknown): unknown {\n\t\tif (typeof value === 'function') {\n\t\t\treturn function (this: unknown, ...args: unknown[]) {\n\t\t\t\tconst result = synchronous(value.apply(this, args))\n\t\t\t\t// Lazy schemas resolve at parse time; their children need the same boundary.\n\t\t\t\treturn result instanceof z.core.$ZodType ? copy(result) : result\n\t\t\t}\n\t\t}\n\t\tif (value === null || typeof value !== 'object') return value\n\t\tif (copies.has(value)) return copies.get(value)\n\t\tif (active.has(value)) throw new CursorError()\n\t\tactive.add(value)\n\t\tlet result: unknown\n\t\tif (value instanceof z.core.$ZodType || value instanceof z.core.$ZodCheck) {\n\t\t\tconst descriptors = Object.getOwnPropertyDescriptors(value._zod.def)\n\t\t\t// A previously parsed lazy schema caches its resolved graph here. Rebuild\n\t\t\t// it through the guarded getter so recursive references resolve to our copy.\n\t\t\tif ('type' in value._zod.def && value._zod.def.type === 'lazy')\n\t\t\t\tdelete descriptors._cachedInner\n\t\t\tconst definition = copy(Object.create(Object.getPrototypeOf(value._zod.def), descriptors))\n\t\t\t// Zod's check typings omit constr, but $constructor installs it on both\n\t\t\t// checks and schemas in the supported Zod 4 peers.\n\t\t\t// SAFETY: the installed constructor reconstructs the same schema/check kind.\n\t\t\tconst Constructor = (\n\t\t\t\tvalue._zod as {\n\t\t\t\t\tconstr: new (definition: unknown) => z.core.$ZodType | z.core.$ZodCheck\n\t\t\t\t}\n\t\t\t).constr\n\t\t\tconst node = new Constructor(definition)\n\t\t\tif (node instanceof z.core.$ZodType && node._zod.def.type === 'promise') {\n\t\t\t\t// Promise schemas are intrinsically async, even with a synchronous child.\n\t\t\t\t// Reject before Zod schedules that child outside this sync boundary.\n\t\t\t\tnode._zod.parse = node._zod.run = () => {\n\t\t\t\t\tfor (const attempt of attempts) attempt.asynchronous = true\n\t\t\t\t\tthrow new CursorError()\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tvalue instanceof z.core.$ZodCheck &&\n\t\t\t\tvalue._zod.def.check === 'custom' &&\n\t\t\t\t!('type' in value._zod.def)\n\t\t\t) {\n\t\t\t\tif (!(node instanceof z.core.$ZodCheck)) throw new CursorError()\n\t\t\t\t// superRefine/check store their callback on the node, not in its definition.\n\t\t\t\t// SAFETY: copy wraps the original callback without changing its arguments or sync result.\n\t\t\t\tnode._zod.check = copy(value._zod.check) as typeof value._zod.check\n\t\t\t}\n\t\t\tresult = node\n\t\t} else if (Array.isArray(value)) {\n\t\t\tresult = value.map((child) => copy(child))\n\t\t} else if (\n\t\t\tObject.getPrototypeOf(value) === Object.prototype ||\n\t\t\tObject.getPrototypeOf(value) === null\n\t\t) {\n\t\t\t// Defaults/prefaults use getters to invoke callbacks per parse. Keep them\n\t\t\t// lazy, while guarding their results just like definition callbacks.\n\t\t\tconst descriptors = Object.getOwnPropertyDescriptors(value)\n\t\t\tfor (const descriptor of Object.values(descriptors)) {\n\t\t\t\tif ('value' in descriptor) descriptor.value = copy(descriptor.value)\n\t\t\t\telse if (descriptor.get) {\n\t\t\t\t\tconst getter = descriptor.get\n\t\t\t\t\tconst get = () => copy(synchronous(getter.call(value)))\n\t\t\t\t\t// Zod object constructors reuse the raw shape behind this getter.\n\t\t\t\t\tif ('raw' in getter) Object.assign(get, { raw: copy(getter.raw) })\n\t\t\t\t\tdescriptor.get = get\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult = Object.create(Object.getPrototypeOf(value), descriptors)\n\t\t} else {\n\t\t\t// RegExp and other literal definition values are not parser nodes.\n\t\t\tresult = value\n\t\t}\n\t\tactive.delete(value)\n\t\tcopies.set(value, result)\n\t\treturn result\n\t}\n\t// SAFETY: reconstruction preserves the root schema's input/output contract.\n\tconst owned = copy(schema) as S\n\treturn (value) => {\n\t\tconst attempt = { asynchronous: false }\n\t\tattempts.add(attempt)\n\t\ttry {\n\t\t\tconst parsed = owned.parse(value)\n\t\t\t// A catch/fallback schema may swallow the thrown boundary error.\n\t\t\tif (attempt.asynchronous) throw new CursorError()\n\t\t\treturn parsed\n\t\t} finally {\n\t\t\tattempts.delete(attempt)\n\t\t}\n\t}\n}\n/* oxlint-enable anti-slop/no-unknown-returns, anti-slop/no-known-value-widening */\n\n/** Preserve own __proto__ fields; SDK scalar conversion handles integer/binary/float tags. */\nfunction jsonToValue(value: JSONValue, depth = 0): Value {\n\tif (depth > bounds.maxDepth) throw new CursorError()\n\tif (Array.isArray(value)) return value.map((item) => jsonToValue(item, depth + 1))\n\tif (value !== null && typeof value === 'object') {\n\t\tconst entries = Object.entries(value)\n\t\tif (entries.some(([key]) => key.startsWith('$'))) return jsonToConvex(value)\n\t\treturn Object.fromEntries(entries.map(([key, item]) => [key, jsonToValue(item, depth + 1)]))\n\t}\n\treturn jsonToConvex(value)\n}\n\n/** Reject accessor-bearing arrays/dictionaries before the shared canonical encoder reads values. */\nfunction checkDescriptors(value: unknown): void {\n\tconst ancestors = new Set<object>()\n\tlet nodes = 0\n\tfunction visit(current: unknown, depth: number): void {\n\t\tif (++nodes > bounds.maxNodes || depth > bounds.maxDepth) throw new CursorError()\n\t\tif (current === null || typeof current !== 'object') return\n\t\tif (current instanceof ArrayBuffer) {\n\t\t\tif (\n\t\t\t\tObject.getPrototypeOf(current) !== ArrayBuffer.prototype ||\n\t\t\t\tObject.getOwnPropertyNames(current).length ||\n\t\t\t\tObject.getOwnPropertySymbols(current).length\n\t\t\t)\n\t\t\t\tthrow new CursorError()\n\t\t\treturn\n\t\t}\n\t\tif (ancestors.has(current)) throw new CursorError()\n\t\tconst array = Array.isArray(current)\n\t\tif (array && Object.getPrototypeOf(current) !== Array.prototype) throw new CursorError()\n\t\tif (\n\t\t\t!array &&\n\t\t\tObject.getPrototypeOf(current) !== Object.prototype &&\n\t\t\tObject.getPrototypeOf(current) !== null\n\t\t)\n\t\t\tthrow new CursorError()\n\t\tif (Object.getOwnPropertySymbols(current).length) throw new CursorError()\n\t\tconst names = Object.getOwnPropertyNames(current)\n\t\tif (names.length > (array ? bounds.maxArrayLength + 1 : bounds.maxObjectFields))\n\t\t\tthrow new CursorError()\n\t\tancestors.add(current)\n\t\ttry {\n\t\t\tfor (const name of names) {\n\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(current, name)!\n\t\t\t\tif (!('value' in descriptor)) throw new CursorError()\n\t\t\t\tif (array && name === 'length') {\n\t\t\t\t\tif (descriptor.value > bounds.maxArrayLength) throw new CursorError()\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!descriptor.enumerable ||\n\t\t\t\t\t(array && (!/^(0|[1-9][0-9]*)$/.test(name) || Number(name) >= current.length))\n\t\t\t\t)\n\t\t\t\t\tthrow new CursorError()\n\t\t\t\tvisit(descriptor.value, depth + 1)\n\t\t\t}\n\t\t} finally {\n\t\t\tancestors.delete(current)\n\t\t}\n\t}\n\tvisit(value, 0)\n}\nfunction aad(\n\tversion: string,\n\tkeyId: string,\n\tbinding: CursorBinding,\n\tnamespace: 'pc' | 'cc',\n): Uint8Array {\n\tcheckDescriptors(binding)\n\tif (binding.clientFilters === undefined || binding.serverFilters === undefined)\n\t\tthrow new CursorError()\n\tconst { table, order, principal, policyVersion, engineVersion, registryVersion } = binding\n\tfor (const field of [table, principal, policyVersion, engineVersion, registryVersion])\n\t\tif (typeof field !== 'string' || !field.length) throw new CursorError()\n\tif (order !== 'asc' && order !== 'desc') throw new CursorError()\n\tfor (const field of [binding.index, binding.parent, binding.tenant])\n\t\tif (field != null && typeof field !== 'string') throw new CursorError()\n\tif (\n\t\t!Array.isArray(binding.relationPath) ||\n\t\tbinding.relationPath.some((part) => typeof part !== 'string')\n\t)\n\t\tthrow new CursorError()\n\treturn encoder.encode(\n\t\tcanonicalConvexBytes(\n\t\t\t{\n\t\t\t\tdomain: namespace === 'pc' ? 'cvx-query-cursor' : 'cvx-custom-cursor',\n\t\t\t\tversion,\n\t\t\t\tkeyId,\n\t\t\t\ttable,\n\t\t\t\tindex: binding.index ?? null,\n\t\t\t\torder,\n\t\t\t\tclientFilters: binding.clientFilters,\n\t\t\t\tserverFilters: binding.serverFilters,\n\t\t\t\trelationPath: binding.relationPath,\n\t\t\t\tparent: binding.parent ?? null,\n\t\t\t\tprincipal,\n\t\t\t\ttenant: binding.tenant ??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