import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{memo,useMemo}from"react";import{Navigate,Route,Routes}from"react-router-dom";import{getFirstPageLink,getItemsByType}from"./helpers";import{SectionContent}from"../SectionContent";function ContentItemsComponent({items:e,root:t=!1}){const o="/",{rootItem:n}=getItemsByType(e),s=!t||n?o:getFirstPageLink(e,o),m=useMemo((()=>_jsxs(Routes,{children:[n&&_jsx(Route,{path:`${n.href||o}*`,element:_jsx(SectionContent,{items:e})}),_jsx(Route,{path:"*",element:_jsx(Navigate,{to:s,replace:!0})})]})),[n,o,e,s]);return t&&!e.length?_jsx(Routes,{children:_jsx(Route,{path:"*",element:_jsx(SectionContent,{items:e})})}):e.length?_jsx(_Fragment,{children:m}):null}export const ContentItems=memo(ContentItemsComponent);
//# sourceMappingURL=ContentItems.js.map