import { useShallow } from 'zustand/react/shallow';
import { useLayoutStore } from './store';
import clsx from 'clsx';
import { Button, message } from 'antd';
import {
  AppstoreOutlined,
  CloseOutlined,
  CodeOutlined,
  DashboardOutlined,
  FolderOutlined,
  HomeOutlined,
  MessageOutlined,
  ReadOutlined,
  RocketOutlined,
  SmileOutlined,
  SwitcherOutlined,
} from '@ant-design/icons';
import { useNewNavigate } from '../navicate';
const meun = [
  {
    title: 'Home',
    icon: <HomeOutlined />,
    link: '/map',
  },
  {
    title: 'Panel',
    icon: <DashboardOutlined />,
    link: '/panel/edit/list',
  },
  {
    title: 'User App',
    icon: <AppstoreOutlined />,
    link: '/app/edit/list',
  },
  {
    title: 'File App',
    icon: <FolderOutlined />,
    link: '/file/edit/list',
  },
  {
    title: 'Prompt',
    icon: <MessageOutlined />,
    link: '/prompt',
  },
  {
    title: 'Container',
    icon: <CodeOutlined />,
    link: '/container/edit/list',
  },
  {
    title: 'Agent',
    icon: <RocketOutlined />,
    link: '/agent/edit/list',
  },
  {
    title: 'Chat Prompt',
    icon: <ReadOutlined />,
    link: '/chat/chat-prompt/list',
  },
  {
    title: 'Org',
    icon: <SwitcherOutlined />,
    link: '/org/edit/list',
  },
  {
    title: 'About',
    icon: <SmileOutlined />,
  },
];
export const LayoutMenu = () => {
  const { open, setOpen } = useLayoutStore(useShallow((state) => ({ open: state.open, setOpen: state.setOpen })));
  const navigate = useNewNavigate();
  return (
    <div className={clsx('w-full h-full absolute z-20', !open && 'hidden')}>
      <div
        className='bg-white w-full absolute h-full opacity-60 z-0'
        onClick={() => {
          setOpen(false);
        }}></div>
      <div className='w-[300px] h-full absolute top-0 left-0 bg-white'>
        <div className='flex justify-between p-6 font-bold items-center'>
          Envision
          <div>
            <Button icon={<CloseOutlined />} onClick={() => setOpen(false)}></Button>
          </div>
        </div>
        <div className='mt-3 font-medium'>
          {meun.map((item, index) => {
            return (
              <div
                key={index}
                className='flex items-center p-4 gap-3 cursor-pointer hover:bg-slate-200 rounded-md'
                onClick={() => {
                  if (item.link) navigate(`${item.link}`);
                  else {
                    message.info('About Envision');
                  }
                  setOpen(false);
                }}>
                <div className='w-6 h-6'>{item.icon}</div>
                <div>{item.title}</div>
              </div>
            );
          })}
        </div>
      </div>
    </div>
  );
};
