<?php
/**
 * Hyvä Themes - https://hyva.io
 * Copyright © Hyvä Themes 2020-present. All rights reserved.
 * This product is licensed per Magento install
 * See https://hyva.io/license
 */

declare(strict_types=1);

use Magento\Catalog\Block\Product\ProductList\Toolbar;
use Magento\Framework\Escaper;

/** @var Toolbar $block */
/** @var Escaper $escaper */
?>
<div class="toolbar-sorter sorter flex items-center order-3 md:w-1/3 md:justify-end">
    <span class="sr-only sorter-label">
        <?= $escaper->escapeHtml(__('Sort By')) ?>
    </span>
    <select data-role="sorter"
            class="border-none focus:ring-0 text-center bg-auto pr-12 pl-0 py-0"
            aria-label="<?= $escaper->escapeHtml(__('Sort By')) ?>"
            @change="changeUrl(
                'product_list_order',
                $event.currentTarget.options[$event.currentTarget.selectedIndex].value,
                options.orderDefault
            )">
        <?php foreach ($block->getAvailableOrders() as $orderCode => $orderLabel):?>
            <option value="<?= $escaper->escapeHtmlAttr($orderCode) ?>" class="font-normal text-black text-base tracking-wider leading-4 text-left" <?php if ($block->isOrderCurrent($orderCode)):?>
                    selected="selected"
                <?php endif; ?>
                >
                <?= $escaper->escapeHtml(__($orderLabel)) ?>
            </option>
        <?php endforeach; ?>
    </select>
</div>
