<?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',
                ['action_type' => 'full_automation', 'entity_type' => 'product']
            ))
?>",
        "getAiModelsUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/grid/getAiModels')) ?>",
        "saveUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/save')) ?>",
        "saveConfigUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/saveconfig')) ?>",
        "restoreUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/grid/restore')) ?>",
        "templateSelectionUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/templateselection')) ?>",
        "templateScope": "product_grid_full_automation",
        "getCustomOptionsUrl": 
            "<?= $block->escapeHtmlAttr($block->getUrl('wtai/grid/getCustomizableOptionsWithValues')) ?>",
        "brandVoiceSelectionUrl": "<?= $block->escapeHtmlAttr($block->getUrl('wtai/settings/brandvoiceselection')) ?>",
        "brandVoiceScope": "product_grid_full_automation",
        "triggerActionAfterNDaysValue": "<?= $block->escapeHtmlAttr($block->getTriggerActionAfterNDaysValue()) ?>",
        "triggerActionPageIsRankingValue":
            "<?= $escaper->escapeHtmlAttr($block->getTriggerActionPageIsRankingValue()) ?>",
        "triggerActionNoneValue": "<?= $escaper->escapeHtmlAttr($block->getTriggerActionNoneValue()) ?>"
    }}'
>
    <div class="wtai-bulk-prompt-header">
        <span class="wtai-bulk-prompt-title">
            <?= /* @noEscape */ __('Full automation') ?>
        </span>
            <span class="wtai-global-settings-wrapper">
        <?php if ($block->isModifyDefaultsAllowed()): ?>
                <a href="#" data-bind="click: save">
                    <?= $escaper->escapeHtml(__('Save to global settings')) ?>
                </a>
                <span class="wtai-separator"> | </span>
        <?php endif; ?>
                <a href="#" data-bind="click: restore">
                    <?= $escaper->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"><?= $escaper->escapeHtml(__('Actions')) ?></div>
                    
                    <div class="wtai-actions-box">
                        <div class="wtai-action-group">
                            <div class="wtai-action-title wtai-bold wtai-available">
                                <span><?= $escaper->escapeHtml(__('Optimize')) ?></span>
                                <span class="wtai-status-icon"></span>
                            </div>
                            <div class="wtai-field" title="<?=
                                $escaper->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">
                                        <?= $escaper->escapeHtml(__('Keyword analysis')) ?>
                                    </span>
                                </label>
                            </div>
                        </div>
                        <div class="wtai-action-group">
                            <div class="wtai-action-title wtai-bold wtai-available">
                                <span><?= $escaper->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">
                                        <?= $escaper->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><?= $escaper->escapeHtml(__('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">
                                        <?= $escaper->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">
                        <?= $escaper->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">
                        <?= $escaper->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">
                        <?= $escaper->escapeHtml(__('Voice & Style')) ?>
                    </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">
                        <?= $escaper->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">
                        <?= $escaper->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 class="wtai-save-global-mask" data-bind="visible: isSaveGlobalLoading "></div>
</div>

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