import{r as e}from"./chunk-QTnfLwEv.js";import{n as t}from"./index-7yDgay5u.js";import{i as n,o as r,r as i,t as a}from"./jsx-runtime-DHSfUA5-.js";import{P as o,h as s}from"./test.id-DxQrYxPk.js";import{t as c}from"./diaryService-CNt2_Lb5.js";import{t as l}from"./navigationService-BNBSAd9W.js";import{t as u}from"./PageHeader-CzIJsNRF.js";import{t as d}from"./useAttachmentThumbUrl-D6z1SOlU.js";import{f,o as p}from"./route-CPr17rXr.js";import{a as m,m as h}from"./selectors-DZWoTA9D.js";import{t as g}from"./useDiaryModel-BQGj9xs8.js";import{t as _}from"./CellList-UkuVgkhN.js";import{n as v}from"./useMembershipStatus-CuwuZX56.js";import{t as y}from"./usePickNotebookImageFromAlbum-DN3QeK7W.js";import{t as b}from"./useDialog-CjsjDZgz.js";var x=e(r(),1),S=a();function C(){let{notebookId:e}=f(),r=g(),a=o(c),C=o(l),w=b(),[T,E]=(0,x.useState)(!1),{status:D}=v(),O=e?h(r,e):void 0,k=O?.avatarAttachmentId?m(r,O.avatarAttachmentId):void 0,A=d(k?.type===`image`?k:void 0,{role:`avatar`}),j=O?.chatBackgroundAttachmentId?m(r,O.chatBackgroundAttachmentId):void 0,M=d(j?.type===`image`?j:void 0,{role:`avatar`}),N=y({notebookId:e,onSuccess:(0,x.useCallback)((e,t)=>{a.updateNotebookAvatar(t,e.id)},[a])});if(!O||!e)return T?null:(0,S.jsx)(p,{to:`/diaries`,replace:!0});let P=()=>{E(!0),a.softDeleteNotebook(e),C.navigate({path:`/`,replace:!0})};return(0,S.jsxs)(`div`,{className:n.Page.GroupedRoot,"data-test-id":s.page,children:[(0,S.jsx)(u,{title:t(`diary.settings`,`Notebook settings`),showBack:!0}),(0,S.jsxs)(`main`,{className:i(n.Page.Content,n.Cell.GroupStack),"data-test-id":s.content,children:[(0,S.jsx)(_,{items:[{label:t(`diary.name`,`Notebook name`),right:{type:`value`,text:O.name},testId:s.name,onClick:()=>C.navigate({path:`/diary/${e}/name`})},{label:t(`diary.cover`,`Notebook cover`),right:A?{type:`image`,url:A}:{type:`initial`,text:O.name},testId:s.avatar,disabled:N.uploading,onClick:()=>void N.pick()},{hide:!D.active,label:t(`diary.chatBackground`,`Chat background`),right:M?{type:`image`,url:M}:void 0,testId:s.chatBackground,onClick:()=>C.navigate({path:`/diary/${e}/chat-background`})}]}),(0,S.jsx)(_,{items:[{label:t(`diary.search`,`Find diary content`),testId:s.search,onClick:()=>C.navigate({path:`/diary/${e}/search`})},{label:t(`diary.export.title`,`Export`),testId:s.export,onClick:()=>C.navigate({path:`/diary/${e}/export`})}]}),(0,S.jsx)(_,{items:[{type:`action`,danger:!0,label:t(`diary.deleteNotebook`,`Delete notebook`),testId:s.deleteNotebook,onClick:()=>w({message:t(`diary.deleteNotebookConfirm`,`Delete this notebook? Entries in it will also be removed.`),confirmLabel:t(`common.delete`,`Delete`),cancelLabel:t(`common.cancel`,`Cancel`),rootTestId:s.deleteConfirm,confirmTestId:s.deleteConfirmAction,cancelTestId:s.deleteCancel,onConfirm:P})}]})]})]})}export{C as DiaryChatSettingsPage};
//# sourceMappingURL=settings-8WterI9r.js.map