<?php
namespace Claromentis\Core\Ai\Parts;

$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"] ?: array()) + array("_01f117db67aa749d3ec8da" . "7eb478730c" => base64_decode("L" . "C" . "A" . "="), "_5159b3572969eca46acd1b2e141845" . "9c" => base64_decode("aW1wb" . "G9kZQ" . "=="), "_bd71c3b5c201fc11db82ed14ce" . "424de5" => base64_decode("aW5" . "fYX" . "JyY" . "Xk="), "_653be373" . "90c48a200" . "701e4322c" . "116779" => base64_decode("c3RyX3N0YXJ0c193a" . "XRo"), "_811cca7a13b" . "3032607a4cbe" . "c695e902d" => base64_decode("SW52YWxpZCBNSU1FIH" . "R5cGUgIg=="), "_75b243bff4b406" . "7f5adeaf3dfa11c" . "126" => base64_decode("aW1hZ2" . "Uv"), "_cc3d6d1784d664e35a1a" . "82275c45b630" => base64_decode("IiBwcm92aWRlZCBmb3IgaW1hZ2UgcGFydC4gQWNjZXB0ZWQg" . "TUlNRSB0eXBlcyBhcmU6IA=="));
use Claromentis\Core\Ai\Exceptions\InvalidImageException;
use InvalidArgumentException;






abstract class AbstractFilePart implements PartInterface
{
    
    
    
    
    protected const MIME_TYPES = ['png' => 'image/png', 'jpg' => 'image/jpeg', 'webp' => 'image/webp', 'pdf' => 'application/pdf', 'html' => 'text/html'];
    
    
    
    
    protected string $data;
    
    
    
    
    
    
    
    protected string $role;
    
    
    
    
    
    
    protected string $mimeType;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public function __construct(string $data, string $_e15567441c24cf597f085689c722c660 = self::MIME_TYPES['png'], string $_d1071a032215f0eb5c4a8ef175f7049d = PartInterface::PART_ROLE_USER)
    {
        if (!$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_bd71c3b" . "5c201fc1" . "1db82ed1" . "4ce424de" . "5"]($_e15567441c24cf597f085689c722c660, $this->getValidMimeTypes())) {
            throw new InvalidArgumentException($GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_811cca7a13b3032607a4cb" . "ec695e902d"] . $_e15567441c24cf597f085689c722c660 . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_cc3d6d1784d664e35a1a82275c4" . "5b630"] . $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_5159b3572969eca46a" . "cd1b2e1418459c"]($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_01f117db67aa749d3ec8da7e" . "b478730c"], self::MIME_TYPES));
        }
        $this->mimeType = $_e15567441c24cf597f085689c722c660;
        $this->data = $data;
        $this->role = $_d1071a032215f0eb5c4a8ef175f7049d;
        if ($this->isImage()) {
            $this->validateImage();
        }
    }
    
    
    
    
    
    
    public function getMimeType() : string
    {
        return $this->mimeType;
    }
    
    
    
    
    
    
    public function getValue() : string
    {
        return $this->data;
    }
    public function getRole() : string
    {
        return $this->role;
    }
    
    
    
    
    
    
    
    
    
    
    public function isImage()
    {
        return $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_653be37390c48a200701e4322c" . "116779"]($this->mimeType, $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_75b243b" . "ff4b4067" . "f5adeaf3" . "dfa11c12" . "6"]);
    }
    
    
    
    
    
    
    
    
    
    private function getValidMimeTypes() : array
    {
        return self::MIME_TYPES;
    }
    
    
    
    
    
    
    protected abstract function validateImage();
}