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

$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] ?: array()) + array("_63320be23a3" . "5daabeeb7422" . "b56f6b894" => base64_decode("YXVkaXRJbWFnZVB" . "yb21wdA=="), "_79d426f9e30060d" . "8279a1da0a9c6baf" . "1" => base64_decode("UHJvbX" . "B0OiAi"), "_58f9cd2f9" . "7dbf4d2db7" . "4ab02504a9" . "0b9" => base64_decode("YXJyYXlf" . "cmV2ZXJz" . "ZQ=="), "_5e30c4717ced36cff9e93e19a5c" . "576cc" => base64_decode("aXNfc3" . "RyaW5n"), "_4b878be3b984a2ace7d2dc22b5f59" . "289" => base64_decode("YXVkaXRUZXh0UHJvbXB" . "0"), "_7f628626dd1d55c" . "71b1fc0932ffd1d2" . "c" => base64_decode("aXNfYXJ" . "yYXk="), "_e92ad742fc12ec1" . "dd5c30557fafca33" . "1" => base64_decode("I" . "g" . "=" . "="), "_9247c1342b3" . "931513e7d846" . "ad4639bb4" => base64_decode("YXVkaXRDaGF0UHJvbX" . "B0"), "_4d707fab93bebb00bbe69e81" . "59697c90" => base64_decode(""));
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["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_4b878be3b984a2ace7d2dc22b5f592" . "89"], AiEventType::CHAT_PROMPT => $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_9247c1342b" . "3931513e7d8" . "46ad4639bb4"], AiEventType::IMAGE_PROMPT => $GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_63320be23a3" . "5daabeeb7422" . "b56f6b894"]];
    }
    
    
    
    
    
    
    
    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->getPrompt();
        $text = $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_4d707fa" . "b93bebb0" . "0bbe69e8" . "159697c9" . "0"];
        if ($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_7f628626d" . "d1d55c71b1" . "fc0932ffd1" . "d2c"]($_9961f986823b4be7f5c4cc8379c6b228)) {
            $_9961f986823b4be7f5c4cc8379c6b228 = $GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["_58f9cd2f97dbf4d2db" . "74ab02504a90b9"]($_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["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_5e30c4717ced" . "36cff9e93e19a" . "5c576cc"]($_9961f986823b4be7f5c4cc8379c6b228)) {
                    $text = $_9961f986823b4be7f5c4cc8379c6b228;
                }
            }
        }
        
        
        if (empty($text)) {
            return;
        }
        $this->audit->Success(AiServiceProvider::NAME, $_18c3ae9a896c5ec6d2e49d0d9d3852f2, 0, $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_79d426f9e30060d8279a1da0a" . "9c6baf1"] . $text . $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_e92ad742fc12ec1d" . "d5c30557fafca331"]);
    }
}