<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/session.inc"; global $isLoggedIn; global $_PROFILE; global $isLowerLoggedIn; global $app;
if (!$isLoggedIn && !$isLowerLoggedIn) header("Location: /-/login") and die();

$available = json_decode(base64_decode($_GET["available"]), true);
$isSexual = true;

die(json_encode([
    [
        "title" => "Cold Haze",
        "items" => [
            [
                "title" => "Front planner",
                "link" => "coldhaze://-/fronting",
                "show" => $available["coldHaze"],
                "icon" => "icons://planner"
            ],
            [
                "title" => "Profile scores",
                "link" => "coldhaze://-/profiles",
                "show" => $available["coldHaze"],
                "icon" => "icons://scores"
            ],
            [
                "title" => "Money tracker",
                "link" => "coldhaze://-/money",
                "show" => $available["coldHaze"] && $isLoggedIn,
                "icon" => "icons://money"
            ],
            [
                "title" => "Rules",
                "link" => "coldhaze://-/rules",
                "show" => $available["coldHaze"] && $isLoggedIn,
                "icon" => "icons://rules"
            ],
            [
                "title" => "Toys database",
                "link" => "coldhaze://-/toys",
                "show" => $available["coldHaze"] && $isLoggedIn && $isSexual,
                "icon" => "icons://toys"
            ],
            [
                "title" => "Documents",
                "link" => "coldhaze://-/docs",
                "show" => $available["coldHaze"] && $isLoggedIn,
                "icon" => "icons://documents"
            ],
            [
                "title" => "Devices",
                "link" => "coldhaze://-/computers",
                "show" => $available["coldHaze"] && $isLoggedIn,
                "icon" => "icons://computers"
            ],
            [
                "title" => "System travelling",
                "link" => "coldhaze://-/travelling",
                "show" => $available["coldHaze"],
                "icon" => "icons://travelling"
            ]
        ]
    ],
    [
        "title" => "Utilities",
        "items" => [
            [
                "title" => "Backup viewer",
                "link" => "local://backup",
                "show" => true,
                "icon" => "icons://backup"
            ],
            [
                "title" => "SSH client",
                "link" => "local://ssh",
                "show" => true,
                "icon" => "icons://ssh"
            ]
        ]
    ],
    [
        "title" => "Booru",
        "items" => [
            [
                "title" => "Home",
                "link" => "booru://home/",
                "show" => $available["booru"],
                "icon" => "icons://home"
            ],
            [
                "title" => "Search",
                "link" => "booru://search/",
                "show" => $available["booru"],
                "icon" => "icons://search"
            ],
            [
                "title" => "Followed tags",
                "link" => "booru://followed/",
                "show" => $available["booru"],
                "icon" => "icons://followed"
            ],
            [
                "title" => "Saved images",
                "link" => "booru://saved/",
                "show" => $available["booru"],
                "icon" => "icons://saved"
            ],
            [
                "title" => "Explicit gallery",
                "link" => "booru://nsfw/g/",
                "show" => $available["booru"] && $isSexual,
                "icon" => "icons://nsfw"
            ],
            [
                "title" => "Genitalia",
                "link" => "booru://nsfw/sp2/",
                "show" => $available["booru"] && $isSexual,
                "icon" => "https://booru.equestria.dev/nsfw/icon/"
            ]
        ]
    ],
    [
        "title" => "Other apps",
        "items" => [
            [
                "title" => "Ponycon.info",
                "link" => "ponycon://",
                "show" => $available["ponycon"],
                "icon" => "icons://ponycon"
            ],
            [
                "title" => "Delta",
                "link" => "delta://",
                "show" => $available["delta"],
                "icon" => "icons://delta"
            ],
            [
                "title" => "Gitea",
                "link" => "gitea://equestria.dev",
                "show" => $available["gitea"],
                "icon" => "icons://gitea"
            ],
            [
                "title" => "JetBrains Hub",
                "link" => "hub://hub/projects",
                "show" => true,
                "icon" => "icons://hub"
            ],
            [
                "title" => "YouTrack",
                "link" => "youtrack://",
                "show" => $available["youtrack"],
                "icon" => "icons://youtrack"
            ],
            [
                "title" => "Plex",
                "link" => "https://plex.equestria.dev",
                "show" => true,
                "icon" => "icons://plex"
            ],
            [
                "title" => "Proxmox",
                "link" => "https://admin.equestria.dev",
                "show" => true,
                "icon" => "icons://proxmox"
            ]
        ]
    ]
]));