<?php
namespace Claromentis\Admin\Sysadmin\Controller\Rest;

$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] ?: array()) + array("_dbe8190f492fbe13" . "6d881ef37eaff050" => base64_decode("Y29tbXVuaWNhdGlvbi5ub3RpZmljYXRpb24udGVzdC5pbnB1dC5lcnJvci5pbnZhb" . "Glk"), "_3877cdf" . "57a61e49" . "b56aeab7" . "af930ee8" . "2" => base64_decode("dXNlcl9" . "pZA=="), "_9cb135e453cdf3a629b154de0f" . "137156" => base64_decode("Y29tbXVuaWNhdGlvbi5lbWFpbC5hZGRyZ" . "XNzLmVycm9yLmludmFsaWQ="), "_00d4556785da10907e2acd8b78" . "d267eb" => base64_decode("c2VuZF9lb" . "WFpbA=="), "_539cf4259a149ca9dbb739b2cdb7c6" . "08" => base64_decode("ZW1haW" . "xfYWRk" . "cmVzcw" . "=="), "_b2e21909d05941" . "68b28b2511e29e0" . "473" => base64_decode("Y29tbXVuaWNhdGlvbi50ZXN0LmVycm9yLmludmFsaWRfdXNlcl9pZA" . "=="), "_32d577a2cf701fc" . "5d5887f166fede4c" . "d" => base64_decode("c2VuZF9pbnN0YW50X21lc3NhZ2" . "U="), "_62d701c" . "3c53404f" . "06345eb3" . "5720a47b" . "4" => base64_decode("aXNfbnVtZXJpY" . "w=="), "_ab96de4" . "40003199" . "04c01c5f" . "5469f705" . "f" => base64_decode("c2VuZ" . "F9wdX" . "No"), "_a267da128f69935df5d7cf22d92fe94" . "1" => base64_decode("cGVvcGxlLmVycm9yLm5vX3VzZXJfd2l0a" . "F9pZA=="), "_c894747360c6ec5bd" . "8169530eaf9c473" => base64_decode("QmFkIFJlc" . "XVlc3Q="), "_3efc5ba7bf51ca70907f5e65" . "ab602ec1" => base64_decode("SW50ZXJuYWw" . "gU2VydmVyIE" . "Vycm9y"), "_eda4c3d5e2b5cb0407af" . "66ed635e1ad8" => base64_decode("Y29tbXVuaWNhdGlvbi50" . "ZXN0LnNlbnQ="));
use Claromentis\Core\Config\Exception\ValueException;
use Claromentis\Core\Http\JsonPrettyResponse;
use Claromentis\Core\Localization\Lmsg;
use Claromentis\Core\Mail\Exception\AddressInvalidException;
use Claromentis\Core\Mail\Exception\DsnException;
use Claromentis\Core\Mail\Exception\MailSendException;
use Claromentis\Core\Notification\Api;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\People\Entity\User;
use Claromentis\People\Repository\UserRepository;
use Exception;
use Psr\Http\Message\ServerRequestInterface;
use RestExBadRequest;
use RestExError;
use RestExNotFound;
use RestFormat;
use Throwable;
class Notification
{
    private Api $api;
    private Lmsg $lmsg;
    private UserRepository $userRepository;
    private RestFormat $restFormat;
    public function __construct(Api $api, UserRepository $_2462766b6a5ed9e85d4472e796fc20c0, RestFormat $_a926da6c2f0ad81d9f885b590054699b, Lmsg $lmsg)
    {
        $this->api = $api;
        $this->userRepository = $_2462766b6a5ed9e85d4472e796fc20c0;
        $this->restFormat = $_a926da6c2f0ad81d9f885b590054699b;
        $this->lmsg = $lmsg;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function sendTest(ServerRequestInterface $_b791059c94b285cdf1c90ca6f3a8f2a6, SecurityContext $context) : JsonPrettyResponse
    {
        $_1029e0409b92a68e2f145f284754cf21 = $this->restFormat->GetJson($_b791059c94b285cdf1c90ca6f3a8f2a6);
        $_4defe7be81f86ea1db6af4de0d32c046 = $_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_539cf4259a149ca" . "9dbb739b2cdb7c60" . "8"]] ?? null;
        $_65976ee34559dcb12bd6d5db68edf074 = $_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_3877cdf57a61e49b56aeab7af930e" . "e82"]] ?? null;
        $_d5462abf37c4cd0bed7b02a80b4ba4b6 = (bool) ($_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_00d4556785da10907e2a" . "cd8b78d267eb"]] ?? false);
        $_f801f4ddbb3bcd352cc5ee038a2c755b = (bool) ($_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_32d577a" . "2cf701fc" . "5d5887f1" . "66fede4c" . "d"]] ?? false);
        $_a3ede8d5fa417c198c932752f1adce85 = (bool) ($_1029e0409b92a68e2f145f284754cf21[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_ab96de44000319" . "904c01c5f5469f7" . "05f"]] ?? false);
        if (!isset($_65976ee34559dcb12bd6d5db68edf074) && !isset($_4defe7be81f86ea1db6af4de0d32c046) || isset($_65976ee34559dcb12bd6d5db68edf074) && !$_f801f4ddbb3bcd352cc5ee038a2c755b && !$_d5462abf37c4cd0bed7b02a80b4ba4b6 && !$_a3ede8d5fa417c198c932752f1adce85) {
            throw new RestExBadRequest(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_dbe8190f492fbe136d881" . "ef37eaff050"]));
        }
        if (isset($_65976ee34559dcb12bd6d5db68edf074)) {
            if (!$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_62d701c3c53404f06345e" . "b35720a47b4"]($_65976ee34559dcb12bd6d5db68edf074)) {
                throw new RestExBadRequest(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_b2e21909d0594168b28b2511e29e0" . "473"]));
            }
            if ($_65976ee34559dcb12bd6d5db68edf074 && $_d5462abf37c4cd0bed7b02a80b4ba4b6) {
                
                
                $_24e0e36600d6af77406a44bb618a6253 = $this->userRepository->find($_65976ee34559dcb12bd6d5db68edf074);
                if ($_24e0e36600d6af77406a44bb618a6253 === null) {
                    throw new RestExNotFound(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_a267da1" . "28f69935" . "df5d7cf2" . "2d92fe94" . "1"], $_65976ee34559dcb12bd6d5db68edf074));
                }
                $_4defe7be81f86ea1db6af4de0d32c046 = $_24e0e36600d6af77406a44bb618a6253->email;
            }
        }
        if ($_4defe7be81f86ea1db6af4de0d32c046) {
            try {
                $this->api->sendTestEmail($_4defe7be81f86ea1db6af4de0d32c046, $context->GetFullName());
            } catch (AddressInvalidException $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExBadRequest(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_9cb135e453cdf3a629b154de0f137" . "156"]), $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_c894747" . "360c6ec5" . "bd816953" . "0eaf9c47" . "3"], $_c35473364fa7a050299058f332ec29c1);
            } catch (Throwable $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExError($_c35473364fa7a050299058f332ec29c1->getMessage(), 500, $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_3efc5ba7bf51ca" . "70907f5e65ab602" . "ec1"], $_c35473364fa7a050299058f332ec29c1);
            }
        }
        if ($_65976ee34559dcb12bd6d5db68edf074 && $_f801f4ddbb3bcd352cc5ee038a2c755b) {
            try {
                $this->api->sendTestInstantMessage($_65976ee34559dcb12bd6d5db68edf074, $context->GetFullName(), $context->GetUserId());
            } catch (Throwable $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExError($_c35473364fa7a050299058f332ec29c1->getMessage(), 500, $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_3efc5ba7bf51ca70907f5e65a" . "b602ec1"], $_c35473364fa7a050299058f332ec29c1);
            }
        }
        if ($_65976ee34559dcb12bd6d5db68edf074 && $_a3ede8d5fa417c198c932752f1adce85) {
            try {
                $this->api->sendTestPush($_65976ee34559dcb12bd6d5db68edf074);
            } catch (Throwable $_c35473364fa7a050299058f332ec29c1) {
                throw new RestExError($_c35473364fa7a050299058f332ec29c1->getMessage(), 500, $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_3efc5ba7bf51c" . "a70907f5e65ab6" . "02ec1"], $_c35473364fa7a050299058f332ec29c1);
            }
        }
        return new JsonPrettyResponse(($this->lmsg)($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_eda4c3d5e2b5cb0407af66e" . "d635e1ad8"]), 200);
    }
}