tmex-cli 0.6.3 → 0.6.5
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/dist/cli-node.js +4 -2
- package/dist/runtime/server.js +15 -4
- package/package.json +1 -1
- package/resources/fe-dist/assets/DevicePage-CNkRwiKd.js +36 -0
- package/resources/fe-dist/assets/{DevicesPage-ImyBiwEt.js → DevicesPage-7Qum8nfK.js} +2 -2
- package/resources/fe-dist/assets/{SettingsPage-CyMAR4ec.js → SettingsPage-CcYjvVBK.js} +2 -2
- package/resources/fe-dist/assets/{index-qxM5NVWd.js → index-DIffR5B7.js} +19 -19
- package/resources/fe-dist/assets/index-D_DHOdUg.css +1 -0
- package/resources/fe-dist/assets/{select-CALI7PWC.js → select-B8Wx7E3G.js} +2 -2
- package/resources/fe-dist/assets/{switch-CkhOAzoZ.js → switch-ByS4bhig.js} +2 -2
- package/resources/fe-dist/assets/{useValueChanged-WtzSkCNQ.js → useValueChanged-BNNSF8VN.js} +3 -3
- package/resources/fe-dist/index.html +7 -4
- package/resources/fe-dist/assets/DevicePage-BGPoxSI1.js +0 -36
- package/resources/fe-dist/assets/index-otkzncJS.css +0 -1
- /package/resources/fe-dist/{assets/tmex-DcyZpuP8.png → tmex.png} +0 -0
package/dist/cli-node.js
CHANGED
|
@@ -121,7 +121,8 @@ Global flags:
|
|
|
121
121
|
"runtime.started": "Service started on {{url}}",
|
|
122
122
|
"runtime.frontendMissing": "Frontend assets not found.",
|
|
123
123
|
"runtime.methodNotAllowed": "Method Not Allowed",
|
|
124
|
-
"runtime.forbidden": "Forbidden"
|
|
124
|
+
"runtime.forbidden": "Forbidden",
|
|
125
|
+
"runtime.notFound": "Not Found"
|
|
125
126
|
},
|
|
126
127
|
"zh-CN": {
|
|
127
128
|
"cli.help": `tmex CLI
|
|
@@ -219,7 +220,8 @@ Global flags:
|
|
|
219
220
|
"runtime.started": "服务已启动:{{url}}",
|
|
220
221
|
"runtime.frontendMissing": "未找到前端静态资源。",
|
|
221
222
|
"runtime.methodNotAllowed": "方法不允许",
|
|
222
|
-
"runtime.forbidden": "禁止访问"
|
|
223
|
+
"runtime.forbidden": "禁止访问",
|
|
224
|
+
"runtime.notFound": "资源不存在"
|
|
223
225
|
}
|
|
224
226
|
};
|
|
225
227
|
var currentLang = "en";
|
package/dist/runtime/server.js
CHANGED
|
@@ -56590,9 +56590,15 @@ async function handleGetManifest(method) {
|
|
|
56590
56590
|
icons: [
|
|
56591
56591
|
{
|
|
56592
56592
|
src: "/tmex.png",
|
|
56593
|
-
sizes: "
|
|
56593
|
+
sizes: "1024x1024",
|
|
56594
56594
|
type: "image/png",
|
|
56595
|
-
purpose: "any
|
|
56595
|
+
purpose: "any"
|
|
56596
|
+
},
|
|
56597
|
+
{
|
|
56598
|
+
src: "/tmex.png",
|
|
56599
|
+
sizes: "1024x1024",
|
|
56600
|
+
type: "image/png",
|
|
56601
|
+
purpose: "maskable"
|
|
56596
56602
|
}
|
|
56597
56603
|
]
|
|
56598
56604
|
};
|
|
@@ -58165,7 +58171,8 @@ Global flags:
|
|
|
58165
58171
|
"runtime.started": "Service started on {{url}}",
|
|
58166
58172
|
"runtime.frontendMissing": "Frontend assets not found.",
|
|
58167
58173
|
"runtime.methodNotAllowed": "Method Not Allowed",
|
|
58168
|
-
"runtime.forbidden": "Forbidden"
|
|
58174
|
+
"runtime.forbidden": "Forbidden",
|
|
58175
|
+
"runtime.notFound": "Not Found"
|
|
58169
58176
|
},
|
|
58170
58177
|
"zh-CN": {
|
|
58171
58178
|
"cli.help": `tmex CLI
|
|
@@ -58263,7 +58270,8 @@ Global flags:
|
|
|
58263
58270
|
"runtime.started": "\u670D\u52A1\u5DF2\u542F\u52A8\uFF1A{{url}}",
|
|
58264
58271
|
"runtime.frontendMissing": "\u672A\u627E\u5230\u524D\u7AEF\u9759\u6001\u8D44\u6E90\u3002",
|
|
58265
58272
|
"runtime.methodNotAllowed": "\u65B9\u6CD5\u4E0D\u5141\u8BB8",
|
|
58266
|
-
"runtime.forbidden": "\u7981\u6B62\u8BBF\u95EE"
|
|
58273
|
+
"runtime.forbidden": "\u7981\u6B62\u8BBF\u95EE",
|
|
58274
|
+
"runtime.notFound": "\u8D44\u6E90\u4E0D\u5B58\u5728"
|
|
58267
58275
|
}
|
|
58268
58276
|
};
|
|
58269
58277
|
var currentLang = "en";
|
|
@@ -58328,6 +58336,9 @@ async function serveFrontend(req, staticRoot) {
|
|
|
58328
58336
|
if (!requestedPath) {
|
|
58329
58337
|
return new Response(t3("runtime.forbidden"), { status: 403 });
|
|
58330
58338
|
}
|
|
58339
|
+
if (!existsSync4(requestedPath) && extname(url.pathname) !== "") {
|
|
58340
|
+
return new Response(t3("runtime.notFound"), { status: 404 });
|
|
58341
|
+
}
|
|
58331
58342
|
const indexPath = join4(staticRoot, "index.html");
|
|
58332
58343
|
const targetPath = existsSync4(requestedPath) ? requestedPath : indexPath;
|
|
58333
58344
|
if (!existsSync4(targetPath)) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var jt=Object.defineProperty;var Wt=(n,e,t)=>e in n?jt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var f=(n,e,t)=>Wt(n,typeof e!="symbol"?e+"":e,t);import{c as be,u as Ke,j as h,X as qt,r as d,aN as Z,by as ut,f as _e,b as it,bz as ot,bA as Xt,bB as lt,d as ae,bC as Jt,e as Qt,bD as Se,B as pe}from"./index-DIffR5B7.js";import{T as Zt,A as en,a as tn,b as nn,c as sn,d as rn,e as on,f as ln,g as an}from"./useValueChanged-BNNSF8VN.js";import{L as We,S as cn,a as ht}from"./switch-ByS4bhig.js";/**
|
|
2
|
+
* @license lucide-react v0.564.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const dn=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],un=be("arrow-down-to-line",dn);/**
|
|
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 hn=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],fn=be("clipboard-paste",hn);/**
|
|
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 mn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],pn=be("copy",mn);/**
|
|
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 wn=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],yn=be("keyboard",wn);/**
|
|
22
|
+
* @license lucide-react v0.564.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const gn=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Sn=be("refresh-cw",gn);/**
|
|
27
|
+
* @license lucide-react v0.564.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const _n=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],bn=be("smartphone",_n);function xn(n){return`rgb(${n.r} ${n.g} ${n.b})`}function qe(n){const e=n.getContext("2d");if(!e)throw new Error("2d canvas context unavailable");return e}class Tn{constructor(e){f(this,"kind","canvas");f(this,"mainCanvas");f(this,"selectionCanvas");f(this,"cursorCanvas");f(this,"mainContext");f(this,"selectionContext");f(this,"cursorContext");f(this,"theme");f(this,"fontFamily");f(this,"fontSize");f(this,"cellDimensions",{width:9,height:17});f(this,"cols",0);f(this,"rows",0);f(this,"lastCursor",null);f(this,"frameCount",0);f(this,"lastDrawnRows",[]);f(this,"colorCache",new Map);f(this,"fontCache",new Map);f(this,"cursorBlinkVisible",!0);f(this,"cursorBlinkTimer",null);this.theme=e.theme,this.fontFamily=e.fontFamily,this.fontSize=e.fontSize,e.screenElement.style.position="relative",e.screenElement.style.overflow="hidden",this.mainCanvas=document.createElement("canvas"),this.selectionCanvas=document.createElement("canvas"),this.cursorCanvas=document.createElement("canvas");for(const[t,s]of[[this.mainCanvas,"main"],[this.selectionCanvas,"selection"],[this.cursorCanvas,"cursor"]])t.dataset.layer=s,t.style.position="absolute",t.style.inset="0",t.style.width="100%",t.style.height="100%",t.style.pointerEvents="none",e.screenElement.appendChild(t);this.mainContext=qe(this.mainCanvas),this.selectionContext=qe(this.selectionCanvas),this.cursorContext=qe(this.cursorCanvas)}setTheme(e){this.theme=e,this.colorCache.clear()}render(e){if(this.frameCount+=1,this.lastDrawnRows=[],this.cellDimensions=e.cellDimensions,this.resize(e.meta.cols,e.meta.rows),this.drawSelection(e.selectionRects??[],e.selectionColor??this.theme.selectionBackground),e.meta.dirty==="clean"){this.drawCursor(e.meta);return}const s=e.meta.dirty==="full"?e.rows:e.rows.filter(r=>r.dirty);for(const r of s)this.drawRow(r,e.meta.colors),this.lastDrawnRows.push(r.y);this.drawCursor(e.meta)}getDebugState(){return{kind:this.kind,frameCount:this.frameCount,lastDrawnRows:[...this.lastDrawnRows]}}dispose(){this.mainCanvas.remove(),this.selectionCanvas.remove(),this.cursorCanvas.remove(),this.colorCache.clear(),this.fontCache.clear(),this.lastCursor=null,this.stopCursorBlink()}startCursorBlink(){this.cursorBlinkTimer||(this.cursorBlinkTimer=setInterval(()=>{this.cursorBlinkVisible=!this.cursorBlinkVisible,this.cursorCanvas.style.opacity=this.cursorBlinkVisible?"1":"0"},1e3))}stopCursorBlink(){this.cursorBlinkTimer&&(clearInterval(this.cursorBlinkTimer),this.cursorBlinkTimer=null),this.cursorBlinkVisible=!0,this.cursorCanvas.style.opacity="1"}resize(e,t){const s=Math.max(1,e),r=Math.max(1,t),i=s*this.cellDimensions.width,o=r*this.cellDimensions.height,l=Math.max(1,globalThis.devicePixelRatio??1);if(this.cols===s&&this.rows===r){const u=`${i}px`,a=`${o}px`;if(this.mainCanvas.style.width===u&&this.mainCanvas.style.height===a)return}this.cols=s,this.rows=r;for(const u of[this.mainCanvas,this.selectionCanvas,this.cursorCanvas])u.width=Math.max(1,Math.ceil(i*l)),u.height=Math.max(1,Math.ceil(o*l)),u.style.width=`${i}px`,u.style.height=`${o}px`;for(const u of[this.mainContext,this.selectionContext,this.cursorContext])u.setTransform(l,0,0,l,0,0),u.textBaseline="top",u.imageSmoothingEnabled=!1}drawSelection(e,t){if(this.selectionContext.clearRect(0,0,this.cols*this.cellDimensions.width,this.rows*this.cellDimensions.height),e.length!==0){this.selectionContext.fillStyle=t;for(const s of e)this.selectionContext.fillRect(s.x*this.cellDimensions.width,s.row*this.cellDimensions.height,s.width*this.cellDimensions.width,this.cellDimensions.height)}}drawRow(e,t){const s=e.y*this.cellDimensions.height,r=this.cols*this.cellDimensions.width,i=this.toCss(t.background);this.mainContext.clearRect(0,s,r,this.cellDimensions.height),this.mainContext.fillStyle=i,this.mainContext.fillRect(0,s,r,this.cellDimensions.height);for(const o of e.cells){if(o.widthKind==="spacer-tail"||o.widthKind==="spacer-head")continue;const l=o.x*this.cellDimensions.width,u=o.style.inverse?o.fgColor??t.foreground:o.bgColor??t.background,a=o.style.inverse?o.bgColor??t.background:o.fgColor??t.foreground,g=o.widthKind==="wide"?this.cellDimensions.width*2:this.cellDimensions.width;(u.r!==t.background.r||u.g!==t.background.g||u.b!==t.background.b)&&(this.mainContext.fillStyle=this.toCss(u),this.mainContext.fillRect(l,s,g,this.cellDimensions.height)),!(!o.text||o.style.invisible)&&(this.mainContext.font=this.resolveFont(o.style),this.mainContext.fillStyle=this.toCss(a),this.mainContext.fillText(o.text,l,s),o.style.underline>0&&this.mainContext.fillRect(l,s+this.cellDimensions.height-2,Math.max(g-1,1),1),o.style.strikethrough&&this.mainContext.fillRect(l,s+this.cellDimensions.height*.55,Math.max(g-1,1),1),o.style.overline&&this.mainContext.fillRect(l,s+1,Math.max(g-1,1),1))}}drawCursor(e){const t=e.colors,s=e.cursor,r=this.lastCursor;if(this.cursorContext.clearRect(0,0,this.cols*this.cellDimensions.width,this.rows*this.cellDimensions.height),!s.visible||s.x===null||s.y===null){this.lastCursor=null,this.stopCursorBlink();return}const i=s.x*this.cellDimensions.width,o=s.y*this.cellDimensions.height,l=s.wideTail?this.cellDimensions.width*2:this.cellDimensions.width,u=t.cursor??t.foreground,a=this.toCss(u);this.cursorContext.fillStyle=a,this.cursorContext.strokeStyle=a,this.cursorContext.globalAlpha=.7,this.cursorContext.fillRect(i,o+this.cellDimensions.height-2,Math.max(l-1,1),2),this.cursorContext.globalAlpha=1,this.startCursorBlink(),this.lastCursor={x:s.x,y:s.y,style:s.style},r&&(r.x!==this.lastCursor.x||r.y!==this.lastCursor.y||r.style!==this.lastCursor.style)&&this.lastDrawnRows.push(r.y)}resolveFont(e){const t=[e.italic?"italic":"normal",e.bold?"700":"400",`${this.fontSize}px`,this.fontFamily].join("|"),s=this.fontCache.get(t);if(s)return s;const r=`${e.italic?"italic ":""}${e.bold?"700 ":""}${this.fontSize}px ${this.fontFamily}`;return this.fontCache.set(t,r),r}toCss(e){const t=`${e.r},${e.g},${e.b}`,s=this.colorCache.get(t);if(s)return s;const r=xn(e);return this.colorCache.set(t,r),r}}const En=0,Rn={Backquote:1,Backslash:2,BracketLeft:3,BracketRight:4,Comma:5,Digit0:6,Digit1:7,Digit2:8,Digit3:9,Digit4:10,Digit5:11,Digit6:12,Digit7:13,Digit8:14,Digit9:15,Equal:16,IntlBackslash:17,IntlRo:18,IntlYen:19,KeyA:20,KeyB:21,KeyC:22,KeyD:23,KeyE:24,KeyF:25,KeyG:26,KeyH:27,KeyI:28,KeyJ:29,KeyK:30,KeyL:31,KeyM:32,KeyN:33,KeyO:34,KeyP:35,KeyQ:36,KeyR:37,KeyS:38,KeyT:39,KeyU:40,KeyV:41,KeyW:42,KeyX:43,KeyY:44,KeyZ:45,Minus:46,Period:47,Quote:48,Semicolon:49,Slash:50,AltLeft:51,AltRight:52,Backspace:53,CapsLock:54,ContextMenu:55,ControlLeft:56,ControlRight:57,Enter:58,MetaLeft:59,MetaRight:60,ShiftLeft:61,ShiftRight:62,Space:63,Tab:64,Convert:65,KanaMode:66,NonConvert:67,Delete:68,End:69,Help:70,Home:71,Insert:72,PageDown:73,PageUp:74,ArrowDown:75,ArrowLeft:76,ArrowRight:77,ArrowUp:78,NumLock:79,Numpad0:80,Numpad1:81,Numpad2:82,Numpad3:83,Numpad4:84,Numpad5:85,Numpad6:86,Numpad7:87,Numpad8:88,Numpad9:89,NumpadAdd:90,NumpadBackspace:91,NumpadClear:92,NumpadClearEntry:93,NumpadComma:94,NumpadDecimal:95,NumpadDivide:96,NumpadEnter:97,NumpadEqual:98,NumpadMemoryAdd:99,NumpadMemoryClear:100,NumpadMemoryRecall:101,NumpadMemoryStore:102,NumpadMemorySubtract:103,NumpadMultiply:104,NumpadParenLeft:105,NumpadParenRight:106,NumpadSubtract:107,NumpadSeparator:108,NumpadUp:109,NumpadDown:110,NumpadRight:111,NumpadLeft:112,NumpadBegin:113,NumpadHome:114,NumpadEnd:115,NumpadInsert:116,NumpadDelete:117,NumpadPageUp:118,NumpadPageDown:119,Escape:120,F1:121,F2:122,F3:123,F4:124,F5:125,F6:126,F7:127,F8:128,F9:129,F10:130,F11:131,F12:132,F13:133,F14:134,F15:135,F16:136,F17:137,F18:138,F19:139,F20:140,F21:141,F22:142,F23:143,F24:144,F25:145,Fn:146,FnLock:147,PrintScreen:148,ScrollLock:149,Pause:150,BrowserBack:151,BrowserFavorites:152,BrowserForward:153,BrowserHome:154,BrowserRefresh:155,BrowserSearch:156,BrowserStop:157,Eject:158,LaunchApp1:159,LaunchApp2:160,LaunchMail:161,MediaPlayPause:162,MediaSelect:163,MediaStop:164,MediaTrackNext:165,MediaTrackPrevious:166,Power:167,Sleep:168,AudioVolumeDown:169,AudioVolumeMute:170,AudioVolumeUp:171,WakeUp:172,Copy:173,Cut:174,Paste:175},at={Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Quote:"'",Semicolon:";",Slash:"/",Space:" ",IntlBackslash:"\\",IntlYen:"¥",IntlRo:"\\"};for(let n=0;n<=9;n+=1)at[`Digit${n}`]=String(n);for(let n=0;n<26;n+=1){const e=String.fromCharCode(65+n),t=String.fromCharCode(97+n);at[`Key${e}`]=t}function ft(n){return Rn[n]??En}function Cn(n){const e=at[n];return e?e.codePointAt(0)??null:null}const xe=0,vn=-2,Mn=1,Dn=2,An=3,On=10,kn=11,In=12,Nn=13,Pn=14,Bn=15,Hn=16,Ln=17,Fn=1,Gn=2,Un=1,zn=2,Yn=3,Vn=4,Kn=5,$n=6,jn=1,Wn=2,qn=3,Xn=4;function ct(n){if(n.disposed||n.renderStateHandle===0)throw new Error("render state resources already disposed")}function Jn(n){switch(n){case 2:return"full";case 1:return"partial";default:return"clean"}}function Qn(n){switch(n){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function Zn(n){switch(n){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function Re(n,e){return{r:n.view().getUint8(e),g:n.view().getUint8(e+1),b:n.view().getUint8(e+2)}}function mt(n,e){const t=n.bindings.allocStruct("GhosttyColorRgb");try{const s=e(t.ptr);if(s===vn)return null;if(s!==xe)throw new Error(`ghostty optional color read failed with result ${s}`);return Re(n.bindings,t.ptr)}finally{t.free()}}function ce(n,e){const t=n.bindings.allocU8();try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty bool read failed with result ${s}`);return n.bindings.readU8(t)!==0}finally{n.bindings.freeU8(t)}}function Pe(n,e){const t=n.bindings.allocBytes(2);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty u16 read failed with result ${s}`);return n.bindings.view().getUint16(t,!0)}finally{n.bindings.freeBytes(t,2)}}function es(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty u32 read failed with result ${s}`);return n.bindings.view().getUint32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function nt(n,e){const t=n.bindings.allocBytes(4);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty enum read failed with result ${s}`);return n.bindings.view().getInt32(t,!0)}finally{n.bindings.freeBytes(t,4)}}function pt(n,e){const t=n.bindings.allocBytes(8);try{const s=e(t);if(typeof s=="number"&&s!==xe)throw new Error(`ghostty u64 read failed with result ${s}`);return n.bindings.readU64(t)}finally{n.bindings.freeBytes(t,8)}}function ts(n){const e=n.bindings.allocStruct("GhosttyStyle");try{n.bindings.setField(e.view,"GhosttyStyle","size",n.bindings.typeSize("GhosttyStyle")),n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,zn,e.ptr);const t=s=>n.bindings.field("GhosttyStyle",s).offset;return{bold:e.view.getUint8(t("bold"))!==0,italic:e.view.getUint8(t("italic"))!==0,faint:e.view.getUint8(t("faint"))!==0,blink:e.view.getUint8(t("blink"))!==0,inverse:e.view.getUint8(t("inverse"))!==0,invisible:e.view.getUint8(t("invisible"))!==0,strikethrough:e.view.getUint8(t("strikethrough"))!==0,overline:e.view.getUint8(t("overline"))!==0,underline:e.view.getInt32(t("underline"),!0)}}finally{e.free()}}function ns(n){const e=es(n,s=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Yn,s));if(e===0)return[];const t=n.bindings.allocBytes(e*4);try{n.bindings.getRenderStateRowCellValue(n.rowCellsHandle,Vn,t);const s=[];for(let r=0;r<e;r+=1)s.push(n.bindings.view().getUint32(t+r*4,!0));return s}finally{n.bindings.freeBytes(t,e*4)}}function ss(n){if(n.length===0)return"";try{return String.fromCodePoint(...n)}catch{return""}}function rs(n){let e="";for(const t of n)if(!(t.widthKind==="spacer-tail"||t.widthKind==="spacer-head")){if(t.text){e+=t.text;continue}t.widthKind==="narrow"&&(e+=" ")}return e}function is(n){const e=n.bindings.allocStruct("GhosttyRenderStateColors");try{n.bindings.setField(e.view,"GhosttyRenderStateColors","size",n.bindings.typeSize("GhosttyRenderStateColors")),n.bindings.getRenderStateColors(n.renderStateHandle,e.ptr);const t=n.bindings.field("GhosttyRenderStateColors","palette").offset,s=[];for(let o=0;o<256;o+=1){const l=e.ptr+t+o*3;s.push(Re(n.bindings,l))}const r=e.view.getUint8(n.bindings.field("GhosttyRenderStateColors","cursor_has_value").offset)!==0,i=ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Pn,o));return{cols:Pe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Mn,o)),rows:Pe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Dn,o)),dirty:Jn(nt(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,An,o))),colors:{background:Re(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","background").offset),foreground:Re(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:r?Re(n.bindings,e.ptr+n.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:s},cursor:{style:Qn(nt(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,On,o))),visible:ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,kn,o)),blinking:ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,In,o)),passwordInput:ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Nn,o)),x:i?Pe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Bn,o)):null,y:i?Pe(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Hn,o)):null,wideTail:i?ce(n,o=>n.bindings.getRenderStateValueResult(n.renderStateHandle,Ln,o)):!1}}}finally{e.free()}}function os(n,e){const t=pt(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,Gn,i));n.bindings.bindRenderStateRowCells(n.rowIteratorHandle,n.rowCellsHandle);const s=[];let r=0;for(;n.bindings.nextRenderStateRowCell(n.rowCellsHandle);){const i=pt(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Un,a)),o=ns(n),l=Zn(nt(n,a=>n.bindings.getRawCellValueResult(i,qn,a))),u={x:r,text:ss(o),codepoints:o,widthKind:l,hasText:ce(n,a=>n.bindings.getRawCellValueResult(i,Xn,a)),style:ts(n),fgColor:mt(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,$n,a)),bgColor:mt(n,a=>n.bindings.getRenderStateRowCellValueResult(n.rowCellsHandle,Kn,a))};s.push(u),r+=1}return{y:e,dirty:ce(n,i=>n.bindings.getRenderStateRowValueResult(n.rowIteratorHandle,Fn,i)),wrap:ce(n,i=>n.bindings.getRawRowValueResult(t,jn,i)),wrapContinuation:ce(n,i=>n.bindings.getRawRowValueResult(t,Wn,i)),text:rs(s),cells:s}}function wt(n){return{bindings:n,renderStateHandle:n.createRenderState(),rowIteratorHandle:n.createRenderStateRowIterator(),rowCellsHandle:n.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function yt(n,e){ct(n),n.bindings.updateRenderState(n.renderStateHandle,e),n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle),n.snapshotVersion+=1,n.cachedMeta=null}function st(n){return ct(n),n.cachedMeta||(n.cachedMeta=is(n)),n.cachedMeta}function*ls(n){ct(n);const e=st(n);n.bindings.bindRenderStateRowIterator(n.renderStateHandle,n.rowIteratorHandle);let t=0;for(;t<e.rows&&n.bindings.nextRenderStateRowIterator(n.rowIteratorHandle);)yield os(n,t),t+=1}function Xe(n){n.disposed||(n.disposed=!0,n.rowCellsHandle!==0&&(n.bindings.freeRenderStateRowCells(n.rowCellsHandle),n.rowCellsHandle=0),n.rowIteratorHandle!==0&&(n.bindings.freeRenderStateRowIterator(n.rowIteratorHandle),n.rowIteratorHandle=0),n.renderStateHandle!==0&&(n.bindings.freeRenderState(n.renderStateHandle),n.renderStateHandle=0),n.cachedMeta=null)}const as={colChars:[],contentCols:0,wrappedToNext:!1};function cs(n){for(let e=n.length-1;e>=0;e-=1){const t=n[e];if(t!==null&&t!==""&&t!==" ")return e+1}return 0}function gt(n,e=!1){const t=[];for(const s of n){if(s.widthKind==="spacer-tail"){t.push(null);continue}if(s.widthKind==="spacer-head"){t.push("");continue}t.push(s.text||" ")}return{colChars:t,contentCols:cs(t),wrappedToNext:e}}function ds(n,e){return Math.max(0,Math.min(Math.max(n.colChars.length-1,0),Math.floor(e)))}function dt(n,e){let t=ds(n,e);for(;t>0&&n.colChars[t]===null;)t-=1;return t}function Je(n,e){let t=e;for(;t>0&&n.colChars[t]===null;)t-=1;return n.colChars[t]||""}function St(n,e){let t=e;for(;t+1<n.colChars.length&&n.colChars[t+1]===null;)t+=1;return t}function us(n,e){return n.line<e.line?{start:n,end:e}:n.line>e.line?{start:e,end:n}:n.col<=e.col?{start:n,end:e}:{start:e,end:n}}function hs(n,e,t){if(t.colChars.length===0)return{start:{line:n,col:0},end:{line:n,col:0}};const s=dt(t,e),r=l=>/[\p{L}\p{N}_-]/u.test(l);if(!r(Je(t,s)))return{start:{line:n,col:s},end:{line:n,col:s}};let i=s,o=s;for(;i>0&&r(Je(t,i-1));)i-=1;for(;o+1<t.colChars.length&&r(Je(t,o+1));)o+=1;return{start:{line:n,col:i},end:{line:n,col:o}}}function kt(n,e){const t=Math.max(e.contentCols-1,0);return{start:{line:n,col:0},end:{line:n,col:t}}}function It(n,e,t){const s=t(n.line);switch(e){case"word":return hs(n.line,n.col,s);case"line":return kt(n.line,s);default:{const r=dt(s,n.col);return{start:{line:n.line,col:r},end:{line:n.line,col:r}}}}}function Nt(){return{anchor:null,focus:null,mode:"character"}}function _t(n){return!!(n.anchor&&n.focus)}function fs(){return Nt()}function ms(n,e,t){const s=It(e,e.mode,t);return{anchor:s.start,focus:s.end,mode:e.mode}}function bt(n,e,t){return n.anchor?n.mode==="line"?{...n,focus:kt(e.line,t(e.line)).end}:n.mode==="word"?{...n,focus:It(e,"word",t).end}:{...n,focus:{line:e.line,col:dt(t(e.line),e.col)}}:n}function Pt(n){return!n.anchor||!n.focus?null:us(n.anchor,n.focus)}function ps(n,e,t){const s=n.wrappedToNext?n.colChars.length-1:n.contentCols-1,r=Math.min(t,s);let i=Math.max(0,e);for(;i>0&&n.colChars[i]===null;)i-=1;if(i>r)return"";let o="";for(let l=i;l<=r;l+=1)o+=n.colChars[l]??"";return o}function ws(n,e){const t=Pt(n);if(!t)return null;let s="";for(let r=t.start.line;r<=t.end.line;r+=1){const i=e(r),o=r===t.start.line?t.start.col:0,l=r===t.end.line?t.end.col:i.colChars.length-1;s+=ps(i,o,l),r<t.end.line&&!i.wrappedToNext&&(s+=`
|
|
32
|
+
`)}return s}function ys(n,e,t,s){const r=Pt(n);if(!r)return[];const i=e+t-1,o=[];for(let l=Math.max(r.start.line,e);l<=Math.min(r.end.line,i);l+=1){const u=l-e;if(l===r.start.line&&l===r.end.line){const g=s==null?void 0:s(l),E=g?St(g,r.end.col):r.end.col;o.push({row:u,x:r.start.col,width:E-r.start.col+1});continue}if(l===r.start.line){const g=s?Math.max(s(l).colChars.length-r.start.col,0):Number.MAX_SAFE_INTEGER;o.push({row:u,x:r.start.col,width:g});continue}if(l===r.end.line){const g=s==null?void 0:s(l),E=g?St(g,r.end.col):r.end.col;o.push({row:u,x:0,width:E+1});continue}const a=s?s(l).colChars.length:Number.MAX_SAFE_INTEGER;o.push({row:u,x:0,width:a})}return o}function Bt(){var e;if(typeof navigator>"u")return!1;const n=((e=navigator.userAgentData)==null?void 0:e.platform)??navigator.platform??"";return/mac|iphone|ipad|ipod/iu.test(n)?!0:/mac os x/iu.test(navigator.userAgent??"")}function gs(n){return n.altKey?!1:!!(Bt()?n.metaKey:n.ctrlKey)}function Ss(n){return gs(n)&&n.key.toLowerCase()==="c"}function _s(n){return n.shiftKey&&n.key==="Insert"&&!n.ctrlKey&&!n.altKey&&!n.metaKey?!0:n.altKey||n.key.toLowerCase()!=="v"?!1:!!(Bt()?n.metaKey:n.ctrlKey)}async function Ht(n){var t;if(!n)return;if(typeof navigator<"u"&&((t=navigator.clipboard)!=null&&t.writeText))try{await navigator.clipboard.writeText(n);return}catch{}if(typeof document>"u"||typeof document.execCommand!="function")throw new Error("clipboard unavailable");const e=document.createElement("textarea");e.value=n,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.left="-9999px",e.style.top="0",document.body.appendChild(e);try{if(e.select(),!document.execCommand("copy"))throw new Error("execCommand copy failed")}finally{e.remove()}}async function bs(n){n&&await Ht(n)}function xs(n,e){return!e||!n.clipboardData?!1:(n.clipboardData.setData("text/plain",e),n.preventDefault(),!0)}const Ts="/assets/ghostty-vt-BKQMf-5X.wasm",Ge=0,xt=-3,Es=11,Rs=12,Cs=13,vs=14,Ms=1,Ds=2,As=9,Os=1,ks=0,Is=1,Ns=2,Ps=0,Bs=1,Hs=2,Ls=4,Fs=2004,Gs=9,Us=1e3,zs=1002,Ys=1003,Vs=1005,Tt=1006,Ks=1015,Et=1016;let Qe=null;function O(n,e){if(n!==Ge)throw new Error(`${e} failed with result ${n}`)}function Lt(n){const e=n.trim().replace(/^#/,"");if(e.length!==6)throw new Error(`expected #RRGGBB color, received: ${n}`);return[Number.parseInt(e.slice(0,2),16),Number.parseInt(e.slice(2,4),16),Number.parseInt(e.slice(4,6),16)]}function $s(n){const t=[...[n.black,n.red,n.green,n.yellow,n.blue,n.magenta,n.cyan,n.white,n.brightBlack,n.brightRed,n.brightGreen,n.brightYellow,n.brightBlue,n.brightMagenta,n.brightCyan,n.brightWhite].map(Lt)],s=[0,95,135,175,215,255];for(const r of s)for(const i of s)for(const o of s)t.push([r,i,o]);for(let r=0;r<24;r+=1){const i=8+r*10;t.push([i,i,i])}return t}function js(n){let e=0;return n&1&&(e+=4),n&4&&(e+=8),n&2&&(e+=16),e}function Ze(n){return n<0||n>223?null:String.fromCharCode(n+32)}function Ws(n){switch(n){case 1:return 0;case 3:return 1;case 2:return 2;case 4:return 64;case 5:return 65;case 6:return 66;case 7:return 67;case 8:return 128;case 9:return 129;case null:case void 0:return 3;default:return null}}function Ft(n){var t,s;let e=0;return n.shiftKey&&(e|=1),n.ctrlKey&&(e|=2),n.altKey&&(e|=4),n.metaKey&&(e|=8),(t=n.getModifierState)!=null&&t.call(n,"CapsLock")&&(e|=16),(s=n.getModifierState)!=null&&s.call(n,"NumLock")&&(e|=32),e}class qs{constructor(e,t,s){this.bindings=e,this.typeName=t,this.ptr=s}get view(){return this.bindings.view(this.ptr,this.bindings.typeSize(this.typeName))}free(){this.bindings.freeBytes(this.ptr,this.bindings.typeSize(this.typeName))}}class Xs{constructor(e,t){f(this,"exports");f(this,"layout");f(this,"decoder",new TextDecoder);f(this,"encoder",new TextEncoder);this.exports=e,this.layout=t}buffer(){return this.exports.memory.buffer}bytes(e=0,t=this.buffer().byteLength-e){return new Uint8Array(this.buffer(),e,t)}view(e=0,t=this.buffer().byteLength-e){return new DataView(this.buffer(),e,t)}typeSize(e){const t=this.layout[e];if(!t)throw new Error(`unknown ghostty type: ${e}`);return t.size}field(e,t){const s=this.layout[e],r=s==null?void 0:s.fields[t];if(!s||!r)throw new Error(`unknown ghostty field: ${e}.${t}`);return r}allocStruct(e){const t=this.allocBytes(this.typeSize(e));return this.bytes(t,this.typeSize(e)).fill(0),new qs(this,e,t)}allocBytes(e){return this.exports.ghostty_wasm_alloc_u8_array(e)}freeBytes(e,t){this.exports.ghostty_wasm_free_u8_array(e,t)}allocOpaque(){return this.exports.ghostty_wasm_alloc_opaque()}freeOpaque(e){this.exports.ghostty_wasm_free_opaque(e)}allocU8(){return this.exports.ghostty_wasm_alloc_u8()}freeU8(e){this.exports.ghostty_wasm_free_u8(e)}allocUsize(){return this.exports.ghostty_wasm_alloc_usize()}freeUsize(e){this.exports.ghostty_wasm_free_usize(e)}readPointer(e){return this.view().getUint32(e,!0)}readU8(e){return this.view().getUint8(e)}readUsize(e){return this.view().getUint32(e,!0)}readU64(e){return this.view().getBigUint64(e,!0)}setField(e,t,s,r){const i=this.field(t,s),o=i.offset;switch(i.type){case"u8":case"bool":e.setUint8(o,Number(r));return;case"u16":e.setUint16(o,Number(r),!0);return;case"u32":e.setUint32(o,Number(r),!0);return;case"u64":e.setBigUint64(o,BigInt(r),!0);return;case"usize":{e.setUint32(o,Number(r),!0);return}case"i32":case"enum":e.setInt32(o,Number(r),!0);return;default:throw new Error(`unsupported field type ${t}.${s}: ${i.type}`)}}writeString(e){const t=this.encoder.encode(e),s=this.allocBytes(t.length);return this.bytes(s,t.length).set(t),{ptr:s,len:t.length,free:()=>this.freeBytes(s,t.length)}}writeBytes(e){const t=this.allocBytes(e.length);return this.bytes(t,e.length).set(e),{ptr:t,len:e.length,free:()=>this.freeBytes(t,e.length)}}readOwnedUtf8(e,t){return this.decoder.decode(this.bytes(e,t))}createTerminal(e,t,s){const r=this.allocStruct("GhosttyTerminalOptions");this.setField(r.view,"GhosttyTerminalOptions","cols",e),this.setField(r.view,"GhosttyTerminalOptions","rows",t),this.setField(r.view,"GhosttyTerminalOptions","max_scrollback",s);const i=this.allocOpaque();try{return O(this.exports.ghostty_terminal_new(0,i,r.ptr),"ghostty_terminal_new"),this.readPointer(i)}finally{r.free(),this.freeOpaque(i)}}freeTerminal(e){this.exports.ghostty_terminal_free(e)}writeVt(e,t){const s=typeof t=="string"?this.encoder.encode(t):t,r=this.writeBytes(s);try{this.exports.ghostty_terminal_vt_write(e,r.ptr,r.len)}finally{r.free()}}resetTerminal(e){this.exports.ghostty_terminal_reset(e)}resizeTerminal(e,t,s,r){O(this.exports.ghostty_terminal_resize(e,t,s,Math.max(1,Math.round(r.width)),Math.max(1,Math.round(r.height))),"ghostty_terminal_resize")}scrollViewportDelta(e,t){const s=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(s.view,"GhosttyTerminalScrollViewport","tag",Ns),s.view.setBigInt64(this.field("GhosttyTerminalScrollViewport","value").offset,BigInt(t),!0),this.exports.ghostty_terminal_scroll_viewport(e,s.ptr)}finally{s.free()}}scrollViewportTop(e){const t=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(t.view,"GhosttyTerminalScrollViewport","tag",ks),this.exports.ghostty_terminal_scroll_viewport(e,t.ptr)}finally{t.free()}}scrollViewportBottom(e){const t=this.allocStruct("GhosttyTerminalScrollViewport");try{this.setField(t.view,"GhosttyTerminalScrollViewport","tag",Is),this.exports.ghostty_terminal_scroll_viewport(e,t.ptr)}finally{t.free()}}setTerminalTheme(e,t){const s=this.allocStruct("GhosttyColorRgb"),r=this.allocStruct("GhosttyColorRgb"),i=this.allocStruct("GhosttyColorRgb"),o=$s(t),l=this.allocBytes(o.length*3),u=(g,E)=>{const[A,B,T]=Lt(E);this.setField(g.view,"GhosttyColorRgb","r",A),this.setField(g.view,"GhosttyColorRgb","g",B),this.setField(g.view,"GhosttyColorRgb","b",T)};u(s,t.foreground),u(r,t.background),u(i,t.cursor);const a=this.bytes(l,o.length*3);o.forEach(([g,E,A],B)=>{const T=B*3;a[T]=g,a[T+1]=E,a[T+2]=A});try{O(this.exports.ghostty_terminal_set(e,Es,s.ptr),"ghostty_terminal_set(foreground)"),O(this.exports.ghostty_terminal_set(e,Rs,r.ptr),"ghostty_terminal_set(background)"),O(this.exports.ghostty_terminal_set(e,Cs,i.ptr),"ghostty_terminal_set(cursor)"),O(this.exports.ghostty_terminal_set(e,vs,l),"ghostty_terminal_set(palette)")}finally{s.free(),r.free(),i.free(),this.freeBytes(l,o.length*3)}}readTerminalSize(e){const t=this.allocBytes(2),s=this.allocBytes(2);try{return O(this.exports.ghostty_terminal_get(e,Ms,t),"ghostty_terminal_get(cols)"),O(this.exports.ghostty_terminal_get(e,Ds,s),"ghostty_terminal_get(rows)"),{cols:this.view().getUint16(t,!0),rows:this.view().getUint16(s,!0)}}finally{this.freeBytes(t,2),this.freeBytes(s,2)}}readScrollbar(e){const t=this.allocStruct("GhosttyTerminalScrollbar");try{return O(this.exports.ghostty_terminal_get(e,As,t.ptr),"ghostty_terminal_get(scrollbar)"),{total:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","total").offset,!0)),offset:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","offset").offset,!0)),len:Number(t.view.getBigUint64(this.field("GhosttyTerminalScrollbar","len").offset,!0))}}finally{t.free()}}isTerminalModeEnabled(e,t){const s=this.allocU8();try{return O(this.exports.ghostty_terminal_mode_get(e,t,s),"ghostty_terminal_mode_get"),this.readU8(s)!==0}finally{this.freeU8(s)}}setTerminalMode(e,t,s){O(this.exports.ghostty_terminal_mode_set(e,t,s?1:0),"ghostty_terminal_mode_set")}createFormatter(e,t,s){const r=this.allocStruct("GhosttyFormatterTerminalOptions"),i=this.field("GhosttyFormatterTerminalOptions","extra").offset,o=this.view(r.ptr+i,this.typeSize("GhosttyFormatterTerminalExtra")),l=this.field("GhosttyFormatterTerminalExtra","screen").offset,u=this.view(r.ptr+i+l,this.typeSize("GhosttyFormatterScreenExtra")),a=this.allocOpaque();try{this.setField(r.view,"GhosttyFormatterTerminalOptions","size",this.typeSize("GhosttyFormatterTerminalOptions")),this.setField(r.view,"GhosttyFormatterTerminalOptions","emit",t),this.setField(r.view,"GhosttyFormatterTerminalOptions","unwrap",s.unwrap),this.setField(r.view,"GhosttyFormatterTerminalOptions","trim",s.trim),this.setField(o,"GhosttyFormatterTerminalExtra","size",this.typeSize("GhosttyFormatterTerminalExtra")),this.setField(o,"GhosttyFormatterTerminalExtra","palette",s.includePalette),this.setField(u,"GhosttyFormatterScreenExtra","size",this.typeSize("GhosttyFormatterScreenExtra"));const g=this.field("GhosttyFormatterTerminalOptions","selection").offset;return r.view.setUint32(g,s.selectionPtr??0,!0),O(this.exports.ghostty_formatter_terminal_new(0,a,e,r.ptr),"ghostty_formatter_terminal_new"),this.readPointer(a)}finally{r.free(),this.freeOpaque(a)}}freeFormatter(e){this.exports.ghostty_formatter_free(e)}resolveViewportGridRef(e,t,s){const r=this.allocStruct("GhosttyPoint"),i=this.allocStruct("GhosttyGridRef");try{this.setField(r.view,"GhosttyPoint","tag",Os);const o=this.field("GhosttyPoint","value").offset,l=this.view(r.ptr+o,this.typeSize("GhosttyPointCoordinate"));return this.setField(l,"GhosttyPointCoordinate","x",t),this.setField(l,"GhosttyPointCoordinate","y",s),this.exports.ghostty_terminal_grid_ref(e,r.ptr,i.ptr)!==Ge?(i.free(),null):i}finally{r.free()}}createViewportSelection(e,t,s){const r=Math.max(1,Math.floor(t)),i=Math.max(1,Math.floor(s)),o=this.resolveViewportGridRef(e,0,0);if(!o)return null;let l=null;for(let a=i-1;a>=0&&(l=this.resolveViewportGridRef(e,r-1,a),!l);a-=1);if(!l)return o.free(),null;const u=this.allocStruct("GhosttySelection");try{this.setField(u.view,"GhosttySelection","size",this.typeSize("GhosttySelection")),this.setField(u.view,"GhosttySelection","rectangle",!1);const a=this.field("GhosttySelection","start").offset,g=this.field("GhosttySelection","end").offset;return this.bytes(u.ptr+a,this.typeSize("GhosttyGridRef")).set(this.bytes(o.ptr,this.typeSize("GhosttyGridRef"))),this.bytes(u.ptr+g,this.typeSize("GhosttyGridRef")).set(this.bytes(l.ptr,this.typeSize("GhosttyGridRef"))),u}finally{o.free(),l.free()}}formatViewport(e,t,s,r){const i=this.readTerminalSize(e),o=this.createViewportSelection(e,Math.max(1,Math.min(i.cols,r.cols)),Math.max(1,Math.min(i.rows,r.rows))),l=this.createFormatter(e,t,{...s,selectionPtr:(o==null?void 0:o.ptr)??null});try{return this.formatFormatter(l)}finally{this.freeFormatter(l),o==null||o.free()}}formatFormatter(e){const t=this.allocOpaque(),s=this.allocUsize();try{O(this.exports.ghostty_formatter_format_alloc(e,0,t,s),"ghostty_formatter_format_alloc");const r=this.readPointer(t),i=this.readUsize(s),o=this.buffer().byteLength;try{if(i===0||r===0)return"";if(r<0||r>o||i>o-r)throw new Error(`ghostty_formatter_format_alloc returned invalid slice ptr=${r} len=${i} mem=${o}`);return this.readOwnedUtf8(r,i)}finally{i>0&&r!==0&&this.exports.ghostty_free(0,r,i)}}finally{this.freeOpaque(t),this.freeUsize(s)}}createRenderState(){const e=this.allocOpaque();try{return O(this.exports.ghostty_render_state_new(0,e),"ghostty_render_state_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderState(e){this.exports.ghostty_render_state_free(e)}updateRenderState(e,t){O(this.exports.ghostty_render_state_update(e,t),"ghostty_render_state_update")}getRenderStateValueResult(e,t,s){return this.exports.ghostty_render_state_get(e,t,s)}getRenderStateValue(e,t,s){O(this.getRenderStateValueResult(e,t,s),"ghostty_render_state_get")}setRenderStateValue(e,t,s){O(this.exports.ghostty_render_state_set(e,t,s),"ghostty_render_state_set")}getRenderStateColors(e,t){O(this.exports.ghostty_render_state_colors_get(e,t),"ghostty_render_state_colors_get")}createRenderStateRowIterator(){const e=this.allocOpaque();try{return O(this.exports.ghostty_render_state_row_iterator_new(0,e),"ghostty_render_state_row_iterator_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderStateRowIterator(e){this.exports.ghostty_render_state_row_iterator_free(e)}bindRenderStateRowIterator(e,t){const s=this.allocOpaque();try{this.view(s,4).setUint32(0,t,!0),this.getRenderStateValue(e,4,s)}finally{this.freeOpaque(s)}}nextRenderStateRowIterator(e){return this.exports.ghostty_render_state_row_iterator_next(e)!==0}getRenderStateRowValueResult(e,t,s){return this.exports.ghostty_render_state_row_get(e,t,s)}getRenderStateRowValue(e,t,s){O(this.getRenderStateRowValueResult(e,t,s),"ghostty_render_state_row_get")}setRenderStateRowValue(e,t,s){O(this.exports.ghostty_render_state_row_set(e,t,s),"ghostty_render_state_row_set")}createRenderStateRowCells(){const e=this.allocOpaque();try{return O(this.exports.ghostty_render_state_row_cells_new(0,e),"ghostty_render_state_row_cells_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeRenderStateRowCells(e){this.exports.ghostty_render_state_row_cells_free(e)}bindRenderStateRowCells(e,t){const s=this.allocOpaque();try{this.view(s,4).setUint32(0,t,!0),this.getRenderStateRowValue(e,3,s)}finally{this.freeOpaque(s)}}nextRenderStateRowCell(e){return this.exports.ghostty_render_state_row_cells_next(e)!==0}selectRenderStateRowCell(e,t){O(this.exports.ghostty_render_state_row_cells_select(e,t),"ghostty_render_state_row_cells_select")}getRenderStateRowCellValueResult(e,t,s){return this.exports.ghostty_render_state_row_cells_get(e,t,s)}getRenderStateRowCellValue(e,t,s){O(this.getRenderStateRowCellValueResult(e,t,s),"ghostty_render_state_row_cells_get")}getRawRowValueResult(e,t,s){return this.exports.ghostty_row_get(e,t,s)}getRawRowValue(e,t,s){O(this.getRawRowValueResult(e,t,s),"ghostty_row_get")}getRawCellValueResult(e,t,s){return this.exports.ghostty_cell_get(e,t,s)}getRawCellValue(e,t,s){O(this.getRawCellValueResult(e,t,s),"ghostty_cell_get")}createKeyEncoder(){const e=this.allocOpaque();try{return O(this.exports.ghostty_key_encoder_new(0,e),"ghostty_key_encoder_new"),this.readPointer(e)}finally{this.freeOpaque(e)}}freeKeyEncoder(e){this.exports.ghostty_key_encoder_free(e)}createMouseEncoder(){const e=this.allocOpaque(),t=this.allocU8();try{O(this.exports.ghostty_mouse_encoder_new(0,e),"ghostty_mouse_encoder_new");const s=this.readPointer(e);return this.view().setUint8(t,1),this.exports.ghostty_mouse_encoder_setopt(s,Ls,t),s}finally{this.freeU8(t),this.freeOpaque(e)}}freeMouseEncoder(e){this.exports.ghostty_mouse_encoder_free(e)}resetMouseEncoder(e){this.exports.ghostty_mouse_encoder_reset(e)}encodeMouseEvent(e,t,s){const r=this.isTerminalModeEnabled(t,Ys),i=this.isTerminalModeEnabled(t,zs),o=this.isTerminalModeEnabled(t,Us),l=this.isTerminalModeEnabled(t,Gs);if(!r&&!i&&!o&&!l||s.action==="motion"&&!(r||i&&s.anyButtonPressed)||l&&s.action!=="press"||!r&&!i&&!l&&s.action==="motion")return null;const u=Ws(s.button);if(u===null)return null;const a=Math.max(1,Math.floor(s.x/Math.max(1,s.cellWidth))+1),g=Math.max(1,Math.floor(s.y/Math.max(1,s.cellHeight))+1),E=Math.round(s.x+1),A=Math.round(s.y+1);let B=s.action==="release"&&!this.isTerminalModeEnabled(t,Tt)&&!this.isTerminalModeEnabled(t,Et)?3:u;if(s.action==="motion"&&(B+=32),B+=js(s.mods),this.isTerminalModeEnabled(t,Et)){const T=s.action==="release"?"m":"M";return`\x1B[<${B};${E};${A}${T}`}if(this.isTerminalModeEnabled(t,Tt)){const T=s.action==="release"?"m":"M";return`\x1B[<${B};${a};${g}${T}`}if(this.isTerminalModeEnabled(t,Ks))return`\x1B[${B};${a};${g}M`;if(this.isTerminalModeEnabled(t,Vs)||o||i||r||l){const T=Ze(B),x=Ze(a),J=Ze(g);return!T||!x||!J?null:`\x1B[M${T}${x}${J}`}return null}encodeKeyEvent(e,t,s){if(s.keyCode<=0)return null;const r=this.allocOpaque();let i=0,o=null;try{return O(this.exports.ghostty_key_event_new(0,r),"ghostty_key_event_new"),i=this.readPointer(r),this.exports.ghostty_key_encoder_setopt_from_terminal(e,t),this.exports.ghostty_key_event_set_action(i,s.action==="release"?Ps:s.action==="repeat"?Hs:Bs),this.exports.ghostty_key_event_set_key(i,s.keyCode),this.exports.ghostty_key_event_set_mods(i,s.mods),this.exports.ghostty_key_event_set_consumed_mods(i,0),this.exports.ghostty_key_event_set_composing(i,s.composing?1:0),s.utf8&&(o=this.writeString(s.utf8),this.exports.ghostty_key_event_set_utf8(i,o.ptr,o.len)),typeof s.unshiftedCodepoint=="number"&&this.exports.ghostty_key_event_set_unshifted_codepoint(i,s.unshiftedCodepoint),this.encodeKeyHandle(e,i)}finally{o==null||o.free(),i!==0&&this.exports.ghostty_key_event_free(i),this.freeOpaque(r)}}encodeKeyHandle(e,t){const s=this.allocUsize();try{const r=this.exports.ghostty_key_encoder_encode(e,t,0,0,s);r!==xt&&r!==Ge&&O(r,"ghostty_key_encoder_encode(size)");const i=Math.max(0,this.readUsize(s));if(i===0)return null;const o=this.allocBytes(i),l=this.allocUsize();try{O(this.exports.ghostty_key_encoder_encode(e,t,o,i,l),"ghostty_key_encoder_encode");const u=this.readUsize(l);return u===0?null:this.readOwnedUtf8(o,u)}finally{this.freeBytes(o,i),this.freeUsize(l)}}finally{this.freeUsize(s)}}encodePaste(e,t){const s=this.writeString(t),r=this.allocUsize();try{const i=this.isTerminalModeEnabled(e,Fs),o=this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,0,0,r);o!==xt&&o!==Ge&&O(o,"ghostty_paste_encode(size)");const l=Math.max(0,this.readUsize(r));if(l===0)return"";const u=this.allocBytes(l),a=this.allocUsize();try{return O(this.exports.ghostty_paste_encode(s.ptr,s.len,i?1:0,u,l,a),"ghostty_paste_encode"),this.readOwnedUtf8(u,this.readUsize(a))}finally{this.freeBytes(u,l),this.freeUsize(a)}}finally{s.free(),this.freeUsize(r)}}}async function Js(n){if((n.startsWith("/")||n.startsWith("./")||n.startsWith("../")||/^[A-Za-z]:[\\/]/.test(n))&&typeof Bun<"u")return Bun.file(n).arrayBuffer();const t=await fetch(n);if(!t.ok)throw new Error(`failed to load ghostty wasm: ${t.status} ${t.statusText}`);return t.arrayBuffer()}async function Qs(){return Qe||(Qe=(async()=>{const n=await Js(Ts),t=(await WebAssembly.instantiate(n,{env:{log(){}}})).instance.exports,s=new Uint8Array(t.memory.buffer),r=t.ghostty_type_json();let i=r;for(;s[i]!==0;)i+=1;const o=JSON.parse(new TextDecoder().decode(s.subarray(r,i)));return new Xs(t,o)})()),Qe}const Rt=80,Ce=24,et=9,Be=17,Zs=48,Gt="ghostty-official",Ue=9,ze=1e3,Ye=1002,Ve=1003,tt=1007,He=1047,Le=1049,er=[Ue,ze,Ye,Ve],Ct=1,vt=3,Mt=2,tr=4,nr=5;class sr{constructor(e){this.content=e}translateToString(e){return e?this.content.replace(/\s+$/u,""):this.content}}class rr{constructor(){f(this,"active",{baseY:0,viewportY:0,length:Ce,getLine:e=>{const t=e-this.active.viewportY,s=this.visibleLines[t];return typeof s=="string"?new sr(s):null}});f(this,"visibleLines",Array.from({length:Ce},()=>""))}setViewport(e,t,s,r){this.active.viewportY=e,this.active.baseY=t,this.active.length=s,this.visibleLines=r}}function ir(n){return!(n.key.length===1&&!n.ctrlKey&&!n.altKey&&!n.metaKey)}function or(n,e){const t=n.slice(0,e).map(s=>s.text);for(;t.length<e;)t.push("");return t}function Fe(n){return Ft({shiftKey:!!n.shiftKey,ctrlKey:!!n.ctrlKey,altKey:!!n.altKey,metaKey:!!n.metaKey,getModifierState:()=>!1})}class lr{constructor(){f(this,"terminal",null)}activate(e){this.terminal=e instanceof $e?e:null}fit(){const e=this.proposeDimensions();!this.terminal||!e||this.terminal.resize(e.cols,e.rows)}proposeDimensions(){var e;return((e=this.terminal)==null?void 0:e.measureSizeFromElement())??null}dispose(){this.terminal=null}}class $e{constructor(e,t,s,r,i,o){f(this,"buffer",new rr);f(this,"_core",{_renderService:{dimensions:{css:{cell:{width:et,height:Be}}}}});f(this,"options");f(this,"element",null);f(this,"textarea",null);f(this,"cols",Rt);f(this,"rows",Ce);f(this,"bindings");f(this,"terminalHandle");f(this,"keyEncoderHandle");f(this,"mouseEncoderHandle");f(this,"renderState");f(this,"dataListeners",new Set);f(this,"selectionListeners",new Set);f(this,"lastNotifiedSelectionText",null);f(this,"addons",new Set);f(this,"screenElement",null);f(this,"renderer",null);f(this,"renderRaf",null);f(this,"disposed",!1);f(this,"disableStdin");f(this,"customKeyEventHandler",()=>!0);f(this,"imeIsComposing",!1);f(this,"lastCompositionCommit",null);f(this,"selectionState",Nt());f(this,"lineCache",new Map);f(this,"lastViewportOffset",0);f(this,"lastViewportRows",Ce);f(this,"lastRenderedRows",[]);f(this,"pointerDrag",{active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null});f(this,"autoScrollTimer",null);f(this,"domEventDisposers",[]);f(this,"copyShortcutSuppressed",!1);f(this,"scrollbarThumb",null);f(this,"scrollbarFadeTimer",null);f(this,"pressedMouseButtons",new Set);f(this,"wheelPixelDelta",0);f(this,"mouseDragActive",!1);this.bindings=e,this.terminalHandle=t,this.keyEncoderHandle=s,this.mouseEncoderHandle=r,this.renderState=i,this.options=o,this.disableStdin=!!o.disableStdin}static async create(e){const t=await Qs(),s=t.createTerminal(Rt,Ce,e.scrollback);let r=0,i=0,o=null;try{return t.setTerminalTheme(s,e.theme),r=t.createKeyEncoder(),i=t.createMouseEncoder(),o=wt(t),new $e(t,s,r,i,o,e)}catch(l){throw o&&Xe(o),r!==0&&t.freeKeyEncoder(r),i!==0&&t.freeMouseEncoder(i),t.freeTerminal(s),l}}open(e){if(this.disposed||this.element)return;const t=document.createElement("div");t.className="xterm",t.style.position="absolute",t.style.inset="0",t.style.overflow="hidden",t.style.width="100%",t.style.height="100%",t.style.backgroundColor=this.options.theme.background,t.style.color=this.options.theme.foreground,t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`,t.style.lineHeight="1.2";const s=document.createElement("div");s.className="xterm-viewport",s.style.width="100%",s.style.height="100%",s.style.overflow="hidden",s.style.position="relative";const r=document.createElement("div");r.className="xterm-screen",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.userSelect="none",r.style.webkitUserSelect="none",r.style.backgroundColor=this.options.theme.background;const i=document.createElement("div");i.className="xterm-helper-textarea",i.setAttribute("aria-label","Terminal Input"),i.setAttribute("role","textbox"),i.setAttribute("contenteditable","true"),i.setAttribute("autocorrect","off"),i.setAttribute("autocapitalize","off"),i.setAttribute("spellcheck","false"),i.style.position="absolute",i.style.opacity="1",i.style.pointerEvents="none",i.style.left="0",i.style.top="0",i.style.minWidth="1px",i.style.minHeight="1px",i.style.whiteSpace="pre",i.style.border="0",i.style.padding="0",i.style.margin="0",i.style.color=this.options.theme.foreground,i.style.backgroundColor="transparent",i.style.caretColor="transparent",i.style.overflow="visible",i.style.outline="none",i.style.boxShadow="none",i.style.fontFamily=this.options.fontFamily,i.style.fontSize=`${this.options.fontSize}px`,i.style.userSelect="text",i.style.webkitUserSelect="text";const o=document.createElement("div");o.className="xterm-scrollbar-track",o.style.position="absolute",o.style.top="0",o.style.right="0",o.style.width="8px",o.style.height="100%",o.style.backgroundColor="transparent",o.style.pointerEvents="none";const l=document.createElement("div");l.className="xterm-scrollbar-thumb",l.style.position="absolute",l.style.top="0",l.style.right="0",l.style.width="6px",l.style.marginRight="1px",l.style.borderRadius="3px",l.style.backgroundColor="rgba(128, 128, 128, 0.5)",l.style.pointerEvents="none",l.style.transition="opacity 0.15s ease",l.style.opacity="0",o.appendChild(l),s.appendChild(r),t.appendChild(s),t.appendChild(i),t.appendChild(o),e.appendChild(t),this.element=t,this.screenElement=r,this.textarea=i,this.scrollbarThumb=l,this.renderer=new Tn({screenElement:r,theme:this.options.theme,fontFamily:this.options.fontFamily,fontSize:this.options.fontSize}),this.syncInputState(),this.bindDomEvents(),this.updateCellDimensions();const u=this.measureSizeFromElement();u?this.resize(u.cols,u.rows):this.render()}loadAddon(e){e.activate(this),this.addons.add(e)}onData(e){return this.dataListeners.add(e),{dispose:()=>{this.dataListeners.delete(e)}}}attachCustomKeyEventHandler(e){this.customKeyEventHandler=e}onSelectionChange(e){return this.selectionListeners.add(e),{dispose:()=>{this.selectionListeners.delete(e)}}}hasSelection(){return _t(this.selectionState)}getSelection(){return this.getSelectionText()??""}clearSelection(){this.disposed||this.clearSelectionState()}startTouchSelection(e,t,s="word"){return this.disposed?!1:this.beginSelectionAt(e,t,s)}updateTouchSelection(e,t){this.disposed||this.updateSelectionDrag(e,t)}endTouchSelection(){this.disposed||!this.pointerDrag.active||(this.stopAutoScroll(),this.pointerDrag.active=!1,this.render())}write(e){if(this.disposed)return;const t=this.isAltScreenActive();this.bindings.writeVt(this.terminalHandle,e);const s=this.isAltScreenActive();t&&!s&&this.clearMouseTrackingModes(),this.scheduleRender()}clearMouseTrackingModes(){if(!this.disposed){for(const e of er)this.bindings.setTerminalMode(this.terminalHandle,e,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(He)||this.isModeEnabled(Le)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(e,t){if(this.disposed)return;const s=Math.max(2,Math.floor(e)),r=Math.max(2,Math.floor(t));this.cols=s,this.rows=r,this.clearSelectionState(!1),this.bindings.resizeTerminal(this.terminalHandle,s,r,this.cellDimensions()),this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.scheduleRender()}scrollLines(e){this.disposed||e===0||(this.bindings.scrollViewportDelta(this.terminalHandle,e),this.render())}scrollToTop(){this.disposed||(this.bindings.scrollViewportTop(this.terminalHandle),this.render())}scrollToBottom(){this.disposed||(this.bindings.scrollViewportBottom(this.terminalHandle),this.render())}exportModeSnapshot(){return{mouseX10:this.isModeEnabled(Ue),mouseNormal:this.isModeEnabled(ze),mouseButton:this.isModeEnabled(Ye),mouseAny:this.isModeEnabled(Ve),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(tt),altScreen1047:this.isModeEnabled(He),altScreen1049:this.isModeEnabled(Le)}}restoreModeSnapshot(e){this.bindings.setTerminalMode(this.terminalHandle,Ue,e.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,ze,e.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,Ye,e.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Ve,e.mouseAny),this.bindings.setTerminalMode(this.terminalHandle,1005,e.mouseUtf8),this.bindings.setTerminalMode(this.terminalHandle,1006,e.mouseSgr),this.bindings.setTerminalMode(this.terminalHandle,1016,e.mouseSgrPixels),this.bindings.setTerminalMode(this.terminalHandle,1015,e.mouseUrxvt),this.bindings.setTerminalMode(this.terminalHandle,tt,e.altScroll),this.bindings.setTerminalMode(this.terminalHandle,He,e.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,Le,e.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(e){if(this.disposed||e.deltaY===0)return!1;const t=this.gestureToLines(e);if(t===0)return!1;const s=this.getInputRoutingState();if(s.mouseReporting){const r=t<0?tr:nr;let i=!1;for(let o=0;o<Math.abs(t);o+=1)i=this.emitMouseInput({action:"press",button:r,clientX:e.clientX,clientY:e.clientY,mods:Fe(e),anyButtonPressed:this.pressedMouseButtons.size>0})||i;return i}return s.altScroll?this.emitAltScrollInput(t):(this.scrollLines(t),!0)}paste(e){if(this.disposed||this.disableStdin||!e)return;const t=this.bindings.encodePaste(this.terminalHandle,e);t&&this.emitData(t)}focus(){var e;(e=this.textarea)==null||e.focus({preventScroll:!0})}getRendererKind(){var e;return((e=this.renderer)==null?void 0:e.kind)??"unknown"}setTheme(e){var t;this.bindings.setTerminalTheme(this.terminalHandle,e),this.options.theme=e,this.element&&(this.element.style.backgroundColor=e.background,this.element.style.color=e.foreground),this.screenElement&&(this.screenElement.style.backgroundColor=e.background),(t=this.renderer)==null||t.setTheme(e),this.scheduleRender()}setDisableStdin(e){this.disableStdin=e,this.syncInputState()}measureSizeFromElement(){const e=this.element;if(!e)return null;const t=e.getBoundingClientRect(),{width:s,height:r}=this.cellDimensions();return t.width===0||t.height===0||s<=0||r<=0?null:{cols:Math.max(2,Math.floor(t.width/s)),rows:Math.max(2,Math.floor(t.height/r))}}dispose(){var e,t;if(!this.disposed){this.disposed=!0,this.renderRaf!==null&&(cancelAnimationFrame(this.renderRaf),this.renderRaf=null),this.stopAutoScroll(),this.updateSelectionTextProbe(null),this.clearDomEventListeners(),this.scrollbarFadeTimer&&(clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=null);for(const s of this.addons)s.dispose();this.addons.clear(),(e=this.renderer)==null||e.dispose(),this.renderer=null,(t=this.element)==null||t.remove(),this.element=null,this.screenElement=null,this.textarea=null,this.scrollbarThumb=null,Xe(this.renderState),this.bindings.freeMouseEncoder(this.mouseEncoderHandle),this.bindings.freeKeyEncoder(this.keyEncoderHandle),this.bindings.freeTerminal(this.terminalHandle)}}cellDimensions(){return this._core._renderService.dimensions.css.cell}syncInputState(){this.textarea&&(this.textarea.readOnly=this.disableStdin,this.textarea.tabIndex=this.disableStdin?-1:0,this.disableStdin&&document.activeElement===this.textarea&&this.textarea.blur())}bindDomEvents(){const e=this.element,t=this.textarea;if(!e||!t)return;e.addEventListener("click",()=>{this.disableStdin||this.focus()}),(this.screenElement??e).addEventListener("mousedown",i=>{if(i instanceof MouseEvent){if(this.disableStdin||this.focus(),this.getInputRoutingState().mouseReporting){const o=this.mouseButtonFromEvent(i);if(o===null)return;this.clearSelectionState(),this.pressedMouseButtons.add(o),this.mouseDragActive=!0,this.emitMouseInput({action:"press",button:o,clientX:i.clientX,clientY:i.clientY,mods:Fe(i),anyButtonPressed:!0}),i.preventDefault();return}i.button===0&&(this.mouseDragActive=!0,this.beginPointerSelection(i),i.preventDefault())}}),e.addEventListener("wheel",i=>{this.handleViewportGesture({source:"wheel",deltaY:i.deltaY,deltaMode:i.deltaMode,clientX:i.clientX,clientY:i.clientY,shiftKey:i.shiftKey,ctrlKey:i.ctrlKey,altKey:i.altKey,metaKey:i.metaKey})&&i.preventDefault()},{passive:!1});const r=typeof window<"u"&&typeof window.addEventListener=="function"?window:null;if(r){const i=l=>{if(this.mouseDragActive){if(this.getInputRoutingState().mouseReporting){this.emitMouseInput({action:"motion",button:this.mouseButtonFromButtons(l.buttons),clientX:l.clientX,clientY:l.clientY,mods:Fe(l),anyButtonPressed:this.pressedMouseButtons.size>0||l.buttons>0});return}this.updatePointerSelection(l)}},o=l=>{if(this.mouseDragActive){if(this.mouseDragActive=!1,this.getInputRoutingState().mouseReporting){const u=this.mouseButtonFromEvent(l);u!==null&&this.pressedMouseButtons.delete(u),this.emitMouseInput({action:"release",button:u,clientX:l.clientX,clientY:l.clientY,mods:Fe(l),anyButtonPressed:this.pressedMouseButtons.size>0});return}this.finishPointerSelection(l)}};r.addEventListener("mousemove",i),r.addEventListener("mouseup",o),this.domEventDisposers.push(()=>{r.removeEventListener("mousemove",i),r.removeEventListener("mouseup",o)})}t.addEventListener("keydown",i=>{const o=this.getSelectionText();if(o&&Ss(i)){i.preventDefault(),bs(o).catch(()=>{}),this.clearSelectionState(),this.copyShortcutSuppressed=!0,this.clearTextarea();return}if(!this.customKeyEventHandler(i)||this.disableStdin||this.imeIsComposing||i.keyCode===229||_s(i)||!ir(i))return;const l=this.encodeKeyboardEvent(i,i.repeat?"repeat":"press");l&&(i.preventDefault(),this.emitData(l),this.clearTextarea())}),t.addEventListener("keyup",i=>{if(this.copyShortcutSuppressed){const l=i.key.toLowerCase();if(l==="c"){i.preventDefault();return}if(l==="control"||l==="meta"||l==="os"){this.copyShortcutSuppressed=!1,i.preventDefault();return}}if(this.disableStdin||this.imeIsComposing)return;const o=this.encodeKeyboardEvent(i,"release");o&&(i.preventDefault(),this.emitData(o),this.clearTextarea())}),t.addEventListener("compositionstart",()=>{this.imeIsComposing=!0,this.lastCompositionCommit=null,this.syncTextareaPositionToCursor()}),t.addEventListener("compositionupdate",()=>{this.syncTextareaPositionToCursor()}),t.addEventListener("compositionend",i=>{this.imeIsComposing=!1;const o=i.data??"";o&&(this.lastCompositionCommit={data:o,at:Date.now()},this.emitData(o),this.clearTextarea())}),t.addEventListener("beforeinput",i=>{if(this.disableStdin||i.inputType==="insertFromPaste")return;const o=i.data??"";if(!o||i.isComposing||this.imeIsComposing)return;const l=this.lastCompositionCommit;if(l&&l.data===o&&Date.now()-l.at<40){this.lastCompositionCommit=null,i.preventDefault(),this.clearTextarea();return}this.lastCompositionCommit=null,i.preventDefault(),this.emitData(o),this.clearTextarea()}),t.addEventListener("paste",i=>{var l;if(this.disableStdin)return;const o=((l=i.clipboardData)==null?void 0:l.getData("text/plain"))??"";o&&(i.preventDefault(),this.paste(o),this.clearTextarea())}),t.addEventListener("copy",i=>{const o=this.getSelectionText();o&&xs(i,o)}),t.addEventListener("input",()=>{if(this.disableStdin||this.imeIsComposing)return;const i=t.textContent??"";if(!i){this.clearTextarea();return}const o=this.lastCompositionCommit;if(o&&o.data===i&&Date.now()-o.at<40){this.lastCompositionCommit=null,this.clearTextarea();return}this.lastCompositionCommit=null,this.emitData(i),this.clearTextarea()})}encodeKeyboardEvent(e,t){const s=ft(e.code);if(s===0)return null;const r=e.key.length===1&&!e.ctrlKey&&!e.metaKey?e.key:null;return this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:t,keyCode:s,mods:Ft(e),composing:e.isComposing,utf8:r,unshiftedCodepoint:Cn(e.code)})}getInputRoutingState(){const e=this.isModeEnabled(Ue)||this.isModeEnabled(ze)||this.isModeEnabled(Ye)||this.isModeEnabled(Ve),t=this.isModeEnabled(He)||this.isModeEnabled(Le);return{mouseReporting:e,altScroll:!e&&t&&this.isModeEnabled(tt)}}gestureToLines(e){const t=this.cellDimensions().height||Be;if(e.source==="wheel"){if(e.deltaMode===1)return this.wheelPixelDelta=0,e.deltaY>0?Math.ceil(e.deltaY):Math.floor(e.deltaY);if(e.deltaMode===2){this.wheelPixelDelta=0;const r=Math.max(1,this.rows),i=e.deltaY*r;return i>0?Math.ceil(i):Math.floor(i)}this.wheelPixelDelta+=e.deltaY;const s=this.wheelPixelDelta>0?Math.floor(this.wheelPixelDelta/t):Math.ceil(this.wheelPixelDelta/t);return s!==0&&(this.wheelPixelDelta-=s*t),s}return e.deltaY>0?Math.ceil(e.deltaY/t):Math.floor(e.deltaY/t)}isModeEnabled(e){return this.bindings.isTerminalModeEnabled(this.terminalHandle,e)}mouseButtonFromEvent(e){switch(e.button){case 0:return Ct;case 1:return vt;case 2:return Mt;default:return null}}mouseButtonFromButtons(e){return e&1?Ct:e&4?vt:e&2?Mt:null}pointerPositionFromClient(e,t){var o;const s=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!s)return null;const r=Math.max(1,s.width),i=Math.max(1,s.height);return{x:Math.max(0,Math.min(r-1,e-s.left)),y:Math.max(0,Math.min(i-1,t-s.top))}}emitMouseInput(e){var o;if(this.disableStdin)return!1;const t=this.pointerPositionFromClient(e.clientX,e.clientY);if(!t)return!1;const s=this.cellDimensions(),r=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!r)return!1;const i=this.bindings.encodeMouseEvent(this.mouseEncoderHandle,this.terminalHandle,{action:e.action,button:e.button,mods:e.mods,x:t.x,y:t.y,anyButtonPressed:e.anyButtonPressed,screenWidth:Math.max(1,Math.round(r.width)),screenHeight:Math.max(1,Math.round(r.height)),cellWidth:Math.max(1,Math.round(s.width||et)),cellHeight:Math.max(1,Math.round(s.height||Be))});return i?(this.emitData(i),!0):!1}emitAltScrollInput(e){const t=ft(e<0?"ArrowUp":"ArrowDown");if(t===0)return!1;let s=!1;for(let r=0;r<Math.abs(e);r+=1){const i=this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:"press",keyCode:t,mods:0,composing:!1,utf8:null,unshiftedCodepoint:null});i&&(this.emitData(i),s=!0)}return s}emitData(e){for(const t of this.dataListeners)t(e)}clearTextarea(){this.textarea&&(this.textarea.textContent="")}syncTextareaPositionToCursor(){const e=this.textarea,t=this.screenElement;if(!e||!t)return;const{width:s,height:r}=this.cellDimensions();if(s<=0||r<=0)return;const i=wt(this.bindings);let o=0,l=0;try{yt(i,this.terminalHandle);const g=st(i);g.cursor.x!==null&&g.cursor.y!==null&&(o=g.cursor.x,l=g.cursor.y)}finally{Xe(i)}const u=o*s,a=l*r;e.style.left=`${u}px`,e.style.top=`${a}px`,e.style.width=`${Math.max(1,s)}px`,e.style.height=`${Math.max(1,r)}px`,e.style.lineHeight=`${r}px`,e.style.fontFamily=this.options.fontFamily,e.style.fontSize=`${this.options.fontSize}px`}scheduleRender(){this.renderRaf===null&&(this.renderRaf=requestAnimationFrame(()=>{this.renderRaf=null,this.render()}))}render(){if(this.disposed||!this.screenElement||!this.renderer)return;const e=this.bindings.readScrollbar(this.terminalHandle),t=Math.max(1,e.len||this.rows);yt(this.renderState,this.terminalHandle);const s=st(this.renderState),r=Array.from(ls(this.renderState));this.cols=Math.max(2,s.cols),this.rows=Math.max(2,s.rows||t),this.lastViewportOffset=e.offset,this.lastViewportRows=this.rows,this.lastRenderedRows=r;for(const a of r)this.lineCache.set(e.offset+a.y,gt(a.cells,a.wrap));const i=ys(this.selectionState,this.lastViewportOffset,this.lastViewportRows,a=>this.getLineModel(a)),o=this.getSelectionText();this.renderer.render({meta:s,rows:r,cellDimensions:this.cellDimensions(),selectionRects:i,selectionColor:this.options.theme.selectionBackground});const l=or(r,this.rows),u=Math.max(0,e.total-e.len);this.buffer.setViewport(e.offset,u,e.total,l),this.updateSelectionTextProbe(o),this.updateScrollbar(e)}updateScrollbar(e){var u;const t=this.scrollbarThumb;if(!t)return;const s=((u=this.screenElement)==null?void 0:u.clientHeight)??0;if(s===0||e.total<=e.len){t.style.opacity="0";return}const r=e.len/e.total,i=Math.max(20,r*s),l=e.offset/Math.max(1,e.total-e.len)*(s-i);t.style.height=`${i}px`,t.style.transform=`translateY(${l}px)`,t.style.opacity="1",this.scrollbarFadeTimer&&clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=setTimeout(()=>{t.style.opacity="0"},800)}updateCellDimensions(){if(!this.element)return;const e=document.createElement("span");e.textContent="WWWWWWWWWW",e.style.position="absolute",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.fontFamily=this.options.fontFamily,e.style.fontSize=`${this.options.fontSize}px`,e.style.lineHeight="1.2",this.element.appendChild(e);const t=e.getBoundingClientRect();e.remove(),this._core._renderService.dimensions.css.cell.width=t.width>0?t.width/10:et,this._core._renderService.dimensions.css.cell.height=t.height>0?t.height:Be}clearSelectionState(e=!0){this.selectionState=fs(),this.pressedMouseButtons.clear(),this.wheelPixelDelta=0,this.pointerDrag={active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null},this.copyShortcutSuppressed=!1,this.stopAutoScroll(),this.updateSelectionTextProbe(null),e&&this.screenElement&&this.renderer&&this.render()}beginSelectionAt(e,t,s){const r=this.hitTest(e,t);return r?(this.pointerDrag={active:!0,moved:!1,mode:s,lastClientX:e,lastClientY:t},this.selectionState=ms(this.selectionState,{...r,mode:s},i=>this.getLineModel(i)),this.updateAutoScroll(),this.render(),!0):!1}updateSelectionDrag(e,t){if(!this.pointerDrag.active)return;const s=this.hitTest(e,t);this.pointerDrag.lastClientX=e,this.pointerDrag.lastClientY=t,s&&(this.pointerDrag.moved=!0,this.selectionState=bt(this.selectionState,s,r=>this.getLineModel(r)),this.render()),this.updateAutoScroll()}beginPointerSelection(e){this.beginSelectionAt(e.clientX,e.clientY,this.selectionModeFromClickDetail(e.detail))}updatePointerSelection(e){this.updateSelectionDrag(e.clientX,e.clientY)}finishPointerSelection(e){var s,r,i,o;if(!this.pointerDrag.active||e.button!==0)return;this.pointerDrag.lastClientX=e.clientX,this.pointerDrag.lastClientY=e.clientY,this.stopAutoScroll();const t=this.pointerDrag.mode==="character"&&!this.pointerDrag.moved&&((s=this.selectionState.anchor)==null?void 0:s.line)===((r=this.selectionState.focus)==null?void 0:r.line)&&((i=this.selectionState.anchor)==null?void 0:i.col)===((o=this.selectionState.focus)==null?void 0:o.col);if(this.pointerDrag.active=!1,t){this.clearSelectionState();return}this.render()}selectionModeFromClickDetail(e){return e>=3?"line":e===2?"word":"character"}hitTest(e,t){var A;const s=(A=this.screenElement)==null?void 0:A.getBoundingClientRect();if(!s)return null;const{width:r,height:i}=this.cellDimensions();if(r<=0||i<=0)return null;const o=e-s.left,l=t-s.top,u=Math.max(this.cols-1,0),a=Math.max(this.lastViewportRows-1,0),g=Math.max(0,Math.min(u,Math.floor(o/r))),E=Math.max(0,Math.min(a,Math.floor(l/i)));return{line:this.lastViewportOffset+E,col:g}}getLineModel(e){const t=this.lineCache.get(e);if(t)return t;const s=e-this.lastViewportOffset,r=this.lastRenderedRows[s];return r?gt(r.cells,r.wrap):as}getSelectionText(){return _t(this.selectionState)?ws(this.selectionState,e=>this.getLineModel(e)):null}updateSelectionTextProbe(e){if(globalThis.__tmexE2eTerminalSelectionText=e,e!==this.lastNotifiedSelectionText){this.lastNotifiedSelectionText=e;for(const t of this.selectionListeners)t(e)}}updateAutoScroll(){var s;if(!this.pointerDrag.active||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const e=(s=this.screenElement)==null?void 0:s.getBoundingClientRect();if(!e){this.stopAutoScroll();return}if(!(this.pointerDrag.lastClientY<e.top||this.pointerDrag.lastClientY>e.bottom)){this.stopAutoScroll();return}this.autoScrollTimer===null&&(this.autoScrollTimer=setInterval(()=>{this.stepAutoScroll()},Zs))}stepAutoScroll(){var r;if(!this.pointerDrag.active||this.pointerDrag.lastClientX===null||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const e=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!e){this.stopAutoScroll();return}let t=0;if(this.pointerDrag.lastClientY<e.top?t=-1:this.pointerDrag.lastClientY>e.bottom&&(t=1),t===0){this.stopAutoScroll();return}this.bindings.scrollViewportDelta(this.terminalHandle,t),this.render();const s=this.hitTest(this.pointerDrag.lastClientX,this.pointerDrag.lastClientY);s&&(this.selectionState=bt(this.selectionState,s,i=>this.getLineModel(i)),this.pointerDrag.moved=!0,this.render())}stopAutoScroll(){this.autoScrollTimer!==null&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}clearDomEventListeners(){for(;this.domEventDisposers.length>0;){const e=this.domEventDisposers.pop();e==null||e()}}}async function ar(n){return $e.create(n)}function cr({visible:n,canPaste:e,onCopy:t,onPaste:s,onDismiss:r}){const{t:i}=Ke();if(!n)return null;const o=l=>{l.preventDefault()};return h.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:[h.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:o,onClick:t,"data-testid":"terminal-selection-copy",children:[h.jsx(pn,{className:"h-4 w-4"}),i("terminal.copy")]}),e&&h.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:o,onClick:s,"data-testid":"terminal-selection-paste",children:[h.jsx(fn,{className:"h-4 w-4"}),i("terminal.paste")]}),h.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:o,onClick:r,"aria-label":i("terminal.clearSelection"),"data-testid":"terminal-selection-dismiss",children:h.jsx(qt,{className:"h-4 w-4"})})]})}function Ut(n){if(!n)return n;const e=n.replace(/\r\n/g,`
|
|
33
|
+
`);return(e.endsWith(`
|
|
34
|
+
`)?e.slice(0,-1):e).replace(/\n/g,`\r
|
|
35
|
+
`)}const dr="\x1B[?1049h\x1B[H\x1B[2J";function ur(n){return dr+Ut(n)}function Dt(n,e){let t=e,s=0;for(const l of n)l===10&&!t&&(s+=1),t=l===13;const r=t;if(s===0)return{normalized:n,endedWithCR:r};const i=new Uint8Array(n.length+s);let o=0;t=e;for(const l of n)l===10&&!t&&(i[o]=13,o+=1),i[o]=l,o+=1,t=l===13;return{normalized:i,endedWithCR:r}}const zt={background:"#e1e1e1",foreground:"#616161",cursor:"#616161",selectionBackground:"rgba(97, 97, 97, 0.25)",black:"#171717",red:"#bf2172",green:"#009799",yellow:"#9a7200",blue:"#007299",magenta:"#9b1d72",cyan:"#007173",white:"#d9d9d9",brightBlack:"#4e4e4e",brightRed:"#e12672",brightGreen:"#00bddf",brightYellow:"#ffdd00",brightBlue:"#7299bc",brightMagenta:"#e17899",brightCyan:"#6fbcbd",brightWhite:"#f1f1f1"},Yt={background:"#262626",foreground:"#d0d0d0",cursor:"#c5c5c5",selectionBackground:"rgba(197, 197, 197, 0.25)",black:"#000000",red:"#ba3c3c",green:"#5d876d",yellow:"#d5a54e",blue:"#887c8d",magenta:"#cd6d6d",cyan:"#618484",white:"#cfcdc3",brightBlack:"#000000",brightRed:"#ea7171",brightGreen:"#7aab7a",brightYellow:"#d1d194",brightBlue:"#afa3b5",brightMagenta:"#e29f9f",brightCyan:"#a0aea3",brightWhite:"#d0d0d0"},hr='"JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", "Source Han Mono SC", "Sarasa Mono SC", "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", monospace',fr=1.3,mr=36,pr=500,wr=12;function yr(n,e){const t=d.useRef(!1);return d.useEffect(()=>{const s=n.current;if(!s||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;t.current=!0;let i=0,o=null,l=!1,u=0,a=0,g=0,E=null,A=!1;const B=()=>{E!==null&&(clearTimeout(E),E=null)},T=b=>b?!!(b.closest(".scrollbar")||b.closest(".slider")||b.closest(".xterm-scroll-area")):!1,x=(b,C,N)=>{const L=N instanceof Element?N:null;if(T(L))return!0;const V=document.elementFromPoint(b,C);if(T(V))return!0;const S=s.querySelector(".xterm");if(!(S instanceof HTMLElement))return!1;const R=S.getBoundingClientRect(),P=b>=R.left&&b<=R.right,F=C>=R.top&&C<=R.bottom;return!P||!F?!1:b>=R.right-mr},J=()=>[s.querySelector(".xterm-viewport"),s.querySelector(".xterm-scrollable-element")].filter(C=>C instanceof HTMLElement),y=b=>{if(o===null)return null;for(let C=0;C<b.length;C+=1){const N=b.item(C);if(N&&N.identifier===o)return N}return null},U=b=>{if(B(),b.touches.length!==1)return;const C=b.touches.item(0);C&&(o=C.identifier,i=C.clientY,u=0,l=x(C.clientX,C.clientY,b.target),a=C.clientX,g=C.clientY,A=!1,l||(E=setTimeout(()=>{var L;E=null;const N=(e==null?void 0:e())??null;(L=N==null?void 0:N.startTouchSelection)!=null&&L.call(N,a,g,"word")&&(A=!0)},pr)))},k=b=>{var P,F,I,j,Q,te,se,D,ie;const C=y(b.touches)??b.touches.item(0);if(!C)return;if(A){const G=(e==null?void 0:e())??null;(P=G==null?void 0:G.updateTouchSelection)==null||P.call(G,C.clientX,C.clientY),b.cancelable&&b.preventDefault();return}if(E!==null&&Math.hypot(C.clientX-a,C.clientY-g)>wr&&B(),l||(l=x(C.clientX,C.clientY,b.target),l&&(u=0)),l)return;const N=C.clientY,L=i-N;if(i=N,L===0)return;let V=!1,S=!1;const R=(e==null?void 0:e())??null;if(R){const G=R==null?void 0:R._core,z=((Q=(j=(I=(F=G==null?void 0:G._renderService)==null?void 0:F.dimensions)==null?void 0:I.css)==null?void 0:j.cell)==null?void 0:Q.height)??18;u+=L*fr;const H=u>0?Math.floor(u/z):Math.ceil(u/z);if(typeof R.handleViewportGesture=="function")H!==0&&(V=R.handleViewportGesture({source:"touch",deltaY:H*z,clientX:C.clientX,clientY:C.clientY}),u-=H*z);else if(H!==0){const $=((se=(te=R.buffer)==null?void 0:te.active)==null?void 0:se.viewportY)??0;R.scrollLines(H);const w=((ie=(D=R.buffer)==null?void 0:D.active)==null?void 0:ie.viewportY)??0;V=$!==w,S=H<0&&$<=0&&w<=0,u-=H*z}}else{const G=J();if(G.length===0)return;for(const z of G){const H=z.scrollTop;z.scrollTop+=L;const $=z.scrollTop;Math.abs($-H)>0&&(V=!0),L<0&&$<=0&&(S=!0)}if(!V){const z=s.querySelector(".xterm");if(z instanceof HTMLElement){const H=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:L}),$=z.dispatchEvent(H);V=H.defaultPrevented||!$}}}b.cancelable&&(V||S)&&b.preventDefault()},K=b=>{var N;if(B(),!(o===null||!y(b.changedTouches))&&(o=null,u=0,l=!1,A)){A=!1;const L=(e==null?void 0:e())??null;(N=L==null?void 0:L.endTouchSelection)==null||N.call(L)}},Y=b=>{A&&b.preventDefault()};return s.addEventListener("touchstart",U,{passive:!0}),s.addEventListener("touchmove",k,{passive:!1}),s.addEventListener("touchend",K,{passive:!0}),s.addEventListener("touchcancel",K,{passive:!0}),s.addEventListener("contextmenu",Y),()=>{t.current=!1,B(),s.removeEventListener("touchstart",U),s.removeEventListener("touchmove",k),s.removeEventListener("touchend",K),s.removeEventListener("touchcancel",K),s.removeEventListener("contextmenu",Y)}},[n,e]),t}function gr({now:n,remoteSize:e,pendingLocalSize:t,ttlMs:s=2e3}){return!t||n-t.at>s?!0:t.cols===e.cols&&t.rows===e.rows}function Sr({currentSize:n,containerSize:e,force:t=!1}){return t?!0:n.cols!==e.cols||n.rows!==e.rows}function _r({deviceId:n,paneId:e,deviceConnected:t,isSelectionInvalid:s,onResize:r,onSync:i,getContainerRect:o}){const l=d.useRef(null),u=d.useRef(null),a=d.useRef(null),g=d.useRef(null),E=d.useRef(0),A=d.useRef([]),B=d.useRef(null),T=d.useRef(null),x=d.useRef(o),J=d.useRef(!1),y=d.useRef(r),U=d.useRef(i);d.useEffect(()=>{y.current=r},[r]),d.useEffect(()=>{U.current=i},[i]),d.useEffect(()=>{x.current=o},[o]);const k=d.useCallback(()=>{var te,se,D,ie,G,z,H,$,w,_;const S=T.current,R=B.current;if(!S||!R||!S.element)return null;let P;try{const v=R.proposeDimensions();if(!v)throw new Error("fitAddon.proposeDimensions() returned null");P=Math.max(2,v.cols)}catch{const v=S._core,W=((ie=(D=(se=(te=v==null?void 0:v._renderService)==null?void 0:te.dimensions)==null?void 0:se.css)==null?void 0:D.cell)==null?void 0:ie.width)??9,q=(G=x.current)==null?void 0:G.call(x);if(!q||q.width===0)return null;P=Math.max(2,Math.floor(q.width/W))}const F=(z=x.current)==null?void 0:z.call(x);if(!F||F.height===0)return null;const I=S._core,j=((_=(w=($=(H=I==null?void 0:I._renderService)==null?void 0:H.dimensions)==null?void 0:$.css)==null?void 0:w.cell)==null?void 0:_.height)??17,Q=Math.max(2,Math.floor(F.height/j));return{cols:P,rows:Q}},[]),K=d.useCallback((S,R)=>{const P=T.current;P&&(P.cols===S&&P.rows===R||P.resize(S,R))},[]),Y=d.useCallback((S,R=!1)=>{if(!n||!e||!t||s&&S!=="sync"||!R&&Date.now()<E.current||!T.current)return!1;const F=k();if(!F)return!1;const{cols:I,rows:j}=F,Q=a.current;return!R&&Q&&Q.cols===I&&Q.rows===j?(K(I,j),!0):(K(I,j),S==="sync"?U.current(I,j):y.current(I,j),a.current={cols:I,rows:j},g.current={cols:I,rows:j,at:Date.now()},!0)},[K,t,n,s,k,e]),b=d.useCallback((S="resize",R={})=>{const{immediate:P=!1,force:F=!1}=R;u.current!==null&&(window.clearTimeout(u.current),u.current=null),l.current!==null&&(cancelAnimationFrame(l.current),l.current=null);const I=()=>{l.current=requestAnimationFrame(()=>{l.current=null,Y(S,F)})};if(P){I();return}u.current=window.setTimeout(()=>{u.current=null,I()},150)},[Y]),C=d.useCallback(()=>{for(const S of A.current)window.clearTimeout(S);A.current=[]},[]),N=d.useCallback(()=>{var R;C(),b("sync",{immediate:!0,force:!0});const S=window.setTimeout(()=>{b("sync",{immediate:!0,force:!0})},60);A.current.push(S),typeof document<"u"&&"fonts"in document&&((R=document.fonts)!=null&&R.ready)&&document.fonts.ready.then(()=>{b("sync",{immediate:!0,force:!0})}).catch(()=>{})},[C,b]);d.useEffect(()=>{let S=null;const R=()=>{S!==null&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{S=null,b("resize")})};return window.addEventListener("resize",R),()=>{window.removeEventListener("resize",R),S!==null&&cancelAnimationFrame(S)}},[b]),d.useEffect(()=>{const S=()=>{var te;const I=T.current,j=k();if(!I||!j)return;if(!Sr({currentSize:{cols:Math.max(2,I.cols),rows:Math.max(2,I.rows)},containerSize:j})){(te=I.refresh)==null||te.call(I);return}b("sync",{force:!0})},R=()=>{if(document.visibilityState!=="visible"){J.current=!0;return}J.current&&(J.current=!1,S())},P=()=>{J.current=!0},F=()=>{J.current&&(J.current=!1,S())};return document.addEventListener("visibilitychange",R),window.addEventListener("blur",P),window.addEventListener("focus",F),()=>{document.removeEventListener("visibilitychange",R),window.removeEventListener("blur",P),window.removeEventListener("focus",F)}},[k,b]),d.useEffect(()=>()=>{C(),u.current!==null&&window.clearTimeout(u.current),l.current!==null&&cancelAnimationFrame(l.current)},[C]);const L=d.useCallback(S=>{B.current=S},[]),V=d.useCallback(S=>{T.current=S},[]);return{scheduleResize:b,runPostSelectResize:N,clearPostSelectResizeTimers:C,setFitAddon:L,setTerminal:V,lastReportedSize:a,pendingLocalSize:g,suppressLocalResizeUntil:E}}const br={fontFamily:hr,fontSize:13,scrollback:1e4},rt="tmex:terminal-mode-cache";function xr(n,e){try{const t=sessionStorage.getItem(rt);return t?JSON.parse(t)[`${n}:${e}`]??null:null}catch{return null}}function Tr(n,e,t){try{const s=sessionStorage.getItem(rt),r=s?JSON.parse(s):{},i=`${n}:${e}`;t?r[i]=t:delete r[i],sessionStorage.setItem(rt,JSON.stringify(r))}catch{}}function Er(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function Rr(n,e){if(!e)return n?{...n,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const t=Er();if(!n)return t;const s=n.mouseNormal||n.mouseButton||n.mouseAny;return{...n,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:s?n.mouseNormal:t.mouseNormal}}function Cr(n){var t;const e=globalThis;e.__tmexE2eXterm=n,e.__tmexE2eTerminal=n,e.__tmexE2eTerminalEngine=Gt,e.__tmexE2eTerminalRenderer=((t=n.getRendererKind)==null?void 0:t.call(n))??null}function vr(n){if(!n)return;const e=globalThis;e.__tmexE2eTerminal!==n&&e.__tmexE2eXterm!==n||(e.__tmexE2eXterm=null,e.__tmexE2eTerminal=null,e.__tmexE2eTerminalEngine=null,e.__tmexE2eTerminalRenderer=null,e.__tmexE2eTerminalSelectionText=null)}const Vt=d.forwardRef(({deviceId:n,paneId:e,theme:t,inputMode:s,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l},u)=>{const[a,g]=d.useState(null),[E,A]=d.useState(!1),B=Z(w=>w.sendInput),{t:T}=Ke(),x=d.useMemo(()=>{switch(t){case"light":return zt;default:return Yt}},[t]),J=d.useRef(null),y=d.useRef(null),U=d.useRef(null),k=d.useRef(n),K=d.useRef(e),Y=d.useRef(n),b=d.useRef(e),C=d.useRef(r&&!i),N=d.useRef(s),L=d.useRef(x),V=d.useRef(!1),S=d.useRef(!1),R=d.useRef(null),P=d.useRef(!1),F=d.useCallback((w,_,v)=>{!(w!=null&&w.exportModeSnapshot)||!_||!v||Tr(_,v,w.exportModeSnapshot())},[]),I=d.useCallback(()=>a,[a]);yr(J,I),d.useEffect(()=>{k.current=n,K.current=e,S.current=!1},[n,e]),d.useEffect(()=>{C.current=r&&!i},[r,i]),d.useEffect(()=>{N.current=s},[s]),d.useEffect(()=>{L.current=x},[x]);const j=d.useCallback(w=>{if(!w||s!=="direct"||!C.current)return;const _=k.current,v=K.current;!_||!v||B(_,v,w,!1)},[s,B]),{pendingLocalSize:Q,scheduleResize:te,runPostSelectResize:se,setFitAddon:D,setTerminal:ie}=_r({deviceId:n,paneId:e,deviceConnected:r,isSelectionInvalid:i,onResize:o,onSync:l,getContainerRect:()=>{const w=J.current;if(!w)return null;const _=w.getBoundingClientRect();return{width:_.width,height:_.height}}});d.useEffect(()=>{let w=!1,_=null;return ar({...br,theme:L.current,disableStdin:N.current==="editor"}).then(v=>{if(w){v.dispose();return}_=v,y.current&&v.open(y.current),Cr(v),g(v)}),()=>{w=!0,g(null),vr(_),_==null||_.dispose()}},[]),d.useEffect(()=>{!a||!("setTheme"in a)||a.setTheme(x)},[a,x]),d.useEffect(()=>{!a||!("setDisableStdin"in a)||a.setDisableStdin(s==="editor")},[a,s]),d.useEffect(()=>{!a||s!=="direct"||window.innerWidth<768||"ontouchstart"in window||a.focus()},[a,s]);const G=d.useMemo(()=>a?{onResetTerminal:w=>{k.current===w&&(F(a,Y.current,b.current),P.current=!0,a.reset(),V.current=!1,se())},onApplyHistory:(w,_,v)=>{var X;if(k.current!==w)return;const W=Rr(xr(k.current,K.current),v);W&&((X=a.restoreModeSnapshot)==null||X.call(a,W));const q=v?ur(_):Ut(_);S.current=!0,a.write(q),P.current=!1,Y.current=k.current,b.current=K.current,F(a,k.current,K.current)},onFlushBuffer:(w,_)=>{if(k.current===w){for(const v of _){const W=Dt(v,V.current);V.current=W.endedWithCR,a.write(W.normalized)}S.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),S.current=!1),Y.current=k.current,b.current=K.current,F(a,k.current,K.current)}},onOutput:(w,_,v)=>{if(k.current!==w||K.current!==_)return;const W=Dt(v,V.current);V.current=W.endedWithCR,a.write(W.normalized),S.current&&(a.buffer.active.baseY<=1&&a.scrollToTop(),S.current=!1),Y.current=k.current,b.current=K.current,F(a,k.current,K.current)}}:{},[a,F,se]);d.useEffect(()=>{a?R.current!==a&&(V.current=!1,Y.current=k.current,b.current=K.current,R.current=a):R.current=null},[a]),d.useEffect(()=>{if(!(!a||!n||!e))return()=>{if(P.current){P.current=!1;return}F(a,Y.current,b.current)}},[n,a,e,F]),d.useEffect(()=>{ut(G)},[G]),d.useEffect(()=>()=>{ut({})},[]),d.useEffect(()=>{if(!a){U.current=null,D(null),ie(null);return}const w=new lr;return a.loadAddon(w),U.current=w,D(w),ie(a),se(),()=>{try{w.dispose()}finally{U.current=null,D(null),ie(null)}}},[a,se,D,ie]),d.useEffect(()=>{const w=J.current;if(!w)return;let _=null;const v=new ResizeObserver(()=>{_!==null&&cancelAnimationFrame(_),_=requestAnimationFrame(()=>{_=null,te("resize")})});return v.observe(w),()=>{v.disconnect(),_!==null&&cancelAnimationFrame(_)}},[te]),d.useEffect(()=>{if(!a||!n||!e)return;const w=a.onData(_=>{!r||i||j(_)});return a.attachCustomKeyEventHandler(_=>!r||i||_.type!=="keydown"||s!=="direct"?!0:_.shiftKey&&_.key==="Enter"?(_.preventDefault(),j("\x1B[13;2u"),!1):!0),()=>{w.dispose(),a.attachCustomKeyEventHandler(()=>!0)}},[a,r,i,s,j,n,e]),d.useEffect(()=>{if(!(a!=null&&a.onSelectionChange)){A(!1);return}const w=a.onSelectionChange(_=>{A(!!_)});return()=>{w.dispose(),A(!1)}},[a]);const z=d.useCallback(()=>{var _;if(!a)return;const w=((_=a.getSelection)==null?void 0:_.call(a))??"";w&&Ht(w).then(()=>{_e.success(T("terminal.copied"))}).catch(()=>{_e.error(T("terminal.copyFailed"))}).finally(()=>{var v;(v=a.clearSelection)==null||v.call(a),a.focus()})},[a,T]),H=d.useCallback(()=>{var _;if(!a)return;((_=navigator.clipboard)!=null&&_.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(v=>{var W;v&&a.paste(v),(W=a.clearSelection)==null||W.call(a),a.focus()}).catch(()=>{_e.error(T("terminal.pasteFailed"))})},[a,T]),$=d.useCallback(()=>{var w;(w=a==null?void 0:a.clearSelection)==null||w.call(a),a==null||a.focus()},[a]);return d.useImperativeHandle(u,()=>({write:w=>a==null?void 0:a.write(w),reset:()=>{a==null||a.reset(),V.current=!1},scrollToBottom:()=>a==null?void 0:a.scrollToBottom(),resize:(w,_)=>a==null?void 0:a.resize(w,_),getTerminal:()=>a??null,getSize:()=>a?{cols:Math.max(2,a.cols),rows:Math.max(2,a.rows)}:null,runPostSelectResize:()=>se(),scheduleResize:(w,_)=>te(w,_),calculateSizeFromContainer:()=>{var De,Ae,oe,we,de,le,ee,ye,ue,ge,Te,Oe,ke,Ie,Ne,Ee;const w=J.current,_=a,v=U.current;if(!w||!_)return null;const W=w.getBoundingClientRect();if(W.width===0||W.height===0)return null;const q=_._core;let X;if(v)try{const c=v.proposeDimensions();if(c)X=Math.max(2,c.cols);else{const m=((we=(oe=(Ae=(De=q==null?void 0:q._renderService)==null?void 0:De.dimensions)==null?void 0:Ae.css)==null?void 0:oe.cell)==null?void 0:we.width)??9;X=Math.max(2,Math.floor(W.width/m))}}catch{const c=((ye=(ee=(le=(de=q==null?void 0:q._renderService)==null?void 0:de.dimensions)==null?void 0:le.css)==null?void 0:ee.cell)==null?void 0:ye.width)??9;X=Math.max(2,Math.floor(W.width/c))}else{const c=((Oe=(Te=(ge=(ue=q==null?void 0:q._renderService)==null?void 0:ue.dimensions)==null?void 0:ge.css)==null?void 0:Te.cell)==null?void 0:Oe.width)??9;X=Math.max(2,Math.floor(W.width/c))}const Me=((Ee=(Ne=(Ie=(ke=q==null?void 0:q._renderService)==null?void 0:ke.dimensions)==null?void 0:Ie.css)==null?void 0:Ne.cell)==null?void 0:Ee.height)??17,fe=Math.max(2,Math.floor(W.height/Me));return{cols:X,rows:fe}},getPendingLocalSize:()=>Q.current}),[a,Q,se,te]),h.jsxs("div",{ref:J,className:"h-full w-full relative",style:{backgroundColor:x.background},"data-terminal-engine":Gt,children:[h.jsx("div",{ref:y,className:"absolute inset-0"}),h.jsx(cr,{visible:E,canPaste:s==="direct"&&r&&!i,onCopy:z,onPaste:H,onDismiss:$})]})});Vt.displayName="Terminal";const Mr=1200,Dr=2e3;function he(n,e){return!n||!e?!1:n.windowId===e.windowId&&n.paneId===e.paneId}function Kt(n,e){const t=n.filter(s=>e-s.at<Mr);return t.length===0?null:t.reduce((s,r)=>r.at>s.at?r:s)}function ve(n,e=Date.now()){return!n||e-n.at>Dr?null:n}function Ar(n){const e=n.now??Date.now(),t=Kt(n.recentSelectRequests,e);if(t&&!he(t,n.activePaneFromEvent)||he(n.currentRoute,n.activePaneFromEvent)||he(n.lastHandledActive,n.activePaneFromEvent))return!0;const s=ve(n.pendingUserSelection,e);return!!(s&&!he(s,n.activePaneFromEvent))}function Or(n){const e=n.now??Date.now(),t=Kt(n.recentSelectRequests,e),s=ve(n.pendingUserSelection,e);return!!(s&&!he(s,n.snapshotActive)||t&&!he(t,n.snapshotActive))}function kr(n){const e=n.now??Date.now(),t=ve(n.pendingUserSelection,e);return!(t&&he(t,n.routeTarget)||n.snapshotActive&&he(n.snapshotActive,n.routeTarget))}function Ir(){const n=it.getState().settings;return(n==null?void 0:n.siteName)||"tmex"}function At(n){const e=n==null?void 0:n.trim();return e&&e.length>0?e:"?"}function $t({paneIdx:n,windowIdx:e,paneTitle:t,windowName:s,deviceName:r}){const i=e??"?",o=n??"?",l=At(t??s),u=At(r);return`${i}/${o}: ${l}@${u}`}function Nr(n){const e=Ir();return n!=null&&n.trim()?`[${e}]${n}`:e}const Pr=[{key:"enter",label:"ENTER",payload:"\r"},{key:"ctrl-c",label:"CTRL-C",payload:""},{key:"ctrl-d",label:"CTRL-D",payload:""},{key:"up",label:"↑",payload:"\x1B[A"},{key:"down",label:"↓",payload:"\x1B[B"},{key:"left",label:"←",payload:"\x1B[D"},{key:"right",label:"→",payload:"\x1B[C"},{key:"shift-enter",label:"SHIFT+ENTER",payload:"\x1B[13;2u"},{key:"tab",label:"TAB",payload:" "},{key:"backspace",label:"BACKSPACE",payload:"\b"},{key:"esc",label:"ESC",payload:"\x1B"},{key:"delete",label:"DELETE",payload:""},{key:":",label:":",payload:":"},{key:"/",label:"/",payload:"/"},{key:"'",label:"'",payload:"'"},{key:'"',label:'"',payload:'"'},{key:"`",label:"`",payload:"`"}],Ot=d.memo(function({onSend:e,onFocusEditor:t,disabled:s,isMobile:r,inputMode:i}){return h.jsx("div",{className:"terminal-shortcuts-strip my-2 bg-muted rounded-xl","data-testid":"terminal-shortcuts-strip",children:h.jsx("div",{className:"shortcut-row flex items-center gap-1.5 p-2 overflow-x-auto scrollbar-thin","data-testid":"editor-shortcuts-row",children:Pr.map(o=>h.jsx(pe,{variant:"secondary",size:"sm",className:"h-7 min-w-9 px-2.5 rounded-full text-[11px] font-medium tracking-wide shrink-0 [@media(any-pointer:coarse)]:h-9 [@media(any-pointer:coarse)]:min-w-10 [@media(any-pointer:coarse)]:px-3",title:o.label,"aria-label":o.label,"data-testid":`editor-shortcut-${o.key}`,onMouseDown:l=>l.preventDefault(),onClick:()=>{e(o.payload),r&&i==="editor"&&(t==null||t())},disabled:s,children:o.label},o.key))})})});function Gr(){var Ee;const{t:n}=Ke(),{deviceId:e,windowId:t,paneId:s}=ot(),r=Xt(),i=d.useRef(null),o=d.useRef(null),l=d.useRef(null),u=d.useRef(null),a=d.useRef(!1),g=d.useRef(!1),E=d.useRef(null),A=Z(c=>c.selectPane),B=Z(c=>e?c.snapshots[e]:void 0),T=Z(c=>{var m;return e?(m=c.deviceErrors)==null?void 0:m[e]:void 0}),x=Z(c=>{var m;return e?((m=c.deviceConnected)==null?void 0:m[e])??!1:!1}),J=it(c=>{var m;return((m=c.settings)==null?void 0:m.siteName)??"tmex"}),y=d.useMemo(()=>lt(s),[s]),U=d.useMemo(()=>e&&y?`${e}:${y}`:null,[e,y]),[k,K]=d.useState(!1),[Y,b]=d.useState(""),C=d.useRef(!1),N=!x||!y,[L,V]=d.useState(!1),S=ae(c=>c.inputMode),R=ae(c=>c.theme),P=ae(c=>c.editorSendWithEnter),F=ae(c=>c.setEditorSendWithEnter),I=ae(c=>c.addEditorHistory),j=ae(c=>c.setEditorDraft),Q=ae(c=>c.removeEditorDraft),te=ae(c=>U?c.editorDrafts[U]??"":""),se=d.useMemo(()=>Jt(),[]),D=(Ee=B==null?void 0:B.session)==null?void 0:Ee.windows,ie=R==="light"?zt:Yt,{data:G}=Qt({queryKey:["devices"],queryFn:async()=>{const c=await fetch("/api/devices");if(!c.ok)throw new Error("Failed to fetch devices");return c.json()},throwOnError:!1}),z=d.useMemo(()=>{if(e)return G==null?void 0:G.devices.find(c=>c.id===e)},[e,G==null?void 0:G.devices]),H=d.useMemo(()=>{if(!(!t||!D))return D.find(c=>c.id===t)},[t,D]),$=d.useMemo(()=>{if(!(!y||!H))return H.panes.find(c=>c.id===y)},[y,H]),w=!!D,q=!!(w&&!!t&&!H||w&&!!t&&!!y&&!!H&&!$?n("wsError.checkGateway"):null),X=!!(x&&y&&!q),Me=d.useMemo(()=>{if(!H||!$)return null;const c=(z==null?void 0:z.name)??e;return $t({paneIdx:$.index,windowIdx:H.index,paneTitle:$.title,windowName:H.name,deviceName:c})},[z==null?void 0:z.name,e,$,H]),fe=d.useMemo(()=>{if(!D||D.length===0)return null;const c=D.find(p=>p.active),m=c==null?void 0:c.panes.find(p=>p.active);return!c||!m?null:{windowId:c.id,paneId:m.id}},[D]),De=d.useCallback((c,m)=>{!e||!y||Z.getState().resizePane(e,y,c,m)},[e,y]),Ae=d.useCallback((c,m)=>{!e||!y||Z.getState().syncPaneSize(e,y,c,m)},[e,y]),oe=d.useCallback((c,m)=>{const p=u.current,M=(p==null?void 0:p.calculateSizeFromContainer())??(p==null?void 0:p.getSize())??void 0;if(M)return M;if(!c||!m||!D)return;const ne=D.find(me=>me.id===c),re=ne==null?void 0:ne.panes.find(me=>me.id===m);if(!(!re||re.width<=1||re.height<=1))return{cols:re.width,rows:re.height}},[D]);d.useEffect(()=>{const c=()=>{K(window.innerWidth<768||"ontouchstart"in window)};return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]),d.useEffect(()=>{if(!k||!se||g.current)return;g.current=!0;const c=()=>{window.scrollTo(0,1)},m=window.requestAnimationFrame(c),p=window.setTimeout(c,120),M=window.setTimeout(c,420);return()=>{window.cancelAnimationFrame(m),window.clearTimeout(p),window.clearTimeout(M)}},[se,k]),d.useEffect(()=>{e&&(a.current=!1,ye.current=null,ue.current=null,E.current=null,de.current=[])},[e]),d.useEffect(()=>{x||(a.current=!1)},[x]),d.useEffect(()=>{if(!e||!x||!t||!D)return;if(D.length===0){r("/devices",{replace:!0});return}const c=D.find(p=>p.id===t);if(!c)return;if(!y){const p=c.panes.find(M=>M.active)??c.panes[0];p&&r(`/devices/${e}/windows/${t}/panes/${Se(p.id)}`,{replace:!0});return}if(!c.panes.find(p=>p.id===y)){const p=c.panes.find(M=>M.active)??c.panes[0];p&&r(`/devices/${e}/windows/${t}/panes/${Se(p.id)}`,{replace:!0});return}},[e,x,D,t,y,r]),d.useEffect(()=>{if(!e||!x||!D||D.length===0||t&&y||a.current)return;const c=D.find(p=>p.active)??D[0],m=c.panes.find(p=>p.active)??c.panes[0];m&&(a.current=!0,r(`/devices/${e}/windows/${c.id}/panes/${Se(m.id)}`,{replace:!0}))},[x,e,r,y,t,D]);const we=d.useRef(null);d.useEffect(()=>{we.current=null},[e,y]),d.useEffect(()=>{if(!e||!t||!y||N||!x)return;const c=`${e}:${t}:${y}`;if(we.current===c)return;we.current=c;const m=oe(t,y);le(t,y),A(e,t,y,m)},[x,e,oe,N,y,A,t]),d.useEffect(()=>{if(!e||!x||!t||!y)return;const c={windowId:t,paneId:y};kr({routeTarget:c,snapshotActive:fe,pendingUserSelection:E.current})&&(E.current={windowId:c.windowId,paneId:c.paneId,at:Date.now()})},[x,e,y,fe,t]);const de=d.useRef([]),le=d.useCallback((c,m)=>{const p=Date.now(),M=[...de.current.filter(ne=>p-ne.at<2e3),{windowId:c,paneId:m,at:p}];de.current=M.slice(-8)},[]),ee=Z(c=>e?c.activePaneFromEvent[e]:void 0),ye=d.useRef(null);d.useEffect(()=>{if(!e||!x||!t||!y||!ee)return;const c=Date.now(),m=ve(E.current,c);if(E.current=m,Ar({now:c,pendingUserSelection:m,activePaneFromEvent:ee,currentRoute:{windowId:t,paneId:y},recentSelectRequests:de.current,lastHandledActive:ye.current}))return;ye.current={...ee},m&&m.windowId===ee.windowId&&m.paneId===ee.paneId&&(E.current=null);const p=oe(ee.windowId,ee.paneId);le(ee.windowId,ee.paneId),A(e,ee.windowId,ee.paneId,p),r(`/devices/${e}/windows/${ee.windowId}/panes/${Se(ee.paneId)}`,{replace:!0})},[e,x,t,y,ee,le,oe,A,r]);const ue=d.useRef(null);d.useEffect(()=>{if(!e||!x||!D||D.length===0)return;const c=de.current,m=D.find(je=>je.active);if(!m)return;const p=m.panes.find(je=>je.active);if(!p)return;const M={windowId:m.id,paneId:p.id},ne=Date.now(),re=ve(E.current,ne);if(E.current=re,Or({now:ne,pendingUserSelection:re,snapshotActive:M,recentSelectRequests:c})||ue.current&&ue.current.windowId===M.windowId&&ue.current.paneId===M.paneId||(ue.current={...M},re&&re.windowId===M.windowId&&re.paneId===M.paneId&&(E.current=null),t===M.windowId&&y===M.paneId))return;const me=oe(M.windowId,M.paneId);le(M.windowId,M.paneId),A(e,M.windowId,M.paneId,me),r(`/devices/${e}/windows/${M.windowId}/panes/${Se(M.paneId)}`,{replace:!0})},[e,x,D,t,y,le,oe,A,r]);const ge=Z(c=>e?c.pendingCreateWindowAt[e]:void 0);d.useEffect(()=>{if(!e||!x||!ge)return;const c=5e3,m=Date.now()-ge;if(m>c){Z.getState().clearPendingCreateWindow(e);return}if(!fe){const ne=window.setTimeout(()=>{Z.getState().clearPendingCreateWindow(e)},c-m);return()=>window.clearTimeout(ne)}const p=fe;if(t===p.windowId&&y===p.paneId){const ne=window.setTimeout(()=>{Z.getState().clearPendingCreateWindow(e)},c-m);return()=>window.clearTimeout(ne)}E.current={windowId:p.windowId,paneId:p.paneId,at:Date.now()};const M=oe(p.windowId,p.paneId);le(p.windowId,p.paneId),A(e,p.windowId,p.paneId,M),r(`/devices/${e}/windows/${p.windowId}/panes/${Se(p.paneId)}`,{replace:!0}),Z.getState().clearPendingCreateWindow(e)},[e,x,ge,fe,t,y,le,oe,A,r]),d.useEffect(()=>{if(!X||!$||N)return;const c=u.current,m=c==null?void 0:c.getTerminal();if(!m)return;const p=Math.max(2,Math.floor($.width||0)),M=Math.max(2,Math.floor($.height||0));if(!p||!M)return;const ne=Date.now(),re={cols:p,rows:M},me=(c==null?void 0:c.getPendingLocalSize())??null;gr({now:ne,remoteSize:re,pendingLocalSize:me})&&(m.cols===p&&m.rows===M||m.resize(p,M))},[X,N,$]),d.useEffect(()=>{const c=window.requestAnimationFrame(()=>{var p;(p=u.current)==null||p.scrollToBottom()}),m=window.setTimeout(()=>{var p;(p=u.current)==null||p.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(c),window.clearTimeout(m)}},[S]),d.useEffect(()=>{T!=null&&T.message&&_e.error(T.message)},[T==null?void 0:T.message]),d.useEffect(()=>(document.title=Nr(Me),()=>{document.title=J}),[J,Me]),d.useEffect(()=>{const c=()=>{var m;(m=u.current)==null||m.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",c),()=>{window.removeEventListener("tmex:jump-to-latest",c)}},[]),d.useEffect(()=>{const c=m=>{const{deviceId:p,windowId:M,paneId:ne}=m.detail;p===e&&(E.current={windowId:M,paneId:ne,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",c),()=>{window.removeEventListener("tmex:user-initiated-selection",c)}},[e]),d.useEffect(()=>{b(te)},[te]);const Te=d.useCallback(c=>{if(!e||!y||!X)return;Z.getState().sendInput(e,y,c,!1)},[X,e,y]),Oe=d.useCallback(()=>{if(!X){_e.error(n("wsError.checkGateway"));return}if(!e||!y||!Y.trim())return;V(!0),window.setTimeout(()=>V(!1),150);const c=P?`${Y}\r`:Y;Z.getState().sendInput(e,y,c,!1),I(Y),U&&Q(U),b("")},[I,X,e,U,P,Y,Q,y,n]),ke=d.useCallback(()=>{if(!X){_e.error(n("wsError.checkGateway"));return}if(!e||!y||!Y.trim())return;V(!0),window.setTimeout(()=>V(!1),150);const c=Y.split(/\r?\n/),m=Z.getState();for(const p of c)p.trim()&&m.sendInput(e,y,`${p}\r`,!1);I(Y),U&&Q(U),b("")},[I,X,e,U,Y,Q,y,n]),Ie=d.useCallback(()=>{var c;(c=l.current)==null||c.focus({preventScroll:!0})},[]);if(!e)return h.jsx("div",{className:"flex h-full items-center justify-center p-4",children:h.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:n("device.noDevices")})});const Ne=!x&&!T;return h.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[h.jsxs("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${k&&S==="editor"?"pb-1":""}`,children:[h.jsx("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:ie.background},children:x&&y?h.jsx("div",{ref:i,className:"flex-1 h-full min-h-0 w-full","data-virtual-keyboard-avoid":!0,children:h.jsx(Vt,{ref:u,deviceId:e,paneId:y,theme:R,inputMode:S,deviceConnected:x,isSelectionInvalid:q,onResize:De,onSync:Ae},`${e}:${y}`)}):h.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:h.jsx("div",{className:"max-w-sm space-y-4",children:x?t?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx(We,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("terminal.connecting")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("window.noWindowSelected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:n("window.selectWindowToStart")})]}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:h.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),h.jsx("h3",{className:"text-lg font-medium",children:n("device.disconnected")}),h.jsx("p",{className:"text-sm text-muted-foreground",children:n("device.connectToStart")})]})})})}),Ne&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:h.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:[h.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),h.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:n("terminal.connecting")})]})})]}),S==="direct"&&h.jsx("div",{className:"",children:h.jsx(Ot,{onSend:Te,disabled:!X,isMobile:k,inputMode:S})}),S==="editor"&&h.jsxs("div",{ref:o,"data-virtual-keyboard-avoid":!0,className:"editor-mode-input bg-card/85 backdrop-blur-sm",children:[k&&h.jsx(Ot,{onSend:Te,onFocusEditor:Ie,disabled:!X,isMobile:k,inputMode:S}),h.jsx("textarea",{ref:l,"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:Y,onChange:c=>{const m=c.target.value;if(b(m),!!U){if(m){j(U,m);return}Q(U)}},placeholder:n("terminal.inputPlaceholder"),onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1}}),h.jsx("div",{className:"actions mt-2",children:h.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[h.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:[h.jsx(cn,{size:"sm",checked:P,onCheckedChange:c=>F(!!c)}),h.jsx("span",{children:n("terminal.editorSendWithEnter")})]}),h.jsxs(pe,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;b(""),U&&Q(U),k&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},title:n("terminal.clear"),children:[h.jsx(Zt,{className:"h-4 w-4"}),n("terminal.clear")]}),h.jsxs(pe,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;ke(),k&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!X||L,children:[L?h.jsx(We,{className:"h-4 w-4 animate-spin"}):h.jsx(ht,{className:"h-4 w-4"}),n("terminal.editorSendLineByLine")]}),h.jsxs(pe,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:c=>c.preventDefault(),onClick:()=>{var c;Oe(),k&&S==="editor"&&((c=l.current)==null||c.focus({preventScroll:!0}))},disabled:!X||L,children:[L?h.jsx(We,{className:"h-4 w-4 animate-spin"}):h.jsx(ht,{className:"h-4 w-4"}),n("common.send")]})]})})]})]})}function Ur(){const{deviceId:n,windowId:e,paneId:t}=ot(),s=t?lt(t):void 0,r=Z(g=>g.snapshots),i=it(g=>{var E;return((E=g.settings)==null?void 0:E.siteName)??"tmex"}),o=n?r[n]:void 0,l=d.useMemo(()=>{var g;if(!(!e||!((g=o==null?void 0:o.session)!=null&&g.windows)))return o.session.windows.find(E=>E.id===e)},[e,o]),u=d.useMemo(()=>{if(!(!s||!l))return l.panes.find(g=>g.id===s)},[s,l]),a=d.useMemo(()=>l&&u?$t({paneIdx:u.index,windowIdx:l.index,paneTitle:u.title,windowName:l.name,deviceName:i}):n??"",[l,u,i,n]);return h.jsx(h.Fragment,{children:a})}function zr(){const{t:n}=Ke(),{deviceId:e,paneId:t}=ot(),s=t?lt(t):void 0,r=ae(T=>T.inputMode),i=ae(T=>T.setInputMode),o=Z(T=>{var x;return e?((x=T.deviceConnected)==null?void 0:x[e])??!1:!1}),[l,u]=d.useState(!1),a=!!(s&&o),g=()=>{i(r==="direct"?"editor":"direct")},E=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},A=()=>{u(!0)},B=()=>{window.location.reload()};return h.jsxs(h.Fragment,{children:[h.jsx(pe,{variant:"ghost",size:"icon-sm",onClick:A,"aria-label":n("nav.refreshPage"),title:n("nav.refreshPage"),children:h.jsx(Sn,{className:"h-4 w-4"})}),h.jsx(pe,{variant:"ghost",size:"icon-sm",onClick:g,disabled:!a,"data-testid":"terminal-input-mode-toggle","aria-label":n(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:n(r==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:r==="direct"?h.jsx(yn,{className:"h-4 w-4"}):h.jsx(bn,{className:"h-4 w-4"})}),h.jsx(pe,{variant:"ghost",size:"icon-sm",onClick:E,disabled:!a,"aria-label":n("nav.jumpToLatest"),title:n("nav.jumpToLatest"),children:h.jsx(un,{className:"h-4 w-4"})}),h.jsx(en,{open:l,onOpenChange:u,children:h.jsxs(tn,{children:[h.jsxs(nn,{children:[h.jsx(sn,{children:n("nav.refreshPage")}),h.jsx(rn,{children:n("nav.refreshPageConfirm")})]}),h.jsxs(on,{children:[h.jsx(ln,{onClick:()=>u(!1),children:n("common.cancel")}),h.jsx(an,{onClick:B,children:n("common.confirm")})]})]})})]})}export{zr as PageActions,Ur as PageTitle,Gr as default};
|
|
36
|
+
//# sourceMappingURL=DevicePage-CNkRwiKd.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ut=Object.defineProperty;var Bt=(e,s,r)=>s in e?Ut(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r;var We=(e,s,r)=>Bt(e,typeof s!="symbol"?s+"":s,r);import{c as Ue,j as t,D as zt,g as _t,h as dt,X as qt,B as pe,k as X,l as Gt,m as Vt,n as Yt,o as Qt,r as o,p as ve,q as lt,s as ut,v as Ae,w as pt,x as ft,y as ye,z as Jt,A as Wt,C as Xt,F as Zt,E as ue,G as en,H as mt,J as tn,K as gt,L as nn,M as sn,P as on,N as an,O as Me,Q as rn,R as cn,S as dn,T as je,U as ln,V as un,W as pn,Y as fn,Z as Te,_ as ht,$ as mn,a0 as $,a1 as gn,a2 as hn,a3 as xt,a4 as vt,a5 as He,a6 as xn,a7 as vn,a8 as yn,a9 as bn,aa as Pe,ab as Cn,ac as we,ad as Xe,ae as jn,af as wn,ag as Le,ah as In,ai as Rn,aj as Mn,ak as Pn,al as Sn,am as Tn,an as Ke,ao as En,ap as yt,aq as Nn,ar as bt,as as kn,at as On,au as Dn,av as $e,aw as Fn,ax as An,ay as Hn,az as De,aA as Ln,aB as Kn,aC as $n,aD as Un,aE as Ze,aF as Bn,aG as zn,aH as _n,aI as qn,aJ as et,aK as tt,aL as Gn,aM as Vn,u as be,a as Ct,e as Yn,aN as Qn,aO as jt,aP as wt,aQ as Jn,f as ce,aR as nt,aS as Wn,aT as Xn,aU as Zn,aV as es}from"./index-
|
|
1
|
+
var Ut=Object.defineProperty;var Bt=(e,s,r)=>s in e?Ut(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r;var We=(e,s,r)=>Bt(e,typeof s!="symbol"?s+"":s,r);import{c as Ue,j as t,D as zt,g as _t,h as dt,X as qt,B as pe,k as X,l as Gt,m as Vt,n as Yt,o as Qt,r as o,p as ve,q as lt,s as ut,v as Ae,w as pt,x as ft,y as ye,z as Jt,A as Wt,C as Xt,F as Zt,E as ue,G as en,H as mt,J as tn,K as gt,L as nn,M as sn,P as on,N as an,O as Me,Q as rn,R as cn,S as dn,T as je,U as ln,V as un,W as pn,Y as fn,Z as Te,_ as ht,$ as mn,a0 as $,a1 as gn,a2 as hn,a3 as xt,a4 as vt,a5 as He,a6 as xn,a7 as vn,a8 as yn,a9 as bn,aa as Pe,ab as Cn,ac as we,ad as Xe,ae as jn,af as wn,ag as Le,ah as In,ai as Rn,aj as Mn,ak as Pn,al as Sn,am as Tn,an as Ke,ao as En,ap as yt,aq as Nn,ar as bt,as as kn,at as On,au as Dn,av as $e,aw as Fn,ax as An,ay as Hn,az as De,aA as Ln,aB as Kn,aC as $n,aD as Un,aE as Ze,aF as Bn,aG as zn,aH as _n,aI as qn,aJ as et,aK as tt,aL as Gn,aM as Vn,u as be,a as Ct,e as Yn,aN as Qn,aO as jt,aP as wt,aQ as Jn,f as ce,aR as nt,aS as Wn,aT as Xn,aU as Zn,aV as es}from"./index-DIffR5B7.js";import{h as It,i as ts,j as ns,k as ss,l as os,m as as,n as rs,u as Se,C as Ie,c as Re,a as is,b as cs,o as ds,I as ie,S as st,d as ot,e as at,f as rt,g as he}from"./select-B8Wx7E3G.js";import{A as ls,a as us,b as ps,h as fs,T as Rt,c as ms,d as gs,e as hs,f as xs,g as vs}from"./useValueChanged-BNNSF8VN.js";/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -14,4 +14,4 @@ var Ut=Object.defineProperty;var Bt=(e,s,r)=>s in e?Ut(e,s,{enumerable:!0,config
|
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/const ws=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Is=Ue("zap",ws);function Rs({...e}){return t.jsx(zt,{"data-slot":"dialog",...e})}function Ms({...e}){return t.jsx(Yt,{"data-slot":"dialog-portal",...e})}function Ps({className:e,...s}){return t.jsx(Qt,{"data-slot":"dialog-overlay",className:X("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",e),...s})}function Ss({className:e,children:s,showCloseButton:r=!0,...n}){return t.jsxs(Ms,{children:[t.jsx(Ps,{}),t.jsxs(_t,{"data-slot":"dialog-content",className:X("bg-background data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 grid max-w-[calc(100%-2rem)] gap-4 rounded-xl p-4 text-sm ring-1 duration-100 sm:max-w-sm fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none",e),...n,children:[s,r&&t.jsxs(dt,{"data-slot":"dialog-close",render:t.jsx(pe,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm"}),children:[t.jsx(qt,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ts({className:e,...s}){return t.jsx("div",{"data-slot":"dialog-header",className:X("gap-2 flex flex-col",e),...s})}function Es({className:e,showCloseButton:s=!1,children:r,...n}){return t.jsxs("div",{"data-slot":"dialog-footer",className:X("bg-muted/50 -mx-4 -mb-4 rounded-b-xl border-t p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...n,children:[r,s&&t.jsx(dt,{render:t.jsx(pe,{variant:"outline"}),children:"Close"})]})}function Ns({className:e,...s}){return t.jsx(Gt,{"data-slot":"dialog-title",className:X("text-base leading-none font-medium",e),...s})}function ks({className:e,...s}){return t.jsx(Vt,{"data-slot":"dialog-description",className:X("text-muted-foreground *:[a]:hover:text-foreground text-sm *:[a]:underline *:[a]:underline-offset-3",e),...s})}const Mt=o.createContext(void 0);function Pt(e){const s=o.useContext(Mt);if(s===void 0&&!e)throw new Error(ve(33));return s}const St=o.createContext(void 0);function fe(e){const s=o.useContext(St);if(s===void 0&&!e)throw new Error(ve(36));return s}const Os=o.createContext(void 0);function Ee(e=!0){const s=o.useContext(Os);if(s===void 0&&!e)throw new Error(ve(25));return s}function Ds(e){const{closeOnClick:s,highlighted:r,id:n,nodeId:p,store:i,itemRef:m,itemMetadata:c}=e,{events:x}=i.useState("floatingTreeRoot"),b=Ee(!0),C=b!==void 0;return o.useMemo(()=>({id:n,role:"menuitem",tabIndex:r?0:-1,onMouseMove(y){p&&x.emit("itemhover",{nodeId:p,target:y.currentTarget})},onClick(y){s&&x.emit("close",{domEvent:y,reason:lt})},onMouseUp(y){if(b){const M=b.initialCursorPointRef.current;if(b.initialCursorPointRef.current=null,C&&M&&Math.abs(y.clientX-M.x)<=1&&Math.abs(y.clientY-M.y)<=1)return}m.current&&i.context.allowMouseUpTriggerRef.current&&(!C||y.button===2)&&(!c||c.type==="regular-item")&&m.current.click()}}),[s,r,n,x,p,i,m,b,C,c])}const Fs={type:"regular-item"};function As(e){const{closeOnClick:s,disabled:r=!1,highlighted:n,id:p,store:i,nativeButton:m,itemMetadata:c,nodeId:x}=e,b=o.useRef(null),{getButtonProps:C,buttonRef:y}=ut({disabled:r,focusableWhenDisabled:!0,native:m}),M=Ds({closeOnClick:s,highlighted:n,id:p,nodeId:x,store:i,itemRef:b,itemMetadata:c}),D=o.useCallback(g=>Ae(M,{onMouseEnter(){c.type==="submenu-trigger"&&c.setActive()},onKeyUp(S){S.key===" "&&i.context.typingRef.current&&S.preventBaseUIHandler()}},g,C),[M,C,i,c]),f=pt(b,y);return o.useMemo(()=>({getItemProps:D,itemRef:f}),[D,f])}const Hs=o.forwardRef(function(s,r){const{render:n,className:p,id:i,label:m,nativeButton:c=!1,disabled:x=!1,closeOnClick:b=!0,...C}=s,y=It({label:m}),M=Pt(!0),D=ft(i),{store:f}=fe(),g=f.useState("isActive",y.index),S=f.useState("itemProps"),{getItemProps:w,itemRef:u}=As({closeOnClick:b,disabled:x,highlighted:g,id:D,store:f,nativeButton:c,nodeId:M==null?void 0:M.nodeId,itemMetadata:Fs});return ye("div",s,{state:{disabled:x,highlighted:g},props:[S,C,w],ref:[u,r,y.ref]})}),Ls={...mt,...en},Ks=o.forwardRef(function(s,r){const{render:n,className:p,finalFocus:i,...m}=s,{store:c}=fe(),{side:x,align:b}=Pt(),C=ts()!=null,y=c.useState("open"),M=c.useState("transitionStatus"),D=c.useState("popupProps"),f=c.useState("mounted"),g=c.useState("instantType"),S=c.useState("activeTriggerElement"),w=c.useState("parent"),u=c.useState("lastOpenChangeReason"),N=c.useState("rootId"),B=c.useState("floatingRootContext"),h=c.useState("floatingTreeRoot"),a=c.useState("closeDelay"),I=c.useState("activeTriggerElement"),F=w.type==="context-menu";Jt({open:y,ref:c.context.popupRef,onComplete(){var j,K;y&&((K=(j=c.context).onOpenChangeComplete)==null||K.call(j,!0))}}),o.useEffect(()=>{function j(K){c.setOpen(!1,ue(K.reason,K.domEvent))}return h.events.on("close",j),()=>{h.events.off("close",j)}},[h.events,c]);const A=c.useState("hoverEnabled"),O=c.useState("disabled");Wt(B,{enabled:A&&!O&&!F&&w.type!=="menubar",closeDelay:a});const P={transitionStatus:M,side:x,align:b,open:y,nested:w.type==="menu",instant:g},d=ye("div",s,{state:P,ref:[r,c.context.popupRef],stateAttributesMapping:Ls,props:[D,{onKeyDown(j){C&&tn.has(j.key)&&j.stopPropagation()}},gt(M),m,{"data-rootownerid":N}]});let l=w.type===void 0||F;return(S||w.type==="menubar"&&u!==Xt)&&(l=!0),t.jsx(Zt,{context:B,modal:F,disabled:!f,returnFocus:i===void 0?l:i,initialFocus:w.type!=="menu",restoreFocus:!0,externalTree:w.type!=="menubar"?h:void 0,previousFocusableElement:I,nextFocusableElement:w.type===void 0?c.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:w.type===void 0?c.context.beforeContentFocusGuardRef:void 0,children:d})}),Tt=o.createContext(void 0);function $s(){const e=o.useContext(Tt);if(e===void 0)throw new Error(ve(32));return e}const Us=o.forwardRef(function(s,r){const{keepMounted:n=!1,...p}=s,{store:i}=fe();return i.useState("mounted")||n?t.jsx(Tt.Provider,{value:n,children:t.jsx(nn,{ref:r,...p})}):null}),Bs=o.forwardRef(function(s,r){var ae;const{anchor:n,positionMethod:p="absolute",className:i,render:m,side:c,align:x,sideOffset:b=0,alignOffset:C=0,collisionBoundary:y="clipping-ancestors",collisionPadding:M=5,arrowPadding:D=5,sticky:f=!1,disableAnchorTracking:g=!1,collisionAvoidance:S=sn,...w}=s,{store:u}=fe(),N=$s(),B=Ee(!0),h=u.useState("parent"),a=u.useState("floatingRootContext"),I=u.useState("floatingTreeRoot"),F=u.useState("mounted"),A=u.useState("open"),O=u.useState("modal"),P=u.useState("activeTriggerElement"),d=u.useState("transitionStatus"),l=u.useState("lastOpenChangeReason"),j=u.useState("floatingNodeId"),K=u.useState("floatingParentNodeId");let de=n,T=b,z=C,Z=x,Y=S;h.type==="context-menu"&&(de=n??((ae=h.context)==null?void 0:ae.anchor),Z=Z??"start",!c&&Z!=="center"&&(z=s.alignOffset??2,T=s.sideOffset??-5));let G=c,Q=Z;h.type==="menu"?(G=G??"inline-end",Q=Q??"start",Y=s.collisionAvoidance??on):h.type==="menubar"&&(G=G??"bottom",Q=Q??"start");const _=h.type==="context-menu",k=an({anchor:de,floatingRootContext:a,positionMethod:B?"fixed":p,mounted:F,side:G,sideOffset:T,align:Q,alignOffset:z,arrowPadding:_?0:D,collisionBoundary:y,collisionPadding:M,sticky:f,nodeId:j,keepMounted:N,disableAnchorTracking:g,collisionAvoidance:Y,shiftCrossAxis:_&&!("side"in Y&&Y.side==="flip"),externalTree:I}),se=o.useMemo(()=>{const E={};return A||(E.pointerEvents="none"),{role:"presentation",hidden:!F,style:{...k.positionerStyles,...E}}},[A,F,k.positionerStyles]);o.useEffect(()=>{function E(H){H.open&&(H.parentNodeId===j&&u.set("hoverEnabled",!1),H.nodeId!==j&&H.parentNodeId===u.select("floatingParentNodeId")&&u.setOpen(!1,ue(je)))}return I.events.on("menuopenchange",E),()=>{I.events.off("menuopenchange",E)}},[u,I.events,j]),o.useEffect(()=>{if(u.select("floatingParentNodeId")==null)return;function E(H){if(H.open||H.nodeId!==u.select("floatingParentNodeId"))return;const ge=H.reason??je;u.setOpen(!1,ue(ge))}return I.events.on("menuopenchange",E),()=>{I.events.off("menuopenchange",E)}},[I.events,u]),o.useEffect(()=>{function E(H){!A||H.nodeId!==u.select("floatingParentNodeId")||H.target&&P&&P!==H.target&&u.setOpen(!1,ue(je))}return I.events.on("itemhover",E),()=>{I.events.off("itemhover",E)}},[I.events,A,P,u]),o.useEffect(()=>{const E={open:A,nodeId:j,parentNodeId:K,reason:u.select("lastOpenChangeReason")};I.events.emit("menuopenchange",E)},[I.events,A,u,j,K]);const xe={open:A,side:k.side,align:k.align,anchorHidden:k.anchorHidden,nested:h.type==="menu"},me=o.useMemo(()=>({side:k.side,align:k.align,arrowRef:k.arrowRef,arrowUncentered:k.arrowUncentered,arrowStyles:k.arrowStyles,nodeId:k.context.nodeId}),[k.side,k.align,k.arrowRef,k.arrowUncentered,k.arrowStyles,k.context.nodeId]),le=ye("div",s,{state:xe,stateAttributesMapping:mt,ref:[r,u.useStateSetter("positionerElement")],props:[se,gt(d),w]}),oe=F&&h.type!=="menu"&&(h.type!=="menubar"&&O&&l!==Me||h.type==="menubar"&&h.context.modal);let J=null;return h.type==="menubar"?J=h.context.contentElement:h.type===void 0&&(J=P),t.jsxs(Mt.Provider,{value:me,children:[oe&&t.jsx(rn,{ref:h.type==="context-menu"||h.type==="nested-context-menu"?h.context.internalBackdropRef:null,inert:cn(!A),cutout:J}),t.jsx(dn,{id:j,children:t.jsx(ns,{elementsRef:u.context.itemDomElements,labelsRef:u.context.itemLabels,children:le})})]})}),zs=o.createContext(null);function Et(e){return o.useContext(zs)}const _s={...pn,disabled:$(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:$(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:$(e=>e.allowMouseEnter),stickIfOpen:$(e=>e.stickIfOpen),parent:$(e=>e.parent),rootId:$(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:$(e=>e.activeIndex),isActive:$((e,s)=>e.activeIndex===s),hoverEnabled:$(e=>e.hoverEnabled),instantType:$(e=>e.instantType),lastOpenChangeReason:$(e=>e.openChangeReason),floatingTreeRoot:$(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:$(e=>e.floatingNodeId),floatingParentNodeId:$(e=>e.floatingParentNodeId),itemProps:$(e=>e.itemProps),closeDelay:$(e=>e.closeDelay),keyboardEventRelay:$(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class Be extends ln{constructor(r){super({...qs(),...r},{positionerRef:o.createRef(),popupRef:o.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:o.createRef(),beforeContentFocusGuardRef:o.createRef(),onOpenChangeComplete:void 0,triggerElements:new un},_s);We(this,"unsubscribeParentListener",null);this.unsubscribeParentListener=this.observe("parent",n=>{var p;if((p=this.unsubscribeParentListener)==null||p.call(this),n.type==="menu"){this.unsubscribeParentListener=n.store.subscribe(()=>{this.notifyAll()}),this.context.allowMouseUpTriggerRef=n.store.context.allowMouseUpTriggerRef;return}n.type!==void 0&&(this.context.allowMouseUpTriggerRef=n.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(r,n){this.state.floatingRootContext.context.events.emit("setOpen",{open:r,eventDetails:n})}static useStore(r,n){const p=fn(()=>new Be(n)).current;return r??p}}function qs(){return{...mn(),disabled:!1,modal:!0,allowMouseEnter:!1,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new ht,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Te,keyboardEventRelay:void 0,closeDelay:0}}const Gs=o.createContext(void 0);function Vs(){return o.useContext(Gs)}const Ys=gn(function(s){const{children:r,open:n,onOpenChange:p,onOpenChangeComplete:i,defaultOpen:m=!1,disabled:c=!1,modal:x,loopFocus:b=!0,orientation:C="vertical",actionsRef:y,closeParentOnEsc:M=!1,handle:D,triggerId:f,defaultTriggerId:g=null,highlightItemOnHover:S=!0}=s,w=Ee(!0),u=fe(!0),N=Et(!0),B=Vs(),h=o.useMemo(()=>B&&u?{type:"menu",store:u.store}:N?{type:"menubar",context:N}:w&&!u?{type:"context-menu",context:w}:{type:void 0},[w,u,N,B]),a=Be.useStore(D==null?void 0:D.store,{open:m,openProp:n,activeTriggerId:g,triggerIdProp:f,parent:h});hn(()=>{n===void 0&&a.state.open===!1&&m===!0&&a.update({open:!0,activeTriggerId:g})}),a.useControlledProp("openProp",n),a.useControlledProp("triggerIdProp",f),a.useContextCallback("onOpenChangeComplete",i);const I=a.useState("floatingTreeRoot"),F=xt(I),A=vt();He(()=>{w&&!u?a.update({parent:{type:"context-menu",context:w},floatingNodeId:F,floatingParentNodeId:A}):u&&a.update({floatingNodeId:F,floatingParentNodeId:A})},[w,u,F,A,a]);const O=a.useState("open"),P=a.useState("activeTriggerElement"),d=a.useState("positionerElement"),l=a.useState("hoverEnabled"),j=a.useState("modal"),K=a.useState("disabled"),de=a.useState("lastOpenChangeReason"),T=a.useState("parent"),z=a.useState("activeIndex"),Z=a.useState("payload"),Y=a.useState("floatingParentNodeId"),G=o.useRef(null),Q=Y!=null;let _;a.useSyncedValues({disabled:c,modal:T.type===void 0?x:void 0,rootId:xn()});const{openMethod:k,triggerProps:se,reset:xe}=vn(O);yn(a);const{forceUnmount:me}=bn(O,a,()=>{a.update({allowMouseEnter:!1,stickIfOpen:!0}),xe()}),le=o.useRef(T.type!=="context-menu"),oe=Pe();o.useEffect(()=>{if(O||(G.current=null),T.type==="context-menu"){if(!O){oe.clear(),le.current=!1;return}oe.start(500,()=>{le.current=!0})}},[oe,O,T.type]),Cn(O&&j&&de!==Me&&k!=="touch",d),He(()=>{!O&&!l&&a.set("hoverEnabled",!0)},[O,l,a]);const J=o.useRef(!0),ae=Pe(),E=we((v,R)=>{var Je;const q=R.reason;if(O===v&&R.trigger===P&&de===q||(R.preventUnmountOnClose=()=>{a.set("preventUnmountingOnClose",!0)},!v&&R.trigger==null&&(R.trigger=P??void 0),p==null||p(v,R),R.isCanceled))return;const Kt={open:v,nativeEvent:R.event,reason:R.reason,nested:Q};_==null||_.emit("openchange",Kt);const re=R.event;if(v===!1&&(re==null?void 0:re.type)==="click"&&re.pointerType==="touch"&&!J.current)return;if(!v&&z!==null){const Oe=a.context.itemDomElements.current[z];queueMicrotask(()=>{Oe==null||Oe.setAttribute("tabindex","-1")})}v&&q===Xe?(J.current=!1,ae.start(300,()=>{J.current=!0})):(J.current=!0,ae.clear());const Ye=(q===jn||q===lt)&&re.detail===0&&(re==null?void 0:re.isTrusted),$t=!v&&(q===wn||q==null),ke={open:v,openChangeReason:q};G.current=R.event??null;const Qe=((Je=R.trigger)==null?void 0:Je.id)??null;(Qe||v)&&(ke.activeTriggerId=Qe,ke.activeTriggerElement=R.trigger??null),a.update(ke),T.type==="menubar"&&(q===Xe||q===Le||q===Me||q===In||q===je)?a.set("instantType","group"):Ye||$t?a.set("instantType",Ye?"click":"dismiss"):a.set("instantType",void 0)}),H=o.useCallback(v=>{const R=ue(v);return R.preventUnmountOnClose=()=>{a.set("preventUnmountingOnClose",!0)},R},[a]),ge=o.useCallback(()=>{a.setOpen(!1,H(Rn))},[a,H]);o.useImperativeHandle(y,()=>({unmount:me,close:ge}),[me,ge]);let ee;T.type==="context-menu"&&(ee=T.context),o.useImperativeHandle(ee==null?void 0:ee.positionerRef,()=>d,[d]),o.useImperativeHandle(ee==null?void 0:ee.actionsRef,()=>({setOpen:E}),[E]);const te=Mn({popupStore:a,onOpenChange:E});_=te.context.events,o.useEffect(()=>{const v=({open:R,eventDetails:q})=>E(R,q);return _.on("setOpen",v),()=>{_==null||_.off("setOpen",v)}},[_,E]);const L=Pn(te,{enabled:!K,bubbles:{escapeKey:M&&T.type==="menu"},outsidePress(){var v;return T.type!=="context-menu"||((v=G.current)==null?void 0:v.type)==="contextmenu"?!0:le.current},externalTree:Q?I:void 0}),U=Sn(te,{role:"menu"}),ne=Tn(),V=o.useCallback(v=>{a.select("activeIndex")!==v&&a.set("activeIndex",v)},[a]),Ne=ss(te,{enabled:!K,listRef:a.context.itemDomElements,activeIndex:z,nested:T.type!==void 0,loopFocus:b,orientation:C,parentOrientation:T.type==="menubar"?T.context.orientation:void 0,rtl:ne==="rtl",disabledIndices:Ke,onNavigate:V,openOnArrowKeyDown:T.type!=="context-menu",externalTree:Q?I:void 0,focusItemOnHover:S}),kt=o.useCallback(v=>{a.context.typingRef.current=v},[a]),Ot=os(te,{listRef:a.context.itemLabels,activeIndex:z,resetMs:En,onMatch:v=>{O&&v!==z&&a.set("activeIndex",v)},onTypingChange:kt}),{getReferenceProps:ze,getFloatingProps:_e,getItemProps:qe,getTriggerProps:Ge}=yt([L,U,Ne,Ot]),Dt=o.useMemo(()=>{const v=Ae(ze(),{onMouseMove(){a.set("allowMouseEnter",!0)}},se);return delete v.role,v},[ze,a,se]),Ft=o.useMemo(()=>{const v=Ge();if(!v)return v;const R=Ae(v,se);return delete R.role,delete R["aria-controls"],R},[Ge,se]),At=o.useMemo(()=>_e({onMouseMove(){a.set("allowMouseEnter",!0),T.type==="menu"&&a.set("hoverEnabled",!1)},onClick(){a.select("hoverEnabled")&&a.set("hoverEnabled",!1)},onKeyDown(v){const R=a.select("keyboardEventRelay");R&&!v.isPropagationStopped()&&R(v)}}),[_e,T.type,a]),Ht=o.useMemo(()=>qe(),[qe]);a.useSyncedValues({floatingRootContext:te,activeTriggerProps:Dt,inactiveTriggerProps:Ft,popupProps:At,itemProps:Ht});const Lt=o.useMemo(()=>({store:a,parent:h}),[a,h]),Ve=t.jsx(St.Provider,{value:Lt,children:typeof r=="function"?r({payload:Z}):r});return T.type===void 0||T.type==="context-menu"?t.jsx(Nn,{externalTree:I,children:Ve}):Ve});function Qs(e={}){const{highlightItemOnHover:s,highlightedIndex:r,onHighlightedIndexChange:n}=bt(),{ref:p,index:i}=It(e),m=r===i,c=o.useRef(null),x=pt(p,c);return{compositeProps:o.useMemo(()=>({tabIndex:m?0:-1,onFocus(){n(i)},onMouseMove(){const C=c.current;if(!s||!C)return;const y=C.hasAttribute("disabled")||C.ariaDisabled==="true";!m&&!y&&C.focus()}}),[m,n,i,s]),compositeRef:x,index:i}}function Js(e){const{render:s,className:r,state:n=Te,props:p=Ke,refs:i=Ke,metadata:m,stateAttributesMapping:c,tag:x="div",...b}=e,{compositeProps:C,compositeRef:y}=Qs({metadata:m});return ye(x,e,{state:n,ref:[...i,y],props:[C,...p,b],stateAttributesMapping:c})}function Nt(e){if(kn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!On(e))return Nt(Dn(e))}function Ws(e){const{enabled:s=!0,mouseDownAction:r,open:n}=e,p=o.useRef(!1);return o.useMemo(()=>s?{onMouseDown:i=>{(r==="open"&&!n||r==="close"&&n)&&(p.current=!0,$e(i.currentTarget).addEventListener("click",()=>{p.current=!1},{once:!0}))},onClick:i=>{p.current&&(p.current=!1,i.preventBaseUIHandler())}}:Te,[s,r,n])}const Ce=2,Xs=Fn(function(s,r){const{render:n,className:p,disabled:i=!1,nativeButton:m=!0,id:c,openOnHover:x,delay:b=100,closeDelay:C=0,handle:y,payload:M,...D}=s,f=fe(!0),g=(y==null?void 0:y.store)??(f==null?void 0:f.store);if(!g)throw new Error(ve(85));const S=ft(c),w=g.useState("isTriggerActive",S),u=g.useState("floatingRootContext"),N=g.useState("isOpenedByTrigger",S),B=o.useRef(null),h=eo(),a=bt(!0),I=An(),F=o.useMemo(()=>I??new ht,[I]),A=xt(F),O=vt(),{registerTrigger:P,isMountedByThisTrigger:d}=Hn(S,B,g,{payload:M,closeDelay:C,parent:h,floatingTreeRoot:F,floatingNodeId:A,floatingParentNodeId:O,keyboardEventRelay:a==null?void 0:a.relayKeyboardEvent}),l=h.type==="menubar",j=g.useState("disabled"),K=i||j||l&&h.context.disabled,{getButtonProps:de,buttonRef:T}=ut({disabled:K,native:m});o.useEffect(()=>{!N&&h.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,N,h.type]);const z=o.useRef(null),Z=Pe(),Y=we(L=>{if(!z.current)return;Z.clear(),g.context.allowMouseUpTriggerRef.current=!1;const U=L.target;if(De(z.current,U)||De(g.select("positionerElement"),U)||U===z.current||U!=null&&Nt(U)===g.select("rootId"))return;const ne=as(z.current);L.clientX>=ne.left-Ce&&L.clientX<=ne.right+Ce&&L.clientY>=ne.top-Ce&&L.clientY<=ne.bottom+Ce||F.events.emit("close",{domEvent:L,reason:Ln})});o.useEffect(()=>{N&&g.select("lastOpenChangeReason")===Me&&$e(z.current).addEventListener("mouseup",Y,{once:!0})},[N,Y,g]);const G=l&&h.context.hasSubmenuOpen,_=Kn(u,{enabled:(x??G)&&!K&&h.type!=="context-menu"&&(!l||G&&!d),handleClose:$n({blockPointerEvents:!l}),mouseOnly:!0,move:!1,restMs:h.type===void 0?b:void 0,delay:{close:C},triggerElementRef:B,externalTree:F,isActiveTrigger:w}),k=Zs(N,g.select("lastOpenChangeReason")),se=rs(u,{enabled:!K&&h.type!=="context-menu",event:N&&l?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:h.type===void 0?k:!1}),xe=Un(u,{enabled:!K&&G}),me=Ws({open:N,enabled:l,mouseDownAction:"open"}),le=yt([se,xe]),oe={disabled:K,open:N},J=g.useState("triggerProps",d),ae=[z,r,T,P,B],E=[le.getReferenceProps(),_??Te,J,{"aria-haspopup":"menu",id:S,onMouseDown:L=>{if(g.select("open"))return;Z.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),$e(L.currentTarget).addEventListener("mouseup",Y,{once:!0})}},l?{role:"menuitem"}:{},me,D,de],H=o.useRef(null),ge=we(L=>{Ze.flushSync(()=>{g.setOpen(!1,ue(Le,L.nativeEvent,L.currentTarget))});const U=Bn(H.current);U==null||U.focus()}),ee=we(L=>{var ne;const U=g.select("positionerElement");if(U&&zn(L,U))(ne=g.context.beforeContentFocusGuardRef.current)==null||ne.focus();else{Ze.flushSync(()=>{g.setOpen(!1,ue(Le,L.nativeEvent,L.currentTarget))});let V=_n(g.context.triggerFocusTargetRef.current||B.current);for(;V!==null&&De(U,V);){const Ne=V;if(V=qn(V),V===Ne)break}V==null||V.focus()}}),te=ye("button",s,{enabled:!l,stateAttributesMapping:et,state:oe,ref:ae,props:E});return l?t.jsx(Js,{tag:"button",render:n,className:p,state:oe,refs:ae,props:E,stateAttributesMapping:et}):N?t.jsxs(o.Fragment,{children:[t.jsx(tt,{ref:H,onFocus:ge},`${S}-pre-focus-guard`),t.jsx(o.Fragment,{children:te},S),t.jsx(tt,{ref:g.context.triggerFocusTargetRef,onFocus:ee},`${S}-post-focus-guard`)]}):t.jsx(o.Fragment,{children:te},S)});function Zs(e,s){const r=Pe(),[n,p]=o.useState(!1);return He(()=>{e&&s==="trigger-hover"?(p(!0),r.start(Gn,()=>{p(!1)})):e||(r.clear(),p(!1))},[e,s,r]),n}function eo(){const e=Ee(!0),s=fe(!0),r=Et();return o.useMemo(()=>r?{type:"menubar",context:r}:e&&!s?{type:"context-menu",context:e}:{type:void 0},[e,s,r])}function to({...e}){return t.jsx(Ys,{"data-slot":"dropdown-menu",...e})}function no({...e}){return t.jsx(Xs,{"data-slot":"dropdown-menu-trigger",...e})}function so({align:e="start",alignOffset:s=0,side:r="bottom",sideOffset:n=4,className:p,...i}){return t.jsx(Us,{children:t.jsx(Bs,{className:"isolate z-50 outline-none",align:e,alignOffset:s,side:r,sideOffset:n,children:t.jsx(Ks,{"data-slot":"dropdown-menu-content",className:X("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden",p),...i})})})}function Fe({className:e,inset:s,variant:r="default",...n}){return t.jsx(Hs,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":r,className:X("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-1.5 rounded-md px-1.5 py-1 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...n})}function oo({className:e,...s}){return t.jsx(Vn,{"data-slot":"dropdown-menu-separator",className:X("bg-border -mx-1 my-1 h-px",e),...s})}function ao({className:e,...s}){return t.jsx("textarea",{"data-slot":"textarea",className:X("border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 rounded-lg border bg-transparent px-2.5 py-2 text-base transition-colors focus-visible:ring-2 aria-invalid:ring-2 md:text-sm placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50",e),...s})}function W(e){const s=e.trim();return s||void 0}function ro(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",authMode:e.type==="local"?"auto":e.authMode,password:"",privateKey:"",privateKeyPassphrase:""}:{name:"",type:"local",host:"",port:22,username:"",sshConfigRef:"",session:"tmex",authMode:"auto",password:"",privateKey:"",privateKeyPassphrase:""}}function io(e){if(e.type==="local")return{name:e.name.trim(),type:"local",session:W(e.session)??"tmex",authMode:"auto"};const s={name:e.name.trim(),type:"ssh",host:W(e.host),port:e.port,username:W(e.username),sshConfigRef:W(e.sshConfigRef),session:W(e.session)??"tmex",authMode:e.authMode};return e.authMode==="password"&&(s.password=e.password),e.authMode==="key"&&(s.privateKey=e.privateKey,s.privateKeyPassphrase=e.privateKeyPassphrase||void 0),s}function co(e){if(e.type==="local")return{name:e.name.trim(),session:W(e.session)??"tmex",authMode:"auto"};const s={name:e.name.trim(),host:W(e.host),port:e.port,username:W(e.username),sshConfigRef:W(e.sshConfigRef),session:W(e.session)??"tmex",authMode:e.authMode};return e.authMode==="password"&&e.password&&(s.password=e.password),e.authMode==="key"&&e.privateKey&&(s.privateKey=e.privateKey,s.privateKeyPassphrase=e.privateKeyPassphrase||void 0),s}async function it(e,s){try{return(await e.json()).error??s}catch{return s}}function go(){const{t:e}=be(),[s,r]=o.useState(!1),[n,p]=o.useState(null),[i,m]=o.useState(null),c=Ct();o.useEffect(()=>{const f=()=>r(!0);return window.addEventListener("tmex:open-add-device",f),()=>window.removeEventListener("tmex:open-add-device",f)},[]);const{data:x,isLoading:b,isError:C}=Yn({queryKey:["devices"],queryFn:async()=>{const f=await fetch("/api/devices");if(!f.ok)throw new Error(e("device.loadFailed"));return f.json()},throwOnError:!1}),y=Qn(f=>f.hydrateDeviceErrors);o.useEffect(()=>{x!=null&&x.devices&&y(x.devices.map(f=>({deviceId:f.id,lastError:f.lastError??null,lastErrorType:f.lastErrorType??null})))},[x,y]);const M=Se({mutationFn:async f=>{if(!(await fetch(`/api/devices/${f}`,{method:"DELETE"})).ok)throw new Error(e("device.deleteFailed"))},onSuccess:()=>{c.invalidateQueries({queryKey:["devices"]}),ce.success(e("common.success"))},onError:f=>{ce.error(f instanceof Error?f.message:e("common.error"))}}),D=(x==null?void 0:x.devices)??[];return t.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:[b?t.jsx(Ie,{children:t.jsx(Re,{className:"py-16 text-center text-sm text-muted-foreground",children:e("common.loading")})}):C?t.jsx(Ie,{children:t.jsx(Re,{className:"py-16 text-center text-sm text-destructive",children:e("device.loadFailed")})}):D.length===0?t.jsx(Ie,{children:t.jsxs(Re,{className:"space-y-4 py-14 text-center",children:[t.jsx("div",{className:"mx-auto flex h-12 w-12 items-center justify-center rounded-xl border border-border bg-muted",children:t.jsx(jt,{className:"h-6 w-6 text-muted-foreground"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("h2",{className:"text-lg font-medium",children:e("device.noDevices")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:e("device.addDevice")})]}),t.jsxs(pe,{variant:"default","data-testid":"devices-add-empty",onClick:()=>r(!0),children:[t.jsx(wt,{className:"h-4 w-4"}),e("device.addDevice")]})]})}):t.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:D.map(f=>t.jsx(lo,{device:f,onEdit:()=>p(f),onDelete:()=>m(f)},f.id))}),s&&t.jsx(ct,{mode:"create",onClose:()=>r(!1)}),n&&t.jsx(ct,{mode:"edit",device:n,onClose:()=>p(null)}),t.jsx(ls,{open:i!==null,onOpenChange:f=>!f&&m(null),children:t.jsxs(us,{children:[t.jsxs(ps,{children:[t.jsx(fs,{className:"bg-destructive/10",children:t.jsx(Rt,{className:"h-5 w-5 text-destructive"})}),t.jsx(ms,{children:e("device.deleteConfirm")}),t.jsx(gs,{children:e("device.deleteDescription",{name:(i==null?void 0:i.name)??""})})]}),t.jsxs(hs,{children:[t.jsx(xs,{children:e("common.cancel")}),t.jsx(vs,{variant:"destructive",disabled:!i||M.isPending,onClick:()=>{i&&(M.mutate(i.id),m(null))},children:e("common.delete")})]})]})})]})}function lo({device:e,onEdit:s,onDelete:r}){const{t:n}=be(),p=e.type==="local"?t.jsx(jt,{className:"h-4 w-4"}):t.jsx(Jn,{className:"h-4 w-4"}),i=e.type==="local"?n("device.typeLocal"):`${e.username??"-"}@${e.host??"-"}:${e.port??22}`,m=Se({mutationFn:async()=>{const c=await fetch(`/api/devices/${e.id}/test-connection`,{method:"POST"});let x=null;try{x=await c.json()}catch{x=null}if(!c.ok){const b=x;throw new Error((b==null?void 0:b.error)??n("common.error"))}return x},onSuccess:c=>{ce.success(c.message??n("common.success"))},onError:c=>{ce.error(c instanceof Error?c.message:n("common.error"))}});return t.jsxs(Ie,{"data-testid":"device-card","data-device-id":e.id,"data-device-name":e.name,className:"overflow-hidden",children:[t.jsxs(is,{className:"space-y-2 pb-2",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[t.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:p}),t.jsxs("div",{className:"min-w-0 space-y-0.5",children:[t.jsx(cs,{className:"line-clamp-1 text-sm",title:e.name,children:e.name}),t.jsx(ds,{className:"line-clamp-1 text-xs",children:i})]})]}),t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:t.jsxs(to,{children:[t.jsx(no,{render:t.jsx(pe,{variant:"ghost",size:"icon-sm","data-testid":`device-card-actions-${e.id}`,"aria-label":n("common.edit"),title:n("common.edit")}),children:t.jsx(bs,{className:"h-4 w-4"})}),t.jsxs(so,{align:"end",children:[t.jsxs(Fe,{"data-testid":`device-card-edit-${e.id}`,onClick:s,children:[t.jsx(js,{className:"h-4 w-4"}),n("common.edit")]}),e.type==="ssh"&&t.jsxs(Fe,{"data-testid":`device-card-test-${e.id}`,onClick:()=>m.mutate(),disabled:m.isPending,children:[t.jsx(Is,{className:"h-4 w-4"}),n("common.test")]}),t.jsx(oo,{}),t.jsxs(Fe,{"data-testid":`device-card-delete-${e.id}`,variant:"destructive",onClick:r,children:[t.jsx(Rt,{className:"h-4 w-4"}),n("common.delete")]})]})]})})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx(nt,{variant:"outline",className:"text-[11px] font-normal",children:e.type==="local"?n("device.typeLocal"):n("device.typeSSHBadge")}),e.session&&t.jsx(nt,{variant:"outline",className:"text-[11px] font-normal",children:e.session}),t.jsx(Wn,{deviceId:e.id})]})]}),t.jsxs(Re,{className:"pt-0",children:[t.jsx(Xn,{className:"mb-2"}),t.jsx("div",{className:"flex items-center justify-end",children:t.jsx(Zn,{to:`/devices/${e.id}`,"data-testid":`device-card-connect-${e.id}`,className:es({variant:"default",size:"sm"}),children:n("device.connect")})})]})]})}function ct({mode:e,device:s,onClose:r}){const{t:n}=be(),p=Ct(),[i,m]=o.useState(ro(s)),[c,x]=o.useState(!1),b=e==="edit",C=i.type==="ssh",y=Se({mutationFn:async d=>{const l=await fetch("/api/devices",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!l.ok)throw new Error(await it(l,n("device.createFailed")));return l.json()},onSuccess:()=>{p.invalidateQueries({queryKey:["devices"]}),ce.success(n("common.success")),r()},onError:d=>{ce.error(d instanceof Error?d.message:n("common.error"))}}),M=Se({mutationFn:async d=>{if(!s)throw new Error(n("apiError.deviceNotFound"));const l=await fetch(`/api/devices/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!l.ok)throw new Error(await it(l,n("device.updateFailed")));return l.json()},onSuccess:()=>{p.invalidateQueries({queryKey:["devices"]}),ce.success(n("common.success")),r()},onError:d=>{ce.error(d instanceof Error?d.message:n("common.error"))}}),D=async d=>{d.preventDefault(),x(!0);try{e==="create"?await y.mutateAsync(io(i)):await M.mutateAsync(co(i))}catch{}finally{x(!1)}},f=`${e}-device-name`,g=`${e}-device-type`,S=`${e}-device-host`,w=`${e}-device-port`,u=`${e}-device-username`,N=`${e}-device-session`,B=`${e}-device-auth-mode`,h=`${e}-device-password`,a=`${e}-device-private-key`,I=`${e}-device-private-key-passphrase`,F={local:n("device.typeLocal"),ssh:n("device.typeSSH")},A={password:n("device.authPassword"),key:n("device.authKey"),agent:n("device.authAgent"),configRef:"SSH Config"},O=d=>t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:d}),P=(d,l,j)=>t.jsxs("label",{className:"block text-xs font-medium text-foreground",htmlFor:d,children:[l,j&&t.jsx("span",{className:"ml-0.5 text-destructive",children:"*"})]});return t.jsx(Rs,{open:!0,onOpenChange:d=>!d&&r(),children:t.jsxs(Ss,{"data-testid":"device-dialog",className:"w-full max-w-2xl",children:[t.jsxs(Ts,{children:[t.jsx(Ns,{children:n(b?"device.editDevice":"device.addDevice")}),t.jsx(ks,{children:n(b?"device.editDeviceDescription":"device.addDeviceDescription")})]}),t.jsxs("form",{onSubmit:D,className:"space-y-4",children:[t.jsxs("div",{className:"-mr-2 max-h-[min(70vh,720px)] space-y-5 overflow-y-auto pr-2",children:[t.jsxs("section",{className:"space-y-2.5",children:[O(n("device.sectionBasic")),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[P(f,n("device.name"),!0),t.jsx(ie,{id:f,"data-testid":"device-name-input",type:"text",value:i.name,onChange:d=>m(l=>({...l,name:d.target.value})),placeholder:n("device.namePlaceholder"),required:!0})]}),t.jsxs("div",{className:"space-y-1.5",children:[P(g,n("device.type")),t.jsxs(st,{value:i.type,onValueChange:d=>{if(!d)return;const l=d;m(j=>({...j,type:l,authMode:l==="local"?"auto":j.authMode==="auto"?"password":j.authMode}))},disabled:b,children:[t.jsx(ot,{id:g,"data-testid":"device-type-select",className:"w-full",children:t.jsx(at,{placeholder:n("device.type"),children:d=>F[d]??""})}),t.jsxs(rt,{children:[t.jsx(he,{value:"local",children:n("device.typeLocal")}),t.jsx(he,{value:"ssh",children:n("device.typeSSH")})]})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[P(N,n("device.session")),t.jsx(ie,{id:N,"data-testid":"device-session-input",type:"text",value:i.session,onChange:d=>m(l=>({...l,session:d.target.value})),placeholder:n("device.sessionPlaceholder")})]})]})]}),C&&t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"space-y-2.5",children:[O(n("device.sectionConnection")),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[t.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[P(S,n("device.host")),t.jsx(ie,{id:S,type:"text",value:i.host,onChange:d=>m(l=>({...l,host:d.target.value})),placeholder:n("device.hostPlaceholder")})]}),t.jsxs("div",{className:"space-y-1.5",children:[P(w,n("device.port")),t.jsx(ie,{id:w,type:"number",value:i.port,onChange:d=>m(l=>({...l,port:Number.parseInt(d.target.value||"22",10)})),min:1,max:65535})]}),t.jsxs("div",{className:"space-y-1.5 sm:col-span-2",children:[P(u,n("device.username")),t.jsx(ie,{id:u,type:"text",value:i.username,onChange:d=>m(l=>({...l,username:d.target.value})),placeholder:n("device.usernamePlaceholder")})]}),t.jsxs("div",{className:"space-y-1.5",children:[P(`${e}-device-ssh-config-ref`,"SSH Config"),t.jsx(ie,{id:`${e}-device-ssh-config-ref`,type:"text",value:i.sshConfigRef,onChange:d=>m(l=>({...l,sshConfigRef:d.target.value})),placeholder:"~/.ssh/config"})]})]})]}),t.jsxs("section",{className:"space-y-2.5",children:[O(n("device.sectionAuth")),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[P(B,n("device.authMode")),t.jsxs(st,{value:i.authMode,onValueChange:d=>{d&&m(l=>({...l,authMode:d}))},children:[t.jsx(ot,{id:B,className:"w-full",children:t.jsx(at,{placeholder:n("device.authMode"),children:d=>A[d]??""})}),t.jsxs(rt,{children:[t.jsx(he,{value:"password",children:n("device.authPassword")}),t.jsx(he,{value:"key",children:n("device.authKey")}),t.jsx(he,{value:"agent",children:n("device.authAgent")}),t.jsx(he,{value:"configRef",children:"SSH Config"})]})]})]}),i.authMode==="password"&&t.jsxs("div",{className:"space-y-1.5",children:[P(h,n("device.password")),t.jsx(ie,{id:h,type:"password",value:i.password,onChange:d=>m(l=>({...l,password:d.target.value}))})]}),i.authMode==="key"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1.5",children:[P(a,n("device.privateKey")),t.jsx(ao,{id:a,value:i.privateKey,onChange:d=>m(l=>({...l,privateKey:d.target.value})),className:"h-28 font-mono text-xs",placeholder:n("device.privateKeyPlaceholder")})]}),t.jsxs("div",{className:"space-y-1.5",children:[P(I,n("device.passphrase")),t.jsx(ie,{id:I,type:"password",value:i.privateKeyPassphrase,onChange:d=>m(l=>({...l,privateKeyPassphrase:d.target.value}))})]})]})]})]})]})]}),t.jsxs(Es,{children:[t.jsx(pe,{type:"button",variant:"outline",onClick:r,children:n("common.cancel")}),t.jsx(pe,{type:"submit",variant:"default","data-testid":"device-dialog-save",disabled:c,children:n(c?"common.saving":"common.save")})]})]})]})})}function ho(){const{t:e}=be();return t.jsx(t.Fragment,{children:e("sidebar.manageDevices")})}function xo(){const{t:e}=be(),s=()=>{window.dispatchEvent(new CustomEvent("tmex:open-add-device"))};return t.jsx(pe,{variant:"ghost",size:"icon-sm","data-testid":"devices-add",onClick:s,"aria-label":e("sidebar.addDevice"),title:e("sidebar.addDevice"),children:t.jsx(wt,{className:"h-4 w-4"})})}export{xo as PageActions,ho as PageTitle,go as default};
|
|
17
|
-
//# sourceMappingURL=DevicesPage-
|
|
17
|
+
//# sourceMappingURL=DevicesPage-7Qum8nfK.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Z,u as B,a as ke,b as Se,r as i,d as fe,e as z,j as e,B as d,I as we,t as Ce,f as o,i as Ae}from"./index-
|
|
1
|
+
import{c as Z,u as B,a as ke,b as Se,r as i,d as fe,e as z,j as e,B as d,I as we,t as Ce,f as o,i as Ae}from"./index-DIffR5B7.js";import{u as b,C as $,a as I,b as _,c as D,I as u,S as $e,d as Ie,e as _e,f as De,g as ze}from"./select-B8Wx7E3G.js";import{T as Ee,A as Le,a as Qe,b as Ke,c as Oe,d as Ue,e as We,f as He,g as Ve}from"./useValueChanged-BNNSF8VN.js";import{S as f,L as Ne,a as Je}from"./switch-ByS4bhig.js";/**
|
|
2
2
|
* @license lucide-react v0.564.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -14,4 +14,4 @@ import{c as Z,u as B,a as ke,b as Se,r as i,d as fe,e as z,j as e,B as d,I as we
|
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/const Ze=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],ve=Z("shield",Ze),Y=["terminal_bell","terminal_notification","tmux_window_close","tmux_pane_close","device_tmux_missing","device_disconnect","session_created","session_closed"];async function h(t,m){try{return(await t.json()).error??m}catch{return m}}function is(){var xe,pe,be,je;const{t}=B(),m=ke(),{refreshSettings:g}=Se(),[n,r]=i.useState("site"),x=fe(s=>s.theme),v=fe(s=>s.setTheme),w=x==="dark",[j,S]=i.useState("tmex"),[C,E]=i.useState(window.location.origin),[p,y]=i.useState("en_US"),[N,P]=i.useState(6),[M,R]=i.useState(3),[T,q]=i.useState(!0),[F,a]=i.useState(!0),[c,k]=i.useState(!0),[ee,se]=i.useState(!0),[te,ae]=i.useState(2),[ne,ie]=i.useState(10),[Te,Fe]=i.useState(!1),[Q,oe]=i.useState(""),[K,re]=i.useState(""),[Be,Pe]=i.useState(null),[O,le]=i.useState(""),[U,ce]=i.useState(""),[W,de]=i.useState(Y),Me=s=>{const l=s?"dark":"light";v(l),document.documentElement.classList.toggle("dark",l==="dark")},H=z({queryKey:["site-settings"],queryFn:async()=>{const s=await fetch("/api/settings/site");if(!s.ok)throw new Error(await h(s,t("settings.loadFailed")));return await s.json()}}),V=z({queryKey:["telegram-bots"],queryFn:async()=>{const s=await fetch("/api/settings/telegram/bots");if(!s.ok)throw new Error(await h(s,t("telegram.loadBotsFailed")));return await s.json()}});i.useEffect(()=>{var l;const s=(l=H.data)==null?void 0:l.settings;s&&(S(s.siteName),E(s.siteUrl),y(s.language??"en_US"),P(s.bellThrottleSeconds),R(s.notificationThrottleSeconds??3),q(s.enableBrowserBellToast??!0),a(s.enableBrowserNotificationToast??!0),k(s.enableTelegramBellPush??!0),se(s.enableTelegramNotificationPush??!0),ae(s.sshReconnectMaxRetries),ie(s.sshReconnectDelaySeconds))},[(xe=H.data)==null?void 0:xe.settings]);const me=b({mutationFn:async()=>{const l=await fetch("/api/settings/site",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteName:j,siteUrl:C,language:p,bellThrottleSeconds:N,notificationThrottleSeconds:M,enableBrowserBellToast:T,enableBrowserNotificationToast:F,enableTelegramBellPush:c,enableTelegramNotificationPush:ee,sshReconnectMaxRetries:te,sshReconnectDelaySeconds:ne})});if(!l.ok)throw new Error(await h(l,t("settings.saveFailed")))},onSuccess:async()=>{var s,l;await Promise.all([m.invalidateQueries({queryKey:["site-settings"]}),g()]),o.success(t("settings.settingsSaved")),((l=(s=H.data)==null?void 0:s.settings)==null?void 0:l.language)!==p&&(Ae.changeLanguage(p),Fe(!0))},onError:s=>{o.error(s instanceof Error?s.message:t("common.error"))}}),J=b({mutationFn:async()=>{const s=await fetch("/api/settings/telegram/bots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Q,token:K,enabled:!0,allowAuthRequests:!0})});if(!s.ok)throw new Error(await h(s,t("telegram.createFailed")))},onSuccess:async()=>{oe(""),re(""),await m.invalidateQueries({queryKey:["telegram-bots"]}),o.success(t("common.success"))},onError:s=>{o.error(s instanceof Error?s.message:t("common.error"))}}),he=((pe=V.data)==null?void 0:pe.bots)??[],G=z({queryKey:["webhooks"],queryFn:async()=>{const s=await fetch("/api/webhooks");if(!s.ok)throw new Error(await h(s,t("webhook.loadFailed")));return await s.json()}}),X=b({mutationFn:async()=>{const s=await fetch("/api/webhooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:O,secret:U,eventMask:W})});if(!s.ok)throw new Error(await h(s,t("webhook.createFailed")))},onSuccess:async()=>{le(""),ce(""),de(Y),await m.invalidateQueries({queryKey:["webhooks"]}),o.success(t("common.success"))},onError:s=>{o.error(s instanceof Error?s.message:t("common.error"))}}),ue=b({mutationFn:async s=>{const l=await fetch(`/api/webhooks/${s}`,{method:"DELETE"});if(!l.ok)throw new Error(await h(l,t("webhook.deleteFailed")))},onSuccess:async()=>{await m.invalidateQueries({queryKey:["webhooks"]}),o.success(t("common.success"))},onError:s=>{o.error(s instanceof Error?s.message:t("common.error"))}}),ge=((be=G.data)==null?void 0:be.webhooks)??[];return e.jsxs("div",{className:"mx-auto flex w-full max-w-6xl flex-col gap-4 p-3 pb-[calc(2rem+env(safe-area-inset-bottom))] sm:gap-6 sm:p-5","data-testid":"settings-page",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(d,{type:"button",size:"sm",variant:n==="site"?"default":"outline","data-testid":"settings-tab-site",onClick:()=>r("site"),children:t("settings.siteSettings")}),e.jsx(d,{type:"button",size:"sm",variant:n==="notifications"?"default":"outline","data-testid":"settings-tab-notifications",onClick:()=>r("notifications"),children:t("settings.notificationsTab")}),e.jsx(d,{type:"button",size:"sm",variant:n==="telegram"?"default":"outline","data-testid":"settings-tab-telegram",onClick:()=>r("telegram"),children:t("telegram.title")}),e.jsx(d,{type:"button",size:"sm",variant:n==="webhooks"?"default":"outline","data-testid":"settings-tab-webhooks",onClick:()=>r("webhooks"),children:t("webhook.title")})]}),n==="site"&&e.jsxs($,{className:"border-0 ring-0",children:[e.jsx(I,{children:e.jsx(_,{children:t("settings.siteSettings")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"site-name-input",children:t("settings.siteName")}),e.jsx(u,{id:"site-name-input",value:j,onChange:s=>S(s.target.value),placeholder:t("settings.siteNamePlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"site-url-input",children:t("settings.siteUrl")}),e.jsx(u,{id:"site-url-input",value:C,onChange:s=>E(s.target.value),placeholder:t("settings.siteUrlPlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"language-select",children:t("settings.language")}),e.jsxs($e,{value:p,onValueChange:s=>{s&&y(s)},children:[e.jsx(Ie,{id:"language-select","data-testid":"settings-language-select",className:"w-full min-h-10",children:e.jsx(_e,{placeholder:t("settings.language"),children:((je=we.locales.find(s=>s.code===p))==null?void 0:je.nativeName)??p})}),e.jsx(De,{className:"max-h-[var(--tmex-viewport-height)]",children:we.locales.map(s=>e.jsx(ze,{value:s.code,children:s.nativeName},s.code))})]}),Te&&e.jsx("p",{className:"mt-1 text-xs text-primary","data-testid":"settings-refresh-notice",children:t("settings.refreshToApply")})]}),e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:t("settings.theme")})}),e.jsx(f,{checked:w,onCheckedChange:s=>Me(!!s),"data-testid":"settings-theme-toggle"})]})})]})]}),n==="notifications"&&e.jsxs($,{className:"border-0 ring-0",children:[e.jsx(I,{children:e.jsx(_,{children:t("settings.notificationsTab")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:t("settings.enableBrowserBellToast")})}),e.jsx(f,{checked:T,onCheckedChange:s=>q(!!s),"data-testid":"settings-enable-browser-bell-toast"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:t("settings.enableTelegramBellPush")})}),e.jsx(f,{checked:c,onCheckedChange:s=>k(!!s),"data-testid":"settings-enable-telegram-bell-push"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:t("settings.enableBrowserNotificationToast")})}),e.jsx(f,{checked:F,onCheckedChange:s=>a(!!s),"data-testid":"settings-enable-browser-notification-toast"})]}),e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsx("div",{className:"min-w-0 pr-2",children:e.jsx("div",{className:"text-sm font-medium",children:t("settings.enableTelegramNotificationPush")})}),e.jsx(f,{checked:ee,onCheckedChange:s=>se(!!s),"data-testid":"settings-enable-telegram-notification-push"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"bell-throttle-input",children:t("settings.bellThrottle")}),e.jsx(u,{id:"bell-throttle-input",type:"number",value:N,min:0,max:300,onChange:s=>P(Number(s.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"notification-throttle-input",children:t("settings.notificationThrottle")}),e.jsx(u,{id:"notification-throttle-input",type:"number",value:M,min:0,max:300,onChange:s=>R(Number(s.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"ssh-reconnect-retries-input",children:t("settings.sshReconnectMaxRetries")}),e.jsx(u,{id:"ssh-reconnect-retries-input",type:"number",value:te,min:0,max:20,onChange:s=>ae(Number(s.target.value)),className:"min-h-10"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"ssh-reconnect-delay-input",children:t("settings.sshReconnectDelay")}),e.jsx(u,{id:"ssh-reconnect-delay-input",type:"number",value:ne,min:1,max:300,onChange:s=>ie(Number(s.target.value)),className:"min-h-10"})]})]})]})]}),n==="telegram"&&e.jsxs($,{className:"border-0 ring-0",children:[e.jsx(I,{children:e.jsx(_,{children:t("telegram.title")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12 md:items-end",children:[e.jsxs("div",{className:"md:col-span-4 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"new-bot-name",children:t("telegram.botName")}),e.jsx(u,{id:"new-bot-name",value:Q,onChange:s=>oe(s.target.value),placeholder:t("telegram.botNamePlaceholder"),className:"min-h-10"})]}),e.jsxs("div",{className:"md:col-span-6 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"new-bot-token",children:t("telegram.botToken")}),e.jsx(u,{id:"new-bot-token",type:"password",value:K,onChange:s=>re(s.target.value),placeholder:t("telegram.botTokenPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs(d,{variant:"default",className:"w-full md:w-auto","data-testid":"telegram-add-bot",onClick:()=>J.mutate(),disabled:J.isPending||!Q.trim()||!K.trim(),children:[J.isPending?e.jsx(Ne,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),t("telegram.addBot")]})})]})}),e.jsxs("div",{className:"space-y-3",children:[V.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:t("common.loading")}),!V.isLoading&&he.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:t("telegram.addBot")}),he.map(s=>e.jsx(es,{bot:s,expanded:Be===s.id,onToggleExpand:()=>{Pe(l=>l===s.id?null:s.id)}},s.id))]})]})]}),n==="webhooks"&&e.jsxs($,{className:"border-0 ring-0",children:[e.jsx(I,{children:e.jsx(_,{children:t("webhook.title")})}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12 md:items-end",children:[e.jsxs("div",{className:"md:col-span-6 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"webhook-url-input",children:t("webhook.url")}),e.jsx(u,{id:"webhook-url-input","data-testid":"webhook-url-input",value:O,onChange:s=>le(s.target.value),placeholder:"https://example.com/webhook",className:"min-h-10"})]}),e.jsxs("div",{className:"md:col-span-4 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:"webhook-secret-input",children:t("webhook.secret")}),e.jsx(u,{id:"webhook-secret-input","data-testid":"webhook-secret-input",value:U,onChange:s=>ce(s.target.value),placeholder:t("webhook.secretPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs(d,{variant:"default",className:"w-full md:w-auto","data-testid":"webhook-add",onClick:()=>X.mutate(),disabled:X.isPending||!O.trim()||!U.trim()||W.length===0,children:[X.isPending?e.jsx(Ne,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),t("webhook.add")]})})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium",children:t("webhook.eventMask")}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:Y.map(s=>{const l=W.includes(s);return e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-4 rounded-lg border border-border bg-background px-3 py-2",children:[e.jsx("div",{className:"min-w-0 pr-2 text-sm font-medium",children:t(`notification.eventType.${s}`)}),e.jsx(f,{checked:l,"data-testid":`webhook-event-${s}`,onCheckedChange:Re=>{de(A=>Re?A.includes(s)?A:[...A,s]:A.filter(qe=>qe!==s))}})]},s)})})]}),e.jsxs("div",{className:"space-y-2",children:[G.isLoading&&e.jsx("div",{className:"text-sm text-muted-foreground",children:t("common.loading")}),!G.isLoading&&ge.length===0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:t("webhook.empty")}),ge.map(s=>e.jsxs("div",{"data-testid":"webhook-item","data-webhook-url":s.url,className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-card px-4 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.url}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(s.createdAt).toLocaleString(Ce(p))})]}),e.jsx(d,{variant:"ghost",size:"icon-sm","data-testid":"webhook-delete",onClick:()=>ue.mutate(s.id),disabled:ue.isPending,"aria-label":t("common.delete"),title:t("common.delete"),children:e.jsx(Ee,{className:"h-4 w-4"})})]},s.id))]})]})]}),(n==="site"||n==="notifications")&&e.jsx("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end",children:e.jsxs(d,{variant:"default","data-testid":"settings-save",onClick:()=>me.mutate(),disabled:me.isPending,className:"w-full sm:w-auto",children:[e.jsx(L,{className:"h-4 w-4"}),t("common.save")]})})]})}function es({bot:t,expanded:m,onToggleExpand:g}){var F;const{t:n}=B(),r=ke(),[x,v]=i.useState(t.name),[w,j]=i.useState(""),[S,C]=i.useState(t.enabled),[E,p]=i.useState(t.allowAuthRequests);i.useEffect(()=>{v(t.name),C(t.enabled),p(t.allowAuthRequests)},[t.allowAuthRequests,t.enabled,t.name]);const y=z({queryKey:["telegram-bot-chats",t.id],enabled:m,queryFn:async()=>{const a=await fetch(`/api/settings/telegram/bots/${t.id}/chats`);if(!a.ok)throw new Error(await h(a,n("telegram.loadChatsFailed")));return await a.json()}}),N=i.useMemo(()=>{var c;const a=((c=y.data)==null?void 0:c.chats)??[];return{pending:a.filter(k=>k.status==="pending"),authorized:a.filter(k=>k.status==="authorized")}},[(F=y.data)==null?void 0:F.chats]),P=b({mutationFn:async()=>{const a={name:x,enabled:S,allowAuthRequests:E};w.trim()&&(a.token=w.trim());const c=await fetch(`/api/settings/telegram/bots/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!c.ok)throw new Error(await h(c,n("telegram.updateFailed")))},onSuccess:async()=>{j(""),await r.invalidateQueries({queryKey:["telegram-bots"]}),o.success(n("common.success"))},onError:a=>{o.error(a instanceof Error?a.message:n("common.error"))}}),M=b({mutationFn:async()=>{const a=await fetch(`/api/settings/telegram/bots/${t.id}`,{method:"DELETE"});if(!a.ok)throw new Error(await h(a,n("telegram.deleteFailed")))},onSuccess:async()=>{await r.invalidateQueries({queryKey:["telegram-bots"]}),o.success(n("common.success"))},onError:a=>{o.error(a instanceof Error?a.message:n("common.error"))}}),R=b({mutationFn:async a=>{const c=await fetch(`/api/settings/telegram/bots/${t.id}/chats/${encodeURIComponent(a)}/approve`,{method:"POST"});if(!c.ok)throw new Error(await h(c,n("telegram.approveFailed")))},onSuccess:async()=>{await Promise.all([r.invalidateQueries({queryKey:["telegram-bots"]}),r.invalidateQueries({queryKey:["telegram-bot-chats",t.id]})]),o.success(n("common.success"))},onError:a=>{o.error(a instanceof Error?a.message:n("common.error"))}}),T=b({mutationFn:async a=>{const c=await fetch(`/api/settings/telegram/bots/${t.id}/chats/${encodeURIComponent(a)}`,{method:"DELETE"});if(!c.ok)throw new Error(await h(c,n("telegram.removeFailed")))},onSuccess:async()=>{await Promise.all([r.invalidateQueries({queryKey:["telegram-bots"]}),r.invalidateQueries({queryKey:["telegram-bot-chats",t.id]})]),o.success(n("common.success"))},onError:a=>{o.error(a instanceof Error?a.message:n("common.error"))}}),q=b({mutationFn:async a=>{const c=await fetch(`/api/settings/telegram/bots/${t.id}/chats/${encodeURIComponent(a)}/test`,{method:"POST"});if(!c.ok)throw new Error(await h(c,n("telegram.testMessageFailed")))},onSuccess:()=>{o.success(n("common.success"))},onError:a=>{o.error(a instanceof Error?a.message:n("common.error"))}});return e.jsxs("div",{className:"space-y-4 rounded-md border-0 bg-card p-4","data-testid":`telegram-bot-card-${t.id}`,"data-bot-name":t.name,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.authorizedCount," / ",t.pendingCount]})]}),e.jsx(d,{variant:"ghost","data-testid":`telegram-bot-toggle-${t.id}`,onClick:g,children:n(m?"common.collapse":"common.expand")})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-12 md:items-end",children:[e.jsxs("div",{className:"md:col-span-3 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:`bot-name-${t.id}`,children:n("telegram.botName")}),e.jsx(u,{id:`bot-name-${t.id}`,value:x,onChange:a=>v(a.target.value),className:"min-h-10"})]}),e.jsxs("div",{className:"md:col-span-4 space-y-2",children:[e.jsx("label",{className:"block text-sm font-medium",htmlFor:`bot-token-${t.id}`,children:n("telegram.botToken")}),e.jsx(u,{id:`bot-token-${t.id}`,type:"password",value:w,onChange:a=>j(a.target.value),placeholder:n("telegram.tokenPlaceholder"),className:"min-h-10"})]}),e.jsx("div",{className:"md:col-span-2",children:e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium",children:n("common.enabled")}),e.jsx(f,{checked:S,onCheckedChange:a=>C(!!a)})]})}),e.jsx("div",{className:"md:col-span-3",children:e.jsxs("div",{className:"flex min-h-10 items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium",children:n("telegram.allowAuthRequests")}),e.jsx(f,{checked:E,onCheckedChange:a=>p(!!a)})]})})]}),e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-end",children:[e.jsxs(d,{variant:"destructive","data-testid":`telegram-bot-delete-${t.id}`,onClick:()=>M.mutate(),className:"w-full sm:w-auto",children:[e.jsx(Ee,{className:"h-4 w-4"}),n("telegram.deleteBot")]}),e.jsxs(d,{variant:"default","data-testid":`telegram-bot-save-${t.id}`,onClick:()=>P.mutate(),className:"w-full sm:w-auto",children:[e.jsx(L,{className:"h-4 w-4"}),n("common.save")]})]}),m&&e.jsxs("div",{className:"grid grid-cols-1 gap-4 border-t border-border pt-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-1",children:[e.jsx(ve,{className:"h-4 w-4"}),n("telegram.pendingChats")]}),N.pending.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"-"}),N.pending.map(a=>e.jsx(ye,{chat:a,pending:!0,onApprove:()=>R.mutate(a.chatId),onDelete:()=>T.mutate(a.chatId)},`${a.botId}-${a.chatId}`))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-1",children:[e.jsx(ve,{className:"h-4 w-4"}),n("telegram.chats")]}),N.authorized.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"-"}),N.authorized.map(a=>e.jsx(ye,{chat:a,pending:!1,onTest:()=>q.mutate(a.chatId),onDelete:()=>T.mutate(a.chatId)},`${a.botId}-${a.chatId}`))]}),y.isLoading&&e.jsx("div",{className:"lg:col-span-2 text-xs text-muted-foreground",children:n("common.loading")})]})]})}function ye({chat:t,pending:m,onApprove:g,onDelete:n,onTest:r}){const{t:x}=B(),v=Se(w=>{var j;return((j=w.settings)==null?void 0:j.language)??"en_US"});return e.jsxs("div",{className:"space-y-2 rounded border-0 bg-background p-3",children:[e.jsx("div",{className:"text-sm font-medium truncate",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[x("telegram.chatId"),":",t.chatId]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(t.appliedAt).toLocaleString(Ce(v))}),e.jsx("div",{className:"flex items-center justify-end gap-2 pt-1",children:m?e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"outline",size:"sm",onClick:n,children:x("telegram.reject")}),e.jsx(d,{variant:"default",size:"sm",onClick:g,children:x("telegram.authorize")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(d,{variant:"secondary",size:"sm",onClick:r,children:[e.jsx(Je,{className:"h-3.5 w-3.5"}),x("telegram.sendTestMessage")]}),e.jsx(d,{variant:"destructive",size:"sm",onClick:n,children:x("common.delete")})]})})]})}function os(){const{t}=B();return e.jsx(e.Fragment,{children:t("sidebar.settings")})}function rs(){const{t}=B(),[m,g]=i.useState(!1),n=b({mutationFn:async()=>{const r=await fetch("/api/settings/restart",{method:"POST"});if(!r.ok)throw new Error(await h(r,t("settings.restartFailed")))},onSuccess:()=>{o.success(t("settings.restartScheduled"))},onError:r=>{o.error(r instanceof Error?r.message:t("common.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"ghost",size:"icon-sm",onClick:()=>g(!0),disabled:n.isPending,"aria-label":t("settings.restartGateway"),title:t("settings.restartGateway"),className:"text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsx(Le,{open:m,onOpenChange:g,children:e.jsxs(Qe,{children:[e.jsxs(Ke,{children:[e.jsx(Oe,{children:t("settings.restartGateway")}),e.jsx(Ue,{children:t("settings.restartConfirm")})]}),e.jsxs(We,{children:[e.jsx(He,{onClick:()=>g(!1),children:t("common.cancel")}),e.jsx(Ve,{variant:"destructive",onClick:()=>{n.mutate(),g(!1)},children:t("common.confirm")})]})]})})]})}export{rs as PageActions,os as PageTitle,is as default};
|
|
17
|
-
//# sourceMappingURL=SettingsPage-
|
|
17
|
+
//# sourceMappingURL=SettingsPage-CcYjvVBK.js.map
|