import { GlobalConfig } from '@/share/types'
// import { Script, Link } from 'hono-vite-react-stack-node/components'
import process from 'node:process'

// 全局配置常量
const GLOBAL_CONFIG: GlobalConfig = {
  OSS_BASE_URL: process.env.OSS_BASE_URL || 'https://oss.d8d.fun',
  APP_NAME: process.env.APP_NAME || '多八多Aider',
}

// export const renderer = reactRenderer(({ children }) => {
//   return (
//     <html>
//       <head>
//         <meta charSet="UTF-8" />
//         <meta name="viewport" content="width=device-width, initial-scale=1.0" />
//         <script src="https://ai-oss.d8d.fun/umd/vconsole.3.15.1.min.js"></script>
//         <script dangerouslySetInnerHTML={{ __html: `
//           const init = () => {
//             const urlParams = new URLSearchParams(window.location.search);
//             if (${import.meta.env?.PROD ? "true":"false"} && !urlParams.has('vconsole')) return;
//             var vConsole = new VConsole({
//               theme: urlParams.get('vconsole_theme') || 'light',
//               onReady: function() {
//                 console.log('vConsole is ready');
//               }
//             });
//           }
//           init();
//         `}} />
//         {/* 注入全局配置 */}
//         <script dangerouslySetInnerHTML={{ __html: `window.CONFIG = ${JSON.stringify(GLOBAL_CONFIG)};` }} />
            
//       </head>
//       <body>
//         {children}
//         <script type="module" src="/src/client/index.tsx"></script>
//       </body>
//     </html> 
//   )
// })

export const Rooter = () => {
  return (
    <html>
      <head>
        <meta charSet="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link href='/src/style.css' rel="stylesheet" />
        <script src="https://ai-oss.d8d.fun/umd/vconsole.3.15.1.min.js"></script>
        <script dangerouslySetInnerHTML={{ __html: `
          const init = () => {
            const urlParams = new URLSearchParams(window.location.search);
            if (${import.meta.env?.PROD ? "true":"false"} && !urlParams.has('vconsole')) return;
            var vConsole = new VConsole({
              theme: urlParams.get('vconsole_theme') || 'light',
              onReady: function() {
                console.log('vConsole is ready');
              }
            });
          }
          init();
        `}} />
        {/* 注入全局配置 */}
        <script dangerouslySetInnerHTML={{ __html: `window.CONFIG = ${JSON.stringify(GLOBAL_CONFIG)};` }} />
            
      </head>
      <body>
        <div id='root' dangerouslySetInnerHTML={{ __html: '<!--app-html-->'}}></div>
        <script type="module" src="/src/client/index.tsx"></script>
      </body>
    </html> 
  )
}