<?php
namespace Claromentis\Infocapture\Repository;

$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] = (@$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] ?: array()) + array("_0c5123aa744f69b" . "bc0e8b3ea2f6e847" . "d" => base64_decode("bG1zZ" . "w=="), "_49c6565477ee9f8" . "22b499a53e6d2995" . "f" => base64_decode("YXJyYX" . "lfa2V5" . "X2V4aX" . "N0cw=="), "_a324c7872ec" . "c0de3af2b025" . "d51fce7f7" => base64_decode("aGVscGRlc2sud3JvbmdfZm9ybQ" . "=="), "_cc2d908b8962262f4876db8ebfedaa" . "9a" => base64_decode("SXNzdWUgZm9ybSBk" . "YXRhIG5vdCBmb3Vu" . "ZA=="), "_49545c7d347e8eb5991e3eaa6e" . "a076d3" => base64_decode("YX" . "Bw" . "X2" . "lk"));
use Claromentis\Core\Security\SecurityContext;
use FBForm;
use HDIssue;
use HDProject;
class FormRepository
{
    
    
    
    
    
    
    protected array $formCache = [];
    
    
    
    
    
    
    
    
    
    public function findForm(int $_0c6a7ccc47e0e836dc056ff9b783f40c) : ?FBForm
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_49c6565477ee9f822b499a53e6d" . "2995f"]($_0c6a7ccc47e0e836dc056ff9b783f40c, $this->formCache)) {
            $form = new FBForm();
            if (!$form->Load($_0c6a7ccc47e0e836dc056ff9b783f40c) || $form->getFBValue($GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_49545c7d3" . "47e8eb5991" . "e3eaa6ea07" . "6d3"]) != HD_FORMS) {
                $form = null;
            }
            $this->formCache[$_0c6a7ccc47e0e836dc056ff9b783f40c] = $form;
        }
        return $this->formCache[$_0c6a7ccc47e0e836dc056ff9b783f40c] ?: null;
    }
    
    
    
    
    
    
    
    public function findFormWithFields(int $_0c6a7ccc47e0e836dc056ff9b783f40c) : ?FBForm
    {
        $form = $this->findForm($_0c6a7ccc47e0e836dc056ff9b783f40c);
        if (!$form) {
            return null;
        }
        $form->LoadFields();
        return $form;
    }
    
    
    
    
    
    
    
    
    
    
    public function getIssueForm(HDIssue $issue) : FBForm
    {
        $_b6b302994975f0d592571c295359f69b = $issue->GetFormData();
        if (!$_b6b302994975f0d592571c295359f69b) {
            throw new \Exception($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_cc2d908b8962262f4876db8ebfedaa" . "9a"]);
        }
        $_0c6a7ccc47e0e836dc056ff9b783f40c = $_b6b302994975f0d592571c295359f69b->GetFormId();
        $form = $this->findFormWithFields($_0c6a7ccc47e0e836dc056ff9b783f40c);
        if (!$form) {
            throw new \Exception($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_0c5123aa744f69bbc0e8b3ea2f6e84" . "7d"]($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_a324c7872ecc0de3af2b02" . "5d51fce7f7"]));
        }
        
        
        
        return $form;
    }
    
    
    
    
    
    
    
    public function clearCache(?int $_0c6a7ccc47e0e836dc056ff9b783f40c = null) : void
    {
        if (isset($_0c6a7ccc47e0e836dc056ff9b783f40c)) {
            unset($this->formCache[$_0c6a7ccc47e0e836dc056ff9b783f40c]);
        } else {
            $this->formCache = [];
        }
    }
}