{#if readOnly && ownerName} {ownerName} {:else} {t.period_tracker} {/if}

{#if ongoing}
{t.current_period} {t.period_day} {ongoingDay} {#if showProjection && predictions.predictedEndOfOngoing} {t.predicted_end} {relativeDate(predictions.predictedEndOfOngoing)} {formatDate(predictions.predictedEndOfOngoing)} {/if} {#if showEntry && !readOnly} {/if}
{#if showProjection && nextCycle}
{t.ovulation} {relativeDate(nextCycle.ovulation)} {formatDate(nextCycle.ovulation)}
{t.fertile} {formatDate(nextCycle.fertileStart)} — {formatDate(nextCycle.fertileEnd)}
{/if}
{:else if showProjection && nextCycle}
{t.next_period} {relativeRange(nextCycle.start, nextCycle.end)} {formatDate(nextCycle.start)} — {formatDate(nextCycle.end)} {#if showEntry && !readOnly} {/if}
{t.ovulation} {relativeDate(nextCycle.ovulation)} {formatDate(nextCycle.ovulation)}
{t.fertile} {formatDate(nextCycle.fertileStart)} — {formatDate(nextCycle.fertileEnd)}
{:else if showEntry}
{sorted.length === 0 ? t.no_period_data : t.no_active_period} {#if !readOnly} {/if}
{/if}
{#if showProjection}
{calendarLabel} {#if calendarOffset !== 0} {/if}
{#each weekDays as wd} {wd} {/each}
{#each calendarDays as cell} {@const startable = canStartOn(cell)} promptStartPeriodOn(cell.date))} >{cell.day} {/each}
{lang === 'de' ? 'Periode' : 'Period'} {lang === 'de' ? 'Prognose' : 'Predicted'} {t.fertile} {t.peak_fertility} {t.ovulation} {t.luteal_phase}
{/if} {#if showProjection && completed.length >= 2}
{t.cycle_length} {Math.round(predictions.avgCycle)} {t.days} {#if predictions.cycleVariance > 0} ± {predictions.cycleVariance} {t.days} (95% CI) {/if}
{t.period_length} {Math.round(predictions.avgPeriod)} {t.days} {#if predictions.periodVariance > 0} ± {predictions.periodVariance} {t.days} (95% CI) {/if}
{/if} {#if showEntry && !readOnly} {#if sorted.length > 0}
{#if showHistory}
{#if showAddForm}
{/if}
{#each sorted as p (p._id)} {#if editId === p._id}
{:else}
{formatDate(p.startDate)} {#if p.endDate} — {formatDate(p.endDate)} {:else} {t.ongoing} {/if} {#if p.endDate} {@const dur = Math.round((new Date(p.endDate).getTime() - new Date(p.startDate).getTime()) / 86400000) + 1} {dur} {t.days} {/if}
{/if} {/each}
{/if}
{:else}
{#if showAddForm}
{/if}
{/if} {/if}
{#if showShare}
showShare = false} onkeydown={(e) => e.key === 'Escape' && (showShare = false)}>
{/if}