"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperationResponseList=void 0;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),react_router_dom_1=require("react-router-dom"),styled_components_1=__importDefault(require("styled-components")),jotai_1=require("jotai"),Tabs_1=require("../Tabs"),ResponseDetails_1=require("./ResponseDetails"),services_1=require("../../services"),styled_1=require("./styled"),LinkToField_1=require("../common/LinkToField"),utils_1=require("../../utils"),ExpandAllButton_1=require("../ExpandAllButton"),hooks_1=require("../../hooks"),models_1=require("../../models"),app_1=require("../../jotai/app");exports.OperationResponseList=(0,react_1.memo)((({responses:e,renderTitle:t,operationId:s,operationPointer:i,activeResponseTab:r,onTabChange:n,callbackId:o})=>{const a=(0,react_router_dom_1.useLocation)(),l=(0,hooks_1.useTranslate)(),u=(0,jotai_1.useAtomValue)(app_1.activeMimeNameAtom),_=e.map((({code:e})=>({key:e,title:e}))),d=_.find((({key:e})=>e===r||(0,utils_1.pathIncludesLink)(a,s)&&(0,utils_1.pathIncludesLink)(a,`c=${e}`))),{activeTab:p,handleTabChange:c}=(0,Tabs_1.useTabsState)({tabs:_,defaultTab:null==d?void 0:d.key,onChange:n}),m=_.find((e=>e.key===(r||p))),x=e.find((e=>e.code===(null==m?void 0:m.key))),j=(0,react_1.useMemo)((()=>{var e;if(!(null==x?void 0:x.content))return!1;const{schema:t}=(0,models_1.getActiveMediaType)(null==x?void 0:x.content,u)||{};return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.some((({schema:e})=>!e.isPrimitive&&!e.isCircular))}),[u,null==x?void 0:x.content]);return m?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsxs)(TitleWrap,{children:[(null==t?void 0:t(m))||(0,jsx_runtime_1.jsxs)(styled_1.StyledTitle,{children:[(0,jsx_runtime_1.jsx)(LinkToField_1.LinkToField,{to:(0,services_1.makeDeepLink)(s,`response&c=${m.key}`)}),l("openapi.responses","Responses")]}),(0,jsx_runtime_1.jsx)(Tabs_1.Tabs,{tabs:_,activeTab:m,onChange:c}),j&&(0,jsx_runtime_1.jsx)(ExpandAllButton_1.ExpandAllButton,{type:"response",operationPointer:i})]}),x?(0,jsx_runtime_1.jsx)("div",{children:(0,jsx_runtime_1.jsx)(ResponseDetails_1.ResponseDetails,{response:x,operationId:s,callbackId:o})},x.code):null]}):null}));const TitleWrap=(0,styled_components_1.default)(styled_1.Row)`
  flex-wrap: wrap;
  gap: var(--spacing-unit);
`;
//# sourceMappingURL=OperationResponseList.js.map