<?php
/**
 * Refer to LICENSE.txt distributed with the Temando Shipping module for notice of license
 */
?>
<?php // @codingStandardsIgnoreFile ?>
<?php
    /** @var \Temando\Shipping\Block\Adminhtml\ComponentContainer $block */
    /** @var \Temando\Shipping\ViewModel\Config\CheckoutFields $viewModel */
    $viewModel = $block->getViewModel();
?>
<div id="temando-componentry"
     data-bind="scope:'temando-componentry'"
     data-component-init='[
     {
        "entrypoint":"CheckoutFieldsForm",
        "assetsUrl":"<?= $block->escapeUrl($block->getAssetsUrl());?>",
        "elements": {
            "m2PageActionsButtonsId": "temando-page-actions-buttons"
        },
        "data": {
            "temandoApiEndpoint": "<?= $block->escapeUrl($viewModel->getShippingApiAccess()->getApiEndpoint()); ?>",
            "temandoApiToken": "<?= $block->escapeHtml($viewModel->getShippingApiAccess()->getSessionToken()); ?>",
            "temandoApiTokenTtl": "<?= $block->escapeHtml($viewModel->getShippingApiAccess()->getSessionTokenExpiry()); ?>",
            "m2ApiTemandoTokenRefreshEndpoint": "<?= $block->escapeUrl($viewModel->getShippingApiAccess()->getSessionTokenRefreshEndpoint()); ?>",
            "m2ApiUpdateCheckoutFieldsEndpoint": "<?= $block->escapeUrl($viewModel->getUpdateCheckoutFieldEndpoint()); ?>",
            "m2ApiFormKey": "<?= $block->escapeHtml($block->getFormKey()); ?>",
            "m2CheckoutFieldsData": {"fields": <?= /* @noEscape */ $viewModel->getCheckoutFieldsData(); ?> },
            "ipAddress": "<?= $block->escapeHtml($block->getIpAddress()); ?>",
            "lang": "<?= $block->escapeHtml($block->getLanguage()); ?>",
            "locale": "<?= $block->escapeHtml($block->getLocale()) ?>",
            "configurationPageUrl": "<?= $block->escapeUrl($viewModel->getConfigurationPageUrl()); ?>"
        }
     }]'
>
    <!-- ko template: getTemplate() --><!-- /ko -->
    <script type="text/x-magento-init">
    {
        "#temando-componentry": {
            "Magento_Ui/js/core/app":  <?= /* @noEscape */ $block->getJsLayout(); ?>
        }
    }
    </script>
</div>
