// React Imports
import { useTranslations } from 'next-intl'

// MUI Imports
import { useTheme } from '@mui/material/styles'

// Type Imports
import type { VerticalMenuContextProps } from '@menu/components/vertical-menu/Menu'

// Component Imports
import HorizontalNav, { Menu, SubMenu, MenuItem } from '@menu/horizontal-menu'
import VerticalNavContent from './VerticalNavContent'
import CustomChip from '@core/components/mui/Chip'

// Hook Imports
import useVerticalNav from '@menu/hooks/useVerticalNav'

// Styled Component Imports
import StyledHorizontalNavExpandIcon from '@menu/styles/horizontal/StyledHorizontalNavExpandIcon'
import StyledVerticalNavExpandIcon from '@menu/styles/vertical/StyledVerticalNavExpandIcon'

// Style Imports
import menuItemStyles from '@core/styles/horizontal/menuItemStyles'
import menuRootStyles from '@core/styles/horizontal/menuRootStyles'
import verticalNavigationCustomStyles from '@core/styles/vertical/navigationCustomStyles'
import verticalMenuItemStyles from '@core/styles/vertical/menuItemStyles'
import verticalMenuSectionStyles from '@core/styles/vertical/menuSectionStyles'

// Menu Data Imports
// import menuData from '@/data/navigation/horizontalMenuData'

type RenderExpandIconProps = {
  level?: number
}

type RenderVerticalExpandIconProps = {
  open?: boolean
  transitionDuration?: VerticalMenuContextProps['transitionDuration']
}

const RenderExpandIcon = ({ level }: RenderExpandIconProps) => (
  <StyledHorizontalNavExpandIcon level={level}>
    <i className='tabler-chevron-right' />
  </StyledHorizontalNavExpandIcon>
)

const RenderVerticalExpandIcon = ({ open, transitionDuration }: RenderVerticalExpandIconProps) => (
  <StyledVerticalNavExpandIcon open={open} transitionDuration={transitionDuration}>
    <i className='tabler-chevron-right' />
  </StyledVerticalNavExpandIcon>
)

const HorizontalMenu = () => {
  const t = useTranslations('navigation')
  const verticalNavOptions = useVerticalNav()
  const theme = useTheme()

  // Vars
  const { transitionDuration } = verticalNavOptions

  return (
    <HorizontalNav
      switchToVertical
      verticalNavContent={VerticalNavContent}
      verticalNavProps={{
        customStyles: verticalNavigationCustomStyles(verticalNavOptions, theme),
        backgroundColor: 'var(--mui-palette-background-paper)'
      }}
    >
      <Menu
        rootStyles={menuRootStyles(theme)}
        renderExpandIcon={({ level }) => <RenderExpandIcon level={level} />}
        menuItemStyles={menuItemStyles(theme, 'tabler-circle')}
        renderExpandedMenuItemIcon={{ icon: <i className='tabler-circle text-xs' /> }}
        popoutMenuOffset={{
          mainAxis: ({ level }) => (level && level > 0 ? 14 : 12),
          alignmentAxis: 0
        }}
        verticalMenuProps={{
          menuItemStyles: verticalMenuItemStyles(verticalNavOptions, theme),
          renderExpandIcon: ({ open }) => (
            <RenderVerticalExpandIcon open={open} transitionDuration={transitionDuration} />
          ),
          renderExpandedMenuItemIcon: { icon: <i className='tabler-circle text-xs' /> },
          menuSectionStyles: verticalMenuSectionStyles(verticalNavOptions, theme)
        }}
      >
        <SubMenu label={t('dashboards')} icon={<i className='tabler-smart-home' />}>

          <MenuItem href={`/dashboards/analytics`} icon={<i className='tabler-trending-up' />}>
            {t('analytics')}
          </MenuItem>
          <MenuItem href={`/dashboards/ecommerce`} icon={<i className='tabler-shopping-cart' />}>
            {t('eCommerce')}
          </MenuItem>
          <MenuItem href={`/dashboards/academy`} icon={<i className='tabler-school' />}>
            {t('academy')}
          </MenuItem>
          <MenuItem href={`/dashboards/logistics`} icon={<i className='tabler-truck' />}>
            {t('logistics')}
          </MenuItem>
        </SubMenu>
        <SubMenu label={t('apps')} icon={<i className='tabler-mail' />}>
          <SubMenu label={t('eCommerce')} icon={<i className='tabler-shopping-cart' />}>
            <MenuItem href={`/apps/ecommerce/dashboard`}>{t('dashboard')}</MenuItem>
            <SubMenu label={t('products')}>
              <MenuItem href={`/apps/ecommerce/products/list`}>{t('list')}</MenuItem>
              <MenuItem href={`/apps/ecommerce/products/add`}>{t('add')}</MenuItem>
              <MenuItem href={`/apps/ecommerce/products/category`}>
                {t('category')}
              </MenuItem>
            </SubMenu>
            <SubMenu label={t('orders')}>
              <MenuItem href={`/apps/ecommerce/orders/list`}>{t('list')}</MenuItem>
              <MenuItem
                href={`/apps/ecommerce/orders/details/5434`}
                exactMatch={false}
                activeUrl='/apps/ecommerce/orders/details'
              >
                {t('details')}
              </MenuItem>
            </SubMenu>
            <SubMenu label={t('customers')}>
              <MenuItem href={`/apps/ecommerce/customers/list`}>{t('list')}</MenuItem>
              <MenuItem
                href={`/apps/ecommerce/customers/details/879861`}
                exactMatch={false}
                activeUrl='/apps/ecommerce/customers/details'
              >
                {t('details')}
              </MenuItem>
            </SubMenu>
            <MenuItem href={`/apps/ecommerce/manage-reviews`}>
              {t('manageReviews')}
            </MenuItem>
            <MenuItem href={`/apps/ecommerce/referrals`}>{t('referrals')}</MenuItem>
            <MenuItem href={`/apps/ecommerce/settings`}>{t('settings')}</MenuItem>
          </SubMenu>
          <SubMenu label={t('academy')} icon={<i className='tabler-school' />}>
            <MenuItem href={`/apps/academy/dashboard`}>{t('dashboard')}</MenuItem>
            <MenuItem href={`/apps/academy/my-courses`}>{t('myCourses')}</MenuItem>
            <MenuItem href={`/apps/academy/course-details`}>
              {t('courseDetails')}
            </MenuItem>
          </SubMenu>
          <SubMenu label={t('logistics')} icon={<i className='tabler-truck' />}>
            <MenuItem href={`/apps/logistics/dashboard`}>{t('dashboard')}</MenuItem>
            <MenuItem href={`/apps/logistics/fleet`}>{t('fleet')}</MenuItem>
          </SubMenu>
          <MenuItem
            href={`/apps/email`}
            icon={<i className='tabler-mail' />}
            exactMatch={false}
            activeUrl='/apps/email'
          >
            {t('email')}
          </MenuItem>
          <MenuItem href={`/apps/chat`} icon={<i className='tabler-message-circle-2' />}>
            {t('chat')}
          </MenuItem>
          <MenuItem href={`/apps/calendar`} icon={<i className='tabler-calendar' />}>
            {t('calendar')}
          </MenuItem>
          <MenuItem href={`/apps/kanban`} icon={<i className='tabler-copy' />}>
            {t('kanban')}
          </MenuItem>
          <SubMenu label={t('invoice')} icon={<i className='tabler-file-description' />}>
            <MenuItem href={`/apps/invoice/list`}>{t('list')}</MenuItem>
            <MenuItem
              href={`/apps/invoice/preview/4987`}
              exactMatch={false}
              activeUrl='/apps/invoice/preview'
            >
              {t('preview')}
            </MenuItem>
            <MenuItem href={`/apps/invoice/edit/4987`} exactMatch={false} activeUrl='/apps/invoice/edit'>
              {t('edit')}
            </MenuItem>
            <MenuItem href={`/apps/invoice/add`}>{t('add')}</MenuItem>
          </SubMenu>
          <SubMenu label={t('user')} icon={<i className='tabler-user' />}>
            <MenuItem href={`/apps/user/list`}>{t('list')}</MenuItem>
            <MenuItem href={`/apps/user/view`}>{t('view')}</MenuItem>
          </SubMenu>
          <SubMenu label={t('rolesPermissions')} icon={<i className='tabler-lock' />}>
            <MenuItem href={`/apps/roles`}>{t('roles')}</MenuItem>
            <MenuItem href={`/apps/permissions`}>{t('permissions')}</MenuItem>
          </SubMenu>
        </SubMenu>
        <SubMenu label={t('pages')} icon={<i className='tabler-file' />}>
          <MenuItem href={`/pages/user-profile`} icon={<i className='tabler-user-circle' />}>
            {t('userProfile')}
          </MenuItem>
          <SubMenu label={t('miscellaneous')} icon={<i className='tabler-file-info' />}>
            <MenuItem href={`/pages/misc/coming-soon`} target='_blank'>
              {t('comingSoon')}
            </MenuItem>
            <MenuItem href={`/pages/misc/under-maintenance`} target='_blank'>
              {t('underMaintenance')}
            </MenuItem>
            <MenuItem href={`/pages/misc/404-not-found`} target='_blank'>
              {t('pageNotFound404')}
            </MenuItem>
            <MenuItem href={`/pages/misc/401-not-authorized`} target='_blank'>
              {t('notAuthorized401')}
            </MenuItem>
          </SubMenu>
          <SubMenu label={t('authPages')} icon={<i className='tabler-shield-lock' />}>
            <SubMenu label={t('login')}>
              <MenuItem href={`/pages/auth/login-v1`} target='_blank'>
                {t('loginV1')}
              </MenuItem>
              <MenuItem href={`/pages/auth/login-v2`} target='_blank'>
                {t('loginV2')}
              </MenuItem>
            </SubMenu>
            <SubMenu label={t('register')}>
              <MenuItem href={`/pages/auth/register-v1`} target='_blank'>
                {t('registerV1')}
              </MenuItem>
              <MenuItem href={`/pages/auth/register-v2`} target='_blank'>
                {t('registerV2')}
              </MenuItem>
              <MenuItem href={`/pages/auth/register-multi-steps`} target='_blank'>
                {t('registerMultiSteps')}
              </MenuItem>
            </SubMenu>
            <SubMenu label={t('verifyEmail')}>
              <MenuItem href={`/pages/auth/verify-email-v1`} target='_blank'>
                {t('verifyEmailV1')}
              </MenuItem>
              <MenuItem href={`/pages/auth/verify-email-v2`} target='_blank'>
                {t('verifyEmailV2')}
              </MenuItem>
            </SubMenu>
            <SubMenu label={t('forgotPassword')}>
              <MenuItem href={`/pages/auth/forgot-password-v1`} target='_blank'>
                {t('forgotPasswordV1')}
              </MenuItem>
              <MenuItem href={`/pages/auth/forgot-password-v2`} target='_blank'>
                {t('forgotPasswordV2')}
              </MenuItem>
            </SubMenu>
            <SubMenu label={t('resetPassword')}>
              <MenuItem href={`/pages/auth/reset-password-v1`} target='_blank'>
                {t('resetPasswordV1')}
              </MenuItem>
              <MenuItem href={`/pages/auth/reset-password-v2`} target='_blank'>
                {t('resetPasswordV2')}
              </MenuItem>
            </SubMenu>
            <SubMenu label={t('twoSteps')}>
              <MenuItem href={`/pages/auth/two-steps-v1`} target='_blank'>
                {t('twoStepsV1')}
              </MenuItem>
              <MenuItem href={`/pages/auth/two-steps-v2`} target='_blank'>
                {t('twoStepsV2')}
              </MenuItem>
            </SubMenu>
          </SubMenu>
          <SubMenu label={t('wizardExamples')} icon={<i className='tabler-dots' />}>
            <MenuItem href={`/pages/wizard-examples/checkout`}>{t('checkout')}</MenuItem>
            <MenuItem href={`/pages/wizard-examples/property-listing`}>
              {t('propertyListing')}
            </MenuItem>
            <MenuItem href={`/pages/wizard-examples/create-deal`}>
              {t('createDeal')}
            </MenuItem>
          </SubMenu>
          <MenuItem href={`/pages/dialog-examples`} icon={<i className='tabler-square' />}>
            {t('dialogExamples')}
          </MenuItem>
          <SubMenu label={t('widgetExamples')} icon={<i className='tabler-chart-bar' />}>
            <MenuItem href={`/pages/widget-examples/basic`}>{t('basic')}</MenuItem>
            <MenuItem href={`/pages/widget-examples/advanced`}>{t('advanced')}</MenuItem>
            <MenuItem href={`/pages/widget-examples/statistics`}>
              {t('statistics')}
            </MenuItem>
            <MenuItem href={`/pages/widget-examples/charts`}>{t('charts')}</MenuItem>
            <MenuItem href={`/pages/widget-examples/actions`}>{t('actions')}</MenuItem>
          </SubMenu>
          <SubMenu label={t('frontPages')} icon={<i className='tabler-files' />}>
            <MenuItem href='/front-pages/landing-page' target='_blank'>
              {t('landing')}
            </MenuItem>
            <MenuItem href='/front-pages/pricing' target='_blank'>
              {t('pricing')}
            </MenuItem>
            <MenuItem href='/front-pages/payment' target='_blank'>
              {t('payment')}
            </MenuItem>
            <MenuItem href='/front-pages/checkout' target='_blank'>
              {t('checkout')}
            </MenuItem>
            <MenuItem href='/front-pages/help-center' target='_blank'>
              {t('helpCenter')}
            </MenuItem>
          </SubMenu>
        </SubMenu>
        <SubMenu label={t('formsAndTables')} icon={<i className='tabler-file-invoice' />}>
          <MenuItem href={`/forms/form-layouts`} icon={<i className='tabler-layout' />}>
            {t('formLayouts')}
          </MenuItem>
          <MenuItem href={`/forms/form-validation`} icon={<i className='tabler-checkup-list' />}>
            {t('formValidation')}
          </MenuItem>
          <MenuItem href={`/forms/form-wizard`} icon={<i className='tabler-git-merge' />}>
            {t('formWizard')}
          </MenuItem>
          <MenuItem href={`/react-table`} icon={<i className='tabler-table' />}>
            {t('reactTable')}
          </MenuItem>
          <MenuItem
            icon={<i className='tabler-checkbox' />}
            href={`${process.env.NEXT_PUBLIC_DOCS_URL}/docs/user-interface/form-elements`}
            suffix={<i className='tabler-external-link text-xl' />}
            target='_blank'
          >
            {t('formELements')}
          </MenuItem>
          <MenuItem
            icon={<i className='tabler-layout-board-split' />}
            href={`${process.env.NEXT_PUBLIC_DOCS_URL}/docs/user-interface/mui-table`}
            suffix={<i className='tabler-external-link text-xl' />}
            target='_blank'
          >
            {t('muiTables')}
          </MenuItem>
        </SubMenu>
        <SubMenu label={t('charts')} icon={<i className='tabler-chart-donut-2' />}>
          <MenuItem href={`/charts/apex-charts`} icon={<i className='tabler-chart-ppf' />}>
            {t('apex')}
          </MenuItem>
          <MenuItem href={`/charts/recharts`} icon={<i className='tabler-chart-sankey' />}>
            {t('recharts')}
          </MenuItem>
        </SubMenu>
        <SubMenu label={t('others')} icon={<i className='tabler-dots' />}>
          <MenuItem
            icon={<i className='tabler-cards' />}
            href={`${process.env.NEXT_PUBLIC_DOCS_URL}/docs/user-interface/foundation`}
            suffix={<i className='tabler-external-link text-xl' />}
            target='_blank'
          >
            {t('foundation')}
          </MenuItem>
          <MenuItem
            icon={<i className='tabler-atom' />}
            href={`${process.env.NEXT_PUBLIC_DOCS_URL}/docs/user-interface/components`}
            suffix={<i className='tabler-external-link text-xl' />}
            target='_blank'
          >
            {t('components')}
          </MenuItem>
          <MenuItem
            icon={<i className='tabler-list-search' />}
            href={`${process.env.NEXT_PUBLIC_DOCS_URL}/docs/menu-examples/overview`}
            suffix={<i className='tabler-external-link text-xl' />}
            target='_blank'
          >
            {t('menuExamples')}
          </MenuItem>
          <MenuItem
            suffix={<i className='tabler-external-link text-xl' />}
            target='_blank'
            href='https://pixinvent.ticksy.com'
            icon={<i className='tabler-lifebuoy' />}
          >
            {t('raiseSupport')}
          </MenuItem>
          <MenuItem
            suffix={<i className='tabler-external-link text-xl' />}
            target='_blank'
            icon={<i className='tabler-book-2' />}
            href={`${process.env.NEXT_PUBLIC_DOCS_URL}`}
          >
            {t('documentation')}
          </MenuItem>
          <MenuItem
            suffix={<CustomChip label='New' size='small' color='info' round='true' />}
            icon={<i className='tabler-notification' />}
          >
            {t('itemWithBadge')}
          </MenuItem>
          <MenuItem
            icon={<i className='tabler-link' />}
            href='https://pixinvent.com'
            target='_blank'
            suffix={<i className='tabler-external-link text-xl' />}
          >
            {t('externalLink')}
          </MenuItem>
          <SubMenu label={t('menuLevels')} icon={<i className='tabler-menu-2' />}>
            <MenuItem>{t('menuLevel2')}</MenuItem>
            <SubMenu label={t('menuLevel2')}>
              <MenuItem>{t('menuLevel3')}</MenuItem>
              <MenuItem>{t('menuLevel3')}</MenuItem>
            </SubMenu>
          </SubMenu>
          <MenuItem disabled>{t('disabledMenu')}</MenuItem>
        </SubMenu>
      </Menu>
      {/* <Menu
        rootStyles={menuRootStyles(theme)}
        renderExpandIcon={({ level }) => <RenderExpandIcon level={level} />}
        menuItemStyles={menuItemStyles(theme, 'tabler-circle')}
        renderExpandedMenuItemIcon={{ icon: <i className='tabler-circle text-xs' /> }}
        popoutMenuOffset={{
          mainAxis: ({ level }) => (level && level > 0 ? 14 : 12),
          alignmentAxis: 0
        }}
        verticalMenuProps={{
          menuItemStyles: verticalMenuItemStyles(verticalNavOptions, theme),
          renderExpandIcon: ({ open }) => (
            <RenderVerticalExpandIcon open={open} transitionDuration={transitionDuration} />
          ),
          renderExpandedMenuItemIcon: { icon: <i className='tabler-circle text-xs' /> },
          menuSectionStyles: verticalMenuSectionStyles(verticalNavOptions, theme)
        }}
      >
        <GenerateHorizontalMenu menuData={menuData(dictionary)} />
      </Menu> */}
    </HorizontalNav>
  )
}

export default HorizontalMenu
