# Path: vise/config.py
# def color(key, default):
#     ans = colors().get(key)
#     if not ans or ans == 'default':
#         ans = default
#     return ans
# 
# @lru_cache()
# def font_sizes():
#     uff = (load_config(user=True).get('fonts') or {}).get('sizes') or {}
#     dff = load_config(user=False)['fonts']['sizes']
#     sizes = {}
# 
#     def conv(x):
#         if x == 'default':
#             return 0
#         try:
#             return int(x)
#         except Exception:
#             pass
# 
#     def get_ff(x):
#         if isinstance(x, dict):
#             return conv(x.get(hostname) or x.get('*'))
#         return conv(x)
# 
#     for ftype, val in uff.items():
#         val = get_ff(val)
#         if isinstance(val, int):
#             sizes[ftype] = val
# 
#     for ftype, val in dff.items():
#         if ftype not in sizes:
#             val = get_ff(val)
#             if isinstance(val, int):
#                 sizes[ftype] = val
# 
#     return sizes
# 
# Path: vise/constants.py
# DOWNLOADS_URL = 'vise:downloads'
# WELCOME_URL = 'vise:welcome'
# STATUS_BAR_HEIGHT = 24
# FOLLOW_LINK_KEY_MAP = {getattr(Qt.Key, 'Key_' + x.upper()): x for x in string.ascii_lowercase + string.digits}
# VISE_SCHEME = 'vise'
# def _get_cache_dir():
# def _get_config_dir():
# def get_windows_username():
# def local_socket_address():
# 
# Path: vise/resources.py
# def get_data_as_file(name):
#     return open(get_data_as_path(name), 'rb')


import glob
import json
import os
import apsw
from base64 import standard_b64decode, standard_b64encode
from binascii import hexlify
from collections import defaultdict
from functools import lru_cache
from PyQt6.QtGui import QKeySequence
from PyQt6.QtWebEngineCore import (QWebEngineProfile, QWebEngineScript,
                                   QWebEngineSettings)
from PyQt6.QtWidgets import QApplication
from .config import color, font_sizes
from .constants import (DOWNLOADS_URL, VISE_SCHEME, appname, cache_dir,
                        config_dir)
from .resources import get_data_as_file
    from .url_intercept import Interceptor
    from .vise_scheme import UrlSchemeHandler
        from .downloads import download_requested
    from .config import font_families, font_sizes
        from .downloads import download_requested
    from .utils import safe_disconnect
        from .utils import parse_url
    if _profile is None:
        _profile = create_profile()
        _profile.downloadRequested.connect(download_requested)
    return _profile


def do_delete_profile(profile):
    safe_disconnect(profile.downloadRequested)
    profile.setParent(None)
    profile.deleteLater()


def delete_profile():
    global _profile
    if _profile is not None:
        do_delete_profile(_profile)
    _profile = None
    for profile in private_profiles:
        do_delete_profile(profile)
    del private_profiles[:]


_quickmarks = None


def quickmarks():
    global _quickmarks
    if _quickmarks is None:
        _quickmarks = {}
        try:

# Path: vise/config.py
# def color(key, default):
#     ans = colors().get(key)
#     if not ans or ans == 'default':
#         ans = default
#     return ans
# 
# @lru_cache()
# def font_sizes():
#     uff = (load_config(user=True).get('fonts') or {}).get('sizes') or {}
#     dff = load_config(user=False)['fonts']['sizes']
#     sizes = {}
# 
#     def conv(x):
#         if x == 'default':
#             return 0
#         try:
#             return int(x)
#         except Exception:
#             pass
# 
#     def get_ff(x):
#         if isinstance(x, dict):
#             return conv(x.get(hostname) or x.get('*'))
#         return conv(x)
# 
#     for ftype, val in uff.items():
#         val = get_ff(val)
#         if isinstance(val, int):
#             sizes[ftype] = val
# 
#     for ftype, val in dff.items():
#         if ftype not in sizes:
#             val = get_ff(val)
#             if isinstance(val, int):
#                 sizes[ftype] = val
# 
#     return sizes
# 
# Path: vise/constants.py
# DOWNLOADS_URL = 'vise:downloads'
# WELCOME_URL = 'vise:welcome'
# STATUS_BAR_HEIGHT = 24
# FOLLOW_LINK_KEY_MAP = {getattr(Qt.Key, 'Key_' + x.upper()): x for x in string.ascii_lowercase + string.digits}
# VISE_SCHEME = 'vise'
# def _get_cache_dir():
# def _get_config_dir():
# def get_windows_username():
# def local_socket_address():
# 
# Path: vise/resources.py
# def get_data_as_file(name):
#     return open(get_data_as_path(name), 'rb')


# Path: vise/settings.py
import glob
import json
import os
import apsw
from base64 import standard_b64decode, standard_b64encode
from binascii import hexlify
from collections import defaultdict
from functools import lru_cache
from PyQt6.QtGui import QKeySequence
from PyQt6.QtWebEngineCore import (QWebEngineProfile, QWebEngineScript,
                                   QWebEngineSettings)
from PyQt6.QtWidgets import QApplication
from .config import color, font_sizes
from .constants import (DOWNLOADS_URL, VISE_SCHEME, appname, cache_dir,
                        config_dir)
from .resources import get_data_as_file
    from .url_intercept import Interceptor
    from .vise_scheme import UrlSchemeHandler
        from .downloads import download_requested
    from .config import font_families, font_sizes
        from .downloads import download_requested
    from .utils import safe_disconnect
        from .utils import parse_url

    if _profile is None:
        _profile = create_profile()
        _profile.downloadRequested.connect(download_requested)
    return _profile


def do_delete_profile(profile):
    safe_disconnect(profile.downloadRequested)
    profile.setParent(None)
    profile.deleteLater()


def delete_profile():
    global _profile
    if _profile is not None:
        do_delete_profile(_profile)
    _profile = None
    for profile in private_profiles:
        do_delete_profile(profile)
    del private_profiles[:]


_quickmarks = None


def quickmarks():
    global _quickmarks
    if _quickmarks is None:
        _quickmarks = {}
        try:

            with open(os.path.join(config_dir, 'quickmarks'), 'rb') as f: