import React from 'react';
import { Route } from 'react-router-dom';
import { languages } from './Language/Language';
import JapanesePage from './Pages/Japan/JapanesePage';
import BlogPage from './Pages/Plamo/BlogPage';
import PaintsPage from './Pages/Plamo/paints/PaintsPage';
import CSharpPage from './Pages/Software/dotnet/csharp/CSharpPage';
import ElmPage from './Pages/Software/elm/ElmPage';
import HaskellPage from './Pages/Software/haskell/HaskellPage';

// Japan
export const japaneseRoutes = languages.map(lang => {
    const pages = ['but', 'cheat-sheet', 'contrast-particle', 'dake-vs-shika', 'expressions', 'if-when', 'japanese-scale-modelling-tools', 'mae-ni-ato-de', 'onomatopoeia', 'particles', 'rashii-kamoshirenai-darou', 'tameni-youni-noni', 'te-form', 'te-oku', 'toka-tari-shi', 'verbs'];
    return pages.map(page => {
      const path = `/${lang}/japan/japanese/${page}`;
      const mdPath = `Japan/Japanese/${lang}/${page}.md`;
      return <Route key={`${lang}-${page}`} exact path={path} element={<JapanesePage mdPath={mdPath} />} />;
    });
  }).flat();

// Plamo
export const plamoBlogRoutes = languages.map(lang => {
  const pages = ['smc-2025-rx-178-mk-2'];
  return pages.map(page => {
    const path = `/${lang}/plamo/blog/${page}`;
    const mdPath = `Plamo/blog/${lang}/${page}.md`;
    return <Route key={`${lang}-${page}`} exact path={path} element={<BlogPage mdPath={mdPath} />} />;
  });
}).flat();
export const plamoEquipmentRoutes = languages.map(lang => {
  const pages = ['airbrush-cabine'];
  return pages.map(page => {
    const path = `/${lang}/plamo/equipment/${page}`;
    const mdPath = `Plamo/equipment/${lang}/${page}.md`;
    return <Route key={`${lang}-${page}`} exact path={path} element={<BlogPage mdPath={mdPath} />} />;
  });
}).flat();
export const plamoPaintRoutes = languages.map(lang => {
    const path = `/${lang}/plamo/paints`;
    const mdPath = `Plamo/paints/${lang}/paints.md`;
    return <Route key={`${lang}-paints`} exact path={path} element={<PaintsPage mdPath={mdPath} />} />;
}).flat();
export const plamoShowcaseGundamRoutes = languages.map(lang => {
  const pages = ['kawasaki-zaku-ii', 'smc-2025-gundam'];
  return pages.map(page => {
    const path = `/${lang}/plamo/showcase/gundam/${page}`;
    const mdPath = `Plamo/showcase/gundam/${lang}/${page}.md`;
    return <Route key={`${lang}-${page}`} exact path={path} element={<BlogPage mdPath={mdPath} />} />;
  });
}).flat();
export const plamoShowcaseMilitairyAirplanesRoutes = languages.map(lang => {
  const pages = ['ki-55'];
  return pages.map(page => {
    const path = `/${lang}/plamo/showcase/military-airplanes/${page}`;
    const mdPath = `Plamo/showcase/military-airplanes/${lang}/${page}.md`;
    return <Route key={`${lang}-${page}`} exact path={path} element={<BlogPage mdPath={mdPath} />} />;
  });
}).flat();

// Software
export const programmingLanguageRoutes = languages.map(lang => {
    // Main page.
    const mainCSharp = <Route key={`${lang}-csharp-main`} exact path={`/${lang}/software/csharp/`} element={<CSharpPage mdPath={`Software/csharp/${lang}/main.md`} />} />
    const mainElm = <Route key={`${lang}-elm-main`} exact path={`/${lang}/software/elm/`} element={<ElmPage mdPath={`Software/elm/${lang}/main.md`} />} />
    const mainHaskell = <Route key={`${lang}-haskell-main`} exact path={`/${lang}/software/haskell/`} element={<HaskellPage mdPath={`Software/haskell/${lang}/main.md`} />} />

    // Pages within C#.
    let md = ['strings', 'types'];
    const entriesCSharp = md.map(entry => {
        const path = `/${lang}/software/csharp/${entry}`;
        const mdPath = `Software/csharp/${lang}/${entry}.md`;
        return <Route key={`${lang}-${entry}`} exact path={path} element={<CSharpPage mdPath={mdPath} />} />;
    });

    // Pages within Elm.
    md = ['dry', 'formatting', 'maybeandthen', 'maybemap'];
    const entriesElm = md.map(entry => {
        const path = `/${lang}/software/elm/${entry}`;
        const mdPath = `Software/elm/${lang}/${entry}.md`;
        return <Route key={`${lang}-${entry}`} exact path={path} element={<ElmPage mdPath={mdPath} />} />;
    });

    // Pages within Haskell.
    md = [
      'caesar-cipher',
      'conditional-expressions-and-guarded-equations',
      'curried-functions',
      'graham-hutton-answers',
      'lambda-expressions',
      'lists',
      'recursive-functions',
      'strings',
      'pattern-matching',
    ];
    const entriesHaskell = md.map(entry => {
        const path = `/${lang}/software/haskell/${entry}`;
        const mdPath = `Software/haskell/${lang}/${entry}.md`;
        return <Route key={`${lang}-${entry}`} exact path={path} element={<HaskellPage mdPath={mdPath} />} />;
    });

    return [mainCSharp, mainElm, mainHaskell, ...entriesCSharp, ...entriesElm, ...entriesHaskell];
}).flat();
