<script>
  console.log("app started with base url " + config.endpoint);
  import { addMessages, init } from "svelte-i18n";
  import en from "./locales/en.json";
  import de from "./locales/de.json";
  addMessages("en", en);
  addMessages("en-US", en);
  addMessages("de", de);
  addMessages("de-DE", de);
  //
  import Scanner from "./Scanner.svelte";
  import Login from "./Login.svelte";
  import Settings from "./Settings.svelte";
  import { apikey, lang, page } from "./store.js";
  $: is_configured = $apikey && $apikey !== "null" && $apikey !== "";
  $: settings_open = $page === "settings";
  init({
    fallbackLocale: "en-US",
    initialLocale: $lang,
  });
</script>

{#if settings_open && is_configured}
  <Settings />
{:else if is_configured}
  <Scanner />
{:else}
  <Login />
{/if}
