<?php
$development = $this->getParam('development', false);
$type = $this->getParam('type', 'general_server_error');
$code = $this->getParam('code', 500);
$errorID = $this->getParam('errorID', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
$message = $this->getParam('message', '');
$trace = $this->getParam('trace', []);
$projectName = $this->getParam('projectName', '');
$projectURL = $this->getParam('projectURL', '');
$title = $this->getParam('title', '')
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="description" content="" />
    <link rel="icon" href="/favicon.png" />
    <link
        rel="preload"
        href="/fonts/inter/inter-v8-latin-600.woff2"
        as="font"
        type="font/woff2"
        crossorigin />
    <link
        rel="preload"
        href="/fonts/inter/inter-v8-latin-regular.woff2"
        as="font"
        type="font/woff2"
        crossorigin />
    <link
        rel="preload"
        href="/fonts/poppins/poppins-v19-latin-500.woff2"
        as="font"
        type="font/woff2"
        crossorigin />
    <link
        rel="preload"
        href="/fonts/poppins/poppins-v19-latin-600.woff2"
        as="font"
        type="font/woff2"
        crossorigin />
    <link
        rel="preload"
        href="/fonts/poppins/poppins-v19-latin-700.woff2"
        as="font"
        type="font/woff2"
        crossorigin />
    <link
        rel="preload"
        href="/fonts/source-code-pro/source-code-pro-v20-latin-regular.woff2"
        as="font"
        type="font/woff2"
        crossorigin />

    <link rel="stylesheet" href="https://unpkg.com/@appwrite.io/pink" />
    <link rel="preload" as="style" type="text/css" href="/fonts/main.css" />
    <link rel="stylesheet" href="/fonts/main.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta http-equiv="content-security-policy" content="">
    <title><?php echo $this->print($title); ?></title>

    <style>
        @media(min-width:768px) {
            article.card {
                padding: 2rem !important;
            }
        }
    </style>
</head>

<body>
    <div class="container u-margin-block-start-24">
        <article class="card u-padding-16">
            <div class="u-flex u-flex-vertical u-gap-16">
                <h1 class="heading-level-4 u-trim-1">Error <?php echo $this->print($code); ?></h1>
                <p class="text"><?php echo $this->print($message); ?></p>
                <div class="u-flex u-flex-vertical u-gap-8">
                    <p class="text">Type</p>
                    <p><code class="inline-code"><?php echo $this->print($type); ?></code></p>
                </div>
                <?php if ($development) : ?>
                    <h2 class="heading-level-5 u-trim-1">Error Trace</h2>
                    <?php foreach ($trace as $log) : ?>
                        <div class="table-with-scroll">
  <div class="table-wrapper">
                        <table class="table is-remove-outer-styles">
                        <tbody class="table-tbody">
                            <?php foreach ($log as $key => $value) : ?>
                                <tr>
                                    <td class="table-col" style="width: 120px"><?php echo $this->print($key, self::FILTER_ESCAPE); ?></td>
                                    <td class="table-col"><code class="grid-code u-max-height-200 u-overflow-x-auto u-overflow-y-auto">
                                        <?php if (is_array($value)) : ?>
                                            
                                            <pre><?php echo $this->print(var_export($value, true), self::FILTER_ESCAPE); ?></pre>
                                        <?php else : ?>
                                            <pre><?php echo $this->print($value, self::FILTER_ESCAPE); ?></pre>
                                        <?php endif; ?>
                                        </code>
                                    </td>
                                </tr>

                            <?php endforeach; ?>
                            </tbody>
                        </table>
                                        </div>
                                        </div>
                    <?php endforeach; ?>
                <?php endif; ?>
            </div>
        </article>
    </div>
    <script type="text/javascript">
        const app = (JSON.parse(localStorage.getItem('appwrite')) ?? {});
        const theme = app.theme ?? 'auto';
        if (theme === 'auto') {
            const darkThemeMq = window.matchMedia('(prefers-color-scheme: dark)');
            if (darkThemeMq.matches) {
                document.body.setAttribute('class', `theme-dark`);
            } else {
                document.body.setAttribute('class', `theme-light`);
            }
        } else {
            document.body.setAttribute('class', `theme-${theme}`);
        }
    </script>
</body>

</html>