<?php
namespace Claromentis\Core\Ai\Adapters\Vertex\Responses\Image;

$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] ?: array()) + array("_e15567441c24cf59" . "7f085689c722c660" => base64_decode("bWltZVR" . "5cGU="), "_c36d11ec" . "61d549064" . "ca5997745" . "729b1c" => base64_decode("cHJlZGljdGlvbnM" . "="), "_72849b9" . "1eda4dfd" . "944fd806" . "7caf54eb" . "2" => base64_decode("Tm8gaW1hZ2VzIHJlY2VpdmVkI" . "GZyb20gQUkgc2VydmljZQ=="), "_9338add0" . "6febdd668" . "e80234d1c" . "857b0c" => base64_decode("SW52YWxpZCBpbWFnZSByZWNlaXZlZCBmcm9tIEFJIHNlcnZpY2" . "U="), "_8b39dd03274720b4ed9a06cd9" . "30f29cc" => base64_decode("Ynl0ZXNCY" . "XNlNjRFbm" . "NvZGVk"), "_f3cd33ffc40bfb37" . "206b0dcff170cc96" => base64_decode("RXJyb3IgaGFuZGxpbmcgaW1hZ2UgZ2VuZXJhdGlvbiByZXNwb25zZT" . "og"));
use Claromentis\Core\Ai\Adapters\Vertex\Requests\Image\VertexAiImageGenerationConfig;
use Claromentis\Core\Ai\AiResponseInterface;
use Claromentis\Core\Ai\Exceptions\AiInvalidResponseException;
use Claromentis\Core\Ai\Parts\InlineFilePart;
use Claromentis\Core\Ai\Parts\PartInterface;
use Webmozart\Assert\Assert;






class VertexAiGenerateImageResponse implements AiResponseInterface
{
    
    
    
    
    
    
    private array $parts;
    
    
    
    
    public function __construct(array $_9961f986823b4be7f5c4cc8379c6b228)
    {
        Assert::allIsInstanceOf($_9961f986823b4be7f5c4cc8379c6b228, InlineFilePart::class);
        foreach ($_9961f986823b4be7f5c4cc8379c6b228 as $_d962cfd1735adb2dfba46f69c7f15cb8) {
            if (!$_d962cfd1735adb2dfba46f69c7f15cb8->isImage()) {
                throw new AiInvalidResponseException($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_9338add06febdd668e80234d1c" . "857b0c"]);
            }
        }
        $this->parts = $_9961f986823b4be7f5c4cc8379c6b228;
    }
    
    
    
    
    
    
    
    
    
    public static function fromArray(array $_fd62bc4eaaf7d58dea9bada3e30443b9) : self
    {
        
        
        
        if (empty($_fd62bc4eaaf7d58dea9bada3e30443b9) || empty($_fd62bc4eaaf7d58dea9bada3e30443b9[$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_c36d11ec61d549064ca5997745" . "729b1c"]])) {
            throw new AiInvalidResponseException($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_72849b91eda4dfd944fd8067c" . "af54eb2"]);
        }
        $_9961f986823b4be7f5c4cc8379c6b228 = [];
        foreach ($_fd62bc4eaaf7d58dea9bada3e30443b9[$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_c36d11ec61d549064ca" . "5997745729b1c"]] as $_c60329b6b53016ba8929aff2f19abcc6) {
            if (empty($_c60329b6b53016ba8929aff2f19abcc6[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_8b39dd03274720b4ed9a06" . "cd930f29cc"]])) {
                
                
                continue;
            }
            try {
                $_31958d0b40348d4ca7900c41684e4adc = new InlineFilePart($_c60329b6b53016ba8929aff2f19abcc6[$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_8b39dd03274720b4ed9" . "a06cd930f29cc"]], $_c60329b6b53016ba8929aff2f19abcc6[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_e15567441c24cf597f085689c722" . "c660"]] ?? VertexAiImageGenerationConfig::DEFAULT_MIME_TYPE, PartInterface::PART_ROLE_MODEL);
            } catch (\Throwable $_3a16c5fe1a78b54b69e204ec07dcf670) {
                throw new AiInvalidResponseException($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_f3cd33ffc" . "40bfb37206" . "b0dcff170c" . "c96"] . $_3a16c5fe1a78b54b69e204ec07dcf670->getMessage(), $_3a16c5fe1a78b54b69e204ec07dcf670->getCode(), $_3a16c5fe1a78b54b69e204ec07dcf670);
            }
            $_9961f986823b4be7f5c4cc8379c6b228[] = $_31958d0b40348d4ca7900c41684e4adc;
        }
        return new self($_9961f986823b4be7f5c4cc8379c6b228);
    }
    public function hasTerminated() : bool
    {
        return false;
    }
    
    
    
    
    
    
    public function getParts() : array
    {
        return $this->parts;
    }
    
    
    
    
    
    
    public function getResponse() : array
    {
        return $this->parts;
    }
}