// @ts-check
import { parseConfiguration } from "./parse-config.mjs";

export const configuration = parseConfiguration();
export const { webserver } = configuration;
export const apiServerBaseURL = configuration.webserver.base_url;
export const sentryDSN = configuration.sentry_dsn_js;
export const apiServerPort = !apiServerBaseURL
  ? undefined
  : configuration.webserver?.port;
export const siteName = configuration.webserver.ui.home.site_name || "Kemono";
export const homeBackgroundImage =
  configuration.webserver.ui.home.home_background_image;
export const homeMascotPath = configuration.webserver.ui.home.mascot_path;
export const homeLogoPath = configuration.webserver.ui.home.logo_path;
export const homeWelcomeCredits = configuration.webserver.ui.home.welcome_credits;
export const homeAnnouncements = configuration.webserver.ui.home.announcements;
// TODO: in development it should point to webpack server
export const kemonoSite = configuration.site || "http://localhost:5000";
export const paysiteList = configuration.webserver.ui.config.paysite_list;
export const artistsOrCreators =
  configuration.webserver.ui.config.artists_or_creators ?? "Artists";
export const disableDMs = configuration.webserver.ui.sidebar?.disable_dms ?? true;
export const disableFAQ = configuration.webserver.ui.sidebar?.disable_faq ?? true;
export const disableFilehaus =
  configuration.webserver.ui.sidebar?.disable_filehaus ?? true;
export const sidebarItems = configuration.webserver.ui.sidebar_items;
export const footerItems = configuration.webserver.ui.footer_items;
export const bannerGlobal = configuration.webserver.ui.banner?.global;
export const bannerWelcome = configuration.webserver.ui.banner?.welcome;
export const headerAd = configuration.webserver.ui.ads?.header;
export const middleAd = configuration.webserver.ui.ads?.middle;
export const footerAd = configuration.webserver.ui.ads?.footer;
export const sliderAd = configuration.webserver.ui.ads?.slider;
export const videoAd = configuration.webserver.ui.ads?.video;
export const isArchiveServerEnabled = configuration.archive_server?.enabled ?? false;
export const analyticsEnabled = configuration.webserver.ui.matomo?.enabled ?? false;
export const analyticsCode = configuration.webserver.ui.matomo?.plain_code;
export const iconsPrepend = webserver.ui.files_url_prepend?.icons_base_url || "";
export const bannersPrepend = webserver.ui.files_url_prepend?.banners_base_url || "";
export const thumbnailsPrepend =
  webserver.ui.files_url_prepend?.thumbnails_base_url || "";
export const isFileServingEnabled = Boolean(
  configuration.archive_server?.file_serving_enabled
);
export const gitCommitHash = process.env.GIT_COMMIT_HASH;
export const buildDate = process.env.BUILD_DATE;
