{#if isShowingLinkModal} { isShowingLinkModal = false; }} on:add={addAdventure} /> {/if} {#if isTransportationEditModalOpen} (isTransportationEditModalOpen = false)} on:saveEdit={saveNewTransportation} startDate={collection.start_date} endDate={collection.end_date} /> {/if} {#if isAdventureModalOpen} (isAdventureModalOpen = false)} on:save={saveOrCreate} {collection} /> {/if} {#if isNoteModalOpen} (isNoteModalOpen = false)} {collection} on:save={(event) => { notes = notes.map((note) => { if (note.id === event.detail.id) { return event.detail; } return note; }); isNoteModalOpen = false; }} on:close={() => (isNoteModalOpen = false)} on:create={(event) => { notes = [event.detail, ...notes]; isNoteModalOpen = false; }} /> {/if} {#if isShowingChecklistModal} (isShowingChecklistModal = false)} on:create={(event) => { checklists = [event.detail, ...checklists]; isShowingChecklistModal = false; }} on:save={(event) => { checklists = checklists.map((checklist) => { if (checklist.id === event.detail.id) { return event.detail; } return checklist; }); isShowingChecklistModal = false; }} /> {/if} {#if isShowingTransportationModal} (isShowingTransportationModal = false)} on:add={(event) => { transportations = [event.detail, ...transportations]; isShowingTransportationModal = false; }} {collection} startDate={collection.start_date} endDate={collection.end_date} /> {/if} {#if notFound}
Lost

{$t('adventures.not_found')}

{$t('adventures.not_found_desc')}

{/if} {#if !collection && !notFound}
{/if} {#if collection} {#if data.user && data.user.uuid && (data.user.uuid == collection.user_id || collection.shared_with.includes(data.user.uuid)) && !collection.is_archived}
{/if} {#if collection.is_archived}
{/if} {#if collection.name}

{collection.name}

{/if} {#if collection.link} {/if} {#if collection.description}

{collection.description}

{/if} {#if adventures.length > 0}
{$t('adventures.collection_stats')}
{numVisited}/{numAdventures} Visited
{#if numAdventures === numVisited}
{$t('adventures.collection_completed')}
{:else}
{$t('adventures.keep_exploring')}
{/if}
{/if} {#if adventures.length == 0 && transportations.length == 0 && notes.length == 0 && checklists.length == 0} {/if} {#if adventures.length > 0}

{$t('adventures.linked_adventures')}

{#each adventures as adventure} {/each}
{/if} {#if transportations.length > 0}

{$t('adventures.transportations')}

{#each transportations as transportation} { transportations = transportations.filter((t) => t.id != event.detail); }} on:edit={(event) => { transportationToEdit = event.detail; isTransportationEditModalOpen = true; }} {collection} /> {/each}
{/if} {#if notes.length > 0}

{$t('adventures.notes')}

{#each notes as note} { noteToEdit = event.detail; isNoteModalOpen = true; }} on:delete={(event) => { notes = notes.filter((n) => n.id != event.detail); }} {collection} /> {/each}
{/if} {#if checklists.length > 0}

{$t('adventures.checklists')}

{#each checklists as checklist} { checklists = checklists.filter((n) => n.id != event.detail); }} on:edit={(event) => { checklistToEdit = event.detail; isShowingChecklistModal = true; }} {collection} /> {/each}
{/if} {#if collection.start_date && collection.end_date}

{$t('adventures.itineary_by_date')}

{#if numberOfDays}

{$t('adventures.duration')}: {numberOfDays} {$t('adventures.days')}

{/if}

Dates: {new Date(collection.start_date).toLocaleDateString(undefined, { timeZone: 'UTC' })} - {new Date( collection.end_date ).toLocaleDateString(undefined, { timeZone: 'UTC' })}

{#each Array(numberOfDays) as _, i} {@const startDate = new Date(collection.start_date)} {@const tempDate = new Date(startDate.getTime())} {@const adjustedDate = new Date(tempDate.setUTCDate(tempDate.getUTCDate() + i))} {@const dateString = adjustedDate.toISOString().split('T')[0]} {@const dayAdventures = groupAdventuresByDate(adventures, new Date(collection.start_date), numberOfDays)[ dateString ] || []} {@const dayTransportations = groupTransportationsByDate(transportations, new Date(collection.start_date), numberOfDays)[ dateString ] || []} {@const dayNotes = groupNotesByDate(notes, new Date(collection.start_date), numberOfDays)[dateString] || []} {@const dayChecklists = groupChecklistsByDate(checklists, new Date(collection.start_date), numberOfDays)[ dateString ] || []}

{$t('adventures.day')} {i + 1}

{adjustedDate.toLocaleDateString(undefined, { timeZone: 'UTC' })}

{#if dayAdventures.length > 0} {#each dayAdventures as adventure} {/each} {/if} {#if dayTransportations.length > 0} {#each dayTransportations as transportation} { transportations = transportations.filter((t) => t.id != event.detail); }} on:edit={(event) => { transportationToEdit = event.detail; isTransportationEditModalOpen = true; }} /> {/each} {/if} {#if dayNotes.length > 0} {#each dayNotes as note} { noteToEdit = event.detail; isNoteModalOpen = true; }} on:delete={(event) => { notes = notes.filter((n) => n.id != event.detail); }} /> {/each} {/if} {#if dayChecklists.length > 0} {#each dayChecklists as checklist} { notes = notes.filter((n) => n.id != event.detail); }} on:edit={(event) => { checklistToEdit = event.detail; isShowingChecklistModal = true; }} /> {/each} {/if} {#if dayAdventures.length == 0 && dayTransportations.length == 0 && dayNotes.length == 0 && dayChecklists.length == 0}

{$t('adventures.nothing_planned')}

{/if}
{/each} {#each adventures as adventure} {#if adventure.longitude && adventure.latitude}
{adventure.name}

{adventure.category?.display_name + ' ' + adventure.category?.icon}

{/if} {/each}
{/if} {/if} {data.props.adventure && data.props.adventure.name ? `${data.props.adventure.name}` : $t('adventures.collection')}