<?php
namespace Claromentis\Core\Http;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] ?: array()) + array("_2b2486424e6dfb906" . "c925739c329be7c" => base64_decode("aGVhZ" . "GVy"), "_bd8510ebf2" . "9b0f687c25c" . "90c740715d8" => base64_decode("aHR0cF9yZXNwb25zZV9" . "jb2Rl"), "_e06da3ffba2e84b8e6f94bd2d" . "6ca3c52" => base64_decode("Y3JlYXRlX2ludGVybmFs" . "X2xpbms="), "_14feb73099827a30c31c0b9" . "96c13f13c" => base64_decode("b25LZXJuZWxS" . "ZXF1ZXN0"), "_781e2532c1e56969c535c118" . "4064bae6" => base64_decode("b25Db3Jl" . "Qm9vdA=="), "_db7b295629faa160" . "27a2c263095eba70" => base64_decode("cGhwX3NhcGlfbmF" . "tZQ=="), "_e6d18c493faa20d5d45c075" . "1d2c02ce6" => base64_decode("TG9jYXRpb" . "246IA=="), "_eea266d1da508f" . "42deea49cc3add6" . "8ec" => base64_decode("UF" . "VU"), "_ab8b6a5" . "b56b4cfd" . "73230ed5" . "cad4fb54" . "c" => base64_decode("Y29y" . "ZS5i" . "b290" . "ZWQ="), "_c91b0ff19f81a8873a4593a2" . "3719472c" => base64_decode("cnRyaW0" . "="), "_4d707fab93bebb00bbe69e815969" . "7c90" => base64_decode(""), "_8fec21706bd243b37ecf62b" . "1caf8fb8a" => base64_decode("Y2x" . "p"), "_8ec8f26c" . "742278f90" . "615f50d68" . "2eea79" => base64_decode("UE" . "9T" . "VA" . "=="), "_87daa84e346f6420a3f3426e05d16a" . "7b" => base64_decode("Lw=" . "="), "_fad3a97fa79" . "19b1999c977c" . "8bdad925a" => base64_decode("c3ltZm9ueV9yZXF1ZXN" . "0"));
use Claromentis\Core\Application\Events\BootedEvent;
use Claromentis\Core\Event\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;





class CanonicalUrlRedirector implements EventSubscriberInterface
{
    protected $canonical_url;
    public function __construct($_504f0c1dde6057a1a55bea80963ef65c)
    {
        $this->canonical_url = $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_c91b0ff19f81a8873a459" . "3a23719472c"]($_504f0c1dde6057a1a55bea80963ef65c, $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_87daa84e346f64" . "20a3f3426e05d16" . "a7b"]);
    }
    
    
    
    
    public static function getSubscribedEvents()
    {
        return array(KernelEvents::REQUEST => array($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_14feb73099827a" . "30c31c0b996c13f" . "13c"], 1536), $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_ab8b6a5b56b4cfd73230ed5" . "cad4fb54c"] => $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_781e2532c1e56969c53" . "5c1184064bae6"]);
    }
    
    
    
    
    
    
    public function onKernelRequest(RequestEvent $event)
    {
        if ($this->canonical_url == $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_4d707fab93bebb00bbe69e815" . "9697c90"] || !$event->isMasterRequest()) {
            return;
        }
        $request = $event->getRequest();
        
        
        if ($request->getMethod() === $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_8ec8f26c742278f90615f50d682ee" . "a79"] || $request->getMethod() === $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_eea266d1d" . "a508f42dee" . "a49cc3add6" . "8ec"]) {
            return;
        }
        if (!$this->IsCanonicalUrl($request)) {
            $event->setResponse($this->BuildRedirectResponse($request));
        }
    }
    
    
    
    
    
    
    
    
    
    public function onCoreBoot(BootedEvent $event) : void
    {
        
        
        if ($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_db7b2956" . "29faa1602" . "7a2c26309" . "5eba70"]() === $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_8fec21706bd243" . "b37ecf62b1caf8f" . "b8a"]) {
            return;
        }
        $app = $event->getApplication();
        
        
        
        
        
        
        $_0ce802ba864a6ec25741334b8e5097bc = $app[$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_fad3a97fa7" . "919b1999c97" . "7c8bdad925a"]];
        if ($_0ce802ba864a6ec25741334b8e5097bc && $this->SimpleCheckAndRedirect($_0ce802ba864a6ec25741334b8e5097bc)) {
            
            
            exit;
        }
    }
    protected function IsCanonicalUrl(\Symfony\Component\HttpFoundation\Request $request)
    {
        return $request->getSchemeAndHttpHost() == $this->canonical_url;
    }
    protected function BuildRedirectResponse(\Symfony\Component\HttpFoundation\Request $request)
    {
        $_c927258f5322288a992c77be40ae0b53 = $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_e06da3f" . "fba2e84b" . "8e6f94bd" . "2d6ca3c5" . "2"]($request->getRequestUri());
        return new RedirectResponse($_c927258f5322288a992c77be40ae0b53, 301);
    }
    
    
    
    
    
    
    
    
    
    public function SimpleCheckAndRedirect(\Symfony\Component\HttpFoundation\Request $request)
    {
        if ($this->canonical_url != $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_4d707fab93bebb00bbe69e8159697c9" . "0"] && !$this->IsCanonicalUrl($request)) {
            $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_bd8510ebf29b0f687c25c90c740715d" . "8"](301);
            $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_2b2486424e6dfb906c925739c329be" . "7c"]($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_e6d18c493fa" . "a20d5d45c075" . "1d2c02ce6"] . $GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"]["_e06da3ffba2e84b8e6f94bd" . "2d6ca3c52"]($request->getRequestUri()));
            return true;
        }
        return false;
    }
}