import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{useMemo}from"react";import{breakpoints,LayoutVariant,OpenApiHeader}from"@redocly/theme";import{useAtomValue}from"jotai";import styled from"styled-components";import{PageFooter}from"../PageFooter";import{globalOptionsAtom}from"../../jotai/store";import{RenderHook}from"../RenderHook";import{RightPanel}from"../RightPanel";import{layoutAtom}from"../../jotai/app";import{Row,SamplesMiddlePanel,SamplesPanel}from"../common";import{Items}from"../ContentItems/Items";import{ContentItem}from"../ContentItem";export function SectionContent({items:e,hideFooterAndHeader:t}){const{unstable_hooks:{MiddlePanelHeader:o},routingBasePath:a}=useAtomValue(globalOptionsAtom),n=useAtomValue(layoutAtom),i=n===LayoutVariant.STACKED,r=useMemo((()=>t?null:_jsx(MiddlePanelWrapper,{isStacked:i,children:_jsx(PageFooter,{})})),[t,i]),s=useMemo((()=>t||!OpenApiHeader&&!o?null:_jsx(MiddlePanelWrapper,{isStacked:i,children:o?_jsx(RenderHook,{Hook:o,props:void 0}):_jsx(OpenApiHeader,{})})),[o,t,i]);return 0===e.length?null:_jsxs(_Fragment,{children:[s,_jsxs(Row,{layout:n,children:[_jsx(SectionContainer,{layout:n,children:e.filter((({type:e})=>"section"===e)).map((e=>_jsx(ContentItem,{item:e,routingBasePath:a,children:_jsx(Items,{items:e.items,routingBasePath:a})},e.id)))}),_jsx(RightPanelContainer,{isStacked:i,tabIndex:0,children:_jsx(RightPanel,{item:e[0]})})]}),e.filter((({type:e})=>"section"!==e)).map((e=>_jsx(ContentItem,{item:e,routingBasePath:a,children:_jsx(Items,{items:e.items,routingBasePath:a})},e.id))),r]})}const MiddlePanelWrapper=styled(SamplesMiddlePanel)`
  align-self: flex-start;
  padding-top: var(--panel-gap-vertical);
  padding-bottom: var(--panel-gap-vertical);
`;export const SectionContainer=styled.div`
  width: 100%;

  @media screen and (min-width: ${breakpoints.large}) {
    width: ${({layout:e})=>e===LayoutVariant.STACKED?"100%":"calc(100% - var(--panel-samples-width))"};
  }
`;export const RightPanelContainer=styled(SamplesPanel)`
  margin: var(--spacing-base) 0;
`;
//# sourceMappingURL=SectionContent.js.map