import"./chunk-QTnfLwEv.js";import{m as e,n as t,p as n,x as r}from"./index-7yDgay5u.js";import{i,o as a,r as o,t as s}from"./jsx-runtime-DHSfUA5-.js";import{P as c,d as l}from"./test.id-DxQrYxPk.js";import{t as u}from"./diaryService-CNt2_Lb5.js";import{n as d}from"./fileAssetService-gA4Q8V3n.js";import{t as f}from"./use-watch-event-Bmff5Oxc.js";import{t as p}from"./navigationService-BNBSAd9W.js";import{t as m}from"./BottomTabBar-CgZg3kJ3.js";import{t as h}from"./PageHeader-CzIJsNRF.js";import{n as g,t as _}from"./CoverThumb-BNESRCXk.js";import{T as v,_ as y,a as b,h as x,l as S,p as C,w}from"./selectors-DZWoTA9D.js";import{t as T}from"./useDiaryModel-BQGj9xs8.js";function E(e,t,n){let[i,a]=r(n?.in,e,t);return i.getFullYear()===a.getFullYear()}function D(t){let r=t.locale??n(),i=k(t.timestamp,t.timezone),a=k(t.currenttime,t.timezone),o=e(r);return v(i,a)?w(i,`HH:mm`,{locale:o}):E(i,a)?w(i,A(r,!1),{locale:o}):w(i,A(r,!0),{locale:o})}function O(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function k(e,t){let n=e instanceof Date?e:new Date(e),r=new Intl.DateTimeFormat(`en-US`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).formatToParts(n),i=new Map(r.map(e=>[e.type,e.value]));return new Date(Number(i.get(`year`)),Number(i.get(`month`))-1,Number(i.get(`day`)),Number(i.get(`hour`)),Number(i.get(`minute`)),Number(i.get(`second`)))}function A(e,t){let n=new Intl.DateTimeFormat(e,{timeZone:`UTC`,year:`numeric`,month:`2-digit`,day:`2-digit`}).formatToParts(new Date(Date.UTC(2026,10,22))).map(e=>e.type).filter(e=>e===`year`||e===`month`||e===`day`),r={year:`yyyy`,month:`MM`,day:`dd`},i=e===`en-US`?`/`:`-`;return n.filter(e=>t||e!==`year`).map(e=>r[e]).join(i)}a();var j=s();function M({model:e,notebook:n,onClick:r}){let a=S(e,C(e,n.id)),o=x(e,n),s=n.avatarAttachmentId?b(e,n.avatarAttachmentId):void 0,c=s?.type===`image`?s:void 0;return(0,j.jsxs)(`button`,{className:i.NotebookItem.Root,type:`button`,"data-test-id":l.notebookItem,onClick:r,children:[c?(0,j.jsx)(_,{attachment:c,className:i.NotebookItem.Cover}):(0,j.jsx)(g,{name:n.name,className:i.NotebookItem.Cover,textClassName:i.NotebookItem.CoverText}),(0,j.jsxs)(`div`,{className:i.NotebookItem.Body,children:[(0,j.jsx)(`div`,{className:i.NotebookItem.TitleRow,children:(0,j.jsx)(`span`,{className:i.NotebookItem.Name,"data-test-id":l.notebookName,children:n.name})}),(0,j.jsx)(`div`,{className:i.NotebookItem.Summary,children:a||t(`diary.notebook.emptySummary`,`No entries yet`)})]}),(0,j.jsx)(`span`,{className:i.NotebookItem.Time,children:o>0&&D({timestamp:o,currenttime:Date.now(),timezone:O()})})]})}function N(){let e=T(),n=c(p),r=c(u),a=c(d);f(r.onSyncStateChange),f(a.onDidChangeConfig);let s=y(e),g=!!a.getSyncConfig()?.recoveryKey,_=r.isSyncing;return(0,j.jsxs)(`div`,{className:i.Page.Root,"data-test-id":l.page,children:[(0,j.jsx)(h,{title:t(`diary.notebooks`,`Diaries`),left:{type:`icon`,icon:`refresh`,label:t(`common.sync`,`Sync`),hide:!g,loading:_,testId:l.sync,onClick:()=>void r.syncNow()},right:{type:`icon`,icon:`plus`,label:t(`diary.addNotebook`,`New notebook`),testId:l.addNotebook,onClick:()=>n.navigate({path:`/diaries/new`})}}),(0,j.jsx)(`main`,{className:o(i.Page.ContentTabbed,i.DiaryListPage.Content),"data-test-id":l.content,children:(0,j.jsx)(`div`,{className:i.Cell.InsetGroup,"data-test-id":l.list,children:s.map(t=>(0,j.jsx)(M,{model:e,notebook:t,onClick:()=>n.navigate({path:`/diary/${t.id}`})},t.id))})}),(0,j.jsx)(m,{active:`diary`})]})}export{N as DiariesPage};
//# sourceMappingURL=diaries-CrGdoWaJ.js.map