<?php

class DashJs {
    public static function byteLength($t) {
        $e = self::l($t);
        $n = $e[0];
        $a = $e[1];
        return 3 * ($n + $a) / 4 - $a;
    }

    public static function toByteArray($t) {
        $e = $n = $i = null;
        $i = self::l($t);
        $o = $i[0];
        $s = $i[1];
        $u = new Uint8Array(self::calculateSize(0, $o, $s));
        $c = 0;
        $d = $s > 0 ? $o - 4 : $o;

        for ($n = 0; $n < $d; $n += 4) {
            $e = self::$a[$t[$n]] << 18 | self::$a[$t[$n + 1]] << 12 | self::$a[$t[$n + 2]] << 6 | self::$a[$t[$n + 3]];
            $u[$c++] = $e >> 16 & 255;
            $u[$c++] = $e >> 8 & 255;
            $u[$c++] = 255 & $e;
        }

        if ($s === 2) {
            $e = self::$a[$t[$n]] << 2 | self::$a[$t[$n + 1]] >> 4;
            $u[$c++] = 255 & $e;
        } elseif ($s === 1) {
            $e = self::$a[$t[$n]] << 10 | self::$a[$t[$n + 1]] << 4 | self::$a[$t[$n + 2]] >> 2;
            $u[$c++] = $e >> 8 & 255;
            $u[$c++] = 255 & $e;
        }

        return $u;
    }

    public static function fromByteArray($t) {
        $e = $a = count($t);
        $r = $a % 3;
        $i = [];
        $o = 16383;
        $l = 0;
        $u = $a - $r;

        for ($l = 0; $l < $u; $l += $o) {
            $i[] = self::s($t, $l, min($l + $o, $u));
        }

        if ($r === 1) {
            $e = $t[$a - 1];
            $i[] = self::$n[$e >> 2] . self::$n[$e << 4 & 63] . "==";
        } elseif ($r === 2) {
            $e = ($t[$a - 2] << 8) + $t[$a - 1];
            $i[] = self::$n[$e >> 10] . self::$n[$e >> 4 & 63] . self::$n[$e << 2 & 63] . "=";
        }

        return implode("", $i);
    }

    private static function l($t) {
        $e = strlen($t);
        if ($e % 4 > 0) {
            throw new Exception("Invalid string. Length must be a multiple of 4");
        }
        $n = strpos($t, "=");
        return $n === false ? [$e, 0] : [$n, $n === $e ? 0 : 4 - $n % 4];
    }

    private static function s($t, $e, $a) {
        $o = [];
        for ($l = $e; $l < $a; $l += 3) {
            $r = ($t[$l] << 16 & 16711680) + ($t[$l + 1] << 8 & 65280) + (255 & $t[$l + 2]);
            $o[] = self::$n[($i = $r) >> 18 & 63] . self::$n[$i >> 12 & 63] . self::$n[$i >> 6 & 63] . self::$n[63 & $i];
        }
        return implode("", $o);
    }

    private static function calculateSize($t, $e, $n) {
        return 3 * ($e + $n) / 4 - $n;
    }

    private static $n = [];
    private static $a = [];
    private static $r = "undefined" !== typeof Uint8Array ? "Uint8Array" : "Array";
    private static $i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    
    public static function init() {
        for ($o = 0; $o < 64; ++$o) {
            self::$n[$o] = self::$i[$o];
            self::$a[self::$i[$o]] = $o;
        }
    }
}

DashJs::init();

<?php
$this->_onRecoveredEarlyEof = null;
$this->_extraData = null;

public function isWorking() {
    return $this->_loader && $this->_loader->isWorking() && !$this->_paused;
}

public function isPaused() {
    return $this->_paused;
}

public function getStatus() {
    return $this->_loader->status;
}

public function getExtraData() {
    return $this->_extraData;
}

public function setExtraData($value) {
    $this->_extraData = $value;
}

public function getOnDataArrival() {
    return $this->_onDataArrival;
}

public function setOnDataArrival($value) {
    $this->_onDataArrival = $value;
}

public function getOnSeeked() {
    return $this->_onSeeked;
}

public function setOnSeeked($value) {
    $this->_onSeeked = $value;
}

public function getOnError() {
    return $this->_onError;
}

public function setOnError($value) {
    $this->_onError = $value;
}

public function getOnComplete() {
    return $this->_onComplete;
}

public function setOnComplete($value) {
    $this->_onComplete = $value;
}

public function getOnRedirect() {
    return $this->_onRedirect;
}

public function setOnRedirect($value) {
    $this->_onRedirect = $value;
}

public function getOnRecoveredEarlyEof() {
    return $this->_onRecoveredEarlyEof;
}

public function setOnRecoveredEarlyEof($value) {
    $this->_onRecoveredEarlyEof = $value;
}

public function getCurrentURL() {
    return $this->_dataSource->url;
}

public function hasRedirect() {
    return $this->_redirectedURL !== null || $this->_dataSource->redirectedURL !== null;
}

public function getCurrentRedirectedURL() {
    return $this->_redirectedURL ?: $this->_dataSource->redirectedURL;
}

public function getCurrentSpeed() {
    return $this->_loaderClass === _ ? $this->_loader->currentSpeed : $this->_speedSampler->lastSecondKBps;
}

public function getLoaderType() {
    return $this->_loader->type;
}

private function _selectSeekHandler() {
    $config = $this->_config;
    if ($config->seekType === "range") {
        $this->_seekHandler = new g($this->_config->rangeLoadZeroStart);
    } elseif ($config->seekType === "param") {
        $t = $config->seekParamStart ?: "bstart";
        $i = $config->seekParamEnd ?: "bend";
        $this->_seekHandler = new v($t, $i);
    } else {
        if ($config->seekType !== "custom") {
            throw new h\OC("Invalid seekType in config: " . $config->seekType);
        }
        if (!is_callable($config->customSeekHandler)) {
            throw new h\OC("Custom seekType specified in config but invalid customSeekHandler!");
        }
        $this->_seekHandler = new $config->customSeekHandler();
    }
}

private function _selectLoader() {
    if ($this->_config->customLoader !== null) {
        $this->_loaderClass = $this->_config->customLoader;
    } elseif ($this->_isWebSocketURL) {
        $this->_loaderClass = m;
    } elseif (l::isSupported()) {
        $this->_loaderClass = l;
    } elseif (c::isSupported()) {
        $this->_loaderClass = c;
    } else {
        if (!_.isSupported()) {
            throw new h\OZ("Your browser doesn't support xhr with arraybuffer responseType!");
        }
        $this->_loaderClass = _;
    }
}

private function _createLoader() {
    $this->_loader = new $this->_loaderClass($this->_seekHandler, $this->_config);
    if (!$this->_loader->needStashBuffer) {
        $this->_enableStash = false;
    }
    $this->_loader->onContentLengthKnown = [$this, '_onContentLengthKnown'];
    $this->_loader->onURLRedirect = [$this, '_onURLRedirect'];
    $this->_loader->onDataArrival = [$this, '_onLoaderChunkArrival'];
    $this->_loader->onComplete = [$this, '_onLoaderComplete'];
    $this->_loader->onError = [$this, '_onLoaderError'];
}

public function open($e) {
    $this->_currentRange = ['from' => 0, 'to' => -1];
    if ($e) {
        $this->_currentRange['from'] = $e;
    }
    $this->_speedSampler->reset();
    if (!$e) {
        $this->_fullRequestFlag = true;
    }
    $this->_loader->open($this->_dataSource, array_merge($this->_currentRange, []));
}

public function abort() {
    $this->_loader->abort();
    if ($this->_paused) {
        $this->_paused = false;
        $this->_resumeFrom = 0;
    }
}

public function pause() {
    if ($this->isWorking()) {
        
    }
}
?>
<?php












class Uint8ArrayLike implements \ArrayAccess, \Countable {
    protected $data;
    protected $byteLength;
    protected $byteOffset;
    protected $buffer; 

    
    public function __construct($sizeOrArrayOrBuffer = 0, $byteOffset = 0, $length = null) {
        if (is_numeric($sizeOrArrayOrBuffer)) {
            
            $size = (int) $sizeOrArrayOrBuffer;
            if ($size < 0) {
                 
                 
                 throw new \RangeException('Invalid array length');
            }
            $this->data = array_fill(0, $size, 0);
            $this->byteLength = $size;
            $this->byteOffset = 0;
            $this->buffer = $this; 
        } elseif (is_array($sizeOrArrayOrBuffer)) {
            
            
            $this->data = array_values($sizeOrArrayOrBuffer); 
            
            foreach ($this->data as &$byte) {
                $byte = $byte & 0xFF; 
            }
            $this->byteLength = count($this->data);
            $this->byteOffset = 0;
            $this->buffer = $this;
        } elseif ($sizeOrArrayOrBuffer instanceof Uint8ArrayLike) {
             
             $buffer = $sizeOrArrayOrBuffer;
             $bufferLength = $buffer->byteLength;
             $byteOffset = (int) $byteOffset;

             if ($byteOffset < 0 || $byteOffset > $bufferLength) {
                 throw new \RangeException('byteOffset is out of bounds');
             }

             if ($length === null) {
                 $length = $bufferLength - $byteOffset;
             } else {
                 $length = (int) $length;
                 if ($byteOffset + $length > $bufferLength) {
                     throw new \RangeException('byteOffset and length extend beyond buffer');
                 }
             }

             if ($length < 0) {
                  throw new \RangeException('Invalid array length');
             }

             $this->data = array_slice($buffer->data, $byteOffset, $length);
             $this->byteLength = $length;
             $this->byteOffset = $byteOffset;
             $this->buffer = $buffer->buffer; 
        } else {
             
             
             
             
             throw new \TypeError('Unsupported constructor argument type');
        }
    }

    
    public function offsetExists($offset): bool {
        return isset($this->data[$offset]) && $offset >= 0 && $offset < $this->byteLength;
    }

    public function offsetGet($offset): mixed {
        if (!$this->offsetExists($offset)) {
             
             
             
             throw new \RangeException("Index out of bounds: " . $offset);
        }
        return $this->data[$offset];
    }

    public function offsetSet($offset, $value): void {
        if (!$this->offsetExists($offset) && $offset !== $this->byteLength) {
             throw new \RangeException("Index out of bounds: " . $offset);
        }
        
        $this->data[$offset] = $value & 0xFF;
    }

    public function offsetUnset($offset): void {
        
        throw new \Exception("Cannot unset Uint8Array elements");
    }

    
    public function count(): int {
        return $this->byteLength;
    }

    
    public function subarray($begin = 0, $end = null): Uint8ArrayLike {
        $begin = (int) $begin;
        $end = $end === null ? $this->byteLength : (int) $end;

        
        if ($begin < 0) {
            $begin = $this->byteLength + $begin;
            if ($begin < 0) $begin = 0;
        }
        if ($end < 0) {
            $end = $this->byteLength + $end;
            if ($end < 0) $end = 0;
        }

        
        $begin = min($begin, $this->byteLength);
        $end = min($end, $this->byteLength);

        
        if ($begin > $end) {
            $begin = $end;
        }

        $length = $end - $begin;
        
        
        
        
        $newOffset = $this->byteOffset + $begin;
        
        
        
        
        
        $sub = new static($length); 
        $sub->data = array_slice($this->data, $begin, $length);
        $sub->byteOffset = $newOffset; 
        $sub->buffer = $this->buffer; 

        return $sub;
    }

    
    public function set($array, $offset = 0): void {
        $offset = (int) $offset;
        if ($offset < 0 || $offset > $this->byteLength) {
             throw new \RangeException("Offset is out of bounds");
        }

        $sourceArray = is_array($array) ? $array : ($array instanceof Uint8ArrayLike ? $array->data : null);

        if ($sourceArray === null) {
             throw new \TypeError("Source must be an array or TypedArray");
        }

        $sourceLength = count($sourceArray);
        if ($offset + $sourceLength > $this->byteLength) {
             throw new \RangeException("Source array too large to fit at offset");
        }

        
        for ($i = 0; $i < $sourceLength; $i++) {
            $this->data[$offset + $i] = $sourceArray[$i] & 0xFF;
        }
    }

    
    
    
    
    
    
    
    
    
    
    
    protected $_arr = null; 

    
    
    
    
    
    
    
    public function __get($name) {
        switch ($name) {
            case 'buffer':
                
                
                return $this->buffer;
            case 'byteOffset':
                
                return $this->byteOffset;
            case 'length': 
                return $this->byteLength;
            default:
                
                
                
                return null; 
        }
    }

    
    public function copyWithin($target, $start, $end = null) {
        
        
        
        
        
        
        
        error_log("Uint8ArrayLike::copyWithin called - not fully implemented in this translation.");
        
        
        
        
        
    }
}






class s extends Uint8ArrayLike {
    
    public $_isBuffer = true;

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public static $kMaxLength = 2147483647; 

    
    public static $poolSize = 8192;

    
    
    
    const K_CHUNK_SIZE = 4096; 

    
    
    
    const P_BASE64_CLEAN_REGEX = '/[^+\/0-9A-Za-z-_]/'; 

    
    
    
    private static $G_hexLookup = null; 

    
    private static function initializeHexLookup() {
        if (self::$G_hexLookup === null) {
            $t_chars = "0123456789abcdef";
            $e_array = array_fill(0, 256, '');
            for ($n_high = 0; $n_high < 16; ++$n_high) {
                $a_base = 16 * $n_high;
                for ($r_low = 0; $r_low < 16; ++$r_low) {
                    $e_array[$a_base + $r_low] = $t_chars[$n_high] . $t_chars[$r_low];
                }
            }
            self::$G_hexLookup = $e_array;
        }
    }

    

    
    
    
    
    
    public static function from($t, $e = null, $n = null) {
        
        
        
        
        error_log("s::from called - relies on missing 'u' function.");
        
        
        
        
        
        if (is_string($t)) {
            $encoding = $e ?? 'utf8'; 
            
            
            
            
            $bytes = self::stringToBytes($t, $encoding); 
            return new self($bytes);
        } elseif (is_array($t)) {
            return new self($t); 
        } elseif ($t instanceof Uint8ArrayLike) {
             
             $offset = $e ?? 0;
             $length = $n ?? $t->byteLength - $offset;
             return new self($t, $offset, $length);
        } elseif (is_numeric($t)) {
             
             return new self($t);
        }
        
        throw new \TypeError('The first argument must be of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type ' . gettype($t));
    }

    
    
    
    
    public static function alloc($t, $e = null, $n = null) {
        
        
        error_log("s::alloc called - relies on missing 'c' and 'l' functions.");

        
        
        
        
        

        
        
        

        $size = (int) $t;
        
        if ($size < 0 || $size > self::$kMaxLength) {
             
             throw new \RangeException('Invalid size for buffer allocation');
        }

        
        $buf = new self($size); 

        
        if ($e !== null) {
            
            
            
            
            
            if (is_string($n)) {
                 
                 
<?php




class jQuery {
    private $elements;

    public function __construct($selector) {
        
        
        
        if (is_string($selector)) {
            
            $this->elements = [$selector]; 
        } elseif (is_object($selector) && method_exists($selector, 'getDomElement')) {
             
             $this->elements = [$selector->getDomElement()]; 
        } elseif (is_array($selector)) {
             
             $this->elements = array_map(function($el) {
                 return is_object($el) && method_exists($el, 'getDomElement') ? $el->getDomElement() : $el;
             }, $selector);
        } else {
             
             $this->elements = [$selector];
        }
    }

    
    public static function default($selector) {
        return new self($selector);
    }

    

    
    public function is($selector) {
        
        
        
        
        
        
        
        
        
        return false; 
    }

    
    public function one($eventName, $handler) {
        
        
        
        
        return $this; 
    }

    
    public function trigger($eventName, $extraParameters = null) {
        
        
        
        
        
        
        return new ConceptualEvent($eventName, $extraParameters);
    }

    
    public function removeClass($className) {
        
        
        
        
        
        return $this; 
    }

    
    public function addClass($className) {
        
        
        
        return $this; 
    }

    
    public function toggleClass($className, $state = null) {
         
         return $this; 
    }


    
    public function closest($selector) {
        
        
        
        
        return new jQuery(null); 
    }

    
    public function detach() {
        
        
        return $this; 
    }

    
    public function remove() {
        
        
        return $this; 
    }

    
    public function data($key, $value = null) {
        
        
        
        
        
        
        if ($value !== null) {
            
            return $this; 
        } else {
            
            
            return null; 
        }
    }

    
    public static function removeData($element, $key) {
        
    }

    
    public function off($eventName) {
        
        
        return $this; 
    }

    
    public function css($propertyName) {
        
        
        return ''; 
    }

    
    public function isVisible() {
        
        
        return true; 
    }

    
    public function each($callback) {
        
        
        foreach ($this->elements as $index => $element) {
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            $callback->call($element, $index, $element); 
        }
        return $this; 
    }

    
    public function not($selector) {
        
        
        return new jQuery([]); 
    }

    
    public function attr($attributeName, $value = null) {
        
        
        if ($value !== null) {
            
            return $this; 
        } else {
            
            return null; 
        }
    }

    
    public static function Event($type, $properties = []) {
        
        
        
        return new ConceptualEvent($type, $properties);
    }

    
    public static $event = null; 

    public static function initEventSpecial() {
        
        if (self::$event === null) {
            self::$event = new stdClass(); 
            self::$event->special = new stdClass();
        }
    }

    
    public static $fn = null; 

    public static function initFn() {
         
         if (self::$fn === null) {
             self::$fn = new stdClass(); 
         }
    }

    
    public static function noop() {
        
    }

    
    public static $jquery = '3.x.x'; 

    
    
    public function emulateTransitionEnd($duration) {
        
        
        return $this; 
    }

    
    public function get(int $index = 0) {
        return $this->elements[$index] ?? null;
    }

    
    public function length() {
        return count($this->elements);
    }

    
    public function hasClass($className) {
        
        
        return false; 
    }

    
    public function querySelector($selector) {
        
        
        return new stdClass(); 
    }

    
    public function querySelectorAll($selector) {
        
        
        return []; 
    }
}


class ConceptualEvent {
    public $type;
    public $relatedTarget;
    public $direction;
    public $from;
    public $to;
    public $target; 
    public $which; 
    public $originalEvent; 
    public $currentTarget; 
    public $handleObj; 

    private $defaultPrevented = false;

    public function __construct($type, $properties = []) {
        $this->type = $type;
        
        foreach ($properties as $key => $value) {
            $this->$key = $value;
        }
    }

    public function isDefaultPrevented() {
        
        return $this->defaultPrevented;
    }

    public function preventDefault() {
        
        $this->defaultPrevented = true;
    }

    public function stopPropagation() {
        
    }
}




class Popper {
    public function __construct($reference, $popper, $options) {
        
    }

    public function destroy() {
        
    }

    public function scheduleUpdate() {
        
    }
}


$r = jQuery::default; 
$s = new stdClass(); 
$s->default = Popper::class; 


jQuery::initEventSpecial();
jQuery::initFn();



























function l(...$args) {
    $target = $args[0];
    for ($i = 1; $i < count($args); $i++) {
        $source = $args[$i];
        if (is_array($target) && is_array($source)) {
            $target = array_merge($target, $source);
        } elseif (is_object($target) && is_object($source)) {
             foreach ($source as $key => $value) {
                 $target->$key = $value;
             }
        }
        
    }
    return $target;
}







$c = "transitionend";
$d = 1e6; 
$h = 1e3; 



function f($e) {
    if ($e === null) {
        return "" . $e; 
    }
    
    $type = gettype($e);
    if ($type === 'object') {
        
        
        
         return 'object'; 
    }
    return strtolower($type); 
}





$p = function() use ($c, $r) {
    $handler = function($e) use ($r) {
        
        
        
        
        
        $thisElement = $this; 
        if ($r($e->target)->is($thisElement)) { 
            
            
            
            
            
            return null; 
        }
        return null; 
    };
    return (object)[ 
        'bindType' => $c,
        'delegateType' => $c,
        'handle' => $handler
    ];
};














$m = function() use ($r, $v, $p) {
    
    
    
    
};



class v {
    
    const TRANSITION_END = "bsTransitionEnd";
    const D = 1e6; 
    const H = 1e3; 

    
    public static function getUID($e) {
        
        
        $id = $e;
        
        
        $id .= mt_rand(0, self::D - 1); 
        return $id;
    }

    public static function getSelectorFromElement($e) {
        
        
        $t = null; 
        if (!$t || "#" === $t) {
            
            $i = null; 
            $t = ($i && "#" !== $i) ? trim($i) : "";
        }
        try {
            
            
            
            
            
            
            
            
            return $t ? $t : null; 
        } catch (\Exception $exception) {
            
            return null;
        }
    }

    public static function getTransitionDurationFromElement($e) {
        
        if (!$e) {
            return 0;
        }
        global $r; 
        
        
        $t = "0s"; 
        $i = "0s"; 

        $n = floatval($t);
        $s = floatval($i);

        if ($n || $s) {
            $t = explode(",", $t)[0];
            $i = explode(",", $i)[0];
            return (floatval($t) + floatval($i)) * self::H;
        }
        return 0;
    }

    public static function reflow($e) {
        
        
        return 0; 
    }

    public static function triggerTransitionEnd($e) {
        
        global $r; 
        $r($e)->trigger(self::TRANSITION_END); 
    }

    public static function supportsTransitionEnd() {
        
        return (bool)self::TRANSITION_END; 
    }

    public static function isElement($e) {
        
        
        
        return is_object($e); 
    }

    public static function typeCheckConfig($e, $t, $i) {
        
        
        foreach ($i as $n => $r) { 
            if (array_key_exists($n, $t)) { 
                $s = $t[$n]; 
                
                $a = self::isElement($s) ? "element" : f($s); 

                
                
                
                
                $phpRegex = "/^(" . str_replace(['(', ')'], ['(?:', ')'], $r) . ")$/"; 

                if (!preg_match($phpRegex, $a)) {
                    throw new \Error(strtoupper($e) . ': Option "' . $n . '" provided type "' . $a . '" but expected type "' . $r . '".');
                }
            }
        }
    }

    public static function findShadowRoot($e) {
        
        
        
        
        return null; 
    }

    public static function jQueryDetection() {
        
        global $r; 
        if (!isset($r) || !is_callable($r)) { 
             throw new \TypeError("Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript.");
        }
        
        
        
        
        
        
        
    }
}


v::jQueryDetection();





$y = "alert";
$b = "4.6.0";
$_ = "bs.alert";
$E = "." . $_;
$T = ".data-api";

$w = null; 

$A = '[data-dismiss="alert"]';
$S = "close" . $E;
$k = "closed" . $E;
$C = "click" . $E . $T;
$x = "alert";
$L = "fade";
$R = "show";


class D {
    
    private $_element;

    
    public function __construct($element) {
        
        $this->_element = $element;
    }

    
    public function close($element = null) {
        global $r; 
        $t = $this->_element;
        if ($element) {
             $t = $this->_getRootElement($element); 
        }

        
        $closeEvent = $this->_triggerCloseEvent($t); 
        if (!$closeEvent->isDefaultPrevented()) {
            $this->_removeElement($t); 
        }
    }

    public function dispose() {
        global $r, $_; 
        
        $r::removeData($this->_element, $_); 
        $this->_element = null;
    }

    private function _getRootElement($e) {
        global $v, $r, $x; 
        
        $t = $v::getSelectorFromElement($e); 
        $i = false;
        if ($t) {
            
            
             $i = new stdClass(); 
        }
        
        
        if (!$i) {
             $i = new stdClass(); 
        }
        return $i; 
    }

    private function _triggerCloseEvent($e) {
        global $r, $S; 
        
        $t = $r::Event($S); 
        $r($e)->trigger($t); 
        return $t; 
    }

    private function _removeElement($e) {
        global $r, $R, $L, $v, $k; 
        $t = $this; 

        
        $r($e)->removeClass($R); 

        
        
        if (true) { 
            
            $i = $v::getTransitionDurationFromElement($e); 
            
            $r($e)->one($v::TRANSITION_END, function($i) use ($t, $e) {
                
                return $t->_destroyElement($e, $i); 
            })->emulateTransitionEnd($i); 
        } else {
            $this->_destroyElement($e); 
        }
    }

    private function _destroyElement($e, $i = null) {
        global $r, $k; 
        
        $r($e)->detach()->trigger($k)->remove(); 
    }

    
    public static function _jQueryInterface($t) {
        global $r, $_; 
        
        
        
        return $r($this)->each(function($index, $element) use ($r, $_, $t) {
            
            
            $i = $r($element); 
            $n = $i->data($_); 

            if (!$n) {
                
                $n = new self($element); 
                $i->data($_, $n); 
            }

            
            if ("close" === $t) {
                
                if (method_exists($n, $t)) {
                    $n->$t($element); 
                } else {
                     
                     
                }
            }
            
        });
    }

    
    public static function _handleDismiss($e) {
        
        
        
        return function($t) use ($e) {
            
            
            $clickedElement = $t->target; 

            if ($t) {
                $t->preventDefault(); 
            }
            
            $e->close($clickedElement); 
        };
    }

    
    public static function getVERSION() {
        global $b; 
        return $b;
    }
}






global $r, $C, $A;







global $y, $w;














$O = "button";
$I = "4.6.0";
$P = "bs.button";
$M = "." . $P;
$N = ".data-api";

$F = null; 

$j = "active";
$B = "btn";
$U = "focus";
$H = '[data-toggle^="button"]';
$q = '[data-toggle="buttons"]';
$G = '[data-toggle="button"]';
$K = '[data-toggle="buttons"] .btn';
$ = 'input:not([type="hidden"])';
$W = ".active";
$X = ".btn";
$V = "click" . $M . $N;
$z = "focus" . $M . $N . " blur" . $M . $N;
$Y = "load" . $M . $N;


class Q {
    
    private $_element;
    public $shouldAvoidTriggerChange; 

    
    public function __construct($element) {
        $this->_element = $element;
        $this->shouldAvoidTriggerChange = false;
    }

    
    public function toggle() {
        global $r, $q, $, $j, $W; 
        $e = true; 
        $t = true; 

        
        
        $i = new stdClass(); 

        if ($i) {
            
            
            $n = new stdClass(); 
            $n->type = 'checkbox'; 
            $n->checked = false; 
            $n->hasAttribute = function($attr) { return false; }; 
            $n->classList = new stdClass(); 
            $n->classList->contains = function($cls) { return false; }; 


            if ($n) {
                if ("radio" === $n->type) {
                    
                    
                    if (false) { 
                        $e = false;
                    } else {
                        
                        
                        $s = new stdClass(); 
                        if ($s) {
                            
                        }
                    }
                }

                
                
                
                $shouldCheck = ("checkbox" !== $n->type && "radio" !== $n->type);
                $toggleChecked = false;
                if (!$shouldCheck) {
                     
                     $toggleChecked = !$this->_element->classList->contains($j); 
                     $n->checked = $toggleChecked; 
                }

                if ($e && ($shouldCheck || $toggleChecked)) {
                    
                    if (!$this->shouldAvoidTriggerChange) {
                        
                    }
                }
                
                
                $t = false;
            }
        }

        
        
        if (true) { 
            
            if ($t) {
                
            }
            
            if ($e) {
                
            }
        }
    }

    public function dispose() {
        global $r, $P; 
        
        $r::removeData($this->_element, $P); 
        $this->_element = null;
    }

    
    public static function _jQueryInterface($t, $i = null) {
        global $r, $P; 
        
        return $r($this)->each(function($index, $element) use ($r, $P, $t, $i) {
            
            $n = $r($element); 
            $s = $n->data($P); 

            if (!$s) {
                
                $s = new self($element); 
                $n->data($P, $s); 
            }

            
            $s->shouldAvoidTriggerChange = $i;

            
            if ("toggle" === $t) {
                 if (method_exists($s, $t)) {
                     $s->$t(); 
                 } else {
                     
                 }
            }
            
        });
    }

    
    public static function getVERSION() {
        global $I; 
        return $I;
    }
}





global $r, $V, $H, $B, $X, $, $Q;











































global $z, $U;













global $Y, $K, $, $j, $G;












































global $O, $F;














$J = "carousel";
$Z = "4.6.0";
$ee = "bs.carousel";
$te = "." . $ee;
$ie = ".data-api";

$ne = null; 

$re = 37; 
$se = 39; 
$ae = 500; 
$oe = 40; 


$le = [
    'interval' => 5000,
    'keyboard' => true,
    'slide' => false, 
    'pause' => 'hover', 
    'wrap' => true,
    'touch' => true,
];


$ue = [
    'interval' => "(number|boolean)",
    'keyboard' => "boolean",
    'slide' => "(boolean|string)",
    'pause' => "(string|boolean)",
    'wrap' => "boolean",
    'touch' => "boolean",
];


$ce = "next";
$de = "prev";
$he = "left";
$fe = "right";
$pe = "slide" . $te; 
$ge = "slid" . $te; 
$me = "keydown" . $te; 
$ve = "mouseenter" . $te; 
$ye = "mouseleave" . $te; 
$be = "touchstart" . $te; 
$_e = "touchmove" . $te; 
$Ee = "touchend" . $te; 
$Te = "pointerdown" . $te; 
$we = "pointerup" . $te; 
$Ae = "dragstart" . $te; 
$Se = "load" . $te . $ie; 
$ke = "click" . $te . $ie; 


$Ce = "carousel";
$xe = "active";
$Le = "slide";
$Re = "carousel-item-right";
$De = "carousel-item-left";
$Oe = "carousel-item-next";
$Ie = "carousel-item-prev";
$Pe = "pointer-event"; 


$Me = ".active"; 
$Ne = ".active.carousel-item"; 
$Fe = ".carousel-item"; 
$je = ".carousel-item img"; 
$Be = ".carousel-item-next, .carousel-item-prev"; 
$Ue = ".carousel-indicators"; 
$He = "[data-slide], [data-slide-to]"; 
$qe = '[data-ride="carousel"]'; 


$Ge = [
    "TOUCH" => "touch",
    "PEN" => "pen",
];


class Ke {
    
    private $_items;
    private $_interval;
    private $_activeElement;
    private $_isPaused;
    private $_isSliding;
    public $touchTimeout; 
    public $touchStartX; 
    public $touchDeltaX; 
    private $_config;
    private $_element;
    private $_indicatorsElement;
    private $_touchSupported;
    private $_pointerEvent;

    
    public function __construct($element, $config) {
        global $Ue; 
        $this->_items = null;
        $this->_interval = null;
        $this->_activeElement = null;
        $this->_isPaused = false;
        $this->_isSliding = false;
        $this->touchTimeout = null;
        $this->touchStartX = 0;
        $this->touchDeltaX = 0;
        $this->_config = $this->_getConfig($config); 
        $this->_element = $element;
        
        
        $this->_indicatorsElement = new stdClass(); 

        
        
        $this->_touchSupported = false; 

        
        
        $this->_pointerEvent = false; 

        $this->_addEventListeners(); 
    }

    
    public function next() {
        global $ce; 
        if (!$this->_isSliding) {
            $this->_slide($ce); 
        }
    }

    public function nextWhenVisible() {
        global $r; 
        
        
        
        if (true) { 
            $this->next(); 
        }
    }

    public function prev() {
        global $de; 
        if (!$this->_isSliding) {
            $this->_slide($de); 
        }
    }

    public function pause($e = null) {
        global $v, $Be; 
        if (!$e) {
            $this->_isPaused = true;
        }
        
        
        if (false) { 
            $v::triggerTransitionEnd($this->_element); 
            $this->cycle(true); 
        }
        
        
        $this->_interval = null;
    }

    public function cycle($e = null) {
        global $v; 
        if (!$e) {
            $this->_isPaused = false;
        }
        
        
        $this->_interval = null; 

        
        if ($this->_config['interval'] && !$this->_isPaused) {
            $this->_updateInterval(); 
            
            
        }
    }

    public function to($e) {
        global $r, $ge, $Ne, $ce, $de; 
        $t = $this; 

        
        
        $this->_activeElement = new stdClass(); 

        $i = $this->_getItemIndex($this->_activeElement); 

        if (!($e > count($this->_items) - 1 || $e < 0)) {
            if ($this->_isSliding) {
                
                
            } else {
                if ($i === $e) {
                    $this->pause(); 
                    $this->cycle(); 
                    return; 
                }
                $n = $e > $i ? $ce : $de;
                $this->_slide($n, $this->_items[$e]); 
            }
        }
    }

    public function dispose() {
        global $r, $te, $ee; 
        
        $r($this->_element)->off($te); 
        
        $r::removeData($this->_element, $ee); 

        $this->_items = null;
        $this->_config = null;
        $this->_element = null;
        
        
        $this->_interval = null;
        $this->_isPaused = null;
        $this->_isSliding = null;
        $this->_activeElement = null;
        $this->_indicatorsElement = null;
    }

    public function update() {
        $this->_inNavbar = $this->_detectNavbar(); 
        
        
    }

    private function _getConfig($e) {
        global $le, $v, $ue, $J; 
        
        $e = l([], $le, $e); 
        
        
        

        $v::typeCheckConfig($J, $e, $ue); 
        return $e;
    }

    private function _handleSwipe() {
        global $oe; 
        $e = abs($this->touchDeltaX);
        if (!($e <= $oe)) {
            $t = $e / $this->touchDeltaX;
            $this->touchDeltaX = 0;
            if ($t > 0) {
                $this->prev(); 
            }
            if ($t < 0) {
                $this->next(); 
            }
        }
    }

    private function _addEventListeners() {
        global $r, $me, $ve, $ye; 
        $e = $this; 

        
        if ($this->_config['keyboard']) {
            
        }

        
        if ("hover" === $this->_config['pause']) {
            
            
        }

        
        if ($this->_config['touch']) {
            $this->_addTouchEventListeners(); 
        }
    }

    private function _addTouchEventListeners() {
        global $r, $Ge, $ae, $je, $Ae, $Te, $we, $be, $_e, $Ee, $Pe; 
        $e = $this; 

        if ($this->_touchSupported) {
            
            $t = function($t) use ($e, $Ge) {
                
                
                
                
                
                
            };
            $i = function($t) use ($e) {
                
                
                
                
                
                
            };
            $n = function($t) use ($e, $Ge, $ae) {
                
                
                
                
                $e->_handleSwipe(); 
                
                if ("hover" === $e->_config['pause']) {
                    $e->pause(); 
                    
                    
                }
            };

            
            

            
            if ($this->_pointerEvent) {
                
                
                
                
            } else {
                
                
                
            }
        }
    }

    private function _keydown($e) {
        global $re, $se; 
        
        
        if (true) { 
            switch ($e->which) { 
                case $re: 
                    $e->preventDefault(); 
                    $this->prev(); 
                    break;
                case $se: 
                    $e->preventDefault(); 
                    $this->next(); 
                    break;
            }
        }
    }

    private function _getItemIndex($e) {
        global $Fe; 
        
        
        $this->_items = []; 
        
        $index = array_search($e, $this->_items, true); 
        return $index === false ? -1 : $index; 
    }

    private function _getItemByDirection($e, $t) {
        global $ce, $de; 
        $i = $e === $ce;
        $n = $e === $de;
        $r = $this->_getItemIndex($t); 
        $s = count($this->_items) - 1;

        if (($n && 0 === $r || $i && $r === $s) && !$this->_config['wrap']) {
            return $t;
        }

        $a = ($r + ($e === $de ? -1 : 1)) % count($this->_items);
        
        if ($a < 0) {
            $a += count($this->_items);
        }

        return $this->_items[$a] ?? null; 
    }

    private function _triggerSlideEvent($e, $t) {
        global $r, $pe, $Ne; 
        $i = $this->_getItemIndex($e); 
        
        
        $n = new stdClass(); 
        $nIndex = $this->_getItemIndex($n); 

        
        $s = $r::Event($pe, [
            'relatedTarget' => $e,
            'direction' => $t,
            'from' => $nIndex,
            'to' => $i,
        ]); 
        $r($this->_element)->trigger($s); 
        return $s; 
    }

    private function _setActiveIndicatorElement($e) {
        global $r, $Me, $xe; 
        if ($this->_indicatorsElement) {
            
            
            $t = []; 

            
            

            
            
            $itemIndex = $this->_getItemIndex($e);
            $i = isset($this->_indicatorsElement->children[$itemIndex]) ? $this->_indicatorsElement->children[$itemIndex] : null; 

            if ($i) {
                
            }
        }
    }

    private function _updateInterval() {
        global $Ne; 
        
        
        $e = new stdClass(); 
        $e->getAttribute = function($attr) { return null; }; 

        if ($e) {
            
            $t = intval($e->getAttribute("data-interval")); 
            if ($t) {
                $this->_config['defaultInterval'] = $this->_config['defaultInterval'] ?? $this->_config['interval'];
                $this->_config['interval'] = $t;
            } else {
                $this->_config['interval'] = $this->_config['defaultInterval'] ?? $this->_config['interval'];
            }
        }
    }

    private function _slide($e, $t = null) {
        global $r, $v, $Ne, $ce, $de, $De, $Oe, $he, $Re, $Ie, $fe, $xe, $Le, $ge; 
        $i; $n; $s; 
        $a = $this; 

        
        
        $o = new stdClass(); 

        $l = $this->_getItemIndex($o); 
        $u = $t ?: ($o ? $this->_getItemByDirection($e, $o) : null); 
        $c = $this->_getItemIndex($u); 
        $d = (bool)$this->_interval;

        if ($e === $ce) {
            $i = $De; 
            $n = $Oe; 
            $s = $he; 
        } else { 
            $i = $Re; 
            $n = $Ie; 
            $s = $fe; 
        }

        
        
        if (false) { 
            $this->_isSliding = false;
            return;
        }

        
        $slideEvent = $this->_triggerSlideEvent($u, $s); 
        if (!$slideEvent->isDefaultPrevented() && $o && $u) {
            $this->_isSliding = true;
            if ($d) {
                $this->pause(); 
            }

            $this->_setActiveIndicatorElement($u); 
            $this->_activeElement = $u;

            
            $h = $r::Event($ge, [
                'relatedTarget' => $u,
                'direction' => $s,
                'from' => $l,
                'to' => $c,
            ]); 

            
            
            if (true) { 
                
                
                $v::reflow($u); 
                
                

                
                $f = $v::getTransitionDurationFromElement($o); 

                
                
                
                
                
                
                
                
                
            } else {
                
                
                
                $this->_isSliding = false;
                
                
            }

            if ($d) {
                $this->cycle(); 
            }
        }
    }

    
    public static function _jQueryInterface($t) {
        global $r, $ee, $le; 
        
        return $r($this)->each(function($index, $element) use ($r, $ee, $le, $t) {
            
            $i = $r($element); 
            $n = $i->data($ee); 
            
            $s = l([], $le, $i->data()); 
            if (is_array($t)) { 
                 $s = l([], $s, $t); 
            }

            $a = is_string($t) ? $t : ($s['slide'] ?? null); 

            if (!$n) {
                
                $n = new self($element, $s); 
                $i->data($ee, $n); 
            }

            
            if (is_numeric($t)) {
                $n->to($t); 
            } else if (is_string($a)) {
                
                if (method_exists($n, $a)) {
                    $n->$a(); 
                } else {
                    throw new \TypeError('No method named "' . $a . '"');
                }
            } else if (isset($s['interval']) && ($s['ride'] ?? false)) { 
                $n->pause(); 
                $n->cycle(); 
            }
        });
    }

    
    public static function _dataApiClickHandler($t) {
        global $v, $r, $Ce, $ee, $le; 
        
        $clickedElement = $t->target; 
        $clickedElement->getAttribute = function($attr) { return null; }; 

        
        $i = $v::getSelectorFromElement($clickedElement); 

        if ($i) {
            
            
            $n = new stdClass(); 
            $n->classList = new stdClass(); 
            $n->classList->contains = function($cls) { return false; }; 

            
            
            if (true) { 
                
                $s = l([], $r($n)->data(), $r($clickedElement)->data()); 

                
                $a = $clickedElement->getAttribute("data-slide-to"); 

                if ($a !== null) { 
                    $s['interval'] = false; 
                }

                
                
                
                self::_jQueryInterface($r($n), $s); 

                if ($a !== null) { 
                    
                    $instance = $r($n)->data($ee); 
                    if ($instance && method_exists($instance, 'to')) {
                         $instance->to(intval($a)); 
                    }
                }

                $t->preventDefault(); 
            }
        }
    }

    
    public static function getVERSION() {
        global $Z; 
        return $Z;
    }

    
    public static function getDefault() {
        global $le; 
        return $le;
    }
}





global $ke, $He;






global $Se, $qe;




















global $J, $ne;














$e_collapse = "collapse"; 
$We = "4.6.0";
$Xe = "bs.collapse";
$Ve = "." . $Xe;
$ze = ".data-api";

$Ye = null; 


$Qe = [
    'toggle' => true,
    'parent' => "", 
];


$Je = [
    'toggle' => "boolean",
    'parent' => "(string|element)",
];


$Ze = "show" . $Ve; 
$et = "shown" . $Ve; 
$tt = "hide" . $Ve; 
$it = "hidden" . $Ve; 
$nt = "click" . $Ve . $ze; 


$rt = "show"; 
$st = "collapse"; 
$at = "collapsing"; 
$ot = "collapsed"; 
$lt = "width"; 
$ut = "height"; 


$ct = ".show, .collapsing"; 
$dt = '[data-toggle="collapse"]'; 


class ht {
    
    private $_isTransitioning;
    private $_element;
    private $_config;
    private $_triggerArray;
    private $_selector; 
    private $_parent;

    
    public function __construct($element, $config) {
        global $dt, $v, $rt, $st, $ot; 
        $this->_isTransitioning = false;
        $this->_element = $element;
        $this->_config = $this->_getConfig($config); 

        
        
        $this->_triggerArray = []; 

        
        
        
        $i = []; 
        for ($n = 0, $r = count($i); $n < $r; $n++) {
            $s = $i[$n]; 
            $a = $v::getSelectorFromElement($s); 
            
            
            $o = []; 

            if (null !== $a && count($o) > 0) {
                $this->_selector = $a;
                $this->_triggerArray[] = $s; 
            }
        }

        $this->_parent = $this->_config['parent'] ? $this->_getParent() : null; 

        
        if (!$this->_config['parent']) {
            $this->_addAriaAndCollapsedClass($this->_element, $this->_triggerArray); 
        }

        if ($this->_config['toggle']) {
            $this->toggle(); 
        }
    }

    
    public function toggle() {
        global $r, $rt; 
        
        
        if (false) { 
            $this->hide(); 
        } else {
            $this->show(); 
        }
    }

    public function show() {
        global $r, $Ze, $ct, $st, $Xe, $at, $ot, $v, $et, $e_collapse; 
        $n = $this; 

        
        
        if (true) { 
            $t = null; 
            $i = null; 

            
            if ($this->_parent) {
                
                
                
                
                $t = []; 

                if (count($t) === 0) {
                    $t = null;
                }
            }

            
            if ($t) {
                
                $i = null; 
            }

            
            if (!($t && $i && ($i->_isTransitioning ?? false))) { 
                
                $s = $r::Event($Ze); 
                $r($this->_element)->trigger($s); 

                if (!$s->isDefaultPrevented()) {
                    
                    if ($t) {
                        
                        
                        self::_jQueryInterface($r($t)->not($this->_selector), "hide"); 
                        
                    }

                    $a = $this->_getDimension(); 

                    
                    
                    
                    

                    
                    if (count($this->_triggerArray) > 0) {
                        
                    }

                    $this->setTransitioning(true); 

                    
                    
                    $l = "scrollHeight"; 

                    
                    $u = $v::getTransitionDurationFromElement($this->_element); 

                    
                    

                    
                    $o = function() use ($r, $n, $at, $st, $rt, $a, $et) {
                        
                        
                        
                        $n->setTransitioning(false); 
                        
                        
                    };

                    
                    
                }
            }
        }
    }

    public function hide() {
        global $r, $tt, $rt, $at, $st, $ot, $v, $it; 
        $e = $this; 

        
        
        if (true) { 
            
            $t = $r::Event($tt); 
            $r($this->_element)->trigger($t); 

            if (!$t->isDefaultPrevented()) {
                $i = $this->_getDimension(); 

                
                
                $v::reflow($this->_element); 

                
                

                $n = count($this->_triggerArray);
                if ($n > 0) {
                    for ($s = 0; $s < $n; $s++) {
                        $a = $this->_triggerArray[$s]; 
                        $a->classList = new stdClass(); 
                        $a->classList->add = function($cls) {}; 
                        $a->setAttribute = function($attr, $val) {}; 

                        $o = $v::getSelectorFromElement($a); 
                        if (null !== $o) {
                            
                            
                            if (true) { 
                                
                            }
                        }
                    }
                }

                $this->setTransitioning(true); 

                
                

                
                $u = $v::getTransitionDurationFromElement($this->_element); 

                
                $l = function() use ($e, $at, $st, $it) {
                    $e->setTransitioning(false); 
                    
                    
                };

                
                
            }
        }
    }

    public function setTransitioning($e) {
        $this->_isTransitioning = $e;
    }

    public function dispose() {
        global $r, $Xe; 
        
        $r::removeData($this->_element, $Xe); 
        $this->_config = null;
        $this->_parent = null;
        $this->_element = null;
        $this->_triggerArray = null;
        $this->_isTransitioning = null;
    }

    private function _getConfig($e) {
        global $Qe, $v, $Je, $e_collapse; 
        
        $e = l([], $Qe, $e); 
        $e['toggle'] = (bool)($e['toggle'] ?? false); 

        $v::typeCheckConfig($e_collapse, $e, $Je); 
        return $e;
    }

    private function _getDimension() {
        global $r, $lt, $ut; 
        
        
        return $ut; 
    }

    private function _getParent() {
        global $v, $r, $rt, $ot, $Xe, $e_collapse; 
        $t; 
        $i = $this; 

        
        if ($v::isElement($this->_config['parent'])) { 
            $t = $this->_config['parent'];
            
            
        } else {
            
            
            $t = new stdClass(); 
        }

        
        $n = '[data-toggle="collapse"][data-parent="' . ($this->_config['parent'] ?? '') . '"]'; 
        
        $s = []; 

        
        
        
        
        

        return $t; 
    }

    private function _addAriaAndCollapsedClass($e, $t) {
        global $r, $rt, $ot; 
        
        
        $i = false; 

        
        if (count($t) > 0) {
            
        }
    }

    
    public static function _getTargetFromElement($e) {
        global $v; 
        
        $t = $v::getSelectorFromElement($e); 
        
        
        return $t ? new stdClass() : null; 
    }

    
    public static function _jQueryInterface($t) {
        global $r, $Xe, $Qe; 
        
        return $r($this)->each(function($index, $element) use ($r, $Xe, $Qe, $t) {
            
            $i = $r($element); 
            $n = $i->data($Xe); 
            
            $s = l([], $Qe, $i->data()); 
            if (is_array($t)) { 
                 $s = l([], $s, $t); 
            }

            
            if (!$n && ($s['toggle'] ?? false) && is_string($t) && preg_match('/show|hide/', $t)) {
                $s['toggle'] = false;
            }

            if (!$n) {
                
                $n = new self($element, $s); 
                $i->data($Xe, $n); 
            }

            
            if (is_string($t)) {
                if (method_exists($n, $t)) {
                    $n->$t(); 
                } else {
                    throw new \TypeError('No method named "' . $t . '"');
                }
            }
        });
    }

    
    public static function getVERSION() {
        global $We; 
        return $We;
    }

    
    public static function getDefault() {
        global $Qe; 
        return $Qe;
    }
}





global $nt, $dt, $v, $r, $Xe;







<?php






class Base64 {
    

    
    private static $n = [];
    
    private static $a = [];
    
    

    
    private static function initializeLookupTables() {
        if (empty(self::$n)) {
            $i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
            for ($o = 0; $o < 64; ++$o) {
                self::$n[$o] = $i[$o];
                self::$a[ord($i[$o])] = $o;
            }
            
            self::$a[ord('-')] = 62;
            self::$a[ord('_')] = 63;
        }
    }

    
    public static function byteLength($t) {
        self::initializeLookupTables();
        $e = self::l($t);
        $n = $e[0]; 
        $a = $e[1]; 
        return (int)(3 * ($n + $a) / 4 - $a);
    }

    
    public static function toByteArray($t) {
        self::initializeLookupTables();
        $i = self::l($t);
        $o = $i[0]; 
        $s = $i[1]; 
        
        
        $u = array_fill(0, (int)(3 * ($o + $s) / 4 - $s), 0); 
        $c = 0; 
        $d = $s > 0 ? $o - 4 : $o; 

        for ($n = 0; $n < $d; $n += 4) {
            $e = (self::$a[ord($t[$n])] << 18) | (self::$a[ord($t[$n + 1])] << 12) | (self::$a[ord($t[$n + 2])] << 6) | self::$a[ord($t[$n + 3])]; 
            $u[$c++] = ($e >> 16) & 255;
            $u[$c++] = ($e >> 8) & 255;
            $u[$c++] = $e & 255;
        }

        if (2 === $s) {
            $e = (self::$a[ord($t[$n])] << 2) | (self::$a[ord($t[$n + 1])] >> 4); 
            $u[$c++] = $e & 255;
        }

        if (1 === $s) {
            $e = (self::$a[ord($t[$n])] << 10) | (self::$a[ord($t[$n + 1])] << 4) | (self::$a[ord($t[$n + 2])] >> 2); 
            $u[$c++] = ($e >> 8) & 255;
            $u[$c++] = $e & 255;
        }

        return $u;
    }

    
    public static function fromByteArray($t) {
        self::initializeLookupTables();
        $e = count($t); 
        $a = $e % 3; 
        $r = []; 
        $i = 16383; 
        $o = 0; 
        $l = $e - $a; 

        for (; $o < $l; $o += $i) {
            $r[] = self::s($t, $o, $o + $i > $l ? $l : $o + $i);
        }

        if (1 === $a) {
            $e = $t[$e - 1]; 
            $r[] = self::$n[$e >> 2] . self::$n[($e << 4) & 63] . "==";
        } elseif (2 === $a) {
            $e = ($t[$e - 2] << 8) + $t[$e - 1]; 
            $r[] = self::$n[$e >> 10] . self::$n[($e >> 4) & 63] . self::$n[($e << 2) & 63] . "=";
        }

        return implode("", $r);
    }

    
    private static function l($t) {
        $e = strlen($t); 
        if ($e % 4 > 0) {
            throw new \Exception("Invalid string. Length must be a multiple of 4");
        }
        $n = strpos($t, "="); 
        if ($n === false) {
            $n = $e;
        }
        return [$n, $n === $e ? 0 : 4 - ($n % 4)];
    }

    
    private static function s($t, $e, $a) {
        self::initializeLookupTables();
        $r = []; 
        $i = $e; 
        for (; $i < $a; $i += 3) {
            $o = ($t[$i] << 16 & 16711680) + ($t[$i + 1] << 8 & 65280) + ($t[$i + 2] & 255); 
            $r[] = self::$n[($i = $o) >> 18 & 63] . self::$n[($i >> 12) & 63] . self::$n[($i >> 6) & 63] . self::$n[$i & 63];
        }
        return implode("", $r);
    }
}


class Buffer {
    

    
    
    

    
    

    const INSPECT_MAX_BYTES = 50;

    
    const kMaxLength = 2147483647; 

    
    const poolSize = 8192;

    
    private $data;
    
    public $_isBuffer = true;
    public $buffer = null; 
    public $byteOffset = 0; 
    public $length = 0; 

    
    private function __construct($data = '', $byteOffset = 0, $byteLength = null) {
        $this->data = $data;
        $this->byteOffset = $byteOffset;
        $this->length = $byteLength === null ? strlen($data) : $byteLength;
        
        
        
        
        $this->buffer = null; 
    }

    

    
    public static function from($t, $e = null, $n = null) {
        
        
        if (is_string($t)) {
            return self::u_string($t, $e);
        } elseif (is_array($t)) {
             
            return self::f_array($t);
        } elseif ($t instanceof self) {
            
            return self::r_buffer($t);
        } elseif (is_numeric($t)) {
             throw new \TypeError('The "value" argument must not be of type number. Received type number');
        } elseif (is_object($t) && method_exists($t, 'valueOf')) {
             $a = $t->valueOf();
             if ($a !== null && $a !== $t) {
                 return self::from($a, $e, $n);
             }
        }

        
        

        throw new \TypeError("The first argument must be one of type string, Buffer, Array, or Array-like Object. Received type " . gettype($t));
    }

    
    public static function alloc($t, $e = null, $n = null) {
        return self::d_alloc($t, $e, $n);
    }

    
    public static function allocUnsafe($t) {
        return self::d_alloc($t); 
    }

    
    public static function allocUnsafeSlow($t) {
        return self::d_alloc($t); 
    }

    
    public static function isBuffer($t) {
        return $t instanceof self && $t->_isBuffer === true;
    }

    
    public static function compare($t, $e) {
        
        if (!($t instanceof self)) {
             if (is_string($t)) $t = new self($t);
             elseif (is_array($t)) $t = self::fromByteArray($t);
             else throw new \TypeError('The "buf1" argument must be one of type Buffer, string or Uint8Array (array).');
        }
         if (!($e instanceof self)) {
             if (is_string($e)) $e = new self($e);
             elseif (is_array($e)) $e = self::fromByteArray($e);
             else throw new \TypeError('The "buf2" argument must be one of type Buffer, string or Uint8Array (array).');
        }

        if ($t === $e) {
            return 0;
        }

        $n = $t->length; 
        $a = $e->length; 
        $r = 0; 
        $i = min($n, $a); 

        for (; $r < $i; ++$r) {
            if ($t->data[$r] !== $e->data[$r]) {
                $n = ord($t->data[$r]);
                $a = ord($e->data[$r]);
                break;
            }
        }

        return $n < $a ? -1 : ($a < $n ? 1 : 0);
    }

    
    public static function isEncoding($t) {
        switch (strtolower(strval($t))) {
            case "hex":
            case "utf8":
            case "utf-8":
            case "ascii":
            case "latin1":
            case "binary":
            case "base64":
            case "ucs2":
            case "ucs-2":
            case "utf16le":
            case "utf-16le":
                return true;
            default:
                return false;
        }
    }

    
    public static function concat($t, $e = null) {
        if (!is_array($t)) {
            throw new \TypeError('"list" argument must be an Array of Buffers');
        }
        if (0 === count($t)) {
            return self::alloc(0);
        }

        $n = null; 
        if (void 0 === $e) { 
            $e = 0;
            for ($n = 0; $n < count($t); ++$n) {
                $e += $t[$n]->length;
            }
        }

        $a = self::allocUnsafe($e); 
        $r = 0; 

        for ($n = 0; $n < count($t); ++$n) {
            $i = $t[$n]; 
            if (!($i instanceof self)) {
                 
                 
                throw new \TypeError('"list" argument must be an Array of Buffers');
            }
            
            
            $i->copy($a, $r);
            $r += $i->length;
        }

        return $a;
    }

    
    public static function byteLength($t, $e = 'utf8', $n = false) {
        return self::h_byteLength($t, $e, $n);
    }

    

    
    public function swap16() {
        $t = $this->length; 
        if ($t % 2 != 0) {
            throw new \RangeError("Buffer size must be a multiple of 16-bits");
        }
        for ($e = 0; $e < $t; $e += 2) {
            self::b_swap($this->data, $e, $e + 1);
        }
        return $this;
    }

    
    public function swap32() {
        $t = $this->length; 
        if ($t % 4 != 0) {
            throw new \RangeError("Buffer size must be a multiple of 32-bits");
        }
        for ($e = 0; $e < $t; $e += 4) {
            self::b_swap($this->data, $e, $e + 3);
            self::b_swap($this->data, $e + 1, $e + 2);
        }
        return $this;
    }

    
    public function swap64() {
        $t = $this->length; 
        if ($t % 8 != 0) {
            throw new \RangeError("Buffer size must be a multiple of 64-bits");
        }
        for ($e = 0; $e < $t; $e += 8) {
            self::b_swap($this->data, $e, $e + 7);
            self::b_swap($this->data, $e + 1, $e + 6);
            self::b_swap($this->data, $e + 2, $e + 5);
            self::b_swap($this->data, $e + 3, $e + 4);
        }
        return $this;
    }

    
    public function toString($t = 'utf8', $e = 0, $n = null) {
        $a = $this->length; 
        if (0 === $a) {
            return "";
        }
        
        
        if ($n === null) {
            $n = $a;
        }
        return self::p_toString($this->data, $t, $e, $n);
    }

    
    public function toLocaleString($t = 'utf8', $e = 0, $n = null) {
        return $this->toString($t, $e, $n);
    }

    
    public function equals($t) {
        if (!self::isBuffer($t)) {
            throw new \TypeError("Argument must be a Buffer");
        }
        return $this === $t || 0 === self::compare($this, $t);
    }

    
    public function inspect() {
        $t = ""; 
        $n = self::INSPECT_MAX_BYTES; 
        $t = substr($this->toString("hex", 0, $n), 0, $n * 2); 
        $t = trim(chunk_split($t, 2, ' ')); 
        if ($this->length > $n) {
            $t .= " ... ";
        }
        return "<Buffer " . $t . ">";
    }

    

    
    public function compare($t, $e = 0, $n = null, $a = 0, $r = null) {
        
        if (!($t instanceof self)) {
             
            throw new \TypeError('The "target" argument must be one of type Buffer or Uint8Array (array). Received type ' . gettype($t));
        }

        
        if ($n === null) {
            $n = $t->length;
        }
        if ($r === null) {
            $r = $this->length;
        }

        
        $e = (int)$e;
        $n = (int)$n;
        $a = (int)$a;
        $r = (int)$r;

        if ($e < 0 || $n > $t->length || $a < 0 || $r > $this->length) {
            throw new \RangeError("out of range index");
        }

        if ($a >= $r && $e >= $n) {
            return 0;
        }
        if ($a >= $r) {
            return -1;
        }
        if ($e >= $n) {
            return 1;
        }

        if ($this === $t) {
            return 0;
        }

        
        $i = $r - $a; 
        $o = $n - $e; 
        $l = min($i, $o); 

        
        $u = substr($this->data, $a, $i); 
        $c = substr($t->data, $e, $o); 

        
        for ($d = 0; $d < $l; ++$d) {
            if ($u[$d] !== $c[$d]) {
                $i = ord($u[$d]);
                $o = ord($c[$d]);
                break;
            }
        }

        return $i < $o ? -1 : ($o < $i ? 1 : 0);
    }

    
    public function includes($t, $e = 0, $n = 'utf8') {
        return -1 !== $this->indexOf($t, $e, $n);
    }

    
    public function indexOf($t, $e = 0, $n = 'utf8') {
        return self::y_search($this->data, $t, $e, $n, true);
    }

    
    public function lastIndexOf($t, $e = 0, $n = 'utf8') {
        return self::y_search($this->data, $t, $e, $n, false);
    }

    
    public function write($t, $e = 0, $n = null, $a = 'utf8') {
        
        
        if (is_string($e)) { 
             $a = $e;
             $e = 0;
             $n = $this->length;
        } elseif (is_numeric($e)) { 
             if (!is_finite($e)) {
                 throw new \Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
             }
             $e = (int)$e;
             if (is_numeric($n)) {
                 if (!is_finite($n)) {
                      throw new \Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
                 }
                 $n = (int)$n;
                 
             } else { 
                 $a = $n;
                 $n = null; 
             }
        } else { 
             $a = 'utf8';
             $e = 0;
             $n = $this->length;
        }


        $r = $this->length - $e; 
        if ($n === null || $n > $r) {
            $n = $r;
        }

        if (strlen($t) > 0 && ($n < 0 || $e < 0) || $e > $this->length) {
            throw new \RangeError("Attempt to write outside buffer bounds");
        }

        if ($a === null) {
            $a = 'utf8';
        }

        $i = false; 
        for (;;) {
            switch (strtolower($a)) {
                case "hex":
                    return self::_writeHex($this->data, $t, $e, $n);
                case "utf8":
                case "utf-8":
                    return self::A_writeUtf8($this->data, $t, $e, $n);
                case "ascii":
                case "latin1":
                case "binary":
                    return self::T_writeLatin1($this->data, $t, $e, $n);
                case "base64":
                    return self::v_writeBase64($this->data, $t, $e, $n);
                case "ucs2":
                case "ucs-2":
                case "utf16le":
                case "utf-16le":
                    return self::w_writeUtf16le($this->data, $t, $e, $n);
                default:
                    if ($i) {
                        throw new \TypeError("Unknown encoding: " . $a);
                    }
                    $a = strtolower($a);
                    $i = true;
            }
        }
    }

    
    public function toJSON() {
        
        
        return [
            'type' => 'Buffer',
            'data' => array_values(unpack('C*', $this->data)) 
        ];
    }

    

    
    public function readUintLE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::x_checkOffset($t, $e, $this->length);
        }

        $a = 0; 
        $r = 1; 
        $i = 0; 

        
        for (; $i < $e; ++$i) {
             $a += ord($this->data[$t + $i]) * $r;
             if ($i < $e - 1) { 
                 $r *= 256;
             }
        }
        return $a;
    }

    
    public function readUIntLE($t, $e, $n = false) {
        return $this->readUintLE($t, $e, $n);
    }

    
    public function readUintBE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::x_checkOffset($t, $e, $this->length);
        }

        $a = 0; 
        $r = 1; 
        $i = $e - 1; 

        
        for (; $i >= 0; --$i) {
             $a += ord($this->data[$t + $i]) * $r;
             if ($i > 0) { 
                 $r *= 256;
             }
        }
        return $a;
    }

    
    public function readUIntBE($t, $e, $n = false) {
        return $this->readUintBE($t, $e, $n);
    }

    
    public function readUint8($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 1, $this->length);
        }
        return ord($this->data[$t]);
    }

    
    public function readUInt8($t, $e = false) {
        return $this->readUint8($t, $e);
    }

    
    public function readUint16LE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 2, $this->length);
        }
        
        $unpacked = unpack('v', substr($this->data, $t, 2));
        return $unpacked[1];
    }

    
    public function readUInt16LE($t, $e = false) {
        return $this->readUint16LE($t, $e);
    }

    
    public function readUint16BE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 2, $this->length);
        }
        
        $unpacked = unpack('n', substr($this->data, $t, 2));
        return $unpacked[1];
    }

    
    public function readUInt16BE($t, $e = false) {
        return $this->readUint16BE($t, $e);
    }

    
    public function readUint32LE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 4, $this->length);
        }
        
        $unpacked = unpack('V', substr($this->data, $t, 4));
        return $unpacked[1];
    }

    
    public function readUInt32LE($t, $e = false) {
        return $this->readUint32LE($t, $e);
    }

    
    public function readUint32BE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 4, $this->length);
        }
        
        $unpacked = unpack('N', substr($this->data, $t, 4));
        return $unpacked[1];
    }

    
    public function readUInt32BE($t, $e = false) {
        return $this->readUint32BE($t, $e);
    }

    
    public function readIntLE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::x_checkOffset($t, $e, $this->length);
        }

        $a = 0; 
        $r = 1; 
        $i = 0; 

        
        for (; $i < $e; ++$i) {
             $a += ord($this->data[$t + $i]) * $r;
             if ($i < $e - 1) { 
                 $r *= 256;
             }
        }

        
        $r *= 128; 
        if ($a >= $r) {
            $a -= pow(2, 8 * $e);
        }

        return $a;
    }

    
    public function readIntBE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::x_checkOffset($t, $e, $this->length);
        }

        $a = $e; 
        $r = 1; 
        $i = ord($this->data[$t + --$a]); 

        
        for (; $a > 0; --$a) {
             $r *= 256;
             $i += ord($this->data[$t + $a - 1]) * $r;
        }

        
        $r *= 128; 
        if ($i >= $r) {
            $i -= pow(2, 8 * $e);
        }

        return $i;
    }

    
    public function readInt8($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 1, $this->length);
        }
        $byte = ord($this->data[$t]);
        
        return ($byte & 128) ? -((255 - $byte) + 1) : $byte;
    }

    
    public function readInt16LE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 2, $this->length);
        }
        
        $unpacked = unpack('s', substr($this->data, $t, 2));
        return $unpacked[1];
    }

    
    public function readInt16BE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 2, $this->length);
        }
        
        $unpacked = unpack('S', substr($this->data, $t, 2)); 
        $n = $unpacked[1]; 
        
        
        
        
        
        
         return $unpacked[1];
    }

    
    public function readInt32LE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 4, $this->length);
        }
        
        $unpacked = unpack('l', substr($this->data, $t, 4));
        return $unpacked[1];
    }

    
    public function readInt32BE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 4, $this->length);
        }
        
        $unpacked = unpack('L', substr($this->data, $t, 4)); 
        $n = $unpacked[1]; 
        
        
        
        
        
        
        
        
        return (ord($this->data[$t]) << 24) | (ord($this->data[$t+1]) << 16) | (ord($this->data[$t+2]) << 8) | ord($this->data[$t+3]);
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        $value = unpack('N', substr($this->data, $t, 4))[1];
        if ($value >= 2147483648) { 
             $value -= 4294967296; 
        }
        return $value;
    }

    
    public function readFloatLE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 4, $this->length);
        }
        
        $unpacked = unpack('P', substr($this->data, $t, 4));
        return $unpacked[1];
    }

    
    public function readFloatBE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 4, $this->length);
        }
        
        $unpacked = unpack('g', substr($this->data, $t, 4));
        return $unpacked[1];
    }

    
    public function readDoubleLE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 8, $this->length);
        }
        
        $unpacked = unpack('e', substr($this->data, $t, 8));
        return $unpacked[1];
    }

    
    public function readDoubleBE($t, $e = false) {
        $t = (int)$t;
        if (!$e) {
            self::x_checkOffset($t, 8, $this->length);
        }
        
        $unpacked = unpack('E', substr($this->data, $t, 8));
        return $unpacked[1];
    }

    

    
    public function writeUintLE($t, $e, $n, $a = false) {
        $t = (int)$t;
        $e = (int)$e;
        $n = (int)$n;
        if (!$a) {
            self::M_checkIntBounds($this, $t, $e, $n, pow(2, 8 * $n) - 1, 0);
        }

        $r = 1; 
        $i = 0; 

        
        $this->data[$e] = chr($t & 255);
        for (++$i; $i < $n; ++$i) {
             $r *= 256;
             $this->data[$e + $i] = chr(($t / $r) & 255);
        }

        return $e + $n;
    }

    
    public function writeUIntLE($t, $e, $n, $a = false) {
        return $this->writeUintLE($t, $e, $n, $a);
    }

    
    public function writeUintBE($t, $e, $n, $a = false) {
        $t = (int)$t;
        $e = (int)$e;
        $n = (int)$n;
        if (!$a) {
            self::M_checkIntBounds($this, $t, $e, $n, pow(2, 8 * $n) - 1, 0);
        }

        $r = $n - 1; 
        $i = 1; 

        
        $this->data[$e + $r] = chr($t & 255);
        for (--$r; $r >= 0; --$r) {
             $i *= 256;
             $this->data[$e + $r] = chr(($t / $i) & 255);
        }

        return $e + $n;
    }

    
    public function writeUIntBE($t, $e, $n, $a = false) {
        return $this->writeUintBE($t, $e, $n, $a);
    }

    
    public function writeUint8($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 1, 255, 0);
        }
        $this->data[$e] = chr($t & 255);
        return $e + 1;
    }

    
    public function writeUInt8($t, $e, $n = false) {
        return $this->writeUint8($t, $e, $n);
    }

    
    public function writeUint16LE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 2, 65535, 0);
        }
        
        $packed = pack('v', $t);
        $this->data = substr_replace($this->data, $packed, $e, 2);
        return $e + 2;
    }

    
    public function writeUInt16LE($t, $e, $n = false) {
        return $this->writeUint16LE($t, $e, $n);
    }

    
    public function writeUint16BE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 2, 65535, 0);
        }
        
        $packed = pack('n', $t);
        $this->data = substr_replace($this->data, $packed, $e, 2);
        return $e + 2;
    }

    
    public function writeUInt16BE($t, $e, $n = false) {
        return $this->writeUint16BE($t, $e, $n);
    }

    
    public function writeUint32LE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 4, 4294967295, 0);
        }
        
        $packed = pack('V', $t);
        $this->data = substr_replace($this->data, $packed, $e, 4);
        return $e + 4;
    }

    
    public function writeUInt32LE($t, $e, $n = false) {
        return $this->writeUint32LE($t, $e, $n);
    }

    
    public function writeUint32BE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 4, 4294967295, 0);
        }
        
        $packed = pack('N', $t);
        $this->data = substr_replace($this->data, $packed, $e, 4);
        return $e + 4;
    }

    
    public function writeUInt32BE($t, $e, $n = false) {
        return $this->writeUint32BE($t, $e, $n);
    }

    
    public function writeIntLE($t, $e, $n, $a = false) {
        $t = (int)$t;
        $e = (int)$e;
        $n = (int)$n;
        if (!$a) {
            $r = pow(2, 8 * $n - 1); 
            self::M_checkIntBounds($this, $t, $e, $n, $r - 1, -$r);
        }

        $i = 0; 
        $o = 1; 
        $l = 0; 

        
        $this->data[$e] = chr($t & 255);
        for (++$i; $i < $n; ++$i) {
             $o *= 256;
             
             if ($t < 0 && $l === 0 && ord($this->data[$e + $i - 1]) !== 0) {
                 $l = 1;
             }
             $this->data[$e + $i] = chr((($t / $o) | 0) - $l & 255);
        }

        return $e + $n;
    }

    
    public function writeIntBE($t, $e, $n, $a = false) {
        $t = (int)$t;
        $e = (int)$e;
        $n = (int)$n;
        if (!$a) {
            $r = pow(2, 8 * $n - 1); 
            self::M_checkIntBounds($this, $t, $e, $n, $r - 1, -$r);
        }

        $i = $n - 1; 
        $o = 1; 
        $l = 0; 

        
        $this->data[$e + $i] = chr($t & 255);
        for (--$i; $i >= 0; --$i) {
             $o *= 256;
             
             if ($t < 0 && $l === 0 && ord($this->data[$e + $i + 1]) !== 0) {
                 $l = 1;
             }
             $this->data[$e + $i] = chr((($t / $o) | 0) - $l & 255);
        }

        return $e + $n;
    }

    
    public function writeInt8($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 1, 127, -128);
        }
        
        if ($t < 0) {
            $t = 255 + $t + 1;
        }
        $this->data[$e] = chr($t & 255);
        return $e + 1;
    }

    
    public function writeInt16LE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 2, 32767, -32768);
        }
        
        $packed = pack('s', $t);
        $this->data = substr_replace($this->data, $packed, $e, 2);
        return $e + 2;
    }

    
    public function writeInt16BE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 2, 32767, -32768);
        }
        
        
        
        
        
        
        
        $this->data[$e] = chr(($t >> 8) & 255);
        $this->data[$e + 1] = chr($t & 255);
        return $e + 2;
    }

    
    public function writeInt32LE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 4, 2147483647, -2147483648);
        }
        
        $packed = pack('l', $t);
        $this->data = substr_replace($this->data, $packed, $e, 4);
        return $e + 4;
    }

    
    public function writeInt32BE($t, $e, $n = false) {
        $t = (int)$t;
        $e = (int)$e;
        if (!$n) {
            self::M_checkIntBounds($this, $t, $e, 4, 2147483647, -2147483648);
        }
        
        
        
        if ($t < 0) {
            $t = 4294967295 + $t + 1; 
        }
        $this->data[$e] = chr(($t >> 24) & 255);
        $this->data[$e + 1] = chr(($t >> 16) & 255);
        $this->data[$e + 2] = chr(($t >> 8) & 255);
        $this->data[$e + 3] = chr($t & 255);
        return $e + 4;
    }

    
    public function writeFloatLE($t, $e, $n = false) {
        return self::O_writeFloat($this->data, $t, $e, true, $n);
    }

    
    public function writeFloatBE($t, $e, $n = false) {
        return self::O_writeFloat($this->data, $t, $e, false, $n);
    }

    
    public function writeDoubleLE($t, $e, $n = false) {
        return self::L_writeDouble($this->data, $t, $e, true, $n);
    }

    
    public function writeDoubleBE($t, $e, $n = false) {
        return self::L_writeDouble($this->data, $t, $e, false, $n);
    }

    
    public function slice($t = 0, $e = null) {
        $n = $this->length; 
        $t = (int)$t;
        $e = $e === null ? $n : (int)$e;

        
        if ($t < 0) {
            $t += $n;
            if ($t < 0) $t = 0;
        } elseif ($t > $n) {
            $t = $n;
        }

        if ($e < 0) {
            $e += $n;
            if ($e < 0) $e = 0;
        } elseif ($e > $n) {
            $e = $n;
        }

        
        if ($e < $t) {
            $e = $t;
        }

        
        
        
        
        
        
        $a = substr($this->data, $t, $e - $t); 
        
        
        
        
        $slicedBuffer = new self($a);
        
        
        
        
        
        
        
        
        
        

        
        
        
        
        
        
        
        return new self($a);
    }

    
    public function copy($t, $e = 0, $n = 0, $a = null) {
        if (!self::isBuffer($t)) {
            throw new \TypeError("argument should be a Buffer");
        }

        
        if ($n === null) $n = 0;
        if ($a === null || $a === 0) $a = $this->length; 
        if ($e === null) $e = 0;

        
        $e = (int)$e;
        $n = (int)$n;
        $a = (int)$a;

        
        if ($e >= $t->length) $e = $t->length;
        if ($e < 0) throw new \RangeError("targetStart out of bounds");
        if ($n < 0 || $n >= $this->length) throw new \RangeError("Index out of range");
        if ($a < 0) throw new \RangeError("sourceEnd out of bounds");
        if ($a > $this->length) $a = $this->length;

        
        if ($a <= $n) return 0;
        if ($a === $n) return 0; 

        
        $r = $a - $n; 

        
        if ($t->length - $e < $r) {
            $r = $t->length - $e;
            $a = $n + $r; 
        }

        
        
        $copied_data = substr($this->data, $n, $a - $n);
        $t->data = substr_replace($t->data, $copied_data, $e, strlen($copied_data));

        return $r;
    }

    
    public function fill($t, $e = 0, $n = null, $a = 'utf8') {
        
        
        if (is_string($t)) {
            if (is_string($e)) { 
                 $a = $e;
                 $e = 0;
                 $n = $this->length;
            } elseif (is_numeric($e)) { 
                 $e = (int)$e;
                 if (is_numeric($n)) {
                     $n = (int)$n;
                     
                 } else { 
                     $a = $n;
                     $n = null; 
                 }
            } else { 
                 $a = 'utf8';
                 $e = 0;
                 $n = $this->length;
            }

            if ($a !== null && !is_string($a)) {
                 throw new \TypeError("encoding must be a string");
            }
            if (is_string($a) && !self::isEncoding($a)) {
                 throw new \TypeError("Unknown encoding: " . $a);
            }

            
            if (strlen($t) === 1) {
                 $r = ord($t); 
                 if (('utf8' === $a && $r < 128) || 'latin1' === $a) {
                     $t = $r; 
                 }
            }
        } elseif (is_numeric($t)) {
            $t = (int)$t & 255; 
        } elseif (is_bool($t)) {
            $t = (int)$t; 
        } else {
             
             if (!self::isBuffer($t)) {
                 throw new \TypeError('The value "' . (is_object($t) ? get_class($t) : gettype($t)) . '" is invalid for argument "value"');
             }
        }


        
        if ($e < 0 || $this->length < $e || ($n !== null && $this->length < $n)) {
            throw new \RangeError("Out of range index");
        }

        
        if ($n !== null && $n <= $e) {
            return $this;
        }

        
        $e = (int)$e;
        $n = $n === null ? $this->length : (int)$n;

        
        if ($t === null) { 
            $t = 0;
        }

        $i = null; 

        if (is_numeric($t)) {
            
            $fillByte = chr($t);
            $fillString = str_repeat($fillByte, $n - $e);
            $this->data = substr_replace($this->data, $fillString, $e, $n - $e);
        } else {
            
            $o = self::isBuffer($t) ? $t : self::from($t, $a); 
            $l = $o->length; 

            if (0 === $l) {
                throw new \TypeError('The value "' . (is_object($t) ? get_class($t) : gettype($t)) . '" is invalid for argument "value"');
            }

            
            $patternData = $o->data;
            $fillLength = $n - $e;
            $repeatedPattern = str_repeat($patternData, ceil($fillLength / $l));
            $fillString = substr($repeatedPattern, 0, $fillLength);

            $this->data = substr_replace($this->data, $fillString, $e, $fillLength);
        }

        return $this;
    }

    

    
    private static function u_string($t, $e) {
        if ("string" == typeof $e && "" !== $e || ($e = "utf8"), !self::isEncoding($e)) {
            throw new \TypeError("Unknown encoding: " . $e);
        }
        $n = self::h_byteLength($t, $e); 
        $a = self::l_alloc($n); 
        $r = $a->write($t, $e); 
        if ($r !== $n) {
            $a = $a->slice(0, $r);
        }
        return $a;
    }

    
    private static function f_array($t) {
        $e = count($t) < 0 ? 0 : (int)count($t); 
        $n = self::l_alloc($e); 
        for ($a = 0; $a < $e; $a += 1) {
            $n->data[$a] = chr($t[$a] & 255);
        }
        return $n;
    }

    
    private static function r_buffer($t) {
        $e = (int)$t->length; 
        $n = self::l_alloc($e); 
        if (0 === $n->length) {
            return $n;
        }
        $t->copy($n, 0, 0, $e);
        return $n;
    }

    
    

    
    private static function c_checkSize($t) {
        if (!is_numeric($t)) {
            throw new \TypeError('"size" argument must be of type number');
        }
        if ($t < 0) {
            throw new \RangeError('The value "' . $t . '" is invalid for option "size"');
        }
    }

    
    private static function d_alloc($t, $e = null, $n = null) {
        self::c_checkSize($t);
        $t = (int)$t;
        if ($t < 0) $t = 0; 
        $t = self::m_checkMaxLength($t); 

        $buffer = self::l_alloc($t); 

        if ($e !== null) { 
            if (is_string($n)) { 
                 $buffer->fill($e, 0, $t, $n);
            } else { 
                 $buffer->fill($e, 0, $t);
            }
        }

        return $buffer;
    }

    
    private static function m_checkMaxLength($t) {
        if ($t >= self::kMaxLength) {
            throw new \RangeError("Attempt to allocate Buffer larger than maximum size: 0x" . dechex(self::kMaxLength) . " bytes");
        }
        return (int)$t;
    }

    
    private static function l_alloc($t) {
        
        $data = str_repeat(chr(0), $t);
        return new self($data);
    }

    
    private static function h_byteLength($t, $e, $n) {
        if ($t instanceof self) {
            return $t->length;
        }
        
        
        
        if (is_array($t)) { 
             return count($t);
        }
        if (!is_string($t)) {
            throw new \TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer (array). Received type ' . gettype($t));
        }

        $a = strlen($t); 
        $r = $n; 

        if (!$r && 0 === $a) {
            return 0;
        }

        $i = false; 
        for (;;) {
            switch (strtolower($e)) {
                case "ascii":
                case "latin1":
                case "binary":
                    return $a;
                case "utf8":
                case "utf-8":
                    return strlen(utf8_decode($t)); 
                    
                    
                    
                    
                    return count(self::F_utf8ToBytes($t));
                case "ucs2":
                case "ucs-2":
                case "utf16le":
                case "utf-16le":
                    return 2 * $a; 
                case "hex":
                    return $a >>> 1; 
                case "base64":
                    return Base64::byteLength($t);
                default:
                    if ($i) {
                        return $r ? -1 : count(self::F_utf8ToBytes($t)); 
                    }
                    $e = strtolower($e);
                    $i = true;
            }
        }
    }

    
    private static function p_toString($t, $e, $n, $a) {
        $a = min(strlen($t), $a);
        if (($a >>>= 0) <= ($n >>>= 0)) {
            return "";
        }

        $r = false; 
        for (;;) {
            switch (strtolower($e)) {
                case "hex":
                    return self::C_toHex($t, $n, $a);
                case "utf8":
                case "utf-8":
                    return self::I_utf8Slice($t, $n, $a);
                case "ascii":
                    return self::R_asciiSlice($t, $n, $a);
                case "latin1":
                case "binary":
                    return self::N_latin1Slice($t, $n, $a);
                case "base64":
                    return self::S_base64Slice($t, $n, $a);
                case "ucs2":
                case "ucs-2":
                case "utf16le":
                case "utf-16le":
                    return self::D_utf16leSlice($t, $n, $a);
                default:
                    if ($r) {
                        throw new \TypeError("Unknown encoding: " . $e);
                    }
                    $e = strtolower($e);
                    $r = true;
            }
        }
    }

    
    private static function b_swap(&$t, $e, $n) {
        $a = $t[$e]; 
        $t[$e] = $t[$n];
        $t[$n] = $a;
    }

    
    private static function y_search($t, $e, $n, $a, $r) {
        $l = strlen($t); 

        
        if (is_string($n)) {
            $a = $n;
            $n = 0;
        } elseif ($n > 2147483647) {
            $n = 2147483647;
        } elseif ($n < -2147483648) {
            $n = -2147483648;
        }
        $n = (int)$n;

        if (self::q_isNaN($n)) {
            $n = $r ? 0 : $l - 1;
        }

        if ($n < 0) {
            $n = $l + $n;
        }

        if ($n >= $l) {
            if ($r) return -1;
            $n = $l - 1;
        } elseif ($n < 0) {
            if (!$r) return -1;
            $n = 0;
        }

        
        if (is_string($e)) {
            $e = self::from($e, $a);
        }

        if (self::isBuffer($e)) {
            if (0 === $e->length) {
                return -1;
            }
            return self::E_bufferSearch($t, $e->data, $n, $a, $r);
        }

        if (is_numeric($e)) {
            $e = (int)$e & 255; 
            
            
            
            return self::E_bufferSearch($t, chr($e), $n, $a, $r);
        }

        throw new \TypeError("val must be string, number or Buffer");
    }

    
    private static function E_bufferSearch($t, $e, $n, $a, $r) {
        $i = 1; 
        $o = strlen($t); 
        $l = strlen($e); 

        
        if ($a !== null && (strtolower($a) === "ucs2" || strtolower($a) === "ucs-2" || strtolower($a) === "utf16le" || strtolower($a) === "utf-16le")) {
            if (strlen($t) < 2 || strlen($e) < 2) {
                return -1;
            }
            $i = 2;
            $o /= 2;
            $l /= 2;
            $n /= 2;
        }

        
        $u = function($buffer_string, $index) use ($i) {
            if ($i === 1) {
                return ord($buffer_string[$index]);
            } else { 
                 
                 $unpacked = unpack('v', substr($buffer_string, $index * $i, $i));
                 return $unpacked[1];
            }
        };

        if ($r) { 
            $c = -1; 
            for ($d = $n; $d < $o; $d++) { 
                
                if ($u($t, $d) === $u($e, $c === -1 ? 0 : $d - $c)) {
                    if ($c === -1) {
                        $c = $d; 
                    }
                    
                    if ($d - $c + 1 === $l) {
                        return $c * $i; 
                    }
                } else {
                    
                    if ($c !== -1) {
                        $d -= ($d - $c); 
                    }
                    $c = -1; 
                }
            }
        } else { 
            if ($n + $l > $o) {
                $n = $o - $l; 
            }
            for ($d = $n; $d >= 0; $d--) { 
                $f = true; 
                for ($g = 0; $g < $l; $g++) { 
                    if ($u($t, $d + $g) !== $u($e, $g)) {
                        $f = false;
                        break;
                    }
                }
                if ($f) {
                    return $d * $i; 
                }
            }
        }

        return -1; 
    }

    
    private static function _writeHex(&$t, $e, $n, $a) {
        $n = (int)$n;
        $r = strlen($t) - $n; 
        $a = (int)$a;
        if ($a > $r) {
            $a = $r;
        }
        $i = strlen($e); 
        if ($a > $i / 2) {
            $a = (int)($i / 2);
        }

        for ($o = 0; $o < $a; ++$o) {
            $l = hexdec(substr($e, 2 * $o, 2)); 
            if (self::q_isNaN($l)) {
                return $o; 
            }
            $t[$n + $o] = chr($l);
        }
        return $o;
    }

    
    private static function A_writeUtf8(&$t, $e, $n, $a) {
        
        $bytes = self::F_utf8ToBytes($e, strlen($t) - $n); 
        
        return self::j_writeBytes($bytes, $t, $n, $a);
    }

    
    private static function T_writeLatin1(&$t, $e, $n, $a) {
        
        $bytes = [];
        for ($r = 0; $r < strlen($e); ++$r) {
            $bytes[] = ord($e[$r]);
        }
        
        return self::j_writeBytes($bytes, $t, $n, $a);
    }

    
    private static function v_writeBase64(&$t, $e, $n, $a) {
        
        $bytes = self::U_base64ToBytes($e);
        
        return self::j_writeBytes($bytes, $t, $n, $a);
    }

    
    private static function w_writeUtf16le(&$t, $e, $n, $a) {
        
        $bytes = self::function_utf16leToBytes($e, strlen($t) - $n); 
        
        return self::j_writeBytes($bytes, $t, $n, $a);
    }

    
    private static function S_base64Slice($t, $e, $n) {
        
        $slice = substr($t, $e, $n - $e);
        
        $byteArray = array_values(unpack('C*', $slice));
        
        return Base64::fromByteArray($byteArray);
    }

    
    private static function I_utf8Slice($t, $e, $n) {
        $n = min(strlen($t), $n);
        $a = []; 
        $r = $e; 

        for (; $r < $n;) {
            $i = ord($t[$r]); 
            $o = null; 
            $l = null; 
            $s = null; 
            $u = null; 

            
            $c = $i > 239 ? 4 : ($i > 223 ? 3 : ($i > 191 ? 2 : 1)); 

            if ($r + $c <= $n) {
                switch ($c) {
                    case 1:
                        if ($i < 128) {
                            $o = $i;
                        }
                        break;
                    case 2:
                        $l = ord($t[$r + 1]);
                        if (($l & 192) === 128) {
                            $s = (($i & 31) << 6) | ($l & 63); 
                            if ($s > 127) {
                                $o = $s;
                            }
                        }
                        break;
                    case 3:
                        $l = ord($t[$r + 1]);
                        $s = ord($t[$r + 2]);
                        if (($l & 192) === 128 && ($s & 192) === 128) {
                            $u = (($i & 15) << 12) | (($l & 63) << 6) | ($s & 63); 
                            if ($u > 2047 && ($u < 55296 || $u > 57343)) { 
                                $o = $u;
                            }
                        }
                        break;
                    case 4:
                        $l = ord($t[$r + 1]);
                        $s = ord($t[$r + 2]);
                        $u = ord($t[$r + 3]);
                        if (($l & 192) === 128 && ($s & 192) === 128 && ($u & 192) === 128) {
                            $d = (($i & 7) << 18) | (($l & 63) << 12) | (($s & 63) << 6) | ($u & 63); 
                            if ($d > 65535 && $d < 1114112) { 
                                $o = $d;
                            }
                        }
                        break;
                }
            }

            if ($o === null) {
                $o = 65533; 
                $c = 1; 
            } elseif ($o > 65535) { 
                $o -= 65536;
                $a[] = (($o >>> 10) & 1023) | 55296; 
                $o = 56320 | ($o & 1023); 
            }

            $a[] = $o; 
            $r += $c; 
        }

        
        return self::function_codePointsToString($a);
    }

    
    private static $k_stringChunkSize = 4096;

    
    private static function function_codePointsToString($t) {
        $e = count($t); 
        if ($e <= self::$k_stringChunkSize) {
            
            
            
            
            
            if (function_exists('mb_chr')) {
                 $result = '';
                 foreach ($t as $codePoint) {
                     $result .= mb_chr($codePoint, 'UTF-8'); 
                 }
                 return $result;
            } else {
                 
                 $result = '';
                 foreach ($t as $codePoint) {
                     if ($codePoint >= 0xD800 && $codePoint <= 0xDBFF) { 
                         
                         $result .= '?'; 
                     } elseif ($codePoint >= 0xDC00 && $codePoint <= 0xDFFF) { 
                         
                         $result .= '?'; 
                     } elseif ($codePoint <= 0xFFFF) {
                         $result .= chr($codePoint); 
                     } else {
                         
                         
                         $result .= '?'; 
                     }
                 }
                 return $result;
            }
        }

        
        $n = ""; 
        $a = 0; 
        while ($a < $e) {
            
            $chunk = array_slice($t, $a, self::$k_stringChunkSize);
            if (function_exists('mb_chr')) {
                 foreach ($chunk as $codePoint) {
                     $n .= mb_chr($codePoint, 'UTF-8');
                 }
            } else {
                 foreach ($chunk as $codePoint) {
                     if ($codePoint >= 0xD800 && $codePoint <= 0xDBFF) { $n .= '?'; }
                     elseif ($codePoint >= 0xDC00 && $codePoint <= 0xDFFF) { $n .= '?'; }
                     elseif ($codePoint <= 0xFFFF) { $n .= chr($codePoint); }
                     else { $n .= '?'; }
                 }
            }
            $a += self::$k_stringChunkSize;
        }
        return $n;
    }


    
    private static function R_asciiSlice($t, $e, $n) {
        $a = ""; 
        $n = min(strlen($t), $n);
        for ($r = $e; $r < $n; ++$r) {
            $a .= chr(ord($t[$r]) & 127); 
        }
        return $a;
    }

    
    private static function N_latin1Slice($t, $e, $n) {
        $a = ""; 
        $n = min(strlen($t), $n);
        for ($r = $e; $r < $n; ++$r) {
            $a .= $t[$r]; 
        }
        return $a;
    }

    
    private static function C_toHex($t, $e, $n) {
        
        static $G_hexLookup = null;
        if ($G_hexLookup === null) {
            $G_hexLookup = [];
            $hexChars = "0123456789abcdef";
            for ($byte = 0; $byte < 256; ++$byte) {
                $G_hexLookup[$byte] = $hexChars[($byte >> 4) & 0x0F] . $hexChars[$byte & 0x0F];
            }
        }

        $a = strlen($t); 
        
        if ($e === null || $e < 0) $e = 0;
        if ($n === null || $n < 0 || $n > $a) $n = $a;

        $r = ""; 
        for ($i = $e; $i < $n; ++$i) {
            $r .= $G_hexLookup[ord($t[$i])];
        }
        return $r;
    }

    
    private static function D_utf16leSlice($t, $e, $n) {
        
        $a = substr($t, $e, $n - $e); 
        $r = ""; 
        
        for ($i = 0; $i < strlen($a) - 1; $i += 2) {
            
            $unpacked = unpack('v', substr($a, $i, 2));
            $r .= chr($unpacked[1]); 
            
            
            
            if (function_exists('mb_convert_encoding')) {
                 return mb_convert_encoding($a, 'UTF-8', 'UTF-16LE');
            } else {
                 
                 $result = '';
                 for ($i = 0; $i < strlen($a) - 1; $i += 2) {
                     $codePoint = ord($a[$i]) | (ord($a[$i+1]) << 8);
                     $result .= chr($codePoint); 
                     
                     
                     
                     
                     
                     
                     
                     $r .= chr(ord($a[$i]) + 256 * ord($a[$i+1])); 
                     
                     $codePoint = ord($a[$i]) | (ord($a[$i+1]) << 8);
                     
                     
                     if (function_exists('mb_chr')) {
                         $r .= mb_chr($codePoint, 'UTF-8');
                     } else {
                         
                         if ($codePoint <= 0xFFFF) {
                             $r .= chr($codePoint); 
                         } else {
                             $r .= '?'; 
                         }
                     }
                 }
                 return $r;
            }
        }
    }

    
    private static function x_checkOffset($t, $e, $n) {
        if (!is_int($t) || $t < 0) {
            throw new \RangeError("offset is not uint");
        }
        if ($t + $e > $n) {
            throw new \RangeError("Trying to access beyond buffer length");
        }
    }

    
    private static function M_checkIntBounds($t, $e, $n, $a, $r, $i) {
        if (!self::isBuffer($t)) {
            throw new \TypeError('"buffer" argument must be a Buffer instance');
        }
        if ($e > $r || $e < $i) {
            throw new \RangeError('"value" argument is out of bounds');
        }
        if ($n + $a > $t->length) {
            throw new \RangeError("Index out of range");
        }
    }

    
    private static function z_checkBounds($t, $e, $n, $a) {
        if ($n + $a > $t->length) {
            throw new \RangeError("Index out of range");
        }
        if ($n < 0) {
            throw new \RangeError("Index out of range");
        }
    }

    
    private static function O_writeFloat(&$t, $e, $n, $a, $i) {
        $e = (float)$e;
        $n = (int)$n;
        if (!$i) {
            self::z_checkBounds(new self($t), 0, $n, 4); 
        }
        
        $packed = pack($a ? 'P' : 'g', $e); 
        $t = substr_replace($t, $packed, $n, 4);
        return $n + 4;
    }

    
    private static function L_writeDouble(&$t, $e, $n, $a, $i) {
        $e = (float)$e;
        $n = (int)$n;
        if (!$i) {
            self::z_checkBounds(new self($t), 0, $n, 8); 
        }
        
        $packed = pack($a ? 'e' : 'E', $e); 
        $t = substr_replace($t, $packed, $n, 8);
        return $n + 8;
    }

    
    private static $P_base64InvalidChars = '/[^+/0-9A-Za-z-_]/g';

    
    private static function F_utf8ToBytes($t, $e = INF) {
        $n = strlen($t); 
        $a = null; 
        $r = []; 
        $i = 0; 

        for (; $i < $n; ++$i) {
            $o = ord($t[$i]); 

            
            if ($o > 55295 && $o < 57344) { 
                if ($a === null) { 
                    if ($o > 56319) { 
                        if (($e -= 3) > -1) $r = array_merge($r, [239, 191, 189]); 
                        continue;
                    }
                    if ($i + 1 === $n) { 
                        if (($e -= 3) > -1) $r = array_merge($r, [239, 191, 189]); 
                        continue;
                    }
                    $a = $o; 
                    continue;
                }
                
                if ($o < 56320) { 
                    if (($e -= 3) > -1) $r = array_merge($r, [239, 191, 189]); 
                    $a = $o; 
                    continue;
                }
                
                $o = 65536 + (($a - 55296) << 10) | ($o - 56320); 
            } elseif ($a !== null) { 
                if (($e -= 3) > -1) $r = array_merge($r, [239, 191, 189]); 
            }

            $a = null; 

            
            if ($o < 128) {
                if (($e -= 1) < 0) break;
                $r[] = $o;
            } elseif ($o < 2048) {
                if (($e -= 2) < 0) break;
                $r[] = ($o >> 6) | 192;
                $r[] = ($o & 63) | 128;
            } elseif ($o < 65536) {
                if (($e -= 3) < 0) break;
                $r[] = ($o >> 12) | 224;
                $r[] = (($o >> 6) & 63) | 128;
                $r[] = ($o & 63) | 128;
            } else {
                if (!($o < 1114112)) { 
                    throw new \Error("Invalid code point");
                }
                if (($e -= 4) < 0) break;
                $r[] = ($o >> 18) | 240;
                $r[] = (($o >> 12) & 63) | 128;
                $r[] = (($o >> 6) & 63) | 128;
                $r[] = ($o & 63) | 128;
            }
        }
        return $r;
    }

    
    private static function function_utf16leToBytes($t, $e = INF) {
        $n = strlen($t); 
        $a = []; 
        $r = 0; 

        for (; $r < $n && !($e < 2); ++$r) {
            $i = ord($t[$r]); 
            $o = null; 
            $l = null; 

            
            $o = ($i >> 8) & 255; 
            $l = $i & 255; 

            $a[] = $l; 
            $a[] = $o; 

            $e -= 2; 
        }
        return $a;
    }


    
    private static function U_base64ToBytes($t) {
        
        $t = preg_replace(self::$P_base64InvalidChars, '', $t);
        $t = rtrim($t, '='); 
        while (strlen($t) % 4 !== 0) {
            $t .= "="; 
        }
        
        return Base64::toByteArray($t);
    }

    
    private static function j_writeBytes($t, &$e, $n, $a) {
        $r = 0; 
        $t_len = count($t);
        $e_len = strlen($e);

        for (; $r < $a && !($r + $n >= $e_len || $r >= $t_len); ++$r) {
            $e[$r + $n] = chr($t[$r]);
        }
        return $r;
    }

    
    private static function B_instanceOf($t, $e) {
        
        
        return $t instanceof $e;
    }

    
    private static function q_isNaN($t) {
        return is_nan($t);
    }
}


class MP4BoxParser {
    

    
    

    
    private static $_boxProcessors = [];

    
    public static function parseBuffer(Buffer $t) {
        
        $file = new MP4File($t);
        return $file->parse();
    }

    
    public static function addBoxProcessor($t, $e) {
        if (is_string($t) && is_callable($e)) {
            self::$_boxProcessors[$t] = $e;
        }
    }

    
    public static function createFile() {
        return new MP4File();
    }

    
    public static function createBox($t, $e = null, $n = -1) {
        $a = Box::create($t); 
        if ($e !== null) {
            self::Utils()->appendBox($e, $a, $n);
        }
        return $a;
    }

    
    public static function createFullBox($t, $e = null, $a = -1) {
        $r = self::createBox($t, $e, $a); 
        $r->version = 0;
        $r->flags = 0;
        return $r;
    }

    
    public static function Utils() {
        
        return MP4BoxParser_Utils::getInstance();
    }

    

    
    public static class Cursor {
        public $offset;

        
        public function __construct($t = 0) {
            $this->offset = $t;
        }
    }

    
    public static class MP4File {
        public $_cursor;
        public $boxes = [];
        public $_raw; 
        public $_root = null; 
        public $_parent = null; 

        
        public function __construct(Buffer $t = null) {
            $this->_cursor = new MP4BoxParser_Cursor();
            if ($t !== null) {
                $this->_raw = $t; 
            }
        }

        
        public function fetch($t) {
            $e = $this->fetchAll($t, true); 
            return count($e) ? $e[0] : null;
        }

        
        public function fetchAll($t, $e = false) {
            $n = []; 
            self::_sweep($this, $t, $n, $e);
            return $n;
        }

        
        public function parse() {
            $this->_cursor->offset = 0;
            $this->boxes = [];
            
            while ($this->_cursor->offset < $this->_raw->length) {
                $t = Box::parse($this); 
                if ($t === null || !isset($t->type)) { 
                    break;
                }
                $this->boxes[] = $t;
            }
            return $this;
        }

        
        private static function _sweep($t, $e, &$n, $a) {
            
            if (isset($t->type) && $t->type == $e) {
                $n[] = $t;
                if ($a) {
                    return; 
                }
            }

            
            if (isset($t->boxes)) {
                foreach ($t->boxes as $r) { 
                    self::_sweep($r, $e, $n, $a);
                    if ($a && count($n) > 0) {
                        return; 
                    }
                }
            }
        }
    }

    
    public static class Box {
        public $size;
        public $type;
        public $boxes = []; 
        public $version = null; 
        public $flags = null; 
        public $_offset; 
        public $_root; 
        public $_raw; 
        public $_parent; 

        
        private static $_boxProcessors = []; 

        
        private function __construct($type) {
            $this->type = $type;
        }

        
        public static function create($t) {
            
            if (isset(self::$_boxProcessors[$t]) && method_exists(self::$_boxProcessors[$t], 'create')) {
                 
                 
                 
                 
            }
            return new self($t);
        }

        
        public static function parse($t) {
            $e = $t->_raw; 
            $n = $t->_cursor; 
            $a = $n->offset; 

            
            if ($a + 8 > $e->length) {
                
                return null;
            }

            
            $r = $e->readUint32BE($a); 
            
            $i = $e->toString('ascii', $a + 4, $a + 8); 

            
            if ($r === 1) {
                
                if ($a + 16 > $e->length) {
                    return null; 
                }
                
                
                
                
                
                
                
                
                 
                 
                 return null; 
            }

            
            if ($r === 0) {
                $r = $e->length - $a; 
            }

            
            if ($a + $r > $e->length) {
                
                return null;
            }

            
            $o = new self($i); 
            $o->size = $r;
            $o->_offset = $a;
            $o->_raw = $e;
            $o->_root = $t->_root ? $t->_root : $t; 
            $o->_parent = $t; 

            
            $n->offset += 8;

            
            
            
            
            
            
            
            if ($a + 8 + 4 <= $a + $r) { 
                 
                 $o->version = $e->readUint8($n->offset);
                 $n->offset += 1;
                 
                 $o->flags = $e->readUintBE($n->offset, 3); 
                 $n->offset += 3;
            }


            
            
            if (isset(self::$_boxProcessors[$o->type])) {
                $processor = self::$_boxProcessors[$o->type];
                
                
                
                $processor($o);
            } else {
                
                
                
                
                
                
                
                
                
                $data_size = $o->size - ($n->offset - $a);
                if ($data_size > 0) {
                     
                     $n->offset += $data_size;
                }
            }

            return $o;
        }
    }

    
    public static class MP4BoxParser_Utils {
        private static $instance = null;

        private function __construct() {} 

        public static function getInstance() {
            if (self::$instance === null) {
                self::$instance = new self();
            }
            return self::$instance;
        }

        
        public function dataViewToString(Buffer $t, $e = 'utf-8') {
            $n = $e; 

            
            
            return $t->toString($n);
        }

        
        public function utf8ToByteArray($t) {
            
            
            return Buffer::F_utf8ToBytes($t);
        }

        
        public function appendBox($t, $e, $n) {
            
            $e->_offset = $t->_cursor->offset; 
            $e->_root = $t->_root ? $t->_root : $t; 
            $e->_raw = $t->_raw; 
            $e->_parent = $t; 

            if ($n !== -1) {
                $a = null; 
                $r = -1; 

                if (is_numeric($n)) {
                    $r = $n;
                } else {
                    if (is_string($n)) {
                        $a = $n;
                    } else {
                        
                        
                        if (!is_object($n) || !isset($n->type)) {
                            
                            return;
                        }
                        $a = $n->type;
                    }

                    
                    for ($i = 0; $i < count($t->boxes); $i++) {
                        if ($a === $t->boxes[$i]->type) {
                            $r = $i + 1; 
                            break;
                        }
                    }
                }
                
                array_splice($t->boxes, $r, 0, [$e]);
            } else {
                
                $t->boxes[] = $e;
            }
        }
    }
}











?>

