from typing import List

import wx
from wx.adv import EditableListBox, EL_DEFAULT_STYLE, EL_NO_REORDER

from clarabot_nano.control.wizard import SimpleWizardPage


class IndexIgnoreMimesPage(SimpleWizardPage):
    def __init__(self, parent, config: List[str]):
        SimpleWizardPage.__init__(
            self,
            parent,
            gettext(
                "Indexing some files can be unnecessary. "
                "For example, saving a web-page from the browser will create many resource files "
                "aside from the HTML: css, javascript, etc.\n"
                "Indexing these would not benefit the user in most circumstances. They would also require language "
                "specific tokenizers for optimal matching anyways."
            ),
        )
        self._old = config

        self.mimes = EditableListBox(
            self, wx.ID_ANY, gettext("Ignored mimetypes"), style=EL_DEFAULT_STYLE | EL_NO_REORDER
        )
        self.mimes.SetStrings(config)
        self.layout.Add(self.mimes, 1, wx.EXPAND | wx.BOTTOM, 8)

    def get_new_config(self):
        return self._old, self.mimes.GetStrings()
