// Type Imports
import type { ChildrenType } from '@core/types'

// Component Imports
import Providers from '@components/Providers'
import BlankLayout from '@layouts/BlankLayout'

// Util Imports
import { getSystemMode } from '@core/utils/serverHelpers'
import { Locale } from 'next-intl'
import GuestOnlyRoute from '@/guards/GuestOnlyRoute'

type Props = ChildrenType & {
  params: Promise<{ lang: Locale }>
}

const Layout = async (props: Props) => {
  const params = await props.params
  const { children } = props

  // Vars
  const direction = params?.lang === 'ar' ? 'rtl' : 'ltr'
  const systemMode = await getSystemMode()

  return (
    <Providers direction={direction}>
      <BlankLayout systemMode={systemMode}>
        <GuestOnlyRoute lang={params.lang}>{children}</GuestOnlyRoute>
      </BlankLayout>
    </Providers>
  )
}

export default Layout
