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

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"] ?: array()) + array("_63320be23a35daabeeb" . "7422b56f6b894" => base64_decode("YXVkaXRJbWFnZVByb21wd" . "A=="), "_9247c1342b3931513e7d8" . "46ad4639bb4" => base64_decode("YXVkaXRDaGF0UHJvbXB" . "0"), "_79d426f9e30060d8279a1da0a9" . "c6baf1" => base64_decode("UHJv" . "bXB0" . "OiAi"), "_58f9cd2f97dbf4d" . "2db74ab02504a90b" . "9" => base64_decode("YXJyYX" . "lfcmV2" . "ZXJzZQ" . "=="), "_5619b7198" . "5d89d61e04" . "b099c66341" . "570" => base64_decode("QUkgIiVzI" . "iB3YXMgJX" . "Mu"), "_4b878be3b984a2ace" . "7d2dc22b5f59289" => base64_decode("YXVkaXR" . "UZXh0UH" . "JvbXB0"), "_7f628626dd1d55c" . "71b1fc0932ffd1d2" . "c" => base64_decode("aXNfYXJyYXk" . "="), "_fd02c7e3d45300b40c3d9698e7" . "b27faf" => base64_decode("ZGlzYWJsZW" . "Q="), "_5e30c4717ced36c" . "ff9e93e19a5c576c" . "c" => base64_decode("aXNfc3" . "RyaW5n"), "_99cee2d2272a85" . "50f4b21e3cb57ff" . "f7d" => base64_decode("ZW5h" . "Ymxl" . "ZA=="), "_6596b8f6a4969f" . "9a3f6a1b22b90e9" . "331" => base64_decode("c3ByaW50Zg=" . "="), "_7fd958b240eef518cc21f5e7b74df" . "ed9" => base64_decode("YXVkaXR" . "TZXR0aW" . "5ncw=="), "_4d707fab93bebb00bbe6" . "9e8159697c90" => base64_decode(""), "_e92ad742fc12e" . "c1dd5c30557faf" . "ca331" => base64_decode("Ig=" . "="));
use Claromentis\Core\Ai\AiServiceProvider;
use Claromentis\Core\Ai\Events\AiEvent;
use Claromentis\Core\Ai\Events\AiEventType;
use Claromentis\Core\Ai\Events\AiSettingsEvent;
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["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_4b878be3b984a" . "2ace7d2dc22b5f" . "59289"], AiEventType::CHAT_PROMPT => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_9247c1342b3931513e7d84" . "6ad4639bb4"], AiEventType::IMAGE_PROMPT => $GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"]["_63320be23a35daab" . "eeb7422b56f6b894"], AiEventType::SETTINGS => $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_7fd958b240eef518cc21f5e7b74dfed" . "9"]];
    }
    
    
    
    
    
    
    
    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);
    }
    public function auditSettings(AiSettingsEvent $event) : void
    {
        $module = $event->getModuleName();
        $_8e7f4b5c8440c0a24fb1b632eee28538 = $event->getNewStatus() ? $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_99cee2d2272a8550f4b" . "21e3cb57fff7d"] : $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_fd02c7e" . "3d45300b" . "40c3d969" . "8e7b27fa" . "f"];
        $_e05e0022a2e5ad344b9c4a0d3f64e1a5 = $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_6596b8f6" . "a4969f9a3" . "f6a1b22b9" . "0e9331"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_5619b71985d" . "89d61e04b099" . "c66341570"], $module, $_8e7f4b5c8440c0a24fb1b632eee28538);
        $this->audit->Success(AiServiceProvider::NAME, AiEventType::SETTINGS, 0, $_e05e0022a2e5ad344b9c4a0d3f64e1a5);
    }
    
    
    
    
    
    
    
    
    private function handlePromptAudit(AiEvent $event, string $_18c3ae9a896c5ec6d2e49d0d9d3852f2) : void
    {
        $_9961f986823b4be7f5c4cc8379c6b228 = $event->getPrompt();
        $text = $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_4d707fab93bebb00" . "bbe69e8159697c90"];
        if ($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_7f628626dd1d55c71b1fc093" . "2ffd1d2c"]($_9961f986823b4be7f5c4cc8379c6b228)) {
            $_9961f986823b4be7f5c4cc8379c6b228 = $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_58f9cd2f97dbf4d2db74ab02504a90" . "b9"]($_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["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_5e30c47" . "17ced36c" . "ff9e93e1" . "9a5c576c" . "c"]($_9961f986823b4be7f5c4cc8379c6b228)) {
                    $text = $_9961f986823b4be7f5c4cc8379c6b228;
                }
            }
        }
        
        
        if (empty($text)) {
            return;
        }
        $this->audit->Success(AiServiceProvider::NAME, $_18c3ae9a896c5ec6d2e49d0d9d3852f2, 0, $GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_79d426f9e30060d8279a1da0a9c6b" . "af1"] . $text . $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_e92ad742fc12ec" . "1dd5c30557fafca" . "331"]);
    }
}