<?php global $isLoggedIn; global $metadata; global $memberData; global $isLowerLoggedIn; global $systemID; global $app; global $lang; global $pages; $pronouns = getMemberPronouns($memberData['pronouns']); ?>
<div id="member-details" class="<?= (($isLoggedIn || $isLowerLoggedIn) && $systemID !== $app["other"]["id"]) ? 'member-details-loggedIn' : 'member-details-loggedIn2' ?>" style="<?php if (!$isLoggedIn && !$isLowerLoggedIn): ?>grid-template-columns: repeat(4, 1fr);<?php endif; ?> background-color: <?= isset($memberData["color"]) ? '#' . $memberData["color"] . "33" : "transparent" ?>; margin-left: -20px; margin-right: -20px;">
    <div>
        <b><?= $lang["details"]["food"] ?></b><span class="member-small-separator"><br></span>
        <?= match ($metadata["food"]) {
            0 => "<span data-bs-toggle='tooltip' title='This pony&apos;s species indicates that this pony doesn&apos;t need to eat food, therefore this pony can eat all foods.'>" . $lang["details"]["food_states"][0] . "</span>",
            1 => "<span data-bs-toggle='tooltip' title='This pony can&apos;t eat fish or meat.'>" . $lang["details"]["food_states"][1] . "</span>",
            2 => "<span data-bs-toggle='tooltip' title='This pony can&apos;t eat meat, but can eat fish.'>" . $lang["details"]["food_states"][2] . "</span>",
            3 => "<span data-bs-toggle='tooltip' title='This pony can eat all foods, meat and fish included.'>" . $lang["details"]["food_states"][3] . "</span>",
        } ?>
    </div>
    <div>
        <b><?= $lang["details"]["memory"] ?></b><span class="member-small-separator"><br></span>
        <?= match ($metadata["shared_memory"]) {
            0 => "<span data-bs-toggle='tooltip' title='This pony doesn&apos;t directly share memories with this pony&apos;s headmates, b, but is able to (slowly) query them if that is needed.'>" . $lang["details"]["memory_states"][0] . "</span>",
            1 => "<span data-bs-toggle='tooltip' title='This pony doesn&apos;t directly share memories with this pony&apos;s headmates, but may be able to share certain memories and/or share memories at will.'>" . $lang["details"]["memory_states"][1] . "</span>",
            2 => "<span data-bs-toggle='tooltip' title='This pony shares all memories with this pony&apos;s headmates.'>" . $lang["details"]["memory_states"][2] . "</span>",
        } ?>
    </div>
        <div>
            <b>Age:</b><span class="member-small-separator"><br></span>
            <?php if (!isset($metadata["birth"]["year"]) || $metadata["birth"]["age"] > 0 || $metadata["birth"]["age"] === -1): ?>
                <?php if ($metadata["birth"]["age"] === -1): $age = abs(log(0)); // => INF ?>
                    <?= "<span data-bs-toggle='tooltip' title='This pony never ages and doesn&apos;t have a defined age, making this pony pretty much eternal.'>Eternal</span>" ?>
                <?php elseif ($metadata["birth"]["age"] <= 0): ?>
                    -
                <?php else: $age = $metadata["birth"]["age"]; if (is_numeric($metadata["birth"]["age"])): ?>
                    <?= "<span data-bs-toggle='tooltip' title='This pony doesn&apos;t age like the body does, making this pony stay " . $metadata["birth"]["age"] . " years old for this pony&apos;s entire life.'>" . $metadata["birth"]["age"] . "* years old</span>" ?>
                <?php else: ?>
                    <?= "<span data-bs-toggle='tooltip' title='This pony&apos;s age changes frequently between " . explode("-", $metadata["birth"]["age"])[0] . " and " . explode("-", $metadata["birth"]["age"])[1] . " years old, and this &apos;t have a single defined age.'>Sliding " . explode("-", $metadata["birth"]["age"])[0] . " to " . explode("-", $metadata["birth"]["age"])[1] . "</span>" ?>
                <?php endif; endif; ?>
            <?php else: ?>
                <?php if ($metadata["birth"]["year"] <= 1900): ?>
                    -
                <?php else: ?>
                    <?php

                    $birthdate = $metadata["birth"]["year"] . date('-m-d');
                    if (isset($metadata["birth"]["date"]) && trim($metadata["birth"]["date"]) !== "" && $metadata["birth"]["date"] !== "01-01") {
                        $birthdate = $metadata["birth"]["year"] . "-" . $metadata["birth"]["date"];
                    }

                    $age = (int)date('Y') - $metadata["birth"]["year"] + (strtotime(date('Y') . "-" . $metadata["birth"]["date"]) <= time() ? 0 : -1);
                    $age2 = floor((time() - strtotime($birthdate)) / 31557600);
                    $birthday = "as time passes";

                    if (isset($metadata["birth"]["date"]) && trim($metadata["birth"]["date"]) !== "" && $metadata["birth"]["date"] !== "01-01") {
                        $birthday = "every " . date('F jS', strtotime(date('Y') . "-" . $metadata["birth"]["date"]));
                    }

                    ?>
                    <?= "<span data-bs-toggle='tooltip' title='$age2 with the old algorithm | This pony ages like the body does, making this pony stay " . $age . " years old for now, having this age change $birthday.'>" . $age . " years old</span>" ?>
                <?php endif; ?>
            <?php endif; ?>
        </div>
    <?php if ($systemID !== $app["other"]["id"]): if ($isLoggedIn || $isLowerLoggedIn):  ?>
    <div>
        <b><?= $lang["details"]["code"] ?></b><span class="member-small-separator"><br></span>
        <?php if (isset($metadata["code"]) && trim($metadata["code"]) !== ""): ?>
            <code style="color: white;"><?= strtoupper(substr($metadata["code"], 0, 3)) ?></code>
        <?php else: ?>
            -
        <?php endif; ?>
    </div>
    <?php endif; ?>
    <div>
        <b>Primary interest:</b><span class="member-small-separator"><br></span>
        <?php if (isset($metadata["interest"]) && trim($metadata["interest"]) !== ""): ?>
            <?= trim($metadata["interest"]) ?>
        <?php else: ?>
            -
        <?php endif; ?>
    </div>
    <?php endif ?>
<?php if ($systemID !== $app["other"]["id"]): ?>
</div>
<?php endif; ?>
<?php if ($isLoggedIn || $isLowerLoggedIn): ?>
<?php if ($systemID !== $app["other"]["id"]): ?>
<div id="member-details-2" style="background-color: <?= isset($memberData["color"]) ? '#' . $memberData["color"] . "33" : "transparent" ?>; margin-left: -20px; margin-right: -20px;<?php if ($isLowerLoggedIn): ?>grid-template-columns: repeat(3, 1fr);<?php endif; ?>">
<?php endif; ?>
    <?php $age2 = $age ?? 0; if (is_string($age2)) $age2 = (int)(explode("-", $age2)[1] ?? "0"); if (((isset($age2) && $age2 >= 16 && $metadata["little"] === 0) || (!isset($age2) && $metadata["little"] === 0)) || $metadata["sexual_features"]): ?>
    <?php if ($isLoggedIn && $systemID !== $app["other"]["id"]): ?>
    <div>
        <span style="vertical-align: middle;">
            <b>Sexual consent:</b><span class="member-small-separator"><br></span>
            <?php if ($metadata["sexually_active"]): ?>
                <span title="Consent is assumed when having sex with this pony, however this pony may ask to not have sex at the moment and such request must be honored." data-bs-toggle="tooltip">Preemptive</span>
            <?php else: ?>
                <span title="Consent is absolutely required every time when having sex with this pony." data-bs-toggle="tooltip">Required</span>
            <?php endif; ?>
        </span>
        <?php if (!((isset($age) && $age >= 16 && $metadata["little"] === 0) || (!isset($age) && $metadata["little"] === 0))): ?>
        <img src="/assets/icons/warning.svg" style="width: 16px;" title="Although this pony is able to engage in sexual relationships, this pony is not allowed to have sex with ponies who are over 16 years old." data-bs-toggle="tooltip">
        <?php endif; ?>
    </div>
    <?php endif; ?>
    <div>
        <b><span class="member-detail-desktop">Sexual alignment</span><span class="member-detail-mobile">Sex. algn.</span>:</b><span class="member-small-separator"><br></span>
        <?php switch ($metadata["alignment"]["sexual"]) {
            case "aroace":
                echo "Asexual";
                break;
            case "hetero":
                echo "Straight";
                break;
            case "homo":
                echo $pronouns["subjective"] === "she" ? "Lesbian" : ($pronouns["subjective"] === "he" ? "Gay" : "Homosexual");
                break;
            case "bi":
                echo "Bisexual";
                break;
            case "pan":
                echo "Pansexual";
                break;
            case "poly":
                echo "Polysexual";
                break;
        } ?><?php if ($metadata["polyamorous"]["sexual"]): ?> (poly)<?php endif; ?>
    </div>
    <?php else: ?>
    <div>
        <style>
            #member-details-2 {
                grid-template-columns: <?= $isLowerLoggedIn ? "1fr 1fr 1fr" : "2fr 1fr 1fr" ?>;
            }
        </style>
        <div style="display: flex; align-items: center; justify-content: center; height: 100%;opacity:.5;">This pony is too young to be in a sexual relationship.</div>
    </div>
    <?php endif; ?>
    <div>
        <b><span class="member-detail-desktop">Romantic alignment</span><span class="member-detail-mobile">Rom. algn.</span>:</b><span class="member-small-separator"><br></span>
        <?php switch ($metadata["alignment"]["romantic"]) {
            case "aroace":
                echo "Aromantic";
                break;
            case "hetero":
                echo "Heteroromantic";
                break;
            case "homo":
                echo $pronouns["subjective"] === "she" ? "Lesbiromantic" : ($pronouns["subjective"] === "he" ? "Gay" : "Homoromantic");
                break;
            case "bi":
                echo "Biromantic";
                break;
            case "pan":
                echo "Panromantic";
                break;
            case "poly":
                echo "Polyromantic";
                break;
        } ?><?php if ($metadata["polyamorous"]["romantic"]): ?> (poly)<?php endif; ?>
    </div>
    <?php if ($systemID !== $app["other"]["id"]): ?>
    <div>
        <b>Birthday:</b><span class="member-small-separator"><br></span>
        <?php if (isset($metadata["birth"]["date"]) && trim($metadata["birth"]["date"]) !== "" && $metadata["birth"]["date"] !== "01-01"): ?>
            <?= date('F jS', strtotime(date('Y') . "-" . $metadata["birth"]["date"])) ?>
        <?php else: ?>
            -
        <?php endif; ?>
    </div>
    <?php endif; ?>
</div>
<?php endif; ?>