<?php
namespace Claromentis\Pages\Category;

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] ?: array()) + array("_989aa346a7ff" . "ac73f8bcf3204" . "a41d45a" => base64_decode("Q291bGQgbm90IGNyZWF0ZSBhIENhdGVnb3J5IGZyb20gY29udGFpbmVyIGtl" . "eSAn"), "_2bcf1e3e0f861" . "d5bf3d9e2d68cd" . "c2557" => base64_decode("JyBoYXMgYWxyZWFkeSBiZWVuIGRlZm" . "luZWQ="), "_4d707fab93" . "bebb00bbe69" . "e8159697c90" => base64_decode(""), "_8dabb06efc95df4cff7c4afe9" . "1857b53" => base64_decode("bmFtZ" . "Q=="), "_a3c961c9f027832b3d87948e5a3" . "a73dc" => base64_decode("Q2F0ZWdvcnk" . "gJw=="), "_a553d306e3b2f1" . "320f801e43d5318" . "6dd" => base64_decode("dWFz" . "b3J0"), "_bb1fe5187ab1118886743090" . "8c6f6111" => base64_decode("RmFpbGVkIHRvIEdld" . "CBDYXRlZ29yaWVzLC" . "BpbnZhbGlkIHNvcnQ" . "gcHJvdmlkZWQ="), "_c7a496674d" . "67798deb8d0" . "26fc0aabab3" => base64_decode("RmFpbGVkIHRvIEdldCBD" . "YXRlZ29yeSwgaW52YWxp" . "ZCBDYXRlZ29yeSBJbmRl" . "eA=="), "_25867e3" . "e3db2896" . "9253f3a3" . "70c3166b" . "a" => base64_decode("ZG" . "Vz" . "Yw" . "=="), "_49c656547" . "7ee9f822b4" . "99a53e6d29" . "95f" => base64_decode("YXJyYXlfa2" . "V5X2V4aXN0" . "cw=="), "_d706c160e45bf7434fff82a" . "5976f0e19" => base64_decode("YXJyYX" . "lfa2V5" . "cw=="), "_e608e5b5c4c34a67ba97ef84c" . "1e16199" => base64_decode("J" . "w" . "=" . "="), "_aed8da0f19091214b78f80351048" . "517c" => base64_decode("c3R" . "ybG" . "Vu"), "_f61cbfe09f8" . "39854b95117f" . "e13b4a1ba" => base64_decode("c3Ry" . "cG9z"), "_7f628626dd1d55c71b1fc0932ffd" . "1d2c" => base64_decode("aXNf" . "YXJy" . "YXk="), "_cfe3120f54395b670652" . "b38c2d0a8e88" => base64_decode("c3Vic" . "3Ry"), "_28fd57f750dbb5ffb3" . "ffad3a888358a9" => base64_decode("ZGVzY3JpcHRp" . "b24="), "_98b180ae98b4" . "49777b6d1738d" . "e0d7f2c" => base64_decode("ZGlyZWN0aW" . "9u"));
use ArrayAccess;
use Claromentis\Core\Application;
use Claromentis\Pages\Exception\CategoryInvalidArgumentException;
use Claromentis\Pages\Exception\CategoryInvalidSortException;
use Claromentis\Pages\Exception\CategoryRuntimeException;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
class PagesCategories implements ArrayAccess, LoggerAwareInterface
{
    use LoggerAwareTrait;
    private $categories = [];
    private $category_factory;
    private $container_categories_prefix;
    
    
    
    
    
    
    
    
    
    public function __construct(Application $_6eb6fcb92c942851e079f8ec5fb80324, CategoryFactory $category_factory, LoggerInterface $logger = null, string $container_categories_prefix = 'pages.categories.')
    {
        $this->setLogger($logger ?? new NullLogger());
        $this->SetCategoryFactory($category_factory);
        $this->SetContainerCategoriesPrefix($container_categories_prefix);
        $this->AddRegisteredPagesCategories($_6eb6fcb92c942851e079f8ec5fb80324);
    }
    
    
    
    
    
    
    public function GetCategories(?array $_f6a16426f3b3f03ad6bacec912eec291 = null) : array
    {
        if (!isset($_f6a16426f3b3f03ad6bacec912eec291)) {
            return $this->categories;
        }
        return $this->SortCategories($this->categories, $_f6a16426f3b3f03ad6bacec912eec291);
    }
    public function GetCategoriesIndexes() : array
    {
        return $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_d706c160e45bf7434fff82a" . "5976f0e19"]($this->GetCategories());
    }
    
    
    
    
    
    
    public function GetCategory($_1cb0853fbfae1a857fd0ecf1f183e45a) : Category
    {
        if (!isset($this->GetCategories()[$_1cb0853fbfae1a857fd0ecf1f183e45a])) {
            throw new CategoryRuntimeException($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_c7a496674d67798deb8d026" . "fc0aabab3"]);
        }
        return $this->GetCategories()[$_1cb0853fbfae1a857fd0ecf1f183e45a];
    }
    
    
    
    
    
    
    public function GetCategoriesProperties(?array $_f6a16426f3b3f03ad6bacec912eec291 = null) : array
    {
        $_88c8ead63b8d5e0811d1a54a128bc21a = [];
        foreach ($this->GetCategories($_f6a16426f3b3f03ad6bacec912eec291) as $_1cb0853fbfae1a857fd0ecf1f183e45a => $_c3492cfbadbaead5d2512469c3eb908e) {
            $_88c8ead63b8d5e0811d1a54a128bc21a[$_1cb0853fbfae1a857fd0ecf1f183e45a] = $_c3492cfbadbaead5d2512469c3eb908e->GetProperties();
        }
        return $_88c8ead63b8d5e0811d1a54a128bc21a;
    }
    
    
    
    
    
    
    public function GetCategoryProperties($_1cb0853fbfae1a857fd0ecf1f183e45a) : array
    {
        return $this->GetCategory($_1cb0853fbfae1a857fd0ecf1f183e45a)->GetProperties();
    }
    
    
    
    
    
    public function HasCategory($_1f50e30be8c2fefa6881834e71d504a2) : bool
    {
        return $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_49c6565477ee9f822b499a53e6" . "d2995f"]($_1f50e30be8c2fefa6881834e71d504a2, $this->GetCategories());
    }
    
    
    
    
    
    public function offsetExists($_1f50e30be8c2fefa6881834e71d504a2) : bool
    {
        return $this->HasCategory($_1f50e30be8c2fefa6881834e71d504a2);
    }
    
    
    
    
    
    public function offsetGet($_1f50e30be8c2fefa6881834e71d504a2) : ?Category
    {
        return $this->GetCategories()[$_1f50e30be8c2fefa6881834e71d504a2] ?? null;
    }
    
    
    
    
    
    public function offsetSet($_1f50e30be8c2fefa6881834e71d504a2, $_71f6a5b5840d77d6f5700b8129d32c14)
    {
        $this->SetCategory($_1f50e30be8c2fefa6881834e71d504a2, $_71f6a5b5840d77d6f5700b8129d32c14);
    }
    
    
    
    
    public function offsetUnset($_1f50e30be8c2fefa6881834e71d504a2)
    {
        unset($this->categories[$_1f50e30be8c2fefa6881834e71d504a2]);
    }
    
    
    
    
    
    
    
    public function SortCategories(array $_006a00786ba8fa97908790a83741c8d8, array $_f6a16426f3b3f03ad6bacec912eec291)
    {
        $_c4aca92597dd88774c8cfe7ac4ec7eb6 = $_f6a16426f3b3f03ad6bacec912eec291[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_8dabb06efc95df4" . "cff7c4afe91857b5" . "3"]] ?? $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_4d707fab93bebb00bbe69e81" . "59697c90"];
        $_98b180ae98b449777b6d1738de0d7f2c = isset($_f6a16426f3b3f03ad6bacec912eec291[$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_98b180ae98b44" . "9777b6d1738de0" . "d7f2c"]]) && $_f6a16426f3b3f03ad6bacec912eec291[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_98b180ae98b449" . "777b6d1738de0d7" . "f2c"]] === $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_25867e3e3db289692" . "53f3a370c3166ba"] ? -1 : 1;
        switch ($_c4aca92597dd88774c8cfe7ac4ec7eb6) {
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_8dabb06e" . "fc95df4cf" . "f7c4afe91" . "857b53"]:
                $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_a553d306e3b2f13" . "20f801e43d53186d" . "d"]($_006a00786ba8fa97908790a83741c8d8, function (Category $_5feede65e7cfe8f0b3d9854c0363d548, Category $_74e6c647b312810242fc360c4ae14d72) use($_98b180ae98b449777b6d1738de0d7f2c) {
                    return $_98b180ae98b449777b6d1738de0d7f2c * ($_5feede65e7cfe8f0b3d9854c0363d548->GetName() <=> $_74e6c647b312810242fc360c4ae14d72->GetName());
                });
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_28fd57f750dbb5ff" . "b3ffad3a888358a9"]:
                $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_a553d306e3b2f1320f801e43" . "d53186dd"]($_006a00786ba8fa97908790a83741c8d8, function (Category $_5feede65e7cfe8f0b3d9854c0363d548, Category $_74e6c647b312810242fc360c4ae14d72) use($_98b180ae98b449777b6d1738de0d7f2c) {
                    return $_98b180ae98b449777b6d1738de0d7f2c * ($_5feede65e7cfe8f0b3d9854c0363d548->GetDescription() <=> $_74e6c647b312810242fc360c4ae14d72->GetDescription());
                });
                break;
            default:
                throw new CategoryInvalidSortException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_bb1fe5187ab11188867430908c6f" . "6111"]);
        }
        return $_006a00786ba8fa97908790a83741c8d8;
    }
    
    
    
    
    
    
    private function AddRegisteredPagesCategories(Application $_6eb6fcb92c942851e079f8ec5fb80324)
    {
        $_dd051582f409bdf1bf513beb806bdd2b = $_6eb6fcb92c942851e079f8ec5fb80324->keys();
        $container_categories_prefix = $this->GetContainerCategoriesPrefix();
        $_c8ef295ed962a46e6246480731bf7b99 = $this->GetCategoryFactory();
        foreach ($_dd051582f409bdf1bf513beb806bdd2b as $_8613c2214654dc2b71f546198bd9ce16) {
            $_c3492cfbadbaead5d2512469c3eb908e = null;
            if ($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_f61cbfe09f839854b95117fe13b4a1b" . "a"]($_8613c2214654dc2b71f546198bd9ce16, $container_categories_prefix) !== 0) {
                continue;
            }
            $_0fe621d40f6a1573fb986abe53021cea = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_cfe3120f54395" . "b670652b38c2d0" . "a8e88"]($_8613c2214654dc2b71f546198bd9ce16, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_aed8da0f19091214b78f8" . "0351048517c"]($container_categories_prefix));
            if ($this->HasCategory($_0fe621d40f6a1573fb986abe53021cea)) {
                $this->logger->warning($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_a3c961c9f027832b3d87948e" . "5a3a73dc"] . (string) $_0fe621d40f6a1573fb986abe53021cea . $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_2bcf1e3" . "e0f861d5" . "bf3d9e2d" . "68cdc255" . "7"]);
                continue;
            }
            if ($_c8ef295ed962a46e6246480731bf7b99->IsCategoryInstance($_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16])) {
                $_c3492cfbadbaead5d2512469c3eb908e = $_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16];
            } elseif ($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_7f628626dd1d55c71b1fc0932ffd1d2" . "c"]($_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16])) {
                try {
                    $_c3492cfbadbaead5d2512469c3eb908e = $_c8ef295ed962a46e6246480731bf7b99->CreateFromArray($_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16]);
                } catch (CategoryInvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
                    $this->logger->warning($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_989aa346a7ffac73f8bcf3204a" . "41d45a"] . (string) $_8613c2214654dc2b71f546198bd9ce16 . $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_e608e5b5c4c34a67ba97ef84c1e" . "16199"]);
                }
            }
            if (isset($_c3492cfbadbaead5d2512469c3eb908e)) {
                $this->SetCategory($_0fe621d40f6a1573fb986abe53021cea, $_c3492cfbadbaead5d2512469c3eb908e);
            }
        }
    }
    
    
    
    
    private function GetCategoryFactory() : CategoryFactory
    {
        return $this->category_factory;
    }
    
    
    
    
    private function GetContainerCategoriesPrefix() : string
    {
        return $this->container_categories_prefix;
    }
    
    
    
    
    
    private function SetCategory($_1f50e30be8c2fefa6881834e71d504a2, Category $_c3492cfbadbaead5d2512469c3eb908e)
    {
        $this->categories[$_1f50e30be8c2fefa6881834e71d504a2] = $_c3492cfbadbaead5d2512469c3eb908e;
    }
    
    
    
    
    private function SetCategoryFactory(CategoryFactory $category_factory)
    {
        $this->category_factory = $category_factory;
    }
    
    
    
    
    private function SetContainerCategoriesPrefix(string $container_categories_prefix)
    {
        $this->container_categories_prefix = $container_categories_prefix;
    }
}