{"version":3,"file":"bigint.cjs","names":["BaseSchema"],"sources":["../../src/schemas/bigint.ts"],"sourcesContent":["import { BaseSchema } from \"../core/base\";\nimport type { CombinedStandardProps } from \"../core/types\";\n\nexport class BigIntSchemaType extends BaseSchema<unknown, bigint> {\n  private _min?: bigint;\n  private _max?: bigint;\n\n  constructor() {\n    super();\n    this.jsonSchema = { type: \"integer\", format: \"bigint\" };\n  }\n\n  /**\n   * Require minimum bigint value.\n   * @param {bigint} n Minimum value.\n   * @returns {BigIntSchemaType} New constrained schema.\n   */\n  min(n: bigint): BigIntSchemaType {\n    const schema = new BigIntSchemaType();\n    Object.assign(schema, this);\n    schema._min = n;\n    schema.jsonSchema = { ...this.jsonSchema, minimum: n.toString() };\n    return schema;\n  }\n\n  /**\n   * Require maximum bigint value.\n   * @param {bigint} n Maximum value.\n   * @returns {BigIntSchemaType} New constrained schema.\n   */\n  max(n: bigint): BigIntSchemaType {\n    const schema = new BigIntSchemaType();\n    Object.assign(schema, this);\n    schema._max = n;\n    schema.jsonSchema = { ...this.jsonSchema, maximum: n.toString() };\n    return schema;\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<unknown, bigint> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        if (this._coerce && typeof value !== \"bigint\") {\n          try {\n            if (\n              typeof value === \"string\" ||\n              typeof value === \"number\" ||\n              typeof value === \"boolean\"\n            ) {\n              value = BigInt(value);\n            }\n          } catch {\n            // fallthrough\n          }\n        }\n        if (typeof value !== \"bigint\") {\n          return { issues: [{ message: `Expected bigint, received ${typeof value}` }] };\n        }\n        if (this._min !== undefined && value < this._min) {\n          return { issues: [{ message: `BigInt less than ${this._min}` }] };\n        }\n        if (this._max !== undefined && value > this._max) {\n          return { issues: [{ message: `BigInt greater than ${this._max}` }] };\n        }\n        return { value };\n      },\n      types: {\n        input: {} as unknown,\n        output: 0n as bigint,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