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

<div class="wtai-col wtai-col-1">
    <div class="row">
        <div class="wtai-text-introduction">
            <span><?= /* @noEscape */ sprintf(
                __('Don’t see any templates?'
                    . ' You can create and assign them in <a href="%s" target="_blank">platform.writetext.ai</a>. '
                    . 'Assigned templates will appear here.'),
                'https://platform.writetext.ai/webshops/'
            ) ?>
            </span>
            
        </div>
        <!-- ko foreach: fields -->
            <!-- ko if: $data.hasTemplate -->
                <div class="wtai-field">
                    <label class="wtai-label admin__field-label" data-bind="
                        attr: {
                            for: 'wtaiTemplateField' + $data.value,
                        },
                        text: $data.label
                    "
                    ></label>
                    <div class="admin__field wtai-select-template-bulk">
                        <div class="admin__field-control">
                            <select class="admin__control-select"
                                data-bind="
                                    disable: $parent.selectedFields.indexOf($data.value) === -1,
                                    attr: {
                                        id: 'wtaiTemplateField' + $data.value,
                                        name: 'wtai_generate_template_' + $data.value,
                                    }
                                "
                            >
                                <option value=""><?= $block->escapeHtml(__('No template')) ?></option>
                                <!-- ko foreach: $data.templates -->
                                <option 
                                    data-bind="
                                        attr: {
                                            value: $data.id,
                                            title: $data.name,
                                        },
                                        text: $data.name.length > 60
                                            ? $data.name.substring(0, 60) + '...' + '\u00A0\u00A0'
                                            : $data.name + '\u00A0\u00A0'
                                    "
                                ></option>
                                <!-- /ko -->
                            </select>
                        </div>
                    </div>
                </div>
            <!-- /ko -->
        <!-- /ko -->
    </div>
</div>