<?php
/**
 * @author 1902 Software
 * @copyright Copyright © 2023 1902 Software (https://1902software.com/magento/)
 * @package WriteTextAI_WriteTextAI
 */
?>
<div class="wtai-signalr" data-bind="scope: 'wtaiSignalr'">
    <div class="wtai-generate-message wtai-no-display" data-bind="css: {
        'wtai-no-display': !showMessage(),
        'wtai-success': messageSuccess,
        'wtai-error': !messageSuccess()
    }">
        <div class="wtai-content">
            <span class="wtai-message" data-bind="html: message"></span>
            <div class="wtai-action">
                <button class="wtai-close" data-bind="click: hideMessage">
                    <span><?= $escaper->escapeHtml(__('Ok')) ?></span>
                </button>
            </div>
        </div>
        <div class="wtai-footer">
            <span class="wtai-error-message" data-bind="
                html: errorMessage,
                visible: errorMessage() !== ''
                    && !(invalidImagePopupDoNotShowAgain || window.wtaiInvalidImagePopupDoNotShowAgain)
            "></span>
            <span data-bind="
                visible: messageSuccess()
            "><?= $escaper->escapeHtml(__(
                'Please remember to check the output for any factual mistakes'
                . ' or inaccuracies before you publish the text to your live site.'
            )) ?></span>
        </div>
    </div>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiSignalr": {
                        "component": "WriteTextAI_WriteTextAI/js/signalr",
                        "pageTitle": "<?= $escaper->escapeJs($block->getPageTitle()) ?>",
                        "pageDescription": "<?= $escaper->escapeJs($block->getPageDescription()) ?>",
                        "productDescription": "<?= $escaper->escapeJs($block->getProductDescription()) ?>",
                        "excerpt": "<?= $escaper->escapeJs($block->getExcerpt()) ?>",
                        "openGraph": "<?= $escaper->escapeJs($block->getOpenGraph()) ?>",
                        "invalidImagePopupDoNotShowAgain":
                            <?= /* @noEscape */ $block->isInvalidImagePopupDoNotShowAgain() ? 'true' : 'false' ?>,
                        "accessToken": "<?= $escaper->escapeJs($block->getAccessToken()) ?>",
                        "signalRUrl": "<?= $escaper->escapeJs($block->getSignalrUrl()) ?>",
                        "getGeneratedUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/edit/textfields_get')) ?>",
                        "getNewAccessTokenUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/grid/token')) ?>",
                        "getImagesUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/image/get')) ?>",
                        "getOptimizationUrl":
                            "<?= $escaper->escapeJs($block->getUrl('wtai/edit/keywordsOptimization_get')) ?>",
                        "getCreditsUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/grid/getCredits')) ?>",
                        "getOptimizationListUrl":
                            "<?= $escaper->escapeJs($block->getUrl('wtai/edit/keywordsOptimization_getList')) ?>",
                        "isSingleRequestUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/edit/isSingleRequest')) ?>",
                        "removeSingleRequestUrl":
                            "<?= $escaper->escapeJs($block->getUrl('wtai/edit/removeSingleRequest')) ?>",
                        "getBulkRequestsUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/grid/getBulkRequests')) ?>",
                        "entityType": "<?= $escaper->escapeJs($block->getEntityType()) ?>",
                        "audienceGetUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/edit/audience_get')) ?>"
                    }
                }
            }
        }
    }
</script>
