{#if data.title}

{data.title}

{/if} {#if !visibleItems.length}

Nothing is available to book right now — please check back soon.

{/if}
{#each visibleItems as item (item.id)} {@const ui = cardStates[item.id]} {@const itemSlotsByDay = slotsByDay.get(item.id)} {@const isService = item.type === 'item_with_time'} {@const soldOut = !isService && item.stock === 0} {@const itemInBasket = !isService && basket.lines.some((l) => l.item === item.id)}
{#if item.imageUrl} {item.name} {:else} {/if}

{item.name}

{#if item.description}

{item.description}

{/if}
{formatPrice(item.price)} {#if isService && item.duration != null} {item.duration} min {:else if !isService && item.stock != null && item.stock > 0 && item.stock <= 5} Only {item.stock} left {:else if soldOut} Sold out {/if}
{#if ui?.errorMsg} {/if}
{#if isService} {:else} {#if itemInBasket} ✓ In basket {/if} {/if}
{#if isService && ui?.pickerOpen && itemSlotsByDay} {@const availableKeys = [...itemSlotsByDay.keys()].sort()} {@const months = pickerMonths(ui.monthOffset)} {@const shownFrom = months[0].days.find((d) => d.inMonth)!.dateKey} {@const shownTo = months[months.length - 1].days.findLast((d) => d.inMonth)!.dateKey} {@const anyShown = availableKeys.some((key) => key >= shownFrom && key <= shownTo)} {@const lastOffset = monthOffsetOf(availableKeys[availableKeys.length - 1]) - (MONTHS_SHOWN - 1)}

Select a date

{#if !anyShown && availableKeys.length}
{availableKeys[0] > shownTo ? 'The first available date is' : 'The next available date is'} {formatDateKey(availableKeys.find((key) => key > shownTo) ?? availableKeys[0], { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}.
{/if}
{#each months as month (month.label)}

{month.label}

{#each weekdayLetters as letter, i (i)} {letter} {/each} {#each month.days as day (day.dateKey)} {@const selectable = day.inMonth && itemSlotsByDay.has(day.dateKey)} {@const selected = selectable && ui.selectedDayKey === day.dateKey} {/each}
{/each}
{#if ui.selectedDayKey} {@const daySlots = itemSlotsByDay.get(ui.selectedDayKey) ?? []}

Available times · {formatDateKey(ui.selectedDayKey, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })}

{#each daySlots as slot (slot.id)} {@const line = basket.lines.find((l) => l.slot === slot.id)} {@const isGroup = slot.capacity > 1} {@const label = `${formatTime(slot.start)}${item.duration != null ? ` · ${item.duration} min` : ''}`} {#if isGroup && line}
{label} · {placesLeft(slot.free)} {#if ui.pendingSlotId === slot.id}{:else}{line.quantity}{/if} {line.quantity === 1 ? 'place' : 'places'} in your basket
{:else} {/if} {/each}
{:else if anyShown}

Days with availability are highlighted{item.duration != null ? ` · ${item.duration} min per session` : ''}.

{/if} {#if ui.justAdded}

Added ✓ — view basket

{/if}
{/if}
{/each}