{if !isset($class)}
    {$class = ""}
{/if}
<select id="{$id}" name="{$name}" {tip trigger=$trigger class="lms-ui-customer-address-select {$class}"}>
    <option value="0">—</option>
    {if isset($addresses) && !empty($addresses)}
        {foreach $addresses as $address_id => $address}
            {if $address.location_address_type == $smarty.const.POSTAL_ADDRESS}
                {$icon = "lms-ui-icon-message fa-fw"}
            {elseif $address.location_address_type == $smarty.const.BILLING_ADDRESS}
                {$icon = "lms-ui-icon-home fa-fw"}
            {elseif $address.location_address_type == $smarty.const.LOCATION_ADDRESS}
                {$icon = "lms-ui-icon-customer-location fa-fw"}
            {elseif $address.location_address_type == $smarty.const.DEFAULT_LOCATION_ADDRESS}
                {$icon = "lms-ui-icon-default-customer-location fa-fw"}
            {elseif $address.location_address_type == $smarty.const.RECIPIENT_ADDRESS}
                {$icon = "lms-ui-icon-document fa-fw"}
            {else}
                {$icon = ""}
            {/if}
            <option value="{$address_id}" data-territ="{if empty($address.teryt)}0{else}1{/if}" data-icon="{$icon}"
                    {if (isset($selected_address_id) && $selected_address_id == $address_id)
                        || (!isset($selected_address_id) && (!isset($preselection) || $preselection) && isset($address.default_address))} selected{/if}
            >{if !empty($address.location_name)}{$address.location_name}, {/if}{if !empty($address.location_ten)} {t a=$address.location_ten}TEN $a{/t}, {/if}{location_str($address)|escape}{if !empty($address.teryt)} (TERYT){/if}</option>
        {/foreach}
    {/if}
</select>
