<?php
namespace Claromentis\Core\DocumentConverter;

$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] ?: array()) + array("_31767d7ad58e706" . "dbf47b7a51a0fe6c" . "4" => base64_decode("Y291" . "bnQ="), "_2351a63ea5f1aa" . "926b0753b192e8d" . "841" => base64_decode("RmFpbGVkIHRvIGNvbnZlcn" . "Qg"), "_ba3845cb79c0" . "05cf3269af8c8" . "3ddbe5e" => base64_decode("ZXJy" . "b3I="), "_6dc023075e" . "7b7a10fcc37" . "e2d1b691033" => base64_decode("IHRvIA=" . "="), "_5e905cea5856ef40d35ea1e" . "daf185d1b" => base64_decode("IHVz" . "aW5n" . "IA=="), "_77317902a2c9" . "03eaeed66f6a3" . "66de08b" => base64_decode("ZXhjZXB0aW9uX21lc" . "3NhZ2U="), "_a7a98b53d82ba8212" . "3bc4047484cd742" => base64_decode("Y29tbW9uLmRvY3VtZW50X2NvbnZlcnRlci5ub19jb" . "252ZXJ0ZXJz"), "_20b3ce3ff928713" . "aae2421713e60898" . "a" => base64_decode("YWRtaW4uZG9jdW1lbn" . "RfY29udmVydGVyLmVy" . "cm9yLmNvdWxkX25vdF" . "9jb25uZWN0"), "_b0e753de" . "b9741c6e9" . "b3d17cac4" . "7b5dc5" => base64_decode("Tm8gYXZhaWxhYmxlIERvY3VtZW50IENvbnZlcnRlcnMgdG" . "8gdXNlLg=="), "_946c6fe2025cf682630afe8f8cdf5" . "861" => base64_decode("Y29tbW9uLmRvY3" . "VtZW50X2NvbnZl" . "cnRlci51bmtub3" . "duX2Vycm9y"), "_b8323c39" . "6da910cd2" . "da11d4d09" . "85e9c5" => base64_decode("aXNfc" . "nVubm" . "luZw=" . "="), "_0c5123aa744f69bbc0e8b3ea2f6e847" . "d" => base64_decode("bG1zZ" . "w=="));
use Claromentis\Core\DocumentConverter\Converters\DocumentConverterInterface;
use Claromentis\Core\DocumentConverter\Exceptions\DocumentConverterException;
use Exception;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Webmozart\Assert\Assert;









class DocumentConverterService
{
    
    
    
    
    
    
    private $document_converters;
    
    
    
    
    
    
    private LoggerInterface $logger;
    
    
    
    
    
    
    
    public function __construct(array $_c347105b86cd04864c78a4febd95a6f0, ?LoggerInterface $logger)
    {
        foreach ($_c347105b86cd04864c78a4febd95a6f0 as $document_converter) {
            Assert::isInstanceOf($document_converter, DocumentConverterInterface::class);
        }
        $this->document_converters = $_c347105b86cd04864c78a4febd95a6f0;
        $this->logger = $logger ?? new NullLogger();
        if (empty($this->document_converters)) {
            $this->logger->warning($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_b0e753de" . "b9741c6e9" . "b3d17cac4" . "7b5dc5"]);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    public function Convert($_6d9f48827153c22baa0cc670b103158e, $_86a17589580c81964d306ebe003a445c, $_d1625ea25fb8b4afdb15b0570f6ab860)
    {
        foreach ($this->document_converters as $_02ad4799244951c2d809ee37be9e79fd => $document_converter) {
            try {
                $document_converter->Convert($_6d9f48827153c22baa0cc670b103158e, $_86a17589580c81964d306ebe003a445c, $_d1625ea25fb8b4afdb15b0570f6ab860);
                return;
            } catch (Exception $_fe441aa3ef350bfb1a1a1ad8520dd530) {
                
                
                if ($_02ad4799244951c2d809ee37be9e79fd === $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_31767d7ad58e706dbf47" . "b7a51a0fe6c4"]($this->document_converters) - 1) {
                    if ($_fe441aa3ef350bfb1a1a1ad8520dd530 instanceof DocumentConverterException) {
                        throw new Exception($_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage());
                    } else {
                        throw new Exception($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_0c5123aa" . "744f69bbc" . "0e8b3ea2f" . "6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_946c6fe2025cf6826" . "30afe8f8cdf5861"]));
                    }
                }
                $this->logger->error($GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_2351a63ea5f1aa926b0753b1" . "92e8d841"] . $_6d9f48827153c22baa0cc670b103158e . $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_6dc023075e7b7a10f" . "cc37e2d1b691033"] . $_d1625ea25fb8b4afdb15b0570f6ab860 . $GLOBALS["__65da1b1e" . "c2d6653e8a" . "0ab7848e53" . "6215"]["_5e905cea5856ef40d35ea1ed" . "af185d1b"] . $document_converter->GetName(), [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_77317902a2c903eaeed66f6" . "a366de08b"] => $_fe441aa3ef350bfb1a1a1ad8520dd530->getMessage()]);
            }
        }
        throw new Exception($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_0c5123aa744f69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_a7a98b53d82ba82123bc4047484cd74" . "2"]));
    }
    
    
    
    
    
    
    public function GetStatus()
    {
        $_2a85611c78080ebe98afdb51c3d4ea92 = [];
        foreach ($this->document_converters as $document_converter) {
            $_b8323c396da910cd2da11d4d0985e9c5 = $document_converter->IsRunning();
            $_2a85611c78080ebe98afdb51c3d4ea92[$document_converter->GetName()] = [$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_b8323c3" . "96da910c" . "d2da11d4" . "d0985e9c" . "5"] => $_b8323c396da910cd2da11d4d0985e9c5];
            if (!$_b8323c396da910cd2da11d4d0985e9c5) {
                $_2a85611c78080ebe98afdb51c3d4ea92[$document_converter->GetName()][$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_ba3845c" . "b79c005c" . "f3269af8" . "c83ddbe5" . "e"]] = $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_0c5123aa744f" . "69bbc0e8b3ea2" . "f6e847d"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_20b3ce3ff928713aae2421713e60" . "898a"], $document_converter->GetHost(), $document_converter->GetPort());
            }
        }
        return $_2a85611c78080ebe98afdb51c3d4ea92;
    }
    
    
    
    
    
    
    public function IsRunning()
    {
        foreach ($this->document_converters as $document_converter) {
            if ($document_converter->IsRunning()) {
                return true;
            }
        }
        return false;
    }
}