<!DOCTYPE html>
<html lang="en">
  <head>
    <title>{{ title }}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/x-icon" href="{{ static_url('img/favicon/favicon.ico') }}">
    <link rel="shortcut icon" href="{{static_url('img/favicon/favicon.ico') }}" type="image/x-icon" />
    <meta name="msapplication-TileColor" content="#2b5797">
    <meta name="msapplication-TileImage" content="{{ static_url('img/favicon/mstile-144x144.png') }}">
    {% block header %} {% end %}
    <style>
      #mask {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100vw;
        height: 100vh;
        position: absolute;
        top: 0;
        left: 0;
        background: #EFEFEF;
        font-family: "Roboto", sans-serif;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div id="mask">
        <div>
          <div style="display: flex; align-items: center; justify-content: center; color: #859145;">
            <img src="{{ static_url('img/favicon/favicon-32x32.png')}}"/>&nbsp;<b>PoWA</b>
          </div>
          <br>
          <noscript>
            Javascript is required to display this page.
          </noscript>
          <script type="text/javascript">
            if (Boolean(JSON.parse(localStorage.getItem("theme") == "dark"))) {
              document.getElementById('mask').style.background = "#333333";
              document.getElementById('mask').style.color = "#ffffff";
            }
         </script>
          <span id="waiter">Loading…</span>
        </div>
      </div>
    </div>
    {% block data %} {% end %}
    <script type="text/messages">
    {% raw to_json(dict(flashed_messages().items())) %}
    </script>
    {% if current_user %}
    <script type="text/messages">
    {% raw to_json(dict(sanitycheck_messages().items())) %}
    </script>
    {% end %}
    {% if handler.application.settings['debug'] %}
      <script>
        function showLoadError() {
          alert("You're runing the dev version. Please make sure ViteJS server is running.");
        }
      </script>
      <script type="module" src="http://localhost:5173/@vite/client"></script>
      <script type="module" src="http://localhost:5173/powa/static/js/main.js" onerror="showLoadError()"></script>
    {% else %}
      {% for css in manifest('powa/static/js/main.js')['css'] %}
      <link rel="stylesheet" href="{{static_url("dist/" + css) }}" />
      {% end %}
      {% for chunk in manifest('powa/static/js/main.js')['imports'] %}
        {% for css in manifest(chunk).get("css", []) %}
        <link rel="stylesheet" href="{{static_url("dist/" + css) }}" />
        {% end %}
      {% end %}
      <script type="module" src="{{ static_url("dist/" + manifest('powa/static/js/main.js')['file']) }}"></script>
      {% for chunk in manifest('powa/static/js/main.js')['imports'] %}
      <script type="modulepreload" src="{{ static_url("dist/" + manifest(chunk)['file']) }}"></script>
      {% end %}
    {% end %}
  </body>
</html>
