@jingyi0605/codingns 0.5.1 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/assets/{AdaptiveButlerPage-SffCV4Vb.js → AdaptiveButlerPage-CUyNL98E.js} +1 -1
- package/dist/public/assets/App-BFP7LCSC.js +30 -0
- package/dist/public/assets/{BootstrapPage--zExdgfM.js → BootstrapPage-G74dX2Us.js} +1 -1
- package/dist/public/assets/ConversationPage-Bz0_tvvM.js +2 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-DvI9CIKi.js → DesktopDetachPreviewPage-IV7oEdOX.js} +1 -1
- package/dist/public/assets/DesktopWindowPage-BBmHyRg5.js +2 -0
- package/dist/public/assets/FileContextPanel--FVTxDrq.js +1 -0
- package/dist/public/assets/GitSidebar-DAiSi9oc.js +6 -0
- package/dist/public/assets/{MobileCreateSessionSheet-CXSKMnYn.js → MobileCreateSessionSheet-DqVwz_Hp.js} +1 -1
- package/dist/public/assets/MobileSheet-D1lMrcvD.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-BWorAJ1C.js → MobileTopHeaderFrame-COTc7cRr.js} +1 -1
- package/dist/public/assets/{MobileWorkspaceSwitcherHeader-DOr4pTUq.js → MobileWorkspaceSwitcherHeader-DJPV9ym2.js} +1 -1
- package/dist/public/assets/RelayConnectEntryPage-dSwU8VzK.js +1 -0
- package/dist/public/assets/{ServerSettingsModal-BYB0GvTl.js → ServerSettingsModal-B34ms3ze.js} +1 -1
- package/dist/public/assets/{SessionIndexPage-CR3IARXX.js → SessionIndexPage-D3tG1gmM.js} +1 -1
- package/dist/public/assets/SettingsPage-B3-6-5GL.js +1 -0
- package/dist/public/assets/{TerminalManagerPanel-PQ-EM64j.js → TerminalManagerPanel-DhuTEdzV.js} +1 -1
- package/dist/public/assets/{TerminalPage-CvnHXBhw.js → TerminalPage-DpsvQQVR.js} +19 -19
- package/dist/public/assets/{TerminalRuntimeFallbackModal-D7Aq186N.js → TerminalRuntimeFallbackModal-CNzOt5v5.js} +1 -1
- package/dist/public/assets/{ToolFilesPage-Qzkc6K2I.js → ToolFilesPage-BX9QDi9Y.js} +1 -1
- package/dist/public/assets/{ToolGitPage-BdNDN-cV.js → ToolGitPage-4VtFox3p.js} +1 -1
- package/dist/public/assets/{ToolProcessesPage-EXJ9DHWI.js → ToolProcessesPage-DZJC6Qnt.js} +1 -1
- package/dist/public/assets/{ToolsHomePage-CjF3CWzR.js → ToolsHomePage-D7JbrAWv.js} +1 -1
- package/dist/public/assets/{WorkbenchLandingPage-DZPk4SmX.js → WorkbenchLandingPage-C0yqnzqh.js} +1 -1
- package/dist/public/assets/WorkbenchLayout-Brlj8K3i.js +3 -0
- package/dist/public/assets/{WorkbenchModal-B09hC9b5.js → WorkbenchModal-CbDxaCOR.js} +1 -1
- package/dist/public/assets/{WorkbenchShellRoute-DsW4mBTX.css → WorkbenchShellRoute-BMcnFadA.css} +1 -1
- package/dist/public/assets/WorkbenchShellRoute-puGpdDFY.js +1 -0
- package/dist/public/assets/{WorkspaceDebugDetailPage-Bcq8s-Ma.js → WorkspaceDebugDetailPage-fTGweC9N.js} +1 -1
- package/dist/public/assets/{WorkspaceDetailPage-DNAa8pKr.js → WorkspaceDetailPage-BtaIzSDB.js} +1 -1
- package/dist/public/assets/{WorkspaceHomePage-BoiLuACV.js → WorkspaceHomePage-CUmmYDrM.js} +1 -1
- package/dist/public/assets/{client-runtime-manager-CRQ-F5d2.js → client-runtime-manager-RHFa_iWo.js} +1 -1
- package/dist/public/assets/{default-session-permission-mode-D0wZ9Jek.js → default-session-permission-mode-Cu5SreTG.js} +1 -1
- package/dist/public/assets/file-tree-icon-BMKuc5pw.js +31 -0
- package/dist/public/assets/index-Cq3ue0za.css +1 -0
- package/dist/public/assets/index-DEbFT-Aq.js +42 -0
- package/dist/public/assets/{preferences-service-gOt2ZjKZ.js → preferences-service-gv_9vGKz.js} +1 -1
- package/dist/public/assets/session-runtime-machine-Bfnxkk9B.js +17 -0
- package/dist/public/assets/{terminal-runtime-meta-BMT-rSEe.js → terminal-runtime-meta-B9xJGY__.js} +1 -1
- package/dist/public/assets/{useRegisteredDebugTemplates-zMcEOGca.js → useRegisteredDebugTemplates-CDfl54Wt.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +1 -0
- package/dist/server/config/env.js +36 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.d.ts +16 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-packets.js.map +1 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.d.ts +2 -1
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js +18 -0
- package/dist/server/modules/relay-tunnel/crypto/relay-tunnel-protocol.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.d.ts +13 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js +2 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-client-context.js.map +1 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.d.ts +6 -0
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js +110 -10
- package/dist/server/modules/relay-tunnel/relay-tunnel-gateway-service.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.d.ts +16 -4
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js +216 -101
- package/dist/server/modules/relay-tunnel/relay-tunnel-runtime-adapter.js.map +1 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.d.ts +4 -1
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js +256 -34
- package/dist/server/modules/relay-tunnel/relay-tunnel-service.js.map +1 -1
- package/dist/server/modules/sessions/session-activity-inspector.js +6 -8
- package/dist/server/modules/sessions/session-activity-inspector.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +1 -0
- package/dist/server/modules/sessions/session-history-service.js +62 -7
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/workbench/workbench-service.d.ts +32 -2
- package/dist/server/modules/workbench/workbench-service.js +36 -2
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/server/create-server.js +10 -5
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/ws/workbench-ws-hub.js +166 -16
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/dist/server/ws/ws-server.js +141 -8
- package/dist/server/ws/ws-server.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +33 -6
- package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +78 -36
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/App-WOLwMld_.js +0 -30
- package/dist/public/assets/ConversationPage-D9pzRmOg.js +0 -2
- package/dist/public/assets/DesktopWindowPage-D8FpOSLE.js +0 -2
- package/dist/public/assets/FileContextPanel-C8T7oqRN.js +0 -1
- package/dist/public/assets/GitSidebar-Bze7DNnc.js +0 -6
- package/dist/public/assets/MobileSheet-Gzc14EpR.js +0 -1
- package/dist/public/assets/SettingsPage-B_BQtnwE.js +0 -1
- package/dist/public/assets/WorkbenchLayout-rwQib5In.js +0 -3
- package/dist/public/assets/WorkbenchShellRoute-Cerk5uK7.js +0 -1
- package/dist/public/assets/file-tree-icon-Dp_xhVfD.js +0 -31
- package/dist/public/assets/index-C2G8Gmf1.js +0 -42
- package/dist/public/assets/index-CpPTUeA3.css +0 -1
- package/dist/public/assets/session-runtime-machine-Dq3pW-UF.js +0 -17
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{b as l,t as n,j as e,A as kn}from"./index-C2G8Gmf1.js";import{u as Ni,d as vi,e as Si,f as xn}from"./App-WOLwMld_.js";import{u as Ti,X as tt,r as bn,w as Mi,aD as Ei,av as Hi,aE as yn,aF as wi,aG as jn,aH as Ai,ax as Ri,aI as Pi,aw as Li,aJ as Di,aK as _i,aC as Fi,aL as Cn,b as ki,aM as Oi,aN as Gi}from"./WorkbenchLayout-rwQib5In.js";import{g as $i}from"./default-session-permission-mode-D0wZ9Jek.js";import{S as Bi,v as Ui,w as Wi,e as Vi}from"./MobileSheet-Gzc14EpR.js";import{F as Ii,a as Dt,b as _t}from"./file-tree-icon-Dp_xhVfD.js";import{W as Fe}from"./WorkbenchModal-B09hC9b5.js";import"./window-BWqRixxq.js";import"./event-DvH9tcej.js";const Et=56,Nn=28,Ht=72,nt=8,vn=960,Sn=60*1e3,Tn=20,Mn=9,En=9,wt=68,_=12,it=8,Ft=260,zi=120,At=6e4,st={authMode:"none",username:"",password:"",token:"",rememberOnHost:!1};function ps({className:a,workspaceId:i,panelActive:u=!0,externalWindowMode:g=!1,workbenchShellOverrides:m}){const C=Ni(),x=vi(),y=Ti(),{subscribeGitSnapshot:b,requestGitRefresh:N,addGitSnapshotListener:M,requestNavigationRefresh:S,selectWorkspace:T,upsertNavigationSession:f}={...y,...m},[r,h]=l.useState(null),[j,E]=l.useState(null),[d,R]=l.useState([]),[w,de]=l.useState(0),[I,me]=l.useState(null),[he,rt]=l.useState(!1),[G,Oe]=l.useState(null),[ne,z]=l.useState(null),[ge,fe]=l.useState(""),[ot,U]=l.useState(!1),[v,P]=l.useState(!1),[zn,Bt]=l.useState([]),[Q,Ut]=l.useState(!0),[ee,W]=l.useState(!1),[F,Kn]=l.useState(()=>typeof window<"u"?window.innerWidth<=vn:!1),[lt,$]=l.useState([]),[pe,V]=l.useState(null),[xe,ie]=l.useState("unstaged"),[be,K]=l.useState(null),[se,X]=l.useState(null),[Xn,ct]=l.useState(!1),[qn,ut]=l.useState(null),[Yn,Ge]=l.useState(!1),[Wt,$e]=l.useState(null),[L,ye]=l.useState(null),[Vt,je]=l.useState(null),[Zn,Ce]=l.useState(!1),[Ne,ae]=l.useState(null),[te,dt]=l.useState(!1),[Jn,ve]=l.useState(!1),[Qn,It]=l.useState([]),[rs,zt]=l.useState(!1),[Be,mt]=l.useState(new Set),[ei,Se]=l.useState(new Map),[Ue,Kt]=l.useState(null),[ti,Te]=l.useState(!1),[A,q]=l.useState(st),[Xt,We]=l.useState("generic"),[qt,Ve]=l.useState(null),[k,ht]=l.useState(null),[O,gt]=l.useState(null),[Yt,Zt]=l.useState(Et),[ft,pt]=l.useState(!1),[Jt,Me]=l.useState(null),[ni,Ee]=l.useState(null),Qt=l.useRef(null),en=l.useRef(null),tn=l.useRef(null),nn=l.useRef(null),sn=l.useRef(null),an=l.useRef(null),xt=l.useRef(null),He=l.useRef(new Map),Ie=l.useRef(new Map),we=l.useRef(0),rn=l.useRef(u),{showToast:H}=Si(),on=x.isDesktop&&!F;l.useEffect(()=>{tt("git_sidebar.props",{workspaceId:i,externalWindowMode:g})},[g,i]),l.useEffect(()=>{Bt([]),Ut(!0),de(0),me(null),rt(!1),z(null),fe(""),W(!1),$([]),V(null),ie("unstaged"),K(null),X(null),ct(!1),ut(null),Ge(!1),$e(null),ye(null),je(null),Ce(!1),ae(null),dt(!1),ve(!1),It([]),mt(new Set),Se(new Map),Kt(null),Te(!1),q(st),We("generic"),Ve(null),ht(null),gt(null),pt(!1),Zt(Et),Me(null),Ee(null),Ie.current.clear(),He.current.clear()},[i]),l.useEffect(()=>{function t(){Kn(window.innerWidth<=vn)}return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),l.useEffect(()=>{if(!ft)return;const t=document.body.style.cursor,s=document.body.style.userSelect;document.body.style.cursor="row-resize",document.body.style.userSelect="none";function o(p){mn(p.clientY)}function c(){pt(!1)}return window.addEventListener("pointermove",o),window.addEventListener("pointerup",c),()=>{document.body.style.cursor=t,document.body.style.userSelect=s,window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",c)}},[ft]),l.useEffect(()=>{var o,c;if(!(i!=null&&i.trim())){h(null),E(null),R([]),de(0),me(null),Oe(null),U(!1);return}const t=i.trim(),s=bn(Pt(t),Sn);if(tt("git_sidebar.snapshot",{workspaceId:t,cached:!!s,cachedHistoryCount:((o=s==null?void 0:s.history)==null?void 0:o.length)??0,cachedChangedCount:((c=s==null?void 0:s.status)==null?void 0:c.changes.length)??0}),s){bt(s),U(!1);return}h(null),E(null),R([]),de(0),me(null),Oe(null),U(!0)},[i]),l.useEffect(()=>{if(i!=null&&i.trim())return M(t=>{var s,o,c;t.workspaceId===i.trim()&&(tt("git_sidebar.snapshot_received",{workspaceId:t.workspaceId,changedCount:((s=t.status)==null?void 0:s.changes.length)??0,historyCount:t.history.length,branchCount:(((o=t.branches)==null?void 0:o.local.length)??0)+(((c=t.branches)==null?void 0:c.remote.length)??0)}),bt(t),U(!1))})},[M,i]),l.useEffect(()=>{if(!(i!=null&&i.trim()))return;const t=i.trim(),s=bn(Pt(t),Sn);b(t,{knownRevision:(s==null?void 0:s.revision)??null}),s||Y()},[N,b,i]),l.useEffect(()=>{const t=rn.current;rn.current=u,i!=null&&i.trim()&&!t&&u&&N(i.trim(),{knownRevision:j})},[u,N,j,i]),l.useEffect(()=>{i&&Mi(Pt(i),{revision:j,status:r,history:d,historyTotalCount:w,historyNextCursor:I,branches:G})},[G,d,I,w,j,r,i]),l.useEffect(()=>{if(!r||!ne)return;r.changes.find(s=>s.path===ne)||z(null)},[ne,r]),l.useEffect(()=>{Ji(nn.current)},[ge]),l.useEffect(()=>{F||($([]),V(null),K(null),Ve(null))},[F]),l.useEffect(()=>{if(!r){$([]);return}const t=new Set(r.changes.map(s=>s.path));$(s=>s.filter(o=>t.has(o)))},[r]);function ii(){const t=tn.current;if(!t)return;t.querySelectorAll(".git-tree-shell").forEach(o=>{o.scrollTop=0})}function bt(t){E(typeof t.revision=="string"?t.revision:null),h(t.status),R(Array.isArray(t.history)?t.history:[]),de(typeof t.historyTotalCount=="number"?t.historyTotalCount:0),me(typeof t.historyNextCursor=="string"?t.historyNextCursor:null),Oe(t.branches??null)}function Y(t){i!=null&&i.trim()&&(U(!0),tt("git_sidebar.refresh_requested",{workspaceId:i.trim(),resetTreeScroll:!1}),N(i.trim(),{knownRevision:j}))}async function yt(t){if(!(i!=null&&i.trim()))return;const s=i.trim();U(!0);try{const[o,c,p]=await Promise.all([Hi(s),yn(s,Tn,null),wi(s)]);bt({status:o,history:c.items,historyTotalCount:c.totalCount,historyNextCursor:c.nextCursor,branches:p}),N(s),t!=null&&t.resetTreeScroll&&requestAnimationFrame(()=>{ii()})}catch(o){H({title:D(o,n("git.panelLoadFailed")),tone:"error"})}finally{U(!1)}}async function ze(){if(!(!i||!I||he)){rt(!0);try{const t=await yn(i,Tn,I);R(s=>{const o=new Set(s.map(p=>p.commitHash)),c=t.items.filter(p=>!o.has(p.commitHash));return[...s,...c]}),de(t.totalCount),me(t.nextCursor)}catch(t){H({title:D(t,n("git.panelLoadFailed")),tone:"error"})}finally{rt(!1)}}}function si(t){if(!Q||he||!I)return;const s=t.currentTarget;s.scrollHeight-s.scrollTop-s.clientHeight<=40&&ze()}async function ai(){if(i){P(!0);try{const t=await Ei(i,"ai");fe(t.validation.normalizedDraft.subject||t.draft.subject)}catch(t){H({title:D(t,n("git.draftFailed")),tone:"error"})}finally{P(!1)}}}async function Ke(t,s){if(i&&t.length){P(!0);try{const o=s?await Pi(i,t):await Li(i,t);h(o),z(t[t.length-1]??null),$(c=>c.filter(p=>!t.includes(p))),V(null),Y()}catch(o){U(!1),H({title:D(o,n("git.stageFailed")),tone:"error"})}finally{P(!1)}}}async function jt(t){if(i&&t.length){P(!0);try{const s=await _i(i,t);h(s),t.includes(ne??"")&&z(null),$(o=>o.filter(c=>!t.includes(c))),V(null),Y()}catch(s){U(!1),H({title:D(s,n("git.discardFailed")),tone:"error"})}finally{P(!1)}}}async function ri(){if(!(!i||!ge.trim())){P(!0);try{await Ai(i,Yi(ge)),H({title:n("git.commitSuccess"),tone:"success"}),fe(""),z(null),Y()}catch(t){H({title:D(t,n("git.commitFailed")),tone:"error"})}finally{P(!1)}}}function Xe(t){q(ts(Ue)),Te(!0),oi(t)}async function oi(t){const s=i==null?void 0:i.trim();if(!s){We("generic");return}try{const o=await jn(s);if((i==null?void 0:i.trim())!==s)return;We(is(o,t))}catch{if((i==null?void 0:i.trim())!==s)return;We("generic")}}function li(){const t=ns(A),s=Xt==="github"?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder");if(A.authMode==="basic"){if(!A.username.trim()){H({title:n("shell.cloneUsernamePlaceholder"),tone:"error"});return}if(!A.password){H({title:s,tone:"error"});return}}if(A.authMode==="token"&&!A.token){H({title:n("shell.cloneTokenPlaceholder"),tone:"error"});return}Kt(t),Te(!1),H({title:t?n("git.remoteAuthSaved"):n("git.remoteAuthCleared"),description:t&&A.rememberOnHost?n("git.remoteAuthRememberHint"):void 0,tone:"success"})}async function ln(){if(i){zt(!0);try{const t=await jn(i);if(t.length===0){H({title:n("git.noRemotes"),tone:"error"});return}if(t.length===1){cn([t[0].name]);return}It(t),mt(new Set),Se(new Map),ve(!0)}catch(t){H({title:D(t,n("git.remoteFailed")),tone:"error"})}finally{zt(!1)}}}async function cn(t){if(!i||t.length===0)return;P(!0),Se(new Map);const s=new Map;let o=!1;try{for(const c of t)try{const p=await Cn(i,"push",c,Ue,A.rememberOnHost);s.set(c,{ok:!0,summary:p.summary})}catch(p){if(o=!0,s.set(c,{ok:!1,summary:D(p,n("git.remoteFailed"))}),Se(new Map(s)),_n(p)){Xe(c);return}}Se(s),Y(),o||(H({title:n("git.pushAllSuccess",{count:String(t.length)}),tone:"success"}),ve(!1))}finally{P(!1)}}async function Ct(t){if(i){if(t==="push"){W(!1),ln();return}P(!0);try{const s=await Cn(i,t,void 0,Ue,A.rememberOnHost);H({title:s.summary,tone:"success"}),W(!1),Y()}catch(s){if(_n(s)){Xe();return}H({title:D(s,n("git.remoteFailed")),tone:"error"})}finally{P(!1)}}}async function re(){if(i){P(!0);try{const t=await Di(i);fe(t.commitSubject??""),H({title:t.summary||n("git.undoLastCommitSuccess"),tone:"success"}),W(!1),Y()}catch(t){H({title:D(t,n("git.undoLastCommitFailed")),tone:"error"})}finally{P(!1)}}}async function ci(t){if(i){P(!0);try{const s=await Oi(i,t,!1);Oe(s),W(!1),Y()}catch(s){H({title:D(s,n("git.branchFailed")),tone:"error"})}finally{P(!1)}}}async function Nt(t){const s=i==null?void 0:i.trim();if(!s)throw new Error(n("git.panelLoadFailed"));const o=Ie.current.get(t);if(o)return o;const c=await Gi(s,t);return Ie.current.set(t,c),c}async function Ae(t){X(null),K(null),ut(t),$e(null);const s=Ie.current.get(t)??null;if(ye(s),Ge(!s),s)return;const o=we.current+1;we.current=o;try{const c=await Nt(t);if(we.current!==o)return;ye(c)}catch(c){if(we.current!==o)return;$e(D(c,n("git.commitDetailLoadFailed"))),ye(null)}finally{we.current===o&&Ge(!1)}}function ui(){ut(null),Ge(!1),$e(null),ye(null)}async function Re(t){try{const s=await Nt(t);await B(s.versionLabel,n("git.copyCommitVersionSuccess"))}catch(s){H({title:D(s,n("git.commitDetailLoadFailed")),tone:"error"})}}function Pe(t){X(null),K(null),je(t),ae(null),Ce(!0)}function di(t){var o;const s=((o=d[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return[{id:`view-changes:${t.commitHash}`,label:n("git.viewCommitChanges"),onSelect:()=>void Ae(t.commitHash)},{id:`copy-hash:${t.commitHash}`,label:n("git.copyCommitHash"),onSelect:()=>void B(t.commitHash,n("git.copyCommitHashSuccess"))},{id:`copy-message:${t.commitHash}`,label:n("git.copyCommitMessage"),onSelect:()=>void B(ue(t),n("git.copyCommitMessageSuccess"))},{id:`copy-version:${t.commitHash}`,label:n("git.copyCommitVersion"),onSelect:()=>void Re(t.commitHash)},{id:`explain:${t.commitHash}`,label:n("git.explainCommitAction"),onSelect:()=>Pe(t.commitHash)},...s?[{id:`undo:${t.commitHash}`,label:n("git.undoLastCommit"),disabled:v,onSelect:()=>void re()}]:[]]}async function un(t){X(null),K(null),await Fi(di(t))}async function mi(){var t,s;if(!(!i||!Vt||!Ne||te)){dt(!0);try{const o=await Nt(Vt),c=await Ui({workspaceId:i,provider:Ne,content:Zi(o),clientRequestId:((s=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:s.call(t))??`git-explain-${Date.now()}-${Math.random().toString(16).slice(2)}`,permissionMode:$i()}),p=c.session??await Wi(c.sessionId);f(p),S(),T(p.workspaceId),C(ki(p.workspaceId,p.sessionId)),Ce(!1),je(null),ae(null),H({title:n("git.explainCommitStarted"),tone:"success"})}catch(o){H({title:D(o,n("git.explainCommitFailed")),tone:"error"})}finally{dt(!1)}}}function qe(t){Bt(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}const hi=450;function dn(t){const s=Date.now(),o=Qt.current;return Qt.current={filePath:t,timestamp:s},(o==null?void 0:o.filePath)===t&&s-o.timestamp<=hi}async function Ye(t,s){if(s.binary){H({title:n("git.binaryDiff"),tone:"info"});return}if(s.status==="A"||s.status==="?")Ee(null),Me(t);else if(i)try{const o=await Ri(i,t,s.staged);Ee(o.content),Me(t)}catch{Ee(null),Me(t)}}function Ze(t){z(t),V(null),$(s=>s.includes(t)?s.filter(o=>o!==t):[...s,t])}function mn(t){const s=en.current;if(!s||!Number.isFinite(t))return;const o=s.getBoundingClientRect(),c=o.height-nt;if(!Number.isFinite(o.top)||!Number.isFinite(o.height)||c<=0)return;const p=(t-o.top-nt/2)/c*100;if(!Number.isFinite(p))return;const _e=Math.max(Nn,Math.min(Ht,Math.round(p)));Zt(_e)}function gi(t){t.preventDefault(),mn(t.clientY),pt(!0)}const Le=(r==null?void 0:r.changes)??[],Z=Le.filter(t=>kt(t,"staged")),oe=Le.filter(t=>kt(t,"unstaged")),hn=Ln(Z,"staged"),gn=Ln(oe,"unstaged"),Je=new Set(zn),Qe=new Set(lt),le=Dn(lt,Le,"staged"),ce=Dn(lt,Le,"unstaged"),vt=Le.length===0&&((r==null?void 0:r.snapshot.ahead)??0)>0,fi=Z.length>0&&ge.trim().length>0,et=(G==null?void 0:G.currentBranch)??(r==null?void 0:r.snapshot.branch)??n("common.unknown"),St=Ue!==null,De=Xt==="github",pi=De?n("git.remoteAuthDescriptionGithub"):n("git.remoteAuthDescription"),xi=De?n("git.remoteAuthGithubPatLabel"):n("shell.clonePasswordLabel"),bi=De?n("git.remoteAuthGithubPatPlaceholder"):n("shell.clonePasswordPlaceholder"),yi=De?n("git.remoteAuthGithubUsernamePlaceholder"):n("shell.cloneUsernamePlaceholder"),Tt=Number.isFinite(Yt)?Yt:Et,ji=Q?`minmax(120px, ${Tt}fr) ${nt}px minmax(140px, ${100-Tt}fr)`:`minmax(120px, 1fr) ${nt}px auto`;l.useEffect(()=>{pe==="staged"&&le.length===0&&V(null),pe==="unstaged"&&ce.length===0&&V(null)},[pe,le.length,ce.length]),l.useEffect(()=>{if(!F)return;const t=oe.length>0?"unstaged":Z.length>0?"staged":"history";ie(s=>s==="unstaged"&&oe.length>0||s==="staged"&&Z.length>0?s:t)},[F,Z.length,oe.length]),l.useEffect(()=>{be&&(d.some(t=>t.commitHash===be)||K(null))},[d,be]),l.useEffect(()=>{se&&(d.some(t=>t.commitHash===se)||X(null))},[se,d]),l.useEffect(()=>{F&&xe!=="history"&&ee&&W(!1)},[F,ee,xe]),l.useLayoutEffect(()=>{if(F||!ee){ht(null);return}function t(){const o=sn.current,c=an.current;!o||!c||typeof window>"u"||ht(Fn(o.getBoundingClientRect(),{width:c.getBoundingClientRect().width||Ft,height:c.getBoundingClientRect().height||c.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}t();const s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[v,G==null?void 0:G.local.length,et,F,ee,St]);const J=be??se;l.useLayoutEffect(()=>{if(!J){gt(null);return}const t=J;function s(){const c=He.current.get(t)??null,p=xt.current;!c||!p||typeof window>"u"||gt(Fn(c.getBoundingClientRect(),{width:p.getBoundingClientRect().width||Ft,height:p.getBoundingClientRect().height||p.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}s();const o=window.requestAnimationFrame(s);return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0)}},[J,d.length]),l.useEffect(()=>{if(!J||typeof document>"u")return;const t=J;function s(o){const c=o.target;if(!(c instanceof Node))return;const p=He.current.get(t)??null,_e=xt.current;p!=null&&p.contains(c)||_e!=null&&_e.contains(c)||(K(null),X(null))}return document.addEventListener("pointerdown",s),()=>{document.removeEventListener("pointerdown",s)}},[J]);async function B(t,s){var o;try{if(typeof navigator>"u"||!((o=navigator.clipboard)!=null&&o.writeText))throw new Error("clipboard unavailable");await navigator.clipboard.writeText(t),H({title:s,tone:"success"})}catch{H({title:n("common.copyContentFailed"),tone:"error"})}}async function fn(t,s){typeof window<"u"&&!window.confirm(n("git.discardConfirm",{path:s}))||await jt(t)}function pn(t){const s=(t==null?void 0:t.desktopFloating)===!0&&!F,o=s?{top:(k==null?void 0:k.top)??_,left:(k==null?void 0:k.left)??_,maxHeight:k==null?void 0:k.maxHeight,transformOrigin:(k==null?void 0:k.transformOrigin)??"top right"}:void 0,c=e.jsxs("div",{ref:s?an:void 0,className:"git-operations-menu","data-floating":s?"true":"false",style:o,children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.currentBranch")}),e.jsx("strong",{className:"git-menu-branch",children:et})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.remoteAuthStatusLabel")}),e.jsxs("div",{className:"git-menu-branch-list",children:[e.jsx("strong",{className:"git-menu-branch",children:St?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>Xe(),children:e.jsx("span",{children:n("git.remoteAuthAction")})})]})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.branchTitle")}),e.jsx("div",{className:"git-menu-branch-list",children:G==null?void 0:G.local.map(p=>e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||p.current,onClick:()=>void ci(p.name),children:e.jsx("span",{children:p.current?`${n("git.switchBranch")} ${p.name}`:`${n("git.switchBranchTo")} ${p.name}`})},p.name))})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>{W(!1),ct(!0)},children:e.jsx("span",{children:n("git.viewAllVersions")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void Ct("fetch"),children:e.jsx("span",{children:n("git.fetch")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void Ct("pull"),children:e.jsx("span",{children:n("git.pull")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void Ct("push"),children:e.jsx("span",{children:n("git.push")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v,onClick:()=>void re(),children:e.jsx("span",{children:n("git.undoLastCommit")})}),e.jsx("button",{className:"git-menu-item",type:"button",disabled:v||ot,onClick:()=>void yt({resetTreeScroll:!0}),children:e.jsx("span",{children:n("git.refresh")})})]})]});return s?typeof document>"u"?null:xn.createPortal(c,document.body):c}function Mt(t,s){if(s){He.current.set(t,s);return}He.current.delete(t)}function Ci(){var o;if(!J||typeof document>"u")return null;const t=d.find(c=>c.commitHash===J);if(!t)return null;const s=((o=d[0])==null?void 0:o.commitHash)===t.commitHash&&t.commitKind==="local";return xn.createPortal(e.jsx("div",{ref:xt,className:"git-history-entry-menu","data-floating":"true",style:{top:(O==null?void 0:O.top)??_,left:(O==null?void 0:O.left)??_,maxHeight:O==null?void 0:O.maxHeight,transformOrigin:(O==null?void 0:O.transformOrigin)??"top right"},children:e.jsx(Xi,{item:t,canUndo:s,actioning:v,onViewCommitChanges:c=>void Ae(c),onCopyCommitHash:c=>void B(c,n("git.copyCommitHashSuccess")),onCopyCommitMessage:c=>void B(ue(c),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:c=>void Re(c),onExplainCommitChange:c=>void Pe(c),onUndoLastCommit:()=>void re()})}),document.body)}return e.jsxs("section",{className:["conversation-panel","surface-card","git-sidebar",a].filter(Boolean).join(" "),"data-testid":"git-sidebar",children:[e.jsxs("section",{className:"git-card git-scaffold-section",children:[e.jsxs("div",{className:"git-editor-row",children:[e.jsx("textarea",{ref:nn,rows:1,value:ge,onChange:t=>fe(Un(t.target.value)),onKeyDown:t=>{t.key==="Enter"&&t.preventDefault()},placeholder:n("git.commitSubjectPlaceholder")}),e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.generateDraft"),title:n("git.generateDraft"),onClick:()=>void ai(),disabled:v||ot,children:e.jsx(as,{})})]}),e.jsxs("div",{className:"git-primary-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void yt({resetTreeScroll:!0}),disabled:v||ot||!i,children:n("git.refreshNow")}),e.jsx("button",{className:"primary-button git-primary-submit",type:"button",onClick:()=>{if(vt){ln();return}ri()},disabled:v||!vt&&!fi,children:vt?n("git.pushNow"):n("git.commitNow")})]})]}),F?e.jsxs("div",{className:"git-mobile-sections",children:[e.jsx(Rt,{title:n("git.stagedChangesTitle"),count:Z.length,expanded:xe==="staged",onToggle:()=>ie("staged"),children:e.jsx(wn,{title:n("git.stagedChangesTitle"),nodes:hn,collapsedTreePathSet:Je,onToggleTreePath:qe,onToggleMobileSelection:Ze,selectedMobilePathSet:Qe,selectedTargets:le,actioning:v,variant:"staged",swipeRowState:qt,onSwipeRowChange:Ve,onStageToggle:Ke,onDiscardWithConfirm:fn,onClearSelectedTargets:()=>$(t=>t.filter(s=>!le.includes(s))),onPreviewFile:Ye})}),e.jsx(Rt,{title:n("git.changesTitle"),count:oe.length,expanded:xe==="unstaged",onToggle:()=>ie("unstaged"),children:e.jsx(wn,{title:n("git.changesTitle"),nodes:gn,collapsedTreePathSet:Je,onToggleTreePath:qe,onToggleMobileSelection:Ze,selectedMobilePathSet:Qe,selectedTargets:ce,actioning:v,variant:"unstaged",swipeRowState:qt,onSwipeRowChange:Ve,onStageToggle:Ke,onDiscardWithConfirm:fn,onClearSelectedTargets:()=>$(t=>t.filter(s=>!ce.includes(s))),onPreviewFile:Ye})}),e.jsxs(Rt,{title:n("git.recentVersionsTitle"),count:w,expanded:xe==="history",onToggle:()=>ie("history"),trailingContent:e.jsx("span",{className:"badge",children:et}),headerAction:e.jsx("button",{className:"git-icon-button git-mobile-section-action",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),"aria-expanded":ee,onClick:()=>{ie("history"),W(t=>!t)},disabled:v,children:e.jsx(ke,{})}),children:[ee?e.jsx("div",{className:"git-mobile-operations-shell",children:pn()}):null,e.jsx(Ki,{history:d,historyLoadingMore:he,hasMore:!!I,actioning:v,openCommitHash:be,onMenuTriggerRef:Mt,onToggleMenu:t=>K(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void ze()})]})]}):e.jsxs("div",{ref:en,className:"git-content-split",style:{gridTemplateRows:ji},children:[e.jsx("section",{className:"git-card git-tree-panel",children:e.jsxs("div",{ref:tn,className:"git-tree-panel-body",children:[Z.length>0?e.jsx(Hn,{title:n("git.stagedChangesTitle"),count:Z.length,nodes:hn,selectedPath:ne,collapsedTreePathSet:Je,onToggleTreePath:qe,onSelectFile:z,onPreviewFile:(t,s)=>{dn(t)&&Ye(t,s)},onToggleMobileSelection:Ze,onStageToggle:Ke,onDiscard:jt,actioning:v,variant:"staged",isMobileViewport:F,selectedMobilePathSet:Qe,selectedTargets:le,mobileActionMenuOpen:pe==="staged",onToggleMobileActionMenu:()=>V(t=>t==="staged"?null:"staged"),onClearSelectedTargets:()=>$(t=>t.filter(s=>!le.includes(s)))}):null,e.jsx(Hn,{title:n("git.changesTitle"),count:oe.length,nodes:gn,selectedPath:ne,collapsedTreePathSet:Je,onToggleTreePath:qe,onSelectFile:z,onPreviewFile:(t,s)=>{dn(t)&&Ye(t,s)},onToggleMobileSelection:Ze,onStageToggle:Ke,onDiscard:jt,actioning:v,variant:"unstaged",isMobileViewport:F,selectedMobilePathSet:Qe,selectedTargets:ce,mobileActionMenuOpen:pe==="unstaged",onToggleMobileActionMenu:()=>V(t=>t==="unstaged"?null:"unstaged"),onClearSelectedTargets:()=>$(t=>t.filter(s=>!ce.includes(s)))})]})}),e.jsx("button",{className:"git-panel-divider",type:"button",role:"separator","aria-label":n("git.resizePanels"),"aria-orientation":"horizontal","aria-valuemin":Nn,"aria-valuemax":Ht,"aria-valuenow":Q?Tt:Ht,"data-dragging":ft,onPointerDown:gi,children:e.jsx("span",{className:"git-panel-divider-handle","aria-hidden":"true"})}),e.jsxs("section",{className:"git-card git-history-section",children:[e.jsxs("div",{className:"git-history-topbar",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":Q,"aria-label":Q?n("git.collapseRecentVersions"):n("git.expandRecentVersions"),onClick:()=>Ut(t=>!t),children:[e.jsxs("span",{className:"git-section-toggle-main",children:[e.jsx(at,{expanded:Q}),e.jsx("span",{children:n("git.recentVersionsTitle")})]}),e.jsx("span",{className:"workbench-section-counter",children:w})]}),e.jsxs("div",{className:"git-history-actions",children:[e.jsx("span",{className:"badge",children:et}),e.jsx("button",{className:"git-icon-button",type:"button",ref:sn,"aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:()=>W(t=>!t),disabled:v,children:e.jsx(ke,{})}),ee?pn({desktopFloating:!0}):null]})]}),Q?e.jsx(Rn,{history:d,historyLoadingMore:he,hasMore:!!I,actioning:v,openCommitHash:se,useNativeContextMenu:on,onMenuTriggerRef:Mt,onScroll:si,onToggleMenu:t=>{if(on){const s=d.find(o=>o.commitHash===t);s&&un(s);return}X(s=>s===t?null:t)},onOpenContextMenu:t=>void un(t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void ze()}):null]})]}),e.jsxs(Fe,{open:Jn,title:n("git.selectRemoteTitle"),description:n("git.selectRemoteDesc"),onClose:()=>{v||ve(!1)},children:[e.jsxs("div",{className:"git-remote-auth-banner",children:[e.jsxs("div",{className:"git-remote-auth-banner-copy",children:[e.jsx("strong",{children:n("git.remoteAuthStatusLabel")}),e.jsx("span",{children:St?n("git.remoteAuthConfigured"):n("git.remoteAuthNotConfigured")})]}),e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>Xe(),children:n("git.remoteAuthAction")})]}),e.jsx("div",{className:"git-remote-select-list",children:Qn.map(t=>{const s=Be.has(t.name),o=ei.get(t.name);return e.jsxs("label",{className:"git-remote-item",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:v,onChange:()=>{mt(c=>{const p=new Set(c);return p.has(t.name)?p.delete(t.name):p.add(t.name),p})}}),e.jsxs("span",{className:"git-remote-item-body",children:[e.jsx("span",{className:"git-remote-name",children:t.name}),e.jsx("span",{className:"git-remote-url",children:t.pushUrl}),o&&e.jsx("span",{className:`git-remote-result ${o.ok?"ok":"err"}`,children:o.summary})]})]},t.name)})}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>ve(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v||Be.size===0,onClick:()=>void cn(Array.from(Be)),children:v?n("git.pushing"):n("git.pushSelected",{count:String(Be.size)})})]})]}),e.jsxs(Fe,{open:ti,title:n("git.remoteAuthTitle"),description:pi,onClose:()=>{v||Te(!1)},children:[e.jsxs("div",{className:"workbench-clone-form",children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneAuthModeLabel")}),e.jsxs("select",{value:A.authMode,disabled:v,onChange:t=>q(s=>({...s,authMode:t.target.value})),children:[e.jsx("option",{value:"none",children:n("shell.cloneAuthModeNone")}),e.jsx("option",{value:"basic",children:n("shell.cloneAuthModeBasic")}),e.jsx("option",{value:"token",children:n("shell.cloneAuthModeToken")})]})]}),A.authMode==="basic"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:yi,autoComplete:"username",onChange:t=>q(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:xi}),e.jsx("input",{type:"password",value:A.password,placeholder:bi,autoComplete:"current-password",onChange:t=>q(s=>({...s,password:t.target.value}))})]})]}):null,A.authMode==="token"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneUsernameLabel")}),e.jsx("input",{type:"text",value:A.username,placeholder:n("shell.cloneTokenUsernamePlaceholder"),autoComplete:"username",onChange:t=>q(s=>({...s,username:t.target.value}))})]}),e.jsxs("label",{className:"workbench-modal-field",children:[e.jsx("span",{children:n("shell.cloneTokenLabel")}),e.jsx("input",{type:"password",value:A.token,placeholder:n("shell.cloneTokenPlaceholder"),autoComplete:"current-password",onChange:t=>q(s=>({...s,token:t.target.value}))})]})]}):null,De?e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthGithubPatHint")}):null,A.authMode!=="none"?e.jsxs("label",{className:"settings-checkbox git-remote-auth-remember-toggle",children:[e.jsx("input",{type:"checkbox",checked:A.rememberOnHost,onChange:t=>q(s=>({...s,rememberOnHost:t.target.checked}))}),e.jsx("span",{children:n("git.remoteAuthRemember")})]}):null,e.jsx("p",{className:"git-remote-auth-hint",children:n("git.remoteAuthSessionHint")})]}),e.jsxs("div",{className:"git-remote-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:v,onClick:()=>Te(!1),children:n("common.close")}),e.jsx("button",{className:"primary-button",type:"button",disabled:v,onClick:li,children:n("git.remoteAuthSave")})]})]}),e.jsx(Fe,{open:Xn,title:n("git.viewAllVersions"),description:n("git.viewAllVersionsDescription",{count:String(w)}),onClose:()=>ct(!1),children:e.jsx(Rn,{history:d,historyLoadingMore:he,hasMore:!!I,actioning:v,openCommitHash:se,className:"git-history-modal-list",onMenuTriggerRef:Mt,onToggleMenu:t=>X(s=>s===t?null:t),onViewCommitChanges:t=>void Ae(t),onCopyCommitHash:t=>void B(t,n("git.copyCommitHashSuccess")),onCopyCommitMessage:t=>void B(ue(t),n("git.copyCommitMessageSuccess")),onCopyCommitVersion:t=>void Re(t),onExplainCommitChange:t=>void Pe(t),onUndoLastCommit:()=>void re(),onLoadMore:()=>void ze()})}),e.jsx(Fe,{open:qn!==null,className:"git-commit-detail-modal",title:(L==null?void 0:L.subject)||n("git.commitDetailTitle"),description:L?n("git.commitDetailDescription",{hash:L.shortHash}):n("git.commitDetailLoading"),onClose:ui,children:Yn?e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailLoading")})}):Wt?e.jsx("div",{className:"git-commit-detail-state is-error",children:e.jsx("p",{children:Wt})}):L?e.jsxs("div",{className:"git-commit-detail-shell",children:[e.jsxs("div",{className:"git-commit-detail-meta-grid",children:[e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitVersionLabel")}),e.jsx("strong",{children:L.versionLabel})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitHashLabel")}),e.jsx("strong",{children:L.commitHash})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitAuthorLabel")}),e.jsx("strong",{children:L.authorName})]}),e.jsxs("div",{className:"git-commit-detail-meta-card",children:[e.jsx("span",{children:n("git.commitTimeLabel")}),e.jsx("strong",{children:Qi(L.authoredAt)})]})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsx("div",{className:"git-commit-detail-section-header",children:e.jsx("h3",{children:n("git.commitMessageLabel")})}),e.jsx("pre",{className:"git-commit-detail-message",children:ue(L)})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.changedFilesTitle")}),e.jsx("span",{className:"workbench-section-counter",children:L.changedFiles.length})]}),e.jsx("div",{className:"git-commit-detail-file-list",children:L.changedFiles.map(t=>e.jsxs("div",{className:"git-commit-detail-file-item",children:[e.jsx("span",{className:"git-commit-detail-file-status","data-status":t.status,children:t.status}),e.jsxs("div",{className:"git-commit-detail-file-copy",children:[e.jsx("strong",{children:t.path}),t.oldPath?e.jsx("span",{children:n("git.renamedFromLabel",{path:t.oldPath})}):null]})]},`${t.status}:${t.oldPath??""}:${t.path}`))})]}),e.jsxs("section",{className:"git-commit-detail-section",children:[e.jsxs("div",{className:"git-commit-detail-section-header",children:[e.jsx("h3",{children:n("git.commitDiffLabel")}),L.diffTruncated?e.jsx("span",{className:"git-commit-detail-truncated",children:n("git.diffTruncated")}):null]}),e.jsx("pre",{className:"git-commit-detail-diff",children:L.diffContent||n("git.emptyDiff")})]})]}):e.jsx("div",{className:"git-commit-detail-state",children:e.jsx("p",{children:n("git.commitDetailEmpty")})})}),e.jsx(Fe,{open:Zn,className:"git-explain-provider-modal",title:n("git.explainCommitTitle"),description:n("git.explainCommitDescription"),onClose:()=>{te||(Ce(!1),je(null),ae(null))},children:e.jsxs("div",{className:"git-explain-provider-shell",children:[e.jsx(Bi,{workspaceId:i,selectedProvider:Ne,pendingProvider:te?Ne:null,disabled:te,onSelect:t=>ae(t)}),e.jsxs("div",{className:"git-explain-provider-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:te,onClick:()=>{Ce(!1),je(null),ae(null)},children:n("common.cancel")}),e.jsx("button",{type:"button",className:"primary-button",disabled:!Ne||te,onClick:()=>void mi(),children:te?n("conversation.sendingState"):n("git.startExplainCommit")})]})]})}),e.jsx(Ii,{workspaceId:i,filePath:Jt,open:Jt!==null,onClose:()=>{Me(null),Ee(null)},onSaved:async()=>{await yt({resetTreeScroll:!0})},diffContent:ni}),Ci()]})}function Hn({title:a,count:i,nodes:u,selectedPath:g,collapsedTreePathSet:m,onToggleTreePath:C,onSelectFile:x,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:f,selectedMobilePathSet:r,selectedTargets:h,mobileActionMenuOpen:j,onToggleMobileActionMenu:E,onClearSelectedTargets:d}){const R=$t(u),w=T==="staged"?n("git.unstageAll"):n("git.stageAll");return e.jsxs("section",{className:"git-tree-group","data-variant":T,children:[e.jsxs("div",{className:"git-section-header git-tree-group-header",children:[e.jsx("h3",{children:a}),e.jsxs("div",{className:"git-tree-group-actions",children:[e.jsx("span",{className:"workbench-section-counter",children:i}),!f&&R.length>0?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":w,title:w,onClick:()=>void N(R,T==="staged"),disabled:S,children:e.jsx(Ot,{staged:T==="staged"})}),T==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discardAll"),title:n("git.discardAll"),onClick:()=>void M(R),disabled:S,children:e.jsx(Gt,{})}):null]}):null,f&&h.length>0?e.jsx("button",{className:"git-icon-button",type:"button","aria-label":n("git.operationMenu"),title:n("git.operationMenu"),onClick:E,disabled:S,children:e.jsx(ke,{})}):null]}),f&&j?e.jsxs("div",{className:"git-selection-menu",children:[e.jsxs("div",{className:"git-menu-section",children:[e.jsx("span",{className:"git-menu-caption",children:n("git.selectedFiles")}),e.jsx("strong",{className:"git-menu-branch",children:h.length})]}),e.jsxs("div",{className:"git-menu-section",children:[e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void N(h,T==="staged"),children:e.jsx("span",{children:T==="staged"?n("git.unstage"):n("git.stage")})}),T==="unstaged"?e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:()=>void M(h),children:e.jsx("span",{children:n("git.discard")})}):null,e.jsx("button",{className:"git-menu-item",type:"button",disabled:S,onClick:d,children:e.jsx("span",{children:n("git.clearSelection")})})]})]}):null]}),e.jsx("div",{className:"git-tree-shell",role:"tree","aria-label":a,children:u.length?Gn({nodes:u,depth:0,collapsedTreePathSet:m,selectedPath:g,onToggleTreePath:C,onSelectFile:x,onPreviewFile:y,onToggleMobileSelection:b,onStageToggle:N,onDiscard:M,actioning:S,variant:T,isMobileViewport:f,selectedMobilePathSet:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function Rt({title:a,count:i,expanded:u,onToggle:g,trailingContent:m,headerAction:C,children:x}){return e.jsxs("section",{className:"git-mobile-section","data-expanded":u,children:[e.jsxs("div",{className:"git-mobile-section-header",children:[e.jsxs("button",{className:"git-mobile-section-toggle",type:"button","aria-expanded":u,onClick:g,children:[e.jsxs("span",{className:"git-mobile-section-toggle-main",children:[e.jsx(at,{expanded:u}),e.jsx("h3",{children:a})]}),e.jsxs("span",{className:"git-mobile-section-toggle-meta",children:[m,e.jsx("span",{className:"workbench-section-counter",children:i})]})]}),C?e.jsx("div",{className:"git-mobile-section-header-action",children:C}):null]}),u?e.jsx("div",{className:"git-mobile-section-body",children:x}):null]})}function wn({title:a,nodes:i,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,selectedTargets:x,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onClearSelectedTargets:f,onPreviewFile:r}){return e.jsxs("div",{className:"git-mobile-record-shell",children:[x.length>0?e.jsxs("div",{className:"git-mobile-selection-toolbar",children:[e.jsxs("span",{className:"git-mobile-selection-count",children:[n("git.selectedFiles")," ",x.length]}),e.jsxs("div",{className:"git-mobile-selection-actions",children:[e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:()=>void S(x,b==="staged"),children:b==="staged"?n("git.unstage"):n("git.stage")}),b==="unstaged"?e.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:y,onClick:()=>void T(x,`${x.length}`),children:n("git.discard")}):null,e.jsx("button",{type:"button",className:"secondary-button",disabled:y,onClick:f,children:n("git.clearSelection")})]})]}):null,e.jsx("div",{className:"git-mobile-record-list",role:"tree","aria-label":a,children:i.length?On({nodes:i,depth:0,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:y,variant:b,swipeRowState:N,onSwipeRowChange:M,onStageToggle:S,onDiscardWithConfirm:T,onPreviewFile:r}):e.jsx("p",{className:"git-tree-status",children:n("git.noChanges")})})]})}function On({nodes:a,depth:i,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:x,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T}){return a.map(f=>{if(f.kind==="directory"){const j=!u.has(f.path),E=$t(f.children),d=`directory:${f.path}`;return e.jsxs("div",{className:"git-mobile-record-branch",children:[e.jsx(An,{rowKey:d,openState:(b==null?void 0:b.path)===d?b.direction:null,onOpenStateChange:R=>N(R?{path:d,direction:R}:null),trailingActions:E.length>0?[{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M(E,y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S(E,f.path)}]:[]]:null,children:e.jsxs("button",{className:"git-mobile-record git-mobile-record-directory",type:"button",style:{paddingInlineStart:`${Mn+i*En}px`},onClick:()=>g(f.path),children:[e.jsxs("span",{className:"git-mobile-record-leading",children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":j,children:e.jsx(at,{expanded:j})}),e.jsx("span",{className:"git-mobile-record-title",children:f.name})]}),e.jsx("span",{className:"git-mobile-record-meta",children:E.length})]})}),j?e.jsx("div",{className:"git-mobile-record-children",role:"group",children:On({nodes:f.children,depth:i+1,collapsedTreePathSet:u,onToggleTreePath:g,onToggleMobileSelection:m,selectedMobilePathSet:C,actioning:x,variant:y,swipeRowState:b,onSwipeRowChange:N,onStageToggle:M,onDiscardWithConfirm:S,onPreviewFile:T})}):null]},d)}const r=`file:${f.path}`,h=C.has(f.path);return e.jsx(An,{rowKey:r,openState:(b==null?void 0:b.path)===r?b.direction:null,onOpenStateChange:j=>N(j?{path:r,direction:j}:null),trailingActions:[{label:n("git.preview"),tone:"neutral",onPress:()=>T(f.change.path,f.change)},{label:y==="staged"?n("git.unstage"):n("git.stage"),tone:"accent",onPress:()=>void M([f.change.path],y==="staged")},...y==="unstaged"?[{label:n("git.discard"),tone:"danger",onPress:()=>void S([f.change.path],f.path)}]:[]],children:e.jsxs("div",{className:"git-mobile-record git-mobile-record-file","data-active":h,style:{paddingInlineStart:`${Mn+i*En}px`},children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${f.name}`,onChange:()=>m(f.change.path)}),e.jsxs("button",{className:"git-mobile-record-file-main",type:"button",onClick:()=>m(f.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":_t(f.name),"aria-hidden":"true",children:Dt(f.name)}),e.jsxs("span",{className:"git-mobile-record-copy",children:[e.jsx("span",{className:"git-mobile-record-title",children:f.name}),e.jsx("span",{className:"git-mobile-record-path",children:f.path})]}),e.jsx("span",{className:"git-status-badge","data-status":f.status,children:f.status})]})]})},r)})}function An({rowKey:a,openState:i,onOpenStateChange:u,trailingActions:g,children:m}){const C=Vi(),x=l.useRef(null),[y,b]=l.useState(0),N=((g==null?void 0:g.length)??0)*wt;l.useEffect(()=>{i||b(0)},[i,a]);const M=y!==0?y:i==="trailing"?-N:0;function S(h){var j,E;h.button===0&&(x.current={pointerId:h.pointerId,startX:h.clientX},(E=(j=h.currentTarget).setPointerCapture)==null||E.call(j,h.pointerId))}function T(h){const j=x.current;if(!j||j.pointerId!==h.pointerId)return;const E=N>0?N+10:0,d=Math.max(-E,Math.min(0,h.clientX-j.startX));b(d)}function f(h){var E,d;const j=x.current;if(!(!j||j.pointerId!==h.pointerId)){if((d=(E=h.currentTarget).releasePointerCapture)==null||d.call(E,h.pointerId),x.current=null,y<=-44&&(g!=null&&g.length)){C.trigger("gesture"),u("trailing"),b(0);return}u(null),b(0)}}function r(h){var E,d;const j=x.current;!j||j.pointerId!==h.pointerId||((d=(E=h.currentTarget).releasePointerCapture)==null||d.call(E,h.pointerId),x.current=null,b(0))}return e.jsxs("div",{className:"git-mobile-swipe-row","data-open-state":i??"closed","data-dragging":y!==0,children:[g==null?void 0:g.map((h,j)=>e.jsx("button",{type:"button",className:"git-mobile-swipe-action trailing","data-tone":h.tone,style:{right:j*wt,width:wt},onClick:()=>{C.trigger(h.tone==="danger"?"warning":"action"),u(null),h.onPress()},children:h.label},`trailing-${j}`)),e.jsx("div",{className:"git-mobile-swipe-content",style:{transform:`translateX(${M}px)`},onPointerDown:S,onPointerMove:T,onPointerUp:f,onPointerCancel:r,children:m})]})}function Ki({history:a,historyLoadingMore:i,hasMore:u,actioning:g,openCommitHash:m,onMenuTriggerRef:C,onToggleMenu:x,onViewCommitChanges:y,onCopyCommitHash:b,onCopyCommitMessage:N,onCopyCommitVersion:M,onExplainCommitChange:S,onUndoLastCommit:T,onLoadMore:f}){return a.length?e.jsxs("div",{className:"git-mobile-history-list",children:[a.map(r=>e.jsx("article",{className:"git-mobile-history-entry","data-kind":r.commitKind,children:e.jsxs("div",{className:"git-mobile-history-entry-main",children:[e.jsx("span",{className:"git-history-marker","data-kind":r.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-mobile-history-copy",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:r.subject,children:r.subject}),e.jsx("span",{className:"git-history-kind-badge","data-kind":r.commitKind,children:Wn(r.commitKind)})]}),r.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:r.refs.map(h=>e.jsx("span",{className:"git-history-ref-pill","data-kind":h.kind,"data-remote-index":String(Vn(h.remoteName)),children:h.name},`${r.commitHash}:${h.kind}:${h.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:r.commitHash.slice(0,8)}),e.jsx("span",{children:r.authorName}),e.jsx("time",{dateTime:r.authoredAt,children:In(r.authoredAt)})]})]}),e.jsx("button",{type:"button",className:"git-icon-button",ref:h=>C(r.commitHash,h),"aria-label":n("git.historyItemMenu"),onClick:()=>x(r.commitHash),children:e.jsx(ke,{})})]})},r.commitHash)),u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:f,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"git-tree-status",children:n("git.noHistory")})}function Rn({history:a,historyLoadingMore:i,hasMore:u,actioning:g,openCommitHash:m,className:C,useNativeContextMenu:x=!1,onMenuTriggerRef:y,onScroll:b,onToggleMenu:N,onOpenContextMenu:M,onViewCommitChanges:S,onCopyCommitHash:T,onCopyCommitMessage:f,onCopyCommitVersion:r,onExplainCommitChange:h,onUndoLastCommit:j,onLoadMore:E}){return a.length?e.jsxs("div",{className:["git-history-list",C].filter(Boolean).join(" "),onScroll:b,children:[a.map(d=>{const R=m===d.commitHash;return e.jsxs("article",{className:"git-history-entry","data-kind":d.commitKind,"data-menu-open":R?"true":"false",onContextMenu:w=>{!x||!M||(w.preventDefault(),w.stopPropagation(),M(d))},children:[e.jsx("span",{className:"git-history-marker","data-kind":d.commitKind,"aria-hidden":"true"}),e.jsxs("div",{className:"git-history-body",children:[e.jsxs("div",{className:"git-history-title-row",children:[e.jsx("strong",{title:d.subject,children:d.subject}),e.jsxs("div",{className:"git-history-title-actions",children:[e.jsx("span",{className:"git-history-kind-badge","data-kind":d.commitKind,children:Wn(d.commitKind)}),x?null:e.jsx("button",{type:"button",className:"git-icon-button git-history-more",ref:w=>y(d.commitHash,w),"aria-label":n("git.historyItemMenu"),onClick:()=>{N(d.commitHash)},children:e.jsx(ke,{})})]})]}),d.refs.length>0?e.jsx("div",{className:"git-history-ref-list",children:d.refs.map(w=>e.jsx("span",{className:"git-history-ref-pill","data-kind":w.kind,"data-remote-index":String(Vn(w.remoteName)),children:w.name},`${d.commitHash}:${w.kind}:${w.name}`))}):null,e.jsxs("div",{className:"git-history-meta",children:[e.jsx("span",{className:"git-history-hash",children:d.commitHash.slice(0,8)}),e.jsx("span",{children:d.authorName}),e.jsx("time",{dateTime:d.authoredAt,children:In(d.authoredAt)})]})]})]},d.commitHash)}),i?e.jsxs("p",{className:"git-history-loading",children:[n("git.refreshNow"),"..."]}):null,u?e.jsx("button",{type:"button",className:"secondary-button git-mobile-history-more",disabled:i,onClick:E,children:i?`${n("git.refreshNow")}...`:n("common.loadMore")}):null]}):e.jsx("p",{className:"status-text",children:n("git.noHistory")})}function Xi({item:a,canUndo:i,actioning:u,onViewCommitChanges:g,onCopyCommitHash:m,onCopyCommitMessage:C,onCopyCommitVersion:x,onExplainCommitChange:y,onUndoLastCommit:b}){return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>g(a.commitHash),children:e.jsx("span",{children:n("git.viewCommitChanges")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>m(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitHash")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>C(a),children:e.jsx("span",{children:n("git.copyCommitMessage")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>x(a.commitHash),children:e.jsx("span",{children:n("git.copyCommitVersion")})}),e.jsx("button",{type:"button",className:"git-menu-item",onClick:()=>y(a.commitHash),children:e.jsx("span",{children:n("git.explainCommitAction")})}),i?e.jsx("button",{type:"button",className:"git-menu-item",disabled:u,onClick:b,children:e.jsx("span",{children:n("git.undoLastCommit")})}):null]})}function Gn({nodes:a,depth:i,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:x,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:f}){return a.map(r=>{if(r.kind==="directory"){const E=!u.has(r.path),d=$t(r.children),R=`${S==="staged"?n("git.unstage"):n("git.stage")} ${r.path}`,w=`${n("git.discard")} ${r.path}`;return e.jsxs("div",{className:"git-tree-node",children:[e.jsxs("div",{className:"git-tree-row",role:"treeitem","aria-expanded":E,children:[e.jsxs("button",{className:"git-tree-trigger",type:"button",style:{paddingInlineStart:`${6+i*8}px`},onClick:()=>m(r.path),children:[e.jsx("span",{className:"git-tree-chevron","data-expanded":E,children:e.jsx(at,{expanded:E})}),e.jsx("span",{className:"git-tree-label git-tree-label-directory",children:r.name})]}),!T&&d.length>0?e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":R,title:R,onClick:()=>void b(d,S==="staged"),disabled:M,children:e.jsx(Ot,{staged:S==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":w,title:w,onClick:()=>void N(d),disabled:M,children:e.jsx(Gt,{})}):null]}):null]}),E?e.jsx("div",{className:"git-tree-children",role:"group",children:Gn({nodes:r.children,depth:i+1,collapsedTreePathSet:u,selectedPath:g,onToggleTreePath:m,onSelectFile:C,onPreviewFile:x,onToggleMobileSelection:y,onStageToggle:b,onDiscard:N,actioning:M,variant:S,isMobileViewport:T,selectedMobilePathSet:f})}):null]},`directory:${r.path}`)}const h=f.has(r.path),j=T?h:g===r.path;return T?e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":j,"data-mobile":"true",children:[e.jsx("input",{className:"git-tree-select-checkbox",type:"checkbox",checked:h,"aria-label":`${n("git.selectFile")} ${r.name}`,onChange:()=>y(r.change.path)}),e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,"data-mobile":"true",style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>y(r.change.path),children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":_t(r.name),"aria-hidden":"true",children:Dt(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]})]},`file:${r.path}`):e.jsxs("div",{className:"git-tree-row",role:"treeitem","data-active":j,children:[e.jsxs("button",{className:"git-tree-file-button",type:"button","data-active":j,style:{paddingInlineStart:`${18+i*8}px`},onClick:()=>{C(r.change.path),x&&x(r.change.path,r.change)},children:[e.jsx("span",{className:"git-tree-file-icon","data-kind":_t(r.name),"aria-hidden":"true",children:Dt(r.name)}),e.jsx("span",{className:"git-tree-label-wrap",children:e.jsx("span",{className:"git-tree-label",children:r.name})}),e.jsx("span",{className:"git-tree-file-meta",children:e.jsx("span",{className:"git-status-badge","data-status":r.status,children:r.status})})]}),e.jsxs("div",{className:"git-row-actions",children:[e.jsx("button",{className:"git-icon-button",type:"button","aria-label":r.variant==="staged"?n("git.unstage"):n("git.stage"),title:r.variant==="staged"?n("git.unstage"):n("git.stage"),onClick:()=>void b([r.change.path],r.variant==="staged"),disabled:M,children:e.jsx(Ot,{staged:r.variant==="staged"})}),S==="unstaged"?e.jsx("button",{className:"git-icon-button danger",type:"button","aria-label":n("git.discard"),title:n("git.discard"),onClick:()=>void N([r.change.path]),disabled:M,children:e.jsx(Gt,{})}):null]})]},`file:${r.path}`)})}function Pn(a,i){return{kind:"directory",name:a,path:i,children:new Map}}function Ln(a,i){const u=Pn("","");for(const g of a){const m=g.path.replace(/\\/g,"/"),C=m.split("/").filter(Boolean);let x=u;C.forEach((y,b)=>{const N=C.slice(0,b+1).join("/");if(b===C.length-1){x.children.set(`file:${N}`,{kind:"file",name:y,path:m,change:g,status:qi(g,i),variant:i});return}const M=`directory:${N}`,S=x.children.get(M);if(S&&S.kind==="directory"){x=S;return}const T=Pn(y,N);x.children.set(M,T),x=T})}return Bn($n([...u.children.values()]))}function $n(a){return[...a].sort((i,u)=>i.kind!==u.kind?i.kind==="directory"?-1:1:i.name.localeCompare(u.name,"zh-CN")).map(i=>i.kind==="directory"?{kind:"directory",name:i.name,path:i.path,children:$n([...i.children.values()])}:i)}function Bn(a){return a.map(i=>{var x;if(i.kind!=="directory")return i;const u=Bn(i.children);let g=i.name,m=i.path,C=u;for(;C.length===1&&((x=C[0])==null?void 0:x.kind)==="directory";){const y=C[0];g=`${g}/${y.name}`,m=y.path,C=y.children}return{kind:"directory",name:g,path:m,children:C}})}function Dn(a,i,u){const g=new Set(a);return i.filter(m=>kt(m,u)&&g.has(m.path)).map(m=>m.path)}function $t(a){const i=[],u=new Set;function g(m){if(m.kind==="file"){u.has(m.path)||(u.add(m.path),i.push(m.path));return}m.children.forEach(g)}return a.forEach(g),i}function kt(a,i){return i==="staged"?!!a.stagedStatus:!!a.worktreeStatus}function qi(a,i){return i==="staged"?a.stagedStatus??a.status:a.worktreeStatus??a.status}function Yi(a){return{subject:Un(a).trim(),body:null,footer:null,source:"manual"}}function Un(a){return a.replace(/[\r\n]+/g," ")}function ue(a){const i=a.subject.trim(),u=a.body.trim();return u?`${i}
|
|
2
|
-
|
|
3
|
-
${u}`:i}function Zi(a){const i=a.changedFiles.map(m=>`- [${m.status}] ${m.path}${m.oldPath?` (from ${m.oldPath})`:""}`).join(`
|
|
4
|
-
`),u=a.diffContent.length>At?a.diffContent.slice(0,At):a.diffContent,g=a.diffContent.length>At||a.diffTruncated?`
|
|
5
|
-
注意:diff 内容过长,下面已经截断,只分析可见部分,同时明确指出可能遗漏的区域。`:"";return["请你分析下面这个 Git 提交。","输出要求:","1. 先用 3 到 5 句话说明这次改动的核心目的。","2. 按文件说明关键改动点,不要泛泛而谈。","3. 指出潜在风险、边界情况和可能的回归点。","4. 如果提交信息写得差,给出一条更合适的中文提交说明。","",`版本号:${a.versionLabel}`,`Commit Hash:${a.commitHash}`,`提交标题:${a.subject}`,`提交作者:${a.authorName} <${a.authorEmail}>`,`提交时间:${a.authoredAt}`,"","变更文件:",i||"- 无",g,"","Diff:",u||"(empty diff)"].join(`
|
|
6
|
-
`)}function Ji(a){if(!a)return;a.style.height="0px";const i=Math.min(Math.max(a.scrollHeight,34),120);a.style.height=`${i}px`,a.style.overflowY=a.scrollHeight>120?"auto":"hidden"}function Wn(a){switch(a){case"local":return n("git.historyKindLocal");case"remote":return n("git.historyKindRemote");default:return n("git.historyKindShared")}}function Vn(a){if(!a)return 0;let i=0;for(const u of a)i=i*33+u.charCodeAt(0)>>>0;return i%6}function Qi(a){const i=Date.parse(a);return Number.isNaN(i)?a:new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(i)}function D(a,i){return a instanceof kn?es(a)??a.message:typeof a=="object"&&a&&"message"in a?a.message:i}function Pt(a){return`git-sidebar.snapshot.${a}`}function es(a){switch(a.errorCode){case"UNAUTHORIZED":return n("git.errors.unauthorized");case"WORKSPACE_NOT_FOUND":return n("git.errors.workspaceNotFound");case"INVALID_WORKSPACE":return n("git.errors.invalidWorkspace");case"NOT_GIT_REPOSITORY":return n("git.errors.notGitRepository");case"GIT_REPO_NOT_FOUND":return n("git.errors.repoNotFound");case"PATH_OUT_OF_WORKSPACE":return n("git.errors.pathOutOfWorkspace");case"INVALID_TARGET":return n("git.errors.invalidTarget");case"NOT_STAGED":return n("git.errors.notStaged");case"EMPTY_STAGED_CHANGES":return n("git.errors.emptyStagedChanges");case"BRANCH_CONFLICT":return n("git.errors.branchConflict");case"BRANCH_NOT_FOUND":return n("git.errors.branchNotFound");case"REMOTE_NOT_FOUND":return n("git.errors.remoteNotFound");case"GIT_REMOTE_AUTH_FAILED":return n("git.errors.remoteAuthFailed");case"GIT_PUSH_FAILED":return n("git.errors.pushFailed");case"GIT_PULL_FAILED":return n("git.errors.pullFailed");case"GIT_REMOTE_FAILED":return n("git.errors.remoteFailed");case"GIT_COMMAND_TIMEOUT":return n("git.errors.commandTimeout");case"GIT_DISCARD_FAILED":return n("git.discardFailed");case"GIT_UNDO_FAILED":return n("git.undoLastCommitFailed");default:return null}}function _n(a){return a instanceof kn&&a.errorCode==="GIT_REMOTE_AUTH_FAILED"}function ts(a){return!a||!a.mode||a.mode==="none"?st:a.mode==="basic"?{authMode:"basic",username:a.username??"",password:a.password??"",token:"",rememberOnHost:!1}:a.mode==="token"?{authMode:"token",username:a.username??"",password:"",token:a.token??"",rememberOnHost:!1}:st}function ns(a){return a.authMode==="none"?null:a.authMode==="basic"?{mode:"basic",username:a.username.trim(),password:a.password}:{mode:"token",username:a.username.trim()||void 0,token:a.token}}function is(a,i){const u=a.find(m=>m.name===i)??a.find(m=>m.name==="origin")??a[0];if(!u)return"generic";const g=u.pushUrl||u.fetchUrl;return ss(g)?"github":"generic"}function ss(a){const i=(a==null?void 0:a.trim().toLowerCase())??"";return i.startsWith("https://github.com/")||i.startsWith("http://github.com/")||i.startsWith("ssh://git@github.com/")||i.startsWith("git@github.com:")}function Fn(a,i,u){const g=Math.max(0,u.width),m=Math.max(0,u.height),C=Math.max(0,m-_*2),x=Math.max(0,g-_*2),y=Math.min(Math.max(i.width||Ft,0),x),b=Math.max(0,m-a.bottom-it-_),N=Math.max(0,a.top-it-_),M=b<i.height&&N>b,T=Lt(Math.max(M?N:b,zi),0,C),f=Math.min(Math.max(i.height,0),T),r=M?a.top-it-f:a.bottom+it,h=Math.max(_,m-_-f),j=Math.max(_,g-_-y);return{top:Lt(r,_,h),left:Lt(a.right-y,_,j),maxHeight:Math.max(0,T),transformOrigin:`${M?"bottom":"top"} right`}}function Lt(a,i,u){return!Number.isFinite(a)||u<i?i:Math.min(Math.max(a,i),u)}function at({expanded:a}){return e.jsx("svg",{className:"git-chevron-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:a?"rotate(0deg)":"rotate(-90deg)"},"aria-hidden":"true",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Ot({staged:a}){return a?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M5 12h14"})}):e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Gt(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[e.jsx("path",{d:"M10 7L6 11l4 4",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M7 11h7c3.87 0 7 3.13 7 7 0 1.9-.76 3.63-2 4.89",strokeLinecap:"round",strokeLinejoin:"round"})]})}function as(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3z"})})}function ke(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"5",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"19",cy:"12",r:"1.8"})]})}function In(a){try{return new Intl.DateTimeFormat("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(a))}catch{return a}}export{ps as GitSidebar,Fn as resolveGitOperationsMenuPosition};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var V=Object.defineProperty;var Z=(e,n,s)=>n in e?V(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s;var R=(e,n,s)=>Z(e,typeof n!="symbol"?n+"":n,s);import{B as i,A as Y,b as w,t as g,j as r,f as X,Q as H,h as $}from"./index-C2G8Gmf1.js";import{d as _,f as ee}from"./App-WOLwMld_.js";function ne(){return i.request("/api/workspaces")}async function Te(){try{return await i.request("/api/workbench")}catch(e){if(!(e instanceof Y)||e.status!==404)throw e;const n=await ne();return{items:await Promise.all(n.items.map(async o=>({workspace:o,sessions:(await se(o.id)).items})))}}}function Be(e){return i.request("/api/workspaces/import",{method:"POST",body:JSON.stringify(e)})}function Me(e){return i.request("/api/workspaces/clone",{method:"POST",body:JSON.stringify(e)})}function je(e){return i.request(`/api/workspaces/${encodeURIComponent(e)}`,{method:"DELETE"})}function ke(e){return i.request("/api/debug-targets/analyze",{method:"POST",body:JSON.stringify(e)})}function Ke(e,n){return i.request(`/api/debug-targets/${encodeURIComponent(e)}/launch-plan`,{method:"POST",body:JSON.stringify({})})}function Fe(){return i.request("/api/framework-compatibility-matrix")}function Je(e){return i.request("/api/workspaces/reorder",{method:"PUT",body:JSON.stringify(e)})}function Qe(e,n){return i.request(`/api/workspaces/${encodeURIComponent(e)}/navigation-state`,{method:"PUT",body:JSON.stringify(n)})}function Ge(e){const n=new URLSearchParams;return e!=null&&e.trim()&&n.set("path",e.trim()),i.request(`/api/workspaces/browse${n.size>0?`?${n.toString()}`:""}`)}function We(e){return i.request("/api/workspaces/directories",{method:"POST",body:JSON.stringify(e)})}function se(e){return i.request(`/api/sessions?workspaceId=${encodeURIComponent(e)}`)}function ze(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`)}function Ve(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/changed-files`)}function Ze(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/seen`,{method:"POST"})}function Ye(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/title`,{method:"PATCH",body:JSON.stringify({title:n})})}function Xe(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/archive`,{method:"PATCH",body:JSON.stringify({archived:n})})}function He(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/favorite`,{method:"PATCH",body:JSON.stringify({favorite:n})})}function $e(e){return i.request(`/api/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function _e(e){return i.request("/api/worktrees",{method:"POST",body:JSON.stringify(e)})}function en(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-preview`,{method:"POST"})}function nn(e){return i.request(`/api/worktrees/${encodeURIComponent(e)}/merge-into-parent`,{method:"POST"})}function sn(e,n){return i.request(`/api/worktrees/${encodeURIComponent(e)}/cleanup`,{method:"POST",body:JSON.stringify(n??{})})}function tn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/capabilities`)}function on(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests`)}function rn(){return i.request("/api/preferences/quick-phrases")}function an(e){return i.request("/api/preferences/quick-phrases",{method:"PUT",body:JSON.stringify({items:e})})}function te(e,n){const s=new URLSearchParams;return n!=null&&n.trim()&&s.set("workspaceId",n.trim()),i.request(`/api/providers/${encodeURIComponent(e)}/capabilities${s.size>0?`?${s.toString()}`:""}`)}async function oe(e,n){const s=await Promise.allSettled(e.map(async t=>[t,await te(t,n)])),o=[];for(const t of s){if(t.status!=="fulfilled")continue;const[a,l]=t.value;o.push([a,l])}return Object.fromEntries(o)}function un(e,n,s,o="forward"){const t=new URLSearchParams;return n&&t.set("cursor",n),t.set("limit",String(s)),t.set("direction",o),i.request(`/api/sessions/${encodeURIComponent(e)}/messages?${t.toString()}`)}function ln(e,n){return i.requestBlob(`/api/sessions/${encodeURIComponent(e)}/attachments/${encodeURIComponent(n)}/content`)}function cn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages`,{method:"POST",body:JSON.stringify(n)})}function dn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/forks`,{method:"POST",body:JSON.stringify(n)})}function fn(e){return i.request("/api/sessions/start-live",{method:"POST",body:JSON.stringify(e)})}function pn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/messages/live`,{method:"POST",body:JSON.stringify(n)})}function mn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`)}function gn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"POST",body:JSON.stringify(n)})}function Sn(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}`,{method:"DELETE"})}function An(e,n){return i.request(`/api/sessions/${encodeURIComponent(e)}/queue/${encodeURIComponent(n)}/steer`,{method:"POST"})}function hn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/runtime`)}function yn(e){return i.request(`/api/sessions/${encodeURIComponent(e)}/interrupt`,{method:"POST"})}function vn(e,n,s){return i.request(`/api/sessions/${encodeURIComponent(e)}/permission-requests/${encodeURIComponent(n)}/reply`,{method:"POST",body:JSON.stringify(s)})}const I="codingns.workspace.session-display-sort-mode",b="codingns.file-panel.show-system-files",q="codingns.notification.preferences",C={notifyOnPermissionRequest:!0,notifyOnSessionCompleted:!0,notifyOnSessionFailed:!0};function D(){return typeof window<"u"&&typeof window.localStorage<"u"}function re(e){return e==="createdAt"||e==="updatedAt"||e==="title"}function B(){if(!D())return"createdAt";const e=window.localStorage.getItem(I);return re(e)?e:"createdAt"}function M(){return D()?window.localStorage.getItem(b)==="1":!1}function U(e){return typeof e=="boolean"}function j(){if(!D())return C;const e=window.localStorage.getItem(q);if(!e)return C;try{const n=JSON.parse(e);return{notifyOnPermissionRequest:U(n.notifyOnPermissionRequest)?n.notifyOnPermissionRequest:C.notifyOnPermissionRequest,notifyOnSessionCompleted:U(n.notifyOnSessionCompleted)?n.notifyOnSessionCompleted:C.notifyOnSessionCompleted,notifyOnSessionFailed:U(n.notifyOnSessionFailed)?n.notifyOnSessionFailed:C.notifyOnSessionFailed}}catch{return C}}function k(e,n){return e.notifyOnPermissionRequest===n.notifyOnPermissionRequest&&e.notifyOnSessionCompleted===n.notifyOnSessionCompleted&&e.notifyOnSessionFailed===n.notifyOnSessionFailed}function ie(e){D()&&window.localStorage.setItem(q,JSON.stringify(e))}class ae{constructor(){R(this,"state",{sessionDisplaySortMode:B(),showSystemFiles:M(),notificationPreferences:j()});R(this,"listeners",new Set);R(this,"subscribe",n=>(this.listeners.add(n),()=>{this.listeners.delete(n)}));R(this,"getState",()=>this.state);R(this,"handleStorage",n=>{if(n.key!==null&&n.key!==I&&n.key!==b&&n.key!==q)return;const s=B(),o=M(),t=j(),a=this.state.sessionDisplaySortMode===s,l=this.state.showSystemFiles===o,d=k(this.state.notificationPreferences,t);a&&l&&d||(this.state={sessionDisplaySortMode:s,showSystemFiles:o,notificationPreferences:t},this.emit())});typeof window<"u"&&window.addEventListener("storage",this.handleStorage)}setSessionDisplaySortMode(n){D()&&(n==="createdAt"?window.localStorage.removeItem(I):window.localStorage.setItem(I,n)),this.state.sessionDisplaySortMode!==n&&(this.state={...this.state,sessionDisplaySortMode:n},this.emit())}setShowSystemFiles(n){D()&&(n?window.localStorage.setItem(b,"1"):window.localStorage.removeItem(b)),this.state.showSystemFiles!==n&&(this.state={...this.state,showSystemFiles:n},this.emit())}setNotificationPreferences(n){const s={...this.state.notificationPreferences,...n};k(this.state.notificationPreferences,s)||(ie(s),this.state={...this.state,notificationPreferences:s},this.emit())}emit(){for(const n of this.listeners)n()}}const K=new ae;function Rn(e){return w.useSyncExternalStore(K.subscribe,()=>e(K.getState()))}function ue(){return _().haptics}const le="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=",ce="/assets/gemini-D4G1NbrE.png",de="/assets/kimi-BWNNSh7e.png",fe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAABzUlEQVR4AeycQQrCQBAEF1+g6J/0o5LPCXmCnnNx0E2nNqGEPciw024VffV0PZ/fHo7BqflBCSgAxd+aAhQAE4DjbYACYAJwvA1QAEwAjrcBCgAIDBRpA2AZClAATACOtwEKgAnA8TZAATABOD7egNc8tz2ftJ+4gPQD9r5fAbDBDQXALx00XgGwGAUoACYAx9sABcAE4HgboACYABxvAxSwJHC7XFryLNP4bzYg7KBar4CKUHiugDDgar0CKkLhuQLCgKv1CqgIhecKCAOu1iugIhSeKyAMuFqvgIpQeK6AMOBq/XAC7o9H6z5fdlRAtp4PJ2BrAHSeAmADClAATACOtwEKgAnA8TZAATABON4GKAAmAMev2AD4JTuNVwAsTgEKgAnA8TZAATABON4GKAAmAMfbAAXABOB4G9ApoPe6AnoJdt5XQCfA3uvDCXhOU0ueXmBr3x9OwNoPHH2fAmBDClAATACOtwEKgAnA8TZAAX8QONAVGwDLVIACYAJwfLwByf/+2WJ32k9cQPoBe9+vANigAhQAE4DjbYACYAJw/A8NgH/pQeMVAItVgAJgAnC8DVAATACOtwEKgAnA8TZAATABON4GFALS4w8AAAD//x7wkLQAAAAGSURBVAMAKj5LkLSa6SQAAAAASUVORK5CYII=",pe=new Set(["low","medium","high","xhigh"]),me=["claude-code","codex","opencode","gemini","kimi"],ge=["codex","claude-code","opencode","gemini","kimi"],G={"claude-code":{displayNameKey:"conversation.providerClaude",fullDisplayNameKey:"shell.providerClaudeCode",draftTitleKey:"conversation.draftTitleClaude",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:le,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:fe,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:void 0,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!1},gemini:{displayNameKey:"conversation.providerGemini",draftTitleKey:"conversation.draftTitleGemini",defaultModelLabelKey:"conversation.modelUseCliDefault",icon:ce,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:de,defaultRunInputMode:"none",reasoningLevelPersists:!1,defaultReasoningLevel:null,supportsInterrupt:!0,supportsAttachments:!1,supportsPermissionPrompt:!1,supportsSlashMenuByDefault:!1,supportsSessionDeleteByDefault:!0,foldRulesMessagesByDefault:!0}},Se=Array.from(new Set(Object.values(G).map(e=>e.icon)));let F=!1;function Ae(e){return me.includes(e)}function c(e){return!e||!Ae(e)?null:G[e]}function he(e){return[{id:"provider-default",name:g(e),usesProviderDefault:!0}]}function ye(e){const n=c(e);return he((n==null?void 0:n.defaultModelLabelKey)??"conversation.modelUseCliDefault")}function Cn(e){return!!(e&&c(e))}function wn(e){const n=c(e);return g((n==null?void 0:n.draftTitleKey)??"conversation.draftTitleCodex")}function ve(e,n="compact"){const s=c(e);return s?n==="full"&&s.fullDisplayNameKey?g(s.fullDisplayNameKey):g(s.displayNameKey):(e==null?void 0:e.trim())||g("conversation.providerCodex")}function Re(e){const n=c(e);return(n==null?void 0:n.icon)??Q}function W(){F||typeof window>"u"||(F=!0,Se.forEach(e=>{const n=new window.Image;n.decoding="async",n.src=e,typeof n.decode=="function"&&n.decode().catch(()=>{})}))}function Dn(e){const n=c(e);return{provider:e,canStartSession:!0,canResumeSession:!0,canSendMessage:!0,inRunInputMode:(n==null?void 0:n.defaultRunInputMode)??"none",supportsSubagents:!1,supportsInterrupt:(n==null?void 0:n.supportsInterrupt)??!1,supportsStructuredToolCalls:!0,supportsTokenUsage:!0,supportsAttachments:(n==null?void 0:n.supportsAttachments)??!0,supportsPermissionPrompt:(n==null?void 0:n.supportsPermissionPrompt)??!0,supportsCheckpoint:!1,supportsSessionDelete:(n==null?void 0:n.supportsSessionDeleteByDefault)??!1,modelOptions:ye(e),defaultReasoningLevel:n==null?void 0:n.defaultReasoningLevel,supportsRunSteering:n==null?void 0:n.supportsRunSteeringByDefault,supportsQueueWhileRunning:n==null?void 0:n.supportsQueueWhileRunningByDefault,limitations:[]}}function Pn(e){return(e==null?void 0:e.provider)??"claude-code"}function On(e){var s;if((e==null?void 0:e.supportsSlashMenu)!==void 0)return e.supportsSlashMenu;const n=(e==null?void 0:e.provider)??null;return((s=c(n))==null?void 0:s.supportsSlashMenuByDefault)??!1}function Nn(e){var n;return(e==null?void 0:e.supportsReasoningSelector)!==void 0?e.supportsReasoningSelector:!!((n=e==null?void 0:e.modelOptions)!=null&&n.some(s=>{var o;return((o=s.supportedReasoningEfforts)==null?void 0:o.some(t=>pe.has(t)))??!1}))}function In(e,n){var a;if((e==null?void 0:e.supportsQueueWhileRunning)!==void 0)return e.supportsQueueWhileRunning;const s=(e==null?void 0:e.provider)??null,o=(a=c(s))==null?void 0:a.supportsQueueWhileRunningByDefault;if(o!==void 0)return o;const t=(e==null?void 0:e.inRunInputMode)??"none";return t==="queued_guidance"||t==="none"||t==="streaming_guidance"&&n===!1}function bn(e){var s;if((e==null?void 0:e.supportsRunSteering)!==void 0)return e.supportsRunSteering;const n=(e==null?void 0:e.provider)??null;return((s=c(n))==null?void 0:s.supportsRunSteeringByDefault)??(e==null?void 0:e.inRunInputMode)==="streaming_guidance"}function En(e){const n=c(e);return(n==null?void 0:n.reasoningLevelPersists)??!1}function Ln(e,n){var o;return((o=c(n??null))==null?void 0:o.foldRulesMessagesByDefault)??!1}typeof window<"u"&&W();const x=new Map;function Un(){x.clear()}function qn({disabled:e=!1,workspaceId:n=null,pendingProvider:s=null,selectedProvider:o=null,providers:t=ge,className:a,disabledReasons:l,statusHintByProvider:d,onSelect:P}){const O=ue(),S=!!n,[v,f]=w.useState(()=>J(t,n)),A=t.map(u=>({provider:u}));return w.useEffect(()=>{W()},[]),w.useEffect(()=>{if(!n){f({});return}const u=J(t,n);f(u);const h=t.filter(m=>!u[m]);if(h.length===0)return;let p=!1;return oe(h,n).then(m=>{we(n,m),p||f(N=>({...N,...m}))}),()=>{p=!0}},[t,n]),r.jsx("div",{className:`session-provider-grid${a?` ${a}`:""}`,children:A.map(u=>{const h=ve(u.provider,"full"),p=s===u.provider,m=o===u.provider,N=!!v[u.provider],E=Ce(v[u.provider]??null),L=(l==null?void 0:l[u.provider])??E,T=p?g("shell.startingSession"):L||((d==null?void 0:d[u.provider])??(S&&!N&&!p?g("shell.providerChecking"):null));return r.jsxs("button",{type:"button",className:"session-provider-card","data-provider":u.provider,"data-pending":p?"true":"false","data-selected":m?"true":"false","aria-label":h,disabled:e||!!L,onClick:()=>{O.trigger("action"),P(u.provider)},children:[r.jsx("span",{className:"session-provider-card-icon","aria-hidden":"true",children:r.jsx("img",{src:Re(u.provider),alt:"",loading:"eager",decoding:"async"})}),r.jsxs("span",{className:"session-provider-card-copy",children:[r.jsx("strong",{children:h}),T?r.jsx("span",{className:"session-provider-card-status",children:T}):null]})]},u.provider)})})}function Ce(e){return!e||e.canStartSession!==!1?null:e.limitations[0]??g("conversation.capabilityDenied")}function J(e,n){const s=(n==null?void 0:n.trim())??"";if(!s)return{};const o=[];for(const t of e){const a=x.get(z(s,t));a&&o.push([t,a])}return Object.fromEntries(o)}function we(e,n){const s=e.trim();if(s)for(const[o,t]of Object.entries(n))t&&x.set(z(s,o),t)}function z(e,n){return`${e}::${n}`}function xn(){const e=X(s=>s),n=H(s=>s);return De(e,n)}function De(e,n){var a;const s=$(e);if(!s)return null;const o=!!((a=s.relayTunnel)!=null&&a.enabled),t=n.activeHostId===s.id&&n.candidateProbePhase==="ready"?Pe(n):null;if(t){const l=Oe(t.kind);return{kind:l,url:t.url,endpointId:t.endpointId,autoDirect:o&&l!=="relay",probeInProgress:!1}}return{kind:Ne(s),url:s.baseUrl,endpointId:null,autoDirect:!1,probeInProgress:o&&n.activeHostId===s.id&&n.candidateProbePhase==="probing"}}function Tn(e){switch(e){case"relay":return"common.connectionRouteRelay";case"lan":return"common.connectionRouteLan";case"loopback":return"common.connectionRouteLoopback";case"tailscale":return"common.connectionRouteTailscale";default:return"common.connectionRouteDirect"}}function Pe(e){const n=e.preferredDirectCandidateEndpointId??e.preferredCandidateEndpointId;return n?e.candidateEndpoints.find(s=>s.endpointId===n&&s.status==="verified")??null:null}function Oe(e){return e==="custom"?"direct":e}function Ne(e){var n;if((n=e.relayTunnel)!=null&&n.enabled&&Ie(e.baseUrl,e.relayTunnel.tunnelDomain))return"relay";try{const s=new URL(e.baseUrl).hostname.toLowerCase();if(be(s))return"loopback";if(Ee(s))return"tailscale";if(Le(s))return"lan"}catch{return"direct"}return e.kind==="local"?"loopback":e.kind==="lan"?"lan":"direct"}function Ie(e,n){try{return new URL(e).hostname.toLowerCase()===n.trim().toLowerCase()}catch{return!1}}function be(e){return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}function Ee(e){if(e.endsWith(".ts.net"))return!0;const n=e.split(".").map(t=>Number(t));if(n.length!==4||n.some(t=>Number.isNaN(t)))return!1;const[s,o]=n;return s===100&&o>=64&&o<=127}function Le(e){const n=e.split(".").map(t=>Number(t));if(n.length!==4||n.some(t=>Number.isNaN(t)))return!1;const[s,o]=n;return s===10||s===192&&o===168||s===172&&o>=16&&o<=31}function Bn({heading:e,description:n,actions:s,tone:o="default",className:t,children:a}){return r.jsxs("section",{className:y("modal-section",t),"data-tone":o,children:[e||n||s?r.jsxs("div",{className:"modal-section-header",children:[r.jsxs("div",{className:"modal-section-copy",children:[e?r.jsx("strong",{className:"modal-section-heading",children:e}):null,n?r.jsx("p",{className:"modal-section-description",children:n}):null]}),s?r.jsx("div",{className:"modal-section-actions",children:s}):null]}):null,a]})}function Mn({label:e,description:n,className:s,htmlFor:o,children:t}){return r.jsxs("div",{className:y("workbench-modal-field","modal-field",s),children:[r.jsxs("div",{className:"modal-field-copy",children:[o?r.jsx("label",{className:"modal-field-label",htmlFor:o,children:e}):r.jsx("span",{className:"modal-field-label",children:e}),n?r.jsx("span",{className:"modal-field-description",children:n}):null]}),t]})}function jn({align:e="end",stack:n=!1,className:s,children:o,...t}){return r.jsx("div",{className:y("workbench-modal-actions","modal-actions",s),"data-align":e,"data-stack":n?"true":void 0,...t,children:o})}function kn({compact:e=!1,className:n,children:s,...o}){return r.jsx("div",{className:y("modal-list",n),"data-compact":e?"true":void 0,...o,children:s})}function Kn(e){const{as:n="div",label:s,description:o,leading:t,trailing:a,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":n==="button"?"true":void 0},A=r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"modal-list-item-main",children:[t?r.jsx("span",{className:"modal-list-item-leading",children:t}):null,r.jsxs("span",{className:"modal-list-item-copy",children:[s?r.jsx("span",{className:"modal-list-item-label",children:s}):null,o?r.jsx("span",{className:"modal-list-item-description",children:o}):null,O]})]}),a?r.jsx("span",{className:"modal-list-item-trailing",children:a}):null]});if(n==="button"){const u=S;return r.jsx("button",{type:u.type??"button",...u,...f,children:A})}return r.jsx("div",{...S,...f,children:A})}function Fn({title:e,description:n,action:s,className:o,compact:t=!1}){return r.jsxs("div",{className:y("modal-empty-state",o),"data-compact":t?"true":void 0,children:[r.jsx("strong",{className:"modal-empty-state-title",children:e}),n?r.jsx("p",{className:"modal-empty-state-description",children:n}):null,s?r.jsx("div",{className:"modal-empty-state-action",children:s}):null]})}function Jn({tone:e="default",className:n,children:s,...o}){return r.jsx("span",{className:y("modal-tag",n),"data-tone":e!=="default"?e:void 0,...o,children:s})}function y(...e){return e.filter(Boolean).join(" ")}function Qn({open:e,title:n,description:s,height:o="auto",kind:t="form",dismissible:a=!0,closeOnBackdrop:l=!0,showHandle:d=!1,showCancelButton:P=!0,cancelLabel:O,className:S,cardClassName:v,bodyClassName:f,footer:A,onClose:u,children:h}){const p=w.useId(),m=w.useId(),N=a&&l;return!e||typeof document>"u"?null:ee.createPortal(r.jsx("div",{className:"ios-action-sheet-overlay mobile-sheet-overlay",role:"presentation",onClick:()=>{N&&u()},children:r.jsxs("div",{className:`mobile-workspace-home-sheet mobile-sheet${S?` ${S}`:""}`,"data-height":o,"data-kind":t,role:"dialog","aria-modal":"true","aria-labelledby":p,"aria-describedby":s?m:void 0,onClick:E=>E.stopPropagation(),children:[r.jsxs("div",{className:`mobile-workspace-home-sheet-card mobile-sheet-card${v?` ${v}`:""}`,children:[d?r.jsx("div",{className:"mobile-sheet-handle","aria-hidden":"true"}):null,r.jsx("div",{className:"mobile-workspace-home-sheet-header mobile-sheet-header",children:r.jsxs("div",{className:"mobile-sheet-title-wrap",children:[r.jsx("strong",{id:p,children:n}),s?r.jsx("p",{id:m,children:s}):null]})}),r.jsx("div",{className:f?`mobile-sheet-body ${f}`:"mobile-sheet-body",children:h}),A?r.jsx("div",{className:"mobile-sheet-footer",children:A}):null]}),P?r.jsx("button",{type:"button",className:"ios-action-sheet-cancel mobile-sheet-cancel",disabled:!a,onClick:()=>{a&&u()},children:O??g("common.cancel")}):null]})}),document.body)}export{Ge as $,Sn as A,An as B,yn as C,vn as D,Ze as E,hn as F,tn as G,on as H,mn as I,cn as J,Cn as K,bn as L,Qn as M,wn as N,Fn as O,$e as P,Pn as Q,Nn as R,qn as S,On as T,In as U,an as V,En as W,rn as X,Ln as Y,ln as Z,Re as _,ve as a,Me as a0,Be as a1,We as a2,en as a3,nn as a4,sn as a5,Xe as a6,Un as a7,Qe as a8,Je as a9,He as aa,Ye as ab,_e as ac,K as ad,Ve as ae,ke as b,Ke as c,Fe as d,ue as e,Bn as f,Te as g,Mn as h,kn as i,Kn as j,Jn as k,xn as l,Tn as m,Dn as n,te as o,oe as p,ge as q,je as r,dn as s,pn as t,Rn as u,fn as v,ze as w,jn as x,un as y,gn as z};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as r,j as e,t as s,B as A,c as ue,e as Q,v as ws,A as ge,N as se,n as Be,O as He,h as tt,f as nt,P as ke,p as at,d as Ce,l as it}from"./index-C2G8Gmf1.js";import{f as lt,h as We,j as rt,k as ct,l as ot,n as dt,d as Ve,e as ut,o as gt,u as Ss,i as mt,c as ht,L as Ts,T as ks,p as Cs}from"./App-WOLwMld_.js";import{a7 as pt,l as bt,m as ft,f as de,k as De,x as te,h as je,i as Ds,j as xt,M as vt,u as ie,ad as le}from"./MobileSheet-Gzc14EpR.js";import{M as jt,W as ne}from"./WorkbenchModal-B09hC9b5.js";import{M as yt}from"./MobileTopHeaderFrame-BWorAJ1C.js";const Ke=2e4,Nt=1e3,wt=5e3;function St({isOpen:t,onClose:a}){const[n,i]=r.useState(null),[l,d]=r.useState(null),[x,v]=r.useState(!1),[p,w]=r.useState(!1),[f,b]=r.useState(null),T=r.useRef(null);if(r.useEffect(()=>{if(!t)return;let h=!1;async function u(){v(!0),b(null),d(null);try{const g=await A.request("/api/observability/runtime/session",{method:"POST",body:JSON.stringify({ttlMs:Ke})});if(h){await Pe(g.sessionId);return}T.current=g.sessionId,i(g);const N=await Je(g.sessionId);if(h){await Pe(g.sessionId);return}d(N)}catch(g){h||b(Me(g))}finally{h||v(!1)}}return u(),()=>{h=!0;const g=T.current;T.current=null,i(null),d(null),v(!1),w(!1),b(null),g&&Pe(g)}},[t]),r.useEffect(()=>{const h=(n==null?void 0:n.sessionId)??null;if(!t||!h)return;const u=h;let g=!1;async function N(){w(!0);try{const m=await Je(u);g||(d(m),b(null))}catch(m){g||b(Me(m))}finally{g||w(!1)}}const M=window.setInterval(()=>{N()},Nt);return()=>{g=!0,window.clearInterval(M)}},[t,n==null?void 0:n.sessionId]),r.useEffect(()=>{const h=(n==null?void 0:n.sessionId)??null;if(!t||!h)return;const u=h;let g=!1;async function N(){try{const m=await A.request(`/api/observability/runtime/session/${u}/heartbeat`,{method:"POST",body:JSON.stringify({ttlMs:Ke})});g||i(m)}catch(m){g||b(Me(m))}}const M=window.setInterval(()=>{N()},wt);return()=>{g=!0,window.clearInterval(M)}},[t,n==null?void 0:n.sessionId]),!t||typeof document>"u")return null;const S=Object.entries((l==null?void 0:l.backgroundTasks.taskTypes)??{}),C=Object.entries((l==null?void 0:l.schedulers.schedulers)??{}),y=Object.entries((l==null?void 0:l.backgroundTasks.totals)??{});return lt.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:a}),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":f?"error":"active",children:f?s("settings.parallelTaskDebugStatusError"):s("settings.parallelTaskDebugStatusActive")}),e.jsx(jt,{onClick:a,"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:Le(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:Le(n==null?void 0:n.expiresAt)})]}),e.jsxs("div",{className:"parallel-task-debug-meta-card",children:[e.jsx("span",{children:s("settings.parallelTaskDebugSessionTtl")}),e.jsx("strong",{children:Tt((n==null?void 0:n.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")})]})]}),x?e.jsx("div",{className:"parallel-task-debug-empty",children:s("settings.parallelTaskDebugLoading")}):null,!x&&f?e.jsx("div",{className:"parallel-task-debug-error",children:f}):null,!x&&!f&&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:p?s("common.loading"):s("settings.parallelTaskDebugAutoRefresh")})]}),e.jsx("div",{className:"parallel-task-debug-counter-grid",children:y.map(([h,u])=>e.jsxs("div",{className:"parallel-task-debug-counter-card",children:[e.jsx("span",{children:kt(h)}),e.jsx("strong",{children:u})]},h))})]}),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:S.length})]}),S.length>0?e.jsx("div",{className:"parallel-task-debug-grid",children:S.map(([h,u])=>e.jsxs("article",{className:"parallel-task-debug-panel",children:[e.jsxs("div",{className:"parallel-task-debug-panel-header",children:[e.jsx("strong",{children:h}),e.jsx("span",{children:Ge(u.executionLane)})]}),e.jsxs("div",{className:"parallel-task-debug-panel-body",children:[e.jsxs("span",{children:[s("settings.parallelTaskDebugWaitAvg"),": ",K(u.waitMs.avg)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugRunAvg"),": ",K(u.runMs.avg)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugRunMax"),": ",K(u.runMs.max)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugStartedCount"),": ",u.counters.started??0]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugFinishedCount"),": ",u.counters.finished??0]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugFailedCount"),": ",u.counters.failed??0]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugCacheHitCount"),": ",u.counters.cache_hit??0]})]})]},h))}):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:C.length})]}),C.length>0?e.jsx("div",{className:"parallel-task-debug-grid",children:C.map(([h,u])=>e.jsxs("article",{className:"parallel-task-debug-panel",children:[e.jsxs("div",{className:"parallel-task-debug-panel-header",children:[e.jsx("strong",{children:h}),e.jsx("span",{children:u.lastIdle?s("settings.parallelTaskDebugIdle"):s("settings.parallelTaskDebugBusy")})]}),e.jsxs("div",{className:"parallel-task-debug-panel-body",children:[e.jsxs("span",{children:[s("settings.parallelTaskDebugTickTotal"),": ",u.tickTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugIdleTickTotal"),": ",u.idleTickTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugTaskCountTotal"),": ",u.taskCountTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugSchedulerErrorTotal"),": ",u.errorTotal]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugLastDuration"),": ",K(u.lastDurationMs)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugNextDelay"),": ",K(u.nextDelayMs)]})]})]},h))}):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(h=>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:h.taskType}),e.jsx("span",{children:Ct(h.eventType)}),e.jsx("span",{children:Ge(h.executionLane)})]}),e.jsxs("p",{children:[s("settings.parallelTaskDebugTaskKey"),": ",h.key]}),e.jsxs("p",{children:[s("settings.parallelTaskDebugStatus"),": ",h.status?Dt(h.status):"-"]})]}),e.jsxs("div",{className:"parallel-task-debug-activity-meta",children:[e.jsx("span",{children:Le(h.recordedAt)}),e.jsxs("span",{children:[s("settings.parallelTaskDebugAttempt"),": ",h.attempt??"-"]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugWaitMs"),": ",K(h.waitMs)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugRunMs"),": ",K(h.runMs)]}),e.jsxs("span",{children:[s("settings.parallelTaskDebugSource"),": ",h.source??"-"]}),h.errorMessage?e.jsxs("span",{children:[s("settings.parallelTaskDebugError"),": ",h.errorMessage]}):null]})]},h.eventId))}):e.jsx("div",{className:"parallel-task-debug-empty",children:s("settings.parallelTaskDebugEmpty")})]})]}):null]})]})]}),document.body)}async function Je(t){return await A.request(`/api/observability/runtime?sessionId=${encodeURIComponent(t)}`)}async function Pe(t){try{await A.request(`/api/observability/runtime/session/${t}`,{method:"DELETE"})}catch{}}function Me(t){return t instanceof Error&&t.message?t.message:s("settings.parallelTaskDebugLoadFailed")}function Le(t){if(!t)return"-";const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString()}function K(t){return t==null||Number.isNaN(t)?"-":`${Math.round(t*100)/100} ms`}function Tt(t){return t===null||Number.isNaN(t)?"-":`${Math.round(t/1e3)} s`}function kt(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 Ge(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 Dt(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 Ze(){const t=ue(),a=Q.getState(),n=await t.bridge.getAndroidRuntimeInfo();if(!n.ok||!n.value)throw new Error(n.detail??"读取 Android 运行时信息失败。");const i=await A.request(`/api/client/release-manifest?channel=${encodeURIComponent(a.releaseChannel)}&platform=android-apk`),l=i.versionCode>n.value.versionCode;return{checkedAt:new Date().toISOString(),currentVersion:n.value.version,currentVersionCode:n.value.versionCode,hasUpdate:l,manifest:i,runtimeInfo:n.value}}async function Pt(t){return ue().bridge.installAndroidUpdate(t)}function Mt(){const[t,a]=r.useState(!1),[n,i]=r.useState(!1),[l,d]=r.useState(null),[x,v]=r.useState(null),[p,w]=r.useState(null),[f,b]=r.useState(!1),[T,S]=r.useState(null),C=r.useRef(!1);r.useEffect(()=>{if(T===null){C.current=!1;return}const u=T;async function g(){if(!C.current){C.current=!0;try{const m=await Ze();if(w(m.manifest),v(m.currentVersion),b(m.hasUpdate),!m.hasUpdate||m.currentVersionCode>=u){d(s("settings.androidInstallSucceeded"));return}d(s("settings.androidInstallCancelled"))}catch(m){d(m instanceof Error?m.message:s("settings.releaseCheckFailed"))}finally{S(null)}}}function N(){g()}function M(){document.visibilityState==="visible"&&g()}return window.addEventListener("focus",N),document.addEventListener("visibilitychange",M),()=>{window.removeEventListener("focus",N),document.removeEventListener("visibilitychange",M)}},[T]);async function y(){a(!0),d(null),S(null);try{const u=await Ze();w(u.manifest),v(u.currentVersion),b(u.hasUpdate),d(u.hasUpdate?s("settings.releaseUpdateReady"):s("settings.releaseUpToDate"))}catch(u){d(u instanceof Error?u.message:s("settings.releaseCheckFailed"))}finally{a(!1)}}async function h(){if(p){i(!0),d(null),S(null);try{const u=await Pt(p);if(u.status==="installer_started"){d(s("settings.androidInstallerStarted")),S(p.versionCode);return}if(u.status==="permission_required"){d(u.detail??s("settings.androidInstallPermissionRequired")),S(null);return}if(u.status==="already_up_to_date"){d(s("settings.releaseUpToDate")),b(!1),S(null);return}d(u.detail??s("settings.releaseInstallFailed")),S(null)}catch(u){d(u instanceof Error?u.message:s("settings.releaseInstallFailed")),S(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:x??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:(p==null?void 0:p.version)??"-"})]})]}),l?e.jsx("p",{className:"settings-update-status","data-tone":f?"warning":"success",children:l}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:t||n,onClick:y,children:t?s("common.loading"):s("settings.releaseCheckNow")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!p||!f||n,onClick:h,children:n?s("common.loading"):s("settings.releaseInstallNow")})]})]})}function Lt(){const t=ue(),a=t.isDesktop,[n,i]=r.useState(!1),[l,d]=r.useState(!1),[x,v]=r.useState(!1),[p,w]=r.useState(null),[f,b]=r.useState(null),T=We(D=>D.latestState),S=We(D=>D.pendingRestartVersion),C=(T==null?void 0:T.currentVersion)??null,y=(T==null?void 0:T.manifest)??null,h=(T==null?void 0:T.hasUpdate)??!1,u=!!S,g=u&&f!==S;async function N(){if(!u){i(!0),w(null);try{const D=await rt({notify:"always"});w(Qe(D.manifest,D.hasUpdate))}catch(D){w(D instanceof Error?D.message:s("settings.releaseCheckFailed"))}finally{i(!1)}}}async function M(){if(!(!y||!h||u)){d(!0),w(null);try{const D=await ct();if(!D.ok){w(D.detail??s("settings.releaseInstallFailed"));return}ot(y.version),b(null),w(s("settings.releaseRestartRequired"))}catch(D){w(D instanceof Error?D.message:s("settings.releaseInstallFailed"))}finally{d(!1)}}}async function m(){if(y!=null&&y.htmlUrl){v(!0);try{const D=await t.bridge.openExternal(y.htmlUrl);D.ok||w(D.detail??s("settings.releasePageOpenFailed"))}catch(D){w(D instanceof Error?D.message:s("settings.releasePageOpenFailed"))}finally{v(!1)}}}const P=!!(a&&y&&h&&!u),R=p??(a?u?s("settings.releaseRestartRequired"):T?Qe(T.manifest,T.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:C??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)??S??"-"})]})]}),R?e.jsx("p",{className:"settings-update-status","data-tone":Et(y,h,R,u),children:R}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:!a||n||l||u,onClick:N,children:n?s("common.loading"):s("settings.releaseCheckNow")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!P||l,onClick:M,children:l?s("common.loading"):s("settings.releaseInstallNow")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:!(y!=null&&y.htmlUrl)||n||l||x,onClick:m,children:x?s("common.loading"):s("settings.releaseOpenPage")})]})]}),e.jsx(At,{open:g,version:S,onClose:()=>b(S)})]})}function Qe(t,a){return a?s("settings.releaseUpdateReady"):s("settings.releaseUpToDate")}function Et(t,a,n,i){return n===s("settings.clientUpdateUnsupported")?"neutral":i||a?"warning":"success"}function At({open:t,version:a,onClose:n}){const[i,l]=r.useState(!1),[d,x]=r.useState(null);async function v(){l(!0),x(null);try{await dt()}catch(p){x(p instanceof Error?p.message:s("settings.releaseRestartFailed")),l(!1)}}return e.jsx(ne,{open:t,title:s("settings.releaseRestartDialogTitle"),description:s("settings.releaseRestartDialogDescription",{version:a??"-"}),onClose:()=>{i||n()},children:e.jsxs("div",{className:"settings-update-card",children:[d?e.jsx("p",{className:"settings-update-status","data-tone":"danger",children:d}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:i,onClick:n,children:s("settings.releaseRestartLater")}),e.jsx("button",{className:"primary-button",type:"button",disabled:i,onClick:v,children:i?s("common.loading"):s("settings.releaseRestartConfirm")})]})]})})}function Ps(){const t=ue();return t.platform==="desktop"?e.jsx(Lt,{}):t.platform==="android"?e.jsx(Mt,{}):e.jsx("div",{className:"settings-update-card",children:e.jsx("p",{className:"settings-update-status","data-tone":"neutral",children:s("settings.clientUpdateUnsupported")})})}async function Xe(){return await A.request("/api/system/model-switch")}async function Rt(t){return await A.request("/api/system/model-switch",{method:"POST",body:JSON.stringify(t)})}const Ut="https://github.com/SaladDay/cc-switch-cli",It="当前机器未安装 cc-switch-cli。这里集成的是 CC-Switch 的衍生 CLI 版本,不是 CC-Switch UI 版本。请先安装:",Ot=/(https?:\/\/[^\s]+)/i;function Ms(){const t=ws(m=>{var P;return((P=m.session)==null?void 0:P.accessToken)??null}),[a,n]=r.useState(null),[i,l]=r.useState(!0),[d,x]=r.useState(null),[v,p]=r.useState(null),[w,f]=r.useState(null),[b,T]=r.useState(!1),[S,C]=r.useState("codex");r.useEffect(()=>{let m=!0;if(!t){n(null),p(null),f(null),l(!1);return}return(async()=>{l(!0);try{const R=await Xe();if(!m)return;n(R),p(null),C(D=>es(R,D))}catch(R){if(!m)return;p(Ee(R))}finally{m&&l(!1)}})(),()=>{m=!1}},[t]);async function y(){const m=await Xe();n(m),p(null),C(P=>es(m,P))}async function h(){if(t){x("refresh"),p(null),f(null);try{await y(),f(s("settings.modelManagementRefreshSuccess"))}catch(m){p(Ee(m))}finally{x(null)}}}async function u(m,P){if(!t||P.isCurrent)return;const R=Ye(m,P.id);x(R),p(null),f(null);try{const D=await Rt({app:m,presetId:P.id});pt(),n(B=>Ft(B,D)),f(s("settings.modelManagementSwitchSuccess",{app:D.displayName,preset:D.currentPresetName??P.name}))}catch(D){p(Ee(D))}finally{x(null)}}const g=(a==null?void 0:a.items)??[],N=g.find(m=>m.app===S)??g[0]??null,M=Ht(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,v?e.jsx("p",{className:"settings-release-status",children:v}):null,M?e.jsxs("section",{className:"settings-model-missing-state",children:[e.jsx("p",{className:"settings-model-missing-copy",children:M.message}),e.jsx("a",{className:"settings-tailscale-link settings-model-missing-link",href:M.url,rel:"noreferrer",target:"_blank",children:M.url})]}):g.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"settings-model-grid",children:g.map(m=>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:m.displayName}),e.jsx("span",{className:"settings-model-card-status","data-status":m.status,children:Bt(m.status)})]}),e.jsxs("div",{className:"settings-model-value-line",children:[e.jsx("strong",{className:"settings-model-preset-value",children:m.currentPresetName??s("settings.modelManagementPresetMissing")}),e.jsx("strong",{className:"settings-model-current-value",children:m.currentModel??s("settings.modelManagementModelUnknown")})]})]}),m.statusText?e.jsx("p",{className:"settings-model-card-note",children:m.statusText}):null]},m.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:()=>{T(!0)},children:s("settings.modelManagementOpenSwitcher")})})]}):e.jsx("div",{className:"settings-model-empty",children:s("settings.modelManagementOptionsEmpty")})]})}),e.jsxs(ne,{open:b&&!M,title:s("settings.modelManagementModalTitle"),description:s("settings.modelManagementModalDescription"),className:"settings-model-modal",headerActions:e.jsx("button",{className:"secondary-button",type:"button",disabled:!t||i||d!==null,onClick:()=>{h()},children:d==="refresh"?s("common.loading"):s("settings.modelManagementRefresh")}),onClose:()=>T(!1),children:[e.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":s("settings.modelManagementTabsLabel"),children:g.map(m=>{const P=(N==null?void 0:N.app)===m.app;return e.jsx("button",{type:"button",role:"tab",className:"settings-model-tab","aria-selected":P,"data-active":P?"true":"false",onClick:()=>C(m.app),children:m.displayName},m.app)})}),N?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:N.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:N.currentModel??s("settings.modelManagementModelUnknown")})]})]}),N.statusText?e.jsx("p",{className:"settings-model-modal-note",children:N.statusText}):null,N.options.length>0?e.jsx("div",{className:"settings-model-switcher-list",children:N.options.map(m=>{const P=Ye(N.app,m.id);return e.jsxs("div",{className:"settings-model-switcher-item","data-current":m.isCurrent?"true":"false",children:[e.jsxs("div",{className:"settings-model-switcher-item-main",children:[e.jsx("strong",{children:m.name}),e.jsx("span",{children:m.model??s("settings.modelManagementModelUnknown")})]}),e.jsx("div",{className:"settings-model-switcher-item-actions",children:m.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||d!==null||N.status!=="ready",onClick:()=>{u(N.app,m)},children:d===P?s("common.loading"):s("settings.modelManagementSwitchAction")})})]},`${N.app}:${m.id}`)})}):e.jsx("div",{className:"settings-model-empty",children:N.statusText??s("settings.modelManagementOptionsEmpty")})]}):e.jsx("div",{className:"settings-model-empty",children:s("settings.modelManagementOptionsEmpty")})]})]})}function Ye(t,a){return`switch:${t}:${a}`}function Ft(t,a){return t&&{...t,scannedAt:new Date().toISOString(),items:t.items.map(n=>n.app===a.app?a:n)}}function es(t,a){var i;return t.items.some(l=>l.app===a)?a:((i=t.items[0])==null?void 0:i.app)??"codex"}function Bt(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 Ee(t){return t instanceof ge?t.message||s("settings.modelManagementLoadFailed"):t instanceof Error?t.message:s("settings.modelManagementLoadFailed")}function Ht(t){var i,l,d;if(t.length===0||!t.every(x=>x.status==="unavailable"&&!x.cliAvailable&&!!x.statusText))return null;const n=((d=(((l=(i=t[0])==null?void 0:i.statusText)==null?void 0:l.trim())??"").match(Ot))==null?void 0:d[1])??Ut;return{message:It,url:n}}var Ls={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ss=se.createContext&&se.createContext(Ls),Vt=["attr","size","title"];function qt(t,a){if(t==null)return{};var n,i,l=_t(t,a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(t);for(i=0;i<d.length;i++)n=d[i],a.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(l[n]=t[n])}return l}function _t(t,a){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(a.indexOf(i)!==-1)continue;n[i]=t[i]}return n}function ye(){return ye=Object.assign?Object.assign.bind():function(t){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},ye.apply(null,arguments)}function ts(t,a){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);a&&(i=i.filter(function(l){return Object.getOwnPropertyDescriptor(t,l).enumerable})),n.push.apply(n,i)}return n}function Ne(t){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?ts(Object(n),!0).forEach(function(i){zt(t,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ts(Object(n)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))})}return t}function zt(t,a,n){return(a=$t(a))in t?Object.defineProperty(t,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[a]=n,t}function $t(t){var a=Wt(t,"string");return typeof a=="symbol"?a:a+""}function Wt(t,a){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,a);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(t)}function Es(t){return t&&t.map((a,n)=>se.createElement(a.tag,Ne({key:n},a.attr),Es(a.child)))}function me(t){return a=>se.createElement(Kt,ye({attr:Ne({},t.attr)},a),Es(t.child))}function Kt(t){var a=n=>{var{attr:i,size:l,title:d}=t,x=qt(t,Vt),v=l||n.size||"1em",p;return n.className&&(p=n.className),t.className&&(p=(p?p+" ":"")+t.className),se.createElement("svg",ye({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,i,x,{className:p,style:Ne(Ne({color:t.color||n.color},n.style),t.style),height:v,width:v,xmlns:"http://www.w3.org/2000/svg"}),d&&se.createElement("title",null,d),t.children)};return ss!==void 0?se.createElement(ss.Consumer,null,n=>a(n)):a(Ls)}function Jt(t){return me({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 Gt(t){return me({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 ns(t){return me({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 Zt(t){return me({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 Qt(t){return me({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 as(){return A.request("/api/auth/devices")}function Xt(t){return A.request("/api/auth/devices/current/primary",{method:"POST",body:JSON.stringify(t)})}function Yt(t){return A.request(`/api/auth/devices/${t}/logout`,{method:"POST"})}function As({compact:t=!1}){const a=ws(c=>{var O;return((O=c.session)==null?void 0:O.accessToken)??null}),[n,i]=r.useState(null),[l,d]=r.useState(!1),[x,v]=r.useState(!1),[p,w]=r.useState(!1),[f,b]=r.useState(null),[T,S]=r.useState(null),[C,y]=r.useState(null),[h,u]=r.useState(null),[g,N]=r.useState(null),[M,m]=r.useState(""),[P,R]=r.useState(null);r.useEffect(()=>{let c=!0;if(!x){d(!1);return}if(!a){i(null),d(!1),y(null),u(null);return}return(async()=>{d(!0);try{const j=await as();if(!c)return;i(j),u(null)}catch(j){if(!c)return;u(Ae(j))}finally{c&&d(!1)}})(),()=>{c=!1}},[a,x]);async function D(){const c=await as();i(c),u(null)}function B(){v(!0),w(!1),y(null),u(null)}function $(){f!=="primary"&&(v(!1),w(!1),N(null),m(""),R(null))}function F(c){N(c),m(""),R(null)}async function H(){if(g){b("primary"),R(null),u(null),y(null);try{await Xt({password:M,primary:g==="enable"}),await D(),y(g==="enable"?s("settings.authDevicePrimaryEnabled"):s("settings.authDevicePrimaryDisabled")),N(null),m("")}catch(c){const O=Ae(c);R(O),u(O)}finally{b(null)}}}async function W(c){if(c.deviceId){S(c.deviceId),u(null),y(null);try{const O=await Yt(c.deviceId);await D(),y(s("settings.authDeviceLogoutDeviceSuccess",{device:fe(c),count:String(O.revokedSessionCount)}))}catch(O){u(Ae(O))}finally{S(null)}}}const U=(n==null?void 0:n.currentDevice)??null,J=(n==null?void 0:n.otherActiveDevices.filter(c=>!c.isLegacy))??[],G=(n==null?void 0:n.otherActiveDevices.filter(c=>c.isLegacy))??[],I=(n==null?void 0:n.recentLoginRecords.filter(c=>!c.isLegacy))??[],V=(n==null?void 0:n.recentLoginRecords.filter(c=>c.isLegacy))??[],k=G.length+V.length,L=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:!a,onClick:B,children:s("settings.authDeviceOpenManager")})})}),e.jsx(ne,{open:x,title:s("settings.authDeviceManagement"),description:s("settings.authDeviceManagementDescription"),className:"settings-device-browser-modal",onClose:$,children:e.jsxs(e.Fragment,{children:[C?e.jsx("p",{className:"settings-release-status",children:C}):null,h?e.jsx("p",{className:"settings-release-status",children:h}):null,l?e.jsx("div",{className:"settings-device-empty",children:s("common.loading")}):e.jsxs(e.Fragment,{children:[k>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(k)})}),e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>w(c=>!c),children:p?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(re,{current:!0,title:fe(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:!L||f!==null,onClick:()=>F(U.isPrimary?"disable":"enable"),children:U.isPrimary?s("settings.authDeviceDisablePrimary"):s("settings.authDeviceEnablePrimary")})}),note:L?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((c,O)=>e.jsx(re,{title:fe(c),clientType:c.clientType,browserName:c.browserName,browserVersion:c.browserVersion,osName:c.osName,osVersion:c.osVersion,timeLabelKey:"settings.authDeviceLastSeen",timestamp:c.lastSeenAt,sourceAddress:c.lastSourceAddress,badges:e.jsxs(e.Fragment,{children:[c.isPrimary?e.jsx("span",{className:"settings-device-tag","data-tone":"primary",children:s("settings.authDevicePrimaryTag")}):null,c.isLegacy?e.jsx("span",{className:"settings-device-tag","data-tone":"legacy",children:s("settings.authDeviceLegacyTag")}):null]}),actions:c.deviceId?e.jsx("button",{className:"settings-button settings-button-danger","data-variant":"device-danger",type:"button",disabled:!E||f!==null||T!==null,onClick:()=>{W(c)},children:T===c.deviceId?s("common.loading"):s("settings.authDeviceLogoutDevice")}):null},`${c.deviceId??"legacy"}-${c.lastSeenAt}-${O}`))}):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")})}),I.length>0?e.jsx("div",{className:"settings-device-list",children:I.map(c=>e.jsx(re,{title:is(c),clientType:c.clientType,browserName:c.browserName,browserVersion:c.browserVersion,osName:c.osName,osVersion:c.osVersion,timeLabelKey:"settings.authDeviceLoginAt",timestamp:c.occurredAt,sourceAddress:c.sourceAddress,badges:c.isCurrentDevice?e.jsx("span",{className:"settings-device-tag","data-tone":"current",children:s("settings.authDeviceCurrentTag")}):null},c.id))}):e.jsx("div",{className:"settings-device-empty",children:s("settings.authDeviceRecentEmpty")})]}),p&&G.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:G.map((c,O)=>e.jsx(re,{title:fe(c),clientType:c.clientType,browserName:c.browserName,browserVersion:c.browserVersion,osName:c.osName,osVersion:c.osVersion,timeLabelKey:"settings.authDeviceLastSeen",timestamp:c.lastSeenAt,sourceAddress:c.lastSourceAddress,badges:e.jsx("span",{className:"settings-device-tag","data-tone":"legacy",children:s("settings.authDeviceLegacyTag")})},`legacy-device-${c.lastSeenAt}-${O}`))})]}):null,p&&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(c=>e.jsx(re,{title:is(c),clientType:c.clientType,browserName:c.browserName,browserVersion:c.browserVersion,osName:c.osName,osVersion:c.osVersion,timeLabelKey:"settings.authDeviceLoginAt",timestamp:c.occurredAt,sourceAddress:c.sourceAddress,badges:e.jsx("span",{className:"settings-device-tag","data-tone":"legacy",children:s("settings.authDeviceLegacyTag")})},c.id))})]}):null]})]})}),e.jsx(ne,{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:()=>{f!=="primary"&&(N(null),m(""),R(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:M,onChange:c=>m(c.target.value)})]}),P?e.jsx("p",{className:"settings-release-status",children:P}):null,e.jsxs("div",{className:"settings-device-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:f==="primary",onClick:()=>{N(null),m(""),R(null)},children:s("common.cancel")}),e.jsx("button",{className:"settings-button",type:"button",disabled:M.trim().length===0||f==="primary",onClick:()=>{H()},children:f==="primary"?s("common.loading"):g==="enable"?s("settings.authDeviceEnablePrimary"):s("settings.authDeviceDisablePrimary")})]})]})})]})}function fe(t){var a;return t.isLegacy?s("settings.authDeviceLegacyLabel"):((a=t.displayName)==null?void 0:a.trim())||Rs(t.clientType)}function is(t){var a;return t.isLegacy?s("settings.authDeviceLegacyLabel"):((a=t.displayName)==null?void 0:a.trim())||Rs(t.clientType)}function en(t){return e.jsxs("div",{className:"settings-device-identity",children:[e.jsx("span",{className:"settings-device-identity-icon","aria-hidden":"true",children:e.jsx(cn,{kind:rn(t.clientType)})}),e.jsx("div",{className:"settings-device-identity-body",children:e.jsx("strong",{children:t.title})})]})}function re(t){const a=ln(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(en,{title:t.title,clientType:t.clientType}),e.jsx("div",{className:"settings-device-meta",children:a.map(n=>e.jsx("span",{children:n},n))}),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 Rs(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 sn(t,a){return s(t,{value:new Date(a).toLocaleString()})}function tn(t){return t?s("settings.authDeviceSourceAddressValue",{value:t}):s("settings.authDeviceSourceAddressUnknown")}function nn(t,a){return t?s("settings.authDeviceBrowserValue",{value:Us(t,a)}):null}function an(t,a){return t?s("settings.authDeviceOsValue",{value:Us(t,a)}):null}function ln(t,a,n,i,l,d,x){return[nn(t,a),an(n,i),sn(l,d),tn(x)].filter(v=>!!v)}function rn(t){switch(t){case"desktop":return"desktop";case"web":return"web";case"ios":return"ios";case"android":return"android";default:return"unknown"}}function Us(t,a){return a!=null&&a.trim()?`${t} ${a}`:t}function cn({kind:t}){const a=on(t),n=a.icon;return e.jsx(n,{color:a.color})}function on(t){switch(t){case"desktop":return{icon:Jt,color:"#2563eb"};case"web":return{icon:Gt,color:"#0f766e"};case"ios":return{icon:Zt,color:"#111827"};case"android":return{icon:Qt,color:"#3ddc84"};case"unknown":return{icon:ns,color:"#64748b"};default:return{icon:ns,color:"#64748b"}}}function Ae(t){return t instanceof ge||t instanceof Error?t.message:s("settings.authDeviceLoadFailed")}async function ls(){const t=Q.getState();return A.request(`/api/client/service-update?channel=${encodeURIComponent(t.releaseChannel)}`)}async function dn(t){const a=Q.getState();return A.request("/api/client/service-update/install",{method:"POST",body:JSON.stringify({packageName:t,channel:a.releaseChannel})})}async function un(t){return A.request(`/api/client/service-update/tasks/${encodeURIComponent(t)}`)}const gn=1500;function Is(){const t=ue(),[a,n]=r.useState(!1),[i,l]=r.useState(!1),[d,x]=r.useState(null),[v,p]=r.useState(null),[w,f]=r.useState(null),b=(v==null?void 0:v.packages[0])??null;r.useEffect(()=>{if(!w||!Re(w.status))return;let y=!1;const h=window.setTimeout(async()=>{var u;try{const g=await un(w.taskId);if(y)return;if(f(g),x(Fe(g)),!Re(g.status)){l(!1);const N=await ls();if(y)return;p(N),f(((u=N.packages[0])==null?void 0:u.installTask)??g),x(rs(N.packages[0]??null,g)),g.restartRequired&&await t.bridge.showNotification(s("settings.serverRestartRequired"),g.targetVersion??"-")}}catch(g){if(y)return;l(!1),x(g instanceof Error?g.message:s("settings.serverInstallFailed"))}},gn);return()=>{y=!0,window.clearTimeout(h)}},[t.bridge,w]);async function T(){n(!0),x(null);try{const y=await ls(),h=y.packages[0]??null;p(y),f((h==null?void 0:h.installTask)??null),x(rs(h,(h==null?void 0:h.installTask)??null)),h!=null&&h.hasUpdate&&await t.bridge.showNotification(s("settings.serverUpdateReady"),`${s("settings.serverTargetVersion")}: ${h.latestVersion??"-"}`)}catch(y){x(y instanceof Error?y.message:s("settings.serverCheckFailed"))}finally{n(!1)}}async function S(){if(b!=null&&b.packageName){l(!0),x(null);try{const y=await dn(b.packageName);f(y),x(Fe(y))}catch(y){l(!1),x(y instanceof Error?y.message:s("settings.serverInstallFailed"))}}}const C=!!(b&&b.checkStatus!=="check_failed"&&b.hasUpdate&&!b.restartRequired&&!Re(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:(b==null?void 0:b.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:(b==null?void 0:b.latestVersion)??"-"})]})]}),d?e.jsx("p",{className:"settings-update-status","data-tone":mn(b,w),children:d}):null,e.jsxs("div",{className:"settings-update-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",disabled:a||i,onClick:T,children:a?s("common.loading"):s("settings.serverCheckNow")}),e.jsx("button",{className:"primary-button",type:"button",disabled:!C||a||i,onClick:S,children:i?s("common.loading"):s("settings.serverInstallNow")})]})]})}function rs(t,a){return a?Fe(a):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 Fe(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 mn(t,a){if(a)switch(a.status){case"queued":case"running":return"warning";case"succeeded":return a.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 Re(t){return t==="queued"||t==="running"}const Os=Be("https://channel.codingns.com:10247");function xe(){return Os}function hn(){return!1}function pn(t){if(!(t!=null&&t.trim()))return null;try{return Be(t)}catch{return null}}function Ue(t){return Os}async function bn(){return await A.request("/api/system/relay-tunnel/status")}async function cs(t){return await A.request("/api/system/relay-tunnel/config",{method:"PUT",body:JSON.stringify(t)})}async function fn(t){return await A.request("/api/system/relay-tunnel/control/login",{method:"POST",body:JSON.stringify(t)})}async function xn(){return await A.request("/api/system/relay-tunnel/control/logout",{method:"POST"})}async function vn(t){const a=t.hostLabel.trim(),n=`/api/system/relay-tunnel/control/host-label-availability?hostLabel=${encodeURIComponent(a)}`;return await A.request(n)}async function jn(t){return await A.request("/api/system/relay-tunnel/control/bind",{method:"POST",body:JSON.stringify(t)})}async function yn(){return await A.request("/api/system/relay-tunnel/control/wallet")}async function os(){return await A.request("/api/system/relay-tunnel/enable",{method:"POST"})}async function Nn(){return await A.request("/api/system/relay-tunnel/disable",{method:"POST"})}async function wn(){return await A.request("/api/system/relay-tunnel/unbind",{method:"POST"})}function Sn(){const t=Ve(),{showToast:a}=ut(),[n,i]=r.useState(null),[l,d]=r.useState(""),[x,v]=r.useState(()=>xe()),[p,w]=r.useState(""),[f,b]=r.useState(""),[T,S]=r.useState(null),[C,y]=r.useState({status:"idle"}),[h,u]=r.useState(!0),[g,N]=r.useState(null),[M,m]=r.useState(null),[P,R]=r.useState(null),[D,B]=r.useState(null),[$,F]=r.useState(null),H=r.useRef(!0),W=hn(),U=Ue(n==null?void 0:n.controlBaseUrl);pn(x);const J=xe(),G=Ue(),I=l.trim(),V=(n==null?void 0:n.activated)??!1,k=p.trim().length>0&&f.trim().length>0,L=!!(n!=null&&n.controlAccountEmail),E=n!=null&&n.bindingId?!0:C.status==="available"&&C.hostLabel===I,c=!!(n!=null&&n.bindingId)||L&&I.length>0&&E,O=gs({controlBaseUrl:G,tunnelDomain:n==null?void 0:n.tunnelDomain,hostLabel:l}),j=!!(n!=null&&n.controlAccountEmail||n!=null&&n.bindingId),_=!!(n!=null&&n.bindingId||E),he=!!(n!=null&&n.enabled&&(n!=null&&n.bindingId)),qs=!!(n!=null&&n.bindingId)||c,_s=T?ce(T.grantedBytes):s("settings.tailscaleUnavailable"),zs=ce(T?T.usedBytes:n==null?void 0:n.trafficUsedBytes),$s=ce(T?T.remainingBytes:n==null?void 0:n.trafficRemainingBytes),qe=He(Q.getState()),X=bt(),ae=X?s(ft(X.kind)):null,pe=X?kn(X):null;r.useEffect(()=>(H.current=!0,we(!1),()=>{H.current=!1}),[]),r.useEffect(()=>{if(!V)return;const o=window.setInterval(()=>{we(!0)},5e3);return()=>{window.clearInterval(o)}},[V]),r.useEffect(()=>{!V||!L||be()},[V,L]),r.useEffect(()=>{n!=null&&n.bindingId||C.status!=="idle"&&C.hostLabel!==I&&y({status:"idle"})},[C,I,n==null?void 0:n.bindingId]),r.useEffect(()=>{{v(xe());return}},[W,U]);async function we(o){o||u(!0);try{const z=await bn();if(!H.current)return;Z(z),m(null)}catch(z){H.current&&m(us(z,"status",qe))}finally{H.current&&!o&&u(!1)}}function Z(o){i(o),F(null),o.controlAccountEmail||S(null),o.tunnelDomain&&l.trim().length===0&&d(Fs(o.tunnelDomain)),et(o)}async function be(){try{const o=await yn();if(!H.current)return;S(o.wallet)}catch(o){H.current&&F(ee(o))}}async function Ws(){if(k){N("login-control"),F(null);try{const o=await fn({email:p.trim(),password:f});B(null),Z(o),await be()}catch(o){B(us(o,"login",qe))}finally{N(null)}}}async function Ks(){N("logout-control"),F(null);try{const o=await xn();Z(o),S(null),y({status:"idle"})}catch(o){F(ee(o))}finally{N(null)}}async function _e(){if(!I)throw new Error(s("settings.relayTunnelHostLabelRequired"));if(C.status==="available"&&C.hostLabel===I)return{hostLabel:C.hostLabel,tunnelDomain:C.tunnelDomain,available:!0,reason:"available"};y({status:"checking",hostLabel:I});const o=await vn({hostLabel:I});if(!o.available||!o.tunnelDomain){const z=Cn(o);throw y({status:"error",hostLabel:I,message:z}),new Error(z)}return y({status:"available",hostLabel:I,tunnelDomain:o.tunnelDomain}),o}async function Js(){if(!(!j||n!=null&&n.bindingId)){N("check-host-label"),F(null);try{await _e()}catch{}finally{N(null)}}}async function Gs(){N("learn-service"),F(null);try{await hs(t.bridge.openExternal,xe())}catch(o){F(ee(o))}finally{N(null)}}async function Zs(){if(O)try{await Pn(O,t),a({title:s("settings.relayTunnelAccessUrlCopied"),tone:"success"})}catch(o){a({title:o instanceof Error?o.message:s("settings.relayTunnelCopyAccessUrlFailed"),tone:"error"})}}async function Qs(){if(O)try{await hs(t.bridge.openExternal,O)}catch(o){a({title:o instanceof Error?o.message:s("settings.relayTunnelOpenAccessUrlFailed"),tone:"error"})}}async function Xs(){if(c){N("enable"),F(null);try{let o=n;if(o!=null&&o.activated||(o=await cs({activated:!0,controlBaseUrl:J}),Z(o)),o!=null&&o.bindingId||(await _e(),o=await jn({hostLabel:I}),Z(o),await be()),!(o!=null&&o.enabled)){const z=await os();Z(z)}}catch(o){F(ee(o))}finally{N(null)}}}async function Ys(){if(n!=null&&n.bindingId){N("reconnect"),F(null);try{if(n!=null&&n.enabled){const z=await Nn();Z(z)}const o=await os();Z(o),n!=null&&n.controlAccountEmail&&await be()}catch(o){F(ee(o))}finally{N(null)}}}async function ze(){N("disconnect-device"),F(null);try{if(n!=null&&n.bindingId||n!=null&&n.accountId){const o=await wn();Z(o)}if(n!=null&&n.activated){const o=await cs({activated:!1});Z(o)}S(null),w(""),d(""),b(""),y({status:"idle"})}catch(o){F(ee(o))}finally{N(null)}}return e.jsxs("div",{className:"settings-relay-tunnel-panel",children:[null,h&&!n?e.jsx(de,{heading:s("settings.relayTunnelWizardTitle"),description:s("settings.relayTunnelWizardDescription"),children:e.jsx("p",{className:"settings-remote-access-panel-note",children:s("common.loading")})}):null,!h&&!he?e.jsxs(de,{heading:s("settings.relayTunnelWizardTitle"),description:s("settings.relayTunnelWizardDescription"),actions:e.jsx("button",{className:"secondary-button",disabled:g!==null,type:"button",onClick:()=>void Gs(),children:s("settings.relayTunnelLearnService")}),children:[M?e.jsx(ds,{title:s("settings.relayTunnelStatusErrorTitle"),message:M,action:e.jsx("button",{className:"secondary-button",disabled:h||g!==null,type:"button",onClick:()=>void we(!1),children:s("common.retry")})}):null,e.jsxs("div",{className:"settings-relay-tunnel-step-list",children:[e.jsxs("section",{className:"settings-relay-tunnel-step","data-state":Ie(j,!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(De,{className:"settings-relay-tunnel-step-tag",children:s(Oe(j,!0))})]}),e.jsx("div",{className:"settings-relay-tunnel-step-body",children:j?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(te,{align:"start",children:e.jsx("button",{className:"secondary-button",disabled:g!==null,type:"button",onClick:()=>{if(n!=null&&n.bindingId){ze();return}Ks()},children:s("common.logout")})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-relay-tunnel-form",children:[e.jsx(je,{label:s("settings.relayTunnelAccountEmail"),children:e.jsx("input",{"aria-label":s("settings.relayTunnelAccountEmail"),className:"settings-text-input",type:"email",value:p,onChange:o=>{w(o.target.value),B(null)},placeholder:s("settings.relayTunnelAccountEmailPlaceholder")})}),e.jsx(je,{label:s("settings.relayTunnelAccountPassword"),children:e.jsx("input",{"aria-label":s("settings.relayTunnelAccountPassword"),className:"settings-text-input",type:"password",value:f,onChange:o=>{b(o.target.value),B(null)},placeholder:s("settings.relayTunnelAccountPasswordPlaceholder")})}),D?e.jsx(ds,{title:s("settings.relayTunnelLoginErrorTitle"),message:D}):null]}),e.jsx(te,{align:"start",children:e.jsx("button",{className:"settings-button",disabled:g!==null||!k,type:"button",onClick:()=>void Ws(),children:g==="login-control"?s("common.loading"):s("settings.relayTunnelLoginAccount")})})]})})]}),e.jsxs("section",{className:"settings-relay-tunnel-step","data-state":Ie(_,j),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(De,{className:"settings-relay-tunnel-step-tag",children:s(Oe(_,j))})]}),e.jsx("div",{className:"settings-relay-tunnel-step-body",children:j?n!=null&&n.bindingId?e.jsx("p",{className:"settings-relay-tunnel-success",children:s("settings.relayTunnelHostLabelAvailable",{domain:O??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:l,onChange:o=>d(o.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:g!==null||I.length===0,type:"button",onClick:()=>void Js(),children:g==="check-host-label"?s("common.loading"):s("settings.relayTunnelHostLabelCheck")})]}),e.jsxs("div",{className:"settings-relay-tunnel-inline-stack",children:[C.status==="available"&&C.hostLabel===I?e.jsx("p",{className:"settings-relay-tunnel-success",children:s("settings.relayTunnelHostLabelAvailable",{domain:gs({controlBaseUrl:J,tunnelDomain:C.tunnelDomain,hostLabel:C.hostLabel})??C.tunnelDomain})}):null,C.status==="checking"&&C.hostLabel===I?e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:s("settings.relayTunnelHostLabelChecking")}):null,C.status==="error"&&C.hostLabel===I?e.jsx("p",{className:"settings-relay-tunnel-error",children:C.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":Ie(he,_),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(De,{className:"settings-relay-tunnel-step-tag",children:s(Oe(he,_))})]}),e.jsx("div",{className:"settings-relay-tunnel-step-body",children:_?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:V?s("settings.relayTunnelStepStartReady"):s("settings.relayTunnelActivationHint")}),e.jsx(te,{align:"start",children:e.jsx("button",{className:"settings-button",disabled:g!==null||!qs,type:"button",onClick:()=>void Xs(),children:g==="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:[X&&ae&&pe?e.jsx(Tn,{hint:pe,label:ae,url:X.url}):null,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,$?e.jsx("p",{className:"settings-relay-tunnel-error",children:$}):null]})]}):null,!h&&he?e.jsxs(de,{heading:s("settings.relayTunnelReadyTitle"),description:s("settings.relayTunnelReadyDescription"),children:[e.jsxs(Ds,{compact:!0,children:[X&&ae?e.jsxs(e.Fragment,{children:[e.jsx(Y,{label:s("settings.relayTunnelClientRouteLabel"),value:ae}),e.jsx(Y,{label:s("settings.relayTunnelClientRouteAddressLabel"),value:X.url})]}):null,e.jsx(Y,{className:"settings-relay-tunnel-summary-line-access-url",label:s("settings.relayTunnelAccessUrlLabel"),trailing:O?e.jsxs("div",{className:"settings-relay-tunnel-access-url",children:[e.jsx("span",{className:"settings-relay-tunnel-access-url-text",title:O,children:O}),e.jsxs("span",{className:"settings-relay-tunnel-access-url-actions",children:[e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Zs(),children:s("settings.relayTunnelCopyAccessUrl")}),e.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Qs(),children:s("settings.relayTunnelOpenAccessUrl")})]})]}):e.jsx("span",{className:"settings-relay-tunnel-summary-value",children:s("settings.relayTunnelUnbound")})}),e.jsx(Y,{label:s("settings.relayTunnelTrafficGranted"),value:_s}),e.jsx(Y,{label:s("settings.relayTunnelTrafficUsed"),value:zs}),e.jsx(Y,{label:s("settings.relayTunnelTrafficRemaining"),value:$s})]}),e.jsxs(te,{align:"start",className:"settings-relay-tunnel-ready-actions",children:[e.jsx("button",{className:"secondary-button",disabled:g!==null||!(n!=null&&n.bindingId),type:"button",onClick:()=>void Ys(),children:g==="reconnect"?s("common.loading"):s("settings.relayTunnelReconnectAction")}),e.jsx("button",{className:"settings-button settings-button-danger",disabled:g!==null,type:"button",onClick:()=>void ze(),children:g==="disconnect-device"?s("common.loading"):s("settings.relayTunnelDisconnectDeviceAction")})]}),e.jsxs("div",{className:"settings-relay-tunnel-inline-stack",children:[X&&ae&&pe?e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:pe}):null,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,$?e.jsx("p",{className:"settings-relay-tunnel-error",children:$}):null]})]}):null]});function et(o){const z=Q.getState(),Se=tt(z);if(!Se)return;const $e=st(o);Mn(Se.relayTunnel??null,$e)||Q.update({hosts:z.hosts.map(Te=>Te.id===Se.id?{...Te,relayTunnel:$e,updatedAt:new Date().toISOString()}:Te)})}function st(o){return!(o!=null&&o.bindingId)||!o.tunnelDomain?null:{provider:"codingns_relay",enabled:o.enabled,tunnelDomain:o.tunnelDomain.trim().toLowerCase(),controlBaseUrl:Ue(o.controlBaseUrl),bindingId:o.bindingId,hostFingerprint:o.hostFingerprint,candidateEndpoints:o.candidateEndpoints}}}function Tn({label:t,url:a,hint:n}){return e.jsxs(e.Fragment,{children:[e.jsxs(Ds,{compact:!0,children:[e.jsx(Y,{label:s("settings.relayTunnelClientRouteLabel"),value:t}),e.jsx(Y,{label:s("settings.relayTunnelClientRouteAddressLabel"),value:a})]}),e.jsx("p",{className:"settings-relay-tunnel-inline-note",children:n})]})}function Y({label:t,value:a,trailing:n,className:i}){return e.jsx(xt,{className:i,label:t,trailing:n??e.jsx("span",{className:"settings-relay-tunnel-summary-value",children:a})})}function kn(t){if(t.probeInProgress)return s("settings.relayTunnelClientRouteHintRelayProbing");switch(t.kind){case"relay":return s("settings.relayTunnelClientRouteHintRelay");case"lan":return s("settings.relayTunnelClientRouteHintLan");case"loopback":return s("settings.relayTunnelClientRouteHintLoopback");case"tailscale":return s("settings.relayTunnelClientRouteHintTailscale");default:return s("settings.relayTunnelClientRouteHintDirect")}}function ds({title:t,message:a,action:n}){return e.jsxs("div",{className:"settings-relay-tunnel-feedback-banner",role:"alert",children:[e.jsxs("div",{className:"settings-relay-tunnel-feedback-copy",children:[e.jsx("strong",{children:t}),e.jsx("span",{children:a})]}),n?e.jsx("div",{className:"settings-relay-tunnel-feedback-action",children:n}):null]})}function Ie(t,a){return t?"done":a?"current":"pending"}function Oe(t,a){return t?"settings.relayTunnelStepDone":a?"settings.relayTunnelStepCurrent":"settings.relayTunnelStepPending"}function Cn(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 ee(t){return t instanceof ge||t instanceof Error?t.message:s("settings.relayTunnelLoadFailed")}function us(t,a,n){if(t instanceof ge&&t.errorCode==="NETWORK_ERROR"){const i=(n==null?void 0:n.trim())||s("common.unknown");return a==="login"?s("settings.relayTunnelLoginNetworkError",{address:i}):a==="config"?s("settings.relayTunnelConfigNetworkError",{address:i}):s("settings.relayTunnelStatusNetworkError",{address:i})}return ee(t)}function ce(t){if(!t)return s("settings.tailscaleUnavailable");const a=Number(t);return!Number.isFinite(a)||a<1024?`${t} B`:a<1024**2?`${(a/1024).toFixed(1)} KB`:a<1024**3?`${(a/1024**2).toFixed(1)} MB`:`${(a/1024**3).toFixed(2)} GB`}function Fs(t){return t?t.split(".")[0]||s("common.unknown"):s("common.unknown")}function gs(t){var i,l,d,x;const a=ms(t.hostLabel)??ms(Fs(t.tunnelDomain));if(!a)return((i=t.tunnelDomain)==null?void 0:i.trim())??null;const n=(l=t.controlBaseUrl)==null?void 0:l.trim();if(!n)return((d=t.tunnelDomain)==null?void 0:d.trim())??null;try{const v=new URL(n);return v.hostname=`${a}.${v.hostname}`,v.pathname="/",v.search="",v.hash="",v.origin}catch{return((x=t.tunnelDomain)==null?void 0:x.trim())??null}}function ms(t){const a=(t==null?void 0:t.trim().toLowerCase())??"";return!a||a===s("common.unknown").toLowerCase()?null:a}async function hs(t,a){!(await t(a)).ok&&typeof window<"u"&&window.open(a,"_blank","noopener,noreferrer")}function Dn(t){var i;if(typeof document>"u")return!1;const a=(i=document.execCommand)==null?void 0:i.bind(document);if(typeof a!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.opacity="0",document.body.append(n),n.select();try{return a("copy")}catch{return!1}finally{n.remove()}}async function Pn(t,a){var n;if(a.bridge.supported)try{if((await a.bridge.writeClipboardText(t)).ok)return}catch{}if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Dn(t))throw new Error(s("settings.relayTunnelCopyAccessUrlFailed"))}function Mn(t,a){return t===a?!0:!t||!a?!1:t.provider===a.provider&&t.enabled===a.enabled&&t.tunnelDomain===a.tunnelDomain&&t.controlBaseUrl===a.controlBaseUrl&&(t.bindingId??null)===(a.bindingId??null)&&(t.hostFingerprint??null)===(a.hostFingerprint??null)&&JSON.stringify(t.candidateEndpoints??[])===JSON.stringify(a.candidateEndpoints??[])}async function ps(){return await A.request("/api/system/tailscale/status")}async function bs(t){return await A.request("/api/system/tailscale/config",{method:"PUT",body:JSON.stringify(t)})}async function Ln(){return await A.request("/api/system/tailscale/enable",{method:"POST"})}async function En(){return await A.request("/api/system/tailscale/disable",{method:"POST"})}async function An(){return await A.request("/api/system/tailscale/login",{method:"POST"})}async function Rn(){return await A.request("/api/system/tailscale/logout",{method:"POST"})}function Un({children:t}){return e.jsx("div",{className:"settings-remote-access-metrics",children:t})}function ve({label:t,value:a}){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:a})]})}function In({checked:t,label:a,disabled:n,onChange:i}){return e.jsxs("div",{className:"settings-remote-access-switch",children:[e.jsx("span",{className:"settings-remote-access-switch-label",children:a}),e.jsxs("label",{className:"settings-mobile-switch","data-disabled":n?"true":void 0,onClick:l=>{if(n){l.preventDefault();return}l.target instanceof HTMLInputElement||(l.preventDefault(),i(!t))},children:[e.jsx("input",{type:"checkbox","aria-label":a,checked:t,disabled:n,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 On({configMode:t="modal"}){const a=Ve(),[n,i]=r.useState(null),[l,d]=r.useState(""),[x,v]=r.useState(""),[p,w]=r.useState(!0),[f,b]=r.useState(null),[T,S]=r.useState(null),[C,y]=r.useState(!1),[h,u]=r.useState(!1),g=r.useRef(!0),N=r.useRef(!1),M=r.useRef(async()=>{}),m=t==="inline",P=(n==null?void 0:n.activated)??!1;N.current=h;function R(k){if(i(k),d(k.controlServerUrl??""),v(k.hostname??""),S(null),!k.activated){u(!1),y(!1);return}N.current&&!vs(k.lastError)&&u(!1)}M.current=async k=>{k||w(!0);try{const L=await ps();if(!g.current)return;R(L)}catch(L){if(!g.current)return;S(oe(L))}finally{g.current&&!k&&w(!1)}},r.useEffect(()=>(g.current=!0,M.current(!1),()=>{g.current=!1}),[]),r.useEffect(()=>{if(!P)return;const k=window.setInterval(()=>{M.current(!0)},5e3);return()=>{window.clearInterval(k)}},[P]),r.useEffect(()=>{if(!h||!P)return;function k(){M.current(!0)}function L(){document.visibilityState==="visible"&&M.current(!0)}return window.addEventListener("focus",k),document.addEventListener("visibilitychange",L),()=>{window.removeEventListener("focus",k),document.removeEventListener("visibilitychange",L)}},[P,h]);const D=((n==null?void 0:n.controlServerUrl)??"")!==l.trim()||((n==null?void 0:n.hostname)??"")!==x.trim(),B=P&&vs(n==null?void 0:n.lastError),$=P&&Hn(a.ui.osFamily)&&B;async function F(){const k=await bs({controlServerUrl:xs(l),hostname:xs(x)});return R(k),k}async function H(k){b("toggle-activation"),S(null);try{const L=await bs({activated:k});R(L)}catch(L){S(oe(L))}finally{b(null),w(!1)}}async function W(k){b(k),S(null);try{D&&k!=="disable"&&k!=="logout"&&await F();const L=k==="enable"?await Ln():k==="disable"?await En():k==="login"?await An():await Rn();R(L)}catch(L){S(oe(L))}finally{b(null)}}async function U(){b("save"),S(null);try{await F(),y(!1)}catch(k){S(oe(k))}finally{b(null)}}async function J(){b("refresh"),S(null);try{const k=await ps();R(k)}catch(k){S(oe(k))}finally{b(null),w(!1)}}async function G(){const k=Vn(a.ui.osFamily);if(k){b("install"),S(null);try{const L=await a.bridge.openExternal(k);if(!L.ok){S(L.detail??s("settings.tailscaleInstallOpenFailed"));return}u(!0)}catch(L){S(L instanceof Error?L.message:s("settings.tailscaleInstallOpenFailed"))}finally{b(null)}}}function I(){f!=="save"&&y(!1)}const V=P?e.jsxs("span",{className:"settings-tailscale-status-indicator","data-tone":qn((n==null?void 0:n.phase)??"disabled"),children:[e.jsx("span",{className:"settings-tailscale-status-dot","aria-hidden":"true"}),Bn((n==null?void 0:n.phase)??"disabled")]}):s("settings.remoteAccessFeatureDisabledValue");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-tailscale-panel",children:[e.jsx(de,{heading:s("settings.tailscaleSectionTitle"),description:s("settings.tailscaleSectionDescription"),actions:e.jsx(In,{checked:P,label:s("settings.tailscaleMasterSwitchLabel"),disabled:f!==null,onChange:k=>{H(k)}}),children:p&&!n?e.jsx("p",{className:"settings-remote-access-panel-note",children:s("common.loading")}):e.jsxs(e.Fragment,{children:[e.jsxs(Un,{children:[e.jsx(ve,{label:s("settings.tailscaleStatusIndicator"),value:V}),e.jsx(ve,{label:s("settings.tailscaleServerAddress"),value:P?(n==null?void 0:n.reachableBaseUrl)??s("settings.tailscaleUnavailable"):s("settings.tailscaleUnavailable")}),e.jsx(ve,{label:s("settings.tailscaleAccountName"),value:P?(n==null?void 0:n.accountName)??s("settings.tailscaleUnavailable"):s("settings.tailscaleUnavailable")}),e.jsx(ve,{label:s("settings.tailscaleIpAddress"),value:P?Fn(n):s("settings.tailscaleUnavailable")})]}),P?null:e.jsx("p",{className:"settings-remote-access-panel-note",children:s("settings.tailscaleActivationHint")}),P&&(n==null?void 0:n.phase)==="needs_login"&&n.loginUrl?e.jsx("p",{className:"settings-tailscale-login-url",children:e.jsx("a",{className:"settings-tailscale-link",href:n.loginUrl,rel:"noreferrer",target:"_blank",children:n.loginUrl})}):null,T||n!=null&&n.lastError?e.jsx("p",{className:"settings-relay-tunnel-error",children:T??(n==null?void 0:n.lastError)}):null,P?e.jsxs(te,{align:"start",children:[$?e.jsx("button",{className:"settings-button",type:"button",disabled:p||f!==null,onClick:()=>{G()},children:f==="install"?s("common.loading"):s("settings.tailscaleInstallAction")}):null,m?null:e.jsx("button",{className:"secondary-button",type:"button",disabled:p||f!==null,onClick:()=>y(!0),children:s("settings.tailscaleConfigure")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:p||f!==null,onClick:()=>{J()},children:f==="refresh"?s("common.loading"):s("settings.tailscaleRefresh")}),n!=null&&n.enabled?e.jsx("button",{className:"secondary-button",type:"button",disabled:p||f!==null||B,onClick:()=>{W("disable")},children:f==="disable"?s("common.loading"):s("settings.tailscaleDisable")}):e.jsx("button",{className:"secondary-button",type:"button",disabled:p||f!==null||B,onClick:()=>{W("enable")},children:f==="enable"?s("common.loading"):s("settings.tailscaleEnable")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:p||f!==null||!(n!=null&&n.enabled)||B,onClick:()=>{W("login")},children:f==="login"?s("common.loading"):s("settings.tailscaleLogin")}),e.jsx("button",{className:"secondary-button",type:"button",disabled:p||f!==null||!(n!=null&&n.enabled)||B,onClick:()=>{W("logout")},children:f==="logout"?s("common.loading"):s("settings.tailscaleLogout")})]}):null]})}),m&&P?e.jsx(de,{heading:s("settings.tailscaleConfigModalTitle"),description:s("settings.tailscaleConfigModalDescription"),children:e.jsx(fs,{controlServerUrlDraft:l,hostnameDraft:x,pendingAction:f,configDirty:D,onControlServerUrlChange:d,onHostnameChange:v,onSave:()=>{U()}})}):null]}),e.jsx(ne,{open:!m&&P&&C,title:s("settings.tailscaleConfigModalTitle"),description:s("settings.tailscaleConfigModalDescription"),size:"regular",onClose:I,children:e.jsx(fs,{controlServerUrlDraft:l,hostnameDraft:x,pendingAction:f,configDirty:D,footer:e.jsx("div",{className:"settings-tailscale-modal-actions",children:e.jsx("button",{className:"secondary-button",type:"button",disabled:f==="save",onClick:I,children:s("common.cancel")})}),onControlServerUrlChange:d,onHostnameChange:v,onSave:()=>{U()}})})]})}function fs({controlServerUrlDraft:t,hostnameDraft:a,pendingAction:n,configDirty:i,footer:l,onControlServerUrlChange:d,onHostnameChange:x,onSave:v}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"settings-tailscale-form",children:[e.jsx(je,{label:s("settings.tailscaleControlServer"),children:e.jsx("input",{"aria-label":s("settings.tailscaleControlServer"),className:"settings-text-input",placeholder:s("settings.tailscaleControlServerPlaceholder"),value:t,onChange:p=>d(p.target.value)})}),e.jsx(je,{label:s("settings.tailscaleHostname"),children:e.jsx("input",{"aria-label":s("settings.tailscaleHostname"),className:"settings-text-input",placeholder:s("settings.tailscaleHostnamePlaceholder"),value:a,onChange:p=>x(p.target.value)})})]}),e.jsxs(te,{align:"start",className:"settings-tailscale-config-actions",children:[l,e.jsx("button",{className:"settings-button",type:"button",disabled:n!==null||!i,onClick:v,children:n==="save"?s("common.loading"):s("common.save")})]})]})}function xs(t){const a=t.trim();return a.length>0?a:null}function oe(t){return t instanceof ge||t instanceof Error?t.message:s("settings.tailscaleLoadFailed")}function Fn(t){if(!t)return s("settings.tailscaleUnavailable");const a=[t.tailnetIpv4,t.tailnetIpv6].filter(n=>!!n);return a.length>0?a.join(" / "):s("settings.tailscaleUnavailable")}function Bn(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 vs(t){return t?t.includes("Tailscale CLI"):!1}function Hn(t){return t==="macos"||t==="windows"}function Vn(t){switch(t){case"macos":return"https://tailscale.com/download/mac";case"windows":return"https://tailscale.com/download/windows";default:return null}}function qn(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 Bs({open:t,mobile:a,onClose:n}){const[i,l]=r.useState("tunnel"),d=r.useId(),x=[{id:"tunnel",label:s("settings.remoteAccessTunnelTab")},{id:"tailscale",label:s("settings.remoteAccessTailscaleTab")}],v=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"settings-model-tabs",role:"tablist","aria-label":s("settings.remoteAccessTabsLabel"),children:x.map(p=>{const w=`${d}-${p.id}-tab`,f=`${d}-${p.id}-panel`,b=i===p.id;return e.jsx("button",{id:w,type:"button",role:"tab",className:"settings-model-tab","data-active":b?"true":void 0,"aria-selected":b,"aria-controls":f,onClick:()=>l(p.id),children:p.label},p.id)})}),i==="tunnel"?e.jsx("div",{id:`${d}-tunnel-panel`,"aria-labelledby":`${d}-tunnel-tab`,role:"tabpanel",children:e.jsx(Sn,{})}):e.jsx("div",{id:`${d}-tailscale-panel`,"aria-labelledby":`${d}-tailscale-tab`,role:"tabpanel",children:e.jsx(On,{configMode:"inline"})})]});return a?e.jsx(vt,{open:t,title:s("settings.remoteAccessModalTitle"),description:s("settings.remoteAccessModalDescription"),height:"full",kind:"form",showHandle:!0,onClose:n,children:v}):e.jsx(ne,{open:t,title:s("settings.remoteAccessModalTitle"),description:s("settings.remoteAccessModalDescription"),size:"wide",onClose:n,children:v})}function js({title:t,description:a,actions:n,content:i,className:l}){return e.jsx(yt,{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})})}),n?e.jsx("div",{className:"mobile-workspace-home-toolbar-actions mobile-page-header-actions",children:n}):null]}),a?e.jsx("p",{className:"mobile-workspace-home-path mobile-page-header-description",children:a}):null,i?e.jsx("div",{className:"mobile-page-header-content",children:i}):null]})})}const Hs={start:43e3,end:47999};function _n(t){return t==="appearance"||t==="model-management"||t==="server-connection"||t==="remote-access"||t==="security-privacy"||t==="software-update"}function zn(t){return t==="en-US"?s("locale.enUS"):s("locale.zhCN")}function $n(t){return t==="beta"?s("settings.releaseBeta"):s("settings.releaseStable")}function Wn(t){switch(t){case"acceptEdits":return s("settings.permissionModeAcceptEdits");case"bypassPermissions":return s("settings.permissionModeBypassPermissions");default:return s("settings.permissionModeDefault")}}function Kn(){const t=Ss(),{theme:a,selectedTheme:n,autoTheme:i,setTheme:l,setAutoTheme:d}=mt(),x=nt(j=>j),v=ke(j=>j.profile.language),p=ke(j=>j.profile.defaultPermissionMode),w=ie(j=>j.sessionDisplaySortMode),f=ie(j=>j.showSystemFiles),b=ie(j=>j.notificationPreferences.notifyOnPermissionRequest),T=ie(j=>j.notificationPreferences.notifyOnSessionCompleted),S=ie(j=>j.notificationPreferences.notifyOnSessionFailed),C={language:v,defaultPermissionMode:p,debugPortPools:ke(j=>j.profile.debugPortPools)??Hs},y=Ve(),h=at(x.platform),u=h,g=He(x)??"",[N,M]=r.useState(g);r.useEffect(()=>{M(g)},[g]);function m(){it.clear(),Ce.resetToLocalFallback(),t("/login",{replace:!0})}function P(j){l(j)}function R(j){d(j)}function D(j){try{return Be(j)}catch{return null}}const B=D(N),$=B!==null&&B!==g;function F(j){j.preventDefault(),B&&Q.update({hosts:x.hosts.map(_=>_.id===x.activeHostId?{..._,baseUrl:B,updatedAt:new Date().toISOString()}:_)})}const H=[{value:"default",label:s("settings.permissionModeDefault")},{value:"acceptEdits",label:s("settings.permissionModeAcceptEdits")},{value:"bypassPermissions",label:s("settings.permissionModeBypassPermissions")}],W=[{value:"createdAt",label:s("settings.sessionSortModeCreatedAt")},{value:"updatedAt",label:s("settings.sessionSortModeUpdatedAt")},{value:"title",label:s("settings.sessionSortModeTitle")}];function U(j){Q.update({releaseChannel:j==="beta"?"beta":"stable"})}function J(j){Q.update({autoReconnect:j})}function G(j){Q.update({autoCheckUpdate:j})}function I(j){const _=j==="acceptEdits"||j==="bypassPermissions"?j:"default";Ce.updateProfile({defaultPermissionMode:_}).catch(()=>{})}function V(j){const _=j==="updatedAt"||j==="title"?j:"createdAt";le.setSessionDisplaySortMode(_)}function k(j){le.setShowSystemFiles(j)}function L(j){le.setNotificationPreferences({notifyOnPermissionRequest:j})}function E(j){le.setNotificationPreferences({notifyOnSessionCompleted:j})}function c(j){le.setNotificationPreferences({notifyOnSessionFailed:j})}async function O(j){await Ce.updateProfile({debugPortPools:j})}return{platform:y,theme:a,selectedTheme:n,autoTheme:i,applyTheme:P,applyAutoTheme:R,runtimeConfig:x,accountPreferences:C,sessionDisplaySortMode:w,showSystemFiles:f,notifyOnPermissionRequest:b,notifyOnSessionCompleted:T,notifyOnSessionFailed:S,showServerSettings:u,canConfigureServerAddress:h,hostBaseUrlDraft:N,setHostBaseUrlDraft:M,canSaveHostBaseUrl:$,permissionModeOptions:H,sessionDisplaySortModeOptions:W,handleHostBaseUrlSubmit:F,handleLogout:m,updateReleaseChannel:U,updateAutoReconnect:J,updateAutoCheckUpdate:G,updateDefaultPermissionMode:I,updateSessionDisplaySortMode:V,updateShowSystemFiles:k,updateNotifyOnPermissionRequest:L,updateNotifyOnSessionCompleted:E,updateNotifyOnSessionFailed:c,updateDebugPortPools:O}}function ba(){const t=Kn(),a=gt();return t.platform.isMobile?e.jsx(Gn,{model:t,appVersion:a}):e.jsx(Jn,{model:t,appVersion:a})}function Jn({model:t,appVersion:a}){const[n,i]=r.useState(!1),[l,d]=r.useState(!1),{theme:x,selectedTheme:v,autoTheme:p,applyTheme:w,applyAutoTheme:f,runtimeConfig:b,accountPreferences:T,sessionDisplaySortMode:S,showSystemFiles:C,notifyOnPermissionRequest:y,notifyOnSessionCompleted:h,notifyOnSessionFailed:u,showServerSettings:g,hostBaseUrlDraft:N,setHostBaseUrlDraft:M,canSaveHostBaseUrl:m,permissionModeOptions:P,sessionDisplaySortModeOptions:R,platform:D,handleHostBaseUrlSubmit:B,handleLogout:$,updateReleaseChannel:F,updateAutoReconnect:H,updateAutoCheckUpdate:W,updateDefaultPermissionMode:U,updateSessionDisplaySortMode:J,updateShowSystemFiles:G,updateNotifyOnPermissionRequest:I,updateNotifyOnSessionCompleted:V,updateNotifyOnSessionFailed:k,updateDebugPortPools:L}=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(Ts,{})})]}),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(q,{checked:p,label:s("settings.autoTheme"),onChange:f})]}),e.jsx("span",{className:"settings-theme-note",children:s("settings.autoThemeDescription")})]}),e.jsx("div",{className:"theme-selector",children:ks.map(E=>e.jsxs("button",{type:"button",className:`theme-card ${v===E.id&&!p?"active":""}`,"aria-pressed":v===E.id&&!p,disabled:p,onClick:()=>w(E.id),children:[e.jsx("span",{className:"theme-preview",style:{background:E.color}}),e.jsx("span",{className:"theme-label",children:Cs(E)}),v===E.id&&!p?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:S,onChange:E=>J(E.target.value),children:R.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(q,{checked:C,label:s("settings.showSystemFiles"),onChange:G})})]})]})]}),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:B,children:[e.jsx("input",{"aria-label":s("settings.serverAddress"),className:"settings-text-input",value:N,onChange:E=>M(E.target.value)}),e.jsx("button",{className:"settings-button",disabled:!m,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(q,{checked:b.autoReconnect,label:s("settings.autoReconnect"),onChange:H})})]})]})]}):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(Ms,{})})})})]}),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:()=>d(!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:T.defaultPermissionMode,onChange:E=>U(E.target.value),children:P.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(As,{})})]}),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(q,{checked:y,label:s("settings.notifyOnPermissionRequest"),onChange:I})})]}),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(q,{checked:h,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(q,{checked:u,label:s("settings.notifyOnSessionFailed"),onChange:k})})]})]})]}),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(Vs,{value:T.debugPortPools,onSave:L})})]}),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:b.releaseChannel,onChange:E=>F(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(Is,{})})]}),D.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(q,{checked:b.autoCheckUpdate,label:s("settings.autoCheckUpdate"),onChange:W})})]}),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(Ps,{})})]})]})]})]}),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",a]}),e.jsx("button",{className:"settings-button settings-button-danger settings-button-sticky",onClick:$,type:"button",children:s("common.logout")})]})]}),e.jsx(St,{isOpen:n,onClose:()=>i(!1)}),e.jsx(Bs,{open:l,mobile:!1,onClose:()=>d(!1)})]})}function Gn({model:t,appVersion:a}){const n=Ss(),{section:i}=ht(),l=_n(i)?i:null,d=[{id:"appearance",title:s("settings.appearance"),description:s("settings.appearanceSectionSummary"),value:zn(t.accountPreferences.language),icon:e.jsx(na,{})}];return t.showServerSettings&&d.push({id:"server-connection",title:s("settings.serverConnection"),description:s("settings.serverConnectionSectionSummary"),value:He(t.runtimeConfig)??"",icon:e.jsx(aa,{})}),d.push({id:"model-management",title:s("settings.modelManagement"),description:s("settings.modelManagementSectionSummary"),value:s("settings.modelManagementNavValue"),icon:e.jsx(ra,{})},{id:"remote-access",title:s("settings.remoteAccess"),description:s("settings.remoteAccessSectionSummary"),value:s("settings.remoteAccessNavValue"),icon:e.jsx(la,{})},{id:"security-privacy",title:s("settings.securityPrivacy"),description:s("settings.securityPrivacySectionSummary"),value:Wn(t.accountPreferences.defaultPermissionMode),icon:e.jsx(ca,{})},{id:"software-update",title:s("settings.softwareUpdate"),description:s("settings.softwareUpdateSectionSummary"),value:$n(t.runtimeConfig.releaseChannel),icon:e.jsx(ia,{})}),(l?d.find(v=>v.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(js,{title:s("settings.title")}),e.jsxs("div",{className:"settings-mobile-container",children:[l==="appearance"?e.jsx(Zn,{model:t}):null,l==="model-management"?e.jsx(sa,{}):null,l==="server-connection"&&t.showServerSettings?e.jsx(Qn,{model:t}):null,l==="remote-access"?e.jsx(ea,{model:t}):null,l==="security-privacy"?e.jsx(Xn,{model:t}):null,l==="software-update"?e.jsx(ta,{model:t}):null]}),e.jsx(Ns,{onLogout:t.handleLogout})]}):e.jsxs("div",{className:"settings-page settings-page-mobile mobile-page-scroll-root mobile-page-with-top-header",children:[e.jsx(js,{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:d.map(v=>e.jsxs("button",{type:"button",className:"settings-mobile-nav-row",onClick:()=>n(`/settings/${v.id}`),children:[e.jsx("span",{className:"settings-mobile-nav-icon",children:v.icon}),e.jsxs("span",{className:"settings-mobile-nav-copy",children:[e.jsx("span",{className:"settings-mobile-nav-title",children:v.title}),e.jsx("span",{className:"settings-mobile-nav-description",children:v.description})]}),e.jsxs("span",{className:"settings-mobile-nav-trailing",children:[v.value?e.jsx("span",{className:"settings-mobile-nav-value",children:v.value}):null,e.jsx(oa,{})]})]},v.id))})}),e.jsx("div",{className:"settings-footer settings-footer-mobile",children:e.jsxs("span",{className:"settings-version",children:["CodingNS v",a]})})]}),e.jsx(Ns,{onLogout:t.handleLogout})]})}function Zn({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(Ts,{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(q,{checked:t.autoTheme,label:s("settings.autoTheme"),onChange:t.applyAutoTheme})]}),ks.map(a=>{const n=t.selectedTheme===a.id&&!t.autoTheme;return e.jsxs("button",{type:"button",className:`settings-mobile-choice-row${n?" active":""}`,"aria-pressed":n,disabled:t.autoTheme,onClick:()=>t.applyTheme(a.id),children:[e.jsxs("span",{className:"settings-mobile-choice-leading",children:[e.jsx("span",{className:"settings-mobile-choice-dot",style:{background:a.color},"aria-hidden":"true"}),e.jsx("span",{className:"settings-mobile-choice-label",children:Cs(a)})]}),e.jsx("span",{className:"settings-mobile-choice-indicator","aria-hidden":"true",children:n?e.jsx(da,{}):null})]},a.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:a=>t.updateSessionDisplaySortMode(a.target.value),children:t.sessionDisplaySortModeOptions.map(a=>e.jsx("option",{value:a.value,children:a.label},a.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(q,{checked:t.showSystemFiles,label:s("settings.showSystemFiles"),onChange:t.updateShowSystemFiles})]})]})]})]})}function Qn({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:a=>t.setHostBaseUrlDraft(a.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(q,{checked:t.runtimeConfig.autoReconnect,label:s("settings.autoReconnect"),onChange:t.updateAutoReconnect})]})})]})]})}function Xn({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:a=>t.updateDefaultPermissionMode(a.target.value),children:t.permissionModeOptions.map(a=>e.jsx("option",{value:a.value,children:a.label},a.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(As,{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(Vs,{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(q,{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(q,{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(q,{checked:t.notifyOnSessionFailed,label:s("settings.notifyOnSessionFailed"),onChange:t.updateNotifyOnSessionFailed})]})]})]})]})}function Vs(t){const[a,n]=r.useState(()=>ys(t.value)),[i,l]=r.useState(!1),[d,x]=r.useState(null),[v,p]=r.useState(!1);r.useEffect(()=>{n(ys(t.value))},[t.value]);async function w(){x(null),p(!1);let f;try{f=Yn(a)}catch(b){x(b instanceof Error?b.message:s("settings.debugPortPoolSaveFailed"));return}try{l(!0),await t.onSave(f),p(!0)}catch(b){x(b instanceof Error?b.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:a.start,onChange:f=>{const b=f.target.value;n(T=>({...T,start:b}))}}),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:a.end,onChange:f=>{const b=f.target.value;n(T=>({...T,end:b}))}}),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")}),v?e.jsx("span",{children:s("settings.debugPortPoolSaved")}):null]})})]}),d?e.jsx("p",{className:"status-text settings-debug-port-pool-feedback","data-tone":"error",children:d}):null]})}function ys(t){const a=t??Hs;return{start:String(a.start),end:String(a.end)}}function Yn(t){const a=Number.parseInt(t.start,10),n=Number.parseInt(t.end,10);if(!Number.isInteger(a)||!Number.isInteger(n))throw new Error(s("settings.debugPortPoolValidationInteger"));if(a<1024||n>65535||a>=n)throw new Error(s("settings.debugPortPoolValidationRange"));return{start:a,end:n}}function ea({model:t}){const[a,n]=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:()=>n(!0),children:s("settings.remoteAccessManageAction")})]})})]}),e.jsx(Bs,{open:a,mobile:!0,onClose:()=>n(!1)})]})}function sa(){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(Ms,{})})]})}function ta({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:a=>t.updateReleaseChannel(a.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(Is,{})})]}),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(q,{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(Ps,{})})]})]})}function Ns({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 q({checked:t,label:a,onChange:n}){return e.jsxs("label",{className:"settings-mobile-switch","aria-label":a,onClick:i=>{i.target instanceof HTMLInputElement||(i.preventDefault(),n(!t))},children:[e.jsx("input",{type:"checkbox","aria-label":a,checked:t,onChange:i=>n(i.target.checked)}),e.jsx("span",{className:"settings-mobile-switch-track","aria-hidden":"true",children:e.jsx("span",{className:"settings-mobile-switch-thumb"})})]})}function na(){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 aa(){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 ia(){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 la(){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 ra(){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 ca(){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 oa(){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 da(){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{ba as SettingsPage};
|