import{r as e}from"./chunk-QTnfLwEv.js";import{n as t}from"./index-7yDgay5u.js";import{o as n,t as r}from"./jsx-runtime-DHSfUA5-.js";import{P as i,p as a}from"./test.id-DxQrYxPk.js";import{t as o}from"./diaryService-CNt2_Lb5.js";import{t as s}from"./navigationService-BNBSAd9W.js";import{f as c,o as l}from"./route-CPr17rXr.js";import{t as u}from"./useSuccessToast-CW8oLO3e.js";import{m as d}from"./selectors-DZWoTA9D.js";import{t as f}from"./useDiaryModel-BQGj9xs8.js";import{t as p}from"./HeaderPage-CPQpvQQw.js";import{t as m}from"./TextInputRow-DqOYjq7o.js";var h=e(n(),1),g=r();function _(){let{notebookId:e}=c(),n=f(),r=i(o),_=i(s),v=u(),y=e?d(n,e):void 0,[b,x]=(0,h.useState)(y?.name??``),S=b.trim(),C=S.length>0&&e;return!y||!e?(0,g.jsx)(l,{to:`/diaries`,replace:!0}):(0,g.jsx)(p,{pageTestId:a.page,contentTestId:a.content,header:{title:t(`diary.name`,`Notebook name`),showBack:!0,right:{type:`button`,label:t(`common.save`,`Save`),disabled:!C,testId:a.save,onClick:()=>{try{r.updateNotebookName(e,S)}catch{v({message:t(`diary.name.duplicate`,`A notebook with this name already exists`),icon:`none`,testId:a.duplicateToast});return}_.goBack()}}},children:(0,g.jsx)(m,{id:`notebookName`,testId:a.nameInput,autoFocus:!0,placeholder:t(`diary.name`,`Notebook name`),value:b,onChange:x})})}export{_ as DiaryChatNamePage};
//# sourceMappingURL=name-CC8oHNKv.js.map