"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }


var _chunkFYSASWVKcjs = require('./chunk-FYSASWVK.cjs');



var _chunkN3H4E6EHcjs = require('./chunk-N3H4E6EH.cjs');

// src/generators/json-schema.ts
_chunkN3H4E6EHcjs.init_cjs_shims.call(void 0, );
var _promises = require('fs/promises');
function generateJsonSchemaFile(schema, file, config) {
  try {
    const jsonSchema = _chunkN3H4E6EHcjs.getOutputFile.call(void 0, file, "json");
    _chunkFYSASWVKcjs.writeTrace.call(void 0, `Writing JSON schema file ${jsonSchema}`, config);
    return _promises.writeFile.call(void 0, jsonSchema, JSON.stringify(schema, null, 2));
  } catch (error) {
    _chunkFYSASWVKcjs.writeError.call(void 0, 
      `Error writing JSON schema file for ${file.name}

Error:
${_optionalChain([error, 'optionalAccess', _ => _.message]) ? error.message : JSON.stringify(error)}${_optionalChain([error, 'optionalAccess', _2 => _2.stack]) ? `
Stack Trace: ${error.stack}` : ""}

Parsed schema:
${JSON.stringify(schema)}
`,
      config
    );
    throw error;
  }
}



exports.generateJsonSchemaFile = generateJsonSchemaFile;
