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

<?php
/**
 * @var WriteTextAI\WriteTextAI\Block\Adminhtml\Grid\Prompt $block
 */
?>
<?php
$tooltipAltTextDisabled = __("Image alt text can’t run alone due to a technical limit. Please include another text type.");
?>

<div class="wtai-bulk-generate-form-container"
    data-bind="scope: 'wtaiPrompt'"
    data-mage-init='{"WriteTextAI_WriteTextAI/js/grid/massactions/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')) ?>",
        "hasAiModels": "<?= $block->escapeHtmlAttr($block->hasAiModels()) ?>"
    }}'
>
    <div class="wtai-bulk-prompt-header">
        <span class="wtai-bulk-prompt-title">
            <?= /* @noEscape */ __('Bulk generate') ?>
        </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 your text to be generated.'
        . ' For Attributes, note that selecting a product attribute does not guarantee that'
        . ' it will appear in the text itself, but'
        . ' it will help guide WriteText.ai in generating more relevant text.'
        . ' 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="wtaiBulkGenerateForm" class="wtai-bulk-generate-form">
        <div class="wtai-form-fields">
            <div class="wtai-col wtai-col-0" id="wtaiPrompt">
                <fieldset class="wtai-fieldset">
                    <div class="wtai-fieldset-title"><?= $block->escapeHtml(__('Generate')) ?></div>
                    <div class="wtai-field">
                        <input type="checkbox"
                            class="admin__control-checkbox"
                            value="all"
                            id="wtaiFieldGenerateAll"
                            name="fields[]"
                            data-bind="checked: allFieldsSelected" />
                        <label class="wtai-label admin__field-label wtai-strong" for="wtaiFieldGenerateAll">
                            <?= $block->escapeHtml(__('Select all')) ?>
                        </label>
                    </div>
                    <!-- ko foreach: fields -->
                        <div class="wtai-field">
                            <input type="checkbox"
                                class="admin__control-checkbox wtai-generate-text-fields"
                                name="fields[]"
                                data-bind="
                                    checked: $parent.selectedFields,
                                    attr: {
                                        id: 'wtaiField' + $data.value,
                                    },
                                    value: $data.value,
                                " />
                            <label class="wtai-label admin__field-label" data-bind="
                                attr: {
                                    for: 'wtaiField' + $data.value,
                                },
                                text: $data.label
                            "></label>
                        </div>
                    <!-- /ko -->
                    <div class="wtai-field" data-bind="attr: { title: isAltTextDisabled()
                        ? '<?= $block->escapeHtmlAttr($tooltipAltTextDisabled) ?>' : ''},
                        css: {'wtai-not-allowed': isAltTextDisabled}">
                        <input type="checkbox"
                            class="admin__control-checkbox wtai-generate-text-fields"
                            value="alt_text"
                            id="wtaiFieldAltText"
                            name="fields[]"
                            data-bind="checked: selectedFields,
                                disable: isAltTextDisabled"
                        />
                        <label class="wtai-label admin__field-label" for="wtaiFieldAltText">
                            <?= $block->escapeHtml(__("Image alt text")) ?>
                        </label>
                    </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="#wtaiTemplatesTab">
                        <?= $block->escapeHtml(__('Templates')) ?>
                    </a>
                </div>
                <div class="item content wtai-tab-content wtai-templates-tab"
                    data-role="content"
                    id="wtaiTemplatesTab"
                >
                    <?= /* @noEscape */ $block->createBlockContent(
                        'WriteTextAI_WriteTextAI::grid/massactions/tabs/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="#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 type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/block-loader":
                "<?= $block->escapeJs($block->getViewFileUrl('images/loader-1.gif')) ?>"
        }
    }
</script>