import cloneDeep from 'lodash/cloneDeep';
import { compareSpecs } from '@looker/sdk-codegen';
export var allDiffToggles = ['missing', 'status', 'params', 'type', 'body', 'response'];
export var standardDiffToggles = ['missing', 'params', 'type', 'body', 'response'];
export var diffSpecs = (lhs, rhs, options) => {
  var includeOptions = (delta, lMethod, rMethod) => options.includes('missing') && (!lMethod || !rMethod) || options.includes('status') && delta.lStatus !== delta.rStatus || options.includes('params') && !!delta.paramsDiff || options.includes('type') && !!delta.typeDiff || options.includes('body') && !!delta.bodyDiff || options.includes('response') && !!delta.responseDiff;

  return compareSpecs(lhs, rhs, includeOptions);
};

var addMethodToTags = (tags, method) => {
  for (var tag of method.schema.tags) {
    var list = tags[tag];

    if (!list) {
      list = {};
      tags[tag] = list;
    }

    list[method.name] = method;
  }

  return tags;
};

export var diffToSpec = (delta, lSpec, rSpec) => {
  var result = cloneDeep(lSpec);
  result.tags = {};
  result.methods = {};
  delta.forEach(row => {
    var name = row.name;
    var method = lSpec.methods[name];
    if (!method) method = rSpec.methods[name];
    result.methods[name] = method;
    addMethodToTags(result.tags, method);
  });
  result.types = {};
  return result;
};
//# sourceMappingURL=diffUtils.js.map