import ProxyIcon from '@material-ui/icons/Notes';
import EndpointIcon from '@material-ui/icons/Send';
import InbountEpIcon from '@material-ui/icons/Transform';
import MessageProcessorIcon from '@material-ui/icons/Message';
import MessageStoreIcon from '@material-ui/icons/StoreMallDirectory';
import ApiIcon from '@material-ui/icons/Apps';
import Event from '@material-ui/icons/Event';
import TemplateIcon from '@material-ui/icons/WrapText';
import SequenceIcon from '@material-ui/icons/CompareArrows';
import LocalEntriesIcon from '@material-ui/icons/Assignment';
import ConnectorIcon from '@material-ui/icons/CastConnected';
import CappIcon from '@material-ui/icons/Dashboard';
import UserIcon from '@material-ui/icons/People';
import RoleIcon from '@material-ui/icons/Accessibility';
import LogFileIcon from '@material-ui/icons/Description';
import LayersIcon from '@material-ui/icons/Layers';
import DnsIcon from '@material-ui/icons/Dns';
import RegistryIcon from '@material-ui/icons/Receipt';
import FunctionsIcon from '@material-ui/icons/Functions';
import StorageIcon from '@material-ui/icons/Storage';
import ViewModuleIcon from '@material-ui/icons/ViewModule';
import TimelineIcon from '@material-ui/icons/Timeline';
import InputIcon from '@material-ui/icons/GetApp';
import OutputIcon from '@material-ui/icons/Publish'; 

export const miCategories = [
    {
      id: 'General',
      children: [
        { id: 'Proxy Services', to: '/proxy-services', icon: <ProxyIcon /> },
        { id: 'Endpoints', to: '/endpoints', icon: <EndpointIcon /> },
        { id: 'Inbound Endpoints', to: '/inbound-endpoints', icon: <InbountEpIcon /> },
        { id: 'Message Processors', to: '/message-processors', icon: <MessageProcessorIcon /> },
        { id: 'Message Stores', to: '/message-stores', icon: <MessageStoreIcon /> },
        { id: 'APIs', to: '/apis', icon: <ApiIcon /> },
        { id: 'Templates', to: '/templates', icon: <TemplateIcon /> },
        { id: 'Sequences', to: '/sequences', icon: <SequenceIcon /> },
        { id: 'Tasks', to: '/tasks', icon: <Event /> },
        { id: 'Local Entries', to: '/local-entries', icon: <LocalEntriesIcon /> },
        { id: 'Data Services', to: '/data-services', icon: <LayersIcon /> },
        { id: 'Data Sources', to: '/data-sources', icon: <DnsIcon /> },
        { id: 'Connectors', to: '/connectors', icon: <ConnectorIcon /> },
        { id: 'Carbon Applications', to: '/carbon-applications', icon: <CappIcon /> },
        { id: 'Log Files', to: '/log-files', icon: <LogFileIcon /> },
        { id: 'Registry Resources', to: '/registry-resources', icon: <RegistryIcon /> },
      ],
    },
    {
      id: 'Global Settings',
      children: [
        { id: 'Log Configs', to: '/log-configs', icon: <LocalEntriesIcon /> },
        { id: 'Users', to: '/users', icon: <UserIcon /> },
        { id: 'Roles', to: '/roles', icon: <RoleIcon /> },
      ],
    },
  ];

export const balCategories = [
  {
    id: 'General',
    children: [
      { id: 'Services', to: '/services', icon: <ProxyIcon /> },
      {id: 'Listeners', to: '/listeners', icon: <EndpointIcon /> }
    ]
  }
];

export const siCategories = [
  {
    id: 'General',
    children: [
      { id: 'Siddhi Applications', to: '/siddhi-applications', icon: <CappIcon /> },
      { id: 'Sources', to: '/sources', icon: <InputIcon /> },
      { id: 'Sinks', to: '/sinks', icon: <OutputIcon /> },
      { id: 'Queries', to: '/queries', icon: <FunctionsIcon /> },
      { id: 'Stores', to: '/stores', icon: <StorageIcon /> },
      { id: 'Windows', to: '/windows', icon: <ViewModuleIcon /> },
      { id: 'Aggregations', to: '/aggregations', icon: <TimelineIcon /> },
      { id: 'Log Files', to: '/log-files', icon: <LogFileIcon /> }
    ]
  }
];

 const nonDisplayItems = [ 
   {id: 'Add Users', to: '/users/add' }, 
   {id: 'Add Roles', to: '/roles/add' }, 
   {id: 'Add Log Config', to: '/log-configs/add'},
   {id: 'Update Password', to: '/update-password'},
  ]

  export const getIdFromRoute = (route) => {
      // todo: should use forEach, not map.
      let allChildren = [];
      miCategories.map((cat) => {
          allChildren = [...allChildren, ...cat.children];
      })
      balCategories.map((cat) => {
          allChildren = [...allChildren, ...cat.children];
      })
      siCategories.map((cat) => {
        allChildren = [...allChildren, ...cat.children];
    })
      let selected = allChildren.find(child => child.to === route);
      if (selected === undefined) {
          selected = nonDisplayItems.find(item => item.to === route);
      }
      return selected ? selected : allChildren[0] ;
  }
