{"version":3,"file":"zod-registry.cjs","names":["$ZodRegistry","schemaMetaRegistry"],"sources":["../../../src/graph/zod/zod-registry.ts"],"sourcesContent":["// @ts-expect-error If zod/v4 is not imported, the module augmentation will fail in build\nimport type { ZodType } from \"zod/v4\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\n// @ts-expect-error If zod/v4-mini is not imported, the module augmentation will fail in build\nimport type { ZodMiniType } from \"zod/v4-mini\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\nimport type * as core from \"zod/v4/core\";\nimport { getInteropZodDefaultGetter } from \"@langchain/core/utils/types\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport {\n  type ReducedZodChannel,\n  type SchemaMeta,\n  type SchemaMetaRegistry,\n  schemaMetaRegistry,\n} from \"./meta.js\";\n\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport class LanggraphZodMetaRegistry<\n  Meta extends SchemaMeta = SchemaMeta,\n  Schema extends $ZodType = $ZodType,\n> extends $ZodRegistry<Meta & { [key: string]: unknown }, Schema> {\n  /**\n   * Creates a new LanggraphZodMetaRegistry instance.\n   *\n   * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n   */\n  constructor(protected parent: SchemaMetaRegistry) {\n    super();\n    // Use the parent's map for metadata storage\n    this._map = this.parent._map as Map<\n      Schema,\n      $replace<Meta & { [key: string]: unknown }, Schema>\n    >;\n  }\n\n  add<S extends Schema>(\n    schema: S,\n    ..._meta: undefined extends Meta & { [key: string]: unknown }\n      ? [$replace<Meta & { [key: string]: unknown }, S>?]\n      : [$replace<Meta & { [key: string]: unknown }, S>]\n  ): this {\n    const firstMeta = _meta[0];\n    if (firstMeta && !firstMeta?.default) {\n      const defaultValueGetter = getInteropZodDefaultGetter(schema);\n      if (defaultValueGetter != null) {\n        // eslint-disable-next-line no-param-reassign\n        firstMeta.default = defaultValueGetter;\n      }\n    }\n    return super.add(schema, ..._meta);\n  }\n}\n\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n  export interface ZodType<\n    out Output = unknown,\n    out Input = unknown,\n    out Internals extends core.$ZodTypeInternals<Output, Input> =\n      core.$ZodTypeInternals<Output, Input>,\n  > extends core.$ZodType<Output, Input, Internals> {\n    register<\n      R extends LanggraphZodMetaRegistry,\n      TOutput = core.output<this>,\n      TInput = core.input<this>,\n      TInternals extends core.$ZodTypeInternals<TOutput, TInput> =\n        core.$ZodTypeInternals<TOutput, TInput>,\n    >(\n      registry: R,\n      meta: SchemaMeta<TOutput, TInput>\n    ): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n  }\n}\n\ndeclare module \"zod/v4-mini\" {\n  export interface ZodMiniType<\n    out Output = unknown,\n    out Input = unknown,\n    out Internals extends core.$ZodTypeInternals<Output, Input> =\n      core.$ZodTypeInternals<Output, Input>,\n  > extends core.$ZodType<Output, Input, Internals> {\n    register<\n      R extends LanggraphZodMetaRegistry,\n      TOutput = core.output<this>,\n      TInput = core.input<this>,\n      TInternals extends core.$ZodTypeInternals<TOutput, TInput> =\n        core.$ZodTypeInternals<TOutput, TInput>,\n    >(\n      registry: R,\n      meta: SchemaMeta<TOutput, TInput>\n    ): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n  }\n}\n\nexport const registry = new LanggraphZodMetaRegistry(schemaMetaRegistry);\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,IAAa,2BAAb,cAGUA,YAAAA,aAAwD;;;;;;CAMhE,YAAY,QAAsC;AAChD,SAAO;AADa,OAAA,SAAA;AAGpB,OAAK,OAAO,KAAK,OAAO;;CAM1B,IACE,QACA,GAAG,OAGG;EACN,MAAM,YAAY,MAAM;AACxB,MAAI,aAAa,CAAC,WAAW,SAAS;GACpC,MAAM,sBAAA,GAAA,4BAAA,4BAAgD,OAAO;AAC7D,OAAI,sBAAsB,KAExB,WAAU,UAAU;;AAGxB,SAAO,MAAM,IAAI,QAAQ,GAAG,MAAM;;;AA8CtC,MAAa,WAAW,IAAI,yBAAyBC,aAAAA,mBAAmB"}