{#if isShowingLinkModal} { isShowingLinkModal = false; }} on:add={addAdventure} /> {/if} {#if isShowingTransportationModal} (isShowingTransportationModal = false)} on:save={saveOrCreateTransportation} {collection} /> {/if} {#if isAdventureModalOpen} (isAdventureModalOpen = false)} on:save={saveOrCreateAdventure} {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 !collection && !notFound}
{/if} {#if collection} {#if data.user && data.user.uuid && (data.user.uuid == collection.user_id || (collection.shared_with && 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 && !collection.start_date && adventures.length == 0 && transportations.length == 0 && notes.length == 0 && checklists.length == 0} {/if} {#if collection.description}
{@html renderMarkdown(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 collection.id} {/if} {#if currentView == 'all'} {#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={editTransportation} {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 adventures.length == 0 && transportations.length == 0 && notes.length == 0 && checklists.length == 0} {/if} {/if} {#if collection.start_date && collection.end_date} {#if currentView == 'itinerary'}

{$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; isShowingTransportationModal = 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}
{/if} {/if} {#if currentView == 'map'}

Trip Map

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

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

{/if} {/each} {#each transportations as transportation} {#if transportation.destination_latitude && transportation.destination_longitude} {getTransportationEmoji(transportation.type)}
{transportation.name}

{transportation.type}

{/if} {#if transportation.origin_latitude && transportation.origin_longitude} {getTransportationEmoji(transportation.type)}
{transportation.name}

{transportation.type}

{/if} {/each}
{/if} {#if currentView == 'calendar'}

{$t('adventures.adventure_calendar')}

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