'use strict';

var chunkZ7S7UHLW_cjs = require('./chunk-Z7S7UHLW.cjs');
var chunkQHAPK6PL_cjs = require('./chunk-QHAPK6PL.cjs');

// ../../node_modules/.pnpm/@standard-community+standard-openapi@0.2.9_@standard-community+standard-json@0.3.5_@sta_a8f2af4507f30d3c5e839067d4aa4952/node_modules/@standard-community/standard-openapi/dist/valibot-D_HTw1Gn.js
function getToOpenAPISchemaFn() {
  return async (schema, context) => {
    const openapiSchema = await chunkQHAPK6PL_cjs.toJsonSchema(schema, {
      errorMode: "ignore",
      // @ts-expect-error
      overrideAction: ({ valibotAction, jsonSchema }) => {
        const _jsonSchema = chunkZ7S7UHLW_cjs.convertToOpenAPISchema(jsonSchema, context);
        if (valibotAction.kind === "metadata" && valibotAction.type === "metadata" && !("$ref" in _jsonSchema)) {
          const metadata = valibotAction.metadata;
          if (metadata.example !== void 0) {
            _jsonSchema.example = metadata.example;
          }
          if (metadata.examples && metadata.examples.length > 0) {
            _jsonSchema.examples = metadata.examples;
          }
          if (metadata.ref) {
            context.components.schemas = {
              ...context.components.schemas,
              [metadata.ref]: _jsonSchema
            };
            return {
              $ref: `#/components/schemas/${metadata.ref}`
            };
          }
        }
        return _jsonSchema;
      },
      ...context.options
    });
    if ("$schema" in openapiSchema) {
      delete openapiSchema.$schema;
    }
    return openapiSchema;
  };
}

module.exports = getToOpenAPISchemaFn;
//# sourceMappingURL=valibot-D_HTw1Gn-CTPUDOX5.cjs.map
//# sourceMappingURL=valibot-D_HTw1Gn-CTPUDOX5.cjs.map