{block name='snippets-shipping-calculator'}
    {et_isShopVersionAtLeast value="5.1.0" assign='shopIsAtLeast51'}
    {et_isShopVersionAtLeast value="5.5.0-rc.1" assign='shopIsAtLeast55'}
    {$lazyLoadImages=$lazyLoadImages|default:true}
    {block name='snippets-shipping-calculator-form'}
        <div id="shipping-estimate-form" class="shipping-calculator-main">
            {block name='snippets-shipping-calculator-form-content'}
                {block name='snippets-shipping-calculator-estimate'}
                    <div class="h3 shipping-calculator-main-heading">{lang key='estimateShippingCostsTo' section='checkout'}:</div>
                {/block}
                {block name='snippets-shipping-calculator-estimate-main'}
                    <div class="form-row">
                        {block name='snippets-shipping-calculator-countries'}
                            <div class="col col-12 col-md-5 shipping-calculator-main-country">
                                {formgroup}
                                    <select name="land" id="country" class="form-control custom-select" aria-label="{lang key='country' section='account data'}">
                                        {if !$shopIsAtLeast51}
                                            {foreach $laender as $land}
                                                <option value="{$land->getISO()}" {if $shippingCountry === $land->getISO()}selected{/if}>
                                                    {$land->getName()}
                                                </option>
                                            {/foreach}
                                        {elseif !$shopIsAtLeast55}
                                            {foreach $countries as $country}
                                                {if $country->isShippingAvailable()}
                                                    <option value="{$country->getISO()}" {if $shippingCountry === $country->getISO()}selected{/if}>
                                                        {$country->getName()}
                                                    </option>
                                                {/if}
                                            {/foreach}
                                        {else}
                                            {foreach $deliverableCountries as $country}
                                                {if $country->isShippingAvailable()}
                                                    <option value="{$country->getISO()}" {if $shippingCountry === $country->getISO()}selected{/if}>
                                                        {$country->getName()}
                                                    </option>
                                                {/if}
                                            {/foreach}
                                        {/if}
                                    </select>
                                {/formgroup}
                            </div>
                        {/block}
                        {block name='snippets-shipping-calculator-submit'}
                            <div class="col col-12 col-md-3">
                                {$selectedZip = ""}
                                {if isset($VersandPLZ)}
                                    {$selectedZip=trim($VersandPLZ)}
                                {elseif JTL\Session\Frontend::getCustomer()->cPLZ !== null}
                                    {$selectedZip=trim(JTL\Session\Frontend::getCustomer()->cPLZ)}
                                {/if}
                                {formgroup label-for="plz" label="{lang key='plz' section='forgot password'}"}
                                    <input type="text"
                                        id="plz"
                                        class="form-control"
                                        name="plz"
                                        size="8"
                                        maxlength="8"
                                        value="{$selectedZip}"
                                        placeholder=" "
                                        aria-label="{lang key='plz' section='account data'}"
                                    />
                                {/formgroup}
                            </div>
                            <div class="col col-12 col-md-4">
                                {include file="widgets/base/button.tpl" variant="secondary" classes="btn-block" name="versandrechnerBTN" type="submit" label="{lang key='estimateShipping' section='checkout'}"}
                            </div>
                        {/block}
                    </div>
                {/block}
            {/block}
        </div>
    {/block}
    {if !empty($Versandland) && !empty($VersandPLZ)}
        <div id="shipping-estimated" class="table-responsive">
            {block name='snippets-shipping-calculator-content'}
                {if !empty($ArtikelabhaengigeVersandarten)}
                    {block name='snippets-shipping-calculator-table-artikelabhaengig'}
                        <table class="table">
                            {block name='snippets-shipping-calculator-table-artikelabhaengig-caption'}
                                <caption>{lang key='productShippingDesc' section='checkout'}</caption>
                            {/block}
                            <tbody>
                                {block name='snippets-shipping-calculator-table-artikelabhaengig-body'}
                                    {foreach $ArtikelabhaengigeVersandarten as $artikelversand}
                                        <tr>
                                            <td>{$artikelversand->cName|trans}</td>
                                            <td class="text-right-util text-nowrap-util">
                                                <strong>{$artikelversand->cPreisLocalized}</strong>
                                            </td>
                                        </tr>
                                    {/foreach}
                                {/block}
                            </tbody>
                        </table>
                    {/block}
                {/if}
                {if !empty($Versandarten)}
                    {block name='snippets-shipping-calculator-shipping-methods'}
                        <table class="table">
                            {block name='snippets-shipping-calculator-shipping-methods-header'}
                                {block name='snippets-shipping-calculator-shipping-methods-caption'}{* Since 5.3.0 *}
                                    <caption>{lang key='shippingMethods'}</caption>
                                {/block}
                            {/block}
                            <tbody>
                                {block name='snippets-shipping-calculator-shipping-methods-body'}
                                    {foreach $Versandarten as $versandart}
                                        <tr id="shipment_{$versandart->kVersandart}">
                                            <td>
                                                {if $versandart->cBild}
                                                    {image src=$versandart->cBild alt="{$versandart->angezeigterName|trans}" fluid=true lazy=$lazyLoadImages}
                                                {else}
                                                    {$versandart->angezeigterName|trans}
                                                {/if}
                                                {if $versandart->angezeigterHinweistext|trans}
                                                    <p class="small">
                                                        {$versandart->angezeigterHinweistext|trans}
                                                    </p>
                                                {/if}
                                                {if isset($versandart->Zuschlag) && $versandart->Zuschlag->fZuschlag != 0}
                                                    <p class="small">
                                                        {$versandart->Zuschlag->angezeigterName|trans}
                                                            (+{$versandart->Zuschlag->cPreisLocalized})
                                                    </p>
                                                {/if}
                                                {if $versandart->cLieferdauer|trans && $Einstellungen.global.global_versandermittlung_lieferdauer_anzeigen === 'Y'}
                                                    <p class="small">
                                                        {lang key='shippingTimeLP'}: {$versandart->cLieferdauer|trans}
                                                    </p>
                                                {/if}
                                            </td>
                                            <td class="text-right-util text-nowrap-util">
                                                <strong>
                                                    {$versandart->cPreisLocalized}
                                                </strong>
                                            </td>
                                        </tr>
                                    {/foreach}
                                {/block}
                            </tbody>
                        </table>
                    {/block}
                    {block name='snippets-shipping-calculator-link'}
                        {if isset($checkout) && $checkout}
                            {get_static_route id='warenkorb.php' assign='link'}
                        {else}
                            {$link = $ShopURL|cat:'/?s='|cat:$Link->getID()}
                        {/if}
                    {/block}
                {else}
                    {block name='snippets-shipping-calculator-no-shipping-available'}
                        <div class="row">
                            <div class="col">
                                {lang key='noShippingAvailable' section='checkout'}
                            </div>
                        </div>
                    {/block}
                {/if}
            {/block}
        </div>
    {/if}
    {block name='snippets-shipping-calculator-hr-end'}
        {if $hrAtEnd|default:true}
            <hr class="shipping-calculator-hr">
        {/if}
    {/block}
{/block}
