<?php
namespace Claromentis\Core\User\Directory;

$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_3bc8ccbfa87dde" . "178330887eeef2f" . "c5e" => base64_decode("RGlyZWN0b3J" . "5IHdpdGggaW" . "Qg"), "ty" . "pe" => base64_decode("dH" . "lw" . "ZQ" . "=="), "_d1d997d6b7fdc0" . "2cc83b4b996482c" . "63a" => base64_decode("MA" . "=="), "_87da279507cfe99829e40eca558cf7" . "d1" => base64_decode("IGRvZXNuJ3QgZXhpc3Qg" . "LSBjYW4ndCB1cGRhdGU="), "_99cee2d" . "2272a855" . "0f4b21e3" . "cb57fff7" . "d" => base64_decode("ZW5hYmxlZA=" . "="), "_7f628626dd1d5" . "5c71b1fc0932ff" . "d1d2c" => base64_decode("aXNfYXJyYX" . "k="), "option" . "s" => base64_decode("b3B0aW9ucw=" . "="));
use Claromentis\Core\Config\Config;
use Claromentis\Core\User\Directory\Exception\UnknownDirectoryException;




class DirectoriesList
{
    protected Config $storage;
    protected string $variable_name;
    public function __construct(Config $storage, $_af1ebf352fcd1d2906ecd42ae1cde56e)
    {
        $this->storage = $storage;
        $this->variable_name = $_af1ebf352fcd1d2906ecd42ae1cde56e;
    }
    
    
    
    
    public function GetAll() : array
    {
        $_1ac0335a1f605e216d9ffde5545a81e3 = $this->storage->get($this->variable_name);
        return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_7f628626d" . "d1d55c71b1" . "fc0932ffd1" . "d2c"]($_1ac0335a1f605e216d9ffde5545a81e3) ? $_1ac0335a1f605e216d9ffde5545a81e3 : [];
    }
    
    
    
    
    
    
    
    
    
    public function GetAllEnabled() : array
    {
        $_d00c9bfa132c9b19f21346632ca3484c = [];
        $_4a1e36876b85dbb4c5d96e6d097ab404 = $this->GetAll();
        foreach ($_4a1e36876b85dbb4c5d96e6d097ab404 as $_40421a4e75c2ba3c82b018e6b56f7425 => $_d9dec3fec40d714836246e2dbbaa7deb) {
            if ($_40421a4e75c2ba3c82b018e6b56f7425 != $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_d1d997d6b7fdc02cc" . "83b4b996482c63a"]) {
                
                
                if ($_d9dec3fec40d714836246e2dbbaa7deb[$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["opti" . "ons"]][$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_99cee2d2272a8550f4b" . "21e3cb57fff7d"]]) {
                    
                    
                    $_d00c9bfa132c9b19f21346632ca3484c[$_40421a4e75c2ba3c82b018e6b56f7425] = $_d9dec3fec40d714836246e2dbbaa7deb;
                }
            }
        }
        return $_d00c9bfa132c9b19f21346632ca3484c;
    }
    
    
    
    
    
    
    
    public function Add(string $type, array $options) : string
    {
        $_1ac0335a1f605e216d9ffde5545a81e3 = $this->GetAll();
        $key = \CryptUtils::GetRandomString(20);
        $_1ac0335a1f605e216d9ffde5545a81e3[$key] = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["t" . "y" . "p" . "e"] => $type, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["optio" . "ns"] => $options];
        $this->SaveAll($_1ac0335a1f605e216d9ffde5545a81e3);
        return $key;
    }
    public function GetByKey(string $key) : ?array
    {
        $_1ac0335a1f605e216d9ffde5545a81e3 = $this->GetAll();
        return isset($_1ac0335a1f605e216d9ffde5545a81e3[$key]) ? $_1ac0335a1f605e216d9ffde5545a81e3[$key] : null;
    }
    
    
    
    
    
    
    
    public function Update(string $key, array $options)
    {
        $_1ac0335a1f605e216d9ffde5545a81e3 = $this->GetAll();
        if (!isset($_1ac0335a1f605e216d9ffde5545a81e3[$key])) {
            throw new UnknownDirectoryException($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_3bc8ccbfa87dde178" . "330887eeef2fc5e"] . $key . $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_87da2795" . "07cfe9982" . "9e40eca55" . "8cf7d1"]);
        }
        $_1ac0335a1f605e216d9ffde5545a81e3[$key][$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["option" . "s"]] = $options;
        $this->SaveAll($_1ac0335a1f605e216d9ffde5545a81e3);
    }
    public function Delete(string $key)
    {
        $_1ac0335a1f605e216d9ffde5545a81e3 = $this->GetAll();
        if (!isset($_1ac0335a1f605e216d9ffde5545a81e3[$key])) {
            return;
        }
        unset($_1ac0335a1f605e216d9ffde5545a81e3[$key]);
        $this->SaveAll($_1ac0335a1f605e216d9ffde5545a81e3);
    }
    protected function SaveAll(array $_1ac0335a1f605e216d9ffde5545a81e3)
    {
        $this->storage->set($this->variable_name, $_1ac0335a1f605e216d9ffde5545a81e3);
        $this->storage->save();
    }
    
    
    
    
    public function DirectoriesAreInUse() : bool
    {
        return !empty($this->GetAllEnabled());
    }
}