<?php
/**
 * Copyright 2015 Adobe
 * All Rights Reserved.
 */
use Magento\Customer\ViewModel\Customer\Data;
use Magento\Customer\ViewModel\CookieSettings;

/**
 * @var \Magento\Customer\Block\CustomerData $block
 * @var \Magento\Framework\Escaper $escaper
 */

// phpcs:disable Magento2.Templates.ThisInTemplate.FoundHelper
/** @var Auth $auth */
$auth = $block->getAuth();
/** @var JsonSerializer $jsonSerializer */
$jsonSerializer = $block->getJsonSerializer();
$customerDataUrl = $block->getCustomerDataUrl('customer/account/updateSession');
$expirableSectionNames = $block->getExpirableSectionNames();
/** @var CookieSettings $cookieSettings */
$cookieSettings = $block->getCookieSettings();
?>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Customer/js/customer-data": {
                "sectionLoadUrl": "<?= $escaper->escapeJs($block->getCustomerDataUrl('customer/section/load')) ?>",
                "expirableSectionLifetime": <?= (int)$block->getExpirableSectionLifetime() ?>,
                "expirableSectionNames": <?= /* @noEscape */ $jsonSerializer->serialize(
                    $expirableSectionNames
                ) ?>,
                "cookieLifeTime": "<?= $escaper->escapeJs($block->getCookieLifeTime()) ?>",
                "cookieDomain": "<?= $escaper->escapeJs($cookieSettings->getCookieDomain()) ?>",
                "updateSessionUrl": "<?= $escaper->escapeJs($customerDataUrl) ?>",
                "isLoggedIn": "<?= /* @noEscape */ $auth->isLoggedIn() ?>"
            }
        }
    }
</script>
