import{u as M}from"./navigation-BzNQiq4W.js";import{d as C,e as $,r as w,f as D,w as _,u as k,b as X,o as B,g as P,h as p,m as S}from"./index-DPl1iiyq.js";import{r as b,G as T}from"./Guide-Cg_R_4Uy.js";import"./__vite-browser-external-D7Ct-6yo.js";function L(s){return class extends s.Component{constructor(o){super(o),this.state={error:null}}static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,c){console.error("MDX Error Boundary caught an error:",o,c)}render(){return this.state.error?s.createElement("div",{className:"mdx-render-error"},`Error rendering MDX: ${this.state.error.message}`):this.props.children}}}const N={class:"mdx-content editor-content editor-static"},q=C({__name:"GuideMdxLoader",props:{project:{},page:{},version:{},versionNames:{},headerLinks:{},guide:{}},setup(s){const t=s,o=$(),{isDarkMode:c}=M(),{state:r,fileHashes:g}=k(),a=w(null),n={value:null};D(async()=>{const e=document.querySelector("#prebuilt-mdx-app");e&&(a.value=e,console.log("Prebuilt MDX App mounted. Target element:",a.value),await l())}),_([()=>g[t.page.uid],()=>t.page.uid],async()=>{console.log("MDX page change",t.page.uid),await l()});async function d(e){try{return await import(e)}catch(i){throw console.log(i),new Error(`Failed to import required module at: ${e}`)}}async function l(){if(console.debug(`Loading MDX page. hydrationTarget.value = ${a.value}, state.assetsConfig = ${JSON.stringify(r.assetsConfig)}`),!(!a.value||!r.assetsConfig))try{const e=r.mdxOutputPaths[t.page.uid],i=await d(`${r.assetsConfig.prefix||r.assetsConfig.dir}/${e}`);n.value&&n.value.unmount();const m=`${r.assetsConfig?.prefix||r.assetsConfig?.dir}/${r.mdxOutputPaths.react}`,{createRoot:f,jsx:h,React:u,flushSync:v}=await d(m);v(()=>{const x=L(u),y=h(i.default,{}),E=u.createElement(u.Suspense,{fallback:"Loading..."},u.createElement(x,null,y));n.value=f(a.value),n.value.render(E)}),b(o,c)}catch(e){a.value&&(a.value.innerHTML=`
      <div class="error">Error rendering page ${t.page.title} at ${r.mdxOutputPaths[t.page.uid]}: ${e instanceof Error?e.message:String(e)}</div>
      <pre class="error-details">${e instanceof Error&&e.stack?e.stack:""}</pre>`.trim())}}return(e,i)=>(B(),X(T,S(t,{guide:e.guide,headings:{},html:""}),{"mdx-content":P(()=>[p("div",N,[p("div",{id:"prebuilt-mdx-app",ref_key:"hydrationTarget",ref:a,class:"page-node"},null,512)])]),_:1},16,["guide"]))}});export{q as default};
