<?php
namespace Claromentis\Infocapture\Repository;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] = (@$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"] ?: array()) + array("_49c6565477ee" . "9f822b499a53e" . "6d2995f" => base64_decode("YXJyYX" . "lfa2V5" . "X2V4aX" . "N0cw=="), "_0c5123aa744" . "f69bbc0e8b3e" . "a2f6e847d" => base64_decode("bG1zZw=" . "="), "_a324c7872ecc0d" . "e3af2b025d51fce" . "7f7" => base64_decode("aGVscGRlc2sud3Jvbmdf" . "Zm9ybQ=="), "_cc2d908b8962262f487" . "6db8ebfedaa9a" => base64_decode("SXNzdWUgZ" . "m9ybSBkYX" . "RhIG5vdCB" . "mb3VuZA=="), "_49545c7d347e8eb5991e3" . "eaa6ea076d3" => base64_decode("YXBwX2l" . "k"));
use Claromentis\Core\Security\SecurityContext;
use FBForm;
use HDIssue;
use HDProject;
class FormRepository
{
    
    
    
    
    
    
    protected array $formCache = [];
    
    
    
    
    
    
    
    
    
    public function findForm(int $_0c6a7ccc47e0e836dc056ff9b783f40c) : ?FBForm
    {
        if (!$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_49c6565477ee9f822b" . "499a53e6d2995f"]($_0c6a7ccc47e0e836dc056ff9b783f40c, $this->formCache)) {
            $form = new FBForm();
            if (!$form->Load($_0c6a7ccc47e0e836dc056ff9b783f40c) || $form->getFBValue($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_49545c7d347e8eb5991e" . "3eaa6ea076d3"]) != 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["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_cc2d908b8962262f4" . "876db8ebfedaa9a"]);
        }
        $_0c6a7ccc47e0e836dc056ff9b783f40c = $_b6b302994975f0d592571c295359f69b->GetFormId();
        $form = $this->findFormWithFields($_0c6a7ccc47e0e836dc056ff9b783f40c);
        if (!$form) {
            throw new \Exception($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_0c5123aa7" . "44f69bbc0e" . "8b3ea2f6e8" . "47d"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_a324c7872ecc0" . "de3af2b025d51f" . "ce7f7"]));
        }
        
        
        
        return $form;
    }
    
    
    
    
    
    
    
    public function clearCache(?int $_0c6a7ccc47e0e836dc056ff9b783f40c = null) : void
    {
        if (isset($_0c6a7ccc47e0e836dc056ff9b783f40c)) {
            unset($this->formCache[$_0c6a7ccc47e0e836dc056ff9b783f40c]);
        } else {
            $this->formCache = [];
        }
    }
}