<?php
namespace Claromentis\Orgchart;

$GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"] ?: array()) + array("_0a6f79a080caf87b6dcca9f98" . "8875b4c" => base64_decode("b3JnY2hhcnQuY29tbW9uLmR" . "lbGV0ZWRfdXNlcg=="), "_785b4eb8ea6f7f8965c445f548" . "bfcd28" => base64_decode("b2N" . "fYW" . "N0a" . "W9u"), "_4a2302989d5147" . "97ced07d553cf63" . "a1c" => base64_decode("b3JnY2hhcnQuZGF0YXRhYmxlLm9yZ2NoYXJ" . "0X25hbWU="), "_3b3d152fde630d1423f0623c1860d9" . "f1" => base64_decode("b2N" . "fbm" . "FtZ" . "Q=="), "_4599a7ede793" . "fcacdbe372061" . "3b1fe59" => base64_decode("b2N" . "faG" . "VhZ" . "A=="), "_52e92569711895" . "8acd8088da4eea7" . "700" => base64_decode("b3JnY2hhcnQuZGF0Y" . "XRhYmxlLm9yZ2NoYX" . "J0X2hlYWQ="), "_0c5123aa744f69bbc0e8b3ea2f6e84" . "7d" => base64_decode("bG" . "1z" . "Zw" . "=="), "_8cca4dd34e20c5344b" . "b2a30f2533c4e5" => base64_decode("ZnV" . "sbF" . "9uY" . "W1l"), "_7fdf61bac986b62bcf" . "7e5b6913efcf3f" => base64_decode("ZG9jdW1lbnRzLmhvb" . "WUuYWN0aW9ucw=="), "i" . "d" => base64_decode("aWQ" . "="));
use Claromentis\Core\Admin\AdminPanel;
use Claromentis\Core\DataTable;
use Claromentis\Core\DataTable\Contract\DataSource;
use Claromentis\Core\Security\SecurityContext;
use Claromentis\Orgchart\Datatable\Decorator\CellActions;
use Claromentis\Orgchart\Exception\OrgchartUserNotFoundException;
use Claromentis\Orgchart\Model\Orgchart;
class OrgchartDataTableSource implements DataSource
{
    
    
    
    
    use DataTable\Shared\ColumnHelper;
    
    
    
    
    protected $repository;
    
    
    
    
    protected $admin_panel;
    public function __construct(OrgchartRepository $repository, AdminPanel $_34142f0805685e788bb54a01fb3e222c)
    {
        $this->repository = $repository;
        $this->admin_panel = $_34142f0805685e788bb54a01fb3e222c;
    }
    
    
    
    
    
    
    
    
    
    public function Columns(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915 = null)
    {
        $_a42c86642011ef739b88ee80672c387d = array(array($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_3b3d152fde6" . "30d1423f0623" . "c1860d9f1"], $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_4a2302989d514797c" . "ed07d553cf63a1c"])), array($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_4599a7ede793fcacdbe372061" . "3b1fe59"], $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_0c5123aa744f" . "69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_52e925697118958acd8088da4eea" . "7700"])), array($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_785b4eb8ea6f7f8" . "965c445f548bfcd2" . "8"], $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_0c5123aa744f69bbc0e8b3e" . "a2f6e847d"]($GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_7fdf61bac986b62bcf7e5b6913efcf" . "3f"]), new CellActions()));
        $output = $this->CreateWithColumns($_a42c86642011ef739b88ee80672c387d);
        return $output;
    }
    
    
    
    
    
    
    
    
    
    
    public function Data(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915, DataTable\Contract\TableFilter $_03e9164d0a343b742df4793268b80767)
    {
        if (!$this->CheckPermissions($context)) {
            return [];
        }
        $_1f50e30be8c2fefa6881834e71d504a2 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetOffset();
        $_f11369824f533e8206f9ccc0c9aab3a0 = $_4c4d12d3e4f6cac68e3eecffe9887915->GetLimit();
        $data = $this->repository->GetList($_1f50e30be8c2fefa6881834e71d504a2, $_f11369824f533e8206f9ccc0c9aab3a0);
        $_a0006f2e6058ce959e86bebdcded2da8 = [];
        
        
        
        
        foreach ($data as $_ea50e3facb857230426d6d1b5d653971) {
            try {
                $_19632122189cf68017da69f3db0f4414 = $this->repository->GetHeadNode($_ea50e3facb857230426d6d1b5d653971);
            } catch (OrgchartUserNotFoundException $e) {
                
                
                $row = [];
                $row[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_3b3d152f" . "de630d142" . "3f0623c18" . "60d9f1"]] = $_ea50e3facb857230426d6d1b5d653971->title;
                $row[$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_4599a7ede793" . "fcacdbe372061" . "3b1fe59"]] = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_0c5123aa744f69bbc0e8b3ea2f6" . "e847d"]($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_0a6f79a08" . "0caf87b6dc" . "ca9f988875" . "b4c"]);
                $row[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_785b4eb8" . "ea6f7f896" . "5c445f548" . "bfcd28"]] = array($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["i" . "d"] => $_ea50e3facb857230426d6d1b5d653971->id);
                $_a0006f2e6058ce959e86bebdcded2da8[] = $row;
                continue;
            }
            $row = [];
            $row[$GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_3b3d152fde6" . "30d1423f0623" . "c1860d9f1"]] = $_ea50e3facb857230426d6d1b5d653971->title;
            $row[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_4599a7ede793f" . "cacdbe3720613b" . "1fe59"]] = $_19632122189cf68017da69f3db0f4414[$GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_8cca4dd34e20c5" . "344bb2a30f2533c" . "4e5"]];
            $row[$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_785b4eb8ea6f7f8965c44" . "5f548bfcd28"]] = array($GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["i" . "d"] => $_ea50e3facb857230426d6d1b5d653971->id);
            $_a0006f2e6058ce959e86bebdcded2da8[] = $row;
        }
        return $_a0006f2e6058ce959e86bebdcded2da8;
    }
    
    
    
    
    
    
    
    
    
    
    public function Count(SecurityContext $context, DataTable\Contract\Parameters $_4c4d12d3e4f6cac68e3eecffe9887915, DataTable\Contract\TableFilter $_e0bd284b1527841bc9c635873b56303b)
    {
        if (!$this->CheckPermissions($context)) {
            return 0;
        }
        return $this->repository->GetTotalCharts();
    }
    protected function CheckPermissions(SecurityContext $context)
    {
        if (isset($this->admin_panel) && $this->admin_panel->IsAccessible($context)) {
            return true;
        }
        return false;
    }
    
    
    
    
    
    
    public function Filters()
    {
        
        
        return [];
    }
}