import { type Metadata } from 'next'
import { Inter, Lexend } from 'next/font/google'
import clsx from 'clsx'

import '@/styles/tailwind.css'
import Script from 'next/script'

export const metadata: Metadata = {
  title: {
    template: '%s - NaviLearn',
    default: 'NaviLearn',
  },
  description:
    'NaviLearn ist Ihre digitale Plattform zur Wissensvermittlung, die hilft, wiederholte Fragen zu vermeiden und effizientes Lernen zu fördern.',
}

const inter = Inter({
  subsets: ['latin'],
  display: 'swap',
  variable: '--font-inter',
})

const lexend = Lexend({
  subsets: ['latin'],
  display: 'swap',
  variable: '--font-lexend',
})

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html
      lang="en"
      className={clsx(
        'h-full scroll-smooth bg-white antialiased',
        inter.variable,
        lexend.variable,
      )}
    >
      <body className="flex h-full flex-col">
        {children}

        <script
          src="https://chatwunder.de/api/chat/embed/cm4zw3ob3000dvr10ocy0ze29?buttonColor=3b82f6&iconColor=ffffff"
          type="text/javascript"
          defer
        ></script>

        {process.env.NODE_ENV === 'production' && (
          <>
            {/* <script
              type="text/javascript"
              dangerouslySetInnerHTML={{
                __html: `
         !function (a, b, c, d, e, f, g) {
    if (c[a] && c[a].g) return;
    c[a] = c[a] || function () { (c[a].q = c[a].q || []).push(arguments) };
    c[a].g = !0, (g = b.createElement(d)).async = !0, g.src = "https://jati-tracker.jannex.de/tracker", b.head.appendChild(g), (f = b.getElementsByTagName(d)[0]).parentNode.insertBefore(g, f), c[a](e);
  }("Pixel-Scaleluna", document, window, "script", { p: "123456789" });`,
              }}
            ></script> */}

            <script
              defer
              data-domain="navilearn.io"
              src="https://anal.jannex.de/js/script.js"
            ></script>

            <script
              type="text/javascript"
              dangerouslySetInnerHTML={{
                __html: `
          (function(c,l,a,r,i,t,y){
              c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
              t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
              y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
          })(window, document, "clarity", "script", "${process.env.CLARITY_ID}");
          `,
              }}
            ></script>
          </>
        )}
      </body>
    </html>
  )
}
