<?php
namespace Claromentis\Pages\Category;

$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] ?: array()) + array("_c7a496674d67798" . "deb8d026fc0aabab" . "3" => base64_decode("RmFpbGVkIHRvIEdldCBDYXRl" . "Z29yeSwgaW52YWxpZCBDYXRl" . "Z29yeSBJbmRleA=="), "_7f62862" . "6dd1d55c" . "71b1fc09" . "32ffd1d2" . "c" => base64_decode("aXNf" . "YXJy" . "YXk="), "_4d707fab93be" . "bb00bbe69e815" . "9697c90" => base64_decode(""), "_989aa346a7ffac73f8bcf320" . "4a41d45a" => base64_decode("Q291bGQgbm90IGNyZWF" . "0ZSBhIENhdGVnb3J5IG" . "Zyb20gY29udGFpbmVyI" . "GtleSAn"), "_d706c160e" . "45bf7434ff" . "f82a5976f0" . "e19" => base64_decode("YXJyYXlfa2V5" . "cw=="), "_cfe3120f54395b670652b38c2d0a8" . "e88" => base64_decode("c3" . "Vi" . "c3" . "Ry"), "_aed8da0f19091214b78f8035104851" . "7c" => base64_decode("c3RybG" . "Vu"), "_bb1fe518" . "7ab111888" . "67430908c" . "6f6111" => base64_decode("RmFpbGVkIHRvIEdldCBDYXRlZ29yaWVzLCBpbnZhbGlkIHNvcnQgcHJvdml" . "kZWQ="), "_f61cbfe09f83" . "9854b95117fe1" . "3b4a1ba" => base64_decode("c3R" . "ycG" . "9z"), "_49c6565477ee9f822" . "b499a53e6d2995f" => base64_decode("YXJyYXl" . "fa2V5X2" . "V4aXN0c" . "w=="), "_8dabb06efc95df4cff7c4afe" . "91857b53" => base64_decode("bmFtZ" . "Q=="), "_98b180ae98" . "b449777b6d1" . "738de0d7f2c" => base64_decode("ZGlyZW" . "N0aW9u"), "_28fd57f750db" . "b5ffb3ffad3a8" . "88358a9" => base64_decode("ZGVzY3JpcHRpb24" . "="), "_a553d306e" . "3b2f1320f8" . "01e43d5318" . "6dd" => base64_decode("dWFz" . "b3J0"), "_25867e3e3db289" . "69253f3a370c316" . "6ba" => base64_decode("ZGVzY" . "w=="), "_a3c961c9f027832b3d87948e5a3" . "a73dc" => base64_decode("Q2F0Z" . "Wdvcn" . "kgJw=" . "="), "_2bcf1e3e0f861d5b" . "f3d9e2d68cdc2557" => base64_decode("JyBoYXMgYWxyZWFkeSBi" . "ZWVuIGRlZmluZWQ="), "_e608e5b5c4c34a67ba97ef84" . "c1e16199" => base64_decode("Jw=" . "="));
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["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_d706c160e" . "45bf7434ff" . "f82a5976f0" . "e19"]($this->GetCategories());
    }
    
    
    
    
    
    
    public function GetCategory($_1cb0853fbfae1a857fd0ecf1f183e45a) : Category
    {
        if (!isset($this->GetCategories()[$_1cb0853fbfae1a857fd0ecf1f183e45a])) {
            throw new CategoryRuntimeException($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_c7a496674d67798deb8d026fc0aaba" . "b3"]);
        }
        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["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_49c6565477ee9f822b499a53e6d2995" . "f"]($_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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_8dabb06efc95df4cff7" . "c4afe91857b53"]] ?? $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_4d707fab93bebb00b" . "be69e8159697c90"];
        $_98b180ae98b449777b6d1738de0d7f2c = isset($_f6a16426f3b3f03ad6bacec912eec291[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_98b180ae98b4497" . "77b6d1738de0d7f2" . "c"]]) && $_f6a16426f3b3f03ad6bacec912eec291[$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_98b180ae98b449777b6d1738de0" . "d7f2c"]] === $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_25867e3e3db" . "28969253f3a3" . "70c3166ba"] ? -1 : 1;
        switch ($_c4aca92597dd88774c8cfe7ac4ec7eb6) {
            case $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_8dabb06efc95" . "df4cff7c4afe9" . "1857b53"]:
                $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_a553d306e3b2f1320f801e43d53186d" . "d"]($_006a00786ba8fa97908790a83741c8d8, function (Category $_5feede65e7cfe8f0b3d9854c0363d548, Category $_74e6c647b312810242fc360c4ae14d72) use($_98b180ae98b449777b6d1738de0d7f2c) {
                    return $_98b180ae98b449777b6d1738de0d7f2c * ($_5feede65e7cfe8f0b3d9854c0363d548->GetName() <=> $_74e6c647b312810242fc360c4ae14d72->GetName());
                });
                break;
            case $GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_28fd57f750dbb5ffb3ffad3a888358" . "a9"]:
                $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_a553d306e3b2f1320f8" . "01e43d53186dd"]($_006a00786ba8fa97908790a83741c8d8, function (Category $_5feede65e7cfe8f0b3d9854c0363d548, Category $_74e6c647b312810242fc360c4ae14d72) use($_98b180ae98b449777b6d1738de0d7f2c) {
                    return $_98b180ae98b449777b6d1738de0d7f2c * ($_5feede65e7cfe8f0b3d9854c0363d548->GetDescription() <=> $_74e6c647b312810242fc360c4ae14d72->GetDescription());
                });
                break;
            default:
                throw new CategoryInvalidSortException($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_bb1fe5187ab111888674" . "30908c6f6111"]);
        }
        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["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_f61cbfe09f83985" . "4b95117fe13b4a1b" . "a"]($_8613c2214654dc2b71f546198bd9ce16, $container_categories_prefix) !== 0) {
                continue;
            }
            $_0fe621d40f6a1573fb986abe53021cea = $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_cfe3120f54395b670652b3" . "8c2d0a8e88"]($_8613c2214654dc2b71f546198bd9ce16, $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_aed8da0f1909" . "1214b78f80351" . "048517c"]($container_categories_prefix));
            if ($this->HasCategory($_0fe621d40f6a1573fb986abe53021cea)) {
                $this->logger->warning($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_a3c961c9f027832b3d87948e5" . "a3a73dc"] . (string) $_0fe621d40f6a1573fb986abe53021cea . $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_2bcf1e3e0f861d5bf3d9e2d68cdc255" . "7"]);
                continue;
            }
            if ($_c8ef295ed962a46e6246480731bf7b99->IsCategoryInstance($_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16])) {
                $_c3492cfbadbaead5d2512469c3eb908e = $_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16];
            } elseif ($GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_7f628626dd1d55c71" . "b1fc0932ffd1d2c"]($_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16])) {
                try {
                    $_c3492cfbadbaead5d2512469c3eb908e = $_c8ef295ed962a46e6246480731bf7b99->CreateFromArray($_6eb6fcb92c942851e079f8ec5fb80324[$_8613c2214654dc2b71f546198bd9ce16]);
                } catch (CategoryInvalidArgumentException $_fe441aa3ef350bfb1a1a1ad8520dd530) {
                    $this->logger->warning($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_989aa34" . "6a7ffac7" . "3f8bcf32" . "04a41d45" . "a"] . (string) $_8613c2214654dc2b71f546198bd9ce16 . $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_e608e5b5c4c34a6" . "7ba97ef84c1e1619" . "9"]);
                }
            }
            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;
    }
}