import*as e from"react";import{useEffect as c}from"react";import{Outlet as E,useLocation as d,useNavigate as g}from"react-router-dom";import{withoutPathPrefix as h}from"@redocly/theme/core/utils";import{useThemeConfig as P}from"@redocly/theme/core/hooks";import{InternalServerErrorLayout as D}from"@redocly/theme/layouts/InternalServerErrorLayout";import{RootLayout as S}from"@redocly/theme/layouts/RootLayout";import{PageLayout as T}from"@redocly/theme/layouts/PageLayout";import{components as L}from"@redocly/theme/markdoc/default";import{Sidebar as v}from"./app/Sidebar/Sidebar";import{loadAndNavigate as _}from"./app/utils/loadAndNavigate";import{useActions as C}from"./app/Sidebar/useActions";import{useScrollTracker as y}from"./app/hooks/useScrollTracker";import{useAutoScroll as A}from"./app/hooks/useAutoScroll";import{OPENAPI_DOCS_TEMPLATE_ID as N,ASYNC_API_DOCS_TEMPLATE_ID as O,GRAPHQL_TEMPLATE_ID as R}from"../constants/common";import{removeTrailingSlash as I}from"../utils/url/remove-trailing-slash";import{removeLeadingSlash as M}from"../utils/url/remove-leading-slash";import*as k from"./app/markdoc/custom-components/index";import{DefaultStyles as b}from"./styling/default-styles";import{ThemeDataProvider as x}from"./providers/theme/ThemeDataProvider";import{PageDataContext as B}from"./providers/page-data/PageDataContext";import{SeoTags as G}from"./app/seo/SeoTags";import{useRouterForLocalLinks as V,useRunningEnvironmentCheck as F}from"./providers/hooks";import{usePageData as w,usePageDataLoader as H}from"./providers/page-data/hooks";import{ErrorBoundary as Q}from"./ErrorBoundary";import{ErrorDetails as u,Loader as U}from"./server-entry";import"@styles";import{useRouteChangeTracker as Y}from"./app/hooks/useRouteChangeTracker";import{isInIframe as j}from"./utils";import{useL10n as q}from"./app/l10n";import{PostMessageProvider as z}from"./providers/post-message/PostMessageProvider";import{ScriptLoader as J}from"./ScriptLoader";import{clientRoutes as K}from"./runtime/generated/routes.js";import{DevModeFloatingBar as W}from"./app/DevModeFloatingBar";import{usePageTimeTracker as X}from"./app/hooks/usePageTimeTracker";import{useMarkdocRenderer as Z}from"./app/hooks/markdown/useMarkdocRenderer";globalThis.__LOADER.markdocComponents={...k,...L};function ke(){const o=H(),[a,n]=e.useState(o),r=d(),m=g();q();const s=e.useMemo(()=>function(){const{palette:p}=P();return e.createElement(b,{palette:p})},[]);c(()=>{o?n(o):_({navigate:m,to:r.pathname+r.search+r.hash}).then(()=>n(U.loadSync(r.pathname)))},[r,m]),V();const t=F();return t?(console.log(t),e.createElement(u,{error:{message:t,name:""}})):a?e.createElement(Q,null,e.createElement(B.Provider,{value:o||a},e.createElement(x,null,e.createElement(s,null),e.createElement(z,{enabled:process.env.NODE_ENV==="development"||j()},e.createElement(E,null))))):null}function f(){Y(),X(),y(),A();const o=w(),a=C(),{layout:n}=a,r={layout:n},m=process.env.NODE_ENV!=="production",s=globalThis.SSR_OMIT_SUSPENSE,t=Z(o?.props?.ast),l=I(o?.slug||"");if(c(()=>{document.documentElement.classList.add("ready")},[]),o?.props.pagePropGetterError?.message)return m?e.createElement(u,{error:{...o?.props?.pagePropGetterError}}):e.createElement(D,null);if(!!o?.props?.compilationErrors?.length)return o?.Template?e.createElement(o.Template,{pageProps:o?.props,children:t}):null;const i=()=>e.createElement(S,null,e.createElement(T,{sidebar:e.createElement(v,{layoutControls:a})},e.createElement(G,{seo:o?.props.seo,slug:l}),o?.Template?e.createElement(o.Template,{pageProps:[N,O,R].includes(o.templateId)?{...o.props,apiOptions:r}:o?.props,children:t}):null),process.env.NODE_ENV!=="production"&&e.createElement(W,null),e.createElement(J,null));return s?i():e.createElement(e.Suspense,null,i())}const be=[...K.map(o=>({Component:f,path:M(h(o).substring(1)+"/*")})),{Component:f,path:"*"}];export{ke as App,f as Page,be as routes};
