"""WizardKit: Auto System Setup Tool"""
# vim: sts=2 sw=2 ts=2

from typing import Any

import wk


# Classes
class MenuEntry():
  """Simple class to allow cleaner code below."""
  def __init__(
      self,
      name: str,
      function: str | None = None,
      selected: bool = True,
      **kwargs):
    self.name: str = name
    self.details: dict[str, Any] = {
      'Function': function,
      'Selected': selected,
      **kwargs,
      }


# STATIC VARIABLES
BASE_MENUS = {
  'Groups': {
    'Backup Settings': (
      MenuEntry('Backup Browsers',          'auto_backup_browser_profiles'),
      MenuEntry('Backup Power Plans',       'auto_backup_power_plans'),
      MenuEntry('Reset Power Plans',        'auto_reset_power_plans'),
      MenuEntry('Set Custom Power Plan',    'auto_set_custom_power_plan'),
      ),
    'Install Software': (
      MenuEntry('Winget',                   'auto_install_winget'),
      MenuEntry('ESET NOD32 AV',            'auto_install_eset_nod32_av', selected=False),
      MenuEntry('ESET NOD32 AV (MSP)',      'auto_install_eset_nod32_av_msp', selected=False),
      MenuEntry('Firefox',                  'auto_install_firefox'),
      MenuEntry('LibreOffice',              'auto_install_libreoffice', selected=False),
      MenuEntry('Open-Shell',               'auto_install_open_shell', selected=False),
      MenuEntry('Software Bundle',          'auto_install_software_bundle'),
      MenuEntry('Software Upgrades',        'auto_install_software_upgrades', selected=False),
      MenuEntry('Visual C++ Runtimes',      'auto_install_vcredists'),
      ),
    'Configure System': (
      MenuEntry('Apply ITS Settings',       'auto_apply_its_settings', selected=False),
      MenuEntry('Open-Shell',               'auto_config_open_shell', selected=False),
      MenuEntry('Disable Chrome Notifications', 'auto_disable_chrome_notifications', selected=False),
      MenuEntry('Disable Fast Startup',     'auto_disable_fast_startup', selected=False),
      MenuEntry('Disable Password Expiration', 'auto_disable_password_expiration'),
      MenuEntry('Disable Telemetry',        'auto_shutup_10'),
      MenuEntry('Enable BSoD MiniDumps',    'auto_enable_bsod_minidumps'),
      MenuEntry('Enable Hibernation',       'auto_enable_hibernation', selected=False),
      MenuEntry('Enable RegBack',           'auto_enable_regback'),
      MenuEntry('Enable System Restore',    'auto_system_restore_enable'),
      MenuEntry('Set System Restore Size',  'auto_system_restore_set_size'),
      MenuEntry('Enable Windows Updates',   'auto_windows_updates_enable'),
      MenuEntry('Windows Activation',       'auto_activate_windows'),
      MenuEntry('Windows Explorer',         'auto_config_explorer'),
      MenuEntry(r'Windows\Temp Fix',        'auto_windows_temp_fix'),
      MenuEntry('Configure Browsers',       'auto_config_browsers'),
      MenuEntry('Create System Restore',    'auto_system_restore_create'),
      ),
    'System Information': (
      MenuEntry('AIDA64 Report',            'auto_export_aida64_report'),
      MenuEntry('Backup Registry',          'auto_backup_registry'),
      ),
    'System Summary': (
      MenuEntry('Operating System',         'auto_show_os_name'),
      MenuEntry('Windows Activation',       'auto_show_os_activation'),
      MenuEntry('Secure Boot',              'auto_show_secure_boot_status'),
      MenuEntry('Installed RAM',            'auto_show_installed_ram'),
      MenuEntry('Storage Status',           'auto_show_storage_status'),
      MenuEntry('Virus Protection',         'auto_show_installed_antivirus'),
      MenuEntry('Partitions 4K Aligned',    'auto_show_4k_alignment_check'),
      ),
    'Run Programs': (
      MenuEntry('Device Manager',           'auto_open_device_manager'),
      MenuEntry('HWiNFO Sensors',           'auto_open_hwinfo_sensors'),
      MenuEntry('Microsoft Store Updates',  'auto_open_microsoft_store_updates'),
      MenuEntry('Snappy Driver Installer',  'auto_open_snappy_driver_installer_origin'),
      MenuEntry('Webcam Tests',             'auto_open_webcam_tests'),
      MenuEntry('Windows Activation',       'auto_open_windows_activation'),
      MenuEntry('Windows Updates',          'auto_open_windows_updates'),
      MenuEntry('XMPlay',                   'auto_open_xmplay'),
      ),
    },
  'Actions': (
    MenuEntry('Load Preset'),
    MenuEntry('Start', Separator=True),
    MenuEntry('Quit'),
    ),
  }
PRESETS = {
  'Default': {}, # Will be built at runtime using BASE_MENUS
  'Additional User': {
    'Configure System': (
      'Configure Browsers',
      'Open-Shell',
      'uBlock Origin',
      'Enable BSoD MiniDumps',
      'Enable RegBack',
      'Enable System Restore',
      'Set System Restore Size',
      'Enable Windows Updates',
      'Windows Explorer',
      ),
    'Install Software': (
      'Firefox', # Needed to handle profile upgrade nonsense
      ),
    'Run Programs': (
      'Microsoft Store Updates',
      ),
    'System Summary': (
      'Operating System',
      'Windows Activation',
      'Secure Boot',
      'Installed RAM',
      'Storage Status',
      'Virus Protection',
      'Partitions 4K Aligned',
      ),
    },
  'Hardware': {
    'Configure System': (
      'Enable BSoD MiniDumps',
      'Enable RegBack',
      'Enable System Restore',
      'Set System Restore Size',
      'Enable Windows Updates',
      ),
    'System Information': (
      'Backup Registry',
      ),
    'System Summary': (
      'Operating System',
      'Windows Activation',
      'Secure Boot',
      'Installed RAM',
      'Storage Status',
      'Virus Protection',
      'Partitions 4K Aligned',
      ),
    'Run Programs': (
      'Device Manager',
      'HWiNFO Sensors',
      'XMPlay',
      ),
    },
  'Verify': {
    'Configure System': (
      'Enable BSoD MiniDumps',
      'Enable RegBack',
      'Enable System Restore',
      'Set System Restore Size',
      'Enable Windows Updates',
      'Windows Explorer',
      ),
    'System Summary': (
      'Operating System',
      'Windows Activation',
      'Secure Boot',
      'Installed RAM',
      'Storage Status',
      'Virus Protection',
      'Installed Office',
      'Partitions 4K Aligned',
      ),
    },
  'Custom': {}, # Will remain empty at runtime
  }


if __name__ == '__main__':
  try:
    wk.setup.win.run_auto_setup(BASE_MENUS, PRESETS)
  except KeyboardInterrupt:
    wk.ui.cli.abort()
  except SystemExit:
    raise
  except: # noqa: E722
    wk.ui.cli.major_exception()
