"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.differ = exports.diffText = void 0;

var _sdkCodegen = require("@looker/sdk-codegen");

var diffText = (row, status, api, sdkLanguage) => {
  var gen;

  if (sdkLanguage === 'All') {
    gen = new _sdkCodegen.PseudoGen(api);
  } else {
    gen = (0, _sdkCodegen.getCodeGenerator)(sdkLanguage, api);
  }

  var method = api.methods[row.name];
  if (!method) return "".concat(row.name, " is missing");
  var indent = '';
  var result = status ? "Status: ".concat(status, "\n") : '';
  result += gen.methodSignature(indent, method);

  if (row.bodyDiff) {
    var args = method.bodyParams.map(p => gen.declareParameter(indent, method, p));
    result += "\nBody:\n".concat(args.join('\n'));
  }

  if (row.typeDiff) {
    result += "\nMethod type:\n".concat(gen.declareType(indent, method.type));
  }

  if (row.responseDiff) {
    var bump = gen.bumper(indent);
    var items = method.responses.map(r => {
      return "".concat(bump, "Code: ").concat(r.statusCode, "\n").concat(bump, "MIME: ").concat(r.mediaType, "\n").concat(bump, "Type:").concat(r.type.fullName);
    });
    result += "\nResponses:\n".concat(items.join('\n'));
  }

  return result;
};

exports.diffText = diffText;

var differ = (row, leftSpec, rightSpec, sdkLanguage) => {
  var lhs = diffText(row, row.lStatus !== row.rStatus ? row.lStatus : '', leftSpec, sdkLanguage);
  var rhs = diffText(row, row.lStatus !== row.rStatus ? row.rStatus : '', rightSpec, sdkLanguage);
  return {
    lhs,
    rhs
  };
};

exports.differ = differ;
//# sourceMappingURL=docDiffUtils.js.map