<div class="storefront-metrics-widget" ...attributes>
    <div class="flex items-center justify-between">
        <div class="flex items-center pl-1.5">
            <h3 class="text-base font-semibold tracking-wide uppercase text-gray-700 dark:text-gray-400">
                Metrics
            </h3>
            {{#if this.loadMetrics.isRunning}}
                <div>
                    <Spinner class="text-sky-400" />
                </div>
            {{/if}}
        </div>
        <div class="storefront-datepicker">
            <DatePicker
                @value={{concat this.start "," this.end}}
                @range={{true}}
                @buttons={{this.datePickerButtons}}
                @onSelect={{this.selectDates}}
                placeholder="Select date range"
                class="min-w-250px"
            />
        </div>
    </div>
    <dl class="mt-4 grid grid-cols-2 gap-5 sm:grid-cols-4">
        <div class="px-4 py-5 border border-gray-200 dark:border-gray-900 bg-gray-50 dark:bg-gray-700 shadow-sm dark:shadow rounded-lg overflow-hidden sm:p-6">
            <dt class="text-sm font-medium text-gray-500 dark:text-gray-100 truncate">
                {{t "storefront.common.orders"}}
            </dt>
            <dd class="mt-1 text-3xl font-semibold text-gray-800 dark:text-white">
                {{this.metrics.orders_count}}
            </dd>
        </div>

        <div class="px-4 py-5 border border-gray-200 dark:border-gray-900 bg-gray-50 dark:bg-gray-700 shadow-sm dark:shadow rounded-lg overflow-hidden sm:p-6">
            <dt class="text-sm font-medium text-gray-500 dark:text-gray-100 truncate">
                {{t "storefront.common.customers"}}
            </dt>
            <dd class="mt-1 text-3xl font-semibold text-gray-800 dark:text-white">
                {{this.metrics.customers_count}}
            </dd>
        </div>

        <div class="px-4 py-5 border border-gray-200 dark:border-gray-900 bg-gray-50 dark:bg-gray-700 shadow-sm dark:shadow rounded-lg overflow-hidden sm:p-6">
            <dt class="text-sm font-medium text-gray-500 dark:text-gray-100 truncate">
                {{pluralize this.metrics.stores_count (t "storefront.common.store") without-count=true}}
            </dt>
            <dd class="mt-1 text-3xl font-semibold text-gray-800 dark:text-white">
                {{this.metrics.stores_count}}
            </dd>
        </div>

        <div class="px-4 py-5 border border-gray-200 dark:border-gray-900 bg-gray-50 dark:bg-gray-700 shadow-sm dark:shadow rounded-lg overflow-hidden sm:p-6">
            <dt class="text-sm font-medium text-gray-500 dark:text-gray-100 truncate">
                {{t "storefront.common.earning"}}
            </dt>
            <dd class="mt-1 text-3xl font-semibold text-gray-800 dark:text-white">
                {{format-currency this.metrics.earnings_sum this.metrics.currency}}
            </dd>
        </div>
    </dl>
</div>