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

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"] ?: array()) + array("_a7442cd" . "7a4d3c55" . "7bf6b6b4" . "b0d72455" . "9" => base64_decode("cHJvb" . "XB0"), "_ab94c6905d095dfa521d004d9" . "e379b9e" => base64_decode("aW5" . "zdG" . "FuY" . "2Vz"), "_1403528d44504acbeae423595d0a" . "3297" => base64_decode("cGFyYW1ldGVycw" . "=="), "_27d36ba68a85217963497" . "e66d46a8f86" => base64_decode("Z2V0d" . "HlwZQ" . "=="));
use BadMethodCallException;
use Claromentis\Core\Ai\Adapters\Vertex\Helpers\VertexAiModels;
use Claromentis\Core\Ai\AiRequestInterface;
use Claromentis\Core\Ai\Exceptions\VertexAiPromptException;
use Claromentis\Core\Ai\Parts\PartInterface;
use Claromentis\Core\Ai\Parts\TextPart;
use Webmozart\Assert\Assert;




class VertexAiImageRequest implements AiRequestInterface
{
    
    
    
    
    
    
    private array $parts;
    
    
    
    
    private string $modelName;
    
    
    
    
    
    
    private VertexAiImageGenerationConfig $generationConfig;
    
    
    
    
    
    
    public function __construct(array $_9961f986823b4be7f5c4cc8379c6b228, string $_accd9508aab49e8a94236732a64663dc, VertexAiImageGenerationConfig $_0781363cd4daa531106ac6b67b811829 = null)
    {
        Assert::allIsInstanceOf($_9961f986823b4be7f5c4cc8379c6b228, PartInterface::class);
        $this->parts = $_9961f986823b4be7f5c4cc8379c6b228;
        $this->modelName = $_accd9508aab49e8a94236732a64663dc;
        $this->generationConfig = $_0781363cd4daa531106ac6b67b811829 ?? new VertexAiImageGenerationConfig();
        $this->validate();
    }
    public function isStreaming() : bool
    {
        return false;
    }
    public function getModelName() : string
    {
        return $this->modelName;
    }
    public function serialize() : array
    {
        $_9961f986823b4be7f5c4cc8379c6b228 = $this->parts;
        $data = [];
        switch ($this->modelName) {
            case VertexAiModels::MODEL_IMAGE_GENERATION_006:
            case VertexAiModels::MODEL_IMAGE_GENERATION_005:
            case VertexAiModels::MODEL_IMAGE_GENERATION_002:
            case VertexAiModels::MODEL_IMAGE_GENERATION_V3_GENERATE_002:
                $_ab94c6905d095dfa521d004d9e379b9e = [];
                foreach ($_9961f986823b4be7f5c4cc8379c6b228 as $_d962cfd1735adb2dfba46f69c7f15cb8) {
                    if (!$_d962cfd1735adb2dfba46f69c7f15cb8 instanceof TextPart) {
                        continue;
                    }
                    $_ab94c6905d095dfa521d004d9e379b9e[] = [$GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_a7442cd7a4d3c557bf6b6b4b0d72455" . "9"] => $_d962cfd1735adb2dfba46f69c7f15cb8->getValue()];
                }
                $data = [$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_ab94c6905d09" . "5dfa521d004d9" . "e379b9e"] => $_ab94c6905d095dfa521d004d9e379b9e];
                break;
        }
        $data[$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_1403528d44504acbea" . "e423595d0a3297"]] = $this->generationConfig->serialize();
        return $data;
    }
    
    
    
    
    
    
    public function unserialize($data)
    {
        throw new BadMethodCallException();
    }
    
    
    
    
    
    
    
    
    private function validate()
    {
        $_17728688d370dbb69c53d9e641c4b0e0 = [];
        foreach ($this->parts as $_d962cfd1735adb2dfba46f69c7f15cb8) {
            $type = $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_27d36ba68a8" . "5217963497e6" . "6d46a8f86"]($_d962cfd1735adb2dfba46f69c7f15cb8);
            if (isset($_17728688d370dbb69c53d9e641c4b0e0[$type])) {
                throw VertexAiPromptException::duplicatePartsDetected();
            }
            $_17728688d370dbb69c53d9e641c4b0e0[$type] = true;
        }
    }
}