@jingyi0605/codingns 0.5.0 → 0.5.1

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.
Files changed (76) hide show
  1. package/dist/public/assets/AdaptiveButlerPage-SffCV4Vb.js +3 -0
  2. package/dist/public/assets/App-WOLwMld_.js +30 -0
  3. package/dist/public/assets/{BootstrapPage-Vu5oEJ8z.js → BootstrapPage--zExdgfM.js} +1 -1
  4. package/dist/public/assets/{ConversationPage-Cjpg6g0J.js → ConversationPage-D9pzRmOg.js} +2 -2
  5. package/dist/public/assets/{DesktopDetachPreviewPage-BgeEqbc5.js → DesktopDetachPreviewPage-DvI9CIKi.js} +1 -1
  6. package/dist/public/assets/{DesktopWindowPage-1WelvxdH.js → DesktopWindowPage-D8FpOSLE.js} +1 -1
  7. package/dist/public/assets/FileContextPanel-C8T7oqRN.js +1 -0
  8. package/dist/public/assets/GitSidebar-Bze7DNnc.js +6 -0
  9. package/dist/public/assets/{MobileCreateSessionSheet-DLq5qPkx.js → MobileCreateSessionSheet-CXSKMnYn.js} +1 -1
  10. package/dist/public/assets/MobileSheet-Gzc14EpR.js +1 -0
  11. package/dist/public/assets/{MobileTopHeaderFrame-DArgZI7L.js → MobileTopHeaderFrame-BWorAJ1C.js} +1 -1
  12. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-0ywJKfBQ.js → MobileWorkspaceSwitcherHeader-DOr4pTUq.js} +1 -1
  13. package/dist/public/assets/{ServerSettingsModal-izoYMx9U.js → ServerSettingsModal-BYB0GvTl.js} +1 -1
  14. package/dist/public/assets/{SessionIndexPage-C5aG8FIv.js → SessionIndexPage-CR3IARXX.js} +1 -1
  15. package/dist/public/assets/SettingsPage-B_BQtnwE.js +1 -0
  16. package/dist/public/assets/TerminalManagerPanel-PQ-EM64j.js +1 -0
  17. package/dist/public/assets/{TerminalPage-CtKXIU0h.js → TerminalPage-CvnHXBhw.js} +12 -12
  18. package/dist/public/assets/{TerminalRuntimeFallbackModal-CRhOQOsT.js → TerminalRuntimeFallbackModal-D7Aq186N.js} +1 -1
  19. package/dist/public/assets/{ToolFilesPage-DcYPsS-e.js → ToolFilesPage-Qzkc6K2I.js} +1 -1
  20. package/dist/public/assets/{ToolGitPage-CsPl89ty.js → ToolGitPage-BdNDN-cV.js} +1 -1
  21. package/dist/public/assets/{ToolProcessesPage-D0dvR8xK.js → ToolProcessesPage-EXJ9DHWI.js} +1 -1
  22. package/dist/public/assets/{ToolsHomePage-4fP-KRiv.js → ToolsHomePage-CjF3CWzR.js} +1 -1
  23. package/dist/public/assets/{WorkbenchLandingPage-kvlfyxRo.js → WorkbenchLandingPage-DZPk4SmX.js} +1 -1
  24. package/dist/public/assets/WorkbenchLayout-rwQib5In.js +3 -0
  25. package/dist/public/assets/{WorkbenchModal-Ctob14VR.js → WorkbenchModal-B09hC9b5.js} +1 -1
  26. package/dist/public/assets/WorkbenchShellRoute-Cerk5uK7.js +1 -0
  27. package/dist/public/assets/WorkbenchShellRoute-DsW4mBTX.css +1 -0
  28. package/dist/public/assets/{WorkspaceDebugDetailPage-Com5kEXJ.js → WorkspaceDebugDetailPage-Bcq8s-Ma.js} +1 -1
  29. package/dist/public/assets/WorkspaceDetailPage-DNAa8pKr.js +1 -0
  30. package/dist/public/assets/WorkspaceHomePage-BoiLuACV.js +1 -0
  31. package/dist/public/assets/client-runtime-manager-CRQ-F5d2.js +1 -0
  32. package/dist/public/assets/{default-session-permission-mode-CcGwR4Kk.js → default-session-permission-mode-D0wZ9Jek.js} +1 -1
  33. package/dist/public/assets/{file-tree-icon-UFVoVzhM.js → file-tree-icon-Dp_xhVfD.js} +14 -14
  34. package/dist/public/assets/index-C2G8Gmf1.js +42 -0
  35. package/dist/public/assets/{index-_52jxu4a.css → index-CpPTUeA3.css} +1 -1
  36. package/dist/public/assets/{preferences-service-KIYeE2gk.js → preferences-service-gOt2ZjKZ.js} +1 -1
  37. package/dist/public/assets/{session-runtime-machine-0KNSSPp5.js → session-runtime-machine-Dq3pW-UF.js} +8 -8
  38. package/dist/public/assets/{terminal-runtime-meta-AWXJpN4r.js → terminal-runtime-meta-BMT-rSEe.js} +1 -1
  39. package/dist/public/assets/{useRegisteredDebugTemplates-DBDRdptr.js → useRegisteredDebugTemplates-zMcEOGca.js} +1 -1
  40. package/dist/public/index.html +2 -2
  41. package/dist/server/modules/client/client-controller.js +1 -1
  42. package/dist/server/modules/client/client-controller.js.map +1 -1
  43. package/dist/server/modules/client/client-service.d.ts +16 -2
  44. package/dist/server/modules/client/client-service.js +21 -3
  45. package/dist/server/modules/client/client-service.js.map +1 -1
  46. package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +2 -1
  47. package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +203 -8
  48. package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
  49. package/dist/server/modules/workbench/snapshot-revision.d.ts +4 -0
  50. package/dist/server/modules/workbench/snapshot-revision.js +13 -0
  51. package/dist/server/modules/workbench/snapshot-revision.js.map +1 -0
  52. package/dist/server/modules/workbench/workbench-service.d.ts +1 -0
  53. package/dist/server/modules/workbench/workbench-service.js +3 -2
  54. package/dist/server/modules/workbench/workbench-service.js.map +1 -1
  55. package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +6 -1
  56. package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +10 -8
  57. package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
  58. package/dist/server/server/create-server.js +1 -1
  59. package/dist/server/server/create-server.js.map +1 -1
  60. package/dist/server/types/domain.d.ts +9 -0
  61. package/dist/server/ws/workbench-ws-hub.js +135 -33
  62. package/dist/server/ws/workbench-ws-hub.js.map +1 -1
  63. package/package.json +1 -1
  64. package/dist/public/assets/AdaptiveButlerPage-R-XZw7pd.js +0 -3
  65. package/dist/public/assets/App-DkvE5EyM.js +0 -30
  66. package/dist/public/assets/FileContextPanel-D_ghXJuW.js +0 -1
  67. package/dist/public/assets/GitSidebar-D9f9Jxwr.js +0 -6
  68. package/dist/public/assets/MobileSheet-DLg-gX1t.js +0 -1
  69. package/dist/public/assets/SettingsPage-HJIC-P-4.js +0 -1
  70. package/dist/public/assets/TerminalManagerPanel-DpyUTo9k.js +0 -1
  71. package/dist/public/assets/WorkbenchLayout-ByFw4eeu.js +0 -3
  72. package/dist/public/assets/WorkbenchShellRoute-BUITtdAg.css +0 -1
  73. package/dist/public/assets/WorkbenchShellRoute-Kw7JEZI3.js +0 -1
  74. package/dist/public/assets/WorkspaceDetailPage-D0Lrx4Uz.js +0 -1
  75. package/dist/public/assets/WorkspaceHomePage-wR8d3aP9.js +0 -1
  76. package/dist/public/assets/index-Byp9hJ0c.js +0 -42
@@ -1 +0,0 @@
1
- var V=Object.defineProperty;var Z=(e,s,n)=>s in e?V(e,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[s]=n;var R=(e,s,n)=>Z(e,typeof s!="symbol"?s+"":s,n);import{z as i,A as Y,b as w,t as g,j as t}from"./index-Byp9hJ0c.js";import{d as X,f as H}from"./App-DkvE5EyM.js";function $(){return i.request("/api/workspaces")}async function De(){try{return await i.request("/api/workbench")}catch(e){if(!(e instanceof Y)||e.status!==404)throw e;const s=await $();return{items:await Promise.all(s.items.map(async o=>({workspace:o,sessions:(await _(o.id)).items})))}}}function Pe(e){return i.request("/api/workspaces/import",{method:"POST",body:JSON.stringify(e)})}function Oe(e){return i.request("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})}function Ne(e){return i.request(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})}function Ie(e){return i.request("/api/debug-targets/analyze",{method:"POST",body:JSON.stringify(e)})}function Ee(e,s){return i.request(`/api/debug-targets/${encodeURIComponent(e)}/launch-plan`,{method:"POST",body:JSON.stringify({})})}function qe(){return i.request("/api/framework-compatibility-matrix")}function xe(e){return i.request("/api/workspaces/reorder",{method:"PUT",body:JSON.stringify(e)})}function be(e,s){return i.request(`/api/workspaces/${encodeURIComponent(e)}/navigation-state`,{method:"PUT",body:JSON.stringify(s)})}function Le(e){const s=new URLSearchParams;return e!=null&&e.trim()&&s.set("path",e.trim()),i.request(`/api/workspaces/browse${s.size>0?`?${s.toString()}`:""}`)}function Ue(e){return i.request("/api/workspaces/directories",{method:"POST",body:JSON.stringify(e)})}function _(e){return i.request(`/api/sessions?workspaceId=${encodeURIComponent(e)}`)}function Be(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`)}function Te(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/changed-files`)}function Me(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/seen`,{method:"POST"})}function je(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/title`,{method:"PATCH",body:JSON.stringify({title:s})})}function Fe(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/archive`,{method:"PATCH",body:JSON.stringify({archived:s})})}function ke(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/favorite`,{method:"PATCH",body:JSON.stringify({favorite:s})})}function Je(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Ke(e){return i.request("/api/worktrees",{method:"POST",body:JSON.stringify(e)})}function Qe(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-preview`,{method:"POST"})}function Ge(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-into-parent`,{method:"POST"})}function ze(e,s){return i.request(`/api/worktrees/${encodeURIComponent(e)}/cleanup`,{method:"POST",body:JSON.stringify(s??{})})}function We(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/capabilities`)}function Ve(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests`)}function Ze(){return i.request("/api/preferences/quick-phrases")}function Ye(e){return i.request("/api/preferences/quick-phrases",{method:"PUT",body:JSON.stringify({items:e})})}function ee(e,s){const n=new URLSearchParams;return s!=null&&s.trim()&&n.set("workspaceId",s.trim()),i.request(`/api/providers/${encodeURIComponent(e)}/capabilities${n.size>0?`?${n.toString()}`:""}`)}async function se(e,s){const n=await Promise.allSettled(e.map(async r=>[r,await ee(r,s)])),o=[];for(const r of n){if(r.status!=="fulfilled")continue;const[u,l]=r.value;o.push([u,l])}return Object.fromEntries(o)}function Xe(e,s,n,o="forward"){const r=new URLSearchParams;return s&&r.set("cursor",s),r.set("limit",String(n)),r.set("direction",o),i.request(`/api/sessions/${encodeURIComponent(e)}/messages?${r.toString()}`)}function He(e,s){return i.requestBlob(`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(s)}/content`)}function $e(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(s)})}function _e(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/forks`,{method:"POST",body:JSON.stringify(s)})}function es(e){return i.request("/api/sessions/start-live",{method:"POST",body:JSON.stringify(e)})}function ss(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages/live`,{method:"POST",body:JSON.stringify(s)})}function ns(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`)}function ts(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"POST",body:JSON.stringify(s)})}function os(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(s)}`,{method:"DELETE"})}function rs(e,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(s)}/steer`,{method:"POST"})}function is(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/runtime`)}function as(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:"POST"})}function us(e,s,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests/${encodeURIComponent(s)}/reply`,{method:"POST",body:JSON.stringify(n)})}const I="codingns.workspace.session-display-sort-mode",E="codingns.file-panel.show-system-files",L="codingns.notification.preferences",C={notifyOnPermissionRequest:!0,notifyOnSessionCompleted:!0,notifyOnSessionFailed:!0};function D(){return typeof window<"u"&&typeof window.localStorage<"u"}function ne(e){return e==="createdAt"||e==="updatedAt"||e==="title"}function T(){if(!D())return"createdAt";const e=window.localStorage.getItem(I);return ne(e)?e:"createdAt"}function M(){return D()?window.localStorage.getItem(E)==="1":!1}function b(e){return typeof e=="boolean"}function j(){if(!D())return C;const e=window.localStorage.getItem(L);if(!e)return C;try{const s=JSON.parse(e);return{notifyOnPermissionRequest:b(s.notifyOnPermissionRequest)?s.notifyOnPermissionRequest:C.notifyOnPermissionRequest,notifyOnSessionCompleted:b(s.notifyOnSessionCompleted)?s.notifyOnSessionCompleted:C.notifyOnSessionCompleted,notifyOnSessionFailed:b(s.notifyOnSessionFailed)?s.notifyOnSessionFailed:C.notifyOnSessionFailed}}catch{return C}}function F(e,s){return e.notifyOnPermissionRequest===s.notifyOnPermissionRequest&&e.notifyOnSessionCompleted===s.notifyOnSessionCompleted&&e.notifyOnSessionFailed===s.notifyOnSessionFailed}function te(e){D()&&window.localStorage.setItem(L,JSON.stringify(e))}class oe{constructor(){R(this,"state",{sessionDisplaySortMode:T(),showSystemFiles:M(),notificationPreferences:j()});R(this,"listeners",new Set);R(this,"subscribe",s=>(this.listeners.add(s),()=>{this.listeners.delete(s)}));R(this,"getState",()=>this.state);R(this,"handleStorage",s=>{if(s.key!==null&&s.key!==I&&s.key!==E&&s.key!==L)return;const n=T(),o=M(),r=j(),u=this.state.sessionDisplaySortMode===n,l=this.state.showSystemFiles===o,d=F(this.state.notificationPreferences,r);u&&l&&d||(this.state={sessionDisplaySortMode:n,showSystemFiles:o,notificationPreferences:r},this.emit())});typeof window<"u"&&window.addEventListener("storage",this.handleStorage)}setSessionDisplaySortMode(s){D()&&(s==="createdAt"?window.localStorage.removeItem(I):window.localStorage.setItem(I,s)),this.state.sessionDisplaySortMode!==s&&(this.state={...this.state,sessionDisplaySortMode:s},this.emit())}setShowSystemFiles(s){D()&&(s?window.localStorage.setItem(E,"1"):window.localStorage.removeItem(E)),this.state.showSystemFiles!==s&&(this.state={...this.state,showSystemFiles:s},this.emit())}setNotificationPreferences(s){const n={...this.state.notificationPreferences,...s};F(this.state.notificationPreferences,n)||(te(n),this.state={...this.state,notificationPreferences:n},this.emit())}emit(){for(const s of this.listeners)s()}}const k=new oe;function ls(e){return w.useSyncExternalStore(k.subscribe,()=>e(k.getState()))}function re(){return X().haptics}const ie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAF+0lEQVRYha2XbXBUZxXHf+e5u4SkCZjg0NIWnQLJLgRF5UWnL75MP9gMjqPT2eyC0qlMiYxOUAR206LOyhiSTVscp52O0xamWgu7WTp0qLUz6kht6Qed1L7M5GUTsAoDTRSIJJos2b33+GFfWMJuNqmcT/c595z/+d3nOc+9zxXKWE9Li7tm0fjyqmT6H0t/Fp8sFz9XM+UCauouH8Rx+ifmWWdP7Q0sLRbT98g3lySC/mcSQd+GGwrQt2vzx1G2ZEa6KJ3S1mJxlpOKIDyEmEM3FGCk5vw5YCw3FmFbb9hXfV2gcm/26vINBfhS+LU0qgcKXB9xT1hbr6kdDhtgcYaDxHSNwVBg92Ao0DMY8n97zgAAZnK8U2AoX1D0++rzWfkC44k6wAVghP7C3EQo8Iiijyq61oEDiV2bPjojwKk234pEsPnh/lDgzpyv/olXrwi6qyDsjsQy2ZQXmJdefPWWvp0v3uZ/CLQ9NxZINpxJj84IYDvmOUT2G/T1DD0CUB/pflnhd1eT5Mcnwl90Adi23JzPl9TbAEN7fF9AeapQW5AOicftGQFEOJ+9tEDbB9v8x99r21wLYBlnJ5AGUKhfklz8QEbY3J71nVnZceziUPAbtzvGxAB3wdPH6yPRx6cXvw4gbbm/B5zIO5SvVKjdMxAMrKvviPcpHMyLqvyoN+ybh7AUwIi+M9TaVOGI/SJwc4Fsf6rS2SqgxQBkukPDYTM40RdCZB/Z5gKmEGmzjStq2alBoDqbvF2hEWgF9oEuAvlugdx/Deaz9ZEjvcWKFwXIWaLNv14cDqmwugDvFRVOi8qOrOMdhT6BzQhvoNxzjbjItxo6o8+VqjEjAMBQa1OFXbXwh4KGuLqmDleXToHzwG1FpLs9kah/uvf98IPz08nkSuZbp+vDL4zNCJAHaQt82lH9JfCJ2cQrTFjq8hiZGrfVtQGcDQhrFNYAywELuFw15SwRgN6dvrrahcnkreGXJ0pCtDZVOFULwsCerEBJExhVGAY8FH/Z2cBvPJHY1ySx13cbaXMaqACSwCVRLqlhVNBRVTOm4lxCOSdqPkB0FdA2m5kosGGEHpC3UP2z6uRJb9fx8SwsJEL+nwBNwEKgWqBSoXaORQqtH+VNhDdErJMNnYf/ViqwbBNO3lRbVZFSS9yyIG1jucRuVuGnM6TZZL4d/wS9KEgawIH/gF5EzAWBvzecto9KPG7PqgkBTu0NLHVs7VBlcxnwS8ALgtyp6Kco3S9/OF850lQWYCD41RpMZUiUH5BZmgkRDqmyVaCqeJYeS1dqwJq4UoG56S5w7hb4PMp6YH426LJR1+qSAOrzWYPLZCvIPuAWAIHXxGGXY3geWAV6DOTrJRR+r5q8P9dskNtJ1etBVl4R19FPdh4eLQowEPR5RKxfgebOeGMqGvLMX/V0YrK/W+B+4ATCYZRnEJ5E+Q5gFM4AFwQ+I8hbLks2Ltt/ZKTUg163Rwfamrcj5q/54spvLZes9nZ2/yIx0b8jW/wCLmeLOLoCAEdeAjmYnaWPGXga9Jiia1O28+bAbt8dswJQEFF5IrO2chGVBzxdsY0r2qNnBx5uvkuELkAFedDTHj+nIl4AIzJsjL2XTAOisB+XtqryKLBcLHNyKLSpsSyAgKrKJoRtbksaPV3R5yFz7BaHOOBGOdAQib6SRV4L4KQZqe+I/wvYmZWqE1ue8nbFggjbgDoH/VOxY3vZXdDT0uKuqR37I+jdIH9JV9r3NIbjU717fLe4jPkASDVEYhW5730i2PwqIvdlZkK3eCPdv06E/GuAbmCBJxJbUnIGill13b8fyxRnRG070BiOTwG4MeuyszBSeNiw3KZFYDTzdPLzU7u3LPZEYu+qTq5Tlev+K2YESAQD94rKjqzgl72Pxd/P3VNLsgAyXJizoj161kG3Z4d1aZP6HIC36/i4tyt6dE4AasQNDIhxNnoisXevvZndJcLw9DxvpLsb5XGE9yzD2ZlqzPpVPN0SIf854FaUZz1dsW0fVqdsD5Q05Qhgg7z+oTX+Xyv2pzNX+x+eTlGviPgh3AAAAABJRU5ErkJggg==",Q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbGSURBVHgBzZo/bBtVHMd/ZzuJA0gYCYlsOFO7xRFDy1R3olucqd0SJtiSjiCknBckpjZjBxRn7BR3owOqs5Wp7tZKoDgSQysh4UqUOCG2eZ/3/Oznv/fObqJ+pfPZd+/ufn++vz/vnQN5FwjbGZFGQSRYUb+yIu2c2tSxIOOMqpktqKpzz9X3ioSLNZkRgUwLhA4aW9KWvPqVl6mgldmVGZSJr0BX8Pb2gIVnRUltxbiKxFOgeLJzAYL3I5BQdhaL/sN9EJ5k1dADw+1LQU1tN328kYgaIMWzDSX4s0sUHmSVwZ5JeFqIGjhZgeKpokyzdKGUGQuyWOtA03YCxlNIC98K5X3AhLgYrYB2ndLeE5l0IFvXklK4mpRsxvyuvmqrrSX71aZUjlsyM4LkpuzM7w8dHhqoAxbO+9Fm63pSwhspLTSo1dt6n830bl1SStx9fK6/Z9LmWL3B1hZ/BHUl1+pgYI9S4Eh0EEVjJ5/SwiPI7m9Nuf+02SfUZi4pO+o8ynDcKmlRqRkPlZ43xQ+q8IXpVfdIsu88vJd2ZOSD/OcJKRXmtMW//PlMyi9a0jjvH5NZCDStEDydCjSlfvm9pa/hd24poc+zf/zH8PUjsCT57wOp/FjpqtQ9pakjR+KJo60Fbdnl3dMubSw4vrc2J/msSXLlF4ZCg+M4zzjGEzM39888aAWVFpYlZN+fRnfEE1iMh8JtVygsDWWefTOvhYMiCLX+8L8h4QHnVx+cas/klgLZvpb0eDrp9d/trjr609P6brbhgesPDXXA5kpS7t0ywYwVi4fERD8noJ1WfIDzBDYeRRw8GscL1gP5iCv0g7FsqAIX4UH9pHeegEb44uG5EuKsT3iuPbg9J08252VPxQ3CoowFGYlgRhEMEY2eFzp3CbbEQ3j28BnXjwI0CSvnXQu6lMJrnOd67qOV6fAf2HuuLPn2l4kbRgGT9yf2OU825o11lXDw+bgenb8LV5JdjwE8s/rAxMPXj0xMkGbxBkpWX8epCRp5WvuERNAHl9qADQ+j8xz0QuGDOz3rIizXW8/wHa7bzISSKAveNCQGGoVElPU3coaTcDQKhmoL3QxEkLMna2FplzKAOCFLGf6b4x+nJQbauURnHjsWWJQg8+1nsChCsZGh2LuUwTvb11J94zfVeVtPGOOej4CuNNlJI2xa9BUeQQaD3FKG83iAdItHClcSQ4rzLJvRohGsRCowqoexyCxKbNiUqVPrnf5MhBL0VKRTv6IWZCJnZJR4bujm7eprY+GD2/M6g/hZyypgKENGspThHha2fqxdjZ4sUg8iRz16aYLXBrN5SLPLa5tBMrGCT3T7wD0GgYcM1XwU0IWsXZ80wPY7WMpVguM2g0ABvMDmZhkXZox4w3dswvQV44FFSIe4vqT46rrbzSAEru1pXF6j1L2vTND6Us10p15Zr5Ywq2OTQRwUO0UMyiCM27PYDDKYLomRoy2VNq+n9HGfbGbvyzM9FWgd+4zMfWY4iaV1v6+assHCZNOl7XcKnUC0bUQ9osrq3qnTevgUTtZYUz4ecGEDDwtjaTYER8jsx0YAO5Gxc2EfyyP83lqq27b4Fc6gqhRolEXSe1FDrRBUZioslrYpkD3WthzHSyg0WNCIkVFeoNWw3S7UsQsAHqiobvQTgrgSNbL80gizdmU4EyEswsNzPMQxV3hqiO1oR3kDoyD87tOm57QStKusUNiUcigRXSlZQRchZW2qpc0Sdg5AbQDuw3XboDIQcwGAUm7uh3LWEPvPx88zRiNgWd5OaBr3o+oBrmeaCJhdDeZ7BB83kbETdjZ3bmzryii6eaDCR8c0PzUk/wOdTX7SFU//bEmg5EYoUiOCvv5H5NXbnuDffpHUGYoxLJN892uvarsgXXIPa/14SJTU+pBepXOWVf5W88yFI58VOWqBW9DAYNM3KQMRE0x4gO2JYmLZrtD1ItLTC3ooK2rKasdvzAIVwNp2PfTqpwmdWZY+CswMKzDeYZp579acNgDjodSLv+IK31JvcT4o218jlhYbM78LcJcUR8EG8xSWrynLL7sHZl7cnQQUoYKvLJn0eVwnHTenCVgxSSbwWNwF4cmm+owsbpeLxLqEC+WhoyPHhosl4Y3hewN4Pyw8mNzfhiehxFgzvRgg/IfhuLPRDXr4ljfwe5f/nkxz/m6HDWMR4zWrPBHPFx+zQ7/BX/d5zRrvRfeFU0pbfVcJHvpeMcVfDfAGby8TG/LO0BFc0vftiwtfzPBnD02rvFnZnrrwVUR3wvEFt5heARddZVDE/uXGjRdt4bru4UWODcfT5WmFdvE/Jeqz44iuBr4AAAAASUVORK5CYII=",ae="/assets/gemini-D4G1NbrE.png",ue="/assets/kimi-BWNNSh7e.png",le="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABzUlEQVR4AeycQQrCQBAEF1+g6J/0o5LPCXmCnnNx0E2nNqGEPciw024VffV0PZ/fHo7BqflBCSgAxd+aAhQAE4DjbYACYAJwvA1QAEwAjrcBCgAIDBRpA2AZClAATACOtwEKgAnA8TZAATABOD7egNc8tz2ftJ+4gPQD9r5fAbDBDQXALx00XgGwGAUoACYAx9sABcAE4HgboACYABxvAxSwJHC7XFryLNP4bzYg7KBar4CKUHiugDDgar0CKkLhuQLCgKv1CqgIhecKCAOu1iugIhSeKyAMuFqvgIpQeK6AMOBq/XAC7o9H6z5fdlRAtp4PJ2BrAHSeAmADClAATACOtwEKgAnA8TZAATABON4GKAAmAMev2AD4JTuNVwAsTgEKgAnA8TZAATABON4GKAAmAMfbAAXABOB4G9ApoPe6AnoJdt5XQCfA3uvDCXhOU0ueXmBr3x9OwNoPHH2fAmBDClAATACOtwEKgAnA8TZAAX8QONAVGwDLVIACYAJwfLwByf/+2WJ32k9cQPoBe9+vANigAhQAE4DjbYACYAJw/A8NgH/pQeMVAItVgAJgAnC8DVAATACOtwEKgAnA8TZAATABON4GFALS4w8AAAD//x7wkLQAAAAGSURBVAMAKj5LkLSa6SQAAAAASUVORK5CYII=",ce=new Set(["low","medium","high","xhigh"]),de=["claude-code","codex","opencode","gemini","kimi"],fe=["codex","claude-code","opencode","gemini","kimi"],G={"claude-code":{displayNameKey:"conversation.providerClaude",fullDisplayNameKey:"shell.providerClaudeCode",draftTitleKey:"conversation.draftTitleClaude",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:ie,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!0,supportsRunSteeringByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},codex:{displayNameKey:"conversation.providerCodex",draftTitleKey:"conversation.draftTitleCodex",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:Q,defaultRunInputMode:"streaming_guidance",reasoningLevelPersists:!0,defaultReasoningLevel:null,supportsSlashMenuByDefault:!1,supportsRunSteeringByDefault:!0,supportsQueueWhileRunningByDefault:!0,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0},opencode:{displayNameKey:"conversation.providerOpenCode",draftTitleKey:"conversation.draftTitleOpenCode",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:le,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},gemini:{displayNameKey:"conversation.providerGemini",draftTitleKey:"conversation.draftTitleGemini",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:ae,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},kimi:{displayNameKey:"conversation.providerKimi",draftTitleKey:"conversation.draftTitleKimi",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:ue,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0}},pe=Array.from(new Set(Object.values(G).map(e=>e.icon)));let J=!1;function me(e){return de.includes(e)}function c(e){return!e||!me(e)?null:G[e]}function ge(e){return[{id:"provider-default",name:g(e),usesProviderDefault:!0}]}function Se(e){const s=c(e);return ge((s==null?void 0:s.defaultModelLabelKey)??"conversation.modelUseCliDefault")}function cs(e){return!!(e&&c(e))}function ds(e){const s=c(e);return g((s==null?void 0:s.draftTitleKey)??"conversation.draftTitleCodex")}function Ae(e,s="compact"){const n=c(e);return n?s==="full"&&n.fullDisplayNameKey?g(n.fullDisplayNameKey):g(n.displayNameKey):(e==null?void 0:e.trim())||g("conversation.providerCodex")}function he(e){const s=c(e);return(s==null?void 0:s.icon)??Q}function z(){J||typeof window>"u"||(J=!0,pe.forEach(e=>{const s=new window.Image;s.decoding="async",s.src=e,typeof s.decode=="function"&&s.decode().catch(()=>{})}))}function fs(e){const s=c(e);return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:(s==null?void 0:s.defaultRunInputMode)??"none",supportsSubagents:!1,supportsInterrupt:(s==null?void 0:s.supportsInterrupt)??!1,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:(s==null?void 0:s.supportsAttachments)??!0,supportsPermissionPrompt:(s==null?void 0:s.supportsPermissionPrompt)??!0,supportsCheckpoint:!1,supportsSessionDelete:(s==null?void 0:s.supportsSessionDeleteByDefault)??!1,modelOptions:Se(e),defaultReasoningLevel:s==null?void 0:s.defaultReasoningLevel,supportsRunSteering:s==null?void 0:s.supportsRunSteeringByDefault,supportsQueueWhileRunning:s==null?void 0:s.supportsQueueWhileRunningByDefault,limitations:[]}}function ps(e){return(e==null?void 0:e.provider)??"claude-code"}function ms(e){var n;if((e==null?void 0:e.supportsSlashMenu)!==void 0)return e.supportsSlashMenu;const s=(e==null?void 0:e.provider)??null;return((n=c(s))==null?void 0:n.supportsSlashMenuByDefault)??!1}function gs(e){var s;return(e==null?void 0:e.supportsReasoningSelector)!==void 0?e.supportsReasoningSelector:!!((s=e==null?void 0:e.modelOptions)!=null&&s.some(n=>{var o;return((o=n.supportedReasoningEfforts)==null?void 0:o.some(r=>ce.has(r)))??!1}))}function Ss(e,s){var u;if((e==null?void 0:e.supportsQueueWhileRunning)!==void 0)return e.supportsQueueWhileRunning;const n=(e==null?void 0:e.provider)??null,o=(u=c(n))==null?void 0:u.supportsQueueWhileRunningByDefault;if(o!==void 0)return o;const r=(e==null?void 0:e.inRunInputMode)??"none";return r==="queued_guidance"||r==="none"||r==="streaming_guidance"&&s===!1}function As(e){var n;if((e==null?void 0:e.supportsRunSteering)!==void 0)return e.supportsRunSteering;const s=(e==null?void 0:e.provider)??null;return((n=c(s))==null?void 0:n.supportsRunSteeringByDefault)??(e==null?void 0:e.inRunInputMode)==="streaming_guidance"}function hs(e){const s=c(e);return(s==null?void 0:s.reasoningLevelPersists)??!1}function ys(e,s){var o;return((o=c(s??null))==null?void 0:o.foldRulesMessagesByDefault)??!1}typeof window<"u"&&z();const U=new Map;function vs(){U.clear()}function Rs({disabled:e=!1,workspaceId:s=null,pendingProvider:n=null,selectedProvider:o=null,providers:r=fe,className:u,disabledReasons:l,statusHintByProvider:d,onSelect:P}){const O=re(),S=!!s,[v,f]=w.useState(()=>K(r,s)),A=r.map(a=>({provider:a}));return w.useEffect(()=>{z()},[]),w.useEffect(()=>{if(!s){f({});return}const a=K(r,s);f(a);const h=r.filter(m=>!a[m]);if(h.length===0)return;let p=!1;return se(h,s).then(m=>{ve(s,m),p||f(N=>({...N,...m}))}),()=>{p=!0}},[r,s]),t.jsx("div",{className:`session-provider-grid${u?` ${u}`:""}`,children:A.map(a=>{const h=Ae(a.provider,"full"),p=n===a.provider,m=o===a.provider,N=!!v[a.provider],q=ye(v[a.provider]??null),x=(l==null?void 0:l[a.provider])??q,B=p?g("shell.startingSession"):x||((d==null?void 0:d[a.provider])??(S&&!N&&!p?g("shell.providerChecking"):null));return t.jsxs("button",{type:"button",className:"session-provider-card","data-provider":a.provider,"data-pending":p?"true":"false","data-selected":m?"true":"false","aria-label":h,disabled:e||!!x,onClick:()=>{O.trigger("action"),P(a.provider)},children:[t.jsx("span",{className:"session-provider-card-icon","aria-hidden":"true",children:t.jsx("img",{src:he(a.provider),alt:"",loading:"eager",decoding:"async"})}),t.jsxs("span",{className:"session-provider-card-copy",children:[t.jsx("strong",{children:h}),B?t.jsx("span",{className:"session-provider-card-status",children:B}):null]})]},a.provider)})})}function ye(e){return!e||e.canStartSession!==!1?null:e.limitations[0]??g("conversation.capabilityDenied")}function K(e,s){const n=(s==null?void 0:s.trim())??"";if(!n)return{};const o=[];for(const r of e){const u=U.get(W(n,r));u&&o.push([r,u])}return Object.fromEntries(o)}function ve(e,s){const n=e.trim();if(n)for(const[o,r]of Object.entries(s))r&&U.set(W(n,o),r)}function W(e,s){return`${e}::${s}`}function Cs({heading:e,description:s,actions:n,tone:o="default",className:r,children:u}){return t.jsxs("section",{className:y("modal-section",r),"data-tone":o,children:[e||s||n?t.jsxs("div",{className:"modal-section-header",children:[t.jsxs("div",{className:"modal-section-copy",children:[e?t.jsx("strong",{className:"modal-section-heading",children:e}):null,s?t.jsx("p",{className:"modal-section-description",children:s}):null]}),n?t.jsx("div",{className:"modal-section-actions",children:n}):null]}):null,u]})}function ws({label:e,description:s,className:n,htmlFor:o,children:r}){return t.jsxs("div",{className:y("workbench-modal-field","modal-field",n),children:[t.jsxs("div",{className:"modal-field-copy",children:[o?t.jsx("label",{className:"modal-field-label",htmlFor:o,children:e}):t.jsx("span",{className:"modal-field-label",children:e}),s?t.jsx("span",{className:"modal-field-description",children:s}):null]}),r]})}function Ds({align:e="end",stack:s=!1,className:n,children:o,...r}){return t.jsx("div",{className:y("workbench-modal-actions","modal-actions",n),"data-align":e,"data-stack":s?"true":void 0,...r,children:o})}function Ps({compact:e=!1,className:s,children:n,...o}){return t.jsx("div",{className:y("modal-list",s),"data-compact":e?"true":void 0,...o,children:n})}function Os(e){const{as:s="div",label:n,description:o,leading:r,trailing:u,tone:l="default",selected:d=!1,className:P,children:O,...S}=e,f={className:y("modal-list-item",P),"data-tone":l!=="default"?l:void 0,"data-selected":d?"true":void 0,"data-interactive":s==="button"?"true":void 0},A=t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"modal-list-item-main",children:[r?t.jsx("span",{className:"modal-list-item-leading",children:r}):null,t.jsxs("span",{className:"modal-list-item-copy",children:[n?t.jsx("span",{className:"modal-list-item-label",children:n}):null,o?t.jsx("span",{className:"modal-list-item-description",children:o}):null,O]})]}),u?t.jsx("span",{className:"modal-list-item-trailing",children:u}):null]});if(s==="button"){const a=S;return t.jsx("button",{type:a.type??"button",...a,...f,children:A})}return t.jsx("div",{...S,...f,children:A})}function Ns({title:e,description:s,action:n,className:o,compact:r=!1}){return t.jsxs("div",{className:y("modal-empty-state",o),"data-compact":r?"true":void 0,children:[t.jsx("strong",{className:"modal-empty-state-title",children:e}),s?t.jsx("p",{className:"modal-empty-state-description",children:s}):null,n?t.jsx("div",{className:"modal-empty-state-action",children:n}):null]})}function Is({tone:e="default",className:s,children:n,...o}){return t.jsx("span",{className:y("modal-tag",s),"data-tone":e!=="default"?e:void 0,...o,children:n})}function y(...e){return e.filter(Boolean).join(" ")}function Es({open:e,title:s,description:n,height:o="auto",kind:r="form",dismissible:u=!0,closeOnBackdrop:l=!0,showHandle:d=!1,showCancelButton:P=!0,cancelLabel:O,className:S,cardClassName:v,bodyClassName:f,footer:A,onClose:a,children:h}){const p=w.useId(),m=w.useId(),N=u&&l;return!e||typeof document>"u"?null:H.createPortal(t.jsx("div",{className:"ios-action-sheet-overlay mobile-sheet-overlay",role:"presentation",onClick:()=>{N&&a()},children:t.jsxs("div",{className:`mobile-workspace-home-sheet mobile-sheet${S?` ${S}`:""}`,"data-height":o,"data-kind":r,role:"dialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":n?m:void 0,onClick:q=>q.stopPropagation(),children:[t.jsxs("div",{className:`mobile-workspace-home-sheet-card mobile-sheet-card${v?` ${v}`:""}`,children:[d?t.jsx("div",{className:"mobile-sheet-handle","aria-hidden":"true"}):null,t.jsx("div",{className:"mobile-workspace-home-sheet-header mobile-sheet-header",children:t.jsxs("div",{className:"mobile-sheet-title-wrap",children:[t.jsx("strong",{id:p,children:s}),n?t.jsx("p",{id:m,children:n}):null]})}),t.jsx("div",{className:f?`mobile-sheet-body ${f}`:"mobile-sheet-body",children:h}),A?t.jsx("div",{className:"mobile-sheet-footer",children:A}):null]}),P?t.jsx("button",{type:"button",className:"ios-action-sheet-cancel mobile-sheet-cancel",disabled:!u,onClick:()=>{u&&a()},children:O??g("common.cancel")}):null]})}),document.body)}export{Pe as $,as as A,us as B,Me as C,is as D,We as E,Ve as F,ns as G,$e as H,cs as I,As as J,ds as K,Ns as L,Es as M,Je as N,ps as O,gs as P,ms as Q,Ss as R,Rs as S,Ye as T,hs as U,Ze as V,ys as W,He as X,he as Y,Le as Z,Oe as _,Ae as a,Ue as a0,Qe as a1,Ge as a2,ze as a3,Fe as a4,vs as a5,be as a6,xe as a7,ke as a8,je as a9,Ke as aa,k as ab,Te as ac,Ie as b,Ee as c,qe as d,re as e,Cs as f,De as g,ws as h,Ps as i,Os as j,Is as k,fs as l,ee as m,se as n,fe as o,_e as p,es as q,Ne as r,ss as s,Be as t,ls as u,Ds as v,Xe as w,ts as x,os as y,rs as z};
@@ -1 +0,0 @@
1
- import{b as r,j as e,t as s,z as R,c as re,e as Z,v as gs,A as be,L as Y,n as Ee,i as Bs,f as Hs,M as ve,p as Vs,N as ms,d as je,m as qs}from"./index-Byp9hJ0c.js";import{f as _s,h as Fe,j as zs,k as $s,l as Ws,n as Ks,d as Re,o as Js,u as hs,i as Gs,c as Zs,L as ps,T as bs,p as fs}from"./App-DkvE5EyM.js";import{a5 as Qs,f as le,k as ye,v as X,h as me,i as Ys,j as Xs,M as et,u as se,ab as te}from"./MobileSheet-DLg-gX1t.js";import{M as st,W as ee}from"./WorkbenchModal-Ctob14VR.js";import{M as tt}from"./MobileTopHeaderFrame-DArgZI7L.js";const Be=2e4,nt=1e3,at=5e3;function it({isOpen:t,onClose:n}){const[a,i]=r.useState(null),[l,u]=r.useState(null),[f,x]=r.useState(!1),[b,w]=r.useState(!1),[v,p]=r.useState(null),D=r.useRef(null);if(r.useEffect(()=>{if(!t)return;let m=!1;async function c(){x(!0),p(null),u(null);try{const g=await R.request("/api/observability/runtime/session",{method:"POST",body:JSON.stringify({ttlMs:Be})});if(m){await Ne(g.sessionId);return}D.current=g.sessionId,i(g);const S=await He(g.sessionId);if(m){await Ne(g.sessionId);return}u(S)}catch(g){m||p(we(g))}finally{m||x(!1)}}return c(),()=>{m=!0;const g=D.current;D.current=null,i(null),u(null),x(!1),w(!1),p(null),g&&Ne(g)}},[t]),r.useEffect(()=>{const m=(a==null?void 0:a.sessionId)??null;if(!t||!m)return;const c=m;let g=!1;async function S(){w(!0);try{const o=await He(c);g||(u(o),p(null))}catch(o){g||p(we(o))}finally{g||w(!1)}}const k=window.setInterval(()=>{S()},nt);return()=>{g=!0,window.clearInterval(k)}},[t,a==null?void 0:a.sessionId]),r.useEffect(()=>{const m=(a==null?void 0:a.sessionId)??null;if(!t||!m)return;const c=m;let g=!1;async function S(){try{const o=await R.request(`/api/observability/runtime/session/${c}/heartbeat`,{method:"POST",body:JSON.stringify({ttlMs:Be})});g||i(o)}catch(o){g||p(we(o))}}const k=window.setInterval(()=>{S()},at);return()=>{g=!0,window.clearInterval(k)}},[t,a==null?void 0:a.sessionId]),!t||typeof document>"u")return null;const j=Object.entries((l==null?void 0:l.backgroundTasks.taskTypes)??{}),P=Object.entries((l==null?void 0:l.schedulers.schedulers)??{}),y=Object.entries((l==null?void 0:l.backgroundTasks.totals)??{});return _s.createPortal(e.jsxs("div",{className:"workbench-modal-layer parallel-task-debug-modal-layer","aria-hidden":!t,children:[e.jsx("button",{type:"button",className:"workbench-modal-backdrop parallel-task-debug-modal-backdrop","aria-label":s("settings.parallelTaskDebugClose"),onClick:n}),e.jsxs("div",{className:"workbench-modal-card surface-card parallel-task-debug-modal-card",role:"dialog","aria-modal":"true","aria-labelledby":"parallel-task-debug-title",children:[e.jsxs("div",{className:"workbench-modal-header",children:[e.jsxs("div",{className:"workbench-modal-title-wrap",children:[e.jsx("h2",{id:"parallel-task-debug-title",children:s("settings.parallelTaskDebugModalTitle")}),e.jsx("p",{children:s("settings.parallelTaskDebugModalDescription")})]}),e.jsxs("div",{className:"workbench-modal-header-actions",children:[e.jsx("span",{className:"parallel-task-debug-status-chip","data-tone":v?"error":"active",children:v?s("settings.parallelTaskDebugStatusError"):s("settings.parallelTaskDebugStatusActive")}),e.jsx(st,{onClick:n,"aria-label":s("settings.parallelTaskDebugClose")})]})]}),e.jsxs("div",{className:"workbench-modal-body parallel-task-debug-body",children:[e.jsxs("div",{className:"parallel-task-debug-meta-grid",children:[e.jsxs("div",{className:"parallel-task-debug-meta-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugObservedAt")}),e.jsx("strong",{children:Se(l==null?void 0:l.observedAt)})]}),e.jsxs("div",{className:"parallel-task-debug-meta-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugSessionExpireAt")}),e.jsx("strong",{children:Se(a==null?void 0:a.expiresAt)})]}),e.jsxs("div",{className:"parallel-task-debug-meta-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugSessionTtl")}),e.jsx("strong",{children:lt((a==null?void 0:a.ttlMs)??null)})]}),e.jsxs("div",{className:"parallel-task-debug-meta-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugCollectorState")}),e.jsx("strong",{children:l!=null&&l.eventLoop.enabled?s("settings.parallelTaskDebugCollectorEnabled"):s("settings.parallelTaskDebugCollectorDisabled")})]})]}),f?e.jsx("div",{className:"parallel-task-debug-empty",children:s("settings.parallelTaskDebugLoading")}):null,!f&&v?e.jsx("div",{className:"parallel-task-debug-error",children:v}):null,!f&&!v&&l?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"parallel-task-debug-section",children:[e.jsxs("div",{className:"parallel-task-debug-section-header",children:[e.jsx("h3",{children:s("settings.parallelTaskDebugCountersTitle")}),e.jsx("span",{children:b?s("common.loading"):s("settings.parallelTaskDebugAutoRefresh")})]}),e.jsx("div",{className:"parallel-task-debug-counter-grid",children:y.map(([m,c])=>e.jsxs("div",{className:"parallel-task-debug-counter-card",children:[e.jsx("span",{children:rt(m)}),e.jsx("strong",{children:c})]},m))})]}),e.jsxs("section",{className:"parallel-task-debug-section",children:[e.jsxs("div",{className:"parallel-task-debug-section-header",children:[e.jsx("h3",{children:s("settings.parallelTaskDebugTaskMetricsTitle")}),e.jsx("span",{children:j.length})]}),j.length>0?e.jsx("div",{className:"parallel-task-debug-grid",children:j.map(([m,c])=>e.jsxs("article",{className:"parallel-task-debug-panel",children:[e.jsxs("div",{className:"parallel-task-debug-panel-header",children:[e.jsx("strong",{children:m}),e.jsx("span",{children:Ve(c.executionLane)})]}),e.jsxs("div",{className:"parallel-task-debug-panel-body",children:[e.jsxs("span",{children:[s("settings.parallelTaskDebugWaitAvg"),": ",K(c.waitMs.avg)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugRunAvg"),": ",K(c.runMs.avg)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugRunMax"),": ",K(c.runMs.max)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugStartedCount"),": ",c.counters.started??0]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugFinishedCount"),": ",c.counters.finished??0]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugFailedCount"),": ",c.counters.failed??0]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugCacheHitCount"),": ",c.counters.cache_hit??0]})]})]},m))}):e.jsx("div",{className:"parallel-task-debug-empty",children:s("settings.parallelTaskDebugEmpty")})]}),e.jsxs("section",{className:"parallel-task-debug-section",children:[e.jsxs("div",{className:"parallel-task-debug-section-header",children:[e.jsx("h3",{children:s("settings.parallelTaskDebugSchedulerTitle")}),e.jsx("span",{children:P.length})]}),P.length>0?e.jsx("div",{className:"parallel-task-debug-grid",children:P.map(([m,c])=>e.jsxs("article",{className:"parallel-task-debug-panel",children:[e.jsxs("div",{className:"parallel-task-debug-panel-header",children:[e.jsx("strong",{children:m}),e.jsx("span",{children:c.lastIdle?s("settings.parallelTaskDebugIdle"):s("settings.parallelTaskDebugBusy")})]}),e.jsxs("div",{className:"parallel-task-debug-panel-body",children:[e.jsxs("span",{children:[s("settings.parallelTaskDebugTickTotal"),": ",c.tickTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugIdleTickTotal"),": ",c.idleTickTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugTaskCountTotal"),": ",c.taskCountTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugSchedulerErrorTotal"),": ",c.errorTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugLastDuration"),": ",K(c.lastDurationMs)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugNextDelay"),": ",K(c.nextDelayMs)]})]})]},m))}):e.jsx("div",{className:"parallel-task-debug-empty",children:s("settings.parallelTaskDebugEmpty")})]}),e.jsxs("section",{className:"parallel-task-debug-section",children:[e.jsxs("div",{className:"parallel-task-debug-section-header",children:[e.jsx("h3",{children:s("settings.parallelTaskDebugEventLoopTitle")}),e.jsx("span",{children:l.eventLoop.enabled?s("settings.parallelTaskDebugCollectorEnabled"):s("settings.parallelTaskDebugCollectorDisabled")})]}),e.jsxs("div",{className:"parallel-task-debug-counter-grid",children:[e.jsxs("div",{className:"parallel-task-debug-counter-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugEventLoopResolution")}),e.jsx("strong",{children:K(l.eventLoop.resolutionMs)})]}),e.jsxs("div",{className:"parallel-task-debug-counter-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugEventLoopMean")}),e.jsx("strong",{children:K(l.eventLoop.meanMs)})]}),e.jsxs("div",{className:"parallel-task-debug-counter-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugEventLoopP95")}),e.jsx("strong",{children:K(l.eventLoop.p95Ms)})]}),e.jsxs("div",{className:"parallel-task-debug-counter-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugEventLoopP99")}),e.jsx("strong",{children:K(l.eventLoop.p99Ms)})]}),e.jsxs("div",{className:"parallel-task-debug-counter-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugEventLoopMax")}),e.jsx("strong",{children:K(l.eventLoop.maxMs)})]})]})]}),e.jsxs("section",{className:"parallel-task-debug-section",children:[e.jsxs("div",{className:"parallel-task-debug-section-header",children:[e.jsx("h3",{children:s("settings.parallelTaskDebugRecentActivitiesTitle")}),e.jsx("span",{children:l.recentTaskActivities.length})]}),l.recentTaskActivities.length>0?e.jsx("div",{className:"parallel-task-debug-activity-list",children:l.recentTaskActivities.map(m=>e.jsxs("article",{className:"parallel-task-debug-activity-item",children:[e.jsxs("div",{className:"parallel-task-debug-activity-main",children:[e.jsxs("div",{className:"parallel-task-debug-activity-title-row",children:[e.jsx("strong",{children:m.taskType}),e.jsx("span",{children:ct(m.eventType)}),e.jsx("span",{children:Ve(m.executionLane)})]}),e.jsxs("p",{children:[s("settings.parallelTaskDebugTaskKey"),": ",m.key]}),e.jsxs("p",{children:[s("settings.parallelTaskDebugStatus"),": ",m.status?ot(m.status):"-"]})]}),e.jsxs("div",{className:"parallel-task-debug-activity-meta",children:[e.jsx("span",{children:Se(m.recordedAt)}),e.jsxs("span",{children:[s("settings.parallelTaskDebugAttempt"),": ",m.attempt??"-"]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugWaitMs"),": ",K(m.waitMs)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugRunMs"),": ",K(m.runMs)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugSource"),": ",m.source??"-"]}),m.errorMessage?e.jsxs("span",{children:[s("settings.parallelTaskDebugError"),": ",m.errorMessage]}):null]})]},m.eventId))}):e.jsx("div",{className:"parallel-task-debug-empty",children:s("settings.parallelTaskDebugEmpty")})]})]}):null]})]})]}),document.body)}async function He(t){return await R.request(`/api/observability/runtime?sessionId=${encodeURIComponent(t)}`)}async function Ne(t){try{await R.request(`/api/observability/runtime/session/${t}`,{method:"DELETE"})}catch{}}function we(t){return t instanceof Error&&t.message?t.message:s("settings.parallelTaskDebugLoadFailed")}function Se(t){if(!t)return"-";const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function K(t){return t==null||Number.isNaN(t)?"-":`${Math.round(t*100)/100} ms`}function lt(t){return t===null||Number.isNaN(t)?"-":`${Math.round(t/1e3)} s`}function rt(t){switch(t){case"enqueue":return s("settings.parallelTaskDebugMetricEnqueue");case"dedupe":return s("settings.parallelTaskDebugMetricDedupe");case"started":return s("settings.parallelTaskDebugMetricStarted");case"finished":return s("settings.parallelTaskDebugMetricFinished");case"failed":return s("settings.parallelTaskDebugMetricFailed");case"cancelled":return s("settings.parallelTaskDebugMetricCancelled");case"timeout":return s("settings.parallelTaskDebugMetricTimeout");case"cache_hit":return s("settings.parallelTaskDebugMetricCacheHit");default:return t}}function Ve(t){switch(t){case"host_background":return s("settings.parallelTaskDebugLaneHostBackground");case"helper_process":return s("settings.parallelTaskDebugLaneHelperProcess");case"external_process":return s("settings.parallelTaskDebugLaneExternalProcess");default:return s("settings.parallelTaskDebugLaneRequestMainThread")}}function ct(t){switch(t){case"enqueued":return s("settings.parallelTaskDebugEventEnqueued");case"deduped":return s("settings.parallelTaskDebugEventDeduped");case"started":return s("settings.parallelTaskDebugEventStarted");case"finished":return s("settings.parallelTaskDebugEventFinished");case"failed":return s("settings.parallelTaskDebugEventFailed");case"cancelled":return s("settings.parallelTaskDebugEventCancelled");case"timeout":return s("settings.parallelTaskDebugEventTimeout");case"cache_hit":return s("settings.parallelTaskDebugEventCacheHit");default:return t}}function ot(t){switch(t){case"queued":return s("settings.parallelTaskDebugTaskStatusQueued");case"running":return s("settings.parallelTaskDebugTaskStatusRunning");case"succeeded":return s("settings.parallelTaskDebugTaskStatusSucceeded");case"failed":return s("settings.parallelTaskDebugTaskStatusFailed");case"cancelled":return s("settings.parallelTaskDebugTaskStatusCancelled");case"timeout":return s("settings.parallelTaskDebugTaskStatusTimeout");default:return t}}async function qe(){const t=re(),n=Z.getState(),a=await t.bridge.getAndroidRuntimeInfo();if(!a.ok||!a.value)throw new Error(a.detail??"读取 Android 运行时信息失败。");const i=await R.request(`/api/client/release-manifest?channel=${encodeURIComponent(n.releaseChannel)}&platform=android-apk`),l=i.versionCode>a.value.versionCode;return{checkedAt:new Date().toISOString(),currentVersion:a.value.version,currentVersionCode:a.value.versionCode,hasUpdate:l,manifest:i,runtimeInfo:a.value}}async function dt(t){return re().bridge.installAndroidUpdate(t)}function ut(){const[t,n]=r.useState(!1),[a,i]=r.useState(!1),[l,u]=r.useState(null),[f,x]=r.useState(null),[b,w]=r.useState(null),[v,p]=r.useState(!1),[D,j]=r.useState(null),P=r.useRef(!1);r.useEffect(()=>{if(D===null){P.current=!1;return}const c=D;async function g(){if(!P.current){P.current=!0;try{const o=await qe();if(w(o.manifest),x(o.currentVersion),p(o.hasUpdate),!o.hasUpdate||o.currentVersionCode>=c){u(s("settings.androidInstallSucceeded"));return}u(s("settings.androidInstallCancelled"))}catch(o){u(o instanceof Error?o.message:s("settings.releaseCheckFailed"))}finally{j(null)}}}function S(){g()}function k(){document.visibilityState==="visible"&&g()}return window.addEventListener("focus",S),document.addEventListener("visibilitychange",k),()=>{window.removeEventListener("focus",S),document.removeEventListener("visibilitychange",k)}},[D]);async function y(){n(!0),u(null),j(null);try{const c=await qe();w(c.manifest),x(c.currentVersion),p(c.hasUpdate),u(c.hasUpdate?s("settings.releaseUpdateReady"):s("settings.releaseUpToDate"))}catch(c){u(c instanceof Error?c.message:s("settings.releaseCheckFailed"))}finally{n(!1)}}async function m(){if(b){i(!0),u(null),j(null);try{const c=await dt(b);if(c.status==="installer_started"){u(s("settings.androidInstallerStarted")),j(b.versionCode);return}if(c.status==="permission_required"){u(c.detail??s("settings.androidInstallPermissionRequired")),j(null);return}if(c.status==="already_up_to_date"){u(s("settings.releaseUpToDate")),p(!1),j(null);return}u(c.detail??s("settings.releaseInstallFailed")),j(null)}catch(c){u(c instanceof Error?c.message:s("settings.releaseInstallFailed")),j(null)}finally{i(!1)}}}return e.jsxs("div",{className:"settings-update-card",children:[e.jsxs("div",{className:"settings-update-summary",children:[e.jsxs("div",{className:"settings-update-field",children:[e.jsx("span",{className:"settings-update-label",children:s("settings.releaseCurrentVersion")}),e.jsx("strong",{className:"settings-update-value",children:f??s("settings.releaseUnknownVersion")})]}),e.jsxs("div",{className:"settings-update-field",children:[e.jsx("span",{className:"settings-update-label",children:s("settings.releaseTargetVersion")}),e.jsx("strong",{className:"settings-update-value",children:(b==null?void 0:b.version)??"-"})]})]}),l?e.jsx("p",{className:"settings-update-status","data-tone":v?"warning":"success",children:l}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:t||a,onClick:y,children:t?s("common.loading"):s("settings.releaseCheckNow")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!b||!v||a,onClick:m,children:a?s("common.loading"):s("settings.releaseInstallNow")})]})]})}function gt(){const t=re(),n=t.isDesktop,[a,i]=r.useState(!1),[l,u]=r.useState(!1),[f,x]=r.useState(!1),[b,w]=r.useState(null),[v,p]=r.useState(null),D=Fe(M=>M.latestState),j=Fe(M=>M.pendingRestartVersion),P=(D==null?void 0:D.currentVersion)??null,y=(D==null?void 0:D.manifest)??null,m=(D==null?void 0:D.hasUpdate)??!1,c=!!j,g=c&&v!==j;async function S(){if(!c){i(!0),w(null);try{const M=await zs({notify:"always"});w(_e(M.manifest,M.hasUpdate))}catch(M){w(M instanceof Error?M.message:s("settings.releaseCheckFailed"))}finally{i(!1)}}}async function k(){if(!(!y||!m||c)){u(!0),w(null);try{const M=await $s();if(!M.ok){w(M.detail??s("settings.releaseInstallFailed"));return}Ws(y.version),p(null),w(s("settings.releaseRestartRequired"))}catch(M){w(M instanceof Error?M.message:s("settings.releaseInstallFailed"))}finally{u(!1)}}}async function o(){if(y!=null&&y.htmlUrl){x(!0);try{const M=await t.bridge.openExternal(y.htmlUrl);M.ok||w(M.detail??s("settings.releasePageOpenFailed"))}catch(M){w(M instanceof Error?M.message:s("settings.releasePageOpenFailed"))}finally{x(!1)}}}const C=!!(n&&y&&m&&!c),L=b??(n?c?s("settings.releaseRestartRequired"):D?_e(D.manifest,D.hasUpdate):null:s("settings.clientUpdateUnsupported"));return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-update-card",children:[e.jsxs("div",{className:"settings-update-summary",children:[e.jsxs("div",{className:"settings-update-field",children:[e.jsx("span",{className:"settings-update-label",children:s("settings.releaseCurrentVersion")}),e.jsx("strong",{className:"settings-update-value",children:P??s("settings.releaseUnknownVersion")})]}),e.jsxs("div",{className:"settings-update-field",children:[e.jsx("span",{className:"settings-update-label",children:s("settings.releaseTargetVersion")}),e.jsx("strong",{className:"settings-update-value",children:(y==null?void 0:y.version)??j??"-"})]})]}),L?e.jsx("p",{className:"settings-update-status","data-tone":mt(y,m,L,c),children:L}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:!n||a||l||c,onClick:S,children:a?s("common.loading"):s("settings.releaseCheckNow")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!C||l,onClick:k,children:l?s("common.loading"):s("settings.releaseInstallNow")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:!(y!=null&&y.htmlUrl)||a||l||f,onClick:o,children:f?s("common.loading"):s("settings.releaseOpenPage")})]})]}),e.jsx(ht,{open:g,version:j,onClose:()=>p(j)})]})}function _e(t,n){return n?s("settings.releaseUpdateReady"):s("settings.releaseUpToDate")}function mt(t,n,a,i){return a===s("settings.clientUpdateUnsupported")?"neutral":i||n?"warning":"success"}function ht({open:t,version:n,onClose:a}){const[i,l]=r.useState(!1),[u,f]=r.useState(null);async function x(){l(!0),f(null);try{await Ks()}catch(b){f(b instanceof Error?b.message:s("settings.releaseRestartFailed")),l(!1)}}return e.jsx(ee,{open:t,title:s("settings.releaseRestartDialogTitle"),description:s("settings.releaseRestartDialogDescription",{version:n??"-"}),onClose:()=>{i||a()},children:e.jsxs("div",{className:"settings-update-card",children:[u?e.jsx("p",{className:"settings-update-status","data-tone":"danger",children:u}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:i,onClick:a,children:s("settings.releaseRestartLater")}),e.jsx("button",{className:"primary-button",type:"button",disabled:i,onClick:x,children:i?s("common.loading"):s("settings.releaseRestartConfirm")})]})]})})}function xs(){const t=re();return t.platform==="desktop"?e.jsx(gt,{}):t.platform==="android"?e.jsx(ut,{}):e.jsx("div",{className:"settings-update-card",children:e.jsx("p",{className:"settings-update-status","data-tone":"neutral",children:s("settings.clientUpdateUnsupported")})})}async function ze(){return await R.request("/api/system/model-switch")}async function pt(t){return await R.request("/api/system/model-switch",{method:"POST",body:JSON.stringify(t)})}const bt="https://github.com/SaladDay/cc-switch-cli",ft="当前机器未安装 cc-switch-cli。这里集成的是 CC-Switch 的衍生 CLI 版本,不是 CC-Switch UI 版本。请先安装:",xt=/(https?:\/\/[^\s]+)/i;function vs(){const t=gs(o=>{var C;return((C=o.session)==null?void 0:C.accessToken)??null}),[n,a]=r.useState(null),[i,l]=r.useState(!0),[u,f]=r.useState(null),[x,b]=r.useState(null),[w,v]=r.useState(null),[p,D]=r.useState(!1),[j,P]=r.useState("codex");r.useEffect(()=>{let o=!0;if(!t){a(null),b(null),v(null),l(!1);return}return(async()=>{l(!0);try{const L=await ze();if(!o)return;a(L),b(null),P(M=>We(L,M))}catch(L){if(!o)return;b(Te(L))}finally{o&&l(!1)}})(),()=>{o=!1}},[t]);async function y(){const o=await ze();a(o),b(null),P(C=>We(o,C))}async function m(){if(t){f("refresh"),b(null),v(null);try{await y(),v(s("settings.modelManagementRefreshSuccess"))}catch(o){b(Te(o))}finally{f(null)}}}async function c(o,C){if(!t||C.isCurrent)return;const L=$e(o,C.id);f(L),b(null),v(null);try{const M=await pt({app:o,presetId:C.id});Qs(),a(O=>vt(O,M)),v(s("settings.modelManagementSwitchSuccess",{app:M.displayName,preset:M.currentPresetName??C.name}))}catch(M){b(Te(M))}finally{f(null)}}const g=(n==null?void 0:n.items)??[],S=g.find(o=>o.app===j)??g[0]??null,k=yt(g);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"settings-model-panel",children:e.jsxs("div",{className:"settings-release-card",children:[w?e.jsx("p",{className:"settings-release-status",children:w}):null,x?e.jsx("p",{className:"settings-release-status",children:x}):null,k?e.jsxs("section",{className:"settings-model-missing-state",children:[e.jsx("p",{className:"settings-model-missing-copy",children:k.message}),e.jsx("a",{className:"settings-tailscale-link settings-model-missing-link",href:k.url,rel:"noreferrer",target:"_blank",children:k.url})]}):g.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"settings-model-grid",children:g.map(o=>e.jsxs("section",{className:"settings-model-card",children:[e.jsxs("div",{className:"settings-model-card-main",children:[e.jsxs("div",{className:"settings-model-card-copy",children:[e.jsx("strong",{className:"settings-model-card-title",children:o.displayName}),e.jsx("span",{className:"settings-model-card-status","data-status":o.status,children:jt(o.status)})]}),e.jsxs("div",{className:"settings-model-value-line",children:[e.jsx("strong",{className:"settings-model-preset-value",children:o.currentPresetName??s("settings.modelManagementPresetMissing")}),e.jsx("strong",{className:"settings-model-current-value",children:o.currentModel??s("settings.modelManagementModelUnknown")})]})]}),o.statusText?e.jsx("p",{className:"settings-model-card-note",children:o.statusText}):null]},o.app))}),e.jsx("div",{className:"settings-model-panel-actions",children:e.jsx("button",{className:"secondary-button settings-model-open-action",type:"button",disabled:!t||i,onClick:()=>{D(!0)},children:s("settings.modelManagementOpenSwitcher")})})]}):e.jsx("div",{className:"settings-model-empty",children:s("settings.modelManagementOptionsEmpty")})]})}),e.jsxs(ee,{open:p&&!k,title:s("settings.modelManagementModalTitle"),description:s("settings.modelManagementModalDescription"),className:"settings-model-modal",headerActions:e.jsx("button",{className:"secondary-button",type:"button",disabled:!t||i||u!==null,onClick:()=>{m()},children:u==="refresh"?s("common.loading"):s("settings.modelManagementRefresh")}),onClose:()=>D(!1),children:[e.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":s("settings.modelManagementTabsLabel"),children:g.map(o=>{const C=(S==null?void 0:S.app)===o.app;return e.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":C,"data-active":C?"true":"false",onClick:()=>P(o.app),children:o.displayName},o.app)})}),S?e.jsxs("section",{className:"settings-model-modal-panel",children:[e.jsxs("div",{className:"settings-model-modal-summary",children:[e.jsxs("div",{className:"settings-model-modal-summary-row",children:[e.jsx("span",{children:s("settings.modelManagementCurrentProfile")}),e.jsx("strong",{children:S.currentPresetName??s("settings.modelManagementPresetMissing")})]}),e.jsxs("div",{className:"settings-model-modal-summary-row",children:[e.jsx("span",{children:s("settings.modelManagementCurrentModel")}),e.jsx("strong",{children:S.currentModel??s("settings.modelManagementModelUnknown")})]})]}),S.statusText?e.jsx("p",{className:"settings-model-modal-note",children:S.statusText}):null,S.options.length>0?e.jsx("div",{className:"settings-model-switcher-list",children:S.options.map(o=>{const C=$e(S.app,o.id);return e.jsxs("div",{className:"settings-model-switcher-item","data-current":o.isCurrent?"true":"false",children:[e.jsxs("div",{className:"settings-model-switcher-item-main",children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:o.model??s("settings.modelManagementModelUnknown")})]}),e.jsx("div",{className:"settings-model-switcher-item-actions",children:o.isCurrent?e.jsx("span",{className:"settings-model-card-status","data-status":"ready",children:s("settings.modelManagementCurrentTag")}):e.jsx("button",{className:"secondary-button settings-model-option-action",type:"button",disabled:i||u!==null||S.status!=="ready",onClick:()=>{c(S.app,o)},children:u===C?s("common.loading"):s("settings.modelManagementSwitchAction")})})]},`${S.app}:${o.id}`)})}):e.jsx("div",{className:"settings-model-empty",children:S.statusText??s("settings.modelManagementOptionsEmpty")})]}):e.jsx("div",{className:"settings-model-empty",children:s("settings.modelManagementOptionsEmpty")})]})]})}function $e(t,n){return`switch:${t}:${n}`}function vt(t,n){return t&&{...t,scannedAt:new Date().toISOString(),items:t.items.map(a=>a.app===n.app?n:a)}}function We(t,n){var i;return t.items.some(l=>l.app===n)?n:((i=t.items[0])==null?void 0:i.app)??"codex"}function jt(t){switch(t){case"unconfigured":return s("settings.modelManagementStatusUnconfigured");case"unavailable":return s("settings.modelManagementStatusUnavailable");case"error":return s("settings.modelManagementStatusError");default:return s("settings.modelManagementStatusReady")}}function Te(t){return t instanceof be?t.message||s("settings.modelManagementLoadFailed"):t instanceof Error?t.message:s("settings.modelManagementLoadFailed")}function yt(t){var i,l,u;if(t.length===0||!t.every(f=>f.status==="unavailable"&&!f.cliAvailable&&!!f.statusText))return null;const a=((u=(((l=(i=t[0])==null?void 0:i.statusText)==null?void 0:l.trim())??"").match(xt))==null?void 0:u[1])??bt;return{message:ft,url:a}}var js={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ke=Y.createContext&&Y.createContext(js),Nt=["attr","size","title"];function wt(t,n){if(t==null)return{};var a,i,l=St(t,n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(t);for(i=0;i<u.length;i++)a=u[i],n.indexOf(a)===-1&&{}.propertyIsEnumerable.call(t,a)&&(l[a]=t[a])}return l}function St(t,n){if(t==null)return{};var a={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(n.indexOf(i)!==-1)continue;a[i]=t[i]}return a}function he(){return he=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var i in a)({}).hasOwnProperty.call(a,i)&&(t[i]=a[i])}return t},he.apply(null,arguments)}function Je(t,n){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);n&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),a.push.apply(a,i)}return a}function pe(t){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?Je(Object(a),!0).forEach(function(i){Tt(t,i,a[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Je(Object(a)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(a,i))})}return t}function Tt(t,n,a){return(n=kt(n))in t?Object.defineProperty(t,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[n]=a,t}function kt(t){var n=Dt(t,"string");return typeof n=="symbol"?n:n+""}function Dt(t,n){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var i=a.call(t,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function ys(t){return t&&t.map((n,a)=>Y.createElement(n.tag,pe({key:a},n.attr),ys(n.child)))}function ce(t){return n=>Y.createElement(Ct,he({attr:pe({},t.attr)},n),ys(t.child))}function Ct(t){var n=a=>{var{attr:i,size:l,title:u}=t,f=wt(t,Nt),x=l||a.size||"1em",b;return a.className&&(b=a.className),t.className&&(b=(b?b+" ":"")+t.className),Y.createElement("svg",he({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,i,f,{className:b,style:pe(pe({color:t.color||a.color},a.style),t.style),height:x,width:x,xmlns:"http://www.w3.org/2000/svg"}),u&&Y.createElement("title",null,u),t.children)};return Ke!==void 0?Y.createElement(Ke.Consumer,null,a=>n(a)):n(js)}function Mt(t){return ce({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 3H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h6v2H8v2h8v-2h-2v-2h6c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2"},child:[]}]})(t)}function Pt(t){return ce({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95a15.65 15.65 0 0 0-1.38-3.56A8.03 8.03 0 0 1 18.92 8zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56A7.987 7.987 0 0 1 5.08 16zm2.95-8H5.08a7.987 7.987 0 0 1 4.33-3.56A15.65 15.65 0 0 0 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95a8.03 8.03 0 0 1-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"},child:[]}]})(t)}function Ge(t){return ce({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"},child:[]}]})(t)}function Lt(t){return ce({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M15.5 1h-8A2.5 2.5 0 0 0 5 3.5v17A2.5 2.5 0 0 0 7.5 23h8a2.5 2.5 0 0 0 2.5-2.5v-17A2.5 2.5 0 0 0 15.5 1zm-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4.5-4H7V4h9v14z"},child:[]}]})(t)}function At(t){return ce({attr:{role:"img",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M18.4395 5.5586c-.675 1.1664-1.352 2.3318-2.0274 3.498-.0366-.0155-.0742-.0286-.1113-.043-1.8249-.6957-3.484-.8-4.42-.787-1.8551.0185-3.3544.4643-4.2597.8203-.084-.1494-1.7526-3.021-2.0215-3.4864a1.1451 1.1451 0 0 0-.1406-.1914c-.3312-.364-.9054-.4859-1.379-.203-.475.282-.7136.9361-.3886 1.5019 1.9466 3.3696-.0966-.2158 1.9473 3.3593.0172.031-.4946.2642-1.3926 1.0177C2.8987 12.176.452 14.772 0 18.9902h24c-.119-1.1108-.3686-2.099-.7461-3.0683-.7438-1.9118-1.8435-3.2928-2.7402-4.1836a12.1048 12.1048 0 0 0-2.1309-1.6875c.6594-1.122 1.312-2.2559 1.9649-3.3848.2077-.3615.1886-.7956-.0079-1.1191a1.1001 1.1001 0 0 0-.8515-.5332c-.5225-.0536-.9392.3128-1.0488.5449zm-.0391 8.461c.3944.5926.324 1.3306-.1563 1.6503-.4799.3197-1.188.0985-1.582-.4941-.3944-.5927-.324-1.3307.1563-1.6504.4727-.315 1.1812-.1086 1.582.4941zM7.207 13.5273c.4803.3197.5506 1.0577.1563 1.6504-.394.5926-1.1038.8138-1.584.4941-.48-.3197-.5503-1.0577-.1563-1.6504.4008-.6021 1.1087-.8106 1.584-.4941z"},child:[]}]})(t)}function Ze(){return R.request("/api/auth/devices")}function Et(t){return R.request("/api/auth/devices/current/primary",{method:"POST",body:JSON.stringify(t)})}function Rt(t){return R.request(`/api/auth/devices/${t}/logout`,{method:"POST"})}function Ns({compact:t=!1}){const n=gs(d=>{var F;return((F=d.session)==null?void 0:F.accessToken)??null}),[a,i]=r.useState(null),[l,u]=r.useState(!1),[f,x]=r.useState(!1),[b,w]=r.useState(!1),[v,p]=r.useState(null),[D,j]=r.useState(null),[P,y]=r.useState(null),[m,c]=r.useState(null),[g,S]=r.useState(null),[k,o]=r.useState(""),[C,L]=r.useState(null);r.useEffect(()=>{let d=!0;if(!f){u(!1);return}if(!n){i(null),u(!1),y(null),c(null);return}return(async()=>{u(!0);try{const N=await Ze();if(!d)return;i(N),c(null)}catch(N){if(!d)return;c(ke(N))}finally{d&&u(!1)}})(),()=>{d=!1}},[n,f]);async function M(){const d=await Ze();i(d),c(null)}function O(){x(!0),w(!1),y(null),c(null)}function I(){v!=="primary"&&(x(!1),w(!1),S(null),o(""),L(null))}function q(d){S(d),o(""),L(null)}async function G(){if(g){p("primary"),L(null),c(null),y(null);try{await Et({password:k,primary:g==="enable"}),await M(),y(g==="enable"?s("settings.authDevicePrimaryEnabled"):s("settings.authDevicePrimaryDisabled")),S(null),o("")}catch(d){const F=ke(d);L(F),c(F)}finally{p(null)}}}async function _(d){if(d.deviceId){j(d.deviceId),c(null),y(null);try{const F=await Rt(d.deviceId);await M(),y(s("settings.authDeviceLogoutDeviceSuccess",{device:de(d),count:String(F.revokedSessionCount)}))}catch(F){c(ke(F))}finally{j(null)}}}const U=(a==null?void 0:a.currentDevice)??null,J=(a==null?void 0:a.otherActiveDevices.filter(d=>!d.isLegacy))??[],W=(a==null?void 0:a.otherActiveDevices.filter(d=>d.isLegacy))??[],H=(a==null?void 0:a.recentLoginRecords.filter(d=>!d.isLegacy))??[],V=(a==null?void 0:a.recentLoginRecords.filter(d=>d.isLegacy))??[],T=W.length+V.length,A=U!==null&&!U.isLegacy,E=(U==null?void 0:U.isPrimary)===!0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`settings-device-panel${t?" settings-device-panel-compact":""}`,children:e.jsx("div",{className:"settings-device-entry-actions",children:e.jsx("button",{className:"settings-button",type:"button",disabled:!n,onClick:O,children:s("settings.authDeviceOpenManager")})})}),e.jsx(ee,{open:f,title:s("settings.authDeviceManagement"),description:s("settings.authDeviceManagementDescription"),className:"settings-device-browser-modal",onClose:I,children:e.jsxs(e.Fragment,{children:[P?e.jsx("p",{className:"settings-release-status",children:P}):null,m?e.jsx("p",{className:"settings-release-status",children:m}):null,l?e.jsx("div",{className:"settings-device-empty",children:s("common.loading")}):e.jsxs(e.Fragment,{children:[T>0?e.jsx("section",{className:"settings-device-section",children:e.jsxs("div",{className:"settings-device-compat-banner",children:[e.jsx("p",{className:"settings-device-inline-note",children:s("settings.authDeviceLegacyHiddenHint",{count:String(T)})}),e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>w(d=>!d),children:b?s("settings.authDeviceLegacyHide"):s("settings.authDeviceLegacyReveal")})]})}):null,e.jsxs("section",{className:"settings-device-section",children:[e.jsx("div",{className:"settings-device-section-header",children:e.jsx("strong",{children:s("settings.authDeviceCurrentTitle")})}),U?e.jsx(ne,{current:!0,title:de(U),clientType:U.clientType,browserName:U.browserName,browserVersion:U.browserVersion,osName:U.osName,osVersion:U.osVersion,timeLabelKey:"settings.authDeviceLastSeen",timestamp:U.lastSeenAt,sourceAddress:U.lastSourceAddress,badges:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"settings-device-tag","data-tone":"current",children:s("settings.authDeviceCurrentTag")}),U.isPrimary?e.jsx("span",{className:"settings-device-tag","data-tone":"primary",children:s("settings.authDevicePrimaryTag")}):null]}),actions:e.jsx(e.Fragment,{children:e.jsx("button",{className:"secondary-button","data-variant":"device-neutral",type:"button",disabled:!A||v!==null,onClick:()=>q(U.isPrimary?"disable":"enable"),children:U.isPrimary?s("settings.authDeviceDisablePrimary"):s("settings.authDeviceEnablePrimary")})}),note:A?null:s("settings.authDevicePrimaryUnavailable")}):e.jsx("div",{className:"settings-device-empty",children:s("settings.authDeviceCurrentEmpty")})]}),e.jsxs("section",{className:"settings-device-section",children:[e.jsx("div",{className:"settings-device-section-header",children:e.jsx("strong",{children:s("settings.authDeviceOthersTitle")})}),J.length>0?e.jsx("div",{className:"settings-device-list",children:J.map((d,F)=>e.jsx(ne,{title:de(d),clientType:d.clientType,browserName:d.browserName,browserVersion:d.browserVersion,osName:d.osName,osVersion:d.osVersion,timeLabelKey:"settings.authDeviceLastSeen",timestamp:d.lastSeenAt,sourceAddress:d.lastSourceAddress,badges:e.jsxs(e.Fragment,{children:[d.isPrimary?e.jsx("span",{className:"settings-device-tag","data-tone":"primary",children:s("settings.authDevicePrimaryTag")}):null,d.isLegacy?e.jsx("span",{className:"settings-device-tag","data-tone":"legacy",children:s("settings.authDeviceLegacyTag")}):null]}),actions:d.deviceId?e.jsx("button",{className:"settings-button settings-button-danger","data-variant":"device-danger",type:"button",disabled:!E||v!==null||D!==null,onClick:()=>{_(d)},children:D===d.deviceId?s("common.loading"):s("settings.authDeviceLogoutDevice")}):null},`${d.deviceId??"legacy"}-${d.lastSeenAt}-${F}`))}):e.jsx("div",{className:"settings-device-empty",children:s("settings.authDeviceOthersEmpty")})]}),e.jsxs("section",{className:"settings-device-section",children:[e.jsx("div",{className:"settings-device-section-header",children:e.jsx("strong",{children:s("settings.authDeviceRecentTitle")})}),H.length>0?e.jsx("div",{className:"settings-device-list",children:H.map(d=>e.jsx(ne,{title:Qe(d),clientType:d.clientType,browserName:d.browserName,browserVersion:d.browserVersion,osName:d.osName,osVersion:d.osVersion,timeLabelKey:"settings.authDeviceLoginAt",timestamp:d.occurredAt,sourceAddress:d.sourceAddress,badges:d.isCurrentDevice?e.jsx("span",{className:"settings-device-tag","data-tone":"current",children:s("settings.authDeviceCurrentTag")}):null},d.id))}):e.jsx("div",{className:"settings-device-empty",children:s("settings.authDeviceRecentEmpty")})]}),b&&W.length>0?e.jsxs("section",{className:"settings-device-section",children:[e.jsx("div",{className:"settings-device-section-header",children:e.jsx("strong",{children:s("settings.authDeviceLegacyDevicesTitle")})}),e.jsx("div",{className:"settings-device-list",children:W.map((d,F)=>e.jsx(ne,{title:de(d),clientType:d.clientType,browserName:d.browserName,browserVersion:d.browserVersion,osName:d.osName,osVersion:d.osVersion,timeLabelKey:"settings.authDeviceLastSeen",timestamp:d.lastSeenAt,sourceAddress:d.lastSourceAddress,badges:e.jsx("span",{className:"settings-device-tag","data-tone":"legacy",children:s("settings.authDeviceLegacyTag")})},`legacy-device-${d.lastSeenAt}-${F}`))})]}):null,b&&V.length>0?e.jsxs("section",{className:"settings-device-section",children:[e.jsx("div",{className:"settings-device-section-header",children:e.jsx("strong",{children:s("settings.authDeviceLegacyRecentTitle")})}),e.jsx("div",{className:"settings-device-list",children:V.map(d=>e.jsx(ne,{title:Qe(d),clientType:d.clientType,browserName:d.browserName,browserVersion:d.browserVersion,osName:d.osName,osVersion:d.osVersion,timeLabelKey:"settings.authDeviceLoginAt",timestamp:d.occurredAt,sourceAddress:d.sourceAddress,badges:e.jsx("span",{className:"settings-device-tag","data-tone":"legacy",children:s("settings.authDeviceLegacyTag")})},d.id))})]}):null]})]})}),e.jsx(ee,{open:g!==null,title:g==="enable"?s("settings.authDeviceEnablePrimaryModalTitle"):s("settings.authDeviceDisablePrimaryModalTitle"),description:g==="enable"?s("settings.authDeviceEnablePrimaryModalDescription"):s("settings.authDeviceDisablePrimaryModalDescription"),className:"settings-device-modal",onClose:()=>{v!=="primary"&&(S(null),o(""),L(null))},children:e.jsxs("div",{className:"settings-device-modal-body",children:[e.jsxs("label",{className:"settings-device-password-field",children:[e.jsx("span",{children:s("settings.authDevicePasswordLabel")}),e.jsx("input",{type:"password",className:"settings-text-input",value:k,onChange:d=>o(d.target.value)})]}),C?e.jsx("p",{className:"settings-release-status",children:C}):null,e.jsxs("div",{className:"settings-device-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:v==="primary",onClick:()=>{S(null),o(""),L(null)},children:s("common.cancel")}),e.jsx("button",{className:"settings-button",type:"button",disabled:k.trim().length===0||v==="primary",onClick:()=>{G()},children:v==="primary"?s("common.loading"):g==="enable"?s("settings.authDeviceEnablePrimary"):s("settings.authDeviceDisablePrimary")})]})]})})]})}function de(t){var n;return t.isLegacy?s("settings.authDeviceLegacyLabel"):((n=t.displayName)==null?void 0:n.trim())||ws(t.clientType)}function Qe(t){var n;return t.isLegacy?s("settings.authDeviceLegacyLabel"):((n=t.displayName)==null?void 0:n.trim())||ws(t.clientType)}function Ut(t){return e.jsxs("div",{className:"settings-device-identity",children:[e.jsx("span",{className:"settings-device-identity-icon","aria-hidden":"true",children:e.jsx(qt,{kind:Vt(t.clientType)})}),e.jsx("div",{className:"settings-device-identity-body",children:e.jsx("strong",{children:t.title})})]})}function ne(t){const n=Ht(t.browserName,t.browserVersion,t.osName,t.osVersion,t.timeLabelKey,t.timestamp,t.sourceAddress);return e.jsx("article",{className:"settings-device-item","data-current":t.current?"true":void 0,children:e.jsxs("div",{className:"settings-device-item-main",children:[e.jsxs("div",{className:"settings-device-item-content",children:[e.jsx(Ut,{title:t.title,clientType:t.clientType}),e.jsx("div",{className:"settings-device-meta",children:n.map(a=>e.jsx("span",{children:a},a))}),t.note?e.jsx("p",{className:"settings-device-inline-note",children:t.note}):null]}),t.badges||t.actions?e.jsxs("div",{className:"settings-device-item-controls",children:[t.badges?e.jsx("div",{className:"settings-device-badges",children:t.badges}):null,t.actions?e.jsx("div",{className:"settings-device-actions",children:t.actions}):null]}):null]})})}function ws(t){switch(t){case"desktop":return s("settings.authDeviceClientDesktop");case"web":return s("settings.authDeviceClientWeb");case"ios":return s("settings.authDeviceClientIos");case"android":return s("settings.authDeviceClientAndroid");default:return s("settings.authDeviceClientUnknown")}}function It(t,n){return s(t,{value:new Date(n).toLocaleString()})}function Ot(t){return t?s("settings.authDeviceSourceAddressValue",{value:t}):s("settings.authDeviceSourceAddressUnknown")}function Ft(t,n){return t?s("settings.authDeviceBrowserValue",{value:Ss(t,n)}):null}function Bt(t,n){return t?s("settings.authDeviceOsValue",{value:Ss(t,n)}):null}function Ht(t,n,a,i,l,u,f){return[Ft(t,n),Bt(a,i),It(l,u),Ot(f)].filter(x=>!!x)}function Vt(t){switch(t){case"desktop":return"desktop";case"web":return"web";case"ios":return"ios";case"android":return"android";default:return"unknown"}}function Ss(t,n){return n!=null&&n.trim()?`${t} ${n}`:t}function qt({kind:t}){const n=_t(t),a=n.icon;return e.jsx(a,{color:n.color})}function _t(t){switch(t){case"desktop":return{icon:Mt,color:"#2563eb"};case"web":return{icon:Pt,color:"#0f766e"};case"ios":return{icon:Lt,color:"#111827"};case"android":return{icon:At,color:"#3ddc84"};case"unknown":return{icon:Ge,color:"#64748b"};default:return{icon:Ge,color:"#64748b"}}}function ke(t){return t instanceof be||t instanceof Error?t.message:s("settings.authDeviceLoadFailed")}async function Ye(){const t=Z.getState();return R.request(`/api/client/service-update?channel=${encodeURIComponent(t.releaseChannel)}`)}async function zt(t){const n=Z.getState();return R.request("/api/client/service-update/install",{method:"POST",body:JSON.stringify({packageName:t,channel:n.releaseChannel})})}async function $t(t){return R.request(`/api/client/service-update/tasks/${encodeURIComponent(t)}`)}const Wt=1500;function Ts(){const t=re(),[n,a]=r.useState(!1),[i,l]=r.useState(!1),[u,f]=r.useState(null),[x,b]=r.useState(null),[w,v]=r.useState(null),p=(x==null?void 0:x.packages[0])??null;r.useEffect(()=>{if(!w||!De(w.status))return;let y=!1;const m=window.setTimeout(async()=>{var c;try{const g=await $t(w.taskId);if(y)return;if(v(g),f(Ae(g)),!De(g.status)){l(!1);const S=await Ye();if(y)return;b(S),v(((c=S.packages[0])==null?void 0:c.installTask)??g),f(Xe(S.packages[0]??null,g)),g.restartRequired&&await t.bridge.showNotification(s("settings.serverRestartRequired"),g.targetVersion??"-")}}catch(g){if(y)return;l(!1),f(g instanceof Error?g.message:s("settings.serverInstallFailed"))}},Wt);return()=>{y=!0,window.clearTimeout(m)}},[t.bridge,w]);async function D(){a(!0),f(null);try{const y=await Ye(),m=y.packages[0]??null;b(y),v((m==null?void 0:m.installTask)??null),f(Xe(m,(m==null?void 0:m.installTask)??null)),m!=null&&m.hasUpdate&&await t.bridge.showNotification(s("settings.serverUpdateReady"),`${s("settings.serverTargetVersion")}: ${m.latestVersion??"-"}`)}catch(y){f(y instanceof Error?y.message:s("settings.serverCheckFailed"))}finally{a(!1)}}async function j(){if(p!=null&&p.packageName){l(!0),f(null);try{const y=await zt(p.packageName);v(y),f(Ae(y))}catch(y){l(!1),f(y instanceof Error?y.message:s("settings.serverInstallFailed"))}}}const P=!!(p&&p.checkStatus!=="check_failed"&&p.hasUpdate&&!p.restartRequired&&!De(w==null?void 0:w.status));return e.jsxs("div",{className:"settings-update-card",children:[e.jsxs("div",{className:"settings-update-summary",children:[e.jsxs("div",{className:"settings-update-field",children:[e.jsx("span",{className:"settings-update-label",children:s("settings.serverCurrentVersion")}),e.jsx("strong",{className:"settings-update-value",children:(p==null?void 0:p.currentVersion)??"-"})]}),e.jsxs("div",{className:"settings-update-field",children:[e.jsx("span",{className:"settings-update-label",children:s("settings.serverTargetVersion")}),e.jsx("strong",{className:"settings-update-value",children:(p==null?void 0:p.latestVersion)??"-"})]})]}),u?e.jsx("p",{className:"settings-update-status","data-tone":Kt(p,w),children:u}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:n||i,onClick:D,children:n?s("common.loading"):s("settings.serverCheckNow")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!P||n||i,onClick:j,children:i?s("common.loading"):s("settings.serverInstallNow")})]})]})}function Xe(t,n){return n?Ae(n):t?t.restartRequired?s("settings.serverRestartRequired"):t.checkStatus==="check_failed"?t.checkError??s("settings.serverCheckFailed"):t.latestVersion?t.hasUpdate?s("settings.serverUpdateReady"):s("settings.serverUpToDate"):s("settings.serverLatestUnknown"):s("settings.serverCheckNow")}function Ae(t){switch(t.status){case"queued":return s("settings.serverInstallQueued");case"running":return s("settings.serverInstalling");case"succeeded":return t.restartRequired?s("settings.serverRestartRequired"):s("settings.serverInstallSucceeded");case"cancelled":return s("settings.serverInstallCancelled");case"timeout":return s("settings.serverInstallTimeout");case"failed":return t.errorMessage??s("settings.serverInstallFailed");default:return t.errorMessage??s("settings.serverInstallFailed")}}function Kt(t,n){if(n)switch(n.status){case"queued":case"running":return"warning";case"succeeded":return n.restartRequired?"warning":"success";case"failed":case"cancelled":case"timeout":return"danger";default:return"neutral"}return t?t.checkStatus==="check_failed"?"danger":t.restartRequired||t.hasUpdate?"warning":"success":"neutral"}function De(t){return t==="queued"||t==="running"}const ks=Ee("https://channel.codingns.com:1443");function Ce(){return ks}function Jt(){return!1}function Gt(t){if(!(t!=null&&t.trim()))return null;try{return Ee(t)}catch{return null}}function Me(t){return ks}async function Zt(){return await R.request("/api/system/relay-tunnel/status")}async function es(t){return await R.request("/api/system/relay-tunnel/config",{method:"PUT",body:JSON.stringify(t)})}async function Qt(t){return await R.request("/api/system/relay-tunnel/control/login",{method:"POST",body:JSON.stringify(t)})}async function Yt(){return await R.request("/api/system/relay-tunnel/control/logout",{method:"POST"})}async function Xt(t){const n=t.hostLabel.trim(),a=`/api/system/relay-tunnel/control/host-label-availability?hostLabel=${encodeURIComponent(n)}`;return await R.request(a)}async function en(t){return await R.request("/api/system/relay-tunnel/control/bind",{method:"POST",body:JSON.stringify(t)})}async function sn(){return await R.request("/api/system/relay-tunnel/control/wallet")}async function ss(){return await R.request("/api/system/relay-tunnel/enable",{method:"POST"})}async function tn(){return await R.request("/api/system/relay-tunnel/disable",{method:"POST"})}async function nn(){return await R.request("/api/system/relay-tunnel/unbind",{method:"POST"})}const an="https://channel.jacksonz.cn:1443";function ln(){const t=Re(),[n,a]=r.useState(null),[i,l]=r.useState(""),[u,f]=r.useState(()=>Ce()),[x,b]=r.useState(""),[w,v]=r.useState(""),[p,D]=r.useState(null),[j,P]=r.useState({status:"idle"}),[y,m]=r.useState(!0),[c,g]=r.useState(null),[S,k]=r.useState(null),o=r.useRef(!0),C=Jt(),L=Me(n==null?void 0:n.controlBaseUrl);Gt(u);const M=Ce(),O=Me(),I=i.trim(),q=(n==null?void 0:n.activated)??!1,G=x.trim().length>0&&w.trim().length>0,_=!!(n!=null&&n.controlAccountEmail),U=n!=null&&n.bindingId?!0:j.status==="available"&&j.hostLabel===I,J=!!(n!=null&&n.bindingId)||_&&I.length>0&&U,W=ts({controlBaseUrl:O,tunnelDomain:n==null?void 0:n.tunnelDomain,hostLabel:i}),H=!!(n!=null&&n.controlAccountEmail||n!=null&&n.bindingId),V=!!(n!=null&&n.bindingId||U),T=!!(n!=null&&n.enabled&&(n!=null&&n.bindingId)),A=!!(n!=null&&n.bindingId)||J,E=p?ae(p.grantedBytes):s("settings.tailscaleUnavailable"),d=ae(p?p.usedBytes:n==null?void 0:n.trafficUsedBytes),F=ae(p?p.remainingBytes:n==null?void 0:n.trafficRemainingBytes);r.useEffect(()=>(o.current=!0,N(!1),()=>{o.current=!1}),[]),r.useEffect(()=>{if(!q)return;const h=window.setInterval(()=>{N(!0)},5e3);return()=>{window.clearInterval(h)}},[q]),r.useEffect(()=>{!q||!_||oe()},[q,_]),r.useEffect(()=>{n!=null&&n.bindingId||j.status!=="idle"&&j.hostLabel!==I&&P({status:"idle"})},[j,I,n==null?void 0:n.bindingId]),r.useEffect(()=>{{f(Ce());return}},[C,L]);async function N(h){h||m(!0);try{const $=await Zt();if(!o.current)return;B($)}catch($){o.current&&k(Q($))}finally{o.current&&!h&&m(!1)}}function B(h){a(h),k(null),h.controlAccountEmail||D(null),h.tunnelDomain&&i.trim().length===0&&l(Ds(h.tunnelDomain)),Os(h)}async function oe(){try{const h=await sn();if(!o.current)return;D(h.wallet)}catch(h){o.current&&k(Q(h))}}async function Ls(){if(G){g("login-control"),k(null);try{const h=await Qt({email:x.trim(),password:w});B(h),await oe()}catch(h){k(Q(h))}finally{g(null)}}}async function As(){g("logout-control"),k(null);try{const h=await Yt();B(h),D(null),P({status:"idle"})}catch(h){k(Q(h))}finally{g(null)}}async function Ue(){if(!I)throw new Error(s("settings.relayTunnelHostLabelRequired"));if(j.status==="available"&&j.hostLabel===I)return{hostLabel:j.hostLabel,tunnelDomain:j.tunnelDomain,available:!0,reason:"available"};P({status:"checking",hostLabel:I});const h=await Xt({hostLabel:I});if(!h.available||!h.tunnelDomain){const $=rn(h);throw P({status:"error",hostLabel:I,message:$}),new Error($)}return P({status:"available",hostLabel:I,tunnelDomain:h.tunnelDomain}),h}async function Es(){if(!(!H||n!=null&&n.bindingId)){g("check-host-label"),k(null);try{await Ue()}catch{}finally{g(null)}}}async function Rs(){g("learn-service"),k(null);try{await cn(t.bridge.openExternal,an)}catch(h){k(Q(h))}finally{g(null)}}async function Us(){if(J){g("enable"),k(null);try{let h=n;if(h!=null&&h.activated||(h=await es({activated:!0,controlBaseUrl:M}),B(h)),h!=null&&h.bindingId||(await Ue(),h=await en({hostLabel:I}),B(h),await oe()),!(h!=null&&h.enabled)){const $=await ss();B($)}}catch(h){k(Q(h))}finally{g(null)}}}async function Is(){if(n!=null&&n.bindingId){g("reconnect"),k(null);try{if(n!=null&&n.enabled){const $=await tn();B($)}const h=await ss();B(h),n!=null&&n.controlAccountEmail&&await oe()}catch(h){k(Q(h))}finally{g(null)}}}async function Ie(){g("disconnect-device"),k(null);try{if(n!=null&&n.bindingId||n!=null&&n.accountId){const h=await nn();B(h)}if(n!=null&&n.activated){const h=await es({activated:!1});B(h)}D(null),b(""),l(""),v(""),P({status:"idle"})}catch(h){k(Q(h))}finally{g(null)}}return e.jsxs("div",{className:"settings-relay-tunnel-panel",children:[null,y&&!n?e.jsx(le,{heading:s("settings.relayTunnelWizardTitle"),description:s("settings.relayTunnelWizardDescription"),children:e.jsx("p",{className:"settings-remote-access-panel-note",children:s("common.loading")})}):null,!y&&!T?e.jsxs(le,{heading:s("settings.relayTunnelWizardTitle"),description:s("settings.relayTunnelWizardDescription"),actions:e.jsx("button",{className:"secondary-button",disabled:c!==null,type:"button",onClick:()=>void Rs(),children:s("settings.relayTunnelLearnService")}),children:[e.jsxs("div",{className:"settings-relay-tunnel-step-list",children:[e.jsxs("section",{className:"settings-relay-tunnel-step","data-state":Pe(H,!0),children:[e.jsxs("div",{className:"settings-relay-tunnel-step-header",children:[e.jsx("span",{className:"settings-relay-tunnel-step-badge",children:"1"}),e.jsxs("div",{className:"settings-relay-tunnel-step-copy",children:[e.jsx("strong",{className:"settings-relay-tunnel-step-title",children:s("settings.relayTunnelStepLoginTitle")}),e.jsx("p",{className:"settings-relay-tunnel-step-description",children:s("settings.relayTunnelStepLoginDescription")})]}),e.jsx(ye,{className:"settings-relay-tunnel-step-tag",children:s(Le(H,!0))})]}),e.jsx("div",{className:"settings-relay-tunnel-step-body",children:H?e.jsxs(e.Fragment,{children:[n!=null&&n.controlAccountEmail?e.jsx("p",{className:"settings-relay-tunnel-success",children:s("settings.relayTunnelLoggedInAs",{email:n.controlAccountEmail})}):e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:s("settings.relayTunnelStepLoginConnected")}),e.jsx(X,{align:"start",children:e.jsx("button",{className:"secondary-button",disabled:c!==null,type:"button",onClick:()=>{if(n!=null&&n.bindingId){Ie();return}As()},children:s("common.logout")})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-relay-tunnel-form",children:[e.jsx(me,{label:s("settings.relayTunnelAccountEmail"),children:e.jsx("input",{"aria-label":s("settings.relayTunnelAccountEmail"),className:"settings-text-input",type:"email",value:x,onChange:h=>b(h.target.value),placeholder:s("settings.relayTunnelAccountEmailPlaceholder")})}),e.jsx(me,{label:s("settings.relayTunnelAccountPassword"),children:e.jsx("input",{"aria-label":s("settings.relayTunnelAccountPassword"),className:"settings-text-input",type:"password",value:w,onChange:h=>v(h.target.value),placeholder:s("settings.relayTunnelAccountPasswordPlaceholder")})})]}),e.jsx(X,{align:"start",children:e.jsx("button",{className:"settings-button",disabled:c!==null||!G,type:"button",onClick:()=>void Ls(),children:c==="login-control"?s("common.loading"):s("settings.relayTunnelLoginAccount")})})]})})]}),e.jsxs("section",{className:"settings-relay-tunnel-step","data-state":Pe(V,H),children:[e.jsxs("div",{className:"settings-relay-tunnel-step-header",children:[e.jsx("span",{className:"settings-relay-tunnel-step-badge",children:"2"}),e.jsxs("div",{className:"settings-relay-tunnel-step-copy",children:[e.jsx("strong",{className:"settings-relay-tunnel-step-title",children:s("settings.relayTunnelStepHostLabelTitle")}),e.jsx("p",{className:"settings-relay-tunnel-step-description",children:s("settings.relayTunnelStepHostLabelDescription")})]}),e.jsx(ye,{className:"settings-relay-tunnel-step-tag",children:s(Le(V,H))})]}),e.jsx("div",{className:"settings-relay-tunnel-step-body",children:H?n!=null&&n.bindingId?e.jsx("p",{className:"settings-relay-tunnel-success",children:s("settings.relayTunnelHostLabelAvailable",{domain:W??n.tunnelDomain??s("settings.relayTunnelUnbound")})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-relay-tunnel-domain-row",children:[e.jsx("input",{"aria-label":s("settings.relayTunnelHostLabel"),className:"settings-text-input settings-relay-tunnel-domain-prefix",value:i,onChange:h=>l(h.target.value),placeholder:s("settings.relayTunnelHostLabelPlaceholder")}),e.jsx("span",{className:"settings-relay-tunnel-domain-suffix",children:s("settings.relayTunnelHostLabelSuffix")}),e.jsx("button",{className:"settings-button settings-relay-tunnel-domain-check",disabled:c!==null||I.length===0,type:"button",onClick:()=>void Es(),children:c==="check-host-label"?s("common.loading"):s("settings.relayTunnelHostLabelCheck")})]}),e.jsxs("div",{className:"settings-relay-tunnel-inline-stack",children:[j.status==="available"&&j.hostLabel===I?e.jsx("p",{className:"settings-relay-tunnel-success",children:s("settings.relayTunnelHostLabelAvailable",{domain:ts({controlBaseUrl:M,tunnelDomain:j.tunnelDomain,hostLabel:j.hostLabel})??j.tunnelDomain})}):null,j.status==="checking"&&j.hostLabel===I?e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:s("settings.relayTunnelHostLabelChecking")}):null,j.status==="error"&&j.hostLabel===I?e.jsx("p",{className:"settings-relay-tunnel-error",children:j.message}):null]})]}):e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:s("settings.relayTunnelStepLocked")})})]}),e.jsxs("section",{className:"settings-relay-tunnel-step","data-state":Pe(T,V),children:[e.jsxs("div",{className:"settings-relay-tunnel-step-header",children:[e.jsx("span",{className:"settings-relay-tunnel-step-badge",children:"3"}),e.jsxs("div",{className:"settings-relay-tunnel-step-copy",children:[e.jsx("strong",{className:"settings-relay-tunnel-step-title",children:s("settings.relayTunnelStepStartTitle")}),e.jsx("p",{className:"settings-relay-tunnel-step-description",children:s("settings.relayTunnelStepStartDescription")})]}),e.jsx(ye,{className:"settings-relay-tunnel-step-tag",children:s(Le(T,V))})]}),e.jsx("div",{className:"settings-relay-tunnel-step-body",children:V?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:q?s("settings.relayTunnelStepStartReady"):s("settings.relayTunnelActivationHint")}),e.jsx(X,{align:"start",children:e.jsx("button",{className:"settings-button",disabled:c!==null||!A,type:"button",onClick:()=>void Us(),children:c==="enable"?s("common.loading"):s("settings.relayTunnelStartAction")})})]}):e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:s("settings.relayTunnelStepLocked")})})]})]}),e.jsxs("div",{className:"settings-relay-tunnel-inline-stack",children:[e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:s("settings.relayTunnelTrustBoundaryNotice")}),n!=null&&n.lastError?e.jsx("p",{className:"settings-relay-tunnel-error",children:s("settings.relayTunnelRecentError",{message:n.lastError})}):null,S?e.jsx("p",{className:"settings-relay-tunnel-error",children:S}):null]})]}):null,!y&&T?e.jsxs(le,{heading:s("settings.relayTunnelReadyTitle"),description:s("settings.relayTunnelReadyDescription"),children:[e.jsxs(Ys,{compact:!0,children:[e.jsx(ue,{label:s("settings.relayTunnelAccessUrlLabel"),value:W??s("settings.relayTunnelUnbound")}),e.jsx(ue,{label:s("settings.relayTunnelTrafficGranted"),value:E}),e.jsx(ue,{label:s("settings.relayTunnelTrafficUsed"),value:d}),e.jsx(ue,{label:s("settings.relayTunnelTrafficRemaining"),value:F})]}),e.jsxs(X,{align:"start",className:"settings-relay-tunnel-ready-actions",children:[e.jsx("button",{className:"secondary-button",disabled:c!==null||!(n!=null&&n.bindingId),type:"button",onClick:()=>void Is(),children:c==="reconnect"?s("common.loading"):s("settings.relayTunnelReconnectAction")}),e.jsx("button",{className:"settings-button settings-button-danger",disabled:c!==null,type:"button",onClick:()=>void Ie(),children:c==="disconnect-device"?s("common.loading"):s("settings.relayTunnelDisconnectDeviceAction")})]}),e.jsxs("div",{className:"settings-relay-tunnel-inline-stack",children:[e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:s("settings.relayTunnelTrustBoundaryNotice")}),n!=null&&n.lastError?e.jsx("p",{className:"settings-relay-tunnel-error",children:s("settings.relayTunnelRecentError",{message:n.lastError})}):null,S?e.jsx("p",{className:"settings-relay-tunnel-error",children:S}):null]})]}):null]});function Os(h){const $=Z.getState(),fe=Bs($);if(!fe)return;const Oe=Fs(h);on(fe.relayTunnel??null,Oe)||Z.update({hosts:$.hosts.map(xe=>xe.id===fe.id?{...xe,relayTunnel:Oe,updatedAt:new Date().toISOString()}:xe)})}function Fs(h){return!(h!=null&&h.bindingId)||!h.tunnelDomain?null:{provider:"codingns_relay",enabled:h.enabled,tunnelDomain:h.tunnelDomain.trim().toLowerCase(),controlBaseUrl:Me(h.controlBaseUrl)}}}function ue({label:t,value:n}){return e.jsx(Xs,{label:t,trailing:e.jsx("span",{className:"settings-relay-tunnel-summary-value",children:n})})}function Pe(t,n){return t?"done":n?"current":"pending"}function Le(t,n){return t?"settings.relayTunnelStepDone":n?"settings.relayTunnelStepCurrent":"settings.relayTunnelStepPending"}function rn(t){switch(t.reason){case"reserved":return s("settings.relayTunnelHostLabelReserved");case"occupied":return s("settings.relayTunnelHostLabelOccupied");case"available":return t.tunnelDomain?s("settings.relayTunnelHostLabelAvailable",{domain:t.tunnelDomain}):s("settings.relayTunnelHostLabelUnavailable");default:return s("settings.relayTunnelHostLabelUnavailable")}}function Q(t){return t instanceof be||t instanceof Error?t.message:s("settings.relayTunnelLoadFailed")}function ae(t){if(!t)return s("settings.tailscaleUnavailable");const n=Number(t);return!Number.isFinite(n)||n<1024?`${t} B`:n<1024**2?`${(n/1024).toFixed(1)} KB`:n<1024**3?`${(n/1024**2).toFixed(1)} MB`:`${(n/1024**3).toFixed(2)} GB`}function Ds(t){return t?t.split(".")[0]||s("common.unknown"):s("common.unknown")}function ts(t){var i,l,u,f;const n=ns(t.hostLabel)??ns(Ds(t.tunnelDomain));if(!n)return((i=t.tunnelDomain)==null?void 0:i.trim())??null;const a=(l=t.controlBaseUrl)==null?void 0:l.trim();if(!a)return((u=t.tunnelDomain)==null?void 0:u.trim())??null;try{const x=new URL(a);return x.hostname=`${n}.${x.hostname}`,x.pathname="/",x.search="",x.hash="",x.origin}catch{return((f=t.tunnelDomain)==null?void 0:f.trim())??null}}function ns(t){const n=(t==null?void 0:t.trim().toLowerCase())??"";return!n||n===s("common.unknown").toLowerCase()?null:n}async function cn(t,n){!(await t(n)).ok&&typeof window<"u"&&window.open(n,"_blank","noopener,noreferrer")}function on(t,n){return t===n?!0:!t||!n?!1:t.provider===n.provider&&t.enabled===n.enabled&&t.tunnelDomain===n.tunnelDomain&&t.controlBaseUrl===n.controlBaseUrl}async function as(){return await R.request("/api/system/tailscale/status")}async function is(t){return await R.request("/api/system/tailscale/config",{method:"PUT",body:JSON.stringify(t)})}async function dn(){return await R.request("/api/system/tailscale/enable",{method:"POST"})}async function un(){return await R.request("/api/system/tailscale/disable",{method:"POST"})}async function gn(){return await R.request("/api/system/tailscale/login",{method:"POST"})}async function mn(){return await R.request("/api/system/tailscale/logout",{method:"POST"})}function hn({children:t}){return e.jsx("div",{className:"settings-remote-access-metrics",children:t})}function ge({label:t,value:n}){return e.jsxs("article",{className:"settings-remote-access-metric-card",children:[e.jsx("span",{className:"settings-remote-access-metric-label",children:t}),e.jsx("strong",{className:"settings-remote-access-metric-value",children:n})]})}function pn({checked:t,label:n,disabled:a,onChange:i}){return e.jsxs("div",{className:"settings-remote-access-switch",children:[e.jsx("span",{className:"settings-remote-access-switch-label",children:n}),e.jsxs("label",{className:"settings-mobile-switch","data-disabled":a?"true":void 0,onClick:l=>{if(a){l.preventDefault();return}l.target instanceof HTMLInputElement||(l.preventDefault(),i(!t))},children:[e.jsx("input",{type:"checkbox","aria-label":n,checked:t,disabled:a,onChange:l=>i(l.target.checked)}),e.jsx("span",{className:"settings-mobile-switch-track","aria-hidden":"true",children:e.jsx("span",{className:"settings-mobile-switch-thumb"})})]})]})}function bn({configMode:t="modal"}){const n=Re(),[a,i]=r.useState(null),[l,u]=r.useState(""),[f,x]=r.useState(""),[b,w]=r.useState(!0),[v,p]=r.useState(null),[D,j]=r.useState(null),[P,y]=r.useState(!1),[m,c]=r.useState(!1),g=r.useRef(!0),S=r.useRef(!1),k=r.useRef(async()=>{}),o=t==="inline",C=(a==null?void 0:a.activated)??!1;S.current=m;function L(T){if(i(T),u(T.controlServerUrl??""),x(T.hostname??""),j(null),!T.activated){c(!1),y(!1);return}S.current&&!cs(T.lastError)&&c(!1)}k.current=async T=>{T||w(!0);try{const A=await as();if(!g.current)return;L(A)}catch(A){if(!g.current)return;j(ie(A))}finally{g.current&&!T&&w(!1)}},r.useEffect(()=>(g.current=!0,k.current(!1),()=>{g.current=!1}),[]),r.useEffect(()=>{if(!C)return;const T=window.setInterval(()=>{k.current(!0)},5e3);return()=>{window.clearInterval(T)}},[C]),r.useEffect(()=>{if(!m||!C)return;function T(){k.current(!0)}function A(){document.visibilityState==="visible"&&k.current(!0)}return window.addEventListener("focus",T),document.addEventListener("visibilitychange",A),()=>{window.removeEventListener("focus",T),document.removeEventListener("visibilitychange",A)}},[C,m]);const M=((a==null?void 0:a.controlServerUrl)??"")!==l.trim()||((a==null?void 0:a.hostname)??"")!==f.trim(),O=C&&cs(a==null?void 0:a.lastError),I=C&&vn(n.ui.osFamily)&&O;async function q(){const T=await is({controlServerUrl:rs(l),hostname:rs(f)});return L(T),T}async function G(T){p("toggle-activation"),j(null);try{const A=await is({activated:T});L(A)}catch(A){j(ie(A))}finally{p(null),w(!1)}}async function _(T){p(T),j(null);try{M&&T!=="disable"&&T!=="logout"&&await q();const A=T==="enable"?await dn():T==="disable"?await un():T==="login"?await gn():await mn();L(A)}catch(A){j(ie(A))}finally{p(null)}}async function U(){p("save"),j(null);try{await q(),y(!1)}catch(T){j(ie(T))}finally{p(null)}}async function J(){p("refresh"),j(null);try{const T=await as();L(T)}catch(T){j(ie(T))}finally{p(null),w(!1)}}async function W(){const T=jn(n.ui.osFamily);if(T){p("install"),j(null);try{const A=await n.bridge.openExternal(T);if(!A.ok){j(A.detail??s("settings.tailscaleInstallOpenFailed"));return}c(!0)}catch(A){j(A instanceof Error?A.message:s("settings.tailscaleInstallOpenFailed"))}finally{p(null)}}}function H(){v!=="save"&&y(!1)}const V=C?e.jsxs("span",{className:"settings-tailscale-status-indicator","data-tone":yn((a==null?void 0:a.phase)??"disabled"),children:[e.jsx("span",{className:"settings-tailscale-status-dot","aria-hidden":"true"}),xn((a==null?void 0:a.phase)??"disabled")]}):s("settings.remoteAccessFeatureDisabledValue");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-tailscale-panel",children:[e.jsx(le,{heading:s("settings.tailscaleSectionTitle"),description:s("settings.tailscaleSectionDescription"),actions:e.jsx(pn,{checked:C,label:s("settings.tailscaleMasterSwitchLabel"),disabled:v!==null,onChange:T=>{G(T)}}),children:b&&!a?e.jsx("p",{className:"settings-remote-access-panel-note",children:s("common.loading")}):e.jsxs(e.Fragment,{children:[e.jsxs(hn,{children:[e.jsx(ge,{label:s("settings.tailscaleStatusIndicator"),value:V}),e.jsx(ge,{label:s("settings.tailscaleServerAddress"),value:C?(a==null?void 0:a.reachableBaseUrl)??s("settings.tailscaleUnavailable"):s("settings.tailscaleUnavailable")}),e.jsx(ge,{label:s("settings.tailscaleAccountName"),value:C?(a==null?void 0:a.accountName)??s("settings.tailscaleUnavailable"):s("settings.tailscaleUnavailable")}),e.jsx(ge,{label:s("settings.tailscaleIpAddress"),value:C?fn(a):s("settings.tailscaleUnavailable")})]}),C?null:e.jsx("p",{className:"settings-remote-access-panel-note",children:s("settings.tailscaleActivationHint")}),C&&(a==null?void 0:a.phase)==="needs_login"&&a.loginUrl?e.jsx("p",{className:"settings-tailscale-login-url",children:e.jsx("a",{className:"settings-tailscale-link",href:a.loginUrl,rel:"noreferrer",target:"_blank",children:a.loginUrl})}):null,D||a!=null&&a.lastError?e.jsx("p",{className:"settings-relay-tunnel-error",children:D??(a==null?void 0:a.lastError)}):null,C?e.jsxs(X,{align:"start",children:[I?e.jsx("button",{className:"settings-button",type:"button",disabled:b||v!==null,onClick:()=>{W()},children:v==="install"?s("common.loading"):s("settings.tailscaleInstallAction")}):null,o?null:e.jsx("button",{className:"secondary-button",type:"button",disabled:b||v!==null,onClick:()=>y(!0),children:s("settings.tailscaleConfigure")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:b||v!==null,onClick:()=>{J()},children:v==="refresh"?s("common.loading"):s("settings.tailscaleRefresh")}),a!=null&&a.enabled?e.jsx("button",{className:"secondary-button",type:"button",disabled:b||v!==null||O,onClick:()=>{_("disable")},children:v==="disable"?s("common.loading"):s("settings.tailscaleDisable")}):e.jsx("button",{className:"secondary-button",type:"button",disabled:b||v!==null||O,onClick:()=>{_("enable")},children:v==="enable"?s("common.loading"):s("settings.tailscaleEnable")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:b||v!==null||!(a!=null&&a.enabled)||O,onClick:()=>{_("login")},children:v==="login"?s("common.loading"):s("settings.tailscaleLogin")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:b||v!==null||!(a!=null&&a.enabled)||O,onClick:()=>{_("logout")},children:v==="logout"?s("common.loading"):s("settings.tailscaleLogout")})]}):null]})}),o&&C?e.jsx(le,{heading:s("settings.tailscaleConfigModalTitle"),description:s("settings.tailscaleConfigModalDescription"),children:e.jsx(ls,{controlServerUrlDraft:l,hostnameDraft:f,pendingAction:v,configDirty:M,onControlServerUrlChange:u,onHostnameChange:x,onSave:()=>{U()}})}):null]}),e.jsx(ee,{open:!o&&C&&P,title:s("settings.tailscaleConfigModalTitle"),description:s("settings.tailscaleConfigModalDescription"),size:"regular",onClose:H,children:e.jsx(ls,{controlServerUrlDraft:l,hostnameDraft:f,pendingAction:v,configDirty:M,footer:e.jsx("div",{className:"settings-tailscale-modal-actions",children:e.jsx("button",{className:"secondary-button",type:"button",disabled:v==="save",onClick:H,children:s("common.cancel")})}),onControlServerUrlChange:u,onHostnameChange:x,onSave:()=>{U()}})})]})}function ls({controlServerUrlDraft:t,hostnameDraft:n,pendingAction:a,configDirty:i,footer:l,onControlServerUrlChange:u,onHostnameChange:f,onSave:x}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-tailscale-form",children:[e.jsx(me,{label:s("settings.tailscaleControlServer"),children:e.jsx("input",{"aria-label":s("settings.tailscaleControlServer"),className:"settings-text-input",placeholder:s("settings.tailscaleControlServerPlaceholder"),value:t,onChange:b=>u(b.target.value)})}),e.jsx(me,{label:s("settings.tailscaleHostname"),children:e.jsx("input",{"aria-label":s("settings.tailscaleHostname"),className:"settings-text-input",placeholder:s("settings.tailscaleHostnamePlaceholder"),value:n,onChange:b=>f(b.target.value)})})]}),e.jsxs(X,{align:"start",className:"settings-tailscale-config-actions",children:[l,e.jsx("button",{className:"settings-button",type:"button",disabled:a!==null||!i,onClick:x,children:a==="save"?s("common.loading"):s("common.save")})]})]})}function rs(t){const n=t.trim();return n.length>0?n:null}function ie(t){return t instanceof be||t instanceof Error?t.message:s("settings.tailscaleLoadFailed")}function fn(t){if(!t)return s("settings.tailscaleUnavailable");const n=[t.tailnetIpv4,t.tailnetIpv6].filter(a=>!!a);return n.length>0?n.join(" / "):s("settings.tailscaleUnavailable")}function xn(t){switch(t){case"blocked_uninitialized":return s("settings.tailscalePhaseBlockedUninitialized");case"starting":return s("settings.tailscalePhaseStarting");case"needs_login":return s("settings.tailscalePhaseNeedsLogin");case"running":return s("settings.tailscalePhaseRunning");case"stopping":return s("settings.tailscalePhaseStopping");case"error":return s("settings.tailscalePhaseError");case"disabled":default:return s("settings.tailscalePhaseDisabled")}}function cs(t){return t?t.includes("Tailscale CLI"):!1}function vn(t){return t==="macos"||t==="windows"}function jn(t){switch(t){case"macos":return"https://tailscale.com/download/mac";case"windows":return"https://tailscale.com/download/windows";default:return null}}function yn(t){switch(t){case"running":return"green";case"starting":case"needs_login":case"error":return"yellow";case"disabled":case"blocked_uninitialized":case"stopping":default:return"gray"}}function Cs({open:t,mobile:n,onClose:a}){const[i,l]=r.useState("tunnel"),u=r.useId(),f=[{id:"tunnel",label:s("settings.remoteAccessTunnelTab")},{id:"tailscale",label:s("settings.remoteAccessTailscaleTab")}],x=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":s("settings.remoteAccessTabsLabel"),children:f.map(b=>{const w=`${u}-${b.id}-tab`,v=`${u}-${b.id}-panel`,p=i===b.id;return e.jsx("button",{id:w,type:"button",role:"tab",className:"settings-model-tab","data-active":p?"true":void 0,"aria-selected":p,"aria-controls":v,onClick:()=>l(b.id),children:b.label},b.id)})}),i==="tunnel"?e.jsx("div",{id:`${u}-tunnel-panel`,"aria-labelledby":`${u}-tunnel-tab`,role:"tabpanel",children:e.jsx(ln,{})}):e.jsx("div",{id:`${u}-tailscale-panel`,"aria-labelledby":`${u}-tailscale-tab`,role:"tabpanel",children:e.jsx(bn,{configMode:"inline"})})]});return n?e.jsx(et,{open:t,title:s("settings.remoteAccessModalTitle"),description:s("settings.remoteAccessModalDescription"),height:"full",kind:"form",showHandle:!0,onClose:a,children:x}):e.jsx(ee,{open:t,title:s("settings.remoteAccessModalTitle"),description:s("settings.remoteAccessModalDescription"),size:"wide",onClose:a,children:x})}function os({title:t,description:n,actions:a,content:i,className:l}){return e.jsx(tt,{className:l,children:e.jsxs("section",{className:"mobile-workspace-home-header mobile-page-header",children:[e.jsx("h1",{className:"mobile-workspace-switcher-heading",children:t}),e.jsxs("div",{className:"mobile-workspace-home-toolbar-top mobile-page-header-main",children:[e.jsx("div",{className:"mobile-page-header-copy",children:e.jsx("div",{className:"mobile-workspace-home-switcher mobile-page-header-static-title",children:e.jsx("span",{className:"mobile-workspace-home-switcher-label",children:t})})}),a?e.jsx("div",{className:"mobile-workspace-home-toolbar-actions mobile-page-header-actions",children:a}):null]}),n?e.jsx("p",{className:"mobile-workspace-home-path mobile-page-header-description",children:n}):null,i?e.jsx("div",{className:"mobile-page-header-content",children:i}):null]})})}const Ms={start:43e3,end:47999};function Nn(t){return t==="appearance"||t==="model-management"||t==="server-connection"||t==="remote-access"||t==="security-privacy"||t==="software-update"}function wn(t){return t==="en-US"?s("locale.enUS"):s("locale.zhCN")}function Sn(t){return t==="beta"?s("settings.releaseBeta"):s("settings.releaseStable")}function Tn(t){switch(t){case"acceptEdits":return s("settings.permissionModeAcceptEdits");case"bypassPermissions":return s("settings.permissionModeBypassPermissions");default:return s("settings.permissionModeDefault")}}function kn(){const t=hs(),{theme:n,selectedTheme:a,autoTheme:i,setTheme:l,setAutoTheme:u}=Gs(),f=Hs(N=>N),x=ve(N=>N.profile.language),b=ve(N=>N.profile.defaultPermissionMode),w=se(N=>N.sessionDisplaySortMode),v=se(N=>N.showSystemFiles),p=se(N=>N.notificationPreferences.notifyOnPermissionRequest),D=se(N=>N.notificationPreferences.notifyOnSessionCompleted),j=se(N=>N.notificationPreferences.notifyOnSessionFailed),P={language:x,defaultPermissionMode:b,debugPortPools:ve(N=>N.profile.debugPortPools)??Ms},y=Re(),m=Vs(f.platform),c=m,g=ms(f)??"",[S,k]=r.useState(g);r.useEffect(()=>{k(g)},[g]);function o(){qs.clear(),je.resetToLocalFallback(),t("/login",{replace:!0})}function C(N){l(N)}function L(N){u(N)}function M(N){try{return Ee(N)}catch{return null}}const O=M(S),I=O!==null&&O!==g;function q(N){N.preventDefault(),O&&Z.update({hosts:f.hosts.map(B=>B.id===f.activeHostId?{...B,baseUrl:O,updatedAt:new Date().toISOString()}:B)})}const G=[{value:"default",label:s("settings.permissionModeDefault")},{value:"acceptEdits",label:s("settings.permissionModeAcceptEdits")},{value:"bypassPermissions",label:s("settings.permissionModeBypassPermissions")}],_=[{value:"createdAt",label:s("settings.sessionSortModeCreatedAt")},{value:"updatedAt",label:s("settings.sessionSortModeUpdatedAt")},{value:"title",label:s("settings.sessionSortModeTitle")}];function U(N){Z.update({releaseChannel:N==="beta"?"beta":"stable"})}function J(N){Z.update({autoReconnect:N})}function W(N){Z.update({autoCheckUpdate:N})}function H(N){const B=N==="acceptEdits"||N==="bypassPermissions"?N:"default";je.updateProfile({defaultPermissionMode:B}).catch(()=>{})}function V(N){const B=N==="updatedAt"||N==="title"?N:"createdAt";te.setSessionDisplaySortMode(B)}function T(N){te.setShowSystemFiles(N)}function A(N){te.setNotificationPreferences({notifyOnPermissionRequest:N})}function E(N){te.setNotificationPreferences({notifyOnSessionCompleted:N})}function d(N){te.setNotificationPreferences({notifyOnSessionFailed:N})}async function F(N){await je.updateProfile({debugPortPools:N})}return{platform:y,theme:n,selectedTheme:a,autoTheme:i,applyTheme:C,applyAutoTheme:L,runtimeConfig:f,accountPreferences:P,sessionDisplaySortMode:w,showSystemFiles:v,notifyOnPermissionRequest:p,notifyOnSessionCompleted:D,notifyOnSessionFailed:j,showServerSettings:c,canConfigureServerAddress:m,hostBaseUrlDraft:S,setHostBaseUrlDraft:k,canSaveHostBaseUrl:I,permissionModeOptions:G,sessionDisplaySortModeOptions:_,handleHostBaseUrlSubmit:q,handleLogout:o,updateReleaseChannel:U,updateAutoReconnect:J,updateAutoCheckUpdate:W,updateDefaultPermissionMode:H,updateSessionDisplaySortMode:V,updateShowSystemFiles:T,updateNotifyOnPermissionRequest:A,updateNotifyOnSessionCompleted:E,updateNotifyOnSessionFailed:d,updateDebugPortPools:F}}function Gn(){const t=kn(),n=Js();return t.platform.isMobile?e.jsx(Cn,{model:t,appVersion:n}):e.jsx(Dn,{model:t,appVersion:n})}function Dn({model:t,appVersion:n}){const[a,i]=r.useState(!1),[l,u]=r.useState(!1),{theme:f,selectedTheme:x,autoTheme:b,applyTheme:w,applyAutoTheme:v,runtimeConfig:p,accountPreferences:D,sessionDisplaySortMode:j,showSystemFiles:P,notifyOnPermissionRequest:y,notifyOnSessionCompleted:m,notifyOnSessionFailed:c,showServerSettings:g,hostBaseUrlDraft:S,setHostBaseUrlDraft:k,canSaveHostBaseUrl:o,permissionModeOptions:C,sessionDisplaySortModeOptions:L,platform:M,handleHostBaseUrlSubmit:O,handleLogout:I,updateReleaseChannel:q,updateAutoReconnect:G,updateAutoCheckUpdate:_,updateDefaultPermissionMode:U,updateSessionDisplaySortMode:J,updateShowSystemFiles:W,updateNotifyOnPermissionRequest:H,updateNotifyOnSessionCompleted:V,updateNotifyOnSessionFailed:T,updateDebugPortPools:A}=t;return e.jsxs("div",{className:"settings-page",children:[e.jsxs("div",{className:"settings-container",children:[e.jsx("h1",{className:"settings-title",children:s("settings.title")}),e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.appearance")}),e.jsxs("div",{className:"settings-card",children:[e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.language")}),e.jsx("span",{className:"settings-row-description",children:s("settings.languageDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx(ps,{})})]}),e.jsxs("div",{className:"settings-row settings-row-theme",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.theme")}),e.jsx("span",{className:"settings-row-description",children:s("settings.themeDescription")})]}),e.jsxs("div",{className:"settings-row-control settings-row-control-stretch",children:[e.jsxs("div",{className:"settings-theme-panel",children:[e.jsxs("div",{className:"settings-theme-toggle-row",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.autoTheme")}),e.jsx(z,{checked:b,label:s("settings.autoTheme"),onChange:v})]}),e.jsx("span",{className:"settings-theme-note",children:s("settings.autoThemeDescription")})]}),e.jsx("div",{className:"theme-selector",children:bs.map(E=>e.jsxs("button",{type:"button",className:`theme-card ${x===E.id&&!b?"active":""}`,"aria-pressed":x===E.id&&!b,disabled:b,onClick:()=>w(E.id),children:[e.jsx("span",{className:"theme-preview",style:{background:E.color}}),e.jsx("span",{className:"theme-label",children:fs(E)}),x===E.id&&!b?e.jsx("span",{className:"theme-check",children:"✓"}):null]},E.id))})]})]}),e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.workspaceSessionSortMode")}),e.jsx("span",{className:"settings-row-description",children:s("settings.workspaceSessionSortModeDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx("select",{"aria-label":s("settings.workspaceSessionSortMode"),className:"settings-select",value:j,onChange:E=>J(E.target.value),children:L.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.showSystemFiles")}),e.jsx("span",{className:"settings-row-description",children:s("settings.showSystemFilesDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx(z,{checked:P,label:s("settings.showSystemFiles"),onChange:W})})]})]})]}),g?e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.serverConnection")}),e.jsxs("div",{className:"settings-card",children:[e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.serverAddress")}),e.jsx("span",{className:"settings-row-description",children:s("settings.serverDescription")})]}),e.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:e.jsxs("form",{className:"settings-inline-form",onSubmit:O,children:[e.jsx("input",{"aria-label":s("settings.serverAddress"),className:"settings-text-input",value:S,onChange:E=>k(E.target.value)}),e.jsx("button",{className:"settings-button",disabled:!o,type:"submit",children:s("common.save")})]})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.autoReconnect")}),e.jsx("span",{className:"settings-row-description",children:s("settings.autoReconnectDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx(z,{checked:p.autoReconnect,label:s("settings.autoReconnect"),onChange:G})})]})]})]}):null,e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.modelManagement")}),e.jsx("div",{className:"settings-card",children:e.jsx("div",{className:"settings-row",children:e.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:e.jsx(vs,{})})})})]}),e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.remoteAccess")}),e.jsx("div",{className:"settings-card",children:e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.remoteAccessManageTitle")}),e.jsx("span",{className:"settings-row-description",children:s("settings.remoteAccessManageDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx("button",{className:"settings-button",type:"button",onClick:()=>u(!0),children:s("settings.remoteAccessManageAction")})})]})})]}),e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.securityPrivacy")}),e.jsxs("div",{className:"settings-card",children:[e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.defaultPermissionMode")}),e.jsx("span",{className:"settings-row-description",children:s("settings.defaultPermissionModeDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx("select",{"aria-label":s("settings.defaultPermissionMode"),className:"settings-select",value:D.defaultPermissionMode,onChange:E=>U(E.target.value),children:C.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.authDeviceManagement")}),e.jsx("span",{className:"settings-row-description",children:s("settings.authDeviceManagementDescription")})]}),e.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:e.jsx(Ns,{})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.notifyOnPermissionRequest")}),e.jsx("span",{className:"settings-row-description",children:s("settings.notifyOnPermissionRequestDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx(z,{checked:y,label:s("settings.notifyOnPermissionRequest"),onChange:H})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.notifyOnSessionCompleted")}),e.jsx("span",{className:"settings-row-description",children:s("settings.notifyOnSessionCompletedDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx(z,{checked:m,label:s("settings.notifyOnSessionCompleted"),onChange:V})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.notifyOnSessionFailed")}),e.jsx("span",{className:"settings-row-description",children:s("settings.notifyOnSessionFailedDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx(z,{checked:c,label:s("settings.notifyOnSessionFailed"),onChange:T})})]})]})]}),e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.debugPortPool")}),e.jsx("div",{className:"settings-card",children:e.jsx(Ps,{value:D.debugPortPools,onSave:A})})]}),e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.softwareUpdate")}),e.jsxs("div",{className:"settings-card",children:[e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.releaseChannel")}),e.jsx("span",{className:"settings-row-description",children:s("settings.releaseChannelDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsxs("select",{"aria-label":s("settings.releaseChannel"),className:"settings-select",value:p.releaseChannel,onChange:E=>q(E.target.value),children:[e.jsx("option",{value:"stable",children:s("settings.releaseStable")}),e.jsx("option",{value:"beta",children:s("settings.releaseBeta")})]})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsx("div",{className:"settings-row-label",children:e.jsx("span",{className:"settings-row-title",children:s("settings.serverUpdate")})}),e.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:e.jsx(Ts,{})})]}),M.isWeb?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-row",children:[e.jsx("div",{className:"settings-row-label",children:e.jsx("span",{className:"settings-row-title",children:s("settings.autoCheckUpdate")})}),e.jsx("div",{className:"settings-row-control",children:e.jsx(z,{checked:p.autoCheckUpdate,label:s("settings.autoCheckUpdate"),onChange:_})})]}),e.jsxs("div",{className:"settings-row",children:[e.jsx("div",{className:"settings-row-label",children:e.jsx("span",{className:"settings-row-title",children:s("settings.clientUpdate")})}),e.jsx("div",{className:"settings-row-control settings-row-control-stretch",children:e.jsx(xs,{})})]})]})]})]}),e.jsxs("section",{className:"settings-section",children:[e.jsx("h2",{className:"settings-section-title",children:s("settings.advancedSettings")}),e.jsx("div",{className:"settings-card",children:e.jsxs("div",{className:"settings-row",children:[e.jsxs("div",{className:"settings-row-label",children:[e.jsx("span",{className:"settings-row-title",children:s("settings.parallelTaskDebug")}),e.jsx("span",{className:"settings-row-description",children:s("settings.parallelTaskDebugDescription")})]}),e.jsx("div",{className:"settings-row-control",children:e.jsx("button",{className:"settings-button",type:"button",onClick:()=>i(!0),children:s("settings.parallelTaskDebugAction")})})]})})]}),e.jsxs("div",{className:"settings-footer settings-footer-with-logout",children:[e.jsxs("span",{className:"settings-version",children:["CodingNS v",n]}),e.jsx("button",{className:"settings-button settings-button-danger settings-button-sticky",onClick:I,type:"button",children:s("common.logout")})]})]}),e.jsx(it,{isOpen:a,onClose:()=>i(!1)}),e.jsx(Cs,{open:l,mobile:!1,onClose:()=>u(!1)})]})}function Cn({model:t,appVersion:n}){const a=hs(),{section:i}=Zs(),l=Nn(i)?i:null,u=[{id:"appearance",title:s("settings.appearance"),description:s("settings.appearanceSectionSummary"),value:wn(t.accountPreferences.language),icon:e.jsx(In,{})}];return t.showServerSettings&&u.push({id:"server-connection",title:s("settings.serverConnection"),description:s("settings.serverConnectionSectionSummary"),value:ms(t.runtimeConfig)??"",icon:e.jsx(On,{})}),u.push({id:"model-management",title:s("settings.modelManagement"),description:s("settings.modelManagementSectionSummary"),value:s("settings.modelManagementNavValue"),icon:e.jsx(Hn,{})},{id:"remote-access",title:s("settings.remoteAccess"),description:s("settings.remoteAccessSectionSummary"),value:s("settings.remoteAccessNavValue"),icon:e.jsx(Bn,{})},{id:"security-privacy",title:s("settings.securityPrivacy"),description:s("settings.securityPrivacySectionSummary"),value:Tn(t.accountPreferences.defaultPermissionMode),icon:e.jsx(Vn,{})},{id:"software-update",title:s("settings.softwareUpdate"),description:s("settings.softwareUpdateSectionSummary"),value:Sn(t.runtimeConfig.releaseChannel),icon:e.jsx(Fn,{})}),(l?u.find(x=>x.id===l)??null:null)?e.jsxs("div",{className:"settings-page settings-page-mobile mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(os,{title:s("settings.title")}),e.jsxs("div",{className:"settings-mobile-container",children:[l==="appearance"?e.jsx(Mn,{model:t}):null,l==="model-management"?e.jsx(Rn,{}):null,l==="server-connection"&&t.showServerSettings?e.jsx(Pn,{model:t}):null,l==="remote-access"?e.jsx(En,{model:t}):null,l==="security-privacy"?e.jsx(Ln,{model:t}):null,l==="software-update"?e.jsx(Un,{model:t}):null]}),e.jsx(us,{onLogout:t.handleLogout})]}):e.jsxs("div",{className:"settings-page settings-page-mobile mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(os,{title:s("settings.title")}),e.jsxs("div",{className:"settings-mobile-container",children:[e.jsx("section",{className:"settings-mobile-group-section",children:e.jsx("div",{className:"settings-mobile-list",children:u.map(x=>e.jsxs("button",{type:"button",className:"settings-mobile-nav-row",onClick:()=>a(`/settings/${x.id}`),children:[e.jsx("span",{className:"settings-mobile-nav-icon",children:x.icon}),e.jsxs("span",{className:"settings-mobile-nav-copy",children:[e.jsx("span",{className:"settings-mobile-nav-title",children:x.title}),e.jsx("span",{className:"settings-mobile-nav-description",children:x.description})]}),e.jsxs("span",{className:"settings-mobile-nav-trailing",children:[x.value?e.jsx("span",{className:"settings-mobile-nav-value",children:x.value}):null,e.jsx(qn,{})]})]},x.id))})}),e.jsx("div",{className:"settings-footer settings-footer-mobile",children:e.jsxs("span",{className:"settings-version",children:["CodingNS v",n]})})]}),e.jsx(us,{onLogout:t.handleLogout})]})}function Mn({model:t}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.language")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.languageDescription")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsx("div",{className:"settings-mobile-row-copy",children:e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.language")})}),e.jsx(ps,{variant:"compact",className:"settings-mobile-language-switcher"})]})})]}),e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.theme")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.themeDescription")}),e.jsxs("div",{className:"settings-mobile-list",children:[e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.autoTheme")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.autoThemeDescription")})]}),e.jsx(z,{checked:t.autoTheme,label:s("settings.autoTheme"),onChange:t.applyAutoTheme})]}),bs.map(n=>{const a=t.selectedTheme===n.id&&!t.autoTheme;return e.jsxs("button",{type:"button",className:`settings-mobile-choice-row${a?" active":""}`,"aria-pressed":a,disabled:t.autoTheme,onClick:()=>t.applyTheme(n.id),children:[e.jsxs("span",{className:"settings-mobile-choice-leading",children:[e.jsx("span",{className:"settings-mobile-choice-dot",style:{background:n.color},"aria-hidden":"true"}),e.jsx("span",{className:"settings-mobile-choice-label",children:fs(n)})]}),e.jsx("span",{className:"settings-mobile-choice-indicator","aria-hidden":"true",children:a?e.jsx(_n,{}):null})]},n.id)})]})]}),e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.fileManager")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.workspaceSessionSortModeDescription")}),e.jsxs("div",{className:"settings-mobile-list",children:[e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.workspaceSessionSortMode")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.workspaceSessionSortModeDescription")})]}),e.jsx("select",{"aria-label":s("settings.workspaceSessionSortMode"),className:"settings-select settings-mobile-select",value:t.sessionDisplaySortMode,onChange:n=>t.updateSessionDisplaySortMode(n.target.value),children:t.sessionDisplaySortModeOptions.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.showSystemFiles")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.showSystemFilesDescription")})]}),e.jsx(z,{checked:t.showSystemFiles,label:s("settings.showSystemFiles"),onChange:t.updateShowSystemFiles})]})]})]})]})}function Pn({model:t}){return e.jsxs(e.Fragment,{children:[t.canConfigureServerAddress?e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.serverAddress")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.serverDescription")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsxs("form",{className:"settings-mobile-form-stack",onSubmit:t.handleHostBaseUrlSubmit,children:[e.jsx("input",{"aria-label":s("settings.serverAddress"),className:"settings-text-input settings-mobile-input",value:t.hostBaseUrlDraft,onChange:n=>t.setHostBaseUrlDraft(n.target.value)}),e.jsx("button",{className:"settings-mobile-primary-button",disabled:!t.canSaveHostBaseUrl,type:"submit",children:s("common.save")})]})})]}):null,e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.serverConnection")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.autoReconnect")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.autoReconnectDescription")})]}),e.jsx(z,{checked:t.runtimeConfig.autoReconnect,label:s("settings.autoReconnect"),onChange:t.updateAutoReconnect})]})})]})]})}function Ln({model:t}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.securityPrivacy")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.securityPrivacySectionSummary")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.defaultPermissionMode")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.defaultPermissionModeDescription")})]}),e.jsx("select",{"aria-label":s("settings.defaultPermissionMode"),className:"settings-select settings-mobile-select",value:t.accountPreferences.defaultPermissionMode,onChange:n=>t.updateDefaultPermissionMode(n.target.value),children:t.permissionModeOptions.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]})})]}),e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.authDeviceManagement")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.authDeviceManagementDescription")}),e.jsx("div",{className:"settings-mobile-panel-shell",children:e.jsx(Ns,{compact:!0})})]}),e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.debugPortPool")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsx(Ps,{value:t.accountPreferences.debugPortPools,onSave:t.updateDebugPortPools,compact:!0})})]}),e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.notificationSettings")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.notificationSettingsDescription")}),e.jsxs("div",{className:"settings-mobile-list",children:[e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.notifyOnPermissionRequest")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.notifyOnPermissionRequestDescription")})]}),e.jsx(z,{checked:t.notifyOnPermissionRequest,label:s("settings.notifyOnPermissionRequest"),onChange:t.updateNotifyOnPermissionRequest})]}),e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.notifyOnSessionCompleted")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.notifyOnSessionCompletedDescription")})]}),e.jsx(z,{checked:t.notifyOnSessionCompleted,label:s("settings.notifyOnSessionCompleted"),onChange:t.updateNotifyOnSessionCompleted})]}),e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.notifyOnSessionFailed")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.notifyOnSessionFailedDescription")})]}),e.jsx(z,{checked:t.notifyOnSessionFailed,label:s("settings.notifyOnSessionFailed"),onChange:t.updateNotifyOnSessionFailed})]})]})]})]})}function Ps(t){const[n,a]=r.useState(()=>ds(t.value)),[i,l]=r.useState(!1),[u,f]=r.useState(null),[x,b]=r.useState(!1);r.useEffect(()=>{a(ds(t.value))},[t.value]);async function w(){f(null),b(!1);let v;try{v=An(n)}catch(p){f(p instanceof Error?p.message:s("settings.debugPortPoolSaveFailed"));return}try{l(!0),await t.onSave(v),b(!0)}catch(p){f(p instanceof Error?p.message:s("settings.debugPortPoolSaveFailed"))}finally{l(!1)}}return e.jsxs("div",{className:t.compact?"settings-mobile-form-stack":"settings-debug-port-pool-editor",children:[e.jsxs("div",{className:t.compact?"settings-mobile-form-row":"settings-row",children:[e.jsx("div",{className:t.compact?"settings-mobile-row-copy":"settings-row-label settings-debug-port-pool-label",children:e.jsx("span",{className:t.compact?"settings-mobile-row-title":"settings-row-title",children:s("settings.debugPortPoolRangeLabel")})}),e.jsx("div",{className:t.compact?"settings-mobile-form-stack":"settings-row-control settings-row-control-stretch",children:e.jsxs("div",{className:"settings-inline-form",children:[e.jsx("input",{"aria-label":`${s("settings.debugPortPool")} ${s("settings.debugPortPoolStart")}`,className:"settings-text-input",inputMode:"numeric",value:n.start,onChange:v=>{const p=v.target.value;a(D=>({...D,start:p}))}}),e.jsx("span",{children:s("settings.debugPortPoolRangeSeparator")}),e.jsx("input",{"aria-label":`${s("settings.debugPortPool")} ${s("settings.debugPortPoolEnd")}`,className:"settings-text-input",inputMode:"numeric",value:n.end,onChange:v=>{const p=v.target.value;a(D=>({...D,end:p}))}}),e.jsx("button",{type:"button",className:t.compact?"settings-mobile-primary-button":"settings-button",disabled:i,onClick:()=>{w()},children:i?s("common.loading"):s("common.save")}),x?e.jsx("span",{children:s("settings.debugPortPoolSaved")}):null]})})]}),u?e.jsx("p",{className:"status-text settings-debug-port-pool-feedback","data-tone":"error",children:u}):null]})}function ds(t){const n=t??Ms;return{start:String(n.start),end:String(n.end)}}function An(t){const n=Number.parseInt(t.start,10),a=Number.parseInt(t.end,10);if(!Number.isInteger(n)||!Number.isInteger(a))throw new Error(s("settings.debugPortPoolValidationInteger"));if(n<1024||a>65535||n>=a)throw new Error(s("settings.debugPortPoolValidationRange"));return{start:n,end:a}}function En({model:t}){const[n,a]=r.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.remoteAccess")}),e.jsx("p",{className:"settings-mobile-group-note",children:s("settings.remoteAccessManageDescription")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.remoteAccessManageTitle")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.remoteAccessSectionSummary")})]}),e.jsx("button",{className:"settings-mobile-primary-button",type:"button",onClick:()=>a(!0),children:s("settings.remoteAccessManageAction")})]})})]}),e.jsx(Cs,{open:n,mobile:!0,onClose:()=>a(!1)})]})}function Rn(){return e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.modelManagement")}),e.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-model-shell",children:e.jsx(vs,{})})]})}function Un({model:t}){return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.softwareUpdate")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsxs("div",{className:"settings-mobile-row-copy",children:[e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.releaseChannel")}),e.jsx("span",{className:"settings-mobile-row-description",children:s("settings.releaseChannelDescription")})]}),e.jsxs("select",{"aria-label":s("settings.releaseChannel"),className:"settings-select settings-mobile-select",value:t.runtimeConfig.releaseChannel,onChange:n=>t.updateReleaseChannel(n.target.value),children:[e.jsx("option",{value:"stable",children:s("settings.releaseStable")}),e.jsx("option",{value:"beta",children:s("settings.releaseBeta")})]})]})})]}),e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.serverUpdate")}),e.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-update-shell",children:e.jsx(Ts,{})})]}),t.platform.isWeb?null:e.jsxs("section",{className:"settings-mobile-group-section",children:[e.jsx("h2",{className:"settings-mobile-group-title",children:s("settings.clientUpdate")}),e.jsx("div",{className:"settings-mobile-list",children:e.jsxs("div",{className:"settings-mobile-form-row",children:[e.jsx("div",{className:"settings-mobile-row-copy",children:e.jsx("span",{className:"settings-mobile-row-title",children:s("settings.autoCheckUpdate")})}),e.jsx(z,{checked:t.runtimeConfig.autoCheckUpdate,label:s("settings.autoCheckUpdate"),onChange:t.updateAutoCheckUpdate})]})}),e.jsx("div",{className:"settings-mobile-panel-shell settings-mobile-update-shell",children:e.jsx(xs,{})})]})]})}function us({onLogout:t}){return e.jsx("div",{className:"settings-mobile-sticky-footer",children:e.jsx("button",{type:"button",className:"settings-mobile-danger-button settings-mobile-danger-button-sticky",onClick:t,children:s("common.logout")})})}function z({checked:t,label:n,onChange:a}){return e.jsxs("label",{className:"settings-mobile-switch","aria-label":n,onClick:i=>{i.target instanceof HTMLInputElement||(i.preventDefault(),a(!t))},children:[e.jsx("input",{type:"checkbox","aria-label":n,checked:t,onChange:i=>a(i.target.checked)}),e.jsx("span",{className:"settings-mobile-switch-track","aria-hidden":"true",children:e.jsx("span",{className:"settings-mobile-switch-thumb"})})]})}function In(){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M10 3.5a6.5 6.5 0 1 0 6.5 6.5c0-.8-.6-1.4-1.4-1.4h-1.6A1.5 1.5 0 0 1 12 7.1V5.5c0-1.1-.9-2-2-2Z"}),e.jsx("circle",{cx:"6.6",cy:"9.2",r:".8",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"8.8",cy:"6.8",r:".8",fill:"currentColor",stroke:"none"}),e.jsx("circle",{cx:"12.1",cy:"6.6",r:".8",fill:"currentColor",stroke:"none"})]})}function On(){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M4 7.5 10 4l6 3.5v5L10 16l-6-3.5v-5Z"}),e.jsx("path",{d:"M10 9.5V16"}),e.jsx("path",{d:"M4 7.5 10 11l6-3.5"})]})}function Fn(){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("rect",{x:"3.5",y:"4",width:"13",height:"9.5",rx:"2.2"}),e.jsx("path",{d:"M7 16h6"}),e.jsx("path",{d:"M10 13.5V16"}),e.jsx("path",{d:"m8 8 2 2 3-3"})]})}function Bn(){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("circle",{cx:"10",cy:"10",r:"5.8"}),e.jsx("path",{d:"M10 4.2c1.5 1.3 2.4 3.5 2.4 5.8s-.9 4.5-2.4 5.8c-1.5-1.3-2.4-3.5-2.4-5.8s.9-4.5 2.4-5.8Z"}),e.jsx("path",{d:"M4.6 8.1h10.8"}),e.jsx("path",{d:"M4.6 11.9h10.8"})]})}function Hn(){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[e.jsx("rect",{x:"3.5",y:"4",width:"13",height:"12",rx:"2.5"}),e.jsx("path",{d:"M6.2 8.1h7.6M6.2 11.9h4.1",strokeLinecap:"round"}),e.jsx("path",{d:"m12.8 11.3 1.3 1.3 2-2.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Vn(){return e.jsxs("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M10 3.2 15 5v4.4c0 3-1.9 5.8-5 7.4-3.1-1.6-5-4.4-5-7.4V5l5-1.8Z"}),e.jsx("path",{d:"m8.3 9.8 1.2 1.2 2.4-2.5"})]})}function qn(){return e.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:e.jsx("path",{d:"m4 2 4 4-4 4"})})}function _n(){return e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"m3.5 8.2 2.6 2.6 6-6"})})}export{Gn as SettingsPage};
@@ -1 +0,0 @@
1
- import{b as s,j as e,t as n,O as Ve}from"./index-Byp9hJ0c.js";import{D as we}from"./WorkbenchModal-Ctob14VR.js";import{M as Le,v as ze}from"./MobileSheet-DLg-gX1t.js";import{u as Xe,X as K,r as ve,w as Ke,aP as Oe}from"./WorkbenchLayout-ByFw4eeu.js";import{u as Je,d as Qe,e as Ye}from"./App-DkvE5EyM.js";import{b as Ze,g as ye,r as Ne,s as ea,u as aa,k as na,m as ra}from"./terminal-runtime-meta-AWXJpN4r.js";import{T as la,i as ta}from"./TerminalRuntimeFallbackModal-CRhOQOsT.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";const O={mode:"command",name:"",cwd:"",target:"",args:"",port:"",proxyEnabled:!1},Te=60*1e3;function ia(l){return l?new Date(l).toLocaleString():n("common.unknown")}function sa(l){return l.split(" ").map(t=>t.trim()).filter(Boolean)}function oa(l){var t,c,u;return((t=l.find(p=>p.id==="cmd"&&p.available))==null?void 0:t.id)??((c=l.find(p=>p.available))==null?void 0:c.id)??((u=l[0])==null?void 0:u.id)??""}function ca(l){const t=l.name.trim();if(t)return t;const c=l.target.trim(),u=l.args.trim();return c?u?`${c} ${u}`:c:l.mode==="script"?n("terminalManager.defaultScriptName"):n("terminalManager.defaultCommandName")}function ma(l){const t=l.args.join(" ");return t?`${l.command} ${t}`:l.command}function da(l){return{mode:Pe(l),name:l.name,cwd:l.cwd,target:l.command,args:l.args.join(" "),port:l.port===null?"":String(l.port),proxyEnabled:l.proxyEnabled}}function ua(l){return Ve(`/proxy/${encodeURIComponent(l)}`)}function Pe(l){const t=l.command.toLowerCase();return t.endsWith(".ps1")||t.endsWith(".bat")||t.endsWith(".cmd")||t.endsWith(".sh")?"script":"command"}function ga(l){const t=l.trim();if(!t)return null;const c=Number(t);return Number.isInteger(c)?c:Number.NaN}function ke(l,t){return l.get(t)??null}function pa(l,t){return l.port===null?{tone:"untracked",title:n("terminalManager.portUnset"),summary:n("terminalManager.portUnsetDescription"),badgeLabel:n("terminalManager.portUnset")}:t!=null&&t.occupied?{tone:"running",title:n("terminalManager.portOccupied"),summary:t.processName||n("terminalManager.processCommandFallback"),badgeLabel:t.processId?`PID ${t.processId}`:n("terminalManager.statusRunning"),badgeTone:"success"}:{tone:"idle",title:n("terminalManager.portAvailable"),summary:n("terminalManager.portAvailableDescription"),badgeLabel:n("terminalManager.statusStopped")}}function ha(l){return l!=null&&l.terminationScope?l.terminationScope==="process_group"?n("terminalManager.terminationScopeProcessGroup"):n("terminalManager.terminationScopeProcess"):null}function xa({open:l,mobile:t=!1,title:c,description:u,onClose:p,children:N,className:m}){return t?e.jsx(Le,{open:l,title:c,description:u,kind:"form",height:"three-quarter",className:m,bodyClassName:"terminal-manager-modal-body",showHandle:!0,onClose:p,children:N}):e.jsx(we,{open:l,title:c,description:u,size:"regular",layout:"form",className:["terminal-manager-modal-card",m].filter(Boolean).join(" "),bodyClassName:"terminal-manager-modal-body",onClose:p,children:N})}function ba({open:l,mobile:t=!1,busy:c,title:u,description:p,confirmLabel:N,onClose:m,onConfirm:h,className:T}){const R=e.jsxs(ze,{className:"terminal-manager-confirm-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:c,onClick:m,children:n("common.cancel")}),e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:c,onClick:()=>{h()},children:c?n("terminalManager.templateRemoving"):N})]});return t?e.jsx(Le,{open:l,title:u,description:p,kind:"action",height:"auto",dismissible:!c,showHandle:!0,showCancelButton:!1,className:T,bodyClassName:"terminal-manager-confirm-body",footer:R,onClose:m,children:null}):e.jsx(we,{open:l,title:u,description:p,size:"compact",layout:"confirm",dismissible:!c,className:["terminal-manager-confirm-modal",T].filter(Boolean).join(" "),bodyClassName:"terminal-manager-confirm-body",footer:R,onClose:m,children:null})}function Ce({label:l,value:t,options:c,open:u,onToggle:p,onChange:N}){const m=c.find(h=>h.value===t)??c[0]??null;return e.jsxs("div",{className:"field-group terminal-manager-mobile-picker",children:[e.jsx("span",{children:l}),e.jsxs("button",{type:"button",className:"terminal-manager-mobile-picker-trigger","aria-label":`${l} ${(m==null?void 0:m.label)??""}`.trim(),"aria-expanded":u?"true":"false",onClick:p,children:[e.jsxs("span",{className:"terminal-manager-mobile-picker-copy",children:[e.jsx("strong",{children:(m==null?void 0:m.label)??n("common.unknown")}),m!=null&&m.description?e.jsx("span",{children:m.description}):null]}),e.jsx(fa,{expanded:u})]}),u?e.jsx("div",{className:"terminal-manager-mobile-picker-list",role:"listbox","aria-label":l,children:c.map(h=>{const T=h.value===t;return e.jsxs("button",{type:"button",role:"option",className:"terminal-manager-mobile-picker-option","aria-selected":T,disabled:h.disabled,onClick:()=>{N(h.value)},children:[e.jsxs("span",{className:"terminal-manager-mobile-picker-option-copy",children:[e.jsx("strong",{children:h.label}),h.description?e.jsx("span",{children:h.description}):null]}),e.jsx("span",{className:"terminal-manager-mobile-picker-option-indicator","aria-hidden":"true",children:T?e.jsx(Ma,{}):e.jsx(ja,{})})]},h.value||"__empty__")})}):null]})}function fa({expanded:l}){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",className:"terminal-manager-mobile-picker-chevron","data-expanded":l?"true":"false",children:e.jsx("path",{d:"M4 6.5L8 10l4-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.7"})})}function ja(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M6 3.5L10.5 8 6 12.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.6"})})}function Ma(){return e.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:e.jsx("path",{d:"M3.5 8.5L6.5 11.5L12.5 5.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.8"})})}function Sa({className:l,currentWorkspaceId:t,navigationGroups:c,externalWindowMode:u=!1,workbenchShellOverrides:p}){var be,fe,je,Me;const N=Je(),m=Qe(),h=Xe(),{subscribeTerminalManagerSnapshot:T,requestTerminalManagerRefresh:R,addTerminalManagerSnapshotListener:re}={...h,...p},i=(t==null?void 0:t.trim())||null,[J,G]=s.useState([]),[f,P]=s.useState([]),[S,D]=s.useState([]),[x,Q]=s.useState([]),[W,Y]=s.useState(""),[A,E]=s.useState(""),[d,j]=s.useState(O),[_,q]=s.useState(null),[I,H]=s.useState(null),[Se,le]=s.useState([]),[te,V]=s.useState(!1),[Z,ie]=s.useState(!1),[se,oe]=s.useState(null),[ce,me]=s.useState(null),[k,de]=s.useState(null),[M,U]=s.useState(null),[z,ee]=s.useState(null),[ue,ge]=s.useState(!1),[pe,C]=s.useState(null),{showToast:b}=Ye(),B=(l==null?void 0:l.includes("mobile-tool-process-panel"))??!1,$=_!==null,he=_==="edit"?f.find(a=>a.id===I)??null:null,w=_==="edit";s.useEffect(()=>{K("terminal_manager.props",{currentWorkspaceId:t,workspaceCount:c.length,externalWindowMode:u})},[t,u,c.length]);const g=s.useMemo(()=>x.find(a=>a.id===W)??null,[W,x]),F=s.useMemo(()=>Ze(m.ui.osFamily),[m.ui.osFamily]),xe=s.useMemo(()=>new Map(S.map(a=>[a.templateId,a])),[S]),Ee=s.useMemo(()=>S.filter(a=>a.occupied).length,[S]),Ie=s.useMemo(()=>f.filter(a=>a.port!==null).length,[f]),Fe=(g==null?void 0:g.available)===!1&&x.length>0;s.useEffect(()=>{Y(a=>x.length?a&&x.some(r=>r.id===a)?a:oa(x):"")},[x]),s.useEffect(()=>{!$||!i||x.length>0||y(i)},[i,x.length,$]),s.useEffect(()=>{$||C(null)},[$]),s.useEffect(()=>{_==="edit"&&I&&!he&&(q(null),H(null),j(O),E(""),C(null))},[he,I,_]),s.useEffect(()=>{!M||k===M.templateId||f.some(a=>a.id===M.templateId)||U(null)},[M,k,f]),s.useEffect(()=>{if(!i){G([]),P([]),D([]),V(!1);return}const a=ve(ne(i),Te);K("terminal_manager.snapshot",{workspaceId:i,cached:!!a,cachedTemplateCount:(a==null?void 0:a.templates.length)??0,cachedStatusCount:(a==null?void 0:a.templateStatuses.length)??0}),a?(G(a.terminals),P(a.templates),D(a.templateStatuses),Q(a.shellOptions??[]),V(!1)):(G([]),P([]),D([]),Q([]),V(!0))},[i]),s.useEffect(()=>{if(i)return re(a=>{a.workspaceId===i&&(K("terminal_manager.snapshot_received",{workspaceId:a.workspaceId,terminalCount:a.terminals.length,templateCount:a.templates.length,statusCount:a.templateStatuses.length}),Re(a),V(!1))})},[i,re]),s.useEffect(()=>{if(!i)return;const a=ve(ne(i),Te)!==null;if(T(i),a){const r=window.setTimeout(()=>{y(i)},1500);return()=>{window.clearTimeout(r)}}y(i)},[i,R,T]),s.useEffect(()=>{i&&Ke(ne(i),{terminals:J,templates:f,templateStatuses:S,shellOptions:x})},[i,x,S,f,J]);function Re(a){G(a.terminals),P(a.templates),D(a.templateStatuses),Q(a.shellOptions??[])}function y(a){K("terminal_manager.refresh_requested",{workspaceId:a}),R(a)}function X(){q(null),H(null),j(O),E(""),C(null)}function De(){H(null),j(O),E(""),q("create")}function Ae(a){H(a.id),j(da(a)),E(a.runtimeType??""),q("edit")}async function _e(a){if(i){me(a);try{await ea(a),y(i),b({title:n("terminalManager.stopProcessSuccess"),tone:"success"})}catch(r){b({title:r instanceof Error?r.message:n("terminalManager.stopProcessFailed"),tone:"error"})}finally{me(null)}}}async function Ue(){if(!i||!d.target.trim())return;const a=ga(d.port);if(Number.isNaN(a)){b({title:n("terminalManager.invalidPort"),tone:"error"});return}if(d.proxyEnabled&&a===null){b({title:n("terminalManager.proxyPortRequired"),tone:"error"});return}ie(!0);try{const r={workspaceId:i,name:ca(d),cwd:d.cwd.trim()||void 0,command:d.target.trim(),args:sa(d.args),port:a,proxyEnabled:d.proxyEnabled,runtimeType:A||null};if(w&&I){const o=await aa(I,r);P(v=>v.map(L=>L.id===o.id?o:L))}else await na(r);X(),y(i),b({title:w?n("terminalManager.templateUpdateSuccess"):n("terminalManager.templateSaveSuccess"),tone:"success"})}catch(r){b({title:r instanceof Error?r.message:w?n("terminalManager.templateUpdateFailed"):n("terminalManager.templateSaveFailed"),tone:"error"})}finally{ie(!1)}}async function Be(a){const r=await m.bridge.openExternal(a);r.ok||b({title:r.detail||n("terminalManager.openProxyUrlFailed"),tone:"error"})}async function $e(a,r){if(i){de(a.id);try{await ra(a.id),P(o=>o.filter(v=>v.id!==a.id)),D(o=>o.filter(v=>v.templateId!==a.id)),le(o=>o.filter(v=>v!==a.id)),U(o=>(o==null?void 0:o.templateId)===a.id?null:o),I===a.id&&X(),y(i),b({title:n("terminalManager.templateDeleteSuccess"),tone:"success"})}catch(o){b({title:o instanceof Error?o.message:n("terminalManager.templateDeleteFailed"),tone:"error"})}finally{de(null)}}}async function Ge(a){if(!i)return;const r=g!=null&&g.available?g.shell:void 0;oe(a);try{await Ne(a,{shell:r}),y(i),b({title:n("terminalManager.templateRunSuccess"),tone:"success"})}catch(o){if(ta(o)){ee({templateId:a,shell:r});return}b({title:o instanceof Error?o.message:n("terminalManager.templateRunFailed"),tone:"error"})}finally{oe(null)}}async function We(){if(!(!i||!z)){ge(!0);try{await Ne(z.templateId,{shell:z.shell,runtimeType:"embedded-pty"}),ee(null),y(i),b({title:n("terminalManager.templateRunSuccess"),tone:"success"})}catch(a){b({title:a instanceof Error?a.message:n("terminalManager.templateRunFailed"),tone:"error"})}finally{ge(!1)}}}function qe(a){le(r=>r.includes(a)?r.filter(o=>o!==a):[...r,a])}return c.length?i?e.jsxs("section",{className:["conversation-panel","surface-card","terminal-manager-panel",l].filter(Boolean).join(" "),children:[e.jsx(la,{open:z!==null,busy:ue,onClose:()=>{ue||ee(null)},onConfirmFallback:()=>{We()}}),e.jsxs("div",{className:"terminal-manager-header terminal-manager-desktop-header",children:[e.jsx("div",{className:"terminal-manager-panel-heading",children:e.jsxs("div",{children:[e.jsx("h2",{children:n("terminalManager.templateSectionTitle")}),e.jsx("p",{className:"status-text",children:n("terminalManager.desktopPanelDescription")})]})}),e.jsxs("div",{className:"terminal-manager-overview",children:[e.jsxs("article",{className:"terminal-manager-overview-card",children:[e.jsx("span",{children:n("terminalManager.runningCountLabel")}),e.jsx("strong",{children:Ee})]}),e.jsxs("article",{className:"terminal-manager-overview-card",children:[e.jsx("span",{children:n("terminalManager.portWatchCountLabel")}),e.jsx("strong",{children:Ie})]}),e.jsxs("article",{className:"terminal-manager-overview-card",children:[e.jsx("span",{children:n("terminalManager.terminalCountLabel")}),e.jsx("strong",{children:J.length})]})]}),e.jsxs("div",{className:"terminal-manager-toolbar terminal-manager-toolbar-header",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:!i,onClick:()=>{i&&N(Oe(i))},children:n("terminalManager.openWorkspaceDebugAction")}),e.jsx("button",{className:"ghost-button",type:"button",disabled:!i||te,onClick:()=>{i&&y(i)},children:n("terminalManager.refresh")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!i,onClick:()=>{De()},children:n("terminalManager.openCreateModalAction")})]})]}),e.jsxs("section",{className:"terminal-manager-section",children:[e.jsxs("div",{className:"terminal-manager-section-header",children:[e.jsxs("div",{children:[e.jsx("h3",{children:n("terminalManager.templateSectionTitle")}),e.jsx("p",{className:"status-text",children:n("terminalManager.templateSectionDescription")})]}),e.jsx("span",{className:"workbench-section-counter",children:f.length})]}),te&&!f.length?e.jsx("p",{className:"status-text",children:n("common.loading")}):null,f.length?e.jsx("div",{className:"terminal-manager-list",children:f.map(a=>{const r=ke(xe,a.id),o=pa(a,r),v=ha(r),L=Se.includes(a.id),He=L?n("terminalManager.hideDetailsAction"):n("terminalManager.showDetailsAction"),ae=a.proxyEnabled&&a.proxySlug?ua(a.proxySlug):null;return e.jsxs("article",{className:"terminal-manager-card terminal-manager-desktop-card","data-tone":o.tone,"data-expanded":L?"true":"false",children:[e.jsxs("div",{className:"terminal-manager-card-header",children:[e.jsxs("div",{className:"terminal-manager-card-title",children:[e.jsx("span",{className:"terminal-manager-card-indicator","aria-hidden":"true"}),e.jsx("strong",{children:a.name})]}),e.jsxs("div",{className:"terminal-manager-card-tools",children:[e.jsx("span",{className:"badge terminal-runtime-badge",children:ye(a.runtimeType,m.ui.osFamily)}),e.jsx("span",{className:"badge",children:Pe(a)==="script"?n("terminalManager.scriptMode"):n("terminalManager.commandMode")}),e.jsx("button",{className:"terminal-manager-detail-toggle",type:"button","aria-label":He,"aria-expanded":L,onClick:()=>{qe(a.id)},children:"i"})]})]}),e.jsxs("div",{className:"terminal-manager-status-panel",children:[e.jsxs("div",{className:"terminal-manager-status-copy",children:[e.jsx("p",{className:"terminal-manager-status-title",children:o.title}),e.jsx("p",{className:"status-text",children:o.summary})]}),e.jsxs("div",{className:"terminal-manager-status-badges",children:[e.jsx("span",{className:"terminal-manager-stat-pill",children:a.port===null?n("terminalManager.portUnset"):`${n("terminalManager.portLabel")} ${a.port}`}),e.jsx("span",{className:"badge","data-tone":o.badgeTone,children:o.badgeLabel}),r!=null&&r.occupied&&r.processGroupId?e.jsx("span",{className:"badge",children:`PGID ${r.processGroupId}`}):null,a.proxyEnabled?e.jsx("span",{className:"badge",children:n("terminalManager.proxyEnabled")}):null]})]}),e.jsxs("div",{className:"terminal-manager-actions",children:[r!=null&&r.occupied?e.jsx("button",{className:"secondary-button",type:"button",disabled:ce===a.id,onClick:()=>{_e(a.id)},children:ce===a.id?n("terminalManager.stoppingProcess"):n("terminalManager.stopProcessAction")}):null,e.jsx("button",{className:"secondary-button",type:"button",disabled:se===a.id||Fe,onClick:()=>{Ge(a.id)},children:se===a.id?n("terminalManager.runningTemplate"):n("terminalManager.runTemplateAction")})]}),L?e.jsxs("section",{className:"terminal-manager-details","aria-label":n("terminalManager.detailsSectionTitle"),children:[e.jsxs("div",{className:"terminal-manager-detail-grid",children:[e.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[e.jsx("span",{children:n("terminalManager.commandPreviewLabel")}),e.jsx("strong",{children:ma(a)})]}),e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminalManager.cwdLabel")}),e.jsx("strong",{children:a.cwd})]}),e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminal.runtimeField")}),e.jsx("strong",{children:ye(a.runtimeType,m.ui.osFamily)})]}),e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminalManager.updatedAt")}),e.jsx("strong",{children:ia(a.updatedAt)})]}),e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminalManager.portLabel")}),e.jsx("strong",{children:a.port===null?n("terminalManager.portUnset"):a.port})]}),e.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[e.jsx("span",{children:n("terminalManager.proxyField")}),e.jsx("strong",{children:ae??n("terminalManager.proxyDisabledDescription")})]}),r!=null&&r.processId?e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminalManager.processIdLabel")}),e.jsx("strong",{children:r.processId})]}):null,r!=null&&r.processGroupId?e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminalManager.processGroupIdLabel")}),e.jsx("strong",{children:r.processGroupId})]}):null,v?e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminalManager.terminationScopeLabel")}),e.jsx("strong",{children:v})]}):null,r!=null&&r.parentProcessId?e.jsxs("div",{className:"terminal-manager-detail-item",children:[e.jsx("span",{children:n("terminalManager.parentProcessIdLabel")}),e.jsx("strong",{children:r.parentProcessId})]}):null,r!=null&&r.processCommandLine?e.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[e.jsx("span",{children:n("terminalManager.processCommandLabel")}),e.jsx("strong",{children:r.processCommandLine})]}):null,r!=null&&r.parentProcessCommandLine?e.jsxs("div",{className:"terminal-manager-detail-item terminal-manager-detail-item-wide",children:[e.jsx("span",{children:n("terminalManager.parentProcessCommandLabel")}),e.jsx("strong",{children:r.parentProcessCommandLine})]}):null]}),e.jsxs("div",{className:"terminal-manager-actions terminal-manager-detail-actions",children:[ae?e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>{Be(ae)},children:n("terminalManager.openProxyUrlAction")}):null,e.jsx("button",{className:"secondary-button",type:"button",disabled:Z||k===a.id,onClick:()=>{Ae(a)},children:n("terminalManager.editAction")}),e.jsx("button",{className:"secondary-button workbench-danger-button",type:"button",disabled:k===a.id,onClick:()=>{U({templateId:a.id,name:a.name,occupied:!!(r!=null&&r.occupied)})},children:k===a.id?n("terminalManager.templateRemoving"):n("terminalManager.removeAction")})]})]}):null]},a.id)})}):e.jsx("section",{className:"workbench-empty-state minimal",children:e.jsx("p",{children:n("terminalManager.emptyTemplateBody")})})]}),e.jsx(xa,{open:$,mobile:B,title:w?n("terminalManager.editModalTitle"):n("terminalManager.createModalTitle"),description:w?n("terminalManager.editModalDescription"):n("terminalManager.createModalDescription"),className:B?"terminal-manager-mobile-modal":void 0,onClose:X,children:e.jsxs("section",{className:"terminal-manager-modal-form",children:[B?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{label:n("terminalManager.shellField"),value:W,open:pe==="shell",options:x.map(a=>({value:a.id,label:a.label,description:a.available?null:a.unavailableReason??n("terminalManager.shellUnavailable"),disabled:!a.available})),onToggle:()=>{C(a=>a==="shell"?null:"shell")},onChange:a=>{Y(a),C(null)}}),(g==null?void 0:g.available)===!1&&g.unavailableReason?e.jsx("p",{className:"status-text",children:g.unavailableReason}):null,e.jsx(Ce,{label:n("terminal.runtimeField"),value:A,open:pe==="runtime",options:F.map(a=>({value:a.value,label:a.label,description:a.description})),onToggle:()=>{C(a=>a==="runtime"?null:"runtime")},onChange:a=>{E(a),C(null)}}),e.jsx("p",{className:"status-text",children:((be=F.find(a=>a.value===A))==null?void 0:be.description)??((fe=F[0])==null?void 0:fe.description)})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field-group",children:[e.jsx("span",{children:n("terminalManager.shellField")}),e.jsx("select",{value:W,onChange:a=>{Y(a.target.value)},children:x.map(a=>e.jsx("option",{value:a.id,disabled:!a.available,children:a.available?a.label:`${a.label} - ${n("terminalManager.shellUnavailable")}`},a.id))}),(g==null?void 0:g.available)===!1&&g.unavailableReason?e.jsx("p",{className:"status-text",children:g.unavailableReason}):null]}),e.jsxs("div",{className:"field-group",children:[e.jsx("span",{children:n("terminal.runtimeField")}),e.jsx("select",{value:A,onChange:a=>{E(a.target.value)},children:F.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value||"auto"))}),e.jsx("p",{className:"status-text",children:((je=F.find(a=>a.value===A))==null?void 0:je.description)??((Me=F[0])==null?void 0:Me.description)})]})]}),e.jsxs("div",{className:"terminal-manager-mode-row",role:"tablist","aria-label":n("terminalManager.modeField"),children:[e.jsx("button",{type:"button",className:d.mode==="command"?"workbench-info-tab active":"workbench-info-tab",onClick:()=>{j(a=>({...a,mode:"command"}))},children:n("terminalManager.commandMode")}),e.jsx("button",{type:"button",className:d.mode==="script"?"workbench-info-tab active":"workbench-info-tab",onClick:()=>{j(a=>({...a,mode:"script"}))},children:n("terminalManager.scriptMode")})]}),e.jsxs("div",{className:"terminal-manager-grid",children:[e.jsxs("div",{className:"field-group",children:[e.jsx("span",{children:n("terminalManager.templateNameField")}),e.jsx("input",{value:d.name,placeholder:n("terminalManager.templateNamePlaceholder"),onChange:a=>{j(r=>({...r,name:a.target.value}))}})]}),e.jsxs("div",{className:"field-group",children:[e.jsx("span",{children:n("terminalManager.cwdField")}),e.jsx("input",{value:d.cwd,placeholder:n("terminalManager.cwdPlaceholder"),onChange:a=>{j(r=>({...r,cwd:a.target.value}))}})]})]}),e.jsxs("div",{className:"terminal-manager-grid",children:[e.jsxs("div",{className:"field-group",children:[e.jsx("span",{children:d.mode==="script"?n("terminalManager.scriptPathField"):n("terminalManager.commandField")}),e.jsx("input",{value:d.target,placeholder:d.mode==="script"?n("terminalManager.scriptPathPlaceholder"):n("terminalManager.commandPlaceholder"),onChange:a=>{j(r=>({...r,target:a.target.value}))}})]}),e.jsxs("div",{className:"field-group",children:[e.jsx("span",{children:n("terminalManager.argsField")}),e.jsx("input",{value:d.args,placeholder:n("terminalManager.argsPlaceholder"),onChange:a=>{j(r=>({...r,args:a.target.value}))}})]})]}),e.jsxs("div",{className:"terminal-manager-grid",children:[e.jsxs("div",{className:"field-group",children:[e.jsx("span",{children:n("terminalManager.portField")}),e.jsx("input",{value:d.port,placeholder:n("terminalManager.portPlaceholder"),onChange:a=>{j(r=>({...r,port:a.target.value}))}})]}),e.jsxs("div",{className:"field-group terminal-manager-proxy-field",children:[e.jsx("span",{children:n("terminalManager.proxyField")}),e.jsxs("div",{className:"terminal-manager-proxy-control",children:[e.jsx("span",{children:n("terminalManager.proxyToggleLabel")}),e.jsxs("label",{className:"terminal-manager-proxy-switch",children:[e.jsx("input",{type:"checkbox",role:"switch","aria-label":n("terminalManager.proxyField"),checked:d.proxyEnabled,onChange:a=>{j(r=>({...r,proxyEnabled:a.target.checked}))}}),e.jsx("span",{className:"terminal-manager-proxy-track","aria-hidden":"true",children:e.jsx("span",{className:"terminal-manager-proxy-thumb"})})]})]})]})]}),e.jsxs("div",{className:"terminal-manager-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:X,children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!i||Z||!d.target.trim(),onClick:()=>{Ue()},children:Z?w?n("terminalManager.templateUpdating"):n("terminalManager.templateSaving"):w?n("terminalManager.saveTemplateChangesAction"):n("terminalManager.saveLaunchAction")})]})]})}),e.jsx(ba,{open:M!==null,mobile:B,busy:M!==null&&k===M.templateId,title:n("terminalManager.removeConfirmTitle"),description:M?n(M.occupied?"terminalManager.removeRunningConfirmTarget":"terminalManager.removeConfirmTarget",{name:M.name}):"",confirmLabel:n("terminalManager.removeConfirmAction"),className:B?"terminal-manager-mobile-modal":"terminal-manager-confirm-modal",onClose:()=>{k||U(null)},onConfirm:()=>{if(!M)return;const a=f.find(r=>r.id===M.templateId);if(!a){U(null);return}ke(xe,a.id),$e(a)}})]}):e.jsx("section",{className:"workbench-empty-state minimal",children:e.jsx("p",{children:n("terminalManager.noCurrentWorkspaceBody")})}):e.jsx("section",{className:"workbench-empty-state minimal",children:e.jsx("p",{children:n("terminalManager.emptyWorkspaceBody")})})}function ne(l){return`terminal-manager.snapshot.${l}`}export{Sa as TerminalManagerPanel};