"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _components = require("@looker/components");

var _runIt = require("@looker/run-it");

var _DocResponseTypes = require("./DocResponseTypes");

var _utils = require("./utils");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var DocResponses = _ref => {
  var {
    api,
    responses
  } = _ref;
  var tabs = (0, _components.useTabs)();
  if (responses.length === 0) return _react.default.createElement(_react.default.Fragment, null);
  var responseTree = (0, _utils.buildResponseTree)(responses);
  return _react.default.createElement(_runIt.CollapserCard, {
    heading: "Response Models",
    id: "response models"
  }, _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_components.TabList, tabs, Object.keys(responseTree).map((statusCode, index) => _react.default.createElement(_components.Tab, {
    key: index
  }, statusCode))), _react.default.createElement(_components.TabPanels, _extends({}, tabs, {
    pt: "0"
  }), Object.values(responseTree).map((responses, index) => _react.default.createElement(_components.TabPanel, {
    key: index
  }, _react.default.createElement(_DocResponseTypes.DocResponseTypes, {
    api: api,
    responses: responses
  }))))));
};

exports.DocResponses = DocResponses;
//# sourceMappingURL=DocResponses.js.map