<?php

declare(strict_types=1);

auth_logout();

header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noindex, nofollow, noarchive, nosnippet">
    <title>Signing out…</title>
</head>
<body>
<p>Signing out…</p>
<script src="<?= e(app_public_script('/assets/js/contracts-indexeddb.js')) ?>"></script>
<script>
(function () {
    'use strict';

    var loginUrl = <?= json_encode(app_path('/admin/login'), JSON_UNESCAPED_SLASHES) ?>;
    var db = window.KarviContractsDB;

    function goLogin() {
        window.location.replace(loginUrl);
    }

    if (!db || typeof db.clearAll !== 'function') {
        goLogin();
        return;
    }

    db.clearAll().catch(function () {
        return null;
    }).finally(goLogin);
})();
</script>
</body>
</html>
