import{d as w,M as C,N as _,y as m,C as $,z as k,v as X,b as S,o as B,w as P,a as f,m as b}from"./index-CDPBytck.js";import{h as N,G as T}from"./Guide-Db2M1XyO.js";import"./__vite-browser-external-D7Ct-6yo.js";import"./DocumentMobileHeader.vue-CtBquMK3.js";function L(n){return class extends n.Component{constructor(o){super(o),this.state={error:null}}static getDerivedStateFromError(o){return{error:o}}componentDidCatch(o,u){console.error("MDX Error Boundary caught an error:",o,u)}render(){return this.state.error?n.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=w({__name:"GuideMdxLoader",props:{project:{},page:{},version:{},versionNames:{},headerLinks:{},guide:{}},setup(n){const t=n,o=C(),{isDarkMode:u}=_(),{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 p())}),k([()=>h[t.page.uid],()=>t.page.uid],async()=>{console.log("MDX page change",t.page.uid),await p()});async function g(e){try{return await import(e)}catch(s){throw console.log(s),new Error(`Failed to import required module at: ${e}`)}}async function p(){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 g(`${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:c,flushSync:M}=await g(v);M(()=>{const i=L(c),E=x(s.default,{}),D=c.createElement(c.Suspense,{fallback:"Loading..."},c.createElement(i,null,E));d.value=y(a.value),d.value.render(D)});try{const i=s&&(s.__HEADINGS??s.__headings);l.value=i??{}}catch(i){console.warn("Failed to read injected MDX headings from module",i),l.value={}}await N({router:o,isDark:u})}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(T,b(t,{guide:n.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};
