from empire.core import *
from sys import getsizeof
from unicodedata import normalize
import random
import string


class Strings:
    @staticmethod
    def sizeof(s: str) -> int:
        return getsizeof(s)

    @staticmethod
    def remove_special_letters(inp: str) -> str:
        """
        SEE: https://stackoverflow.com/questions/1207457/convert-a-unicode-string-to-a-string-in-python-containing-extra-symbols
        """
        return normalize('NFKD', inp)

    @staticmethod
    def generate_random_string(string_length: int, lowercase: bool = False) -> str:
        random_string: str = ''.join(random.choice(string.ascii_uppercase) for i in range(string_length))

        return random_string.lower() if lowercase else random_string

    @staticmethod
    def get_next_unique_string(all_strings: List[str], value: str) -> str:
        count: int = -1
        for s in all_strings:
            if s.startswith(value):
                count += 1
        
        if count == -1:
            return value
        else:
            return '{}{}'.format(value, count)
