<?php
namespace Claromentis\Core\Tree;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("_6fd29f1ce8" . "2d5e2d09a2d" . "806c2e2b1d5" => base64_decode("aXNf" . "Y2Fs" . "bGFi" . "bGU="), "_a591754a8ddcdbda9c80f1db4d91" . "1e14" => base64_decode("aXNfbnVsbA" . "=="), "_b13aec0775985a2600" . "1b6b287477f3fe" => base64_decode("RGVwdGggZmlsdGVyIGlzIG5vdCBjY" . "WxsYWJsZQ=="));
use RecursiveIterator;























abstract class FolderIdsIterator implements RecursiveIterator
{
    const LEAVES_FIRST = 1;
    const FOLDERS_FIRST = 2;
    protected $folder_id;
    protected $include_deleted;
    protected $mode;
    protected $children;
    protected $pos = 0;
    protected $cache_all;
    protected $children_iterators = null;
    
    
    
    
    protected $depth_filter = null;
    
    
    
    
    
    
    
    public function __construct($folder_id, $_9217945053dcf5f2b8e7f005e1025e64 = false, $_601a171d59986f7c15972b586685671b = self::LEAVES_FIRST, $_25467b9c95c4c672788507e4e0284f32 = false)
    {
        $this->folder_id = $folder_id;
        $this->include_deleted = $_9217945053dcf5f2b8e7f005e1025e64;
        $this->mode = $_601a171d59986f7c15972b586685671b;
        $this->children = null;
        $this->pos = 0;
        $this->cache_all = $_25467b9c95c4c672788507e4e0284f32;
    }
    
    
    
    
    
    
    
    
    
    public function SetDepthFilter($_93871b54f3f55af06dbe4cdc98bd678f)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_6fd29f1ce82d5e2d09a2d" . "806c2e2b1d5"]($_93871b54f3f55af06dbe4cdc98bd678f) && !$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_a591754a8ddcdbda9c80f1db4d911" . "e14"]($_93871b54f3f55af06dbe4cdc98bd678f)) {
            throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_b13aec0775985a260" . "01b6b287477f3fe"]);
        }
        $this->depth_filter = $_93871b54f3f55af06dbe4cdc98bd678f;
    }
    public function current()
    {
        $this->FillChildrenArray();
        return $this->children[$this->pos];
    }
    public function next()
    {
        $this->pos++;
    }
    public function key()
    {
        return $this->pos;
    }
    public function valid()
    {
        $this->FillChildrenArray();
        return isset($this->children[$this->pos]);
    }
    public function rewind()
    {
        $this->pos = 0;
    }
    
    
    
    
    
    
    public function hasChildren()
    {
        if ($this->depth_filter) {
            $_03e9164d0a343b742df4793268b80767 = $this->depth_filter;
            if (!$_03e9164d0a343b742df4793268b80767($this->current())) {
                return false;
            }
        }
        
        
        
        
        return true;
    }
    
    
    
    
    
    
    public function getChildren()
    {
        if (isset($this->children_iterators[$this->pos])) {
            return $this->children_iterators[$this->pos];
        }
        $_a4b4fe29a876bd36f8024f56a625bf4c = $this->children[$this->pos];
        $_3974247ae4b1054a37517e9579770287 = new static($_a4b4fe29a876bd36f8024f56a625bf4c[1], $this->include_deleted, $this->mode, $this->cache_all);
        if ($this->cache_all) {
            $this->children_iterators[$this->pos] = $_3974247ae4b1054a37517e9579770287;
        } else {
            $this->children_iterators = array($this->pos => $_3974247ae4b1054a37517e9579770287);
        }
        return $_3974247ae4b1054a37517e9579770287;
    }
    protected function FillChildrenArray()
    {
        if ($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_a591754a8ddcdbda9c80f1db4d9" . "11e14"]($this->children)) {
            $this->children = $this->GetAllChildrenArray($this->folder_id);
        }
    }
    
    
    
    
    
    
    protected abstract function GetAllChildrenArray($folder_id);
}