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AAG;AACrD,IAAA,IAAI,UAAA,KAAe,MAAA,EAAW,MAAA,CAAO,GAAG,CAAA,GAAI,UAAA;AAAA,EAC9C;AACA,EAAA,OAAO,MAAA;AACT;AAUO,SAAS,WAAc,KAAA,EAAa;AACzC,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,UAAU,OAAO,KAAA;AACxD,EAAA,IAAI,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG,OAAO,KAAA;AACnC,EAAA,KAAA,MAAW,MAAA,IAAU,MAAA,CAAO,MAAA,CAAO,KAAgC,CAAA,EAAG;AACpE,IAAA,UAAA,CAAW,MAAM,CAAA;AAAA,EACnB;AACA,EAAA,OAAO,MAAA,CAAO,OAAO,KAAK,CAAA;AAC5B","file":"chunk-BXHAPCQG.cjs","sourcesContent":["/**\n * Predicate for values that are materially present in database rows.\n */\nexport function isPresent(value: unknown): boolean {\n  return value !== null && value !== undefined;\n}\n\n/**\n * Narrows a value after a runtime presence check. Prefer this to a non-null\n * assertion: an invalid invariant fails at the point where it is assumed,\n * with a stable error instead of propagating `undefined` into unrelated code.\n */\nexport function requireDefined<T>(\n  value: T,\n  message = \"Expected a defined value.\",\n): NonNullable<T> {\n  if (value === undefined || value === null) throw new TypeError(message);\n  return value;\n}\n","/**\n * Plain-object predicate. Excludes class instances (Date, Map, Set,\n * RegExp, Buffer, …) and arrays. Used wherever the caller needs to\n * distinguish a literal `{}` from anything else — e.g. JSON-value\n * validation and runtime-document structural checks.\n */\nexport function isPlainObject(\n  value: unknown,\n): value is Record<string, unknown> {\n  if (typeof value !== \"object\" || value === null) return false;\n  const prototype: unknown = Object.getPrototypeOf(value);\n  return prototype === Object.prototype || prototype === null;\n}\n\n/**\n * Own-key membership for a bag whose KEYS ARE DATA — a props record parsed out\n * of a JSON column, a JSON-Schema `properties` map, a serialized-schema kind\n * table. The single owner of that question; every path asking it calls here.\n *\n * `in` is the wrong operator for these bags because it also finds inherited\n * members: `\"toString\" in {}` is `true`, as are `\"constructor\"`, `\"valueOf\"`,\n * `\"__proto__\"`, and the rest of `Object.prototype`. A bag that does NOT carry\n * the key therefore reads as if it does, and the `bag[key]` read that follows\n * yields the inherited member instead of stored data.\n *\n * Reachable, and not through anything exotic: a schema may DECLARE a field named\n * after a prototype member — `z.object({ toString: z.string() })` is an ordinary\n * schema — and such a field survives validation, storage, and the JSON round-trip\n * as normal data. (`__proto__` is the narrower case: Zod drops an own `__proto__`\n * key and `bag[\"__proto__\"] = value` assigns a prototype rather than creating one,\n * so no validated write produces it — but the unvalidated trusted import writes a\n * caller's bag verbatim, and JSON parses `__proto__` back as an own key.)\n *\n * `in` remains correct — and stays in use — where the key set is statically\n * known: a discriminated union's tag, a capability probe, a brand check. The\n * distinction is whether the key came from data or from the code.\n */\nexport function hasOwnKey(\n  bag: Readonly<Record<string, unknown>>,\n  key: string,\n): boolean {\n  return Object.hasOwn(bag, key);\n}\n\n/**\n * Own-key read of a data-keyed bag: an absent key reads `undefined`, never an\n * inherited `Object.prototype` member. The read companion to {@link hasOwnKey}\n * (see its doc for why `bag[key]` alone is wrong for these bags), and like it\n * the single owner — every path reading a data-keyed bag by a data-supplied\n * key calls here rather than re-spelling the guard.\n */\nexport function readOwnProperty(\n  bag: Readonly<Record<string, unknown>>,\n  key: string,\n): unknown {\n  return hasOwnKey(bag, key) ? bag[key] : undefined;\n}\n\n/**\n * Creates an accumulator whose KEYS ARE DATA — a kind name, a property name, a\n * JSON-Schema keyword, an entity's property bag. The write-side companion to\n * {@link hasOwnKey} / {@link readOwnProperty}, and like them the single owner\n * of the question: every accumulator keyed by data is built here.\n *\n * Null-prototype, because `bag[key] = value` on a `{}` literal does NOT create\n * an entry when `key` is `__proto__`: it invokes `Object.prototype`'s\n * `__proto__` SETTER, which either reparents the bag (object value) or does\n * nothing at all (primitive value). Either way the value is silently dropped,\n * and every later own-key read answers as if the writer never wrote it — the\n * write-side mirror of the inherited-member read `hasOwnKey` exists to prevent.\n *\n * Reachable, and not through anything exotic: kind names are validated against\n * `/^[A-Za-z_][A-Za-z0-9_]*$/`, which admits `__proto__` (as it does\n * `toString` and `constructor`); extension property names are unrestricted\n * apart from a reserved list; and `JSON.parse` yields `__proto__` as an\n * ordinary own key, so any document read off disk or the wire can carry one.\n *\n * A plain `{}` remains correct — and stays in use — for records whose keys are\n * statically known: an options object, a discriminated-union member, a fixed\n * lookup table.\n *\n * ## Spread it at the boundary\n *\n * The null prototype is an INTERNAL write-side protection, not something a\n * caller asked for. A bag that escapes into a value this library RETURNS must\n * be copied with a spread — `return { ...bag }` — at that boundary: returned\n * as-is it has no `toString`, no `hasOwnProperty`, and answers `false` to\n * `instanceof Object`, which is a public behavior change against every other\n * object the library hands back. The spread is safe precisely where a\n * key-by-key rebuild would not be: it copies own properties with\n * CreateDataProperty rather than Set, so an own `__proto__` key survives the\n * copy while `Object.prototype` is restored.\n */\nexport function createDataKeyedBag<T>(): Record<string, T> {\n  return Object.create(null) as Record<string, T>;\n}\n\n/**\n * The two property names JavaScript itself probes on an arbitrary object:\n * `then` (the thenable check promise adoption performs) and `toJSON` (the hook\n * `JSON.stringify` looks for). A proxy standing in for data resolves them to\n * `undefined` so it is not mistaken for a promise and does not break\n * serialization.\n */\nconst INTEROP_PROBE_KEYS: ReadonlySet<string> = new Set([\"then\", \"toJSON\"]);\n\n/**\n * True if `key` is a name the language probes for a protocol rather than a name\n * a caller asked for. The single owner of WHICH names those are — the companion\n * to, not a substitute for, the question of whether the name is data\n * (`hasOwnKey` for a materialized bag, `SchemaIntrospector.hasDeclaredField`\n * for a proxy whose key set is the schema).\n *\n * **This predicate is a fallback, never a short-circuit.** `then` and `toJSON`\n * are ordinary identifiers: `z.object({ toJSON: z.string() })` is a legal\n * schema, and such a field is stored, validated, and round-tripped as data like\n * any other. A trap that answers `undefined` for these names BEFORE consulting\n * the data it fronts therefore drops a declared field — the read side of the\n * same mistake `hasOwnKey` fixes on the write side. Ask the data question\n * first; reach for this only once the answer is \"not data\", where resolving to\n * `undefined` keeps `await` and `JSON.stringify` working on a partial object.\n *\n * Returning stored data for an own `then` is safe as well as correct: props\n * come from a JSON column, so the value can never be callable, and the thenable\n * check ignores a non-callable `then` exactly as it does on the plain objects\n * the non-selective path returns.\n */\nexport function isInteropProbeKey(key: string): boolean {\n  return INTEROP_PROBE_KEYS.has(key);\n}\n\n/**\n * Builds an object dropping any keys whose value is `undefined`.\n *\n * Lets callers construct discriminated-union members and `defineNode` /\n * `defineEdge` option objects without tripping over\n * `exactOptionalPropertyTypes: true` — which forbids setting `optional:\n * undefined` on a type that declares `optional?: boolean`. The cast keeps\n * call sites readable; this helper is the single typed seam.\n */\nexport function compactUndefined<T extends object>(value: {\n  [K in keyof T]: T[K] | undefined;\n}): T {\n  const result: Record<string, unknown> = {};\n  for (const [key, fieldValue] of Object.entries(value)) {\n    if (fieldValue !== undefined) result[key] = fieldValue;\n  }\n  return result as T;\n}\n\n/**\n * Recursively `Object.freeze` every plain object / array reachable from\n * `value`. Already-frozen branches are skipped. Returns the input for\n * convenient chaining; the freeze is in-place.\n *\n * Class instances and other non-plain values are left alone — only their\n * containers freeze.\n */\nexport function freezeDeep<T>(value: T): T {\n  if (value === null || typeof value !== \"object\") return value;\n  if (Object.isFrozen(value)) return value;\n  for (const nested of Object.values(value as Record<string, unknown>)) {\n    freezeDeep(nested);\n  }\n  return Object.freeze(value);\n}\n"]}