import{d as _,e as w,f as C,r as m,g as $,w as k,u as X,b as S,o as B,h as P,i as f,m as b}from"./index-BX34W763.js";import{h as T,G as L}from"./Guide-u83ZxDpN.js";import"./__vite-browser-external-D7Ct-6yo.js";import"./DocumentMobileHeader.vue-CXp3gXuT.js";function N(i){return class extends i.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?i.createElement("div",{className:"mdx-render-error"},`Error rendering MDX: ${this.state.error.message}`):this.props.children}}}const G={class:"mdx-content editor-content editor-static"},R=_({__name:"GuideMdxLoader",props:{project:{},page:{},version:{},versionNames:{},headerLinks:{},guide:{}},setup(i){const t=i,o=w(),{isDarkMode:c}=C(),{state:r,fileHashes:h}=X(),a=m(null),d={value:null},l=m({});$(async()=>{const e=document.querySelector("#prebuilt-mdx-app");e&&(a.value=e,console.log("Prebuilt MDX App mounted. Target element:",a.value),await g())}),k([()=>h[t.page.uid],()=>t.page.uid],async()=>{console.log("MDX page change",t.page.uid),await g()});async function p(e){try{return await import(e)}catch(s){throw console.log(s),new Error(`Failed to import required module at: ${e}`)}}async function g(){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],s=await p(`${r.assetsConfig.prefix||r.assetsConfig.dir}/${e}`);d.value&&d.value.unmount();const v=`${r.assetsConfig?.prefix||r.assetsConfig?.dir}/${r.mdxOutputPaths.react}`,{createRoot:y,jsx:x,React:u,flushSync:E}=await p(v);E(()=>{const n=N(u),M=x(s.default,{}),D=u.createElement(u.Suspense,{fallback:"Loading..."},u.createElement(n,null,M));d.value=y(a.value),d.value.render(D)});try{const n=s&&(s.__HEADINGS??s.__headings);l.value=n??{}}catch(n){console.warn("Failed to read injected MDX headings from module",n),l.value={}}T({router:o,isDark: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,s)=>(B(),S(L,b(t,{guide:e.guide,headings:l.value,html:""}),{"mdx-content":P(()=>[f("div",G,[f("div",{id:"prebuilt-mdx-app",ref_key:"hydrationTarget",ref:a,class:"page-node"},null,512)])]),_:1},16,["guide","headings"]))}});export{R as default};
