{% sw_extends '@Storefront/storefront/component/address/address-form.html.twig' %}
{% block component_address_form_country_select %}
{% set initialCountry = null %}
{% if data.get('country') %}
{% set initialCountry = data.get('country') %}
{% elseif page.countries|length == 1 %}
{% set initialCountry = (page.countries|first).iso %}
{% endif %}
<select class="country-select custom-select{% if violationPath %} is-invalid{% endif %}"
id="{{ prefix }}AddressCountry"
name="{{ prefix }}[country]"
required="required"
data-initial-country="{{ initialCountry }}">
{% if not initialCountry %}
<option disabled="disabled"
value=""
selected="selected">
{{ "address.countryPlaceholder"|trans|sw_sanitize }}
</option>
{% endif %}
{% set firstCountryId = null %}
{% for country in page.countries %}
{% if firstCountryId == null %}
{% set firstCountryId = country.id %}
{% endif %}
<option {% if country.iso|lower == initialCountry %}
selected="selected"
{% endif %}
value="{{ country.iso|lower }}"
data-vat-id-required="{{ country.vatIdRequired }}"
{% if feature('FEATURE_NEXT_15707') and not country.shippingAvailable and disableNonShippableCountries %}
disabled="disabled"
{% endif %}>
{{ country.translated.name }}{% if feature('FEATURE_NEXT_15707') and showNoShippingPostfix and not country.shippingAvailable %} {{ "address.countryPostfixNoShipping"|trans|sw_sanitize }}{% endif %}
</option>
{% endfor %}
</select>
<input type="hidden" name="{{ prefix }}[countryId]" value="{{ firstCountryId }}">
{% endblock %}