<?php
/**
 * @author 1902 Software
 * @copyright Copyright © 2023 1902 Software (https://1902software.com/magento/)
 * @package WriteTextAI_WriteTextAI
 */
?>

<?php
/**
 * @var WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\FullAutomationPrompt $block
 */

$tooltipCronNotAvailable = __("Website cron jobs have been disabled."
    . " This setting requires a cron job to function properly."
    . " Please enable it to ensure proper operation. You may need to"
    . " contact your hosting provider or developer regarding this.");
?>

<div class="wtai-bulk-full-automation-form-container"
    id="wtaiFullAutomationPrompt"
    data-bind="scope: 'wtaiFullAutomationPrompt'"
    data-mage-init='{"WriteTextAI_WriteTextAI/js/grid/massactions/full-automation-prompt": {
        "getSettingsUrl": "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/prompt')) ?>",
        "saveUrl": "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/save')) ?>",
        "restoreUrl": "<?= $block->escapeHtmlAttr($block->getUrl('wtai/grid/restore')) ?>",
        "triggerActionAfterNDaysValue": "<?= $block->escapeHtmlAttr($block->getTriggerActionAfterNDaysValue()) ?>",
        "triggerActionPageIsRankingValue":
            "<?= $block->escapeHtmlAttr($block->getTriggerActionPageIsRankingValue()) ?>",
        "triggerActionNoneValue": "<?= $block->escapeHtmlAttr($block->getTriggerActionNoneValue()) ?>",
        "hasAiModels": "<?= $block->escapeHtmlAttr($block->hasAiModels()) ?>"
    }}'
>
    <div class="wtai-bulk-prompt-header">
        <span class="wtai-bulk-prompt-title">
            <?= /* @noEscape */ __('Full automation') ?>
        </span>
        <span class="wtai-restore">
            <a href="#" data-bind="click: restore">
                <?= $block->escapeHtml(__('Restore global settings')) ?>
            </a>
        </span>
    </div>
    <p class="wtai-subtitle">
        <?= /* @noEscape */ sprintf(
            __('Configure how you want full automation to run for your selected products.'
            . ' Once set, WriteText.ai will handle everything from keyword research'
            . ' to content creation and transfer—no manual steps required.'
            . ' You will receive an email once bulk processing is done.'
            . ' Email notification settings can be configured in your account at'
            . ' <a href="%s" target="_blank">platform.writetext.ai</a>'),
            'https://platform.writetext.ai/email-notifications/'
        ) ?>
    </p>
    <div class="wtai-tabs-error-message"></div>
    <form method="post" id="wtaiFullAutomationForm" class="wtai-bulk-full-automation-form">
        <input type="hidden" name="auto_optimize_keywords" value="true" />
        <div class="wtai-form-fields">
            <div class="wtai-col wtai-col-0" id="wtaiFullAutomationPromptGenerate">
                <fieldset class="wtai-fieldset">
                    <div class="wtai-fieldset-title"><?= $block->escapeHtml(__('Actions')) ?></div>
                    
                    <div class="wtai-actions-box">
                        <div class="wtai-action-group">
                            <div class="wtai-action-title wtai-bold wtai-available">
                                <span><?= $block->escapeHtml(__('Optimize')) ?></span>
                                <span class="wtai-status-icon"></span>
                            </div>
                            <div class="wtai-field" title="<?=
                                $block->escapeHtmlAttr(
                                    __('Keyword optimization is enabled by default for Full Automation.')
                                ) ?>">
                                <input type="checkbox"
                                    class="admin__control-checkbox"
                                    id="wtaiKeywordAnalysisFull"
                                    checked
                                    disabled
                                />
                                <label class="wtai-label admin__field-label" for="wtaiKeywordAnalysisFull">
                                    <span class="wtai-action-text">
                                        <?= $block->escapeHtml(__('Keyword analysis')) ?>
                                    </span>
                                </label>
                            </div>
                        </div>
                        <div class="wtai-action-group">
                            <div class="wtai-action-title wtai-bold wtai-available">
                                <span><?= $block->escapeHtml(__('Generate')) ?></span>
                                <span class="wtai-status-icon"></span>
                            </div>
                            <div class="wtai-field">
                                <input type="checkbox"
                                    class="admin__control-checkbox"
                                    id="wtaiGenerateNewTextFull"
                                    checked
                                    disabled
                                />
                                <label class="wtai-label admin__field-label" for="wtaiGenerateNewTextFull">
                                    <span class="wtai-action-text">
                                        <?= $block->escapeHtml(__('Generate new text')) ?>
                                    </span>
                                </label>
                            </div>
                        </div>
                        <div class="wtai-action-group wtai-transfer-action"
                            data-bind="css: transferActionClass">
                            <div class="wtai-action-title wtai-bold">
                                <span><?= __('Transfer') ?></span>
                                <span class="wtai-status-icon"></span>
                            </div>
                            <div class="wtai-field">
                                <input type="checkbox" id="wtaiTransferToMagento" class="admin__control-checkbox" 
                                    name="transfer_to_magento" 
                                    data-bind="checked: transferToMagento" />
                                <label class="wtai-label admin__field-label" for="wtaiTransferToMagento">
                                    <span class="wtai-action-text">
                                        <?= $block->escapeHtml(__('Transfer to Magento')) ?>
                                    </span>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="wtai-error-message"></div>
                </fieldset>
            </div>
            <hr class="wtai-mobile-divider wtai-tablet-hidden">
            <div class="data items wtai-tabs">
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiTextTypeTab">
                        <?= $block->escapeHtml(__('Text type & Templates')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content wtai-text-type-tab" 
                    data-role="content"
                    id="wtaiTextTypeTab"
                >
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/text_types_templates.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class
                    ); ?>
                </div>
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiKeywordOptimizationTab">
                        <?= $block->escapeHtml(__('Keyword analysis')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content wtai-keyword-optimization-tab" 
                    data-role="content"
                    id="wtaiKeywordOptimizationTab"
                >
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/keyword_analysis.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class
                    ); ?>
                </div>
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiTonesStyleAudienceTab">
                        <?= $block->escapeHtml(__('Tones, Style, Audiences')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content" data-role="content" id="wtaiTonesStyleAudienceTab">
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/tones_styles_audience.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class,
                        true
                    ); ?>
                </div>
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiAttributesTab">
                        <?= $block->escapeHtml(__('Product data')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content" data-role="content" id="wtaiAttributesTab">
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/attributes.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class
                    ); ?>
                </div>
                <div class="item title wtai-tab-title" data-role="collapsible">
                    <a class="data switch" data-toggle="trigger" href="#wtaiTextLengthTab">
                        <?= $block->escapeHtml(__('Text length')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content wtai-text-length-tab"
                    data-role="content"
                    id="wtaiTextLengthTab"
                >
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/text_length.phtml',
                        \WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt::class
                    ); ?>
                </div>
            </div>
        </div>
    </form>
    <div class="wtai-loading-mask" data-bind="visible: isLoading"></div>
    <div class="wtai-restore-global-mask" data-bind="visible: isRestoreGlobalLoading"></div>
</div>

<script>
    require([
    "jquery",
    "mage/mage",
    "mage/validation"
    ], function($) {
        $("#wtaiFullAutomationPrompt").trigger('contentUpdated');
    });
</script>