# This is free software for the public good of a permacomputer hosted at
# permacomputer.com, an always-on computer by the people, for the people.
# One which is durable, easy to repair, & distributed like tap water
# for machine learning intelligence.
#
# The permacomputer is community-owned infrastructure optimized around
# four values:
#
#   TRUTH      First principles, math & science, open source code freely distributed
#   FREEDOM    Voluntary partnerships, freedom from tyranny & corporate control
#   HARMONY    Minimal waste, self-renewing systems with diverse thriving connections
#   LOVE       Be yourself without hurting others, cooperation through natural law
#
# This software contributes to that vision by archiving the web, preserving digital knowledge before it disappears.
# Code is seeds to sprout on any abandoned technology.

"""
serp - Search Engine Results Page for neopig.
# Side quest 20/21: SERP is just the beginning.

FastAPI web server for searching and browsing crawled media.
"""

from .i18n import (
    TRANSLATIONS,
    LANG_NAMES,
    get_lang,
    t,
    inject_i18n,
    NAV_HTML,
    SEARCH_BOX_HTML,
)
from .models import CrawlRequest
from .app import app, templates, DB_PATH, VAULT_PATH, CRAWL_DISABLED, IMPORT_MODE, get_language
from .archive import (
    ArchiveDB,
    read_from_tarball,
    find_media_in_tarball,
    _open_tarball,
    TAR_PATH,
    TAR_OFFSET,
    TAR_MEMBERS,
    TAR_MEDIA_INDEX,
    ARCHIVE_ROOT,
    TEMP_DB_PATH,
)
from .logging import start_job_logging, stop_job_logging, get_job_logs
from .utils import slugify

# Import server module to register all routes on the app
from . import server

# Re-export server components
db = server.db
main = server.main
init_tarball_mode = server.init_tarball_mode

__all__ = [
    # i18n
    'TRANSLATIONS', 'LANG_NAMES', 'get_lang', 't', 'inject_i18n', 'NAV_HTML', 'SEARCH_BOX_HTML',
    # Models
    'CrawlRequest',
    # App
    'app', 'templates', 'DB_PATH', 'VAULT_PATH', 'CRAWL_DISABLED', 'IMPORT_MODE',
    # Archive
    'ArchiveDB', 'read_from_tarball', 'find_media_in_tarball', '_open_tarball',
    'TAR_PATH', 'TAR_OFFSET', 'TAR_MEMBERS', 'TAR_MEDIA_INDEX', 'ARCHIVE_ROOT', 'TEMP_DB_PATH',
    # Logging
    'start_job_logging', 'stop_job_logging', 'get_job_logs',
    # Utils
    'slugify',
    # Server
    'db', 'main', 'init_tarball_mode', 'server',
]
