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

<?php
    use WriteTextAI\WriteTextAI\ViewModel\Premium;
?>

<?php
    /** @var Premium $premium */
    $premium = $block->getPremium();
    $getUnlockedPremium = $premium->getUnlockedPremium();
    $hasProAccess = $premium->getHasProAccess();
    $membershipType = $premium->getMembershipType();
    $showByApi = $getUnlockedPremium && !$hasProAccess && $membershipType === Premium::MEMBERSHIP_TYPE_STARTER;

    $showPopup = $showByApi;
?>

<div class="wtai-welcome-starter-popup-modal" data-bind="scope: 'wtaiWelcomeStarterPopup'" style="display: none;">
    <div class="wtai-popup-content">
        <div class="wtai-popup-image">
            <img src="<?= /* @noEscape */ $block->getViewFileUrl(
                'WriteTextAI_WriteTextAI/images/welcome_banner.png'
            ) ?>" alt="Welcome to Starter">
        </div>
        <div class="wtai-popup-text">
            <div class="wtai-popup-title">
                <?= /* @noEscape */ __("You’re now on Starter!") ?>
            </div>
            <div>
                <p>
                    <?= /* @noEscape */ __(
                        "You now have access to all core content generation tools using prepaid credits."
                    ) ?>
                </p>
                
                <p>
                    <?= /* @noEscape */ __("Generate product descriptions, apply templates, and enhance your content"
                        . " with AI-powered product research—at your own pace, no subscription needed.") ?>
                </p>
                <p>
                    <?= /* @noEscape */ __("Start generating text by clicking on a product.") ?>
                </p>
            </div>
            <div class="wtai-popup-buttons">
                <button type="button" class="action-primary primary" data-bind="click: closeStarterPopup">
                    <?= $block->escapeHtml(__('Got it')) ?>
                </button>
            </div>
        </div>
    </div>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiWelcomeStarterPopup": {
                        "component": "WriteTextAI_WriteTextAI/js/popups/welcome-starter",
                        "saveUrl": "<?= $block->escapeJs($block->getUrl('wtai/settings/popups')) ?>",
                        "showPopupOnLoad": <?= /* @noEscape */ $showPopup ? 'true' : 'false' ?>
                    }
                }
            }
        }
    }
</script>