"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OperationsNavigation=void 0,exports.OperationsNavigationComponent=OperationsNavigationComponent;const jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),react_router_dom_1=require("react-router-dom"),theme_1=require("@redocly/theme"),styled_components_1=__importDefault(require("styled-components")),index_1=require("jotai/index"),common_1=require("../common"),app_1=require("../../jotai/app"),OperationNavigationItems_1=require("./OperationNavigationItems"),styled_1=require("./styled"),hooks_1=require("../../hooks"),MAX_OPERATIONS=8;function OperationsNavigationComponent({items:e,routingBasePath:t}){const o=(0,hooks_1.useTranslate)(),[a,i]=(0,react_1.useState)(!1),n=(0,react_router_dom_1.useNavigate)(),r=(0,index_1.useAtomValue)(app_1.layoutAtom)===theme_1.LayoutVariant.STACKED,{operations:s,webhooks:p,count:u}=(0,react_1.useMemo)((()=>{const t=e.filter((e=>"operation"===e.type)),o=a?t:t.slice(0,MAX_OPERATIONS),{operations:i,webhooks:n}=o.reduce(((e,t)=>(t.isWebhook?e.webhooks.push(t):e.operations.push(t),e)),{operations:[],webhooks:[]});return{operations:i,webhooks:n,count:!a&&t.length>MAX_OPERATIONS?t.length-MAX_OPERATIONS:0}}),[a,e]),_=(0,react_1.useCallback)((e=>n(e)),[n]);return s.length||p.length?(0,jsx_runtime_1.jsxs)(Wrapper,{isStacked:r,"data-testid":"operation-navigation-list",children:[s.length>0&&(0,jsx_runtime_1.jsx)(OperationNavigationItems_1.OperationNavigationItems,{items:s,onClick:_,routingBasePath:t,translate:o,title:o("openapi.operations","Operations")}),p.length>0&&(0,jsx_runtime_1.jsx)(OperationNavigationItems_1.OperationNavigationItems,{items:p,onClick:_,routingBasePath:t,translate:o,title:o("openapi.webhooks","Webhooks")}),!a&&Boolean(u)&&(0,jsx_runtime_1.jsxs)(styled_1.StyledButton,{variant:"link",size:"large","data-testid":"show-more-operations",fullWidth:!0,onClick:()=>i(!0),children:[o("openapi.actions.show","Show")," ",u," ",o("openapi.actions.more","more"),"..."]})]}):null}exports.OperationsNavigation=(0,react_1.memo)(OperationsNavigationComponent);const Wrapper=(0,styled_components_1.default)(common_1.SamplesPanel)`
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxs);
  padding-top: var(--spacing-xxl);
`;
//# sourceMappingURL=OperationsNavigation.js.map