"""
WiP.

Soon.
"""

# region [Imports]

import os
import re
import sys
import json
import queue
import math
import base64
import pickle
import random
import shelve
import dataclasses
import shutil
import asyncio
import logging
import sqlite3
import platform

import subprocess
import inspect

from time import sleep, process_time, process_time_ns, perf_counter, perf_counter_ns
from io import BytesIO, StringIO
from abc import ABC, ABCMeta, abstractmethod
from copy import copy, deepcopy
from enum import Enum, Flag, auto, unique
from pprint import pprint, pformat
from pathlib import Path
from string import Formatter, digits, printable, whitespace, punctuation, ascii_letters, ascii_lowercase, ascii_uppercase
from timeit import Timer
from typing import (TYPE_CHECKING, TypeVar, TypeGuard, TypeAlias, Final, TypedDict, Generic, Union, Optional, ForwardRef, final, Callable,
                    no_type_check, no_type_check_decorator, overload, get_type_hints, cast, Protocol, runtime_checkable, NoReturn, NewType, Literal, AnyStr, IO, BinaryIO, TextIO, Any)
from collections import Counter, ChainMap, deque, namedtuple, defaultdict
from collections.abc import (AsyncGenerator, AsyncIterable, AsyncIterator, Awaitable, ByteString, Callable, Collection, Container, Coroutine, Generator,
                             Hashable, ItemsView, Iterable, Iterator, KeysView, Mapping, MappingView, MutableMapping, MutableSequence, MutableSet, Reversible, Sequence, Set, Sized, ValuesView)
from zipfile import ZipFile, ZIP_LZMA
from datetime import datetime, timezone, timedelta
from tempfile import TemporaryDirectory
from textwrap import TextWrapper, fill, wrap, dedent, indent, shorten
from functools import wraps, partial, lru_cache, singledispatch, total_ordering, cached_property, cache
from contextlib import contextmanager, asynccontextmanager, nullcontext, closing, ExitStack, suppress
from statistics import mean, mode, stdev, median, variance, pvariance, harmonic_mean, median_grouped
from urllib.parse import urlparse
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor, Future, wait, as_completed, ALL_COMPLETED, FIRST_EXCEPTION, FIRST_COMPLETED

from colorsys import hsv_to_rgb, rgb_to_hls, rgb_to_hsv, hls_to_rgb

if sys.version_info >= (3, 11):
    from typing import Self
else:
    from typing_extensions import Self

if TYPE_CHECKING:
    ...

# endregion [Imports]

# region [TODO]


# endregion [TODO]

# region [Logging]


# endregion [Logging]

# region [Constants]

THIS_FILE_DIR = Path(__file__).parent.absolute()

# endregion [Constants]


def float_to_degrees(in_value: float) -> float:
    return (in_value * 360) % 360


def rgb_to_hsl(r: float, g: float, b: float) -> tuple[float, float, float]:
    h, l, s = rgb_to_hls(r, g, b)
    return h, s, l


def hsl_to_rgb(h: float, s: float, l: float) -> tuple[float, float, float]:
    return hls_to_rgb(h, l, s)


def rgb_float_to_rgb_int(in_rgb_float: tuple[float]) -> tuple[int]:
    return tuple(round(255 * i) for i in in_rgb_float)


def rgb_int_to_rgb_float(in_rgb_int: tuple[float]) -> tuple[int]:
    return tuple(float(i / 255) for i in in_rgb_int)


def rgb_float_to_hex(in_rgb_float: tuple[float]) -> str:
    values = rgb_float_to_rgb_int(in_rgb_float)
    return '#' + ''.join(f"{p:02X}" for p in values)


def hex_to_rgb_float(in_hex: str) -> tuple[float]:
    cleaned_hex = in_hex.removeprefix("#")
    rgb_int_values = tuple(bytes.fromhex(cleaned_hex))
    return rgb_int_to_rgb_float(rgb_int_values)


# region [Main_Exec]
if __name__ == '__main__':
    import numpy as np
    x = (0.0, 0.6901960784313725, 1.0)

    y = rgb_to_hsv(*x)

    z = ((y[0] + 0.5) - 1.0, (y[1] / 4) * 3, (y[2] / 4) * 3)

    print(f"{z=}")
    zz = hsv_to_rgb(*z)
    print(f"{rgb_float_to_hex(zz)=}")

    # x = "#00B0FF"
    # print(f"{hex_to_rgb_float(x)=}")
# endregion [Main_Exec]
