tmex-cli 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/runtime/server.js +1339 -135
- package/package.json +4 -3
- package/resources/fe-dist/assets/DevicePage-B2xsa-ys.js +21 -0
- package/resources/fe-dist/assets/DevicesPage-Bm7E9QAf.js +2 -0
- package/resources/fe-dist/assets/FilePage-DtXS6Krk.js +16 -0
- package/resources/fe-dist/assets/SettingsPage-Bxat-d_V.js +32 -0
- package/resources/fe-dist/assets/{arc-Wv219fq_.js → arc-CWkT1O24.js} +2 -2
- package/resources/fe-dist/assets/{architectureDiagram-3BPJPVTR-DkPPo2hY.js → architectureDiagram-3BPJPVTR-nu1LX68y.js} +2 -2
- package/resources/fe-dist/assets/{blockDiagram-GPEHLZMM-DPAThozG.js → blockDiagram-GPEHLZMM-DLFLNzT_.js} +2 -2
- package/resources/fe-dist/assets/{c4Diagram-AAUBKEIU-DBs_N-_p.js → c4Diagram-AAUBKEIU-BE8aWxc1.js} +2 -2
- package/resources/fe-dist/assets/{card-Dl0HC88A.js → card-Duis2VHj.js} +2 -2
- package/resources/fe-dist/assets/channel-zKL2OH3S.js +2 -0
- package/resources/fe-dist/assets/{chunk-2J33WTMH-D3mrUPCp.js → chunk-2J33WTMH-Dlc3MV0y.js} +2 -2
- package/resources/fe-dist/assets/{chunk-4BX2VUAB-C0DRv58j.js → chunk-4BX2VUAB-E9XGobks.js} +2 -2
- package/resources/fe-dist/assets/{chunk-55IACEB6-DheUp7iQ.js → chunk-55IACEB6-Bp7ueFZf.js} +2 -2
- package/resources/fe-dist/assets/{chunk-727SXJPM-Cvew2yIJ.js → chunk-727SXJPM-CQrvyHfQ.js} +2 -2
- package/resources/fe-dist/assets/{chunk-AQP2D5EJ-DUoa4Wdg.js → chunk-AQP2D5EJ-c0B1XNZr.js} +2 -2
- package/resources/fe-dist/assets/{chunk-FMBD7UC4-Bt9Oi52P.js → chunk-FMBD7UC4-BWQBkKWs.js} +2 -2
- package/resources/fe-dist/assets/{chunk-ND2GUHAM-DlWpyDaS.js → chunk-ND2GUHAM-D9TROogS.js} +2 -2
- package/resources/fe-dist/assets/{chunk-QZHKN3VN-BZtXwgRW.js → chunk-QZHKN3VN-DRXr6zVP.js} +2 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-Drw216KI.js +2 -0
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-Drw216KI.js +2 -0
- package/resources/fe-dist/assets/{cose-bilkent-S5V4N54A-yKy6sTY_.js → cose-bilkent-S5V4N54A-CBgJRn7g.js} +2 -2
- package/resources/fe-dist/assets/{dagre-BM42HDAG-DL4fpno6.js → dagre-BM42HDAG-ClYznWvX.js} +2 -2
- package/resources/fe-dist/assets/{diagram-2AECGRRQ-BueYws-9.js → diagram-2AECGRRQ-Br_41uIc.js} +2 -2
- package/resources/fe-dist/assets/{diagram-5GNKFQAL-GQEQSUeb.js → diagram-5GNKFQAL-BD9o1BrS.js} +2 -2
- package/resources/fe-dist/assets/{diagram-KO2AKTUF-LE3yI4ed.js → diagram-KO2AKTUF-Diq2zS9Y.js} +2 -2
- package/resources/fe-dist/assets/{diagram-LMA3HP47-BkHjYrU4.js → diagram-LMA3HP47-CLaOalPy.js} +2 -2
- package/resources/fe-dist/assets/{diagram-OG6HWLK6-DrnHic-P.js → diagram-OG6HWLK6-BcSlvdPy.js} +2 -2
- package/resources/fe-dist/assets/{erDiagram-TEJ5UH35-BCwWv-rO.js → erDiagram-TEJ5UH35-BNlad0c4.js} +2 -2
- package/resources/fe-dist/assets/{flowDiagram-I6XJVG4X-DEC2Z_fh.js → flowDiagram-I6XJVG4X-Zb1FLY00.js} +2 -2
- package/resources/fe-dist/assets/{ganttDiagram-6RSMTGT7-H1T5bCsY.js → ganttDiagram-6RSMTGT7-DPRPR5Is.js} +2 -2
- package/resources/fe-dist/assets/{gitGraphDiagram-PVQCEYII-DmZUfKfl.js → gitGraphDiagram-PVQCEYII-BENU2uEN.js} +2 -2
- package/resources/fe-dist/assets/index-CRCD4gPw.css +1 -0
- package/resources/fe-dist/assets/index-Den36xcn.js +488 -0
- package/resources/fe-dist/assets/{infoDiagram-5YYISTIA-fDOg9Qr5.js → infoDiagram-5YYISTIA-NfMlH21e.js} +2 -2
- package/resources/fe-dist/assets/{ishikawaDiagram-YF4QCWOH-QIvSJI3q.js → ishikawaDiagram-YF4QCWOH-CzK9-7uY.js} +2 -2
- package/resources/fe-dist/assets/{journeyDiagram-JHISSGLW-Iz7u4iH8.js → journeyDiagram-JHISSGLW-CIX5Ahuw.js} +2 -2
- package/resources/fe-dist/assets/{kanban-definition-UN3LZRKU-BYiFSFgn.js → kanban-definition-UN3LZRKU-C5Ccl5Cw.js} +2 -2
- package/resources/fe-dist/assets/{linear-DNHZFKop.js → linear-CBC08yeS.js} +2 -2
- package/resources/fe-dist/assets/markdown-preview-Bf_6UH9R.css +1 -0
- package/resources/fe-dist/assets/markdown-preview-Drd503bU.js +269 -0
- package/resources/fe-dist/assets/{mermaid.core-DUipsjFg.js → mermaid.core-DYl6mxS0.js} +6 -6
- package/resources/fe-dist/assets/{mindmap-definition-RKZ34NQL-tPbrKC3m.js → mindmap-definition-RKZ34NQL-ACR2SUDm.js} +2 -2
- package/resources/fe-dist/assets/{pieDiagram-4H26LBE5-26o8qBzb.js → pieDiagram-4H26LBE5-BuDDdwwy.js} +2 -2
- package/resources/fe-dist/assets/{quadrantDiagram-W4KKPZXB-BgpGo9Ak.js → quadrantDiagram-W4KKPZXB-CzM2Ydhy.js} +2 -2
- package/resources/fe-dist/assets/{refresh-cw-DdcimDhs.js → refresh-cw-DhzvbVDA.js} +2 -2
- package/resources/fe-dist/assets/{requirementDiagram-4Y6WPE33-BEfrxsDZ.js → requirementDiagram-4Y6WPE33-BveKh_kW.js} +2 -2
- package/resources/fe-dist/assets/{sankeyDiagram-5OEKKPKP-BuIeHyjh.js → sankeyDiagram-5OEKKPKP-BGQ6jtyE.js} +2 -2
- package/resources/fe-dist/assets/{sequenceDiagram-3UESZ5HK-CL0sinOn.js → sequenceDiagram-3UESZ5HK-D2fdqire.js} +2 -2
- package/resources/fe-dist/assets/{stateDiagram-AJRCARHV-BCq5X6hO.js → stateDiagram-AJRCARHV-DtuVBIq9.js} +2 -2
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-gun__PvU.js +2 -0
- package/resources/fe-dist/assets/{timeline-definition-PNZ67QCA-CnqqA91O.js → timeline-definition-PNZ67QCA-Dslo0JFS.js} +2 -2
- package/resources/fe-dist/assets/{vennDiagram-CIIHVFJN-BqFG3JXB.js → vennDiagram-CIIHVFJN-BLcoN4xU.js} +2 -2
- package/resources/fe-dist/assets/{wardley-L42UT6IY-DvfZKNwT.js → wardley-L42UT6IY-OsbD5r1L.js} +2 -2
- package/resources/fe-dist/assets/{wardleyDiagram-YWT4CUSO-DlABpMGt.js → wardleyDiagram-YWT4CUSO-B_33zIif.js} +2 -2
- package/resources/fe-dist/assets/{xychartDiagram-2RQKCTM6-BDiyUuus.js → xychartDiagram-2RQKCTM6-DcB27Ap1.js} +2 -2
- package/resources/fe-dist/fonts/GeistMonoNerdFontMono-Bold.woff2 +0 -0
- package/resources/fe-dist/fonts/GeistMonoNerdFontMono-Regular.woff2 +0 -0
- package/resources/fe-dist/index.html +2 -2
- package/resources/fe-dist/tmex-maskable.png +0 -0
- package/resources/fe-dist/tmex.png +0 -0
- package/resources/fe-dist/assets/DevicePage-5vkaNOjl.js +0 -26
- package/resources/fe-dist/assets/DevicesPage-CKnRUGQm.js +0 -2
- package/resources/fe-dist/assets/FilePage-Dj0cszD4.css +0 -1
- package/resources/fe-dist/assets/FilePage-Uj-tzGW7.js +0 -283
- package/resources/fe-dist/assets/SettingsPage-Cfzr_Phh.js +0 -22
- package/resources/fe-dist/assets/channel-DyLhDM_y.js +0 -2
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-DA8DiM06.js +0 -2
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-DA8DiM06.js +0 -2
- package/resources/fe-dist/assets/index-OpBFduyh.js +0 -466
- package/resources/fe-dist/assets/index-yMgNjHUH.css +0 -1
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-DH2ctCND.js +0 -2
- package/resources/fe-dist/fonts/GeistMono-Bold.woff2 +0 -0
- package/resources/fe-dist/fonts/GeistMono-Regular.woff2 +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import{Y as U,u as F,j as e,L as Ye,M as ze,z as es,r as j,c as K,B as w,P as de,a as M,e as k,o as y,aw as Ve,ax as we,ay as ss,ap as A,v as Ne,T as O,A as z,f as V,g as H,h as ts,i as J,k as W,l as G,m as Z,n as X,az as as,C as Y,F as ee,H as se,I as te,J as me,N as ae,O as ne,Q as ie,R as re,U as Q,K as P,W as he,ao as q,G as ns,aA as is,x as He,a9 as rs,b as ue,t as ke,aq as ls,aB as os,aC as cs,aj as De,aD as ds,aE as ms,aF as hs,aG as us,aH as gs,aI as xs,aJ as ps,aK as Be,aL as fs}from"./index-Den36xcn.js";import{C as $,b as _,c as R,d as js,a as D}from"./card-Duis2VHj.js";import{R as Je}from"./refresh-cw-DhzvbVDA.js";import{M as ys}from"./markdown-preview-Drd503bU.js";/**
|
|
2
|
+
* @license lucide-react v0.564.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const vs=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],ws=U("boxes",vs);/**
|
|
7
|
+
* @license lucide-react v0.564.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const bs=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Ns=U("rotate-ccw",bs);/**
|
|
12
|
+
* @license lucide-react v0.564.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ks=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],L=U("save",ks);/**
|
|
17
|
+
* @license lucide-react v0.564.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Cs=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],Ss=U("server",Cs);/**
|
|
22
|
+
* @license lucide-react v0.564.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Es=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],_e=U("shield",Es);/**
|
|
27
|
+
* @license lucide-react v0.564.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Fs=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],Ps=U("users",Fs);function Ts(){const{t:s}=F();return e.jsxs($,{className:"border-0 ring-0",children:[e.jsxs(_,{children:[e.jsx(R,{children:s("settings.deviceManagement.title")}),e.jsx(js,{children:s("settings.deviceManagement.description")})]}),e.jsx(D,{children:e.jsxs(Ye,{to:"/devices","data-testid":"settings-device-management-link",className:es({variant:"secondary"}),children:[e.jsx(ze,{className:"h-4 w-4"}),s("settings.deviceManagement.openButton")]})})]})}function ce({type:s,className:a}){return s==="ssh"?e.jsx(ns,{className:a}):e.jsx(ze,{className:a})}function Ms(){var d,v;const{t:s}=F(),[a,t]=j.useState(!1),[n,r]=j.useState(void 0),m=K({queryKey:["files","roots"],queryFn:is}),p=K({queryKey:["devices"],queryFn:async()=>{const l=await fetch("/api/devices");if(!l.ok)throw new Error(`HTTP ${l.status}`);return await l.json()},throwOnError:!1}),x=((d=m.data)==null?void 0:d.roots)??[],i=((v=p.data)==null?void 0:v.devices)??[],c=()=>{r(void 0),t(!0)},f=l=>{r(l),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs($,{className:"border-0 ring-0","data-testid":"settings-files-section",children:[e.jsxs(_,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(R,{children:s("settings.files.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("settings.files.description")})]}),e.jsxs(w,{variant:"secondary","data-testid":"settings-files-root-add",onClick:c,children:[e.jsx(de,{className:"h-4 w-4"}),s("settings.files.addRoot")]})]}),e.jsxs(D,{className:"space-y-3",children:[m.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!m.isLoading&&x.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"settings-files-empty",children:s("settings.files.empty")}),x.map(l=>e.jsx(As,{root:l,onEdit:f},l.id))]})]}),e.jsx(Ks,{open:a,onOpenChange:t,root:n,devices:i})]})}function As({root:s,onEdit:a}){const{t}=F(),n=M(),[r,m]=j.useState(!1),p=k({mutationFn:({id:i,enabled:c})=>Ve(i,{enabled:c}),onSuccess:async()=>{await n.invalidateQueries({queryKey:["files"]})},onError:()=>{y.error(t("settings.files.toggleFailed"))}}),x=k({mutationFn:i=>ss(i),onSuccess:async()=>{await n.invalidateQueries({queryKey:["files"]}),y.success(t("common.success"))},onError:i=>{const c=i instanceof we?i.message:t("settings.files.deleteFailed");y.error(c)}});return e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border p-3","data-testid":`settings-files-root-${s.id}`,children:[e.jsx(A,{checked:s.enabled,disabled:p.isPending,onCheckedChange:i=>p.mutate({id:s.id,enabled:!!i}),"data-testid":`settings-files-root-enabled-${s.id}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(ce,{type:s.deviceType,className:"h-3.5 w-3.5 shrink-0"}),s.deviceName===null?e.jsx("span",{className:"text-destructive",children:t("settings.files.missing")}):e.jsx("span",{className:"truncate",children:s.deviceName})]}),e.jsx("div",{className:"truncate font-mono text-xs",children:s.path}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:s.name})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.edit"),"data-testid":`settings-files-root-edit-${s.id}`,onClick:()=>a(s),children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.delete"),"data-testid":`settings-files-root-delete-${s.id}`,onClick:()=>m(!0),disabled:x.isPending,children:e.jsx(O,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(z,{open:r,onOpenChange:m,children:e.jsxs(V,{children:[e.jsxs(H,{children:[e.jsx(ts,{className:"bg-destructive/10",children:e.jsx(O,{className:"h-5 w-5 text-destructive"})}),e.jsx(J,{children:t("settings.files.deleteTitle")}),e.jsx(W,{children:t("settings.files.deleteDesc",{path:s.path})})]}),e.jsxs(G,{children:[e.jsx(Z,{children:t("common.cancel")}),e.jsx(X,{variant:"destructive","data-testid":`settings-files-root-delete-confirm-${s.id}`,onClick:()=>{x.mutate(s.id),m(!1)},children:t("common.delete")})]})]})})]})}const Re="h-9 w-full";function Ks({open:s,onOpenChange:a,root:t,devices:n}){const{t:r}=F(),m=M(),p=!!t,[x,i]=j.useState(""),[c,f]=j.useState(""),[d,v]=j.useState(!0);j.useEffect(()=>{s&&(i((t==null?void 0:t.deviceId)??""),f((t==null?void 0:t.path)??""),v((t==null?void 0:t.enabled)??!0))},[s,t]);const l=k({mutationFn:()=>{const N={deviceId:x,path:c.trim(),enabled:d};return as(N)},onSuccess:async()=>{await m.invalidateQueries({queryKey:["files"]}),y.success(r("common.success")),a(!1)},onError:N=>{const I=N instanceof we?N.message:r("settings.files.addFailed");y.error(I)}}),h=k({mutationFn:()=>{if(!t)throw new Error(r("settings.files.updateFailed"));const N={path:c.trim(),enabled:d};return Ve(t.id,N)},onSuccess:async()=>{await m.invalidateQueries({queryKey:["files"]}),y.success(r("common.success")),a(!1)},onError:N=>{const I=N instanceof we?N.message:r("settings.files.updateFailed");y.error(I)}}),b=l.isPending||h.isPending,E=c.trim().startsWith("/")&&(p||x.length>0),g=()=>{!E||b||(p?h.mutate():l.mutate())},C=n.find(N=>N.id===x);return e.jsx(Y,{open:s,onOpenChange:a,children:e.jsxs(ee,{className:"sm:max-w-lg","data-testid":p?`settings-files-edit-modal-${t==null?void 0:t.id}`:"settings-files-add-modal",children:[e.jsxs(se,{children:[e.jsx(te,{children:r(p?"settings.files.modalEditTitle":"settings.files.modalAddTitle")}),e.jsx(me,{children:r("settings.files.description")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"files-form-device",children:r("settings.files.device")}),p?e.jsxs("div",{className:"flex h-9 items-center gap-1.5 rounded-lg border border-input bg-muted/30 px-2.5 text-sm",children:[e.jsx(ce,{type:(t==null?void 0:t.deviceType)??null,className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:(t==null?void 0:t.deviceName)??r("settings.files.missing")})]}):e.jsxs(ae,{value:x,onValueChange:N=>{N&&i(N)},children:[e.jsx(ne,{id:"files-form-device","data-testid":"settings-files-device-select",className:Re,disabled:n.length===0,children:e.jsx(ie,{children:C?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ce,{type:C.type,className:"h-4 w-4 shrink-0"}),C.name]}):e.jsx("span",{className:"text-muted-foreground",children:r("settings.files.devicePlaceholder")})})}),e.jsx(re,{children:n.map(N=>e.jsxs(Q,{value:N.id,children:[e.jsx(ce,{type:N.type,className:"h-4 w-4 shrink-0"}),N.name]},N.id))})]}),!p&&n.length===0&&e.jsx("p",{className:"text-xs text-destructive",children:r("settings.files.noDevices")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"files-form-path",children:r("settings.files.path")}),e.jsx(P,{id:"files-form-path","data-testid":"settings-files-path-input",value:c,onChange:N=>f(N.target.value),placeholder:r("settings.files.pathPlaceholder"),className:`${Re} font-mono`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r("settings.files.pathHint")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{checked:d,onCheckedChange:N=>v(!!N),"data-testid":"settings-files-enabled-switch"}),e.jsx("label",{className:"text-sm font-medium",htmlFor:"settings-files-enabled-switch",children:r("settings.files.enabled")})]})]}),e.jsxs(he,{children:[e.jsx(w,{variant:"outline",onClick:()=>a(!1),disabled:b,children:r("common.cancel")}),e.jsxs(w,{variant:"secondary","data-testid":"settings-files-form-submit",onClick:g,disabled:!E||b,children:[b?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),r("common.save")]})]})]})})}async function B(s,a){try{return(await s.json()).error??a}catch{return a}}const qs=["openai-chat","openai-responses"],le="h-9 w-full";function $s({open:s,onOpenChange:a,provider:t}){const{t:n}=F(),r=M(),m=!!t,[p,x]=j.useState(""),[i,c]=j.useState(""),[f,d]=j.useState("openai-chat"),[v,l]=j.useState("");j.useEffect(()=>{s&&(x((t==null?void 0:t.name)??""),c((t==null?void 0:t.baseUrl)??""),d((t==null?void 0:t.protocol)??"openai-chat"),l(""))},[s,t]);const h=k({mutationFn:async()=>{const g={name:p.trim(),protocol:f,baseUrl:i.trim(),apiKey:v.trim(),enabled:!0},C=await fetch("/api/llm/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!C.ok)throw new Error(await B(C,n("settings.llm.createFailed")));return await C.json()},onSuccess:async g=>{await r.invalidateQueries({queryKey:["llm-providers"]}),g.modelsError?y.warning(n("settings.llm.modelsFetchFailed",{error:g.modelsError})):y.success(n("common.success")),a(!1)},onError:g=>{y.error(g instanceof Error?g.message:n("common.error"))}}),b=k({mutationFn:async()=>{if(!t)throw new Error(n("settings.llm.updateFailed"));const g={name:p.trim(),baseUrl:i.trim(),protocol:f};v.trim()&&(g.apiKey=v.trim());const C=await fetch(`/api/llm/providers/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!C.ok)throw new Error(await B(C,n("settings.llm.updateFailed")));return await C.json()},onSuccess:async g=>{await r.invalidateQueries({queryKey:["llm-providers"]}),g.modelsError?y.warning(n("settings.llm.modelsFetchFailed",{error:g.modelsError})):y.success(n("common.success")),a(!1)},onError:g=>{y.error(g instanceof Error?g.message:n("common.error"))}}),S=h.isPending||b.isPending,o=p.trim().length>0&&i.trim().length>0&&(m||v.trim().length>0),E=()=>{!o||S||(m?b.mutate():h.mutate())};return e.jsx(Y,{open:s,onOpenChange:a,children:e.jsxs(ee,{className:"sm:max-w-lg","data-testid":m?`llm-provider-edit-modal-${t==null?void 0:t.id}`:"llm-provider-add-modal",children:[e.jsxs(se,{children:[e.jsx(te,{children:n(m?"settings.llm.editProvider":"settings.llm.addProvider")}),e.jsx(me,{children:n("settings.llm.formHint")})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-name",children:n("settings.llm.name")}),e.jsx(P,{id:"llm-form-name","data-testid":"llm-provider-name-input",value:p,onChange:g=>x(g.target.value),placeholder:n("settings.llm.namePlaceholder"),className:le})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-baseurl",children:n("settings.llm.baseUrl")}),e.jsx(P,{id:"llm-form-baseurl","data-testid":"llm-provider-baseurl-input",value:i,onChange:g=>c(g.target.value),placeholder:n("settings.llm.baseUrlPlaceholder"),className:le}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.llm.baseUrlHint")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-protocol",children:n("settings.llm.protocol")}),e.jsxs(ae,{value:f,onValueChange:g=>{g&&d(g)},children:[e.jsx(ne,{id:"llm-form-protocol","data-testid":"llm-provider-protocol-select",className:le,children:e.jsx(ie,{})}),e.jsx(re,{children:qs.map(g=>e.jsx(Q,{value:g,children:g},g))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-form-apikey",children:n("settings.llm.apiKey")}),e.jsx(P,{id:"llm-form-apikey","data-testid":"llm-provider-apikey-input","data-key-set":t!=null&&t.hasApiKey?"true":"false",type:"password",value:v,onChange:g=>l(g.target.value),placeholder:t!=null&&t.hasApiKey?n("settings.llm.apiKeySetPlaceholder"):n("settings.llm.apiKeyPlaceholder"),className:le})]})]}),e.jsxs(he,{children:[e.jsx(w,{variant:"outline",onClick:()=>a(!1),disabled:S,children:n("common.cancel")}),e.jsxs(w,{variant:"secondary","data-testid":"llm-provider-form-submit",onClick:E,disabled:!o||S,children:[S?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),n("common.save")]})]})]})})}function Ds({models:s,onChange:a}){const{t}=F(),[n,r]=j.useState(""),m=(i,c)=>{a(s.map(f=>f.id===i?{...f,enabled:c}:f))},p=i=>{a(s.filter(c=>c.id!==i))},x=()=>{const i=n.trim();if(i){if(s.some(c=>c.id===i)){r("");return}a([...s,{id:i,source:"manual",enabled:!0}]),r("")}};return e.jsxs("div",{className:"space-y-3","data-testid":"llm-provider-models",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{value:n,onChange:i=>r(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),x())},placeholder:t("settings.llm.addModelPlaceholder"),className:"h-9","data-testid":"llm-provider-add-model-input"}),e.jsxs(w,{type:"button",variant:"outline",size:"lg",onClick:x,disabled:!n.trim(),"data-testid":"llm-provider-add-model",children:[e.jsx(de,{className:"h-4 w-4"}),t("common.add")]})]}),s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.llm.modelsNotFetched")}):e.jsx("ul",{className:"max-h-56 space-y-1 overflow-y-auto rounded-lg border border-border bg-background p-2",children:s.map(i=>e.jsxs("li",{className:"flex items-center justify-between gap-2 rounded-md px-2 py-1.5","data-testid":`llm-provider-model-${i.id}`,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(A,{checked:i.enabled,onCheckedChange:c=>m(i.id,!!c),"data-testid":`llm-provider-model-toggle-${i.id}`}),e.jsx("span",{className:"truncate font-mono text-xs",children:i.id}),i.source==="manual"&&e.jsx(He,{variant:"secondary",children:t("settings.llm.modelManual")})]}),i.source==="manual"&&e.jsx(w,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>p(i.id),"data-testid":`llm-provider-model-remove-${i.id}`,children:e.jsx(rs,{className:"h-4 w-4"})})]},i.id))})]})}function Bs(s){return s.modelDetails.map(a=>({id:a.id,source:a.source,enabled:a.enabled}))}function _s({open:s,onOpenChange:a,provider:t}){const{t:n}=F(),r=M(),[m,p]=j.useState([]);j.useEffect(()=>{s&&p(Bs(t))},[s,t]);const x=k({mutationFn:async()=>{const i=m.filter(v=>v.source==="manual").map(v=>v.id),c=m.filter(v=>!v.enabled).map(v=>v.id),f={manualModels:i,disabledModels:c},d=await fetch(`/api/llm/providers/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!d.ok)throw new Error(await B(d,n("settings.llm.updateFailed")));return await d.json()},onSuccess:async i=>{await r.invalidateQueries({queryKey:["llm-providers"]}),i.modelsError?y.warning(n("settings.llm.modelsFetchFailed",{error:i.modelsError})):y.success(n("common.success")),a(!1)},onError:i=>{y.error(i instanceof Error?i.message:n("common.error"))}});return e.jsx(Y,{open:s,onOpenChange:a,children:e.jsxs(ee,{className:"sm:max-w-lg","data-testid":`llm-provider-models-modal-${t.id}`,children:[e.jsxs(se,{children:[e.jsx(te,{children:n("settings.llm.modelsTitle",{name:t.name})}),e.jsx(me,{children:n("settings.llm.modelsHint")})]}),e.jsx(Ds,{models:m,onChange:p}),e.jsxs(he,{children:[e.jsx(w,{variant:"outline",onClick:()=>a(!1),disabled:x.isPending,children:n("common.cancel")}),e.jsxs(w,{variant:"secondary","data-testid":`llm-provider-models-save-${t.id}`,onClick:()=>x.mutate(),disabled:x.isPending,children:[x.isPending?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),n("common.save")]})]})]})})}function Rs(s){try{const a=new URL(s);return`${a.protocol}//${a.host}${a.pathname==="/"?"":a.pathname}`}catch{return s}}function Ls({provider:s,onEdit:a}){const{t}=F(),n=M(),[r,m]=j.useState(!1),[p,x]=j.useState(!1),i=k({mutationFn:async d=>{const v=await fetch(`/api/llm/providers/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:d})});if(!v.ok)throw new Error(await B(v,t("settings.llm.updateFailed")))},onSuccess:async()=>{await n.invalidateQueries({queryKey:["llm-providers"]})},onError:d=>{y.error(d instanceof Error?d.message:t("common.error"))}}),c=k({mutationFn:async()=>{const d=await fetch(`/api/llm/providers/${s.id}/refresh-models`,{method:"POST"});if(!d.ok)throw new Error(await B(d,t("settings.llm.refreshModelsFailed")))},onSuccess:async()=>{await n.invalidateQueries({queryKey:["llm-providers"]}),y.success(t("common.success"))},onError:d=>{y.error(d instanceof Error?d.message:t("common.error"))}}),f=k({mutationFn:async()=>{const d=await fetch(`/api/llm/providers/${s.id}`,{method:"DELETE"});if(!d.ok)throw new Error(await B(d,t("settings.llm.deleteFailed")))},onSuccess:async()=>{await n.invalidateQueries({queryKey:["llm-providers"]}),await n.invalidateQueries({queryKey:["llm-settings"]}),y.success(t("common.success"))},onError:d=>{y.error(d instanceof Error?d.message:t("common.error"))}});return e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3 sm:flex-row sm:items-center sm:justify-between","data-testid":`llm-provider-row-${s.id}`,"data-provider-name":s.name,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(A,{checked:s.enabled,disabled:i.isPending,onCheckedChange:d=>i.mutate(!!d),"data-testid":`llm-provider-enabled-${s.id}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium",children:s.name}),e.jsx(He,{variant:"outline",children:s.protocol})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"truncate font-mono",children:Rs(s.baseUrl)}),e.jsx("span",{"aria-hidden":!0,children:"·"}),e.jsx("span",{className:"whitespace-nowrap",children:t("settings.llm.modelsCount",{total:s.models.length})})]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("settings.llm.refreshModels"),"data-testid":`llm-provider-refresh-models-${s.id}`,onClick:()=>c.mutate(),disabled:c.isPending,children:c.isPending?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(Je,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("settings.llm.models"),"data-testid":`llm-provider-models-${s.id}`,onClick:()=>x(!0),children:e.jsx(ws,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.edit"),"data-testid":`llm-provider-edit-${s.id}`,onClick:()=>a(s),children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.delete"),"data-testid":`llm-provider-delete-${s.id}`,onClick:()=>m(!0),disabled:f.isPending,children:e.jsx(O,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(_s,{open:p,onOpenChange:x,provider:s}),e.jsx(z,{open:r,onOpenChange:m,children:e.jsxs(V,{children:[e.jsxs(H,{children:[e.jsx(J,{children:t("settings.llm.deleteProvider")}),e.jsx(W,{children:t("settings.llm.deleteConfirm",{name:s.name})})]}),e.jsxs(G,{children:[e.jsx(Z,{onClick:()=>m(!1),children:t("common.cancel")}),e.jsx(X,{variant:"destructive","data-testid":`llm-provider-delete-confirm-${s.id}`,onClick:()=>{f.mutate(),m(!1)},children:t("common.confirm")})]})]})})]})}function Is(){var c;const{t:s}=F(),[a,t]=j.useState(!1),[n,r]=j.useState(void 0),m=K({queryKey:["llm-providers"],queryFn:async()=>{const f=await fetch("/api/llm/providers");if(!f.ok)throw new Error(await B(f,s("settings.llm.loadFailed")));return await f.json()}}),p=((c=m.data)==null?void 0:c.providers)??[],x=()=>{r(void 0),t(!0)},i=f=>{r(f),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs($,{className:"border-0 ring-0","data-testid":"llm-providers-section",children:[e.jsxs(_,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsx(R,{children:s("settings.llm.title")}),e.jsxs(w,{variant:"secondary","data-testid":"llm-provider-add",onClick:x,children:[e.jsx(de,{className:"h-4 w-4"}),s("settings.llm.addProvider")]})]}),e.jsxs(D,{className:"space-y-3",children:[m.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!m.isLoading&&p.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground","data-testid":"llm-providers-empty",children:s("settings.llm.empty")}),p.map(f=>e.jsx(Ls,{provider:f,onEdit:i},f.id))]})]}),e.jsx($s,{open:a,onOpenChange:t,provider:n}),e.jsx(Os,{providers:p})]})}const xe="__none__";function Os({providers:s}){var b,S;const{t:a}=F(),t=M(),[n,r]=j.useState(null),[m,p]=j.useState(""),x=K({queryKey:["llm-settings"],queryFn:async()=>{const o=await fetch("/api/llm/settings");if(!o.ok)throw new Error(await B(o,a("settings.llm.settingsLoadFailed")));return await o.json()}}),i=((b=x.data)==null?void 0:b.settings.defaultProviderId)??null,c=((S=x.data)==null?void 0:S.settings.defaultModelId)??"",f=!!x.data;j.useEffect(()=>{f&&(r(i),p(c))},[f,i,c]);const d=k({mutationFn:async()=>{const o={defaultProviderId:n,defaultModelId:m.trim()||null},E=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!E.ok)throw new Error(await B(E,a("settings.llm.settingsSaveFailed")))},onSuccess:async()=>{await t.invalidateQueries({queryKey:["llm-settings"]}),y.success(a("common.success"))},onError:o=>{y.error(o instanceof Error?o.message:a("common.error"))}}),v=s.filter(o=>o.enabled),l=s.find(o=>o.id===n),h=(l==null?void 0:l.models)??[];return e.jsxs($,{className:"border-0 ring-0","data-testid":"llm-defaults-section",children:[e.jsx(_,{children:e.jsx(R,{children:a("settings.llm.defaults")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-default-provider-select",children:a("settings.llm.defaultProvider")}),e.jsxs(ae,{value:n??xe,onValueChange:o=>{o&&r(o===xe?null:o)},children:[e.jsx(ne,{id:"llm-default-provider-select","data-testid":"llm-default-provider-select",className:"h-9 w-full",children:e.jsx(ie,{children:(l==null?void 0:l.name)??a("settings.llm.defaultProviderNone")})}),e.jsxs(re,{children:[e.jsx(Q,{value:xe,children:a("settings.llm.defaultProviderNone")}),v.map(o=>e.jsx(Q,{value:o.id,children:o.name},o.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"llm-default-model-input",children:a("settings.llm.defaultModel")}),e.jsx(P,{id:"llm-default-model-input","data-testid":"llm-default-model-input",list:"llm-default-model-options",value:m,onChange:o=>p(o.target.value),placeholder:a("settings.llm.defaultModelPlaceholder"),className:"h-9"}),e.jsx("datalist",{id:"llm-default-model-options",children:h.map(o=>e.jsx("option",{value:o},o))})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{variant:"secondary","data-testid":"llm-defaults-save",onClick:()=>d.mutate(),disabled:d.isPending||x.isLoading,className:"w-full sm:w-auto",children:[d.isPending?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),a("settings.llm.saveDefaults")]})})]})]})}const Qs=["none","tavily","brave"];async function pe(s,a){try{return(await s.json()).error??a}catch{return a}}function Us(){var S;const{t:s}=F(),a=M(),[t,n]=j.useState("none"),[r,m]=j.useState(""),[p,x]=j.useState(""),[i,c]=j.useState(null),f=K({queryKey:["llm-settings"],queryFn:async()=>{const o=await fetch("/api/llm/settings");if(!o.ok)throw new Error(await pe(o,s("settings.search.loadFailed")));return await o.json()}}),d=(S=f.data)==null?void 0:S.settings,v=d==null?void 0:d.searchProvider;j.useEffect(()=>{v&&n(v)},[v]);const l=k({mutationFn:async()=>{const o={searchProvider:t};r.trim()&&(o.tavilyApiKey=r.trim()),p.trim()&&(o.braveApiKey=p.trim());const E=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!E.ok)throw new Error(await pe(E,s("settings.search.saveFailed")))},onSuccess:async()=>{m(""),x(""),await a.invalidateQueries({queryKey:["llm-settings"]}),y.success(s("common.success"))},onError:o=>{y.error(o instanceof Error?o.message:s("common.error"))}}),h=k({mutationFn:async o=>{const E={[o]:""},g=await fetch("/api/llm/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});if(!g.ok)throw new Error(await pe(g,s("settings.search.saveFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["llm-settings"]}),y.success(s("common.success"))},onError:o=>{y.error(o instanceof Error?o.message:s("common.error"))}}),b=o=>o==="none"?s("settings.search.providerNone"):o==="tavily"?"Tavily":"Brave";return e.jsxs($,{className:"border-0 ring-0","data-testid":"settings-search-section",children:[e.jsx(_,{children:e.jsx(R,{children:s("settings.search.title")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"search-provider-select",children:s("settings.search.provider")}),e.jsxs(ae,{value:t,onValueChange:o=>{o&&n(o)},children:[e.jsx(ne,{id:"search-provider-select","data-testid":"settings-search-provider-select",className:"w-full min-h-10",children:e.jsx(ie,{children:b(t)})}),e.jsx(re,{children:Qs.map(o=>e.jsx(Q,{value:o,children:b(o)},o))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("settings.search.responsesApiHint")})]}),e.jsx(Le,{id:"search-tavily-key-input",testId:"settings-search-tavily",label:s("settings.search.tavilyApiKey"),value:r,hasKey:(d==null?void 0:d.hasTavilyApiKey)??!1,onChange:m,onClear:()=>c("tavilyApiKey"),clearing:h.isPending&&h.variables==="tavilyApiKey"}),e.jsx(Le,{id:"search-brave-key-input",testId:"settings-search-brave",label:s("settings.search.braveApiKey"),value:p,hasKey:(d==null?void 0:d.hasBraveApiKey)??!1,onChange:x,onClear:()=>c("braveApiKey"),clearing:h.isPending&&h.variables==="braveApiKey"}),e.jsx(z,{open:i!==null,onOpenChange:o=>{o||c(null)},children:e.jsxs(V,{children:[e.jsxs(H,{children:[e.jsx(J,{children:s("settings.search.clearKey")}),e.jsx(W,{children:s("settings.search.clearKeyConfirm")})]}),e.jsxs(G,{children:[e.jsx(Z,{children:s("common.cancel")}),e.jsx(X,{"data-testid":"settings-search-clear-confirm",onClick:()=>{i&&h.mutate(i),c(null)},children:s("settings.search.clearKey")})]})]})}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(w,{variant:"secondary","data-testid":"settings-search-save",onClick:()=>l.mutate(),disabled:l.isPending||f.isLoading,className:"w-full sm:w-auto",children:[l.isPending?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),s("common.save")]})})]})]})}function Le({id:s,testId:a,label:t,value:n,hasKey:r,onChange:m,onClear:p,clearing:x}){const{t:i}=F();return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:s,children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{id:s,"data-testid":`${a}-input`,"data-key-set":r?"true":"false",type:"password",value:n,onChange:c=>m(c.target.value),placeholder:i(r?"settings.search.keySetPlaceholder":"settings.search.keyPlaceholder"),className:"min-h-10"}),r&&e.jsxs(w,{variant:"outline",size:"sm","data-testid":`${a}-clear`,onClick:p,disabled:x,className:"shrink-0",children:[e.jsx(O,{className:"h-4 w-4"}),i("settings.search.clearKey")]})]})]})}const Ie="min-h-10";async function Oe(s,a){try{return(await s.json()).error??a}catch{return a}}function zs({open:s,onOpenChange:a,bot:t}){const{t:n}=F(),r=M(),m=!!t,[p,x]=j.useState(""),[i,c]=j.useState(""),[f,d]=j.useState(!0);j.useEffect(()=>{s&&(x((t==null?void 0:t.name)??""),c(""),d((t==null?void 0:t.allowAuthRequests)??!0))},[s,t]);const v=k({mutationFn:async()=>{const o=await fetch("/api/settings/telegram/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim(),token:i.trim(),enabled:!0,allowAuthRequests:f})});if(!o.ok)throw new Error(await Oe(o,n("telegram.createFailed")))},onSuccess:async()=>{await r.invalidateQueries({queryKey:["telegram-bots"]}),y.success(n("common.success")),a(!1)},onError:o=>{y.error(o instanceof Error?o.message:n("common.error"))}}),l=k({mutationFn:async()=>{if(!t)throw new Error(n("telegram.updateFailed"));const o={name:p.trim(),allowAuthRequests:f};i.trim()&&(o.token=i.trim());const E=await fetch(`/api/settings/telegram/bots/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!E.ok)throw new Error(await Oe(E,n("telegram.updateFailed")))},onSuccess:async()=>{await r.invalidateQueries({queryKey:["telegram-bots"]}),y.success(n("common.success")),a(!1)},onError:o=>{y.error(o instanceof Error?o.message:n("common.error"))}}),h=v.isPending||l.isPending,b=p.trim().length>0&&(m||i.trim().length>0),S=()=>{!b||h||(m?l.mutate():v.mutate())};return e.jsx(Y,{open:s,onOpenChange:a,children:e.jsxs(ee,{className:"sm:max-w-lg","data-testid":m?`telegram-bot-edit-modal-${t==null?void 0:t.id}`:"telegram-bot-add-modal",children:[e.jsx(se,{children:e.jsx(te,{children:n(m?"telegram.editBot":"telegram.addBot")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"telegram-bot-name",children:n("telegram.botName")}),e.jsx(P,{id:"telegram-bot-name","data-testid":"telegram-bot-name-input",value:p,onChange:o=>x(o.target.value),placeholder:n("telegram.botNamePlaceholder"),className:Ie})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"telegram-bot-token",children:n("telegram.botToken")}),e.jsx(P,{id:"telegram-bot-token","data-testid":"telegram-bot-token-input",type:"password",value:i,onChange:o=>c(o.target.value),placeholder:n(m?"telegram.tokenPlaceholder":"telegram.botTokenPlaceholder"),className:Ie})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium",children:n("telegram.allowAuthRequests")}),e.jsx(A,{checked:f,"data-testid":"telegram-bot-allow-auth",onCheckedChange:o=>d(!!o)})]})]}),e.jsxs(he,{children:[e.jsx(w,{variant:"outline",onClick:()=>a(!1),disabled:h,children:n("common.cancel")}),e.jsxs(w,{variant:"secondary","data-testid":"telegram-bot-form-submit",onClick:S,disabled:!b||h,children:[h?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),n("common.save")]})]})]})})}async function oe(s,a){try{return(await s.json()).error??a}catch{return a}}function Vs({open:s,onOpenChange:a,botId:t,botName:n}){var v;const{t:r}=F(),m=M(),p=K({queryKey:["telegram-bot-chats",t],enabled:s,queryFn:async()=>{const l=await fetch(`/api/settings/telegram/bots/${t}/chats`);if(!l.ok)throw new Error(await oe(l,r("telegram.loadChatsFailed")));return await l.json()}}),x=j.useMemo(()=>{var h;const l=((h=p.data)==null?void 0:h.chats)??[];return{pending:l.filter(b=>b.status==="pending"),authorized:l.filter(b=>b.status==="authorized")}},[(v=p.data)==null?void 0:v.chats]),i=async()=>{await Promise.all([m.invalidateQueries({queryKey:["telegram-bots"]}),m.invalidateQueries({queryKey:["telegram-bot-chats",t]})])},c=k({mutationFn:async l=>{const h=await fetch(`/api/settings/telegram/bots/${t}/chats/${encodeURIComponent(l)}/approve`,{method:"POST"});if(!h.ok)throw new Error(await oe(h,r("telegram.approveFailed")))},onSuccess:async()=>{await i(),y.success(r("common.success"))},onError:l=>{y.error(l instanceof Error?l.message:r("common.error"))}}),f=k({mutationFn:async l=>{const h=await fetch(`/api/settings/telegram/bots/${t}/chats/${encodeURIComponent(l)}`,{method:"DELETE"});if(!h.ok)throw new Error(await oe(h,r("telegram.removeFailed")))},onSuccess:async()=>{await i(),y.success(r("common.success"))},onError:l=>{y.error(l instanceof Error?l.message:r("common.error"))}}),d=k({mutationFn:async l=>{const h=await fetch(`/api/settings/telegram/bots/${t}/chats/${encodeURIComponent(l)}/test`,{method:"POST"});if(!h.ok)throw new Error(await oe(h,r("telegram.testMessageFailed")))},onSuccess:()=>{y.success(r("common.success"))},onError:l=>{y.error(l instanceof Error?l.message:r("common.error"))}});return e.jsx(Y,{open:s,onOpenChange:a,children:e.jsxs(ee,{className:"sm:max-w-2xl","data-testid":`telegram-bot-chats-modal-${t}`,children:[e.jsxs(se,{children:[e.jsx(te,{children:r("telegram.chats")}),e.jsx(me,{children:n})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"flex items-center gap-1 text-sm font-semibold",children:[e.jsx(_e,{className:"h-4 w-4"}),r("telegram.pendingChats")]}),x.pending.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:r("telegram.noPendingChats")}),x.pending.map(l=>e.jsx(Qe,{chat:l,pending:!0,onApprove:()=>c.mutate(l.chatId),onDelete:()=>f.mutate(l.chatId)},`${l.botId}-${l.chatId}`))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"flex items-center gap-1 text-sm font-semibold",children:[e.jsx(_e,{className:"h-4 w-4"}),r("telegram.chats")]}),x.authorized.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:r("telegram.noAuthorizedChats")}),x.authorized.map(l=>e.jsx(Qe,{chat:l,pending:!1,onTest:()=>d.mutate(l.chatId),onDelete:()=>f.mutate(l.chatId)},`${l.botId}-${l.chatId}`))]}),p.isLoading&&e.jsx("div",{className:"text-xs text-muted-foreground lg:col-span-2",children:r("common.loading")})]})]})})}function Qe({chat:s,pending:a,onApprove:t,onDelete:n,onTest:r}){const{t:m}=F(),p=ue(x=>{var i;return((i=x.settings)==null?void 0:i.language)??"en_US"});return e.jsxs("div",{className:"space-y-2 rounded border-0 bg-background p-3",children:[e.jsx("div",{className:"truncate text-sm font-medium",title:s.displayName,children:s.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[m("telegram.chatId"),":",s.chatId]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(s.appliedAt).toLocaleString(ke(p))}),e.jsx("div",{className:"flex items-center justify-end gap-2 pt-1",children:a?e.jsxs(e.Fragment,{children:[e.jsx(w,{variant:"outline",size:"sm",onClick:n,children:m("telegram.reject")}),e.jsx(w,{variant:"secondary",size:"sm",onClick:t,children:m("telegram.authorize")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(w,{variant:"secondary",size:"sm",onClick:r,children:[e.jsx(ls,{className:"h-3.5 w-3.5"}),m("telegram.sendTestMessage")]}),e.jsx(w,{variant:"destructive",size:"sm",onClick:n,children:m("common.delete")})]})})]})}async function Ue(s,a){try{return(await s.json()).error??a}catch{return a}}function Hs({bot:s,onEdit:a}){const{t}=F(),n=M(),[r,m]=j.useState(!1),p=k({mutationFn:async i=>{const c=await fetch(`/api/settings/telegram/bots/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:i})});if(!c.ok)throw new Error(await Ue(c,t("telegram.updateFailed")))},onSuccess:async()=>{await n.invalidateQueries({queryKey:["telegram-bots"]})},onError:i=>{y.error(i instanceof Error?i.message:t("common.error"))}}),x=k({mutationFn:async()=>{const i=await fetch(`/api/settings/telegram/bots/${s.id}`,{method:"DELETE"});if(!i.ok)throw new Error(await Ue(i,t("telegram.deleteFailed")))},onSuccess:async()=>{await n.invalidateQueries({queryKey:["telegram-bots"]}),y.success(t("common.success"))},onError:i=>{y.error(i instanceof Error?i.message:t("common.error"))}});return e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-3 sm:flex-row sm:items-center sm:justify-between","data-testid":`telegram-bot-card-${s.id}`,"data-bot-name":s.name,children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(A,{checked:s.enabled,disabled:p.isPending,onCheckedChange:i=>p.mutate(!!i),"data-testid":`telegram-bot-enabled-${s.id}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium",children:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t("telegram.authCount",{authorized:s.authorizedCount,pending:s.pendingCount})})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("telegram.chats"),"data-testid":`telegram-bot-chats-${s.id}`,onClick:()=>m(!0),children:e.jsx(Ps,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("common.edit"),"data-testid":`telegram-bot-edit-${s.id}`,onClick:()=>a(s),children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx(w,{variant:"ghost",size:"icon-sm",title:t("telegram.deleteBot"),"data-testid":`telegram-bot-delete-${s.id}`,onClick:()=>x.mutate(),disabled:x.isPending,children:e.jsx(O,{className:"h-4 w-4 text-destructive"})})]}),e.jsx(Vs,{open:r,onOpenChange:m,botId:s.id,botName:s.name})]})}async function Js(s,a){try{return(await s.json()).error??a}catch{return a}}function Ws(){var c;const{t:s}=F(),[a,t]=j.useState(!1),[n,r]=j.useState(void 0),m=K({queryKey:["telegram-bots"],queryFn:async()=>{const f=await fetch("/api/settings/telegram/bots");if(!f.ok)throw new Error(await Js(f,s("telegram.loadBotsFailed")));return await f.json()}}),p=((c=m.data)==null?void 0:c.bots)??[],x=()=>{r(void 0),t(!0)},i=f=>{r(f),t(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs($,{className:"border-0 ring-0",children:[e.jsxs(_,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsx(R,{children:s("telegram.title")}),e.jsxs(w,{variant:"secondary","data-testid":"telegram-add-bot",onClick:x,children:[e.jsx(de,{className:"h-4 w-4"}),s("telegram.addBot")]})]}),e.jsxs(D,{className:"space-y-3",children:[m.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!m.isLoading&&p.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("telegram.noBots")}),p.map(f=>e.jsx(Hs,{bot:f,onEdit:i},f.id))]})]}),e.jsx(zs,{open:a,onOpenChange:t,bot:n})]})}async function fe(s,a){try{return(await s.json()).error??a}catch{return a}}function je({label:s,value:a}){return e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2 text-sm font-medium",children:s}),e.jsx("div",{className:"min-w-0 truncate text-right text-sm text-muted-foreground",children:a})]})}function Gs(){const{t:s}=F(),a=M(),t=ue(g=>{var C;return((C=g.settings)==null?void 0:C.language)??"en_US"}),[n,r]=j.useState(!1),[m,p]=j.useState(!1),x=j.useRef(!1),c=K({queryKey:["system-info"],queryFn:async()=>{const g=await fetch("/api/system/info");if(!g.ok)throw new Error(await fe(g,s("settings.loadFailed")));return await g.json()}}).data,f=K({queryKey:["system-update-check"],enabled:!1,gcTime:0,queryFn:async()=>{const g=await fetch("/api/system/update-check");if(!g.ok)throw new Error(await fe(g,s("settings.version.checkFailed")));return await g.json()}}),d=f.data,l=K({queryKey:["system-upgrade-status"],enabled:m,refetchInterval:g=>{var N;const C=(N=g.state.data)==null?void 0:N.state;return m||C&&C!=="idle"?2e3:!1},retry:!0,queryFn:async()=>{const g=await fetch("/api/system/upgrade");if(!g.ok)throw new Error("status");return await g.json()}}).data;j.useEffect(()=>{if(!m)return;const g=l==null?void 0:l.state;g&&g!=="idle"?x.current=!0:g==="idle"&&(l!=null&&l.error)?(x.current=!1,p(!1),y.error(l.error)):g==="idle"&&x.current&&(x.current=!1,p(!1),a.invalidateQueries({queryKey:["system-info"]}),a.removeQueries({queryKey:["system-update-check"]}),y.success(s("common.success")))},[m,l,a,s]);const h=k({mutationFn:async g=>{const C=await fetch("/api/system/upgrade",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({version:g})});if(!C.ok)throw new Error(await fe(C,s("common.error")));return await C.json()},onSuccess:g=>{x.current=!1,p(!0),a.setQueryData(["system-upgrade-status"],g),y.success(s("settings.version.upgradeStarted"))},onError:g=>{y.error(g instanceof Error?g.message:s("common.error"))}}),b=g=>s(g==="launchd"?"settings.version.deploymentLaunchd":g==="systemd"?"settings.version.deploymentSystemd":"settings.version.deploymentNone"),S=m&&(l==null?void 0:l.state)!==void 0,o=(l==null?void 0:l.state)==="downloading"?s("settings.version.stateDownloading"):(l==null?void 0:l.state)==="executing"?s("settings.version.stateExecuting"):null,E=c!=null&&c.canSelfUpdate?null:c!=null&&c.isProd?c!=null&&c.installedViaCli?null:s("settings.version.upgradeDisabledNonCli"):s("settings.version.upgradeDisabledDev");return e.jsxs($,{className:"border-0 ring-0",children:[e.jsx(_,{children:e.jsx(R,{children:s("settings.version.title")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{label:s("settings.version.currentVersion"),value:e.jsx("span",{"data-testid":"settings-version-current",className:"font-mono",children:c?c.version:s("common.loading")})}),e.jsx(je,{label:s("settings.version.installMethod"),value:c?c.installedViaCli?s("settings.version.installMethodCli"):s("settings.version.installMethodNonCli"):"-"}),e.jsx(je,{label:s("settings.version.deployment"),value:c?b(c.deployment):"-"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(w,{variant:"outline","data-testid":"settings-version-check",onClick:()=>f.refetch(),disabled:f.isFetching||S,children:[f.isFetching?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(Je,{className:"h-4 w-4"}),f.isFetching?s("settings.version.checking"):s("settings.version.checkUpdate")]}),d&&e.jsxs("span",{className:"text-sm text-muted-foreground","data-testid":"settings-version-latest",children:[d.hasUpdate&&d.latestVersion?s("settings.version.updateAvailable",{version:d.latestVersion}):s("settings.version.upToDate"),d.publishedAt?` · ${s("settings.version.publishedAt",{date:new Date(d.publishedAt).toLocaleDateString(ke(t))})}`:""]})]}),f.isError&&e.jsx("div",{className:"text-sm text-destructive",children:s("settings.version.checkFailed")}),(d==null?void 0:d.hasUpdate)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-sm font-semibold",children:s("settings.version.changelog")}),e.jsx("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:d.changelog?e.jsx(ys,{source:d.changelog,basePath:"/"}):e.jsx("div",{className:"text-sm text-muted-foreground",children:s("settings.version.changelogUnavailable")})}),c!=null&&c.canSelfUpdate?e.jsxs(w,{variant:"secondary","data-testid":"settings-version-upgrade",disabled:S||h.isPending,onClick:()=>r(!0),children:[S?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(os,{className:"h-4 w-4"}),s("settings.version.upgrade")]}):e.jsxs("div",{className:"space-y-1",children:[E&&e.jsx("div",{className:"text-sm text-muted-foreground",children:E}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:s("settings.version.terminalHint")})]})]}),S&&o&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-border bg-card px-4 py-3","data-testid":"settings-version-upgrade-status",children:[e.jsx(q,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:o}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s("settings.version.interruptNotice")})]})]})]}),e.jsx(z,{open:n,onOpenChange:r,children:e.jsxs(V,{children:[e.jsxs(H,{children:[e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(cs,{className:"h-5 w-5 text-destructive"}),s("settings.version.upgradeWarningTitle")]}),e.jsx(W,{children:s("settings.version.upgradeWarningBody")})]}),e.jsxs(G,{children:[e.jsx(Z,{onClick:()=>r(!1),children:s("common.cancel")}),e.jsx(X,{variant:"destructive","data-testid":"settings-version-upgrade-confirm",onClick:()=>{r(!1),d!=null&&d.latestVersion&&h.mutate(d.latestVersion)},children:s("settings.version.upgrade")})]})]})})]})}const ye=["terminal_bell","terminal_notification","tmux_window_close","tmux_pane_close","device_tmux_missing","device_disconnect","session_created","session_closed","agent_confirmation_pending","agent_turn_finished","agent_error","watch_triggered","watch_model_unavailable","watch_rule_error"];async function ve(s,a){try{return(await s.json()).error??a}catch{return a}}function Zs(){var l;const{t:s}=F(),a=M(),t=ue(h=>{var b;return((b=h.settings)==null?void 0:b.language)??"en_US"}),[n,r]=j.useState(""),[m,p]=j.useState(""),[x,i]=j.useState(ye),c=K({queryKey:["webhooks"],queryFn:async()=>{const h=await fetch("/api/webhooks");if(!h.ok)throw new Error(await ve(h,s("webhook.loadFailed")));return await h.json()}}),f=k({mutationFn:async()=>{const h=await fetch("/api/webhooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:n,secret:m,eventMask:x})});if(!h.ok)throw new Error(await ve(h,s("webhook.createFailed")))},onSuccess:async()=>{r(""),p(""),i(ye),await a.invalidateQueries({queryKey:["webhooks"]}),y.success(s("common.success"))},onError:h=>{y.error(h instanceof Error?h.message:s("common.error"))}}),d=k({mutationFn:async h=>{const b=await fetch(`/api/webhooks/${h}`,{method:"DELETE"});if(!b.ok)throw new Error(await ve(b,s("webhook.deleteFailed")))},onSuccess:async()=>{await a.invalidateQueries({queryKey:["webhooks"]}),y.success(s("common.success"))},onError:h=>{y.error(h instanceof Error?h.message:s("common.error"))}}),v=((l=c.data)==null?void 0:l.webhooks)??[];return e.jsxs($,{className:"border-0 ring-0",children:[e.jsx(_,{children:e.jsx(R,{children:s("webhook.title")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12 md:items-end",children:[e.jsxs("div",{className:"md:col-span-6 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"webhook-url-input",children:s("webhook.url")}),e.jsx(P,{id:"webhook-url-input","data-testid":"webhook-url-input",value:n,onChange:h=>r(h.target.value),placeholder:"https://example.com/webhook",className:"min-h-10"})]}),e.jsxs("div",{className:"md:col-span-4 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"webhook-secret-input",children:s("webhook.secret")}),e.jsx(P,{id:"webhook-secret-input","data-testid":"webhook-secret-input",value:m,onChange:h=>p(h.target.value),placeholder:s("webhook.secretPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs(w,{variant:"secondary",className:"w-full md:w-auto","data-testid":"webhook-add",onClick:()=>f.mutate(),disabled:f.isPending||!n.trim()||!m.trim()||x.length===0,children:[f.isPending?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),s("webhook.add")]})})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium",children:s("webhook.eventMask")}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:ye.map(h=>{const b=x.includes(h);return e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-background px-3 py-2",children:[e.jsx("div",{className:"min-w-0 pr-2 text-sm font-medium",children:s(`notification.eventType.${h}`)}),e.jsx(A,{checked:b,"data-testid":`webhook-event-${h}`,onCheckedChange:S=>{i(o=>S?o.includes(h)?o:[...o,h]:o.filter(E=>E!==h))}})]},h)})})]}),e.jsxs("div",{className:"space-y-2",children:[c.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("common.loading")}),!c.isLoading&&v.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s("webhook.empty")}),v.map(h=>e.jsxs("div",{"data-testid":"webhook-item","data-webhook-url":h.url,className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:h.url}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(h.createdAt).toLocaleString(ke(t))})]}),e.jsx(w,{variant:"ghost",size:"icon-sm","data-testid":"webhook-delete",onClick:()=>d.mutate(h.id),disabled:d.isPending,"aria-label":s("common.delete"),title:s("common.delete"),children:e.jsx(O,{className:"h-4 w-4"})})]},h.id))]})]})]})}async function be(s,a){try{return(await s.json()).error??a}catch{return a}}function tt(){var qe,$e;const{t:s}=F(),a=M(),{refreshSettings:t}=ue(),[n,r]=j.useState("general"),m=De(u=>u.theme),p=De(u=>u.setTheme),x=m==="dark",[i,c]=j.useState("tmex"),[f,d]=j.useState(window.location.origin),[v,l]=j.useState("en_US"),[h,b]=j.useState(6),[S,o]=j.useState(3),[E,g]=j.useState(!0),[C,N]=j.useState(!0),[I,Ce]=j.useState(!0),[Se,Ee]=j.useState(!0),[Fe,Pe]=j.useState(2),[Te,Me]=j.useState(10),[We,Ge]=j.useState(!1),Ze=u=>{const T=u?"dark":"light";p(T),document.documentElement.classList.toggle("dark",T==="dark")},ge=K({queryKey:["site-settings"],queryFn:async()=>{const u=await fetch("/api/settings/site");if(!u.ok)throw new Error(await be(u,s("settings.loadFailed")));return await u.json()}});j.useEffect(()=>{var T;const u=(T=ge.data)==null?void 0:T.settings;u&&(c(u.siteName),d(u.siteUrl),l(u.language??"en_US"),b(u.bellThrottleSeconds),o(u.notificationThrottleSeconds??3),g(u.enableBrowserBellToast??!0),N(u.enableBrowserNotificationToast??!0),Ce(u.enableTelegramBellPush??!0),Ee(u.enableTelegramNotificationPush??!0),Pe(u.sshReconnectMaxRetries),Me(u.sshReconnectDelaySeconds))},[(qe=ge.data)==null?void 0:qe.settings]);const Ae=k({mutationFn:async()=>{const T=await fetch("/api/settings/site",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:i,siteUrl:f,language:v,bellThrottleSeconds:h,notificationThrottleSeconds:S,enableBrowserBellToast:E,enableBrowserNotificationToast:C,enableTelegramBellPush:I,enableTelegramNotificationPush:Se,sshReconnectMaxRetries:Fe,sshReconnectDelaySeconds:Te})});if(!T.ok)throw new Error(await be(T,s("settings.saveFailed")))},onSuccess:async()=>{var u,T;await Promise.all([a.invalidateQueries({queryKey:["site-settings"]}),t()]),y.success(s("settings.settingsSaved")),((T=(u=ge.data)==null?void 0:u.settings)==null?void 0:T.language)!==v&&(fs.changeLanguage(v),Ge(!0))},onError:u=>{y.error(u instanceof Error?u.message:s("common.error"))}}),Xe=[{value:"general",label:s("settings.tabGroup.general"),icon:ds,testId:"settings-tab-general"},{value:"devicesAndFiles",label:s("settings.tabGroup.devicesAndFiles"),icon:Ss,testId:"settings-tab-devicesAndFiles"},{value:"notifications",label:s("settings.tabGroup.notifications"),icon:ms,testId:"settings-tab-notifications"},{value:"ai",label:s("settings.tabGroup.ai"),icon:hs,testId:"settings-tab-ai"}],Ke=e.jsx("div",{className:"flex justify-end pt-2",children:e.jsxs(w,{variant:"secondary","data-testid":"settings-save",onClick:()=>Ae.mutate(),disabled:Ae.isPending,className:"w-full sm:w-auto",children:[e.jsx(L,{className:"h-4 w-4"}),s("common.save")]})});return e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-4 p-3 pb-[calc(2rem+env(safe-area-inset-bottom))] sm:gap-6 sm:p-5","data-testid":"settings-page",children:[e.jsx(us,{value:n,onValueChange:u=>r(u),children:e.jsx(gs,{className:"w-full rounded-xl border border-border/60 p-1 group-data-horizontal/tabs:h-11",children:Xe.map(u=>{const T=u.icon;return e.jsxs(xs,{value:u.value,"data-testid":u.testId,className:ps,children:[e.jsx(T,{}),u.label]},u.value)})})}),n==="general"&&e.jsxs(e.Fragment,{children:[e.jsxs($,{className:"border-0 ring-0",children:[e.jsx(_,{children:e.jsx(R,{children:s("settings.siteSettings")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"site-name-input",children:s("settings.siteName")}),e.jsx(P,{id:"site-name-input",value:i,onChange:u=>c(u.target.value),placeholder:s("settings.siteNamePlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"site-url-input",children:s("settings.siteUrl")}),e.jsx(P,{id:"site-url-input",value:f,onChange:u=>d(u.target.value),placeholder:s("settings.siteUrlPlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"language-select",children:s("settings.language")}),e.jsxs(ae,{value:v,onValueChange:u=>{u&&l(u)},children:[e.jsx(ne,{id:"language-select","data-testid":"settings-language-select",className:"w-full min-h-10",children:e.jsx(ie,{placeholder:s("settings.language"),children:(($e=Be.locales.find(u=>u.code===v))==null?void 0:$e.nativeName)??v})}),e.jsx(re,{className:"max-h-[var(--tmex-viewport-height)]",children:Be.locales.map(u=>e.jsx(Q,{value:u.code,children:u.nativeName},u.code))})]}),We&&e.jsx("p",{className:"mt-1 text-xs text-primary","data-testid":"settings-refresh-notice",children:s("settings.refreshToApply")})]}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.theme")})}),e.jsx(A,{checked:x,onCheckedChange:u=>Ze(!!u),"data-testid":"settings-theme-toggle"})]})}),Ke]})]}),e.jsx(Gs,{})]}),n==="devicesAndFiles"&&e.jsxs(e.Fragment,{children:[e.jsx(Ts,{}),e.jsx(Ms,{})]}),n==="notifications"&&e.jsxs(e.Fragment,{children:[e.jsx($,{className:"border-0 ring-0",children:e.jsxs(D,{className:"space-y-6 pt-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableBrowserBellToast")})}),e.jsx(A,{checked:E,onCheckedChange:u=>g(!!u),"data-testid":"settings-enable-browser-bell-toast"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableTelegramBellPush")})}),e.jsx(A,{checked:I,onCheckedChange:u=>Ce(!!u),"data-testid":"settings-enable-telegram-bell-push"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableBrowserNotificationToast")})}),e.jsx(A,{checked:C,onCheckedChange:u=>N(!!u),"data-testid":"settings-enable-browser-notification-toast"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:s("settings.enableTelegramNotificationPush")})}),e.jsx(A,{checked:Se,onCheckedChange:u=>Ee(!!u),"data-testid":"settings-enable-telegram-notification-push"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"bell-throttle-input",children:s("settings.bellThrottle")}),e.jsx(P,{id:"bell-throttle-input",type:"number",value:h,min:0,max:300,onChange:u=>b(Number(u.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"notification-throttle-input",children:s("settings.notificationThrottle")}),e.jsx(P,{id:"notification-throttle-input",type:"number",value:S,min:0,max:300,onChange:u=>o(Number(u.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"ssh-reconnect-retries-input",children:s("settings.sshReconnectMaxRetries")}),e.jsx(P,{id:"ssh-reconnect-retries-input",type:"number",value:Fe,min:0,max:20,onChange:u=>Pe(Number(u.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"ssh-reconnect-delay-input",children:s("settings.sshReconnectDelay")}),e.jsx(P,{id:"ssh-reconnect-delay-input",type:"number",value:Te,min:1,max:300,onChange:u=>Me(Number(u.target.value)),className:"min-h-10"})]})]}),Ke]})}),e.jsx(Ws,{}),e.jsx(Zs,{})]}),n==="ai"&&e.jsxs(e.Fragment,{children:[e.jsx(Is,{}),e.jsx(Us,{})]})]})}function at(){const{t:s}=F();return e.jsx(e.Fragment,{children:s("sidebar.settings")})}function nt(){const{t:s}=F(),[a,t]=j.useState(!1),n=k({mutationFn:async()=>{const r=await fetch("/api/settings/restart",{method:"POST"});if(!r.ok)throw new Error(await be(r,s("settings.restartFailed")))},onSuccess:()=>{y.success(s("settings.restartScheduled"))},onError:r=>{y.error(r instanceof Error?r.message:s("common.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(w,{variant:"ghost",size:"icon-sm",onClick:()=>t(!0),disabled:n.isPending,"aria-label":s("settings.restartGateway"),title:s("settings.restartGateway"),className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(Ns,{className:"h-4 w-4"})}),e.jsx(z,{open:a,onOpenChange:t,children:e.jsxs(V,{children:[e.jsxs(H,{children:[e.jsx(J,{children:s("settings.restartGateway")}),e.jsx(W,{children:s("settings.restartConfirm")})]}),e.jsxs(G,{children:[e.jsx(Z,{onClick:()=>t(!1),children:s("common.cancel")}),e.jsx(X,{variant:"destructive",onClick:()=>{n.mutate(),t(!1)},children:s("common.confirm")})]})]})})]})}export{nt as PageActions,at as PageTitle,tt as default};
|
|
32
|
+
//# sourceMappingURL=SettingsPage-Bxat-d_V.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a0 as ln,a1 as an,a2 as H,a3 as q,a4 as B,a5 as un,a6 as y,a7 as tn,a8 as L,a9 as _,aa as rn,ab as o,ac as on,ad as sn,ae as fn}from"./mermaid.core-
|
|
2
|
-
//# sourceMappingURL=arc-
|
|
1
|
+
import{a0 as ln,a1 as an,a2 as H,a3 as q,a4 as B,a5 as un,a6 as y,a7 as tn,a8 as L,a9 as _,aa as rn,ab as o,ac as on,ad as sn,ae as fn}from"./mermaid.core-DYl6mxS0.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,C,a){var O=I-l,i=D-h,n=C-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function W(l,h,I,D,v,A,C){var a=l-I,O=h-D,i=(C?A:-A)/L(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,F=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*L(on(0,T*T*R-P*P)),j=(P*g-m*S)/R,z=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=j-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(j=w,z=p),{cx:j,cy:z,x01:-n,y01:-d,x11:j*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=yn,I=B(0),D=null,v=gn,A=dn,C=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(F>tn-y)a.moveTo(s*H(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*H(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=F,S=F,j=C.apply(this,arguments)/2,z=j>y&&(D?+D.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(z>y){var G=sn(z/u*q(j)),M=sn(z/s*q(j));(P-=G*2)>y?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(S-=M*2)>y?(M*=t?1:-1,m+=M,g-=M):(S=0,m=g=(f+c)/2)}var J=s*H(m),K=s*q(m),N=u*H(T),Q=u*q(T);if(w>y){var U=s*H(g),V=s*q(g),X=u*H(R),Y=u*q(R),E;if(F<an)if(E=pn(J,K,X,Y,U,V,N,Q)){var Z=J-E[0],$=K-E[1],b=U-E[0],k=V-E[1],nn=1/q(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,g,!t)):a.moveTo(J,K),!(u>y)||!(P>y)?a.lineTo(N,Q):p>y?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:B(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:B(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|
|
2
|
+
//# sourceMappingURL=arc-CWkT1O24.js.map
|