<?php
namespace Claromentis\Core\Tree;

$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("_b13aec0775985a26001b6b28" . "7477f3fe" => base64_decode("RGVwdGggZmlsdGVyI" . "GlzIG5vdCBjYWxsYW" . "JsZQ=="), "_a591754a8ddcdbda9c8" . "0f1db4d911e14" => base64_decode("aXNfbnVsb" . "A=="), "_6fd29f1ce82d5e2d" . "09a2d806c2e2b1d5" => base64_decode("aXNfY2FsbGFibG" . "U="));
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["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_6fd29f1ce82d5e2d09a" . "2d806c2e2b1d5"]($_93871b54f3f55af06dbe4cdc98bd678f) && !$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_a591754a8ddcdbda9c80f" . "1db4d911e14"]($_93871b54f3f55af06dbe4cdc98bd678f)) {
            throw new \InvalidArgumentException($GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_b13aec0775985a26001b6b287477f3" . "fe"]);
        }
        $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["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_a591754a8ddcdbda9c" . "80f1db4d911e14"]($this->children)) {
            $this->children = $this->GetAllChildrenArray($this->folder_id);
        }
    }
    
    
    
    
    
    
    protected abstract function GetAllChildrenArray($folder_id);
}