tmex-cli 0.16.2 → 0.16.4
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 +6 -18
- package/dist/runtime/server.js +826 -243
- package/package.json +1 -1
- package/resources/fe-dist/assets/DevicePage-DxFUn3eM.js +24 -0
- package/resources/fe-dist/assets/{DevicesPage-B_jvUZtl.js → DevicesPage-CJF229QB.js} +1 -1
- package/resources/fe-dist/assets/{FilePage-DTSmWM1D.js → FilePage-CkEaJiW3.js} +1 -1
- package/resources/fe-dist/assets/{SettingsPage-LTHV37Rj.js → SettingsPage-BjsRYOBG.js} +4 -4
- package/resources/fe-dist/assets/{agent-tab-vPjPGa5f.js → agent-tab-6MAsxcE4.js} +1 -1
- package/resources/fe-dist/assets/{api-D_FToAy0.js → api-B3b18azE.js} +1 -1
- package/resources/fe-dist/assets/{arc-BSCyoyGW.js → arc-BAINpc3Q.js} +1 -1
- package/resources/fe-dist/assets/{architectureDiagram-3BPJPVTR-CBO0dAe2.js → architectureDiagram-3BPJPVTR-CWFap8y8.js} +1 -1
- package/resources/fe-dist/assets/{blockDiagram-GPEHLZMM-0ONANm30.js → blockDiagram-GPEHLZMM-BnR3WVDx.js} +1 -1
- package/resources/fe-dist/assets/{c4Diagram-AAUBKEIU-DpvhCnF8.js → c4Diagram-AAUBKEIU-BT4ZOccY.js} +1 -1
- package/resources/fe-dist/assets/{card-CD9i-fLq.js → card-TMGETMIE.js} +1 -1
- package/resources/fe-dist/assets/channel-C_D-Pin5.js +1 -0
- package/resources/fe-dist/assets/{chunk-2J33WTMH-MmS9_ur_.js → chunk-2J33WTMH-B4Tvbi6K.js} +1 -1
- package/resources/fe-dist/assets/{chunk-4BX2VUAB-CLd4Yxwh.js → chunk-4BX2VUAB-e7mC2fAZ.js} +1 -1
- package/resources/fe-dist/assets/{chunk-55IACEB6-DgCH4WwT.js → chunk-55IACEB6-CIYZgFr_.js} +1 -1
- package/resources/fe-dist/assets/{chunk-727SXJPM-B9DM5PB4.js → chunk-727SXJPM-Cp8xQ_Up.js} +1 -1
- package/resources/fe-dist/assets/{chunk-AQP2D5EJ-DQwC9D9W.js → chunk-AQP2D5EJ-C-NtHCtH.js} +1 -1
- package/resources/fe-dist/assets/{chunk-FMBD7UC4-BnvyNYGh.js → chunk-FMBD7UC4-DmjdaPSW.js} +1 -1
- package/resources/fe-dist/assets/{chunk-ND2GUHAM-BzcZgEWG.js → chunk-ND2GUHAM-Zg5krkW_.js} +1 -1
- package/resources/fe-dist/assets/{chunk-QZHKN3VN-C9BaHIUI.js → chunk-QZHKN3VN-BIuK8Di1.js} +1 -1
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-BKAkOexI.js +1 -0
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-BKAkOexI.js +1 -0
- package/resources/fe-dist/assets/{copy-DzIk8AxV.js → copy-BfbLkQQH.js} +1 -1
- package/resources/fe-dist/assets/{cose-bilkent-S5V4N54A-NkTc0ObP.js → cose-bilkent-S5V4N54A-DjsBN2Gw.js} +1 -1
- package/resources/fe-dist/assets/{dagre-BM42HDAG-BdFDBfE_.js → dagre-BM42HDAG-EHYEOgd4.js} +1 -1
- package/resources/fe-dist/assets/{diagram-2AECGRRQ-Ba4Y0igR.js → diagram-2AECGRRQ-DP2qaS44.js} +1 -1
- package/resources/fe-dist/assets/{diagram-5GNKFQAL-B4_Or8Vp.js → diagram-5GNKFQAL-CXjsd6rW.js} +1 -1
- package/resources/fe-dist/assets/{diagram-KO2AKTUF-DbmmHTYj.js → diagram-KO2AKTUF-C3imvzg0.js} +1 -1
- package/resources/fe-dist/assets/{diagram-LMA3HP47-CRrd6lc4.js → diagram-LMA3HP47-BWfVIlqx.js} +1 -1
- package/resources/fe-dist/assets/{diagram-OG6HWLK6-BOEazFIu.js → diagram-OG6HWLK6-DjPzNtRm.js} +1 -1
- package/resources/fe-dist/assets/{erDiagram-TEJ5UH35-Dk-UowK8.js → erDiagram-TEJ5UH35-B0NYaEtR.js} +1 -1
- package/resources/fe-dist/assets/{files-tab-D2vddvsj.js → files-tab-BFIlXST7.js} +1 -1
- package/resources/fe-dist/assets/{flowDiagram-I6XJVG4X-BhbGYx-g.js → flowDiagram-I6XJVG4X-CdStxlad.js} +1 -1
- package/resources/fe-dist/assets/{ganttDiagram-6RSMTGT7-iezClDTv.js → ganttDiagram-6RSMTGT7-DdEyq_eg.js} +1 -1
- package/resources/fe-dist/assets/{gitGraphDiagram-PVQCEYII-Ncqf3CQw.js → gitGraphDiagram-PVQCEYII-DVt7acpU.js} +1 -1
- package/resources/fe-dist/assets/{index-UoApkLSY.js → index-C1akMMWP.js} +63 -63
- package/resources/fe-dist/assets/{index-DOfY8kwB.js → index-c9jmHxDX.js} +1 -1
- package/resources/fe-dist/assets/{infoDiagram-5YYISTIA-CUg3PkAb.js → infoDiagram-5YYISTIA-BfBQlpuG.js} +1 -1
- package/resources/fe-dist/assets/{ishikawaDiagram-YF4QCWOH-DU0ekJw5.js → ishikawaDiagram-YF4QCWOH-DUn8fG3F.js} +1 -1
- package/resources/fe-dist/assets/{journeyDiagram-JHISSGLW-Ji7WtMH7.js → journeyDiagram-JHISSGLW-D1YteFVs.js} +1 -1
- package/resources/fe-dist/assets/{kanban-definition-UN3LZRKU-B8zVyM8Q.js → kanban-definition-UN3LZRKU-Do0o8nlT.js} +1 -1
- package/resources/fe-dist/assets/{linear-tNPPicfI.js → linear-Bmap7qQK.js} +1 -1
- package/resources/fe-dist/assets/{markdown-preview-CzbcKxcJ.js → markdown-preview-ByBN48Ac.js} +3 -3
- package/resources/fe-dist/assets/{mermaid.core-BoNU6G1d.js → mermaid.core-CloKtMOb.js} +5 -5
- package/resources/fe-dist/assets/{mindmap-definition-RKZ34NQL-D_v1LaNP.js → mindmap-definition-RKZ34NQL-BFPgS54r.js} +1 -1
- package/resources/fe-dist/assets/{pieDiagram-4H26LBE5-B1CHCpFf.js → pieDiagram-4H26LBE5-DwY4DDxv.js} +1 -1
- package/resources/fe-dist/assets/{quadrantDiagram-W4KKPZXB-DvA3zgR7.js → quadrantDiagram-W4KKPZXB-3jSLHV3z.js} +1 -1
- package/resources/fe-dist/assets/{requirementDiagram-4Y6WPE33-BCna6ZG5.js → requirementDiagram-4Y6WPE33-DHrqJmHL.js} +1 -1
- package/resources/fe-dist/assets/{sankeyDiagram-5OEKKPKP-KEllFLAf.js → sankeyDiagram-5OEKKPKP-CIaPmx-2.js} +1 -1
- package/resources/fe-dist/assets/{send-BgCF67Uc.js → send-CAJeq7VS.js} +1 -1
- package/resources/fe-dist/assets/{sequenceDiagram-3UESZ5HK-DRsq_jg_.js → sequenceDiagram-3UESZ5HK-DhRU1sO_.js} +1 -1
- package/resources/fe-dist/assets/{stateDiagram-AJRCARHV-DhATBo8D.js → stateDiagram-AJRCARHV-DZWC0te0.js} +1 -1
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-BJcIn84l.js +1 -0
- package/resources/fe-dist/assets/{terminal-settings-panel-DsMMZFBi.js → terminal-settings-panel-BiDSWGtf.js} +2 -2
- package/resources/fe-dist/assets/{timeline-definition-PNZ67QCA-Det7AzPd.js → timeline-definition-PNZ67QCA-Y0cAlUby.js} +1 -1
- package/resources/fe-dist/assets/{transfer-toast-CHcCj3qf.js → transfer-toast-yJBQc29j.js} +1 -1
- package/resources/fe-dist/assets/{triangle-alert-BjHP6Ipw.js → triangle-alert-Bs89Dzy0.js} +1 -1
- package/resources/fe-dist/assets/{vennDiagram-CIIHVFJN-BF4R466L.js → vennDiagram-CIIHVFJN-BVWElA6Q.js} +1 -1
- package/resources/fe-dist/assets/{wardley-L42UT6IY-DLHZ_6-V.js → wardley-L42UT6IY-BBf8FmIs.js} +1 -1
- package/resources/fe-dist/assets/{wardleyDiagram-YWT4CUSO-CekN3Ye6.js → wardleyDiagram-YWT4CUSO-Cyk4va1x.js} +1 -1
- package/resources/fe-dist/assets/{xychartDiagram-2RQKCTM6-CJD3yg0M.js → xychartDiagram-2RQKCTM6-DmEvYdFT.js} +1 -1
- package/resources/fe-dist/assets/{zap-Dx7JTXJN.js → zap-B28XlJER.js} +1 -1
- package/resources/fe-dist/index.html +1 -1
- package/resources/gateway-drizzle/0014_lucky_killraven.sql +1 -0
- package/resources/gateway-drizzle/meta/_journal.json +7 -0
- package/resources/fe-dist/assets/DevicePage-CgDkuNLp.js +0 -24
- package/resources/fe-dist/assets/channel-DBhb6_En.js +0 -1
- package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-9V2iXOG7.js +0 -1
- package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-9V2iXOG7.js +0 -1
- package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-Dn_gMFVD.js +0 -1
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{Y as qe,u as Ie,j as i,aD as jt,aE as Ct,aF as Nt,aG as Pt,aH as kt,at as It,r as n,d as H,af as ge,ai as ut,ah as dt,ag as Mt,aj as Lt,aI as At,aJ as _t,o as Le,aK as zt,D as Dt,p as $t,q as Bt,s as Ft,ay as ft,aL as Ze,aM as et,aw as ht,b as mt,aN as tt,aO as Ht,c as nt,aC as pt,aP as Pe,aQ as Wt,aq as Ue,y as Ot,a2 as qt,B as Ne,T as Xt,aR as Yt,aS as Ut,aT as Vt,aU as Kt,aV as Gt,$ as Qt,aW as Jt,A as Zt,f as en,g as tn,i as nn,k as rn,l as sn,m as on,n as cn}from"./index-C1akMMWP.js";import{T as an,C as ln,c as un,F as dn,a as wt,R as fn,A as hn,f as mn,t as pn,S as wn}from"./terminal-settings-panel-BiDSWGtf.js";import{e as gn}from"./selection-clipboard-D3gUQQ7L.js";import{C as xn}from"./copy-BfbLkQQH.js";import{S as ct,K as vn}from"./send-CAJeq7VS.js";const bn=/^[0-9a-fA-F]{4}$/;function Sn(t){if(typeof t!="string"||t.length<6)return null;const e=t.slice(0,4);if(!bn.test(e)||t[4]!==",")return null;const s={input:t,pos:5},c=gt(s);return!c||s.pos!==t.length?null:{checksum:e,root:c}}function Be(t){const e=t.pos;for(;t.pos<t.input.length;){const s=t.input.charCodeAt(t.pos);if(s<48||s>57)break;t.pos+=1}return t.pos===e?null:Number.parseInt(t.input.slice(e,t.pos),10)}function Fe(t,e){return t.input[t.pos]!==e?!1:(t.pos+=1,!0)}function gt(t){const e=Be(t);if(e===null||!Fe(t,"x"))return null;const s=Be(t);if(s===null||!Fe(t,","))return null;const c=Be(t);if(c===null||!Fe(t,","))return null;const u=Be(t);if(u===null)return null;const w=t.input[t.pos];if(w===","){t.pos+=1;const g=Be(t);return g===null?null:{type:"leaf",paneNumId:g,width:e,height:s,x:c,y:u}}if(w==="{"||w==="["){const g=w==="{"?"}":"]";t.pos+=1;const x=[];for(;;){const I=gt(t);if(!I)return null;if(x.push(I),!Fe(t,",")){if(Fe(t,g))break;return null}}return x.length<2?null:{type:w==="{"?"row":"column",width:e,height:s,x:c,y:u,children:x}}return null}function Ve(t){return`%${t.paneNumId}`}/**
|
|
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 yn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],En=qe("columns-2",yn);/**
|
|
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 Rn=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Tn=qe("search-x",Rn);/**
|
|
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 jn=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Cn=qe("settings-2",jn);/**
|
|
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 Nn=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Pn=qe("smartphone",Nn);function kn({open:t,onOpenChange:e}){const{t:s}=Ie();return i.jsx(jt,{open:t,onOpenChange:e,children:i.jsxs(Ct,{side:"bottom",className:"max-h-[88dvh] overflow-y-auto pb-[var(--tmex-safe-area-bottom)] sm:mx-auto sm:max-w-md sm:rounded-t-2xl sm:border sm:border-b-0","data-testid":"keyboard-behavior-sheet",children:[i.jsxs(Nt,{children:[i.jsx(Pt,{children:s("settings.terminal.title")}),i.jsx(kt,{children:s("settings.terminal.savedInBrowser")})]}),i.jsx("div",{className:"px-4 pb-4",children:i.jsx(an,{})})]})})}function In({visible:t,canPaste:e,onCopy:s,onPaste:c,onDismiss:u}){const{t:w}=Ie();if(!t)return null;const g=x=>{x.preventDefault()};return i.jsxs("div",{className:"absolute top-2 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-md backdrop-blur","data-testid":"terminal-selection-toolbar",children:[i.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:g,onClick:s,"data-testid":"terminal-selection-copy",children:[i.jsx(xn,{className:"h-4 w-4"}),w("terminal.copy")]}),e&&i.jsxs("button",{type:"button",className:"flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium hover:bg-accent hover:text-accent-foreground",onMouseDown:g,onClick:c,"data-testid":"terminal-selection-paste",children:[i.jsx(ln,{className:"h-4 w-4"}),w("terminal.paste")]}),i.jsx("button",{type:"button",className:"flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground",onMouseDown:g,onClick:u,"aria-label":w("terminal.clearSelection"),"data-testid":"terminal-selection-dismiss",children:i.jsx(It,{className:"h-4 w-4"})})]})}function xt(t){if(!t)return t;const e=t.replace(/\r\n/g,`
|
|
22
|
+
`);return(e.endsWith(`
|
|
23
|
+
`)?e.slice(0,-1):e).replace(/\n/g,`\r
|
|
24
|
+
`)}const Mn="\x1B[?1049h\x1B[H\x1B[2J";function Ln(t){return Mn+xt(t)}function An(t,e){let s=e,c=0;for(const x of t)x===10&&!s&&(c+=1),s=x===13;const u=s;if(c===0)return{normalized:t,endedWithCR:u};const w=new Uint8Array(t.length+c);let g=0;s=e;for(const x of t)x===10&&!s&&(w[g]=13,g+=1),w[g]=x,g+=1,s=x===13;return{normalized:w,endedWithCR:u}}const _n=1.3,zn=36,Dn=500,$n=12;function Bn(t,e){const s=n.useRef(!1);return n.useEffect(()=>{const c=t.current;if(!c||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;s.current=!0;let w=0,g=null,x=!1,I=0,V=0,X=0,E=null,M=!1;const Z=()=>{E!==null&&(clearTimeout(E),E=null)},r=v=>v?!!(v.closest(".scrollbar")||v.closest(".slider")||v.closest(".xterm-scroll-area")):!1,oe=(v,b,T)=>{const C=T instanceof Element?T:null;if(r(C))return!0;const A=document.elementFromPoint(v,b);if(r(A))return!0;const W=c.querySelector(".xterm");if(!(W instanceof HTMLElement))return!1;const S=W.getBoundingClientRect(),Y=v>=S.left&&v<=S.right,R=b>=S.top&&b<=S.bottom;return!Y||!R?!1:v>=S.right-zn},P=()=>[c.querySelector(".xterm-viewport"),c.querySelector(".xterm-scrollable-element")].filter(b=>b instanceof HTMLElement),ce=v=>{if(g===null)return null;for(let b=0;b<v.length;b+=1){const T=v.item(b);if(T&&T.identifier===g)return T}return null},ee=v=>{if(Z(),v.touches.length!==1)return;const b=v.touches.item(0);b&&(g=b.identifier,w=b.clientY,I=0,x=oe(b.clientX,b.clientY,v.target),V=b.clientX,X=b.clientY,M=!1,x||(E=setTimeout(()=>{var C;E=null;const T=(e==null?void 0:e())??null;(C=T==null?void 0:T.startTouchSelection)!=null&&C.call(T,V,X,"word")&&(M=!0)},Dn)))},we=v=>{var Y,R,_,z,te,L,K,ne,ue;const b=ce(v.touches)??v.touches.item(0);if(!b)return;if(M){const q=(e==null?void 0:e())??null;(Y=q==null?void 0:q.updateTouchSelection)==null||Y.call(q,b.clientX,b.clientY),v.cancelable&&v.preventDefault();return}if(E!==null&&Math.hypot(b.clientX-V,b.clientY-X)>$n&&Z(),x||(x=oe(b.clientX,b.clientY,v.target),x&&(I=0)),x)return;const T=b.clientY,C=w-T;if(w=T,C===0)return;let A=!1,W=!1;const S=(e==null?void 0:e())??null;if(S){const q=S==null?void 0:S._core,ie=((te=(z=(_=(R=q==null?void 0:q._renderService)==null?void 0:R.dimensions)==null?void 0:_.css)==null?void 0:z.cell)==null?void 0:te.height)??18;I+=C*_n;const O=I>0?Math.floor(I/ie):Math.ceil(I/ie);if(typeof S.handleViewportGesture=="function")O!==0&&(A=S.handleViewportGesture({source:"touch",deltaY:O*ie,clientX:b.clientX,clientY:b.clientY}),I-=O*ie);else if(O!==0){const N=((K=(L=S.buffer)==null?void 0:L.active)==null?void 0:K.viewportY)??0;S.scrollLines(O);const pe=((ue=(ne=S.buffer)==null?void 0:ne.active)==null?void 0:ue.viewportY)??0;A=N!==pe,W=O<0&&N<=0&&pe<=0,I-=O*ie}}else{const q=P();if(q.length===0)return;for(const ie of q){const O=ie.scrollTop;ie.scrollTop+=C;const N=ie.scrollTop;Math.abs(N-O)>0&&(A=!0),C<0&&N<=0&&(W=!0)}if(!A){const ie=c.querySelector(".xterm");if(ie instanceof HTMLElement){const O=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:C}),N=ie.dispatchEvent(O);A=O.defaultPrevented||!N}}}v.cancelable&&(A||W)&&v.preventDefault()},ae=v=>{var T;if(Z(),!(g===null||!ce(v.changedTouches))&&(g=null,I=0,x=!1,M)){M=!1;const C=(e==null?void 0:e())??null;(T=C==null?void 0:C.endTouchSelection)==null||T.call(C)}},h=v=>{M&&v.preventDefault()};return c.addEventListener("touchstart",ee,{passive:!0}),c.addEventListener("touchmove",we,{passive:!1}),c.addEventListener("touchend",ae,{passive:!0}),c.addEventListener("touchcancel",ae,{passive:!0}),c.addEventListener("contextmenu",h),()=>{s.current=!1,Z(),c.removeEventListener("touchstart",ee),c.removeEventListener("touchmove",we),c.removeEventListener("touchend",ae),c.removeEventListener("touchcancel",ae),c.removeEventListener("contextmenu",h)}},[t,e]),s}function Fn({now:t,remoteSize:e,pendingLocalSize:s,ttlMs:c=2e3}){return!s||t-s.at>c?!0:s.cols===e.cols&&s.rows===e.rows}function Hn({currentSize:t,containerSize:e,force:s=!1}){return s?!0:t.cols!==e.cols||t.rows!==e.rows}function Wn({deviceId:t,paneId:e,deviceConnected:s,isSelectionInvalid:c,sizingMode:u="report",onResize:w,onSync:g,onResizeSettled:x,getContainerRect:I}){const V=n.useRef(null),X=n.useRef(null),E=n.useRef(null),M=n.useRef(null),Z=n.useRef(0),r=n.useRef([]),oe=n.useRef(null),P=n.useRef(null),ce=n.useRef(I),ee=n.useRef(!1),we=n.useRef(w),ae=n.useRef(g),h=n.useRef(x);n.useEffect(()=>{we.current=w},[w]),n.useEffect(()=>{ae.current=g},[g]),n.useEffect(()=>{h.current=x},[x]),n.useEffect(()=>{ce.current=I},[I]);const v=n.useCallback(()=>{var ue,q,ie,O,N,pe,fe,a,l,y;const R=P.current,_=oe.current;if(!R||!_||!R.element)return null;let z;try{const $=_.proposeDimensions();if(!$)throw new Error("fitAddon.proposeDimensions() returned null");z=Math.max(2,$.cols)}catch{const $=R._core,le=((O=(ie=(q=(ue=$==null?void 0:$._renderService)==null?void 0:ue.dimensions)==null?void 0:q.css)==null?void 0:ie.cell)==null?void 0:O.width)??9,he=(N=ce.current)==null?void 0:N.call(ce);if(!he||he.width===0)return null;z=Math.max(2,Math.floor(he.width/le))}const te=(pe=ce.current)==null?void 0:pe.call(ce);if(!te||te.height===0)return null;const L=R._core,K=((y=(l=(a=(fe=L==null?void 0:L._renderService)==null?void 0:fe.dimensions)==null?void 0:a.css)==null?void 0:l.cell)==null?void 0:y.height)??17,ne=Math.max(2,Math.floor(te.height/K));return{cols:z,rows:ne}},[]),b=n.useCallback((R,_)=>{const z=P.current;z&&(z.cols===R&&z.rows===_||z.resize(R,_))},[]),T=n.useCallback((R,_=!1)=>{var ue;if(u==="follow"||!t||!e||!s||c&&R!=="sync"||!_&&Date.now()<Z.current||!P.current)return!1;const te=v();if(!te)return!1;const{cols:L,rows:K}=te,ne=E.current;return!_&&ne&&ne.cols===L&&ne.rows===K?(b(L,K),!0):(b(L,K),R==="sync"?ae.current(L,K):we.current(L,K),E.current={cols:L,rows:K},M.current={cols:L,rows:K,at:Date.now()},(ue=h.current)==null||ue.call(h,L,K),!0)},[b,s,t,c,v,e,u]),C=n.useCallback((R="resize",_={})=>{const{immediate:z=!1,force:te=!1}=_;X.current!==null&&(window.clearTimeout(X.current),X.current=null),V.current!==null&&(cancelAnimationFrame(V.current),V.current=null);const L=()=>{V.current=requestAnimationFrame(()=>{V.current=null,T(R,te)})};if(z){L();return}X.current=window.setTimeout(()=>{X.current=null,L()},150)},[T]),A=n.useCallback(()=>{for(const R of r.current)window.clearTimeout(R);r.current=[]},[]),W=n.useCallback(()=>{var _;A(),C("sync",{immediate:!0,force:!0});const R=window.setTimeout(()=>{C("sync",{immediate:!0,force:!0})},60);r.current.push(R),typeof document<"u"&&"fonts"in document&&((_=document.fonts)!=null&&_.ready)&&document.fonts.ready.then(()=>{C("sync",{immediate:!0,force:!0})}).catch(()=>{})},[A,C]);n.useEffect(()=>{let R=null;const _=()=>{R!==null&&cancelAnimationFrame(R),R=requestAnimationFrame(()=>{R=null,C("resize")})};return window.addEventListener("resize",_),()=>{window.removeEventListener("resize",_),R!==null&&cancelAnimationFrame(R)}},[C]),n.useEffect(()=>{const R=()=>{var ue;const L=P.current,K=v();if(!L||!K)return;if(!Hn({currentSize:{cols:Math.max(2,L.cols),rows:Math.max(2,L.rows)},containerSize:K})){(ue=L.forceFullRepaint)==null||ue.call(L);return}C("sync",{force:!0})},_=()=>{if(document.visibilityState!=="visible"){ee.current=!0;return}ee.current&&(ee.current=!1,R())},z=()=>{ee.current=!0},te=()=>{ee.current&&(ee.current=!1,R())};return document.addEventListener("visibilitychange",_),window.addEventListener("blur",z),window.addEventListener("focus",te),()=>{document.removeEventListener("visibilitychange",_),window.removeEventListener("blur",z),window.removeEventListener("focus",te)}},[v,C]),n.useEffect(()=>()=>{A(),X.current!==null&&window.clearTimeout(X.current),V.current!==null&&cancelAnimationFrame(V.current)},[A]);const S=n.useCallback(R=>{oe.current=R},[]),Y=n.useCallback(R=>{P.current=R},[]);return{scheduleResize:C,runPostSelectResize:W,clearPostSelectResizeTimers:A,setFitAddon:S,setTerminal:Y,lastReportedSize:E,pendingLocalSize:M,suppressLocalResizeUntil:Z}}const On=1e4,Ge="tmex:terminal-mode-cache";function qn(t,e){try{const s=sessionStorage.getItem(Ge);return s?JSON.parse(s)[`${t}:${e}`]??null:null}catch{return null}}function Xn(t,e,s){try{const c=sessionStorage.getItem(Ge),u=c?JSON.parse(c):{},w=`${t}:${e}`;s?u[w]=s:delete u[w],sessionStorage.setItem(Ge,JSON.stringify(u))}catch{}}function Yn(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function Un(t,e){if(!e)return t?{...t,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const s=Yn();if(!t)return s;const c=t.mouseNormal||t.mouseButton||t.mouseAny;return{...t,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:c?t.mouseNormal:s.mouseNormal}}function Vn(t){var s;const e=globalThis;e.__tmexE2eXterm=t,e.__tmexE2eTerminal=t,e.__tmexE2eTerminalEngine=wt,e.__tmexE2eTerminalRenderer=((s=t.getRendererKind)==null?void 0:s.call(t))??null}function Kn(t){if(!t)return;const e=globalThis;e.__tmexE2eTerminal!==t&&e.__tmexE2eXterm!==t||(e.__tmexE2eXterm=null,e.__tmexE2eTerminal=null,e.__tmexE2eTerminalEngine=null,e.__tmexE2eTerminalRenderer=null,e.__tmexE2eTerminalSelectionText=null)}const rt=n.forwardRef(({deviceId:t,paneId:e,theme:s,inputMode:c,deviceConnected:u,isSelectionInvalid:w,sizingMode:g="report",autoFocus:x=!0,focused:I=!0,onResize:V,onSync:X,onResizeSettled:E,children:M},Z)=>{const[r,oe]=n.useState(null),[P,ce]=n.useState(!1),ee=H(d=>d.sendInput),we=ge(d=>d.terminalFontId),ae=ge(d=>d.terminalFontSize),h=ge(d=>d.terminalLineHeight),{t:v}=Ie(),b=n.useMemo(()=>{switch(s){case"light":return dt;default:return ut}},[s]),T=n.useRef(null),C=n.useRef(null),A=n.useRef(null),W=n.useRef(t),S=n.useRef(e),Y=n.useRef(t),R=n.useRef(e),_=n.useRef(u&&!w),z=n.useRef(c),te=n.useRef(b),L=n.useRef(!1),K=n.useRef(!1),ne=n.useRef(null),ue=n.useRef(!1),q=n.useCallback((d,f,j)=>{!(d!=null&&d.exportModeSnapshot)||!f||!j||Xn(f,j,d.exportModeSnapshot())},[]),ie=n.useCallback(()=>r,[r]);Bn(T,ie),n.useEffect(()=>{W.current=t,S.current=e,K.current=!1},[t,e]),n.useEffect(()=>{_.current=u&&!w},[u,w]),n.useEffect(()=>{z.current=c},[c]),n.useEffect(()=>{te.current=b},[b]);const O=n.useCallback(d=>{if(!d||c!=="direct"||!_.current)return;const f=W.current,j=S.current;!f||!j||ee(f,j,d,!1)},[c,ee]),{pendingLocalSize:N,scheduleResize:pe,runPostSelectResize:fe,setFitAddon:a,setTerminal:l}=Wn({deviceId:t,paneId:e,deviceConnected:u,isSelectionInvalid:w,sizingMode:g,onResize:V,onSync:X,onResizeSettled:E,getContainerRect:()=>{const d=T.current;if(!d)return null;const f=d.getBoundingClientRect();return{width:f.width,height:f.height}}});n.useEffect(()=>{let d=!1,f=null;return(async()=>{if(await Mt(we,ae),d)return;const j=await un({fontFamily:Lt(we),fontSize:ae,lineHeight:h,scrollback:On,theme:te.current,disableStdin:z.current==="editor"});if(d){j.dispose();return}f=j,C.current&&j.open(C.current),oe(j)})(),()=>{d=!0,oe(null),Kn(f),f==null||f.dispose()}},[we,ae,h]),n.useEffect(()=>{!r||!x||Vn(r)},[r,x]),n.useEffect(()=>{var d;(d=r==null?void 0:r.setFocused)==null||d.call(r,I)},[r,I]),n.useEffect(()=>{!r||!("setTheme"in r)||r.setTheme(b)},[r,b]),n.useEffect(()=>{!r||!("setDisableStdin"in r)||r.setDisableStdin(c==="editor")},[r,c]),n.useEffect(()=>{if(!(r!=null&&r.getCursorViewportRect))return;const d=()=>{var f;return((f=r.getCursorViewportRect)==null?void 0:f.call(r))??null};return zt(d),()=>At(d)},[r]),n.useEffect(()=>{!r||c!=="direct"||!x||window.innerWidth<768||"ontouchstart"in window||r.focus()},[r,c,x]);const y=n.useMemo(()=>r?{onReset:()=>{q(r,Y.current,R.current),ue.current=!0,r.reset(),L.current=!1,fe()},onApplyHistory:(d,f)=>{var U,J;const j=Un(qn(W.current,S.current),f);j&&((U=r.restoreModeSnapshot)==null||U.call(r,j));const B=f?Ln(d):xt(d);K.current=!0,r.write(B),(J=r.forceFullRepaint)==null||J.call(r),ue.current=!1,Y.current=W.current,R.current=S.current,q(r,W.current,S.current)},onOutput:d=>{const f=An(d,L.current);L.current=f.endedWithCR,r.write(f.normalized),K.current&&(r.buffer.active.baseY<=1&&r.scrollToTop(),K.current=!1),Y.current=W.current,R.current=S.current,q(r,W.current,S.current)}}:null,[r,q,fe]);n.useEffect(()=>{r?ne.current!==r&&(L.current=!1,Y.current=W.current,R.current=S.current,ne.current=r):ne.current=null},[r]),n.useEffect(()=>{if(!(!r||!t||!e))return()=>{if(ue.current){ue.current=!1;return}q(r,Y.current,R.current)}},[t,r,e,q]),n.useEffect(()=>{if(!(!y||!t||!e))return _t(t,e,y)},[y,t,e]),n.useEffect(()=>{if(!r){A.current=null,a(null),l(null);return}const d=new dn;return r.loadAddon(d),A.current=d,a(d),l(r),fe(),()=>{try{d.dispose()}finally{A.current=null,a(null),l(null)}}},[r,fe,a,l]),n.useEffect(()=>{const d=T.current;if(!d)return;let f=null;const j=new ResizeObserver(()=>{f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,pe("resize")})});return j.observe(d),()=>{j.disconnect(),f!==null&&cancelAnimationFrame(f)}},[pe]),n.useEffect(()=>{if(!r||!t||!e)return;const d=r.onData(f=>{!u||w||O(f)});return r.attachCustomKeyEventHandler(f=>!u||w||f.type!=="keydown"||c!=="direct"?!0:f.shiftKey&&f.key==="Enter"?(f.preventDefault(),O("\x1B[13;2u"),!1):!0),()=>{d.dispose(),r.attachCustomKeyEventHandler(()=>!0)}},[r,u,w,c,O,t,e]),n.useEffect(()=>{if(!(r!=null&&r.onLinkActivated))return;const d=r.onLinkActivated(f=>{window.open(f,"_blank","noopener,noreferrer")});return()=>d.dispose()},[r]),n.useEffect(()=>{if(!(r!=null&&r.onSelectionChange)){ce(!1);return}const d=r.onSelectionChange(f=>{ce(!!f)});return()=>{d.dispose(),ce(!1)}},[r]);const $=n.useCallback(()=>{var f;if(!r)return;const d=((f=r.getSelection)==null?void 0:f.call(r))??"";d&&gn(d).then(()=>{Le.success(v("terminal.copied"))}).catch(()=>{Le.error(v("terminal.copyFailed"))}).finally(()=>{var j;(j=r.clearSelection)==null||j.call(r),r.focus()})},[r,v]),le=n.useCallback(()=>{var f;if(!r)return;((f=navigator.clipboard)!=null&&f.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(j=>{var B;j&&r.paste(j),(B=r.clearSelection)==null||B.call(r),r.focus()}).catch(()=>{Le.error(v("terminal.pasteFailed"))})},[r,v]),he=n.useCallback(()=>{var d;(d=r==null?void 0:r.clearSelection)==null||d.call(r),r==null||r.focus()},[r]);return n.useImperativeHandle(Z,()=>({write:d=>r==null?void 0:r.write(d),reset:()=>{r==null||r.reset(),L.current=!1},scrollToBottom:()=>r==null?void 0:r.scrollToBottom(),resize:(d,f)=>r==null?void 0:r.resize(d,f),getTerminal:()=>r??null,getSize:()=>r?{cols:Math.max(2,r.cols),rows:Math.max(2,r.rows)}:null,runPostSelectResize:()=>fe(),scheduleResize:(d,f)=>pe(d,f),calculateSizeFromContainer:()=>{var Te,xe,F,re,D,G,Q,de,Ee,Re,ve,Me,Ae,ze,me,_e;const d=T.current,f=r,j=A.current;if(!d||!f)return null;const B=d.getBoundingClientRect();if(B.width===0||B.height===0)return null;const U=f._core;let J;if(j)try{const je=j.proposeDimensions();if(je)J=Math.max(2,je.cols);else{const De=((re=(F=(xe=(Te=U==null?void 0:U._renderService)==null?void 0:Te.dimensions)==null?void 0:xe.css)==null?void 0:F.cell)==null?void 0:re.width)??9;J=Math.max(2,Math.floor(B.width/De))}}catch{const je=((de=(Q=(G=(D=U==null?void 0:U._renderService)==null?void 0:D.dimensions)==null?void 0:G.css)==null?void 0:Q.cell)==null?void 0:de.width)??9;J=Math.max(2,Math.floor(B.width/je))}else{const je=((Me=(ve=(Re=(Ee=U==null?void 0:U._renderService)==null?void 0:Ee.dimensions)==null?void 0:Re.css)==null?void 0:ve.cell)==null?void 0:Me.width)??9;J=Math.max(2,Math.floor(B.width/je))}const Ce=((_e=(me=(ze=(Ae=U==null?void 0:U._renderService)==null?void 0:Ae.dimensions)==null?void 0:ze.css)==null?void 0:me.cell)==null?void 0:_e.height)??17,ye=Math.max(2,Math.floor(B.height/Ce));return{cols:J,rows:ye}},getPendingLocalSize:()=>N.current,getCellSize:()=>{var j,B,U;const d=r==null?void 0:r._core,f=(U=(B=(j=d==null?void 0:d._renderService)==null?void 0:j.dimensions)==null?void 0:B.css)==null?void 0:U.cell;return!(f!=null&&f.width)||!(f!=null&&f.height)?null:{width:f.width,height:f.height}}}),[r,N,fe,pe]),i.jsxs("div",{className:"flex h-full w-full flex-col",style:{backgroundColor:b.background},"data-terminal-engine":wt,children:[i.jsxs("div",{ref:T,className:"relative min-h-0 w-full flex-1",children:[i.jsx("div",{ref:C,className:"absolute inset-0"}),i.jsx(In,{visible:P,canPaste:c==="direct"&&u&&!w,onCopy:$,onPaste:le,onDismiss:he})]}),M]})});rt.displayName="Terminal";function Gn({window:t,currentPaneId:e,onSelectPane:s}){const{t:c}=Ie();return i.jsxs(Dt,{children:[i.jsxs($t,{"data-testid":"pane-switcher-button","aria-label":c("window.switchPane"),title:c("window.switchPane"),className:"relative inline-flex size-7 items-center justify-center rounded-[min(var(--radius-md),12px)] text-sm hover:bg-muted hover:text-foreground data-popup-open:bg-muted",children:[i.jsx(En,{className:"h-4 w-4"}),i.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary px-0.5 text-[9px] font-medium leading-none text-primary-foreground",children:t.panes.length})]}),i.jsx(Bt,{align:"end",backdrop:!0,className:"min-w-56 max-w-[80vw]","data-testid":"pane-switcher-menu",children:t.panes.map(u=>{const w=u.id===e;return i.jsxs(Ft,{"data-testid":"pane-switcher-item","data-pane-id":u.id,className:`py-2 [@media(any-pointer:coarse)]:py-2.5 ${w?"bg-primary/10 text-primary":u.active?"bg-accent text-accent-foreground":""}`,onClick:()=>{w||s(u.id)},children:[i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"font-mono text-[11px] leading-tight font-medium line-clamp-2 [overflow-wrap:break-word]",children:u.customName||u.title||c("window.pane")}),u.currentCommand&&i.jsx("span",{className:"font-mono text-[10.5px] leading-tight text-muted-foreground line-clamp-1 break-all",children:u.currentPath?`${u.currentCommand}@${u.currentPath}`:u.currentCommand})]}),w&&i.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-primary"})]},u.id)})})]})}function Qn(t,e){return ft(s=>{for(const c of Object.values(s.sessions))if(!(!c||c.deviceId!==t||c.paneId!==e)&&!(c.status==="stopped"||c.status==="error")){if(c.status==="running"){const u=s.inProgress[c.id];return u&&(u.texts.length>0||u.toolCalls.length>0||u.reasonings.length>0),"generating"}return"bound"}return"none"})}function Qe(t){return t.type==="leaf"?t:t.type==="row"?Qe(t.children[t.children.length-1]):Qe(t.children[0])}function Je(t){return t.type==="leaf"?t:t.type==="column"?Je(t.children[t.children.length-1]):Je(t.children[0])}function Jn(t,e){const s=[],c=[],u=w=>{if(w.type==="leaf"){s.push({paneId:Ve(w),cols:w.width,rows:w.height,rect:{left:w.x*e.width,top:w.y*e.height,width:w.width*e.width,height:w.height*e.height}});return}for(let g=0;g<w.children.length;g+=1){const x=w.children[g];if(u(x),g!==w.children.length-1)if(w.type==="row"){const I=Qe(x);c.push({axis:"x",rect:{left:(x.x+x.width)*e.width,top:w.y*e.height,width:e.width,height:w.height*e.height},edgeLeafPaneId:Ve(I)})}else{const I=Je(x);c.push({axis:"y",rect:{left:w.x*e.width,top:(x.y+x.height)*e.height,width:w.width*e.width,height:e.height},edgeLeafPaneId:Ve(I)})}}};return u(t),{panes:s,gutters:c}}function We(t){if(t.type==="leaf")return 1;if(t.type==="column"){let s=0;for(const c of t.children)s+=We(c);return s}let e=1;for(const s of t.children)e=Math.max(e,We(s));return e}function Oe(t){if(t.type==="leaf")return 1;if(t.type==="row"){let s=0;for(const c of t.children)s+=Oe(c);return s}let e=1;for(const s of t.children)e=Math.max(e,Oe(s));return e}function Zn(t,e){const s=We(t),c=Oe(t),u=Math.max(0,e.viewport.width-c*e.paneChrome.width),w=Math.max(0,e.viewport.height-s*e.paneChrome.height),g=Math.max(2,Math.floor(u/e.cell.width)),x=Math.max(2,Math.floor(w/e.cell.height));return{cols:g,rows:x}}function er(t){return t?t.panes.map(e=>`${e.paneId}:${e.cols}x${e.rows}`).join("|"):""}function tr(t,e){const s=Math.min(1,Math.max(0,t)),c=Math.min(1,Math.max(0,e)),u=[["left",s],["right",1-s],["top",c],["bottom",1-c]];return u.sort((w,g)=>w[1]-g[1]),u[0][0]}const at=150,nr=200,rr=15,sr=46,or=38,ir=12,cr=6;function lt(t){var e,s;return((e=t==null?void 0:t.customName)==null?void 0:e.trim())||((s=t==null?void 0:t.title)==null?void 0:s.trim())||"Pane"}function ar(t){var c,u;const e=(c=t==null?void 0:t.currentCommand)==null?void 0:c.trim();if(!e)return null;const s=(u=t==null?void 0:t.currentPath)==null?void 0:u.trim();return s?`${e}@${s}`:e}function lr({paneId:t}){return Ze(s=>!!s.ringingPanes[t])?i.jsx("span",{className:"bell-blink shrink-0",children:"🔔 "}):null}function ur({deviceId:t,paneId:e}){const{t:s}=Ie(),c=Qn(t,e);return c==="none"?null:c==="generating"?i.jsxs("span",{className:"shrink-0 select-none text-xs",title:s("agent.paneBadge.generating"),"aria-label":s("agent.paneBadge.generating"),children:["🤖",i.jsx("span",{className:"ml-0.5 text-[10px] animate-pulse",children:"✨"})]}):i.jsx("span",{className:"text-muted-foreground/60 shrink-0 select-none text-xs grayscale",title:s("agent.paneBadge.bound"),"aria-label":s("agent.paneBadge.bound"),children:"🤖"})}const dr={left:"left-0 top-0 bottom-0 w-1/2",right:"right-0 top-0 bottom-0 w-1/2",top:"left-0 right-0 top-0 h-1/2",bottom:"left-0 right-0 bottom-0 h-1/2"};function fr({deviceId:t,window:e,focusedPaneId:s,theme:c,inputMode:u,deviceConnected:w,focusedTerminalRef:g,onUserSelectPane:x,onWindowResize:I,onWindowResizeSettled:V}){var N,pe,fe;const X=n.useRef(null),E=n.useRef(new Map),[M,Z]=n.useState(null),[r,oe]=n.useState(null),{t:P}=Ie(),ce=H(a=>a.subscribePanes),ee=H(a=>a.fetchPaneHistory),we=H(a=>a.resizePaneInWindow),ae=H(a=>a.movePane),h=H(a=>a.breakPane),v=H(a=>a.closePane),b=n.useMemo(()=>{const a=new Map;for(const l of e.panes)a.set(l.id,l);return a},[e.panes]),T=n.useMemo(()=>e.layout?Sn(e.layout):null,[e.layout]),C=n.useMemo(()=>T?Jn(T.root,{width:1,height:1}):null,[T]),A=n.useRef(C);A.current=C;const W=(T==null?void 0:T.root.width)??1,S=(T==null?void 0:T.root.height)??1,Y=e.panes.map(a=>a.id).join(",");n.useEffect(()=>(ce(t,Y?Y.split(","):[]),()=>{ce(t,[])}),[t,Y,ce]);const R=n.useRef({key:"",fetched:new Set});n.useEffect(()=>{const a=`${t}:${e.id}`;R.current.key!==a&&(R.current={key:a,fetched:new Set});for(const l of Y?Y.split(","):[])R.current.fetched.has(l)||l!==s&&(R.current.fetched.add(l),ee(t,l))},[t,e.id,Y,s,ee]),n.useEffect(()=>{var l,y;u!=="direct"||window.innerWidth<768||"ontouchstart"in window||(y=(l=E.current.get(s))==null?void 0:l.getTerminal())==null||y.focus()},[s,u]);const _=n.useCallback(()=>{var a;for(const l of[s,...E.current.keys()]){const y=(a=E.current.get(l))==null?void 0:a.getCellSize();if(y)return y}return null},[s]),z=er(C);n.useEffect(()=>{var l;const a=A.current;if(a)for(const y of a.panes)(l=E.current.get(y.paneId))==null||l.resize(y.cols,y.rows)},[z]);const te=n.useMemo(()=>T?We(T.root):1,[T]),L=n.useMemo(()=>T?Oe(T.root):1,[T]),K=n.useCallback(()=>{const a=X.current;if(!a||!T)return!1;const l=a.getBoundingClientRect();if(l.width<1||l.height<1)return!1;const y=_();if(!y)return!1;const{cols:$,rows:le}=Zn(T.root,{viewport:{width:l.width,height:l.height},cell:y,paneChrome:{width:ir,height:sr}});return I($,le),V==null||V($,le),!0},[_,T,I,V]),ne=n.useRef(K);n.useEffect(()=>{ne.current=K},[K]),n.useEffect(()=>{const a=X.current;if(!a)return;let l=null,y=null,$=0;const le=()=>{if(ne.current()){$=0;return}$<rr&&($+=1,y=setTimeout(le,nr))},he=new ResizeObserver(()=>{l&&clearTimeout(l),l=setTimeout(le,at)});return he.observe(a),()=>{he.disconnect(),l&&clearTimeout(l),y&&clearTimeout(y)}},[]),n.useEffect(()=>{const a=setTimeout(()=>{ne.current()},at);return()=>clearTimeout(a)},[te,L]);const ue=n.useCallback((a,l,y)=>{y.preventDefault();const $=X.current;if(!$)return;const le=y.clientX,he=y.clientY,d=y.currentTarget;d.setPointerCapture(y.pointerId),Z({gutterIndex:a,deltaPx:0});const f=J=>{const Ce=l.axis==="x"?J.clientX-le:J.clientY-he;Z({gutterIndex:a,deltaPx:Ce})},j=(J,Ce)=>{if(d.removeEventListener("pointermove",f),d.removeEventListener("pointerup",B),d.removeEventListener("pointercancel",U),window.removeEventListener("pointerup",B),window.removeEventListener("pointercancel",U),Z(null),!Ce)return;const ye=_();if(!ye)return;const Te=l.axis==="x"?J.clientX-le:J.clientY-he,xe=l.axis==="x"?ye.width:ye.height;if(xe<=0)return;const F=Math.round(Te/xe);if(F===0)return;const re=$.querySelector(`[data-pane-id="${l.edgeLeafPaneId}"]`);if(!re)return;const D=re.getBoundingClientRect(),Q=(l.axis==="x"?Math.floor(D.width/xe):Math.floor(D.height/xe))+F;Q<2||(ne.current(),we(t,l.edgeLeafPaneId,l.axis==="x"?{cols:Q}:{rows:Q}))},B=J=>j(J,!0),U=J=>j(J,!1);d.addEventListener("pointermove",f),window.addEventListener("pointerup",B),window.addEventListener("pointercancel",U)},[t,_,we]),q=n.useCallback((a,l)=>{const y=X.current,$=C;if(!y||!$)return;l.preventDefault();const le=l.clientX,he=l.clientY,d=l.currentTarget;d.setPointerCapture(l.pointerId);let f=!1;const j=(F,re)=>{const D=y.getBoundingClientRect();if(D.width<1||D.height<1)return null;const G=(F-D.left)/D.width*Math.max(1,W),Q=(re-D.top)/D.height*Math.max(1,S);for(const de of $.panes)if(G>=de.rect.left&&G<=de.rect.left+de.rect.width&&Q>=de.rect.top&&Q<=de.rect.top+de.rect.height){const Ee=(G-de.rect.left)/Math.max(1e-6,de.rect.width),Re=(Q-de.rect.top)/Math.max(1e-6,de.rect.height);return{paneId:de.paneId,position:tr(Ee,Re)}}return null},B=(F,re,D)=>F>=D.left&&F<=D.right&&re>=D.top&&re<=D.bottom,U=(F,re)=>{for(const D of Array.from(document.querySelectorAll('[data-testid^="window-item-"]'))){const G=D.getBoundingClientRect();if(G.width<1||!B(F,re,G))continue;const Q=(D.getAttribute("data-testid")??"").replace("window-item-","");return!Q||Q===e.id?null:{type:"window",windowId:Q,rect:{left:G.left,top:G.top,width:G.width,height:G.height}}}for(const D of Array.from(document.querySelectorAll('[data-slot="sidebar"]'))){const G=D.getBoundingClientRect();if(!(G.width<1||!B(F,re,G)))return{type:"break",rect:{left:G.left,top:G.top,width:G.width,height:G.height}}}return null},J=(F,re)=>{const D=j(F,re);return D?D.paneId===a?null:{type:"pane",...D}:U(F,re)},Ce=F=>{const re=Math.hypot(F.clientX-le,F.clientY-he);!f&&re<cr||(f=!0,oe({srcPaneId:a,active:!0,pointerX:F.clientX,pointerY:F.clientY,target:J(F.clientX,F.clientY)}))},ye=(F,re)=>{var G,Q;if(d.removeEventListener("pointermove",Ce),d.removeEventListener("pointerup",Te),d.removeEventListener("pointercancel",xe),window.removeEventListener("pointerup",Te),window.removeEventListener("pointercancel",xe),oe(null),!re||!f)return;const D=J(F.clientX,F.clientY);if(D){if(D.type==="pane"){ae(t,a,D.paneId,D.position);return}if(D.type==="window"){const de=(Q=(G=H.getState().snapshots[t])==null?void 0:G.session)==null?void 0:Q.windows,Ee=de==null?void 0:de.find(ve=>ve.id===D.windowId),Re=(Ee==null?void 0:Ee.panes.find(ve=>ve.active))??(Ee==null?void 0:Ee.panes[0]);Re&&ae(t,a,Re.id,"right");return}h(t,a)}},Te=F=>ye(F,!0),xe=F=>ye(F,!1);d.addEventListener("pointermove",Ce),window.addEventListener("pointerup",Te),window.addEventListener("pointercancel",xe)},[t,C,ae,h,W,S,e.id]),ie=n.useCallback(a=>l=>{var y;if(l){E.current.set(a,l);const $=(y=A.current)==null?void 0:y.panes.find(le=>le.paneId===a);$&&l.resize($.cols,$.rows)}else E.current.delete(a);a===s&&g(l)},[s,g]);if(n.useEffect(()=>{g(E.current.get(s)??null)},[s,g]),!C)return null;const O=(a,l)=>`${a/Math.max(1,l)*100}%`;return i.jsxs("div",{ref:X,className:"relative h-full w-full min-h-0 min-w-0","data-testid":"split-terminal-area",children:[C.panes.map(a=>{var d;const l=a.paneId===s,y=b.get(a.paneId),$=ar(y),le=(r==null?void 0:r.active)&&r.srcPaneId===a.paneId,he=r!=null&&r.active&&((d=r.target)==null?void 0:d.type)==="pane"&&r.target.paneId===a.paneId?r.target.position:null;return i.jsxs("div",{className:`absolute flex flex-col overflow-hidden ${le?"opacity-60":""}`,"data-testid":"split-pane","data-pane-id":a.paneId,"data-focused":l||void 0,style:{left:O(a.rect.left,W),top:O(a.rect.top,S),width:O(a.rect.width,W),height:O(a.rect.height,S)},onPointerDownCapture:()=>{l||x(e.id,a.paneId)},children:[i.jsx("div",{className:"shrink-0 px-1.5 pt-1.5 pb-2",style:{height:or},children:i.jsxs("div",{"data-testid":"split-pane-titlebar","data-active":l||void 0,className:`flex h-6 cursor-grab touch-none select-none items-center gap-1.5 rounded-md px-2.5 transition-colors active:cursor-grabbing ${l?"bg-foreground/10":"bg-foreground/[0.04]"}`,onPointerDown:f=>q(a.paneId,f),children:[i.jsx(lr,{paneId:a.paneId}),i.jsx(ur,{deviceId:t,paneId:a.paneId}),i.jsx("span",{className:`shrink-0 truncate font-mono text-[10.5px] leading-none ${l?"text-foreground/90":"text-foreground/50"}`,children:lt(y)}),$&&i.jsx("span",{className:`min-w-0 flex-1 truncate font-mono text-[10px] leading-none ${l?"text-muted-foreground":"text-muted-foreground/60"}`,children:$}),i.jsx("button",{type:"button","data-testid":`split-pane-close-${a.paneId}`,"aria-label":P("window.closePane"),title:P("window.closePane"),className:"ml-auto flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground/50 hover:bg-foreground/10 hover:text-foreground",onPointerDown:f=>f.stopPropagation(),onClick:f=>{f.stopPropagation(),v(t,a.paneId)},children:i.jsx("span",{className:"text-xs leading-none",children:"×"})})]})}),i.jsx("div",{className:"relative min-h-0 flex-1 overflow-hidden px-1.5 pb-2","data-pane-content-id":a.paneId,children:i.jsx(rt,{ref:ie(a.paneId),deviceId:t,paneId:a.paneId,theme:c,inputMode:u,deviceConnected:w,isSelectionInvalid:!1,sizingMode:"follow",autoFocus:l,focused:l,onResize:()=>{},onSync:()=>{}},`${t}:${a.paneId}`)}),he&&i.jsx("div",{"data-testid":"split-pane-drop-preview","data-position":he,className:`pointer-events-none absolute z-30 rounded-sm bg-primary/20 ring-1 ring-inset ring-primary/60 ${dr[he]}`})]},a.paneId)}),(M!==null||(r==null?void 0:r.active))&&i.jsx("div",{"data-testid":"split-drag-shield",className:`absolute inset-0 z-30 ${M!==null?((N=C.gutters[M.gutterIndex])==null?void 0:N.axis)==="x"?"cursor-col-resize":"cursor-row-resize":"cursor-grabbing"}`}),(r==null?void 0:r.active)&&r.target&&r.target.type!=="pane"&&i.jsx("div",{"data-testid":"split-pane-sidebar-drop","data-drop-type":r.target.type,className:"pointer-events-none fixed z-40 rounded-lg bg-primary/15 ring-1 ring-inset ring-primary/50",style:{left:r.target.rect.left,top:r.target.rect.top,width:r.target.rect.width,height:r.target.rect.height}}),(r==null?void 0:r.active)&&i.jsxs("div",{className:"pointer-events-none fixed z-50 rounded border border-primary/40 bg-popover/95 px-2 py-1 font-mono text-[10.5px] text-popover-foreground shadow-md",style:{left:r.pointerX+12,top:r.pointerY+12},children:[i.jsx("div",{children:lt(b.get(r.srcPaneId))}),((pe=r.target)==null?void 0:pe.type)==="window"&&i.jsx("div",{className:"text-[9.5px] text-muted-foreground",children:P("window.moveToWindow")}),((fe=r.target)==null?void 0:fe.type)==="break"&&i.jsx("div",{className:"text-[9.5px] text-muted-foreground",children:P("window.breakToWindow")})]}),C.gutters.map((a,l)=>{const y=a.axis==="x",$=(M==null?void 0:M.gutterIndex)===l;return i.jsxs("div",{className:"absolute z-20",style:{left:O(a.rect.left,W),top:O(a.rect.top,S),width:O(y?1:a.rect.width,W),height:O(y?a.rect.height:1,S)},children:[i.jsx("div",{"data-testid":"split-gutter","data-axis":a.axis,className:`absolute touch-none select-none ${y?"-inset-x-1 inset-y-0 cursor-col-resize":"inset-x-0 -inset-y-1 cursor-row-resize"}`,onPointerDown:le=>ue(l,a,le),children:i.jsx("div",{className:`absolute bg-foreground/[0.08] transition-colors hover:bg-primary/50 ${y?"inset-y-0 left-1/2 w-px -translate-x-1/2":"inset-x-0 top-1/2 h-px -translate-y-1/2"} ${$?"bg-primary":""}`})}),$&&M&&i.jsx("div",{className:"pointer-events-none absolute bg-primary/70",style:y?{top:0,bottom:0,width:2,left:`calc(50% + ${M.deltaPx}px)`}:{left:0,right:0,height:2,top:`calc(50% + ${M.deltaPx}px)`}})]},`${e.layout??""}:${l}`)})]})}const hr=1200,mr=2e3;function ke(t,e){return!t||!e?!1:t.windowId===e.windowId&&t.paneId===e.paneId}function vt(t,e){const s=t.filter(c=>e-c.at<hr);return s.length===0?null:s.reduce((c,u)=>u.at>c.at?u:c)}function He(t,e=Date.now()){return!t||e-t.at>mr?null:t}function pr(t){const e=t.now??Date.now(),s=vt(t.recentSelectRequests,e),c=w=>!!(w&&w.paneId===t.activePaneFromEvent.paneId&&w.windowId!==t.activePaneFromEvent.windowId);if(s&&!ke(s,t.activePaneFromEvent)&&!c(s)||ke(t.currentRoute,t.activePaneFromEvent)||ke(t.lastHandledActive,t.activePaneFromEvent))return!0;const u=He(t.pendingUserSelection,e);return!!(u&&!ke(u,t.activePaneFromEvent)&&!c(u))}function wr(t){const e=t.now??Date.now(),s=vt(t.recentSelectRequests,e),c=He(t.pendingUserSelection,e);return!!(c&&!ke(c,t.snapshotActive)||s&&!ke(s,t.snapshotActive))}function gr(t){const e=t.now??Date.now(),s=He(t.pendingUserSelection,e);return!(s&&ke(s,t.routeTarget)||t.snapshotActive&&ke(t.snapshotActive,t.routeTarget))}const Ke=n.memo(function({onActivate:e,disabled:s}){const{data:c}=nt({queryKey:pn,queryFn:mn,staleTime:6e4}),u=(c==null?void 0:c.items)??[];return u.length===0?null:i.jsx("div",{className:"terminal-shortcuts-strip","data-testid":"terminal-shortcuts-strip",children:i.jsx(wn,{items:u,useIcons:(c==null?void 0:c.useIcons)??!1,onActivate:e,disabled:s,preventFocusSteal:!0,rowTestId:"terminal-shortcuts-row",idPrefix:"terminal-shortcut"})})});function Er(){var it;const{t}=Ie(),{deviceId:e,windowId:s,paneId:c}=et(),u=ht(),w=n.useRef(null),g=n.useRef(null),x=n.useRef(null),I=n.useRef(null),V=n.useRef(!1),X=n.useRef(!1),E=n.useRef(null),M=H(o=>o.selectPane),Z=H(o=>o.focusPane),r=H(o=>e?o.snapshots[e]:void 0),oe=H(o=>{var m;return e?(m=o.deviceErrors)==null?void 0:m[e]:void 0}),P=H(o=>{var m;return e?((m=o.deviceConnected)==null?void 0:m[e])??!1:!1}),ee=!!H(o=>{var m;return e?(m=o.deviceReconnecting)==null?void 0:m[e]:void 0}),we=H(o=>e?o.connectedDevices.has(e):!1),ae=mt(o=>{var m;return((m=o.settings)==null?void 0:m.siteName)??"tmex"}),h=n.useMemo(()=>tt(c),[c]),v=n.useMemo(()=>e&&h?`${e}:${h}`:null,[e,h]),[b,T]=n.useState(!1),C=n.useRef(!1);n.useEffect(()=>{C.current=b},[b]);const[A,W]=n.useState(""),S=n.useRef(!1),Y=!P||!h,[R,_]=n.useState(!1),z=ge(o=>o.inputMode),te=ge(o=>o.theme),L=ge(o=>o.editorSendWithEnter),K=ge(o=>o.setEditorSendWithEnter),ne=ge(o=>o.addEditorHistory),ue=ge(o=>o.setEditorDraft),q=ge(o=>o.removeEditorDraft),ie=ge(o=>v?o.editorDrafts[v]??"":""),O=n.useMemo(()=>Ht(),[]),N=(it=r==null?void 0:r.session)==null?void 0:it.windows,pe=te==="light"?dt:ut,{data:fe}=nt({queryKey:["devices"],queryFn:async()=>{const o=await fetch("/api/devices");if(!o.ok)throw new Error("Failed to fetch devices");return o.json()},throwOnError:!1}),a=n.useMemo(()=>{if(e)return fe==null?void 0:fe.devices.find(o=>o.id===e)},[e,fe==null?void 0:fe.devices]),l=n.useMemo(()=>{if(!(!s||!N))return N.find(o=>o.id===s)},[s,N]),y=n.useMemo(()=>{if(!(!h||!l))return l.panes.find(o=>o.id===h)},[h,l]),$=!!N,d=$&&!!s&&!l?t("terminal.windowClosed"):$&&!!s&&!!h&&!!l&&!y?t("terminal.paneClosed"):null,f=!!d,j=!!(P&&h&&!f),B=!!(!b&&l&&l.panes.length>1&&l.layout&&!f),U=n.useRef(B);n.useEffect(()=>{U.current=B},[B]);const J=Ze(o=>o.ringingPanes),Ce=n.useMemo(()=>{if(!l||!y)return null;const o=(a==null?void 0:a.name)??e,m=pt({paneCustomName:y.customName,paneTitle:y.title,windowName:l.name,windowCustomName:l.customName,deviceName:o});return J[y.id]?`🔔 ${m}`:m},[a==null?void 0:a.name,e,y,l,J]),ye=n.useMemo(()=>{if(!N||N.length===0)return null;const o=N.find(p=>p.active),m=o==null?void 0:o.panes.find(p=>p.active);return!o||!m?null:{windowId:o.id,paneId:m.id}},[N]),Te=b&&l&&l.panes.length>1?l.id:null,xe=n.useRef(Te);n.useEffect(()=>{xe.current=Te},[Te]);const F=n.useRef(!1);n.useEffect(()=>{F.current=!!N&&!!s},[N,s]);const re=n.useCallback((o,m)=>{if(!e||!h)return;const p=xe.current;if(p){H.getState().applyStackedLayout(e,p,o,m);return}C.current&&!F.current||H.getState().resizePane(e,h,o,m)},[e,h]),D=n.useCallback((o,m)=>{if(!e||!h)return;const p=xe.current;if(p){H.getState().applyStackedLayout(e,p,o,m);return}C.current&&!F.current||H.getState().syncPaneSize(e,h,o,m)},[e,h]),G=n.useCallback(()=>{e&&H.getState().syncThemeAfterResize(e)},[e]),Q=n.useCallback((o,m)=>{var $e;const p=I.current;if(U.current){const Se=($e=w.current)==null?void 0:$e.getBoundingClientRect(),Ye=p==null?void 0:p.getCellSize();return Se&&Ye&&Se.width>0&&Se.height>0?{cols:Math.max(2,Math.floor(Se.width/Ye.width)),rows:Math.max(2,Math.floor(Se.height/Ye.height))}:void 0}if(C.current)return;const k=(p==null?void 0:p.calculateSizeFromContainer())??(p==null?void 0:p.getSize())??void 0;if(k)return k;if(!o||!m||!N)return;const se=N.find(Se=>Se.id===o),be=se==null?void 0:se.panes.find(Se=>Se.id===m);if(!(!be||be.width<=1||be.height<=1))return{cols:be.width,rows:be.height}},[N]),de=n.useCallback((o,m)=>{e&&(E.current={windowId:o,paneId:m,at:Date.now()},u(`/devices/${e}/windows/${o}/panes/${Pe(m)}`,{replace:!0}))},[e,u]),Ee=n.useCallback(o=>{I.current=o},[]);n.useEffect(()=>{const o=()=>{T(window.innerWidth<768||"ontouchstart"in window)};return o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),n.useEffect(()=>{if(!b||!O||X.current)return;X.current=!0;const o=()=>{window.scrollTo(0,1)},m=window.requestAnimationFrame(o),p=window.setTimeout(o,120),k=window.setTimeout(o,420);return()=>{window.cancelAnimationFrame(m),window.clearTimeout(p),window.clearTimeout(k)}},[O,b]),n.useEffect(()=>{e&&(V.current=!1,_e.current=null,je.current=null,E.current=null,Re.current=[])},[e]),n.useEffect(()=>{P||(V.current=!1)},[P]),n.useEffect(()=>{if(!e||!P||!s||!N)return;if(N.length===0){u("/devices",{replace:!0});return}const o=N.find(p=>p.id===s);if(!o)return;if(!h){const p=o.panes.find(k=>k.active)??o.panes[0];p&&u(`/devices/${e}/windows/${s}/panes/${Pe(p.id)}`,{replace:!0});return}if(!o.panes.find(p=>p.id===h)){const p=N.find(se=>se.panes.some(be=>be.id===h));if(p){u(`/devices/${e}/windows/${p.id}/panes/${Pe(h)}`,{replace:!0});return}const k=o.panes.find(se=>se.active)??o.panes[0];k&&u(`/devices/${e}/windows/${s}/panes/${Pe(k.id)}`,{replace:!0});return}},[e,P,N,s,h,u]),n.useEffect(()=>{if(!e||!P||!N||N.length===0||s&&h||V.current)return;const o=N.find(p=>p.active)??N[0],m=o.panes.find(p=>p.active)??o.panes[0];m&&(V.current=!0,u(`/devices/${e}/windows/${o.id}/panes/${Pe(m.id)}`,{replace:!0}))},[P,e,u,h,s,N]);const Re=n.useRef([]),ve=n.useCallback((o,m)=>{const p=Date.now(),k=[...Re.current.filter(se=>p-se.at<2e3),{windowId:o,paneId:m,at:p}];Re.current=k.slice(-8)},[]),Me=n.useRef(null);n.useEffect(()=>{Me.current=null},[e,h]);const Ae=n.useRef(null),ze=n.useRef(B);n.useEffect(()=>{ze.current!==B&&(ze.current=B,Me.current=null,Ae.current=null)},[B]),n.useEffect(()=>{if(!e||!s||!h||Y||!P)return;const o=`${e}:${s}:${h}`;if(Me.current===o)return;Me.current=o;const m=B&&Ae.current===`${e}:${s}`&&!!(l!=null&&l.panes.some(k=>k.id===h));if(ve(s,h),m){Z(e,s,h);return}const p=Q(s,h);M(e,s,h,p),Ae.current=`${e}:${s}`},[P,e,Z,Q,Y,B,ve,h,M,l,s]),n.useEffect(()=>{if(!e||!P||!s||!h)return;const o={windowId:s,paneId:h};gr({routeTarget:o,snapshotActive:ye,pendingUserSelection:E.current})&&(E.current={windowId:o.windowId,paneId:o.paneId,at:Date.now()})},[P,e,h,ye,s]);const me=H(o=>e?o.activePaneFromEvent[e]:void 0),_e=n.useRef(null);n.useEffect(()=>{if(!e||!P||!s||!h||!me)return;const o=Date.now(),m=He(E.current,o);if(E.current=m,pr({now:o,pendingUserSelection:m,activePaneFromEvent:me,currentRoute:{windowId:s,paneId:h},recentSelectRequests:Re.current,lastHandledActive:_e.current}))return;if(_e.current={...me},m&&m.windowId===me.windowId&&m.paneId===me.paneId&&(E.current=null),!(U.current&&me.windowId===s)){const k=Q(me.windowId,me.paneId);ve(me.windowId,me.paneId),M(e,me.windowId,me.paneId,k)}u(`/devices/${e}/windows/${me.windowId}/panes/${Pe(me.paneId)}`,{replace:!0})},[e,P,s,h,me,ve,Q,M,u]);const je=n.useRef(null);n.useEffect(()=>{if(!e||!P||!N||N.length===0)return;const o=Re.current,m=N.find(Se=>Se.active);if(!m)return;const p=m.panes.find(Se=>Se.active);if(!p)return;const k={windowId:m.id,paneId:p.id},se=Date.now(),be=He(E.current,se);if(E.current=be,wr({now:se,pendingUserSelection:be,snapshotActive:k,recentSelectRequests:o})||je.current&&je.current.windowId===k.windowId&&je.current.paneId===k.paneId||(je.current={...k},be&&be.windowId===k.windowId&&be.paneId===k.paneId&&(E.current=null),s===k.windowId&&h===k.paneId))return;if(!(U.current&&k.windowId===s)){const Se=Q(k.windowId,k.paneId);ve(k.windowId,k.paneId),M(e,k.windowId,k.paneId,Se)}u(`/devices/${e}/windows/${k.windowId}/panes/${Pe(k.paneId)}`,{replace:!0})},[e,P,N,s,h,ve,Q,M,u]);const De=H(o=>e?o.pendingCreateWindowAt[e]:void 0);n.useEffect(()=>{if(!e||!P||!De)return;const o=5e3,m=Date.now()-De;if(m>o){H.getState().clearPendingCreateWindow(e);return}if(!ye){const se=window.setTimeout(()=>{H.getState().clearPendingCreateWindow(e)},o-m);return()=>window.clearTimeout(se)}const p=ye;if(s===p.windowId&&h===p.paneId){const se=window.setTimeout(()=>{H.getState().clearPendingCreateWindow(e)},o-m);return()=>window.clearTimeout(se)}E.current={windowId:p.windowId,paneId:p.paneId,at:Date.now()};const k=Q(p.windowId,p.paneId);ve(p.windowId,p.paneId),M(e,p.windowId,p.paneId,k),u(`/devices/${e}/windows/${p.windowId}/panes/${Pe(p.paneId)}`,{replace:!0}),H.getState().clearPendingCreateWindow(e)},[e,P,De,ye,s,h,ve,Q,M,u]),n.useEffect(()=>{if(B||!j||!y||Y)return;const o=I.current,m=o==null?void 0:o.getTerminal();if(!m)return;const p=Math.max(2,Math.floor(y.width||0)),k=Math.max(2,Math.floor(y.height||0));if(!p||!k)return;const se=Date.now(),be={cols:p,rows:k},$e=(o==null?void 0:o.getPendingLocalSize())??null;Fn({now:se,remoteSize:be,pendingLocalSize:$e})&&(m.cols===p&&m.rows===k||m.resize(p,k))},[j,Y,B,y]),n.useEffect(()=>{const o=window.requestAnimationFrame(()=>{var p;(p=I.current)==null||p.scrollToBottom()}),m=window.setTimeout(()=>{var p;(p=I.current)==null||p.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(o),window.clearTimeout(m)}},[z]),n.useEffect(()=>{oe!=null&&oe.message&&Le.error(oe.message)},[oe==null?void 0:oe.message]),n.useEffect(()=>(document.title=Wt(Ce),()=>{document.title=ae}),[ae,Ce]),n.useEffect(()=>{const o=()=>{var m;(m=I.current)==null||m.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",o),()=>{window.removeEventListener("tmex:jump-to-latest",o)}},[]),n.useEffect(()=>{const o=m=>{const{deviceId:p,windowId:k,paneId:se}=m.detail;p===e&&(E.current={windowId:k,paneId:se,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",o),()=>{window.removeEventListener("tmex:user-initiated-selection",o)}},[e]),n.useEffect(()=>{W(ie)},[ie]);const st=n.useCallback(o=>{if(!e||!h||!j)return;H.getState().sendInput(e,h,o,!1)},[j,e,h]),Xe=n.useCallback(o=>{var m,p;if(o.type==="action"){if(o.action==="toggleKeyboard"){ge.getState().setInputMode(z==="direct"?"editor":"direct");return}if(o.action==="scrollToBottom"){(m=I.current)==null||m.scrollToBottom();return}}if(o.type==="send"){o.payload&&st(o.payload);return}if(!(!e||!h||!j))switch(o.action){case"paste":{((p=navigator.clipboard)!=null&&p.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(se=>{se&&H.getState().paste(e,h,se)}).catch(()=>Le.error(t("terminal.pasteFailed")));break}case"newAgentSession":ft.getState().startDraft(e,h,null),ge.getState().setSidebarCollapsed(!1),ge.getState().setSidebarTab("agent");break}},[j,e,st,z,h,t]),bt=n.useCallback(()=>{if(!j){Le.error(t("wsError.checkGateway"));return}if(!e||!h||!A.trim())return;_(!0),window.setTimeout(()=>_(!1),150);const o=L?`${A}\r`:A;H.getState().sendInput(e,h,o,!1),ne(A),v&&q(v),W("")},[ne,j,e,v,L,A,q,h,t]),St=n.useCallback(()=>{if(!j){Le.error(t("wsError.checkGateway"));return}if(!e||!h||!A.trim())return;_(!0),window.setTimeout(()=>_(!1),150);const o=A.split(/\r?\n/),m=H.getState();for(const p of o)p.trim()&&m.sendInput(e,h,`${p}\r`,!1);ne(A),v&&q(v),W("")},[ne,j,e,v,A,q,h,t]),yt=n.useCallback(()=>{var o;(o=x.current)==null||o.focus({preventScroll:!0})},[]);if(!e)return i.jsx("div",{className:"flex h-full items-center justify-center p-4",children:i.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:t("device.noDevices")})});const Et=!!h&&!f&&(P||ee),Rt=P&&!!h&&!f&&!y,Tt=we&&!P&&!oe&&!ee,ot=i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:i.jsx(Ue,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),i.jsx("h3",{className:"text-lg font-medium",children:t("terminal.connecting")})]});return i.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[i.jsx("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${b&&z==="editor"?"pb-1":""}`,children:i.jsxs("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:pe.background},children:[f?i.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:i.jsxs("div",{className:"max-w-sm space-y-4",children:[i.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:i.jsx(Tn,{className:"h-6 w-6 text-muted-foreground"})}),i.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"terminal-selection-invalid",children:d})]})}):Et&&h?B&&l?i.jsxs("div",{className:"flex h-full min-h-0 w-full flex-1 flex-col","data-virtual-keyboard-avoid":!0,children:[i.jsx("div",{ref:w,className:"relative min-h-0 flex-1",children:i.jsx(fr,{deviceId:e,window:l,focusedPaneId:h,theme:te,inputMode:z,deviceConnected:P,focusedTerminalRef:Ee,onUserSelectPane:de,onWindowResize:re,onWindowResizeSettled:G},`${e}:${l.id}`)}),z==="direct"&&i.jsx("div",{className:"kb-floating-shortcuts",style:{backgroundColor:pe.background},children:i.jsx(Ke,{onActivate:Xe,disabled:!j})})]}):i.jsx("div",{ref:w,className:"flex-1 h-full min-h-0 w-full","data-virtual-keyboard-avoid":!0,children:i.jsx(rt,{ref:I,deviceId:e,paneId:h,theme:te,inputMode:z,deviceConnected:P,isSelectionInvalid:f,onResize:re,onSync:D,onResizeSettled:G,children:z==="direct"&&i.jsx("div",{className:"kb-floating-shortcuts",style:{backgroundColor:pe.background},children:i.jsx(Ke,{onActivate:Xe,disabled:!j})})},`${e}:${h}`)}):i.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:i.jsx("div",{className:"max-w-sm space-y-4",children:Tt?ot:!P&&!ee?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:i.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),i.jsx("h3",{className:"text-lg font-medium",children:t("device.disconnected")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:t("device.connectToStart")})]}):s?ot:i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:i.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),i.jsx("h3",{className:"text-lg font-medium",children:t("window.noWindowSelected")}),i.jsx("p",{className:"text-sm text-muted-foreground",children:t("window.selectWindowToStart")})]})})}),ee&&i.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-2 z-10 flex justify-center","data-testid":"terminal-reconnecting-indicator",children:i.jsx(Ot,{deviceId:e,className:"shadow-sm"})}),Rt&&i.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:i.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border bg-card/90 px-4 py-3 shadow-sm",children:[i.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),i.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:t("terminal.connecting")})]})})]})}),z==="editor"&&i.jsxs("div",{ref:g,"data-virtual-keyboard-avoid":!0,className:"editor-mode-input bg-card/85 backdrop-blur-sm",children:[b&&i.jsx(Ke,{onActivate:o=>{Xe(o),o.type==="send"&&yt()},disabled:!j}),i.jsx("textarea",{ref:x,"data-testid":"editor-input",className:"min-h-[88px] max-h-[28vh] w-full resize-y rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground shadow-xs outline-none transition-colors focus:border-ring",value:A,onChange:o=>{const m=o.target.value;if(W(m),!!v){if(m){ue(v,m);return}q(v)}},placeholder:t("terminal.inputPlaceholder"),onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1}}),i.jsx("div",{className:"actions mt-2",children:i.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[i.jsxs("div",{className:"send-with-enter-toggle mr-auto flex items-center gap-2 text-xs text-muted-foreground","data-testid":"editor-send-with-enter-toggle",children:[i.jsx(qt,{size:"sm",checked:L,onCheckedChange:o=>K(!!o)}),i.jsx("span",{children:t("terminal.editorSendWithEnter")})]}),i.jsxs(Ne,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:o=>o.preventDefault(),onClick:()=>{var o;W(""),v&&q(v),b&&z==="editor"&&((o=x.current)==null||o.focus({preventScroll:!0}))},title:t("terminal.clear"),children:[i.jsx(Xt,{className:"h-4 w-4"}),t("terminal.clear")]}),i.jsxs(Ne,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:o=>o.preventDefault(),onClick:()=>{var o;St(),b&&z==="editor"&&((o=x.current)==null||o.focus({preventScroll:!0}))},disabled:!j||R,children:[R?i.jsx(Ue,{className:"h-4 w-4 animate-spin"}):i.jsx(ct,{className:"h-4 w-4"}),t("terminal.editorSendLineByLine")]}),i.jsxs(Ne,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:o=>o.preventDefault(),onClick:()=>{var o;bt(),b&&z==="editor"&&((o=x.current)==null||o.focus({preventScroll:!0}))},disabled:!j||R,children:[R?i.jsx(Ue,{className:"h-4 w-4 animate-spin"}):i.jsx(ct,{className:"h-4 w-4"}),t("common.send")]})]})})]})]})}function Rr(){const{deviceId:t,windowId:e,paneId:s}=et(),c=s?tt(s):void 0,u=H(E=>E.snapshots),w=mt(E=>{var M;return((M=E.settings)==null?void 0:M.siteName)??"tmex"}),g=t?u[t]:void 0,x=n.useMemo(()=>{var E;if(!(!e||!((E=g==null?void 0:g.session)!=null&&E.windows)))return g.session.windows.find(M=>M.id===e)},[e,g]),I=n.useMemo(()=>{if(!(!c||!x))return x.panes.find(E=>E.id===c)},[c,x]),V=n.useMemo(()=>x&&I?pt({paneCustomName:I.customName,paneTitle:I.title,windowName:x.name,windowCustomName:x.customName,deviceName:w}):t??"",[x,I,w,t]),X=Ze(E=>c?!!E.ringingPanes[c]:!1);return i.jsxs(i.Fragment,{children:[X&&i.jsx("span",{className:"bell-blink",children:"🔔 "}),V]})}function Tr(){const{t}=Ie(),{deviceId:e,windowId:s,paneId:c}=et(),u=ht(),w=Yt(),g=c?tt(c):void 0,x=ge(S=>S.inputMode),I=ge(S=>S.setInputMode),V=H(S=>{var Y;return e?((Y=S.deviceConnected)==null?void 0:Y[e])??!1:!1}),X=H(S=>e?S.snapshots[e]:void 0),E=n.useMemo(()=>{var S;if(!(!s||!((S=X==null?void 0:X.session)!=null&&S.windows)))return X.session.windows.find(Y=>Y.id===s)},[s,X]),M=n.useCallback(S=>{!e||!s||u(`/devices/${e}/windows/${s}/panes/${Pe(S)}`,{replace:!0})},[e,s,u]),Z=n.useMemo(()=>{if(!(!g||!E))return E.panes.find(S=>S.id===g)},[g,E]),r=n.useCallback(S=>{!e||!g||H.getState().splitPane(e,g,S,Z==null?void 0:Z.currentPath)},[e,g,Z==null?void 0:Z.currentPath]),[oe,P]=n.useState(!1),[ce,ee]=n.useState(!1),[we,ae]=n.useState(!1),h=!!(g&&V),b=(nt({queryKey:Vt(e??"",g??""),queryFn:()=>Ut(e??"",g??""),enabled:!!(e&&g),throwOnError:!1}).data??[]).some(S=>S.enabled),T=()=>{I(x==="direct"?"editor":"direct")},C=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},A=()=>{P(!0)},W=()=>{window.location.reload()};return i.jsxs(i.Fragment,{children:[w&&g&&E&&E.panes.length>1&&i.jsx(Gn,{window:E,currentPaneId:g,onSelectPane:M}),!w&&i.jsxs(i.Fragment,{children:[i.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:()=>r("right"),disabled:!h,"data-testid":"split-right-button","aria-label":t("window.splitRight"),title:t("window.splitRight"),children:i.jsx(Kt,{className:"h-4 w-4"})}),i.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:()=>r("down"),disabled:!h,"data-testid":"split-down-button","aria-label":t("window.splitDown"),title:t("window.splitDown"),children:i.jsx(Gt,{className:"h-4 w-4"})})]}),i.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:A,"aria-label":t("nav.refreshPage"),title:t("nav.refreshPage"),children:i.jsx(fn,{className:"h-4 w-4"})}),i.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:T,disabled:!h,"data-testid":"terminal-input-mode-toggle","aria-label":t(x==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:t(x==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:x==="direct"?i.jsx(vn,{className:"h-4 w-4"}):i.jsx(Pn,{className:"h-4 w-4"})}),i.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:C,disabled:!h,"aria-label":t("nav.jumpToLatest"),title:t("nav.jumpToLatest"),children:i.jsx(hn,{className:"h-4 w-4"})}),i.jsxs(Ne,{variant:"ghost",size:"icon-sm",className:"relative",onClick:()=>ee(!0),disabled:!g,"data-testid":"watch-open-button","aria-label":t("watch.title"),title:t("watch.title"),children:[i.jsx(Qt,{className:"h-4 w-4"}),b&&i.jsx("span",{className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-primary","data-testid":"watch-active-indicator"})]}),i.jsx(Ne,{variant:"ghost",size:"icon-sm",onClick:()=>ae(!0),"data-testid":"keyboard-behavior-open-button","aria-label":t("settings.terminal.title"),title:t("settings.terminal.title"),children:i.jsx(Cn,{className:"h-4 w-4"})}),i.jsx(kn,{open:we,onOpenChange:ae}),e&&g&&i.jsx(Jt,{open:ce,onOpenChange:ee,deviceId:e,paneId:g}),i.jsx(Zt,{open:oe,onOpenChange:P,children:i.jsxs(en,{children:[i.jsxs(tn,{children:[i.jsx(nn,{children:t("nav.refreshPage")}),i.jsx(rn,{children:t("nav.refreshPageConfirm")})]}),i.jsxs(sn,{children:[i.jsx(on,{onClick:()=>P(!1),children:t("common.cancel")}),i.jsx(cn,{onClick:W,children:t("common.confirm")})]})]})})]})}export{Tr as PageActions,Rr as PageTitle,Er as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as b,r as v,a as _,b as ie,c as re,d as ne,e as I,t as oe,j as s,M as X,B as C,P as Y,A as ce,f as de,g as le,h as ue,T as ee,i as me,k as he,l as pe,m as xe,n as ve,G as fe,o as f,D as ge,p as ye,E as je,q as we,s as $,v as Ne,w as De,x as Q,y as Ce,S as be,L as Se,z as ke,C as Ee,F as Me,H as Pe,I as Ie,J as Ke,K as x,N as z,O as V,Q as U,R as J,U as w,V as Re,W as $e}from"./index-UoApkLSY.js";import{C as M,a as P,b as Ae,c as Te,d as Fe}from"./card-CD9i-fLq.js";import{Z as We}from"./zap-Dx7JTXJN.js";function g(e){const o=e.trim();return o||void 0}function qe(e){return e?{name:e.name,type:e.type,host:e.host??"",port:e.port??22,username:e.username??"",sshConfigRef:e.sshConfigRef??"",session:e.session??"tmex",defaultWorkingDir:e.defaultWorkingDir??"",authMode:e.type==="local"?"auto":e.authMode,password:"",privateKey:"",privateKeyPassphrase:""}:{name:"",type:"local",host:"",port:22,username:"root",sshConfigRef:"",session:"tmex",defaultWorkingDir:"",authMode:"auto",password:"",privateKey:"",privateKeyPassphrase:""}}function Le(e){if(e.type==="local")return{name:e.name.trim(),type:"local",session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir),authMode:"auto"};const o={name:e.name.trim(),type:"ssh",host:e.host.trim(),port:e.port,username:e.username.trim(),session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir),authMode:e.authMode};return e.authMode==="configRef"&&(o.sshConfigRef=e.sshConfigRef.trim()),e.authMode==="password"&&(o.password=e.password),e.authMode==="key"&&(o.privateKey=e.privateKey,o.privateKeyPassphrase=e.privateKeyPassphrase||void 0),o}function He(e){if(e.type==="local")return{name:e.name.trim(),session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir)??"",authMode:"auto"};const o={name:e.name.trim(),host:e.host.trim(),port:e.port,username:e.username.trim(),sshConfigRef:e.authMode==="configRef"?e.sshConfigRef.trim():"",session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir)??"",authMode:e.authMode};return e.authMode==="password"&&e.password&&(o.password=e.password),e.authMode==="key"&&e.privateKey&&(o.privateKey=e.privateKey,o.privateKeyPassphrase=e.privateKeyPassphrase||void 0),o}function se(e){return Number.isInteger(e)&&e>=1&&e<=65535}function Oe(e){return e.type!=="ssh"?null:e.host.trim()?se(e.port)?e.username.trim()?e.authMode==="configRef"&&!e.sshConfigRef.trim()?"validation.sshConfigRequired":null:"validation.usernameRequired":"validation.portRequired":"validation.hostRequired"}async function G(e,o){try{return(await e.json()).error??o}catch{return o}}function Ue(){const{t:e}=b(),[o,m]=v.useState(!1),[t,y]=v.useState(null),[r,d]=v.useState(null),l=_(),h=ie(n=>{var p;return((p=n.settings)==null?void 0:p.language)??"en_US"});v.useEffect(()=>{const n=()=>m(!0);return window.addEventListener("tmex:open-add-device",n),()=>window.removeEventListener("tmex:open-add-device",n)},[]);const{data:c,isLoading:K,isError:N}=re({queryKey:["devices"],queryFn:async()=>{const n=await fetch("/api/devices");if(!n.ok)throw new Error(e("device.loadFailed"));return n.json()},throwOnError:!1}),S=ne(n=>n.hydrateDeviceErrors);v.useEffect(()=>{c!=null&&c.devices&&S(c.devices.map(n=>({deviceId:n.id,lastError:n.lastError??null,lastErrorType:n.lastErrorType??null})))},[c,S]);const k=I({mutationFn:async n=>{if(!(await fetch(`/api/devices/${n}`,{method:"DELETE"})).ok)throw new Error(e("device.deleteFailed"))},onSuccess:()=>{l.invalidateQueries({queryKey:["devices"]}),f.success(e("common.success"))},onError:n=>{f.error(n instanceof Error?n.message:e("common.error"))}}),E=v.useMemo(()=>[...(c==null?void 0:c.devices)??[]].sort((p,D)=>p.sortOrder-D.sortOrder||p.name.localeCompare(D.name,oe(h),{numeric:!0,sensitivity:"base"})),[c==null?void 0:c.devices,h]);return s.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-3 p-3 pb-[calc(1rem+env(safe-area-inset-bottom))] sm:gap-4 sm:p-5","data-testid":"devices-page",children:[K?s.jsx(M,{children:s.jsx(P,{className:"py-16 text-center text-sm text-muted-foreground",children:e("common.loading")})}):N?s.jsx(M,{children:s.jsx(P,{className:"py-16 text-center text-sm text-destructive",children:e("device.loadFailed")})}):E.length===0?s.jsx(M,{children:s.jsxs(P,{className:"space-y-4 py-14 text-center",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted",children:s.jsx(X,{className:"h-6 w-6 text-muted-foreground"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-medium",children:e("device.noDevices")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e("device.addDevice")})]}),s.jsxs(C,{variant:"default","data-testid":"devices-add-empty",onClick:()=>m(!0),children:[s.jsx(Y,{className:"h-4 w-4"}),e("device.addDevice")]})]})}):s.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:E.map(n=>s.jsx(Be,{device:n,onEdit:()=>y(n),onDelete:()=>d(n)},n.id))}),o&&s.jsx(Z,{mode:"create",onClose:()=>m(!1)}),t&&s.jsx(Z,{mode:"edit",device:t,onClose:()=>y(null)}),s.jsx(ce,{open:r!==null,onOpenChange:n=>!n&&d(null),children:s.jsxs(de,{children:[s.jsxs(le,{children:[s.jsx(ue,{className:"bg-destructive/10",children:s.jsx(ee,{className:"h-5 w-5 text-destructive"})}),s.jsx(me,{children:e("device.deleteConfirm")}),s.jsx(he,{children:e("device.deleteDescription",{name:(r==null?void 0:r.name)??""})})]}),s.jsxs(pe,{children:[s.jsx(xe,{children:e("common.cancel")}),s.jsx(ve,{variant:"destructive",disabled:!r||k.isPending,onClick:()=>{r&&(k.mutate(r.id),d(null))},children:e("common.delete")})]})]})})]})}function Be({device:e,onEdit:o,onDelete:m}){const{t}=b(),y=e.type==="local"?s.jsx(X,{className:"h-4 w-4"}):s.jsx(fe,{className:"h-4 w-4"}),r=e.type==="local"?t("device.typeLocal"):`${e.username??"-"}@${e.host??"-"}:${e.port??22}`,d=I({mutationFn:async()=>{const l=await fetch(`/api/devices/${e.id}/test-connection`,{method:"POST"});let h=null;try{h=await l.json()}catch{h=null}if(!l.ok){const c=h;throw new Error((c==null?void 0:c.error)??t("common.error"))}return h},onSuccess:l=>{f.success(l.message??t("common.success"))},onError:l=>{f.error(l instanceof Error?l.message:t("common.error"))}});return s.jsxs(M,{"data-testid":"device-card","data-device-id":e.id,"data-device-name":e.name,className:"overflow-hidden border-border/50",children:[s.jsxs(Ae,{className:"space-y-2 pb-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground",children:y}),s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsx(Te,{className:"line-clamp-1 text-sm",title:e.name,children:e.name}),s.jsx(Fe,{className:"line-clamp-1 text-xs",children:r})]})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s.jsxs(ge,{children:[s.jsx(ye,{render:s.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":`device-card-actions-${e.id}`,"aria-label":t("common.edit"),title:t("common.edit")}),children:s.jsx(je,{className:"h-4 w-4"})}),s.jsxs(we,{align:"end",children:[s.jsxs($,{"data-testid":`device-card-edit-${e.id}`,onClick:o,children:[s.jsx(Ne,{className:"h-4 w-4"}),t("common.edit")]}),e.type==="ssh"&&s.jsxs($,{"data-testid":`device-card-test-${e.id}`,onClick:()=>d.mutate(),disabled:d.isPending,children:[s.jsx(We,{className:"h-4 w-4"}),t("common.test")]}),s.jsx(De,{}),s.jsxs($,{"data-testid":`device-card-delete-${e.id}`,variant:"destructive",onClick:m,children:[s.jsx(ee,{className:"h-4 w-4"}),t("common.delete")]})]})]})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:e.type==="local"?t("device.typeLocal"):t("device.typeSSHBadge")}),e.session&&s.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:e.session}),s.jsx(Ce,{deviceId:e.id})]})]}),s.jsxs(P,{className:"pt-0",children:[s.jsx(be,{className:"mb-2"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(Se,{to:`/devices/${e.id}`,"data-testid":`device-card-connect-${e.id}`,className:ke({variant:"outline",size:"sm"}),children:t("device.connect")})})]})]})}function Z({mode:e,device:o,onClose:m}){const{t}=b(),y=_(),[r,d]=v.useState(qe(o)),[l,h]=v.useState(!1),[c,K]=v.useState(!1),N=e==="edit",S=r.type==="ssh",k=I({mutationFn:async a=>{const i=await fetch("/api/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.createFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),f.success(t("common.success")),m()},onError:a=>{f.error(a instanceof Error?a.message:t("common.error"))}}),E=I({mutationFn:async a=>{if(!o)throw new Error(t("apiError.deviceNotFound"));const i=await fetch(`/api/devices/${o.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.updateFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),f.success(t("common.success")),m()},onError:a=>{f.error(a instanceof Error?a.message:t("common.error"))}}),n=async a=>{a.preventDefault(),K(!0);const i=Oe(r);if(i){f.error(t(i));return}h(!0);try{e==="create"?await k.mutateAsync(Le(r)):await E.mutateAsync(He(r))}catch{}finally{h(!1)}},p=`${e}-device-name`,D=`${e}-device-type`,A=`${e}-device-host`,T=`${e}-device-port`,F=`${e}-device-username`,W=`${e}-device-session`,q=`${e}-device-default-working-dir`,L=`${e}-device-auth-mode`,H=`${e}-device-password`,O=`${e}-device-private-key`,B=`${e}-device-private-key-passphrase`,te={local:t("device.typeLocal"),ssh:t("device.typeSSH")},ae={password:t("device.authPassword"),key:t("device.authKey"),agent:t("device.authAgent"),configRef:t("device.authConfigRef")},R=a=>s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),u=(a,i,j)=>s.jsxs("label",{className:"block text-xs font-medium text-foreground",htmlFor:a,children:[i,j&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]});return s.jsx(Ee,{open:!0,onOpenChange:a=>!a&&m(),children:s.jsxs(Me,{"data-testid":"device-dialog",className:"w-full max-w-2xl",children:[s.jsxs(Pe,{children:[s.jsx(Ie,{children:t(N?"device.editDevice":"device.addDevice")}),s.jsx(Ke,{children:t(N?"device.editDeviceDescription":"device.addDeviceDescription")})]}),s.jsxs("form",{onSubmit:n,className:"space-y-4",children:[s.jsxs("div",{className:"-mr-2 max-h-[min(70dvh,720px)] space-y-5 overflow-y-auto pr-2",children:[s.jsxs("section",{className:"space-y-2.5",children:[R(t("device.sectionBasic")),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(p,t("device.name"),!0),s.jsx(x,{id:p,"data-testid":"device-name-input",type:"text",value:r.name,onChange:a=>d(i=>({...i,name:a.target.value})),placeholder:t("device.namePlaceholder"),required:!0})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(D,t("device.type")),s.jsxs(z,{value:r.type,onValueChange:a=>{if(!a)return;const i=a;d(j=>({...j,type:i,authMode:i==="local"?"auto":j.authMode==="auto"?"agent":j.authMode}))},disabled:N,children:[s.jsx(V,{id:D,"data-testid":"device-type-select",className:"w-full",children:s.jsx(U,{placeholder:t("device.type"),children:a=>te[a]??""})}),s.jsxs(J,{children:[s.jsx(w,{value:"local",children:t("device.typeLocal")}),s.jsx(w,{value:"ssh",children:t("device.typeSSH")})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(W,t("device.session")),s.jsx(x,{id:W,"data-testid":"device-session-input",type:"text",value:r.session,onChange:a=>d(i=>({...i,session:a.target.value})),placeholder:t("device.sessionPlaceholder")})]}),s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(q,t("device.defaultWorkingDir")),s.jsx(x,{id:q,"data-testid":"device-default-working-dir-input",type:"text",value:r.defaultWorkingDir,onChange:a=>d(i=>({...i,defaultWorkingDir:a.target.value})),placeholder:t("device.defaultWorkingDirPlaceholder")})]})]})]}),S&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"space-y-2.5",children:[R(t("device.sectionConnection")),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(A,t("device.host"),!0),s.jsx(x,{id:A,type:"text",value:r.host,onChange:a=>d(i=>({...i,host:a.target.value})),placeholder:t("device.hostPlaceholder"),"aria-invalid":c&&!r.host.trim()})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(T,t("device.port"),!0),s.jsx(x,{id:T,type:"number",value:Number.isNaN(r.port)?"":r.port,onChange:a=>{const i=a.target.value;d(j=>({...j,port:i===""?Number.NaN:Number.parseInt(i,10)}))},min:1,max:65535,"aria-invalid":c&&!se(r.port)})]}),s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(F,t("device.username"),!0),s.jsx(x,{id:F,type:"text",value:r.username,onChange:a=>d(i=>({...i,username:a.target.value})),placeholder:t("device.usernamePlaceholder"),"aria-invalid":c&&!r.username.trim()})]})]})]}),s.jsxs("section",{className:"space-y-2.5",children:[R(t("device.sectionAuth")),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[u(L,t("device.authMode")),s.jsxs(z,{value:r.authMode,onValueChange:a=>{a&&d(i=>({...i,authMode:a}))},children:[s.jsx(V,{id:L,"data-testid":"device-auth-mode-select",className:"w-full",children:s.jsx(U,{placeholder:t("device.authMode"),children:a=>ae[a]??""})}),s.jsxs(J,{children:[s.jsx(w,{value:"password",children:t("device.authPassword")}),s.jsx(w,{value:"key",children:t("device.authKey")}),s.jsx(w,{value:"agent",children:t("device.authAgent")}),s.jsx(w,{value:"configRef",children:t("device.authConfigRef")})]})]})]}),r.authMode==="password"&&s.jsxs("div",{className:"space-y-1.5",children:[u(H,t("device.password")),s.jsx(x,{id:H,type:"password",value:r.password,onChange:a=>d(i=>({...i,password:a.target.value}))})]}),r.authMode==="key"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[u(O,t("device.privateKey")),s.jsx(Re,{id:O,value:r.privateKey,onChange:a=>d(i=>({...i,privateKey:a.target.value})),className:"h-28 font-mono text-xs",placeholder:t("device.privateKeyPlaceholder")})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(B,t("device.passphrase")),s.jsx(x,{id:B,type:"password",value:r.privateKeyPassphrase,onChange:a=>d(i=>({...i,privateKeyPassphrase:a.target.value}))})]})]}),r.authMode==="configRef"&&s.jsxs("div",{className:"space-y-1.5",children:[u(`${e}-device-ssh-config-ref`,t("device.authConfigRef"),!0),s.jsx(x,{id:`${e}-device-ssh-config-ref`,"data-testid":"device-ssh-config-ref-input",type:"text",value:r.sshConfigRef,onChange:a=>d(i=>({...i,sshConfigRef:a.target.value})),placeholder:t("device.sshConfigRefPlaceholder"),"aria-invalid":c&&!r.sshConfigRef.trim()}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("device.sshConfigRefHint")})]})]})]})]})]}),s.jsxs($e,{children:[s.jsx(C,{type:"button",variant:"outline",onClick:m,children:t("common.cancel")}),s.jsx(C,{type:"submit",variant:"default","data-testid":"device-dialog-save",disabled:l,children:t(l?"common.saving":"common.save")})]})]})]})})}function Je(){const{t:e}=b();return s.jsx(s.Fragment,{children:e("sidebar.manageDevices")})}function Ge(){const{t:e}=b(),o=()=>{window.dispatchEvent(new CustomEvent("tmex:open-add-device"))};return s.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":"devices-add",onClick:o,"aria-label":e("sidebar.addDevice"),title:e("sidebar.addDevice"),children:s.jsx(Y,{className:"h-4 w-4"})})}export{Ge as PageActions,Je as PageTitle,Ue as default};
|
|
1
|
+
import{u as b,r as v,a as _,b as ie,c as re,d as ne,e as I,t as oe,j as s,M as X,B as C,P as Y,A as ce,f as de,g as le,h as ue,T as ee,i as me,k as he,l as pe,m as xe,n as ve,G as fe,o as f,D as ge,p as ye,E as je,q as we,s as $,v as Ne,w as De,x as Q,y as Ce,S as be,L as Se,z as ke,C as Ee,F as Me,H as Pe,I as Ie,J as Ke,K as x,N as z,O as V,Q as U,R as J,U as w,V as Re,W as $e}from"./index-C1akMMWP.js";import{C as M,a as P,b as Ae,c as Te,d as Fe}from"./card-TMGETMIE.js";import{Z as We}from"./zap-B28XlJER.js";function g(e){const o=e.trim();return o||void 0}function qe(e){return e?{name:e.name,type:e.type,host:e.host??"",port:e.port??22,username:e.username??"",sshConfigRef:e.sshConfigRef??"",session:e.session??"tmex",defaultWorkingDir:e.defaultWorkingDir??"",authMode:e.type==="local"?"auto":e.authMode,password:"",privateKey:"",privateKeyPassphrase:""}:{name:"",type:"local",host:"",port:22,username:"root",sshConfigRef:"",session:"tmex",defaultWorkingDir:"",authMode:"auto",password:"",privateKey:"",privateKeyPassphrase:""}}function Le(e){if(e.type==="local")return{name:e.name.trim(),type:"local",session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir),authMode:"auto"};const o={name:e.name.trim(),type:"ssh",host:e.host.trim(),port:e.port,username:e.username.trim(),session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir),authMode:e.authMode};return e.authMode==="configRef"&&(o.sshConfigRef=e.sshConfigRef.trim()),e.authMode==="password"&&(o.password=e.password),e.authMode==="key"&&(o.privateKey=e.privateKey,o.privateKeyPassphrase=e.privateKeyPassphrase||void 0),o}function He(e){if(e.type==="local")return{name:e.name.trim(),session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir)??"",authMode:"auto"};const o={name:e.name.trim(),host:e.host.trim(),port:e.port,username:e.username.trim(),sshConfigRef:e.authMode==="configRef"?e.sshConfigRef.trim():"",session:g(e.session)??"tmex",defaultWorkingDir:g(e.defaultWorkingDir)??"",authMode:e.authMode};return e.authMode==="password"&&e.password&&(o.password=e.password),e.authMode==="key"&&e.privateKey&&(o.privateKey=e.privateKey,o.privateKeyPassphrase=e.privateKeyPassphrase||void 0),o}function se(e){return Number.isInteger(e)&&e>=1&&e<=65535}function Oe(e){return e.type!=="ssh"?null:e.host.trim()?se(e.port)?e.username.trim()?e.authMode==="configRef"&&!e.sshConfigRef.trim()?"validation.sshConfigRequired":null:"validation.usernameRequired":"validation.portRequired":"validation.hostRequired"}async function G(e,o){try{return(await e.json()).error??o}catch{return o}}function Ue(){const{t:e}=b(),[o,m]=v.useState(!1),[t,y]=v.useState(null),[r,d]=v.useState(null),l=_(),h=ie(n=>{var p;return((p=n.settings)==null?void 0:p.language)??"en_US"});v.useEffect(()=>{const n=()=>m(!0);return window.addEventListener("tmex:open-add-device",n),()=>window.removeEventListener("tmex:open-add-device",n)},[]);const{data:c,isLoading:K,isError:N}=re({queryKey:["devices"],queryFn:async()=>{const n=await fetch("/api/devices");if(!n.ok)throw new Error(e("device.loadFailed"));return n.json()},throwOnError:!1}),S=ne(n=>n.hydrateDeviceErrors);v.useEffect(()=>{c!=null&&c.devices&&S(c.devices.map(n=>({deviceId:n.id,lastError:n.lastError??null,lastErrorType:n.lastErrorType??null})))},[c,S]);const k=I({mutationFn:async n=>{if(!(await fetch(`/api/devices/${n}`,{method:"DELETE"})).ok)throw new Error(e("device.deleteFailed"))},onSuccess:()=>{l.invalidateQueries({queryKey:["devices"]}),f.success(e("common.success"))},onError:n=>{f.error(n instanceof Error?n.message:e("common.error"))}}),E=v.useMemo(()=>[...(c==null?void 0:c.devices)??[]].sort((p,D)=>p.sortOrder-D.sortOrder||p.name.localeCompare(D.name,oe(h),{numeric:!0,sensitivity:"base"})),[c==null?void 0:c.devices,h]);return s.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-3 p-3 pb-[calc(1rem+env(safe-area-inset-bottom))] sm:gap-4 sm:p-5","data-testid":"devices-page",children:[K?s.jsx(M,{children:s.jsx(P,{className:"py-16 text-center text-sm text-muted-foreground",children:e("common.loading")})}):N?s.jsx(M,{children:s.jsx(P,{className:"py-16 text-center text-sm text-destructive",children:e("device.loadFailed")})}):E.length===0?s.jsx(M,{children:s.jsxs(P,{className:"space-y-4 py-14 text-center",children:[s.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted",children:s.jsx(X,{className:"h-6 w-6 text-muted-foreground"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h2",{className:"text-lg font-medium",children:e("device.noDevices")}),s.jsx("p",{className:"text-sm text-muted-foreground",children:e("device.addDevice")})]}),s.jsxs(C,{variant:"default","data-testid":"devices-add-empty",onClick:()=>m(!0),children:[s.jsx(Y,{className:"h-4 w-4"}),e("device.addDevice")]})]})}):s.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:E.map(n=>s.jsx(Be,{device:n,onEdit:()=>y(n),onDelete:()=>d(n)},n.id))}),o&&s.jsx(Z,{mode:"create",onClose:()=>m(!1)}),t&&s.jsx(Z,{mode:"edit",device:t,onClose:()=>y(null)}),s.jsx(ce,{open:r!==null,onOpenChange:n=>!n&&d(null),children:s.jsxs(de,{children:[s.jsxs(le,{children:[s.jsx(ue,{className:"bg-destructive/10",children:s.jsx(ee,{className:"h-5 w-5 text-destructive"})}),s.jsx(me,{children:e("device.deleteConfirm")}),s.jsx(he,{children:e("device.deleteDescription",{name:(r==null?void 0:r.name)??""})})]}),s.jsxs(pe,{children:[s.jsx(xe,{children:e("common.cancel")}),s.jsx(ve,{variant:"destructive",disabled:!r||k.isPending,onClick:()=>{r&&(k.mutate(r.id),d(null))},children:e("common.delete")})]})]})})]})}function Be({device:e,onEdit:o,onDelete:m}){const{t}=b(),y=e.type==="local"?s.jsx(X,{className:"h-4 w-4"}):s.jsx(fe,{className:"h-4 w-4"}),r=e.type==="local"?t("device.typeLocal"):`${e.username??"-"}@${e.host??"-"}:${e.port??22}`,d=I({mutationFn:async()=>{const l=await fetch(`/api/devices/${e.id}/test-connection`,{method:"POST"});let h=null;try{h=await l.json()}catch{h=null}if(!l.ok){const c=h;throw new Error((c==null?void 0:c.error)??t("common.error"))}return h},onSuccess:l=>{f.success(l.message??t("common.success"))},onError:l=>{f.error(l instanceof Error?l.message:t("common.error"))}});return s.jsxs(M,{"data-testid":"device-card","data-device-id":e.id,"data-device-name":e.name,className:"overflow-hidden border-border/50",children:[s.jsxs(Ae,{className:"space-y-2 pb-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground",children:y}),s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsx(Te,{className:"line-clamp-1 text-sm",title:e.name,children:e.name}),s.jsx(Fe,{className:"line-clamp-1 text-xs",children:r})]})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:s.jsxs(ge,{children:[s.jsx(ye,{render:s.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":`device-card-actions-${e.id}`,"aria-label":t("common.edit"),title:t("common.edit")}),children:s.jsx(je,{className:"h-4 w-4"})}),s.jsxs(we,{align:"end",children:[s.jsxs($,{"data-testid":`device-card-edit-${e.id}`,onClick:o,children:[s.jsx(Ne,{className:"h-4 w-4"}),t("common.edit")]}),e.type==="ssh"&&s.jsxs($,{"data-testid":`device-card-test-${e.id}`,onClick:()=>d.mutate(),disabled:d.isPending,children:[s.jsx(We,{className:"h-4 w-4"}),t("common.test")]}),s.jsx(De,{}),s.jsxs($,{"data-testid":`device-card-delete-${e.id}`,variant:"destructive",onClick:m,children:[s.jsx(ee,{className:"h-4 w-4"}),t("common.delete")]})]})]})})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:e.type==="local"?t("device.typeLocal"):t("device.typeSSHBadge")}),e.session&&s.jsx(Q,{variant:"outline",className:"text-[11px] font-normal",children:e.session}),s.jsx(Ce,{deviceId:e.id})]})]}),s.jsxs(P,{className:"pt-0",children:[s.jsx(be,{className:"mb-2"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(Se,{to:`/devices/${e.id}`,"data-testid":`device-card-connect-${e.id}`,className:ke({variant:"outline",size:"sm"}),children:t("device.connect")})})]})]})}function Z({mode:e,device:o,onClose:m}){const{t}=b(),y=_(),[r,d]=v.useState(qe(o)),[l,h]=v.useState(!1),[c,K]=v.useState(!1),N=e==="edit",S=r.type==="ssh",k=I({mutationFn:async a=>{const i=await fetch("/api/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.createFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),f.success(t("common.success")),m()},onError:a=>{f.error(a instanceof Error?a.message:t("common.error"))}}),E=I({mutationFn:async a=>{if(!o)throw new Error(t("apiError.deviceNotFound"));const i=await fetch(`/api/devices/${o.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!i.ok)throw new Error(await G(i,t("device.updateFailed")));return i.json()},onSuccess:()=>{y.invalidateQueries({queryKey:["devices"]}),f.success(t("common.success")),m()},onError:a=>{f.error(a instanceof Error?a.message:t("common.error"))}}),n=async a=>{a.preventDefault(),K(!0);const i=Oe(r);if(i){f.error(t(i));return}h(!0);try{e==="create"?await k.mutateAsync(Le(r)):await E.mutateAsync(He(r))}catch{}finally{h(!1)}},p=`${e}-device-name`,D=`${e}-device-type`,A=`${e}-device-host`,T=`${e}-device-port`,F=`${e}-device-username`,W=`${e}-device-session`,q=`${e}-device-default-working-dir`,L=`${e}-device-auth-mode`,H=`${e}-device-password`,O=`${e}-device-private-key`,B=`${e}-device-private-key-passphrase`,te={local:t("device.typeLocal"),ssh:t("device.typeSSH")},ae={password:t("device.authPassword"),key:t("device.authKey"),agent:t("device.authAgent"),configRef:t("device.authConfigRef")},R=a=>s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),u=(a,i,j)=>s.jsxs("label",{className:"block text-xs font-medium text-foreground",htmlFor:a,children:[i,j&&s.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]});return s.jsx(Ee,{open:!0,onOpenChange:a=>!a&&m(),children:s.jsxs(Me,{"data-testid":"device-dialog",className:"w-full max-w-2xl",children:[s.jsxs(Pe,{children:[s.jsx(Ie,{children:t(N?"device.editDevice":"device.addDevice")}),s.jsx(Ke,{children:t(N?"device.editDeviceDescription":"device.addDeviceDescription")})]}),s.jsxs("form",{onSubmit:n,className:"space-y-4",children:[s.jsxs("div",{className:"-mr-2 max-h-[min(70dvh,720px)] space-y-5 overflow-y-auto pr-2",children:[s.jsxs("section",{className:"space-y-2.5",children:[R(t("device.sectionBasic")),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(p,t("device.name"),!0),s.jsx(x,{id:p,"data-testid":"device-name-input",type:"text",value:r.name,onChange:a=>d(i=>({...i,name:a.target.value})),placeholder:t("device.namePlaceholder"),required:!0})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(D,t("device.type")),s.jsxs(z,{value:r.type,onValueChange:a=>{if(!a)return;const i=a;d(j=>({...j,type:i,authMode:i==="local"?"auto":j.authMode==="auto"?"agent":j.authMode}))},disabled:N,children:[s.jsx(V,{id:D,"data-testid":"device-type-select",className:"w-full",children:s.jsx(U,{placeholder:t("device.type"),children:a=>te[a]??""})}),s.jsxs(J,{children:[s.jsx(w,{value:"local",children:t("device.typeLocal")}),s.jsx(w,{value:"ssh",children:t("device.typeSSH")})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(W,t("device.session")),s.jsx(x,{id:W,"data-testid":"device-session-input",type:"text",value:r.session,onChange:a=>d(i=>({...i,session:a.target.value})),placeholder:t("device.sessionPlaceholder")})]}),s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(q,t("device.defaultWorkingDir")),s.jsx(x,{id:q,"data-testid":"device-default-working-dir-input",type:"text",value:r.defaultWorkingDir,onChange:a=>d(i=>({...i,defaultWorkingDir:a.target.value})),placeholder:t("device.defaultWorkingDirPlaceholder")})]})]})]}),S&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"space-y-2.5",children:[R(t("device.sectionConnection")),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(A,t("device.host"),!0),s.jsx(x,{id:A,type:"text",value:r.host,onChange:a=>d(i=>({...i,host:a.target.value})),placeholder:t("device.hostPlaceholder"),"aria-invalid":c&&!r.host.trim()})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(T,t("device.port"),!0),s.jsx(x,{id:T,type:"number",value:Number.isNaN(r.port)?"":r.port,onChange:a=>{const i=a.target.value;d(j=>({...j,port:i===""?Number.NaN:Number.parseInt(i,10)}))},min:1,max:65535,"aria-invalid":c&&!se(r.port)})]}),s.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[u(F,t("device.username"),!0),s.jsx(x,{id:F,type:"text",value:r.username,onChange:a=>d(i=>({...i,username:a.target.value})),placeholder:t("device.usernamePlaceholder"),"aria-invalid":c&&!r.username.trim()})]})]})]}),s.jsxs("section",{className:"space-y-2.5",children:[R(t("device.sectionAuth")),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[u(L,t("device.authMode")),s.jsxs(z,{value:r.authMode,onValueChange:a=>{a&&d(i=>({...i,authMode:a}))},children:[s.jsx(V,{id:L,"data-testid":"device-auth-mode-select",className:"w-full",children:s.jsx(U,{placeholder:t("device.authMode"),children:a=>ae[a]??""})}),s.jsxs(J,{children:[s.jsx(w,{value:"password",children:t("device.authPassword")}),s.jsx(w,{value:"key",children:t("device.authKey")}),s.jsx(w,{value:"agent",children:t("device.authAgent")}),s.jsx(w,{value:"configRef",children:t("device.authConfigRef")})]})]})]}),r.authMode==="password"&&s.jsxs("div",{className:"space-y-1.5",children:[u(H,t("device.password")),s.jsx(x,{id:H,type:"password",value:r.password,onChange:a=>d(i=>({...i,password:a.target.value}))})]}),r.authMode==="key"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[u(O,t("device.privateKey")),s.jsx(Re,{id:O,value:r.privateKey,onChange:a=>d(i=>({...i,privateKey:a.target.value})),className:"h-28 font-mono text-xs",placeholder:t("device.privateKeyPlaceholder")})]}),s.jsxs("div",{className:"space-y-1.5",children:[u(B,t("device.passphrase")),s.jsx(x,{id:B,type:"password",value:r.privateKeyPassphrase,onChange:a=>d(i=>({...i,privateKeyPassphrase:a.target.value}))})]})]}),r.authMode==="configRef"&&s.jsxs("div",{className:"space-y-1.5",children:[u(`${e}-device-ssh-config-ref`,t("device.authConfigRef"),!0),s.jsx(x,{id:`${e}-device-ssh-config-ref`,"data-testid":"device-ssh-config-ref-input",type:"text",value:r.sshConfigRef,onChange:a=>d(i=>({...i,sshConfigRef:a.target.value})),placeholder:t("device.sshConfigRefPlaceholder"),"aria-invalid":c&&!r.sshConfigRef.trim()}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("device.sshConfigRefHint")})]})]})]})]})]}),s.jsxs($e,{children:[s.jsx(C,{type:"button",variant:"outline",onClick:m,children:t("common.cancel")}),s.jsx(C,{type:"submit",variant:"default","data-testid":"device-dialog-save",disabled:l,children:t(l?"common.saving":"common.save")})]})]})]})})}function Je(){const{t:e}=b();return s.jsx(s.Fragment,{children:e("sidebar.manageDevices")})}function Ge(){const{t:e}=b(),o=()=>{window.dispatchEvent(new CustomEvent("tmex:open-add-device"))};return s.jsx(C,{variant:"ghost",size:"icon-sm","data-testid":"devices-add",onClick:o,"aria-label":e("sidebar.addDevice"),title:e("sidebar.addDevice"),children:s.jsx(Y,{className:"h-4 w-4"})})}export{Ge as PageActions,Je as PageTitle,Ue as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Y as zn,_ as ut,r as oe,j as h,X as gt,aM as bt,u as ae,c as $n,aq as qn,a as mt,B as se,Z as nn}from"./index-
|
|
1
|
+
import{Y as zn,_ as ut,r as oe,j as h,X as gt,aM as bt,u as ae,c as $n,aq as qn,a as mt,B as se,Z as nn}from"./index-C1akMMWP.js";import{r as pt,M as _t}from"./markdown-preview-ByBN48Ac.js";import{k as ft,d as Ve,l as te,D as Kn,m as Et,f as ht,c as Nt}from"./api-B3b18azE.js";import{R as yt,s as vt}from"./transfer-toast-yJBQc29j.js";import"./index-c9jmHxDX.js";/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|