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

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_5e30c4717ced36cff9" . "e93e19a5c576cc" => base64_decode("aXNf" . "c3Ry" . "aW5n"), "_63320be" . "23a35daa" . "beeb7422" . "b56f6b89" . "4" => base64_decode("YXVkaXRJbWFnZVBy" . "b21wdA=="), "_4d707fab93bebb00bbe69e81596" . "97c90" => base64_decode(""), "_7f628626dd1d55c71b1fc0932ff" . "d1d2c" => base64_decode("aXNfYXJyYXk" . "="), "_58f9cd2" . "f97dbf4d" . "2db74ab0" . "2504a90b" . "9" => base64_decode("YXJyYXlfcmV2ZXJzZQ=" . "="), "_4b878be3b98" . "4a2ace7d2dc2" . "2b5f59289" => base64_decode("YXVkaXRUZ" . "Xh0UHJvbX" . "B0"), "_79d426f9e30060d8279a1da0a9c6b" . "af1" => base64_decode("UHJvb" . "XB0Oi" . "Ai"), "_9247c134" . "2b3931513" . "e7d846ad4" . "639bb4" => base64_decode("YXVkaXRDaGF0UH" . "JvbXB0"), "_e92ad742fc12ec1dd5c30557fafca" . "331" => base64_decode("Ig=" . "="));
use Claromentis\Core\Ai\AiServiceProvider;
use Claromentis\Core\Ai\Events\AiEvent;
use Claromentis\Core\Ai\Events\AiEventType;
use Claromentis\Core\Ai\Parts\PartInterface;
use Claromentis\Core\Ai\Parts\TextPart;
use Claromentis\Core\Audit\Audit;
use Claromentis\Core\Security\SecurityContext;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AuditSubscriber implements EventSubscriberInterface
{
    
    
    
    
    protected Audit $audit;
    
    
    
    
    
    
    public function __construct(Audit $audit)
    {
        $this->audit = $audit;
    }
    
    
    
    
    
    
    
    
    public static function getSubscribedEvents() : array
    {
        return [AiEventType::TEXT_PROMPT => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_4b878be3b984a2ace7d2dc22b5f59" . "289"], AiEventType::CHAT_PROMPT => $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_9247c134" . "2b3931513" . "e7d846ad4" . "639bb4"], AiEventType::IMAGE_PROMPT => $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_63320be23a35daabeeb7422b56" . "f6b894"]];
    }
    
    
    
    
    
    
    
    public function auditTextPrompt(AiEvent $event) : void
    {
        $this->handlePromptAudit($event, AiEventType::TEXT_PROMPT);
    }
    
    
    
    
    
    
    
    public function auditChatPrompt(AiEvent $event) : void
    {
        $this->handlePromptAudit($event, AiEventType::CHAT_PROMPT);
    }
    
    
    
    
    
    
    
    public function auditImagePrompt(AiEvent $event) : void
    {
        $this->handlePromptAudit($event, AiEventType::IMAGE_PROMPT);
    }
    
    
    
    
    
    
    
    
    private function handlePromptAudit(AiEvent $event, string $_18c3ae9a896c5ec6d2e49d0d9d3852f2) : void
    {
        $_9961f986823b4be7f5c4cc8379c6b228 = $event->getParts();
        $text = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_4d707fab93bebb" . "00bbe69e8159697" . "c90"];
        if ($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_7f628626dd1d55c71" . "b1fc0932ffd1d2c"]($_9961f986823b4be7f5c4cc8379c6b228)) {
            $_9961f986823b4be7f5c4cc8379c6b228 = $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_58f9cd2f97d" . "bf4d2db74ab0" . "2504a90b9"]($_9961f986823b4be7f5c4cc8379c6b228);
            foreach ($_9961f986823b4be7f5c4cc8379c6b228 as $_d962cfd1735adb2dfba46f69c7f15cb8) {
                
                
                if ($_d962cfd1735adb2dfba46f69c7f15cb8 instanceof TextPart && $_d962cfd1735adb2dfba46f69c7f15cb8->getRole() === PartInterface::PART_ROLE_USER) {
                    $text = $_d962cfd1735adb2dfba46f69c7f15cb8->getValue();
                    break;
                }
            }
        } else {
            if ($_9961f986823b4be7f5c4cc8379c6b228 instanceof TextPart) {
                $text = $_9961f986823b4be7f5c4cc8379c6b228->getValue();
            } else {
                if ($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_5e30c4717ced36cff" . "9e93e19a5c576cc"]($_9961f986823b4be7f5c4cc8379c6b228)) {
                    $text = $_9961f986823b4be7f5c4cc8379c6b228;
                }
            }
        }
        
        
        if (empty($text)) {
            return;
        }
        $this->audit->Success(AiServiceProvider::NAME, $_18c3ae9a896c5ec6d2e49d0d9d3852f2, 0, $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_79d426f9e30060d8279a1" . "da0a9c6baf1"] . $text . $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_e92ad742fc12e" . "c1dd5c30557faf" . "ca331"]);
    }
}