{"version":3,"file":"lazy.cjs","names":["BaseSchema"],"sources":["../../src/schemas/lazy.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport { BaseSchema } from \"../core/base\";\nimport type { CombinedStandardProps, Schema } from \"../core/types\";\n\nexport class LazySchema<I, O> extends BaseSchema<I, O> {\n  private readonly getter: () => Schema<I, O>;\n  private cached?: Schema<I, O>;\n\n  constructor(getter: () => Schema<I, O>) {\n    super();\n    this.getter = getter;\n    this.jsonSchema = { $ref: \"#/definitions/lazy\" };\n  }\n\n  private resolve(): Schema<I, O> {\n    if (!this.cached) {\n      this.cached = this.getter();\n    }\n    return this.cached;\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<I, O> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.resolve().jsonSchema ?? {},\n        output: () => this.resolve().jsonSchema ?? {},\n      },\n      validate: (value: unknown) =>\n        this.resolve()[\"~standard\"].validate(value) as StandardSchemaV1.Result<O>,\n      types: {\n        input: {} as I,\n        output: {} as O,\n      },\n    };\n  }\n}\n"],"mappings":";;AAIA,IAAa,aAAb,cAAsCA,aAAAA,WAAiB;CACrD;CACA;CAEA,YAAY,QAA4B;EACtC,MAAM;EACN,KAAK,SAAS;EACd,KAAK,aAAa,EAAE,MAAM,qBAAqB;CACjD;CAEA,UAAgC;EAC9B,IAAI,CAAC,KAAK,QACR,KAAK,SAAS,KAAK,OAAO;EAE5B,OAAO,KAAK;CACd;CAEA,KAAK,eAA4C;EAC/C,OAAO;GACL,SAAS;GACT,QAAQ;GACR,YAAY;IACV,aAAa,KAAK,QAAQ,CAAC,CAAC,cAAc,CAAC;IAC3C,cAAc,KAAK,QAAQ,CAAC,CAAC,cAAc,CAAC;GAC9C;GACA,WAAW,UACT,KAAK,QAAQ,CAAC,CAAC,YAAY,CAAC,SAAS,KAAK;GAC5C,OAAO;IACL,OAAO,CAAC;IACR,QAAQ,CAAC;GACX;EACF;CACF;AACF"}