{"version":3,"file":"schema.cjs","sources":["../../../src/utils/schema.ts"],"sourcesContent":["// src/utils/schema.ts\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport type { ZodTypeAny } from 'zod';\n\n/** Checks if a schema is a Zod schema by looking for the _def property */\nexport function isZodSchema(schema: unknown): schema is ZodTypeAny {\n  return (\n    schema != null && typeof schema === 'object' && '_def' in (schema as object)\n  );\n}\n\n/**\n * Converts a schema to JSON schema format.\n * Handles both Zod schemas (converts) and JSON schemas (passthrough).\n */\nexport function toJsonSchema(\n  schema: unknown,\n  name?: string,\n  description?: string\n): Record<string, unknown> {\n  if (isZodSchema(schema)) {\n    const zodSchema = schema as ZodTypeAny & {\n      describe: (desc: string) => ZodTypeAny;\n    };\n    const described =\n      description != null && description !== ''\n        ? zodSchema.describe(description)\n        : schema;\n    return zodToJsonSchema(\n      described as Parameters<typeof zodToJsonSchema>[0],\n      name ?? ''\n    );\n  }\n  return schema as Record<string, unknown>;\n}\n"],"names":["zodToJsonSchema"],"mappings":";;;;AAAA;AAIA;AACM,SAAU,WAAW,CAAC,MAAe,EAAA;AACzC,IAAA,QACE,MAAM,IAAI,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAK,MAAiB;AAEhF;AAEA;;;AAGG;SACa,YAAY,CAC1B,MAAe,EACf,IAAa,EACb,WAAoB,EAAA;AAEpB,IAAA,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,SAAS,GAAG,MAEjB;QACD,MAAM,SAAS,GACb,WAAW,IAAI,IAAI,IAAI,WAAW,KAAK;AACrC,cAAE,SAAS,CAAC,QAAQ,CAAC,WAAW;cAC9B,MAAM;QACZ,OAAOA,+BAAe,CACpB,SAAkD,EAClD,IAAI,IAAI,EAAE,CACX;IACH;AACA,IAAA,OAAO,MAAiC;AAC1C;;;;;"}