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

<?php
$tooltipText = __("Note: Selecting the product image"
    . " to be considered in generating text might result in a significantly"
    . " longer time to complete your bulk generation, This is because"
    . " we have to download and resize the image and then send it to the"
    . " AI for analysis. The time it takes for this processing on a single"
    . " product generation may be negligible, but it can add up when"
    . " doing bulk generation for multiple products.");
?>

<div class="wtai-col wtai-col-2">
    <div class="row wtai-category-attributes">
        <fieldset class="wtai-fieldset">
            <div class="wtai-fieldset-title">
                <?= $escaper->escapeHtml(__('Category context')) ?>
            </div>
            <div class="wtai-text-introduction">
                <p><?= $escaper->escapeHtml(
                    __('Category context controls what information WriteText.ai '
                    .'uses when writing category content. By default, WriteText.ai '
                    .'references 5 representative products per category '
                    .'(set in the single category editor, or selected randomly if none are set),'
                    .' using their names, descriptions, and images. You can optionally include:')
                ) ?>
                </p>
                <p>
                    <strong><?= $escaper->escapeHtml(__('Category image')) ?></strong>
                    <?= $escaper->escapeHtml(__(' — Your primary image as additional context.')) ?>
                </p>
                <p>
                    <strong><?= $escaper->escapeHtml(__('Product Research')) ?></strong>
                    <?= $escaper->escapeHtml(
                        __(' — AI-powered online research on the 5 representative products')
                        . __(' to improve writing accuracy.')
                    ) ?>
                </p>
            </div> 
            <div class="wtai-field-columns">
                <!-- ko foreach: attributes -->
                    <!-- ko if: $data.value === 'thumbnail' -->
                        <div class="wtai-field wtai-thumbnail-field" data-bind="attr: {
                            title: '<?= $escaper->escapeHtmlAttr($tooltipText) ?>'
                        }">
                            <input type="checkbox"
                                class="admin__control-checkbox wtai-product_attributes"
                                data-bind="
                                    checked: $parent.attributesSelected,
                                    value: $data.value,
                                    attr: {
                                        id: 'wtaiAttr' + $data.id,
                                    },
                                    enable: $parent.attrAllowed
                                "
                                name="attributes[]"
                            />
                            <label class="wtai-label admin__field-label" data-bind="
                                attr: { for: 'wtaiAttr' + $data.id }
                            ">
                                <span data-bind="text: $data.label"></span>
                                <p class="wtai-thumbnail-text">
                                    <?= $escaper->escapeHtml(
                                        __("(Analyze image to generate more relevant text)")
                                    ) ?>
                                </p>
                            </label>
                        </div>
                    <!-- /ko -->
                    <!-- ko if: $data.value === 'wtai_product_research_data' -->
                        <div class="wtai-field wtai-thumbnail-field">
                            <input type="checkbox"
                                class="admin__control-checkbox wtai-product_attributes"
                                data-bind="
                                    checked: $parent.attributesSelected,
                                    attr: {
                                        id: 'wtaiAttr' + $data.id,
                                    },
                                    value: $data.value,
                                    enable: $parent.attrAllowed
                                "
                                name="attributes[]"
                            />
                            <label class="wtai-label admin__field-label" data-bind="
                                attr: { for: 'wtaiAttr' + $data.id }
                            ">
                                <span data-bind="text: $data.label"></span>
                                <p class="wtai-thumbnail-text">
                                    <?= $escaper->escapeHtml(
                                        __("(AI-powered research to improve writing accuracy)")
                                    ) ?>
                                </p>
                            </label>
                        </div>
                    <!-- /ko -->
                    <!-- ko ifnot: $data.value === 'thumbnail' || $data.value === 'wtai_product_research_data' -->
                        <div class="wtai-field">
                            <input type="checkbox"
                                class="admin__control-checkbox wtai-product_attributes"
                                data-bind="
                                    checked: $parent.attributesSelected,
                                    attr: {
                                        id: 'wtaiAttr' + $data.id,
                                    },
                                    value: $data.value,
                                    enable: $parent.attrAllowed
                                "
                                name="attributes[]"
                            />
                            <label class="wtai-label admin__field-label" data-bind="
                                attr: { for: 'wtaiAttr' + $data.id }
                            ">
                                <span data-bind="text: $data.label"></span>
                            </label>
                        </div>
                    <!-- /ko -->
                <!-- /ko -->
            </div>
            <div class="wtai-error-message"></div>
        </fieldset>
    </div>
    <div class="row wtai-special-instructions">
        <div class="wtai-field">
            <label class="admin__field-label">
                <?= $escaper->escapeHtml(__('Special instructions')) ?>
            </label>
            <div class="admin__field-tooltip wtai-small">
                <a class="admin__field-tooltip-action" href="#" data-toggle="dropdown"></a>
                <div class="admin__field-tooltip-content wtai-bottom-left" data-target="dropdown">
                    <div class="wtai-content-wrapper">
                        <?= /* @noEscape */ $block->getTooltip('wtai.special.instructions.category') ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="wtai-control">
            <textarea class="admin__control-textarea"
                name="product_details"
                data-bind="
                    event: { input: handleInputSpecialInstructions },
                    textInput: specialInstructions,
                    attr: { maxlength: rules().maxOtherDetailsLength }
                "
            ></textarea>
            <span class="wtai-note">
                <?= $escaper->escapeHtml(__('Use a comma to separate details.')) ?>
            </span>
            <span class="wtai-text-length" data-bind="text: getOtherProductDetailsLength"></span>
        </div>
    </div>
</div>