{#if isLocationModalOpen} { isLocationModalOpen = false; locationToEdit = null; locationBeingUpdated = null; pendingAddDate = null; addedToItinerary.clear(); addedToItinerary = addedToItinerary; }} {user} {locationToEdit} bind:location={locationBeingUpdated} {collection} initialVisitDate={pendingAddDate} /> {/if} {#if isLodgingModalOpen} { isLodgingModalOpen = false; lodgingToEdit = null; lodgingBeingUpdated = null; pendingAddDate = null; pendingLodgingAddDate = null; addedToItinerary.clear(); addedToItinerary = addedToItinerary; }} {user} {lodgingToEdit} bind:lodging={lodgingBeingUpdated} {collection} initialVisitDate={pendingLodgingAddDate || pendingAddDate} /> {/if} {#if isTransportationModalOpen} { isTransportationModalOpen = false; transportationToEdit = null; transportationBeingUpdated = null; pendingAddDate = null; addedToItinerary.clear(); addedToItinerary = addedToItinerary; }} {user} {transportationToEdit} bind:transportation={transportationBeingUpdated} {collection} initialVisitDate={pendingAddDate} /> {/if} {#if isNoteModalOpen} { pendingAddDate = null; noteToEdit = null; isNoteModalOpen = false; }} {collection} {user} note={noteToEdit} on:create={(e) => void handleNoteUpsert(e.detail)} on:save={(e) => void handleNoteUpsert(e.detail)} initialVisitDate={pendingAddDate} /> {/if} {#if isChecklistModalOpen} { pendingAddDate = null; checklistToEdit = null; isChecklistModalOpen = false; }} {collection} {user} checklist={checklistToEdit} on:create={(e) => void handleChecklistUpsert(e.detail)} on:save={(e) => void handleChecklistUpsert(e.detail)} initialVisitDate={pendingAddDate} /> {/if} {#if isItineraryLinkModalOpen} (isItineraryLinkModalOpen = false)} on:addItem={(e) => { const { type, itemId, updateDate } = e.detail; addItineraryItemForObject(type, itemId, linkModalTargetDate, updateDate); }} /> {/if} {#if isDayPickModalOpen} { isDayPickModalOpen = false; dayPickItemToAdd = null; dayPickScheduledDates = []; dayPickSourceVisit = null; dayPickSourceItineraryItemId = null; }} /> {/if} {#if canAutoGenerate}

{$t('itinerary.auto_generate_itinerary')}

{$t('itinerary.auto_generate_itinerary_desc')}
{/if} {#if days.length === 0 && unscheduledItems.length === 0}

{$t('itinerary.no_itinerary_yet')}

{$t('itinerary.start_planning')}

{:else}
{#if globalItems.length > 0 || canModify}

{$t('itinerary.trip_context') || 'Trip Context'}

{#if globalItems.length === 0}

{$t('itinerary.no_trip_context_items')}

{:else}
{#each globalItems as item (item.id)} {@const objectType = item.item?.type || ''} {@const resolvedObj = item.resolvedObject}
{#if resolvedObj} {#if canModify}
{/if} {#if objectType === 'location'} moveItemToGlobal(e.detail.type, e.detail.id)} {user} {collection} compact={true} showImage={false} /> {:else if objectType === 'transportation'} moveItemToGlobal(e.detail.type, e.detail.id)} /> {:else if objectType === 'lodging'} moveItemToGlobal(e.detail.type, e.detail.id)} /> {:else if objectType === 'note'} moveItemToGlobal(e.detail.type, e.detail.id)} /> {:else if objectType === 'checklist'} moveItemToGlobal(e.detail.type, e.detail.id)} /> {/if} {:else}
⚠️ {$t('itinerary.item_not_found')} (ID: {item.object_id})
{/if}
{/each}
{/if}
{/if} {#each days as day, dayIndex} {@const dayNumber = dayIndex + 1} {@const totalDays = days.length} {@const weekday = DateTime.fromISO(day.date).toFormat('ccc')} {@const dayOfMonth = DateTime.fromISO(day.date).toFormat('d')} {@const monthAbbrev = DateTime.fromISO(day.date).toFormat('LLL')} {@const preTimelineLodging = day.preTimelineLodging} {@const postTimelineLodging = day.postTimelineLodging} {@const dayTimelineItems = getDayTimelineItems(day)} {@const firstConnectableItem = getFirstConnectableItem(day.items)} {@const lastConnectableItem = getLastConnectableItem(day.items)} {@const noLocationsInDay = !firstConnectableItem && !lastConnectableItem} {@const shouldCollapseBoundaryLodging = noLocationsInDay && preTimelineLodging?.id && postTimelineLodging?.id && preTimelineLodging.id === postTimelineLodging.id} {@const startBoundaryConnector = preTimelineLodging && firstConnectableItem ? getLocationConnector(preTimelineLodging, firstConnectableItem) : null} {@const startBoundaryDirectionsUrl = preTimelineLodging && firstConnectableItem ? buildDirectionsUrl( preTimelineLodging, firstConnectableItem, startBoundaryConnector?.mode || 'walking' ) : null} {@const endBoundaryConnector = postTimelineLodging && lastConnectableItem ? getLocationConnector(lastConnectableItem, postTimelineLodging) : null} {@const endBoundaryDirectionsUrl = postTimelineLodging && lastConnectableItem ? buildDirectionsUrl( lastConnectableItem, postTimelineLodging, endBoundaryConnector?.mode || 'walking' ) : null}
{weekday}
{dayOfMonth}
{monthAbbrev}
{formatDayTemperature(day)}

{day.displayDate}

{#if canModify} {#if day.dayMetadata?.name} { const newName = e.currentTarget.value.trim() || null; if (newName !== day.dayMetadata?.name) { saveDayMetadata(day.date, newName, day.dayMetadata?.description || null); } }} /> {:else} { const newName = e.currentTarget.value.trim() || null; if (newName) { saveDayMetadata(day.date, newName, day.dayMetadata?.description || null); } else { e.currentTarget.classList.add('w-0'); e.currentTarget.classList.remove('w-auto'); } }} on:focus={(e) => { e.currentTarget.classList.remove('w-0'); e.currentTarget.classList.add('w-auto'); }} /> {/if} {:else if day.dayMetadata?.name} — {day.dayMetadata.name} {/if}
{$t('calendar.day')} {dayNumber} {$t('worldtravel.of')} {totalDays} {day.items.length} {day.items.length === 1 ? $t('checklist.item') : $t('checklist.items')} {#if day.overnightLodging.length > 0} {$t('adventures.overnight')} {/if}
{#if canModify}