@ensocode/server 0.2.12 → 0.2.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/out/node_modules/@earendil-works/pi-coding-agent/node_modules/.bin/jiti +2 -2
  2. package/out/node_modules/@earendil-works/pi-coding-agent/node_modules/.bin/pi-ai +2 -2
  3. package/out/node_modules/@earendil-works/pi-coding-agent/node_modules/.bin/semver +2 -2
  4. package/out/node_modules/@earendil-works/pi-coding-agent/node_modules/.bin/yaml +2 -2
  5. package/out/node_modules/@rahularya01/pi-cursor/node_modules/.bin/pi +2 -2
  6. package/out/node_modules/@rahularya01/pi-cursor/node_modules/.bin/pi-ai +2 -2
  7. package/out/renderer/assets/{abnfDiagram-VCTEODGH-DSknDX4E.js → abnfDiagram-VCTEODGH-BDMrRlBj.js} +1 -1
  8. package/out/renderer/assets/{arc-zTFUKTRJ.js → arc-BHxAM6vy.js} +1 -1
  9. package/out/renderer/assets/{architectureDiagram-5GKGNRK7-C3ozR2n4.js → architectureDiagram-5GKGNRK7-DQrws1sS.js} +1 -1
  10. package/out/renderer/assets/{blockDiagram-I7D4REHJ-CP8IPcaX.js → blockDiagram-I7D4REHJ-DNVn9Vt7.js} +1 -1
  11. package/out/renderer/assets/{c4Diagram-7LVT6UL2-Dg7E4owk.js → c4Diagram-7LVT6UL2--LtDB-qV.js} +1 -1
  12. package/out/renderer/assets/channel-DIfxeADv.js +1 -0
  13. package/out/renderer/assets/{chunk-2Q5K7J3B-DJGGTYcL.js → chunk-2Q5K7J3B-t33NDV5v.js} +1 -1
  14. package/out/renderer/assets/{chunk-5VM5RSS4-BtSsuqjz.js → chunk-5VM5RSS4-aCGmL6_s.js} +1 -1
  15. package/out/renderer/assets/{chunk-F27PBJKO-BWV_yV1h.js → chunk-F27PBJKO-DQvndxlp.js} +1 -1
  16. package/out/renderer/assets/{chunk-IMKFNOWR-Ck5oy1zk.js → chunk-IMKFNOWR-rH1b7xzl.js} +1 -1
  17. package/out/renderer/assets/{chunk-JWPE2WC7-B-S2-0Sm.js → chunk-JWPE2WC7-B7-2fQn6.js} +1 -1
  18. package/out/renderer/assets/{chunk-POPQ4Y6H-R_8Vekxl.js → chunk-POPQ4Y6H-CVYzlJTE.js} +1 -1
  19. package/out/renderer/assets/{chunk-SVP7TREG-tsjEM3PC.js → chunk-SVP7TREG-v3eUqihT.js} +1 -1
  20. package/out/renderer/assets/{chunk-TICWLB2K-DUvlZ-eV.js → chunk-TICWLB2K-Dq2BsFU4.js} +1 -1
  21. package/out/renderer/assets/{chunk-XXDRQBXY-Dyxh1s1Z.js → chunk-XXDRQBXY-DjMnIDLm.js} +1 -1
  22. package/out/renderer/assets/classDiagram-ZZMXUADV-D8Q2hInV.js +1 -0
  23. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-D8Q2hInV.js +1 -0
  24. package/out/renderer/assets/{cose-bilkent-JH36ORCC-BtT54hjs.js → cose-bilkent-JH36ORCC-DAUPCDab.js} +1 -1
  25. package/out/renderer/assets/{cynefin-OW5HDTMX-Cs8squh2.js → cynefin-OW5HDTMX-DBni0eSw.js} +1 -1
  26. package/out/renderer/assets/{cynefinDiagram-5FMLGOSQ-fbUAGuvo.js → cynefinDiagram-5FMLGOSQ-n0u0erlW.js} +1 -1
  27. package/out/renderer/assets/{cytoscape-fcose-Bz_Tpcw2.js → cytoscape-fcose-DVQaQP2R.js} +1 -1
  28. package/out/renderer/assets/{dagre-GXQ25YYZ-Fhu5QOEm.js → dagre-GXQ25YYZ-B-0jlzO1.js} +1 -1
  29. package/out/renderer/assets/{diagram-S7CK7UJ4-DK47UH_g.js → diagram-S7CK7UJ4-BxXw3viF.js} +1 -1
  30. package/out/renderer/assets/{diagram-UQ7AKVKN-DtVjeJ2g.js → diagram-UQ7AKVKN-BCCjG-ot.js} +1 -1
  31. package/out/renderer/assets/{diagram-VSXAHHWV-q-yK0nOP.js → diagram-VSXAHHWV-BK0zhBZp.js} +1 -1
  32. package/out/renderer/assets/{diagram-VX7I27RA-A7YCLSM9.js → diagram-VX7I27RA-DylHuw1A.js} +1 -1
  33. package/out/renderer/assets/{diagram-Z3DM3KII-C8JKpOpD.js → diagram-Z3DM3KII-biplaxsX.js} +1 -1
  34. package/out/renderer/assets/{ebnfDiagram-PWID7BFC-BB8uppX2.js → ebnfDiagram-PWID7BFC-DzoKjl97.js} +1 -1
  35. package/out/renderer/assets/{erDiagram-RLTQ6QDP-bsoIoJ_o.js → erDiagram-RLTQ6QDP-CxhgKPs-.js} +1 -1
  36. package/out/renderer/assets/{flowDiagram-HODETNUW-D1-YOWb-.js → flowDiagram-HODETNUW-DCi3FHwP.js} +1 -1
  37. package/out/renderer/assets/{ganttDiagram-EL5Y4UJY-BfLmFDZ-.js → ganttDiagram-EL5Y4UJY-BCmOcEsS.js} +1 -1
  38. package/out/renderer/assets/{gitGraphDiagram-WWUBYQGX-Cm8h40L_.js → gitGraphDiagram-WWUBYQGX-CWwjuui-.js} +1 -1
  39. package/out/renderer/assets/{globals-BKWml662.js → globals-BwNQF72D.js} +1 -1
  40. package/out/renderer/assets/{index-EZ5OaOIy.js → index-CzysFMwH.js} +3 -3
  41. package/out/renderer/assets/{infoDiagram-27XIBGKW-yWJunXz9.js → infoDiagram-27XIBGKW-C2vV0S3R.js} +1 -1
  42. package/out/renderer/assets/{ishikawaDiagram-5VMMS53U-DxwTsrS1.js → ishikawaDiagram-5VMMS53U-BSWVe4Qr.js} +1 -1
  43. package/out/renderer/assets/{journeyDiagram-3NMN7TZE-CuB5mhXa.js → journeyDiagram-3NMN7TZE-D_D_AgW8.js} +1 -1
  44. package/out/renderer/assets/{kanban-definition-UXKFOSKX-Cmva56gL.js → kanban-definition-UXKFOSKX-Dp-tJLJV.js} +1 -1
  45. package/out/renderer/assets/{layout-DoAgDBEn.js → layout-BGyL6Nz9.js} +1 -1
  46. package/out/renderer/assets/{linear-CZwdsMB7.js → linear-NiGqkXcf.js} +1 -1
  47. package/out/renderer/assets/{mermaid.core-DU532gMP.js → mermaid.core-CAbX6U-E.js} +5 -5
  48. package/out/renderer/assets/{mindmap-definition-YA3MSWOX-DK3MTfhw.js → mindmap-definition-YA3MSWOX-C_KTsCSk.js} +1 -1
  49. package/out/renderer/assets/{pegDiagram-XKGWAZYB-D6n-lh1R.js → pegDiagram-XKGWAZYB-BlEf-4SS.js} +1 -1
  50. package/out/renderer/assets/{pieDiagram-E7YTZNPT-CxpB_WP9.js → pieDiagram-E7YTZNPT-C2l9VhhT.js} +1 -1
  51. package/out/renderer/assets/{quadrantDiagram-AXDQQJYC-eGxakEz6.js → quadrantDiagram-AXDQQJYC-Bkm2D1II.js} +1 -1
  52. package/out/renderer/assets/{railroadDiagram-O6MQD6OU-Bn8WVtzF.js → railroadDiagram-O6MQD6OU-Cy9AsJch.js} +1 -1
  53. package/out/renderer/assets/{requirementDiagram-BXWQKSXE-k1J6FH4-.js → requirementDiagram-BXWQKSXE-DaqpZJ20.js} +1 -1
  54. package/out/renderer/assets/{sankeyDiagram-P5KCCOFB-zs75kBxO.js → sankeyDiagram-P5KCCOFB-DShER0Cl.js} +1 -1
  55. package/out/renderer/assets/{sequenceDiagram-WJ2MYXX4-l16uPywk.js → sequenceDiagram-WJ2MYXX4-fA8_5PiI.js} +1 -1
  56. package/out/renderer/assets/{settings-PBZusE8m.js → settings-BwM2TgQ9.js} +2 -2
  57. package/out/renderer/assets/{sizeCapture-INFHLROL-qNGUa7l4.js → sizeCapture-INFHLROL-CpzQOV5k.js} +1 -1
  58. package/out/renderer/assets/{stateDiagram-D77RDMKH-XunN8EqP.js → stateDiagram-D77RDMKH-CIEGNnJO.js} +1 -1
  59. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-DYbIahny.js +1 -0
  60. package/out/renderer/assets/{swimlanes-42K2YHIH-BFbz49DP.js → swimlanes-42K2YHIH-CAeLgkB1.js} +1 -1
  61. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-BLHkQmpd.js +8 -0
  62. package/out/renderer/assets/{timeline-definition-24CTP7MA-BZe7g-xh.js → timeline-definition-24CTP7MA-CkWIsYs6.js} +1 -1
  63. package/out/renderer/assets/{vennDiagram-4TSXK5OY-HhmToh-J.js → vennDiagram-4TSXK5OY-Cus6U3uz.js} +1 -1
  64. package/out/renderer/assets/{wardleyDiagram-VM6X3IG4-C7Xrbo9d.js → wardleyDiagram-VM6X3IG4-BJg1coTW.js} +1 -1
  65. package/out/renderer/assets/{xychartDiagram-S5SC5T6Z-CzFFFEO6.js → xychartDiagram-S5SC5T6Z-DjRPfyub.js} +1 -1
  66. package/out/renderer/index.html +2 -2
  67. package/out/renderer/settings.html +3 -3
  68. package/out/server/agent.js +1 -1
  69. package/out/server/index.js +4 -4
  70. package/package.json +1 -1
  71. package/out/renderer/assets/channel-CwD8Sdta.js +0 -1
  72. package/out/renderer/assets/classDiagram-ZZMXUADV-C_zVt_Ll.js +0 -1
  73. package/out/renderer/assets/classDiagram-v2-VYDZK3BY-C_zVt_Ll.js +0 -1
  74. package/out/renderer/assets/stateDiagram-v2-MP3YSRHH-DtHEdXeq.js +0 -1
  75. package/out/renderer/assets/swimlanesDiagram-VR7AAH4N-DyNtRiPo.js +0 -8
@@ -1,4 +1,4 @@
1
- import{c as Re,j as e,A as Fo,r as u,u as Cr,a as Sr,b as hn,d as Ir,t as Er,C as zn,e as V,I as K,f as Uo,X as wt,h as $o,i as Vo,Z as Qe,k as qo,S as Ko,l as Go,m as Wo,n as Ho,o as Jo,p as w,q as B,M as xn,T as Ar,s as Yo,v as Qo,w as Xo,x as Zo,B as P,y as Mr,z as Rt,D as Q,E as Bt,F as X,G as Z,H as ee,J as H,K as We,L as ie,N as Pr,R as Dt,O as ei,V as ti,P as si,Q as ni,U as ai,W as Tr,Y as ri,_ as is,$ as Rr,a0 as oi,a1 as Dr,a2 as ii,a3 as Bn,a4 as Or,a5 as li,a6 as ci,a7 as di,a8 as _n,a9 as ui,aa as mi,ab as hi,ac as xi,ad as pi,ae as fi,af as gi,ag as ji,ah as vi,ai as bi,aj as yi,ak as ls,al as wi,am as Ni,an as ki,ao as Ci,ap as Si,aq as Ii,ar as Me,as as pn,at as Wt,au as we,av as Ne,aw as ke,ax as Ce,ay as $e,az as Pe,aA as Le,aB as Lr,aC as bt,aD as ze,aE as Ue,aF as fn,aG as Nt,aH as Se,aI as gn,aJ as jn,aK as vn,aL as bn,aM as yn,aN as wn,aO as Nn,aP as zr,aQ as Ke,aR as Fn,aS as Ei,aT as qt,aU as Kt,aV as Ai,aW as He,aX as Je,aY as Un,aZ as $n,a_ as Fe,a$ as Xe,b0 as Mi,b1 as Vn,b2 as qn,b3 as Kn,b4 as cs,b5 as Gn,b6 as Pi,b7 as Br,b8 as ds,b9 as Ti,ba as _r,bb as Fr,bc as Ie,bd as te,be as Ee,bf as Ri,bg as Di,bh as Oi,bi as Li,bj as zi,bk as Wn,bl as Bi,bm as _i,bn as Ot,bo as Lt,bp as Ve,bq as At,br as Zs,bs as Fi,bt as Ui,bu as en,bv as rt,bw as Ur,bx as $i,by as Vi,bz as $r,bA as qi,bB as Hn,bC as Vr,bD as Ki,bE as Gi,bF as qr,bG as Be,bH as Kr,bI as Wi,bJ as tn,bK as Hi,bL as Jn,bM as Ji,bN as Yi,bO as Qi,bP as at,bQ as Xi,bR as Yn,bS as Qn,bT as Zi,bU as Xn,bV as el,bW as tl,bX as sl,bY as nl,bZ as _e,b_ as us,b$ as Gr,c0 as al,c1 as rl,c2 as ol,c3 as il,c4 as ll,c5 as cl,c6 as kn,c7 as dl,c8 as Wr,c9 as ul,ca as Zn,cb as ml,cc as Zt,cd as hl,ce as xl,cf as pl,g as fl,cg as sn,ch as Hr,ci as _t,cj as gl,ck as jl,cl as de,cm as ue,cn as es,co as Jr,cp as Cn,cq as vl,cr as ea,cs as ta,ct as sa,cu as bl,cv as yl,cw as wl,cx as Nl,cy as kl,cz as Cl,cA as Sl,cB as Il,cC as El,cD as Al,cE as Ml,cF as Pl,cG as na,cH as Yr,cI as Qr,cJ as Xr,cK as Zr,cL as Tl,cM as Rl,cN as kt,cO as Dl,cP as Ol,cQ as Ll,cR as zl,cS as Bl,cT as _l,cU as Fl,cV as eo,cW as Ul,cX as $l,cY as Vl,cZ as ql,c_ as Ht,c$ as Kl,d0 as Sn,d1 as to,d2 as so,d3 as In,d4 as no,d5 as ao,d6 as ro,d7 as oo,d8 as io,d9 as En,da as Gl,db as Wl,dc as Hl,dd as Jl,de as Yl,df as Ql,dg as Xl,dh as Zl,di as ec,dj as tc,dk as sc,dl as nc,dm as ac,dn as rc,dp as oc,dq as ic,dr as lo,ds as co,dt as uo,du as lc,dv as mo,dw as cc,dx as dc,dy as uc,dz as ho,dA as mc,dB as hc,dC as xc,dD as Jt,dE as pc,dF as fc,dG as gc,dH as jc,dI as et,dJ as vc,dK as xo,dL as bc,dM as ms,dN as yc,dO as wc,dP as Nc,dQ as kc,dR as Cc,dS as Sc,dT as Ic,dU as Ec,dV as Ac,dW as Mc,dX as Pc,dY as Tc,dZ as Rc,d_ as Dc,d$ as Oc,e0 as Lc,e1 as zc,e2 as Bc,e3 as _c,e4 as Fc,e5 as Uc,e6 as $c,e7 as Vc,e8 as qc}from"./globals-BKWml662.js";import{c as po}from"./cytoscape.esm-DzSz-X2X.js";import{f as Kc}from"./cytoscape-fcose-Bz_Tpcw2.js";const Gc=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Wc=Re("box",Gc);const Hc=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Jc=Re("chart-column",Hc);const Yc=[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],Qc=Re("file-archive",Yc);const Xc=[["path",{d:"M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z",key:"ukzhwg"}],["path",{d:"M14.487 7.858A1 1 0 0 1 14 7V2",key:"1klhew"}],["path",{d:"M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516",key:"rxaxab"}],["path",{d:"M8 18h1",key:"13wk12"}]],Zc=Re("file-pen-line",Xc);const ed=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],td=Re("flag",ed);const sd=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],aa=Re("heart",sd);const nd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ad=Re("image",nd);const rd=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],od=Re("link-2",rd);const id=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],fo=Re("lock-keyhole",id);const ld=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],cd=Re("moon",ld);const dd=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],ud=Re("palette",dd);const md=[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]],hd=Re("shrink",md);const xd=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],pd=Re("sun",xd);const fd=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],go=Re("upload",fd);function gd(t){const{multiple:s=!1,defaultValue:a,value:n,onValueChange:r,autoComplete:o,...i}=t;return e.jsx(Fo,{...i,selectionMode:s?"multiple":"single",selectedValue:n,defaultSelectedValue:a,onSelectedValueChange:r,formAutoComplete:o})}const jd=u.forwardRef(function(s,a){const{selected:n}=Cr();return s.keepMounted||n?e.jsx(vd,{...s,ref:a}):null}),vd=u.memo(u.forwardRef((t,s)=>{const{render:a,className:n,style:r,keepMounted:o,...i}=t,{selected:c}=Cr(),d=u.useRef(null),{transitionStatus:x,setMounted:h}=Sr(c),p=hn("span",t,{ref:[s,d],state:{selected:c,transitionStatus:x},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:Er});return Ir({open:c,ref:d,onComplete(){c||h(!1)}}),p})),An=u.createContext({chipsRef:null,multiple:!1,rootRef:null});function bd(t){const s=u.useRef(null),a=u.useRef(null);return e.jsx(An.Provider,{value:{chipsRef:s,multiple:!!t.multiple,rootRef:a},children:e.jsx("div",{ref:a,className:"contents",children:e.jsx(gd,{...t})})})}function yd({className:t,showTrigger:s=!0,showClear:a=!1,startAddon:n,size:r,...o}){const{multiple:i}=u.useContext(An),c=r??"default";return i?e.jsx(zn,{className:V("min-w-12 flex-1 text-base outline-none sm:text-sm [[data-slot=combobox-chip]+&]:ps-0.5",c==="sm"?"ps-1.5":"ps-2",t),"data-size":typeof c=="string"?c:void 0,"data-slot":"combobox-input",size:typeof c=="number"?c:void 0,...o}):e.jsxs("div",{className:"relative w-full has-disabled:opacity-64",children:[n&&e.jsx("div",{"aria-hidden":"true",className:"[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 has-[+[data-size=sm]]:ps-[calc(--spacing(2.5)-1px)] [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4","data-slot":"combobox-start-addon",children:n}),e.jsx(zn,{className:V(n&&"data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7.5)-1px)] *:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]",c==="sm"?"has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-6.5":"has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-7",t),"data-slot":"combobox-input",render:e.jsx(K,{className:"has-disabled:opacity-100",size:c}),...o}),s&&e.jsx(wd,{className:V("-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",c==="sm"?"end-0":"end-0.5"),children:e.jsx(Uo,{})}),a&&e.jsx(Sd,{className:V("-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",c==="sm"?"end-0":"end-0.5"),children:e.jsx(wt,{})})]})}function wd({className:t,...s}){return e.jsx(Ho,{className:t,"data-slot":"combobox-trigger",...s})}function Nd({className:t,children:s,sideOffset:a=4,zIndex:n,...r}){const{chipsRef:o,rootRef:i}=u.useContext(An);let c=Qe.DROPDOWN;if(n!==void 0)c=n;else{const d=i?.current;d&&(d.closest('[data-slot="dialog-popup"] [data-slot="dialog-popup"]')?c=Qe.DROPDOWN_IN_NESTED_MODAL:d.closest('[data-slot="dialog-popup"]')&&(c=Qe.DROPDOWN_IN_MODAL))}return e.jsx($o,{children:e.jsx(Vo,{anchor:o,className:"select-none",style:{zIndex:c},"data-slot":"combobox-positioner",sideOffset:a,children:e.jsx("span",{className:V("relative flex max-h-full origin-(--transform-origin) rounded-lg border bg-popover bg-clip-padding transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-lg has-data-starting-style:scale-98 has-data-starting-style:opacity-0 dark:not-in-data-[slot=group]:bg-clip-border",t),children:e.jsx(qo,{className:"flex max-h-[min(var(--available-height),23rem)] w-(--anchor-width) max-w-(--available-width) flex-col","data-slot":"combobox-popup",...r,children:s})})})})}function kd({className:t,children:s,endAddon:a,...n}){return e.jsxs(Wo,{className:V("grid min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr_auto] items-center gap-2 rounded-sm py-1 ps-2 pe-4 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),"data-slot":"combobox-item",...n,children:[e.jsx(jd,{className:"col-start-1",children:e.jsx("svg",{"aria-hidden":"true",fill:"none",height:"24",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5.252 12.7 10.2 18.63 18.748 5.37"})})}),e.jsx("div",{className:"col-start-2",children:s}),a&&e.jsx("div",{className:"col-start-3 flex items-center",children:a})]})}function Cd({className:t,...s}){return e.jsx(Ko,{scrollbarGutter:!0,scrollFade:!0,children:e.jsx(Go,{className:V("not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1 in-data-has-overflow-y:pe-3",t),"data-slot":"combobox-list",...s})})}function Sd({className:t,...s}){return e.jsx(Jo,{className:t,"data-slot":"combobox-clear",...s})}function pt({label:t,value:s,onCommit:a,min:n=0,max:r=100,unit:o="%"}){const[i,c]=u.useState(s);return u.useEffect(()=>{c(s)},[s]),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(si,{min:n,max:r,value:i,onValueChange:d=>c(Array.isArray(d)?d[0]:d),onValueCommitted:d=>a(Array.isArray(d)?d[0]:d)}),e.jsxs("span",{className:"w-12 shrink-0 text-right text-sm text-muted-foreground",children:[i,o]})]})]})}function Id(){const{t}=B(),s=w(L=>L.backgroundImageEnabled),a=w(L=>L.setBackgroundImageEnabled),n=w(L=>L.backgroundSourceType),r=w(L=>L.setBackgroundSourceType),o=w(L=>L.backgroundImagePath),i=w(L=>L.setBackgroundImagePath),c=w(L=>L.backgroundFolderPath),d=w(L=>L.setBackgroundFolderPath),x=w(L=>L.backgroundUrlPath),h=w(L=>L.setBackgroundUrlPath),l=w(L=>L.backgroundRandomEnabled),p=w(L=>L.setBackgroundRandomEnabled),m=w(L=>L.backgroundRandomInterval),f=w(L=>L.setBackgroundRandomInterval),j=w(L=>L.backgroundOpacity),v=w(L=>L.setBackgroundOpacity),N=w(L=>L.backgroundBlur),b=w(L=>L.setBackgroundBlur),C=w(L=>L.backgroundBrightness),k=w(L=>L.setBackgroundBrightness),M=w(L=>L.backgroundSaturation),O=w(L=>L.setBackgroundSaturation),S=w(L=>L.backgroundComposerOpacity),y=w(L=>L.setBackgroundComposerOpacity),g=w(L=>L.backgroundCodeOpacity),E=w(L=>L.setBackgroundCodeOpacity),I=w(L=>L.backgroundSizeMode),D=w(L=>L.setBackgroundSizeMode),_=w(L=>L.bumpBackgroundRefresh),A=n==="file"?o:n==="folder"?c:x,[F,q]=u.useState(A);u.useEffect(()=>{q(A)},[A]);const W=u.useCallback(()=>{const L=F.trim();n==="file"?i(L):n==="folder"?d(L):h(L)},[F,n,i,d,h]),[R,G]=u.useState(m);u.useEffect(()=>{G(m)},[m]);const ne=async()=>{if(n==="folder"){const L=await window.electronAPI.dialog.selectDirectory();L&&d(L)}else{const L=await window.electronAPI.dialog.selectFile([...ei,...ti]);L&&i(L)}},xe=[{value:"file",label:t("Single image")},{value:"folder",label:t("Folder (random)")},{value:"url",label:t("Remote URL")}],U=[{value:"cover",label:t("Cover")},{value:"contain",label:t("Contain")},{value:"repeat",label:t("Repeat")},{value:"center",label:t("Center")}],se=t(n==="file"?"Image path":n==="folder"?"Folder path":"Image URL");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between border-t pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:t("Background image")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("Show a custom image behind the interface")})]}),e.jsx(ie,{checked:s,onCheckedChange:L=>a(L===!0)})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Source type")}),e.jsxs(Q,{items:xe,value:n,onValueChange:L=>r(L),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:xe.map(L=>e.jsx(H,{value:L.value,children:L.label},L.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:se}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:F,onChange:L=>q(L.target.value),onBlur:W,onKeyDown:L=>{L.nativeEvent.isComposing||L.key==="Enter"&&(W(),L.currentTarget.blur())},placeholder:n==="url"?"https://example.com/image.jpg":"",className:"flex-1"}),n!=="url"&&e.jsx(P,{variant:"outline",size:"icon",onClick:ne,"aria-label":t("Browse"),children:n==="folder"?e.jsx(Pr,{className:"h-4 w-4"}):e.jsx(ad,{className:"h-4 w-4"})}),n!=="file"&&e.jsx(P,{variant:"outline",size:"icon",onClick:_,"aria-label":t("Refresh now"),children:e.jsx(Dt,{className:"h-4 w-4"})})]})]}),n!=="file"&&e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Auto switch")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{checked:l,onCheckedChange:L=>p(L===!0)}),l&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"number",min:5,max:86400,value:R,onChange:L=>G(Number(L.target.value)),onBlur:()=>f(R),onKeyDown:L=>{L.key==="Enter"&&(f(R),L.currentTarget.blur())},className:"w-24"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("seconds")})]})]})]}),e.jsx(pt,{label:t("Background visibility"),value:Math.round(j*100),onCommit:L=>v(L/100)}),e.jsx(pt,{label:t("Blur"),value:N,onCommit:b,max:20,unit:"px"}),e.jsx(pt,{label:t("Brightness"),value:Math.round(C*100),onCommit:L=>k(L/100),max:200}),e.jsx(pt,{label:t("Saturation"),value:Math.round(M*100),onCommit:L=>O(L/100),max:200}),e.jsx(pt,{label:t("Composer opacity"),value:Math.round(S*100),onCommit:L=>y(L/100)}),e.jsx(pt,{label:t("Code block opacity"),value:Math.round(g*100),onCommit:L=>E(L/100)}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Size mode")}),e.jsxs(Q,{items:U,value:I,onValueChange:L=>D(L),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:U.map(L=>e.jsx(H,{value:L.value,children:L.label},L.value))})]})]})]})]})}function Ed({theme:t,fontSize:s,fontFamily:a,fontWeight:n}){const r=[{id:"prompt1",text:"$ ",color:t.green},{id:"cmd1",text:"ls -la",color:t.foreground},{id:"nl1",text:`
1
+ import{c as Re,j as e,A as Fo,r as u,u as Cr,a as Sr,b as hn,d as Ir,t as Er,C as zn,e as V,I as K,f as Uo,X as wt,h as $o,i as Vo,Z as Qe,k as qo,S as Ko,l as Go,m as Wo,n as Ho,o as Jo,p as w,q as B,M as xn,T as Ar,s as Yo,v as Qo,w as Xo,x as Zo,B as P,y as Mr,z as Rt,D as Q,E as Bt,F as X,G as Z,H as ee,J as H,K as We,L as ie,N as Pr,R as Dt,O as ei,V as ti,P as si,Q as ni,U as ai,W as Tr,Y as ri,_ as is,$ as Rr,a0 as oi,a1 as Dr,a2 as ii,a3 as Bn,a4 as Or,a5 as li,a6 as ci,a7 as di,a8 as _n,a9 as ui,aa as mi,ab as hi,ac as xi,ad as pi,ae as fi,af as gi,ag as ji,ah as vi,ai as bi,aj as yi,ak as ls,al as wi,am as Ni,an as ki,ao as Ci,ap as Si,aq as Ii,ar as Me,as as pn,at as Wt,au as we,av as Ne,aw as ke,ax as Ce,ay as $e,az as Pe,aA as Le,aB as Lr,aC as bt,aD as ze,aE as Ue,aF as fn,aG as Nt,aH as Se,aI as gn,aJ as jn,aK as vn,aL as bn,aM as yn,aN as wn,aO as Nn,aP as zr,aQ as Ke,aR as Fn,aS as Ei,aT as qt,aU as Kt,aV as Ai,aW as He,aX as Je,aY as Un,aZ as $n,a_ as Fe,a$ as Xe,b0 as Mi,b1 as Vn,b2 as qn,b3 as Kn,b4 as cs,b5 as Gn,b6 as Pi,b7 as Br,b8 as ds,b9 as Ti,ba as _r,bb as Fr,bc as Ie,bd as te,be as Ee,bf as Ri,bg as Di,bh as Oi,bi as Li,bj as zi,bk as Wn,bl as Bi,bm as _i,bn as Ot,bo as Lt,bp as Ve,bq as At,br as Zs,bs as Fi,bt as Ui,bu as en,bv as rt,bw as Ur,bx as $i,by as Vi,bz as $r,bA as qi,bB as Hn,bC as Vr,bD as Ki,bE as Gi,bF as qr,bG as Be,bH as Kr,bI as Wi,bJ as tn,bK as Hi,bL as Jn,bM as Ji,bN as Yi,bO as Qi,bP as at,bQ as Xi,bR as Yn,bS as Qn,bT as Zi,bU as Xn,bV as el,bW as tl,bX as sl,bY as nl,bZ as _e,b_ as us,b$ as Gr,c0 as al,c1 as rl,c2 as ol,c3 as il,c4 as ll,c5 as cl,c6 as kn,c7 as dl,c8 as Wr,c9 as ul,ca as Zn,cb as ml,cc as Zt,cd as hl,ce as xl,cf as pl,g as fl,cg as sn,ch as Hr,ci as _t,cj as gl,ck as jl,cl as de,cm as ue,cn as es,co as Jr,cp as Cn,cq as vl,cr as ea,cs as ta,ct as sa,cu as bl,cv as yl,cw as wl,cx as Nl,cy as kl,cz as Cl,cA as Sl,cB as Il,cC as El,cD as Al,cE as Ml,cF as Pl,cG as na,cH as Yr,cI as Qr,cJ as Xr,cK as Zr,cL as Tl,cM as Rl,cN as kt,cO as Dl,cP as Ol,cQ as Ll,cR as zl,cS as Bl,cT as _l,cU as Fl,cV as eo,cW as Ul,cX as $l,cY as Vl,cZ as ql,c_ as Ht,c$ as Kl,d0 as Sn,d1 as to,d2 as so,d3 as In,d4 as no,d5 as ao,d6 as ro,d7 as oo,d8 as io,d9 as En,da as Gl,db as Wl,dc as Hl,dd as Jl,de as Yl,df as Ql,dg as Xl,dh as Zl,di as ec,dj as tc,dk as sc,dl as nc,dm as ac,dn as rc,dp as oc,dq as ic,dr as lo,ds as co,dt as uo,du as lc,dv as mo,dw as cc,dx as dc,dy as uc,dz as ho,dA as mc,dB as hc,dC as xc,dD as Jt,dE as pc,dF as fc,dG as gc,dH as jc,dI as et,dJ as vc,dK as xo,dL as bc,dM as ms,dN as yc,dO as wc,dP as Nc,dQ as kc,dR as Cc,dS as Sc,dT as Ic,dU as Ec,dV as Ac,dW as Mc,dX as Pc,dY as Tc,dZ as Rc,d_ as Dc,d$ as Oc,e0 as Lc,e1 as zc,e2 as Bc,e3 as _c,e4 as Fc,e5 as Uc,e6 as $c,e7 as Vc,e8 as qc}from"./globals-BwNQF72D.js";import{c as po}from"./cytoscape.esm-DzSz-X2X.js";import{f as Kc}from"./cytoscape-fcose-DVQaQP2R.js";const Gc=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Wc=Re("box",Gc);const Hc=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],Jc=Re("chart-column",Hc);const Yc=[["path",{d:"M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5",key:"4pqfef"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 12v-1",key:"1ej8lb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M8 7V6",key:"1nbb54"}],["circle",{cx:"8",cy:"20",r:"2",key:"ckkr5m"}]],Qc=Re("file-archive",Yc);const Xc=[["path",{d:"M14.364 13.634a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506l4.013-4.009a1 1 0 0 0-3.004-3.004z",key:"ukzhwg"}],["path",{d:"M14.487 7.858A1 1 0 0 1 14 7V2",key:"1klhew"}],["path",{d:"M20 19.645V20a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l2.516 2.516",key:"rxaxab"}],["path",{d:"M8 18h1",key:"13wk12"}]],Zc=Re("file-pen-line",Xc);const ed=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],td=Re("flag",ed);const sd=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],aa=Re("heart",sd);const nd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ad=Re("image",nd);const rd=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],od=Re("link-2",rd);const id=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],fo=Re("lock-keyhole",id);const ld=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],cd=Re("moon",ld);const dd=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],ud=Re("palette",dd);const md=[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]],hd=Re("shrink",md);const xd=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],pd=Re("sun",xd);const fd=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],go=Re("upload",fd);function gd(t){const{multiple:s=!1,defaultValue:a,value:n,onValueChange:r,autoComplete:o,...i}=t;return e.jsx(Fo,{...i,selectionMode:s?"multiple":"single",selectedValue:n,defaultSelectedValue:a,onSelectedValueChange:r,formAutoComplete:o})}const jd=u.forwardRef(function(s,a){const{selected:n}=Cr();return s.keepMounted||n?e.jsx(vd,{...s,ref:a}):null}),vd=u.memo(u.forwardRef((t,s)=>{const{render:a,className:n,style:r,keepMounted:o,...i}=t,{selected:c}=Cr(),d=u.useRef(null),{transitionStatus:x,setMounted:h}=Sr(c),p=hn("span",t,{ref:[s,d],state:{selected:c,transitionStatus:x},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:Er});return Ir({open:c,ref:d,onComplete(){c||h(!1)}}),p})),An=u.createContext({chipsRef:null,multiple:!1,rootRef:null});function bd(t){const s=u.useRef(null),a=u.useRef(null);return e.jsx(An.Provider,{value:{chipsRef:s,multiple:!!t.multiple,rootRef:a},children:e.jsx("div",{ref:a,className:"contents",children:e.jsx(gd,{...t})})})}function yd({className:t,showTrigger:s=!0,showClear:a=!1,startAddon:n,size:r,...o}){const{multiple:i}=u.useContext(An),c=r??"default";return i?e.jsx(zn,{className:V("min-w-12 flex-1 text-base outline-none sm:text-sm [[data-slot=combobox-chip]+&]:ps-0.5",c==="sm"?"ps-1.5":"ps-2",t),"data-size":typeof c=="string"?c:void 0,"data-slot":"combobox-input",size:typeof c=="number"?c:void 0,...o}):e.jsxs("div",{className:"relative w-full has-disabled:opacity-64",children:[n&&e.jsx("div",{"aria-hidden":"true",className:"[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 has-[+[data-size=sm]]:ps-[calc(--spacing(2.5)-1px)] [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4","data-slot":"combobox-start-addon",children:n}),e.jsx(zn,{className:V(n&&"data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7.5)-1px)] *:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]",c==="sm"?"has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-6.5":"has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-7",t),"data-slot":"combobox-input",render:e.jsx(K,{className:"has-disabled:opacity-100",size:c}),...o}),s&&e.jsx(wd,{className:V("-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",c==="sm"?"end-0":"end-0.5"),children:e.jsx(Uo,{})}),a&&e.jsx(Sd,{className:V("-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",c==="sm"?"end-0":"end-0.5"),children:e.jsx(wt,{})})]})}function wd({className:t,...s}){return e.jsx(Ho,{className:t,"data-slot":"combobox-trigger",...s})}function Nd({className:t,children:s,sideOffset:a=4,zIndex:n,...r}){const{chipsRef:o,rootRef:i}=u.useContext(An);let c=Qe.DROPDOWN;if(n!==void 0)c=n;else{const d=i?.current;d&&(d.closest('[data-slot="dialog-popup"] [data-slot="dialog-popup"]')?c=Qe.DROPDOWN_IN_NESTED_MODAL:d.closest('[data-slot="dialog-popup"]')&&(c=Qe.DROPDOWN_IN_MODAL))}return e.jsx($o,{children:e.jsx(Vo,{anchor:o,className:"select-none",style:{zIndex:c},"data-slot":"combobox-positioner",sideOffset:a,children:e.jsx("span",{className:V("relative flex max-h-full origin-(--transform-origin) rounded-lg border bg-popover bg-clip-padding transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-lg has-data-starting-style:scale-98 has-data-starting-style:opacity-0 dark:not-in-data-[slot=group]:bg-clip-border",t),children:e.jsx(qo,{className:"flex max-h-[min(var(--available-height),23rem)] w-(--anchor-width) max-w-(--available-width) flex-col","data-slot":"combobox-popup",...r,children:s})})})})}function kd({className:t,children:s,endAddon:a,...n}){return e.jsxs(Wo,{className:V("grid min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default grid-cols-[1rem_1fr_auto] items-center gap-2 rounded-sm py-1 ps-2 pe-4 text-base outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),"data-slot":"combobox-item",...n,children:[e.jsx(jd,{className:"col-start-1",children:e.jsx("svg",{"aria-hidden":"true",fill:"none",height:"24",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5.252 12.7 10.2 18.63 18.748 5.37"})})}),e.jsx("div",{className:"col-start-2",children:s}),a&&e.jsx("div",{className:"col-start-3 flex items-center",children:a})]})}function Cd({className:t,...s}){return e.jsx(Ko,{scrollbarGutter:!0,scrollFade:!0,children:e.jsx(Go,{className:V("not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1 in-data-has-overflow-y:pe-3",t),"data-slot":"combobox-list",...s})})}function Sd({className:t,...s}){return e.jsx(Jo,{className:t,"data-slot":"combobox-clear",...s})}function pt({label:t,value:s,onCommit:a,min:n=0,max:r=100,unit:o="%"}){const[i,c]=u.useState(s);return u.useEffect(()=>{c(s)},[s]),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(si,{min:n,max:r,value:i,onValueChange:d=>c(Array.isArray(d)?d[0]:d),onValueCommitted:d=>a(Array.isArray(d)?d[0]:d)}),e.jsxs("span",{className:"w-12 shrink-0 text-right text-sm text-muted-foreground",children:[i,o]})]})]})}function Id(){const{t}=B(),s=w(L=>L.backgroundImageEnabled),a=w(L=>L.setBackgroundImageEnabled),n=w(L=>L.backgroundSourceType),r=w(L=>L.setBackgroundSourceType),o=w(L=>L.backgroundImagePath),i=w(L=>L.setBackgroundImagePath),c=w(L=>L.backgroundFolderPath),d=w(L=>L.setBackgroundFolderPath),x=w(L=>L.backgroundUrlPath),h=w(L=>L.setBackgroundUrlPath),l=w(L=>L.backgroundRandomEnabled),p=w(L=>L.setBackgroundRandomEnabled),m=w(L=>L.backgroundRandomInterval),f=w(L=>L.setBackgroundRandomInterval),j=w(L=>L.backgroundOpacity),v=w(L=>L.setBackgroundOpacity),N=w(L=>L.backgroundBlur),b=w(L=>L.setBackgroundBlur),C=w(L=>L.backgroundBrightness),k=w(L=>L.setBackgroundBrightness),M=w(L=>L.backgroundSaturation),O=w(L=>L.setBackgroundSaturation),S=w(L=>L.backgroundComposerOpacity),y=w(L=>L.setBackgroundComposerOpacity),g=w(L=>L.backgroundCodeOpacity),E=w(L=>L.setBackgroundCodeOpacity),I=w(L=>L.backgroundSizeMode),D=w(L=>L.setBackgroundSizeMode),_=w(L=>L.bumpBackgroundRefresh),A=n==="file"?o:n==="folder"?c:x,[F,q]=u.useState(A);u.useEffect(()=>{q(A)},[A]);const W=u.useCallback(()=>{const L=F.trim();n==="file"?i(L):n==="folder"?d(L):h(L)},[F,n,i,d,h]),[R,G]=u.useState(m);u.useEffect(()=>{G(m)},[m]);const ne=async()=>{if(n==="folder"){const L=await window.electronAPI.dialog.selectDirectory();L&&d(L)}else{const L=await window.electronAPI.dialog.selectFile([...ei,...ti]);L&&i(L)}},xe=[{value:"file",label:t("Single image")},{value:"folder",label:t("Folder (random)")},{value:"url",label:t("Remote URL")}],U=[{value:"cover",label:t("Cover")},{value:"contain",label:t("Contain")},{value:"repeat",label:t("Repeat")},{value:"center",label:t("Center")}],se=t(n==="file"?"Image path":n==="folder"?"Folder path":"Image URL");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between border-t pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:t("Background image")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("Show a custom image behind the interface")})]}),e.jsx(ie,{checked:s,onCheckedChange:L=>a(L===!0)})]}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Source type")}),e.jsxs(Q,{items:xe,value:n,onValueChange:L=>r(L),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:xe.map(L=>e.jsx(H,{value:L.value,children:L.label},L.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:se}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:F,onChange:L=>q(L.target.value),onBlur:W,onKeyDown:L=>{L.nativeEvent.isComposing||L.key==="Enter"&&(W(),L.currentTarget.blur())},placeholder:n==="url"?"https://example.com/image.jpg":"",className:"flex-1"}),n!=="url"&&e.jsx(P,{variant:"outline",size:"icon",onClick:ne,"aria-label":t("Browse"),children:n==="folder"?e.jsx(Pr,{className:"h-4 w-4"}):e.jsx(ad,{className:"h-4 w-4"})}),n!=="file"&&e.jsx(P,{variant:"outline",size:"icon",onClick:_,"aria-label":t("Refresh now"),children:e.jsx(Dt,{className:"h-4 w-4"})})]})]}),n!=="file"&&e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Auto switch")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{checked:l,onCheckedChange:L=>p(L===!0)}),l&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"number",min:5,max:86400,value:R,onChange:L=>G(Number(L.target.value)),onBlur:()=>f(R),onKeyDown:L=>{L.key==="Enter"&&(f(R),L.currentTarget.blur())},className:"w-24"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("seconds")})]})]})]}),e.jsx(pt,{label:t("Background visibility"),value:Math.round(j*100),onCommit:L=>v(L/100)}),e.jsx(pt,{label:t("Blur"),value:N,onCommit:b,max:20,unit:"px"}),e.jsx(pt,{label:t("Brightness"),value:Math.round(C*100),onCommit:L=>k(L/100),max:200}),e.jsx(pt,{label:t("Saturation"),value:Math.round(M*100),onCommit:L=>O(L/100),max:200}),e.jsx(pt,{label:t("Composer opacity"),value:Math.round(S*100),onCommit:L=>y(L/100)}),e.jsx(pt,{label:t("Code block opacity"),value:Math.round(g*100),onCommit:L=>E(L/100)}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Size mode")}),e.jsxs(Q,{items:U,value:I,onValueChange:L=>D(L),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:U.map(L=>e.jsx(H,{value:L.value,children:L.label},L.value))})]})]})]})]})}function Ed({theme:t,fontSize:s,fontFamily:a,fontWeight:n}){const r=[{id:"prompt1",text:"$ ",color:t.green},{id:"cmd1",text:"ls -la",color:t.foreground},{id:"nl1",text:`
2
2
  `},{id:"perm1",text:"drwxr-xr-x ",color:t.blue},{id:"meta1",text:"5 user staff 160 Dec 23 ",color:t.foreground},{id:"dir1",text:"Documents",color:t.cyan},{id:"nl2",text:`
3
3
  `},{id:"perm2",text:"-rw-r--r-- ",color:t.foreground},{id:"meta2",text:"1 user staff 2048 Dec 22 ",color:t.foreground},{id:"file1",text:"config.json",color:t.yellow},{id:"nl3",text:`
4
4
 
@@ -6,7 +6,7 @@ import{c as Re,j as e,A as Fo,r as u,u as Cr,a as Sr,b as hn,d as Ir,t as Er,C a
6
6
  `},{id:"output1",text:"Hello, World!",color:t.magenta}];return e.jsxs("div",{className:"rounded-lg border p-4 h-40 overflow-auto",style:{backgroundColor:t.background,fontSize:`${s}px`,fontFamily:a,fontWeight:n},children:[r.map(o=>o.text===`
7
7
  `?e.jsx("br",{},o.id):o.text===`
8
8
 
9
- `?e.jsxs(u.Fragment,{children:[e.jsx("br",{}),e.jsx("br",{})]},o.id):e.jsx("span",{style:{color:o.color},children:o.text},o.id)),e.jsx("span",{className:"inline-block w-2 h-4 animate-pulse",style:{backgroundColor:t.cursor}})]})}function Ad({isFavorite:t,onClick:s,ariaLabel:a}){return e.jsx("button",{type:"button","aria-label":a,"aria-pressed":t,onClick:n=>{n.stopPropagation(),n.preventDefault(),s(n)},className:"p-1 hover:text-red-500 transition-colors",children:t?e.jsx(aa,{className:"h-4 w-4 fill-red-500 text-red-500"}):e.jsx(aa,{className:"h-4 w-4"})})}function Md({value:t,onValueChange:s,themes:a,favoriteThemes:n,onToggleFavorite:r,onThemeHover:o,showFavoritesOnly:i,onShowFavoritesOnlyChange:c,showEmptyFavoritesHint:d}){const{t:x}=B(),[h,l]=u.useState(t),[p,m]=u.useState(t),[f,j]=u.useState(!1),v=u.useRef(void 0),N=u.useRef(null),b=u.useRef(t),C=u.useRef(!1),k=u.useMemo(()=>new Set(n),[n]);u.useEffect(()=>{f||(l(t),m(t))},[t,f]);const M=u.useMemo(()=>{if(!p||p===h)return a;const E=p.toLowerCase();return a.filter(I=>I.toLowerCase().includes(E))},[a,p,h]),O=E=>{E&&(C.current=!0,l(E),m(E)),s(E)},S=E=>{j(E),E?(b.current=t,C.current=!1,l(t),m(t)):C.current||o?.(b.current)},y=E=>{clearTimeout(v.current),v.current=setTimeout(()=>{o?.(E)},50)},g=()=>{clearTimeout(v.current)};return u.useEffect(()=>{if(!f)return;const E=I=>{(I.key==="ArrowDown"||I.key==="ArrowUp")&&requestAnimationFrame(()=>{const D=N.current?.querySelector("[data-highlighted]");if(D){const _=D.getAttribute("data-value");_&&o?.(_)}})};return document.addEventListener("keydown",E,!0),()=>{document.removeEventListener("keydown",E,!0)}},[f,o]),u.useEffect(()=>()=>{clearTimeout(v.current)},[]),e.jsxs(bd,{value:h,onValueChange:O,inputValue:p,onInputValueChange:m,open:f,onOpenChange:S,children:[e.jsxs("div",{className:"relative",children:[e.jsx(yd,{placeholder:x("Search themes...")}),e.jsxs("div",{className:"absolute right-8 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx(We,{id:"show-favorites-only-inner",checked:i,onCheckedChange:E=>c(E===!0),onClick:E=>E.stopPropagation()}),e.jsx("label",{htmlFor:"show-favorites-only-inner",className:"text-xs text-muted-foreground cursor-pointer whitespace-nowrap",onClick:E=>E.stopPropagation(),onKeyDown:E=>E.stopPropagation(),children:x("Show favorites only")})]})]}),e.jsx(Nd,{children:e.jsxs(Cd,{ref:N,children:[M.length===0&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:x(d?"No favorite themes yet. Click the heart icon to add favorites.":"No themes found")}),M.map(E=>e.jsx(kd,{value:E,"data-value":E,onMouseEnter:()=>y(E),onMouseLeave:g,endAddon:e.jsx(Ad,{isFavorite:k.has(E),onClick:()=>r(E),ariaLabel:k.has(E)?x("Remove from favorites"):x("Add to favorites")}),children:E},E))]})})]})}const Pd={violet:"oklch(0.54 0.2 280)",indigo:"oklch(0.53 0.19 265)",teal:"oklch(0.56 0.1 185)",amber:"oklch(0.64 0.16 55)",graphite:"oklch(0.27 0.01 285)"},Td={violet:"Violet",indigo:"Indigo",teal:"Teal",amber:"Amber",graphite:"Graphite"};function Rd(){const{theme:t,setTheme:s,accentColor:a,setAccentColor:n,terminalTheme:r,setTerminalTheme:o,terminalFontSize:i,setTerminalFontSize:c,terminalFontFamily:d,setTerminalFontFamily:x,terminalFontWeight:h,setTerminalFontWeight:l,terminalFontWeightBold:p,setTerminalFontWeightBold:m,favoriteTerminalThemes:f,toggleFavoriteTerminalTheme:j}=w(),{t:v}=B(),N=[{value:"light",icon:pd,label:v("Light")},{value:"dark",icon:cd,label:v("Dark")},{value:"system",icon:xn,label:v("System")},{value:"sync-terminal",icon:Ar,label:v("Sync terminal theme")}],b=Yo.map(R=>({value:R,label:v(Td[R]),swatch:Pd[R]})),[C,k]=u.useState(i),[M,O]=u.useState(d),[S,y]=u.useState(!1);u.useEffect(()=>{k(i)},[i]),u.useEffect(()=>{O(d)},[d]);const g=u.useCallback(()=>{const R=Math.max(8,Math.min(32,C||8));R!==C&&k(R),R!==i&&c(R)},[C,i,c]),E=u.useCallback(()=>{const R=M.trim()||d;R!==M&&O(R),R!==d&&x(R)},[M,d,x]),I=u.useMemo(()=>Qo(),[]),D=u.useMemo(()=>{if(!S)return I;const R=I.filter(G=>f.includes(G));return f.includes(r)?R:[r,...R]},[I,S,f,r]),_=S&&f.length===0,A=u.useMemo(()=>Zo(r)??Xo,[r]),F=R=>{R&&o(R)},q=()=>{const R=S?D:I,G=R.indexOf(r),ne=G<=0?R.length-1:G-1;o(R[ne])},W=()=>{const R=S?D:I,G=R.indexOf(r),ne=G>=R.length-1?0:G+1;o(R[ne])};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{"data-settings-row":"appearance.theme",children:[e.jsx("h3",{className:"text-lg font-medium",children:v("Theme mode")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v("Choose interface theme")})]}),e.jsx("div",{className:"grid grid-cols-4 gap-3",children:N.map(R=>e.jsxs("button",{type:"button",onClick:()=>s(R.value),className:V("flex flex-col items-center gap-2 rounded-lg border-2 p-3 transition-colors",t===R.value?"border-primary bg-accent text-accent-foreground":"border-transparent bg-muted/50 hover:bg-muted"),children:[e.jsx("div",{className:V("flex h-10 w-10 items-center justify-center rounded-full",t===R.value?"bg-accent-foreground/20 text-accent-foreground":"bg-muted"),children:e.jsx(R.icon,{className:"h-5 w-5"})}),e.jsx("span",{className:"text-sm font-medium",children:R.label})]},R.value))}),e.jsxs("div",{"data-settings-row":"appearance.accent",children:[e.jsx("h3",{className:"text-lg font-medium",children:v("Accent color")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v("Highlight color used across the interface")})]}),e.jsx("div",{className:"flex items-center gap-3",children:b.map(R=>e.jsx("button",{type:"button",onClick:()=>n(R.value),title:R.label,"aria-label":R.label,"aria-pressed":a===R.value,style:{backgroundColor:R.swatch},className:V("size-6 rounded-full transition-shadow",a===R.value&&"ring-2 ring-offset-2 ring-offset-background ring-foreground/60")},R.value))}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-medium",children:v("Terminal")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v("Terminal appearance")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:v("Preview")}),e.jsx(Ed,{theme:A,fontSize:C,fontFamily:M,fontWeight:h})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Color scheme")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"outline",size:"icon",onClick:q,children:e.jsx(Mr,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1",children:e.jsx(Md,{value:r,onValueChange:F,themes:D,favoriteThemes:f,onToggleFavorite:j,onThemeHover:o,showFavoritesOnly:S,onShowFavoritesOnlyChange:y,showEmptyFavoritesHint:_})}),e.jsx(P,{variant:"outline",size:"icon",onClick:W,children:e.jsx(Rt,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Font")}),e.jsx(K,{value:M,onChange:R=>O(R.target.value),onBlur:E,onKeyDown:R=>{R.nativeEvent.isComposing||R.key==="Enter"&&(E(),R.currentTarget.blur())},placeholder:"JetBrains Mono, monospace"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Font size")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{type:"number",value:C,onChange:R=>k(Number(R.target.value)),onBlur:g,onKeyDown:R=>{R.key==="Enter"&&(g(),R.currentTarget.blur())},min:8,max:32,className:"w-20"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"px"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Font weight")}),e.jsxs(Q,{items:Bt,value:h,onValueChange:R=>l(R),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:Bt.map(R=>e.jsx(H,{value:R.value,children:R.label},R.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Bold font weight")}),e.jsxs(Q,{items:Bt,value:p,onValueChange:R=>m(R),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:Bt.map(R=>e.jsx(H,{value:R.value,children:R.label},R.value))})]})]}),e.jsx(Id,{})]})}function Dd(t){return/^\//.test(t)||/^[A-Za-z]:[\\/]/.test(t)||/^\\\\[^\\]/.test(t)}function nn({className:t,render:s,...a}){const n={className:V("inline-flex items-center gap-2 text-base/4.5 sm:text-sm/4 font-medium",t),"data-slot":"label"};return ni({defaultTagName:"label",props:ai(n,a),render:s})}const an={checked(t){return t?{"data-checked":""}:{"data-unchecked":""}},...Er,...Tr},jo=u.createContext(void 0);function Od(){return u.useContext(jo)}const vo=u.createContext(void 0);function Ld(){const t=u.useContext(vo);if(t===void 0)throw new Error(ri(52));return t}const zd=u.forwardRef(function(s,a){const{render:n,className:r,disabled:o=!1,readOnly:i=!1,required:c=!1,"aria-labelledby":d,value:x,inputRef:h,nativeButton:l=!1,id:p,style:m,...f}=s,j=Od(),{disabled:v,readOnly:N,required:b,form:C,checkedValue:k,touched:M=!1,validation:O,name:S,setCheckedValue:y=is,setTouched:g=is,registerInputRef:E=is}=j??{},{setTouched:I,setFilled:D,state:_,disabled:A}=Rr(),F=oi(),{labelId:q,getDescriptionProps:W}=Dr(),R=A||F.disabled||v||o,G=N||i,ne=b||c,xe=C,U=j?k===x:x==="",se=u.useRef(null),L=u.useRef(null),me=O?.registerInput,oe=u.useCallback(he=>me?.(he,{controlRef:se,value:void 0}),[me]),ce=ii(h,L,E,oe);Bn(()=>{L.current?.checked&&D(!0)},[D]),Bn(()=>{if(L.current){if(R&&U){E(null);return}E(L.current)}},[U,R,E]);const le=Or(),ge=li({id:p,implicit:!1,controlRef:se}),z=l?void 0:ge,Y=ci(d,q,L,!l,z),ae={role:"radio","aria-checked":U,"aria-labelledby":Y,[fi]:U?"":void 0,id:l?ge:le,onKeyDown(he){he.key==="Enter"&&he.preventDefault()},onClick(he){if(he.defaultPrevented||R||G)return;he.preventDefault();const Ze=L.current;Ze&&pi(Ze,he)},onFocus(he){he.defaultPrevented||R||G||!M||(L.current?.click(),g(!1))}},{getButtonProps:be,buttonRef:J}=di({disabled:R,native:l,composite:!1}),je={type:"radio",ref:ce,form:xe,id:z,name:S,tabIndex:-1,style:S?hi:xi,"aria-hidden":!0,...x!==void 0?{value:ui(x)}:_n,disabled:R,checked:U,required:ne,readOnly:G,onChange(he){if(he.nativeEvent.defaultPrevented||R||G||x===void 0)return;const Ze=gi(ji,he.nativeEvent);y(x,Ze),!Ze.isCanceled&&I(!0)},onClick(he){he.stopPropagation()},onFocus(){se.current?.focus()}},Te=u.useMemo(()=>({..._,required:ne,disabled:R,readOnly:G,checked:U}),[_,R,G,U,ne]),mt=Te,$=j!==void 0,ye=[a,se,J],ve=[ae,f,be,W,O?he=>O.getValidationProps(R,he):_n],Oe=hn("span",s,{enabled:!$,state:Te,ref:ye,props:ve,stateAttributesMapping:an});return e.jsxs(vo.Provider,{value:mt,children:[$?e.jsx(mi,{tag:"span",render:n,className:r,style:m,state:Te,refs:ye,props:ve,stateAttributesMapping:an}):Oe,e.jsx("input",{...je,suppressHydrationWarning:!0})]})}),Bd=u.forwardRef(function(s,a){const{render:n,className:r,style:o,keepMounted:i=!1,...c}=s,d=Ld(),x=d.checked,{mounted:h,transitionStatus:l,setMounted:p}=Sr(x),m={...d,transitionStatus:l},f=u.useRef(null),j=i||h,v=hn("span",s,{ref:[a,f],state:m,props:c,stateAttributesMapping:an});return Ir({open:x,ref:f,onComplete(){x||p(!1)}}),j?v:null}),_d=[Si],Fd=u.forwardRef(function(s,a){const{render:n,className:r,disabled:o,readOnly:i,required:c,onValueChange:d,value:x,defaultValue:h,form:l,name:p,inputRef:m,id:f,style:j,...v}=s,{setTouched:N,setFocused:b,validationMode:C,name:k,disabled:M,state:O,validation:S,setDirty:y,setFilled:g,validityData:E}=Rr(),{labelId:I}=Dr(),{clearErrors:D,elementRef:_}=vi(),A=bi(!0),F=M||o,q=k??p,W=Or(f),[R,G]=yi({controlled:x,default:h,name:"RadioGroup",state:"value"}),[ne,xe]=u.useState(!1),U=ls((J,je)=>{d?.(J,je),!je.isCanceled&&G(J)}),se=S.getInputControl,L=u.useMemo(()=>({get current(){return se()}}),[se]),me=u.useRef(null),oe=u.useRef(null);function ce(J){let je;return m&&(typeof m=="function"?je=m(J):m.current=J),me.current=J,je}const le=ls(J=>{if(!J||J.disabled)return;oe.current||(oe.current=J);const je=me.current,Te=J.checked||je==null||je.disabled?ce(J):void 0;return()=>{oe.current===J&&(oe.current=null),me.current===J?Te?(Te(),me.current=null):ce(null):Te?.()}}),ge=ls(()=>{const J=_.current;if(!J)return R??null;for(const je of S.registeredInputs.keys())if(je.checked&&wi(je,J))return R??null;return null});Ni(L,W,R??null,ge,!F,p),ki(R,()=>{D(q),y(R!==E.initialValue),g(R!=null),S.change(R);const J=oe.current;R==null&&J&&!J.disabled&&ce(J)});const z=I??A?.legendId,Y={...O,disabled:F??!1,required:c??!1,readOnly:i??!1},ae=u.useMemo(()=>({checkedValue:R,disabled:F,form:l,validation:S,name:q,readOnly:i,registerInputRef:le,required:c,setCheckedValue:U,setTouched:xe,touched:ne}),[R,F,l,S,q,i,le,c,U,xe,ne]),be={id:f,role:"radiogroup","aria-required":c||void 0,"aria-disabled":F||void 0,"aria-readonly":i||void 0,"aria-labelledby":z,onFocus(){b(!0)},onBlur(J){Ii(J.currentTarget,J.relatedTarget)||(N(!0),b(!1),C==="onBlur"&&S.commit(R))},onKeyDownCapture(J){J.key.startsWith("Arrow")&&(xe(!0),b(!0))}};return e.jsx(jo.Provider,{value:ae,children:e.jsx(Ci,{render:n,className:r,style:j,state:Y,props:[be,v,J=>S.getValidationProps(F??!1,J)],refs:[a],stateAttributesMapping:Tr,enableHomeAndEndKeys:!1,modifierKeys:_d})})});function Ud({className:t,...s}){return e.jsx(Fd,{className:V("flex flex-col gap-3",t),"data-slot":"radio-group",...s})}function ra({className:t,...s}){return e.jsx(zd,{className:V("relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-full border border-input bg-background bg-clip-padding shadow-xs outline-none transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-full not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none",t),"data-slot":"radio",...s,children:e.jsx(Bd,{className:"-inset-px absolute flex size-4.5 items-center justify-center rounded-full before:size-2 before:rounded-full before:bg-primary-foreground data-unchecked:hidden data-checked:bg-primary sm:size-4 sm:before:size-1.5","data-slot":"radio-indicator"})})}const $d=[{category:"providers",label:"Model Providers"},{category:"presets",label:"Presets"},{category:"agentTypes",label:"Agent types"},{category:"skills",label:"Skills"},{category:"mcpServers",label:"MCP Servers"},{category:"instructions",label:"Instruction Files"},{category:"subagentModels",label:"Subagent Models"},{category:"settings",label:"Scalar settings"}];function Vd(){const{t}=B(),[s,a]=u.useState(!1),[n,r]=u.useState(!1),[o,i]=u.useState(null),[c,d]=u.useState(null),x=()=>{i(null),a(!0)},h=async()=>{r(!0),i(null);try{const l=await window.electronAPI.configSync.openImport();if(!l.ok){i({kind:l.cancelled?"cancelled":"error",text:l.cancelled?t("Import cancelled."):t(l.error)});return}d(l)}catch{i({kind:"error",text:t("Could not open configuration package.")})}finally{r(!1)}};return e.jsxs("section",{className:"space-y-3","data-settings-row":"general.configSync",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("Configuration transfer")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Move models, presets, agent types, skills, MCP servers and instruction files between devices.")})]}),e.jsxs("div",{className:"rounded-md border px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(Qc,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:t("Portable Enso configuration")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Export a package or preview one before importing it.")})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs(P,{variant:"outline",size:"sm",disabled:n,onClick:h,children:[n?e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(pn,{className:"h-3.5 w-3.5"}),t("Import configuration")]}),e.jsxs(P,{size:"sm",disabled:n,onClick:x,children:[e.jsx(go,{className:"h-3.5 w-3.5"}),t("Export configuration")]})]})]}),e.jsxs("div",{className:"mt-3 flex items-start gap-2 border-t pt-3 text-xs text-muted-foreground",children:[e.jsx(Wt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("p",{children:t("OAuth login sessions are never transferred. Skill, instruction, and system prompt contents require an encrypted export.")})]}),o&&e.jsx("p",{className:o.kind==="error"?"mt-2 text-xs text-destructive":"mt-2 text-xs text-muted-foreground",role:o.kind==="error"?"alert":"status",children:o.text})]}),e.jsx(qd,{open:s,onOpenChange:a}),c&&e.jsx(Kd,{file:c,onClose:()=>d(null)})]})}function qd({open:t,onOpenChange:s}){const{t:a}=B(),[n,r]=u.useState(!1),[o,i]=u.useState(""),[c,d]=u.useState(""),[x,h]=u.useState(!1),[l,p]=u.useState(null),[m,f]=u.useState(!1),[j,v]=u.useState(null),[N,b]=u.useState([]);u.useEffect(()=>{t&&(r(!1),i(""),d(""),h(!1),p(null),f(!1),v(null),b([]))},[t]);const C=()=>{x||(i(""),d(""),s(!1))},k=async()=>{if(n&&o.length<8){p(a("Password must be at least 8 characters."));return}if(n&&o!==c){p(a("Passwords do not match."));return}h(!0),p(null),f(!1);try{const M=await window.electronAPI.configSync.exportConfig({includeSecrets:n,...n?{password:o}:{}});if(i(""),d(""),!M.ok){M.cancelled?f(!0):p(a(M.error));return}v(M.filePath),b(M.skippedInstructions??[])}catch{i(""),d(""),p(a("Could not export configuration."))}finally{h(!1)}};return e.jsx(we,{open:t,onOpenChange:M=>!M&&C(),children:e.jsxs(Ne,{className:"max-w-xl",showCloseButton:!x,children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:a("Export configuration")}),e.jsx($e,{children:a("Create a portable .enso-config package for another device.")})]}),e.jsx(Pe,{className:"max-h-[55vh] space-y-4",children:j?e.jsxs(e.Fragment,{children:[e.jsxs(Le,{variant:"success",children:[e.jsx(Lr,{}),e.jsx(bt,{children:a("Configuration exported")}),e.jsxs(ze,{children:[e.jsx("p",{children:a("Saved package:")}),e.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:j})]})]}),N.length>0&&e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsxs(ze,{children:[e.jsx("p",{children:a("These instructions were skipped because their source files are missing or unreadable:")}),e.jsx("p",{className:"break-all text-foreground",children:N.join(", ")})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Le,{variant:"warning",children:[e.jsx(fn,{}),e.jsx(bt,{children:a("File contents can be private")}),e.jsx(ze,{children:a("Skill and instruction file contents may contain private data, so configurations containing them can only be exported with encryption.")})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-md border px-3 py-2.5",children:[e.jsx(We,{checked:n,onCheckedChange:M=>{const O=M===!0;r(O),p(null),O||(i(""),d(""))}}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:a("Include sensitive configuration")}),e.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:a("Encrypt the entire package with a password. OAuth login sessions are still excluded.")})]})]}),!n&&e.jsxs(Le,{variant:"info",children:[e.jsx(Wt,{}),e.jsx(ze,{children:a("API keys, provider account links, MCP arguments and environment values, plus credentials and private URL parts in MCP endpoints, will be omitted. Configurations containing skill or instruction files require encryption.")})]}),n&&e.jsxs("div",{className:"space-y-3 rounded-md border px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(fo,{className:"h-4 w-4 text-muted-foreground"}),a("Encryption password")]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(nn,{htmlFor:"config-export-password",children:a("Password")}),e.jsx(K,{id:"config-export-password",type:"password",autoComplete:"new-password",value:o,"aria-invalid":!!(l&&o.length<8),onChange:M=>{i(M.target.value),p(null)}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(nn,{htmlFor:"config-export-confirmation",children:a("Confirm password")}),e.jsx(K,{id:"config-export-confirmation",type:"password",autoComplete:"new-password",value:c,"aria-invalid":!!(l&&c!==o),onChange:M=>{d(M.target.value),p(null)}})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("Use at least 8 characters. This password cannot be recovered.")})]}),m&&e.jsx("p",{className:"text-xs text-muted-foreground",role:"status",children:a("Export cancelled.")}),l&&e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[e.jsx(Nt,{className:"h-3.5 w-3.5 shrink-0"}),l]})]})}),e.jsx(Se,{children:j?e.jsx(P,{size:"sm",onClick:C,children:a("Done")}):e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",disabled:x,onClick:C,children:a("Cancel")}),e.jsxs(P,{size:"sm",disabled:x,onClick:()=>{k()},children:[x?e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(go,{className:"h-3.5 w-3.5"}),a(x?"Exporting…":"Export")]})]})})]})})}function Kd({file:t,onClose:s}){const{t:a}=B(),[n,r]=u.useState(t.encrypted?"password":"preview"),[o,i]=u.useState(""),[c,d]=u.useState("merge"),[x,h]=u.useState(null),[l,p]=u.useState([]),[m,f]=u.useState(null),[j,v]=u.useState(!1),[N,b]=u.useState(null),[C,k]=u.useState(null),[M,O]=u.useState(!1),S=u.useRef(0),y=u.useCallback(async(A,F)=>{const q=++S.current;b("preview"),k(null),h(null),p([]);try{const W=await window.electronAPI.configSync.previewImport({token:t.token,mode:A,...F?{password:F}:{}});if(q!==S.current)return;if(i(""),!W.ok){k(a(W.error));return}d(W.mode),h(W.summary),p(W.warnings),r("preview")}catch{q===S.current&&(i(""),k(a("Could not preview configuration package.")))}finally{q===S.current&&b(null)}},[t.token,a]);u.useEffect(()=>{t.encrypted||y("merge")},[t.encrypted,y]);const g=()=>{N||(S.current+=1,O(!1),i(""),window.electronAPI.configSync.cancelImport(t.token).catch(()=>{}),s())},E=A=>{A===c||N||(d(A),y(A))},I=!!x?.some(A=>(A.category==="skills"||A.category==="mcpServers")&&A.added+A.updated+A.skipped>0),D=x!==null,_=async()=>{if(x){b("commit"),k(null);try{const A=await window.electronAPI.configSync.commitImport({token:t.token,mode:c});if(!A.ok){h(null),p([]),k(a(A.error));return}i("");try{await w.persist.rehydrate()}catch{v(!0)}p(A.warnings),f(A.backupPath),r("success")}catch{h(null),p([]),k(a("Could not import configuration."))}finally{b(null)}}};return e.jsxs(we,{open:!0,onOpenChange:A=>!A&&g(),children:[e.jsxs(Ne,{className:"max-w-2xl",showCloseButton:N===null,children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:a(n==="success"?"Configuration imported":"Import configuration")}),e.jsx($e,{children:n==="success"?a(j?"Configuration was imported, but this window could not refresh automatically.":"This window has been refreshed with the imported settings."):a("Review {{fileName}} before changing this device.",{fileName:t.fileName})})]}),n==="password"&&e.jsxs(Pe,{className:"space-y-4",children:[e.jsxs(Le,{variant:"info",children:[e.jsx(fo,{}),e.jsx(bt,{children:a("Encrypted configuration package")}),e.jsx(ze,{children:a("Enter the export password to decrypt and preview this package.")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(nn,{htmlFor:"config-import-password",children:a("Password")}),e.jsx(K,{id:"config-import-password",type:"password",autoFocus:!0,autoComplete:"current-password",value:o,"aria-invalid":!!C,onChange:A=>{i(A.target.value),k(null)},onKeyDown:A=>{A.key==="Enter"&&o.length>0&&!N&&y("merge",o)}})]}),C&&e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[e.jsx(Nt,{className:"h-3.5 w-3.5 shrink-0"}),C]})]}),n==="preview"&&e.jsxs(Pe,{className:"max-h-[58vh] space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:a("Import mode")}),e.jsxs(Ud,{value:c,onValueChange:A=>E(A),className:"grid gap-2 sm:grid-cols-2","aria-label":a("Import mode"),children:[e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2.5",children:[e.jsx(ra,{value:"merge",disabled:N!==null}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:a("Merge")}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:a("Add and update matching items while keeping items only on this device.")})]})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2.5",children:[e.jsx(ra,{value:"replace",disabled:N!==null}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:a("Replace")}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:a("Replace transferred item categories, removing local-only items in them.")})]})]})]})]}),N==="preview"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 rounded-md border border-dashed py-10",children:[e.jsx(Me,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:a("Preparing preview…")})]}),!N&&x&&e.jsx("div",{className:"overflow-hidden rounded-md border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-3 py-2 text-left font-medium",children:a("Category")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Added")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Updated")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Skipped")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Removed")})]})}),e.jsx("tbody",{children:$d.map(({category:A,label:F})=>{const q=x.find(W=>W.category===A);return e.jsxs("tr",{className:"border-t first:border-t-0",children:[e.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-medium",children:a(F)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.added??0}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.updated??0}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.skipped??0}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.removed??0})]},A)})})]})}),!N&&x?.find(A=>A.category==="settings")?.fields?.length?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a("Portable settings changed:")," ",x.find(A=>A.category==="settings")?.fields?.join(", ")]}):null,c==="replace"&&x&&!N&&e.jsxs(Le,{variant:"error",children:[e.jsx(Ue,{}),e.jsx(bt,{children:a("Local-only configuration will be deleted")}),e.jsx(ze,{children:a("Items in transferred collections that exist only on this device will be removed. Removed counts are shown above. Included portable preferences are overwritten. A complete backup is created first.")})]}),l.map(A=>e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsx(ze,{children:a(A)})]},A)),x&&!N&&e.jsxs(Le,{variant:"warning",children:[e.jsx(fn,{}),e.jsx(bt,{children:a("Only import packages you trust")}),e.jsx(ze,{children:a("An imported package can change portable preferences and configuration. Skills and MCP servers may also run commands later when you use them. Previewing does not execute them; continue only if you trust the package.")})]}),C&&e.jsxs(Le,{variant:"error",children:[e.jsx(Nt,{}),e.jsx(ze,{children:C})]})]}),n==="success"&&m&&e.jsxs(Pe,{className:"space-y-4",children:[e.jsxs(Le,{variant:"success",children:[e.jsx(Lr,{}),e.jsx(bt,{children:a("Import complete")}),e.jsxs(ze,{children:[e.jsx("p",{children:a("Backup of previous settings:")}),e.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:m})]})]}),j&&e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsx(ze,{children:a("Reopen Settings to load the imported configuration in this window.")})]}),l.map(A=>e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsx(ze,{children:a(A)})]},A))]}),e.jsxs(Se,{children:[n==="password"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",disabled:N!==null,onClick:g,children:a("Cancel")}),e.jsxs(P,{size:"sm",disabled:N!==null||o.length===0,onClick:()=>{y("merge",o)},children:[N==="preview"&&e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}),a("Preview")]})]}),n==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",disabled:N!==null,onClick:g,children:a("Cancel")}),C&&!x?e.jsx(P,{size:"sm",disabled:N!==null,onClick:()=>{y(c)},children:a("Refresh preview")}):e.jsxs(P,{variant:c==="replace"?"destructive":"default",size:"sm",disabled:N!==null||!x,onClick:()=>{x&&(D?O(!0):_())},children:[N==="commit"?e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(pn,{className:"h-3.5 w-3.5"}),a(N==="commit"?"Importing…":"Import")]})]}),n==="success"&&e.jsx(P,{size:"sm",onClick:g,children:a("Done")})]})]}),e.jsx(Gd,{open:M,mode:c,hasImportedExecutableResources:I,onOpenChange:O,onConfirm:()=>{_()}})]})}function Gd({open:t,mode:s,hasImportedExecutableResources:a,onOpenChange:n,onConfirm:r}){const{t:o}=B();return e.jsx(gn,{open:t,onOpenChange:n,children:e.jsxs(jn,{className:"sm:max-w-md",zIndexLevel:"nested",children:[e.jsxs(vn,{children:[e.jsxs(bn,{className:"flex items-start gap-2 text-base",children:[e.jsx(Ue,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),o("Confirm configuration import")]}),e.jsxs(yn,{className:"space-y-2",children:[e.jsx("span",{className:"block",children:o("This package can change portable preferences and configuration. Continue only if you trust this package.")}),a&&e.jsx("span",{className:"block",children:o("It includes skills or MCP servers that may execute commands when you use them.")}),s==="replace"&&e.jsx("span",{className:"block",children:o("Replace mode removes local-only items from transferred collections and overwrites included portable preferences. A complete backup will be created first.")}),e.jsx("span",{className:"block",children:o("Do you want to continue with this import?")})]})]}),e.jsxs(wn,{variant:"bare",children:[e.jsx(Nn,{render:e.jsx(P,{variant:"outline",size:"sm"}),children:o("Cancel")}),e.jsx(P,{variant:s==="replace"?"destructive":"default",size:"sm",onClick:()=>{n(!1),r()},children:o("Confirm import")})]})]})})}function Wd(){const{t}=B(),s=w(m=>m.contextMenuOpen),a=w(m=>m.setContextMenuOpen),[n,r]=u.useState(!1),[o,i]=u.useState(!1),c=m=>m.target==="reveal"?t("File manager"):m.target==="vscode"?t("VS Code"):m.applicationPath.split(/[/\\]/).at(-1)?.replace(/\.(exe|app)$/i,"")||m.applicationPath,d=s.filter(m=>m.enabled).map(c),x=d.length?`${d.slice(0,2).join(", ")}${d.length>2?` +${d.length-2}`:""}`:t("No opening methods enabled"),h=m=>{if(m.length>32){Ke({type:"error",title:t("Context menu opening"),description:t("You can configure up to 32 opening methods.")});return}a(m)},l=(m,f)=>{const j=w.getState().contextMenuOpen;a(j.map(v=>v.id===m.id?{...v,enabled:f}:v))},p=async()=>{i(!0);try{const m=await window.electronAPI.dialog.selectFile();if(!m)return;if(!zr(m)){Ke({type:"error",title:t("Context menu opening"),description:t("The selected application path is invalid.")});return}const f=w.getState().contextMenuOpen,j=Fn(m),v=f.find(N=>N.target==="application"&&Fn(N.applicationPath)===j);if(v){h(f.map(N=>N.id===v.id?{...N,enabled:!0}:N));return}h([...f,{id:crypto.randomUUID(),target:"application",applicationPath:m,enabled:!0}])}catch(m){Ke({type:"error",title:t("Context menu opening"),description:m instanceof Error?m.message:String(m)})}finally{i(!1)}};return e.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h5",{className:"text-sm font-medium",children:t("Context menu opening")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>r(!0),children:t("Configure list")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Select the opening methods shown in file link context menus. You can add multiple applications.")}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:d.join(", "),children:x}),e.jsx(we,{open:n,onOpenChange:r,children:e.jsxs(Ne,{zIndexLevel:"nested",children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:t("Context menu opening")}),e.jsx($e,{children:t("Select the opening methods shown in file link context menus. You can add multiple applications.")})]}),e.jsxs(Pe,{className:"space-y-2",children:[s.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:t("No opening methods enabled")}),s.map(m=>{const f=c(m);return e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-3",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-3",children:[e.jsx(We,{checked:m.enabled,disabled:o,"aria-label":f,onCheckedChange:j=>l(m,j)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm",title:f,children:f}),m.target==="application"&&e.jsx("span",{className:"block truncate text-xs text-muted-foreground",title:m.applicationPath,children:m.applicationPath})]})]}),e.jsx(P,{variant:"ghost",size:"sm",disabled:o,onClick:()=>a(w.getState().contextMenuOpen.filter(j=>j.id!==m.id)),children:t("Delete")})]},m.id)})]}),e.jsxs(Se,{children:[e.jsx(P,{variant:"outline",disabled:o,onClick:()=>{p()},children:t("Add application")}),e.jsx(P,{onClick:()=>r(!1),children:t("Close")})]})]})})]})}const oa=["internal","reveal","system","application"];function ia({extension:t,value:s,disabled:a,onChange:n}){const{t:r}=B(),o={internal:r("Open inside EnsoCode"),reveal:r("Reveal in file manager"),system:r("System default application"),application:r("Selected application")},i=qt(`file${t}`),c=Kt(`file${t}`)!==null,d=i?c?["internal","reveal"]:["reveal"]:oa,x=i&&(!c||s==="system"||s==="application")?"reveal":s;return e.jsxs(Q,{items:Object.fromEntries(d.map(h=>[h,o[h]])),value:x,disabled:a,onValueChange:h=>{oa.includes(h)&&n(h)},children:[e.jsx(X,{className:"w-52","aria-label":r("File opening"),children:e.jsx(Z,{})}),e.jsx(ee,{children:d.map(h=>e.jsx(H,{value:h,disabled:h==="internal"&&!c,children:o[h]},h))})]})}function Hd(){const{t}=B(),s=w(C=>C.fileOpenRules),a=w(C=>C.setFileOpenRules),[n,r]=u.useState(""),[o,i]=u.useState("internal"),[c,d]=u.useState(),[x,h]=u.useState(null),[l,p]=u.useState(!1),m=Ei([{extension:n,target:"reveal"}])[0]?.extension,f=C=>{Ke({type:"error",title:t("File opening"),description:C})},j=async C=>{p(!0);try{const k=await window.electronAPI.dialog.selectFile();if(k){if(!zr(k)){f(t("The selected application path is invalid."));return}C(k)}}catch(k){f(k instanceof Error?k.message:String(k))}finally{p(!1)}},v=C=>{const k=Ai(C);return k?(a(k),!0):(f(t("Could not complete the file action.")),!1)},N=(C,k,M)=>{if(k==="internal"&&!Kt(`file${C.extension}`)){f(t("This extension does not support internal preview."));return}v(s.map(O=>O.extension===C.extension?{extension:C.extension,target:k,...k==="application"?{applicationPath:M}:{}}:O))},b=()=>{if(!m){h(t("Enter a valid file extension, for example .md."));return}if(s.some(O=>O.extension===m)){h(t("This extension already has an opening rule."));return}const C=qt(`file${m}`),k=Kt(`file${m}`)!==null,M=C&&(!k||o==="system"||o==="application")?"reveal":o;if(M==="internal"&&!Kt(`file${m}`)){f(t("This extension does not support internal preview."));return}if(M==="application"&&!c){h(t("Choose an application before saving this rule."));return}v([...s,{extension:m,target:M,...M==="application"?{applicationPath:c}:{}}])&&(r(""),d(void 0),h(null))};return e.jsxs("section",{className:"space-y-3","data-settings-row":"general.fileOpening",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("File opening")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Configure how local workspace file links open by extension.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("By default, supported files open inside EnsoCode; other files are revealed in the file manager.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Executable and installer files are always revealed in the file manager.")})]}),e.jsx(Wd,{}),s.map(C=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md border px-3 py-2",children:[e.jsx("span",{className:"w-20 shrink-0 font-mono text-sm",children:C.extension}),e.jsx(ia,{extension:C.extension,value:C.target,disabled:l,onChange:k=>{k==="application"?j(M=>N(C,k,M)):N(C,k)}}),C.target==="application"&&!qt(`file${C.extension}`)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",title:C.applicationPath,children:C.applicationPath}),e.jsx(P,{variant:"outline",size:"sm",disabled:l,onClick:()=>{j(k=>N(C,"application",k))},children:t("Choose application")})]}),e.jsx(P,{variant:"ghost",size:"sm",disabled:l,onClick:()=>v(s.filter(k=>k.extension!==C.extension)),children:t("Delete")})]},C.extension)),e.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{className:"w-24",value:n,placeholder:".md","aria-label":t("File extension"),disabled:l,onChange:C=>{r(C.target.value),h(null)},onKeyDown:C=>{C.key==="Enter"&&b()}}),e.jsx(ia,{extension:m??".md",value:o,disabled:l,onChange:C=>{i(C),h(null)}}),e.jsx(P,{variant:"outline",size:"sm",disabled:l,onClick:b,children:t("Add")})]}),o==="application"&&!qt(`file${m??".md"}`)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"outline",size:"sm",disabled:l,onClick:()=>{j(C=>{d(C),h(null)})},children:t("Choose application")}),e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",title:c,children:c})]}),x&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:x})]})]})}const la={auto:"Auto (by usage)",fast:"Fast",balanced:"Balanced",thorough:"Thorough"},ca={standard:"Standard",smart:"Smart compaction","codex-native":"Codex native compaction","continuous-memory":"Continuous memory (experimental)"};function Jd(){const{t}=B(),s=w(m=>m.compactStrategy),a=w(m=>m.smartCompactEnabled),n=Mi(s,a),r=w(m=>m.setCompactStrategy),o=n!=="standard",i=w(m=>m.smartCompactModel),c=w(m=>m.setSmartCompactModel),d=w(m=>m.smartCompactMode),x=w(m=>m.setSmartCompactMode),h=He(),l=i?h.find(m=>m.id===i.providerId):void 0,p=l?.models.find(m=>m.id===i?.modelId);return e.jsxs("section",{className:"space-y-2 rounded-lg border bg-card p-3","data-settings-row":"general.smartCompactEnabled",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h4",{className:"font-medium text-sm",children:[t("Context compaction strategy"),e.jsx(Je,{})]}),e.jsx("p",{className:"mt-0.5 text-muted-foreground text-xs",children:t("Standard uses default compact. Smart compaction uses Enso verified summary at compact time. Codex native compaction additionally stores an official Codex checkpoint on Codex models and uses smart compaction otherwise. Continuous memory records observations in the background so compact keeps more context; all fall back to default compact on failure. Switching strategy takes effect on the next session. The summary model and compaction mode apply to open conversations on the next compaction.")})]}),e.jsxs(Q,{items:Object.fromEntries(Un.map(m=>[m,t(ca[m])])),value:n,onValueChange:m=>r(m),children:[e.jsx(X,{className:"w-52",children:e.jsx(Z,{})}),e.jsx(ee,{children:Un.map(m=>e.jsx(H,{value:m,children:t(ca[m])},m))})]})]}),(n==="smart"||n==="codex-native")&&e.jsxs("div",{className:"flex items-center justify-between gap-4","data-smart-compact-mode":d,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Compaction mode")}),e.jsx("p",{className:"mt-0.5 text-muted-foreground/80 text-[11px]",children:t("Mode changes summary budget and how much recent tail to keep. It does not decide whether compact runs.")})]}),e.jsxs(Q,{items:Object.fromEntries($n.map(m=>[m,t(la[m])])),value:d,onValueChange:m=>x(m),children:[e.jsx(X,{className:"w-36",children:e.jsx(Z,{})}),e.jsx(ee,{children:$n.map(m=>e.jsx(H,{value:m,children:t(la[m])},m))})]})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium text-sm",children:t(n==="continuous-memory"?"Background memory model":"Summary model")}),h.length>0&&e.jsx("div",{className:"w-full min-w-0",children:e.jsx(Fe,{providers:h,providerId:l?.id??"",modelId:p?.id??"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,emptyLabel:t("Follows the session model"),side:"bottom",triggerClassName:Xe,onSelect:(m,f)=>c({providerId:m,modelId:f}),onReasoningChange:()=>{},onThinkingChange:()=>{}})}),i&&(!l||!p)&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Selected model is unavailable — falls back to the session model.")}),i&&e.jsx(P,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>c(null),children:t("Follow session model")})]})]})}const Yd={cmd:"Command Prompt",powershell:"Windows PowerShell",pwsh:"PowerShell 7 (pwsh)","git-bash":"Git Bash",zsh:"zsh",bash:"bash",fish:"fish"};function Qd(){const{language:t,setLanguage:s}=w(),{t:a}=B();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:a("General")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("General application settings")})]}),e.jsxs("div",{className:"flex items-center gap-3","data-settings-row":"general.language",children:[e.jsx("span",{className:"text-sm font-medium",children:a("Language")}),e.jsxs(Q,{items:{en:"English",zh:"简体中文"},value:t,onValueChange:n=>s(n),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(H,{value:"en",children:"English"}),e.jsx(H,{value:"zh",children:"简体中文"})]})]})]}),e.jsx(Xd,{}),e.jsx(eu,{}),e.jsx(Zd,{}),e.jsx(Hd,{}),e.jsx(Jd,{}),e.jsx(nu,{}),e.jsx(tu,{}),e.jsx(su,{}),e.jsx(au,{}),e.jsx(Vd,{}),e.jsx(ru,{})]})}function Xd(){const{t}=B(),s=w(n=>n.notifyMainAgentOnly),a=w(n=>n.setNotifyMainAgentOnly);return e.jsx(Ae,{rowId:"general.notifyMainAgentOnly",title:t("Notify only for the main agent"),description:t("Skip coworker completion and failure notifications on this computer and the paired phone. Questions and approvals still notify."),checked:s,onChange:a})}function Zd(){const{t}=B(),s=w(y=>y.openChangesOnFileEdit),a=w(y=>y.setOpenChangesOnFileEdit),n=w(y=>y.compactReadOnlyTools),r=w(y=>y.setCompactReadOnlyTools),o=w(y=>y.expandLiveEdits),i=w(y=>y.setExpandLiveEdits),c=w(y=>y.expandLiveReasoning),d=w(y=>y.setExpandLiveReasoning),x=w(y=>y.autoCollapseTurns),h=w(y=>y.setAutoCollapseTurns),l=w(y=>y.collapseCompletedActivity),p=w(y=>y.setCollapseCompletedActivity),m=w(y=>y.pinUnfinishedTodos),f=w(y=>y.setPinUnfinishedTodos),j=w(y=>y.generationStallTimeoutMin),v=w(y=>y.setGenerationStallTimeoutMin),N=w(y=>y.autoRetryLimit),b=w(y=>y.setAutoRetryLimit),C=cs.some(y=>y===N)?[...cs]:[...cs,N].sort((y,g)=>y===ds?1:g===ds?-1:y-g),k=y=>y===0?t("Off"):y===ds?t("Unlimited"):t("{{count}} times",{count:y}),M=w(y=>y.activeRetentionMinutes),O=w(y=>y.setActiveRetentionMinutes),S=y=>y===0?t("Off"):t("{{count}} min",{count:y});return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ae,{rowId:"general.openChangesOnFileEdit",title:t("Open Changes when files are edited"),description:t("Automatically show the side panel Changes tab after the agent edits a file"),checked:s,onChange:a}),e.jsx(Ae,{rowId:"general.compactReadOnlyTools",title:t("Compact read-only tool calls"),description:t("Show read/grep/find/ls as one-line rows and fold consecutive tool calls while the agent is still running"),checked:n,onChange:r}),e.jsx(Ae,{rowId:"general.expandLiveEdits",title:t("Expand file edits while running"),description:t("Automatically unfold diffs or written content from file modification tools while the agent is still running"),checked:o,onChange:i}),e.jsx(Ae,{rowId:"general.expandLiveReasoning",title:t("Expand reasoning while streaming"),description:t("Automatically unfold the thinking block while the model is still reasoning. It collapses again when reasoning ends."),checked:c,onChange:d}),e.jsx(Ae,{rowId:"general.autoCollapseTurns",title:t("Auto-collapse previous turns"),description:t("After you send a new message, fold earlier turns down to the question, timestamp and duration; the latest turn stays expanded"),checked:x,onChange:h}),e.jsx(Ae,{rowId:"general.collapseCompletedActivity",title:t("Collapse activity after reply"),description:t("When a reply finishes, fold consecutive thinking and tool calls (including edits and commands) into one summary row; failed calls stay visible"),checked:l,onChange:p}),e.jsx(Ae,{rowId:"general.pinUnfinishedTodos",title:t("Pin unfinished todos"),description:t("Keep the latest todo list above the input while it has unfinished items, so it does not scroll away with the timeline"),checked:m,onChange:f}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.generationStallTimeout",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Stop if no output")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Abort and retry the run when no tokens or tool results arrive for this long. Thinking counts as output.")})]}),e.jsxs(Q,{items:Object.fromEntries(Kn.map(y=>[String(y),y===0?t("Never"):t("{{count}} min",{count:y})])),value:String(j),onValueChange:y=>v(Number(y)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:Kn.map(y=>e.jsx(H,{value:String(y),children:y===0?t("Never"):t("{{count}} min",{count:y})},y))})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.autoRetryLimit",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Auto-retry on transient errors")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Retry with backoff (up to 60s apart) after 429, 5xx or network errors. Quota and billing errors are never retried. Unlimited keeps retrying until you cancel.")})]}),e.jsxs(Q,{items:Object.fromEntries(C.map(y=>[String(y),k(y)])),value:String(N),onValueChange:y=>b(Number(y)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:C.map(y=>e.jsx(H,{value:String(y),children:k(y)},y))})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.activeRetentionMinutes",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Keep in Active after last message")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Viewed conversations stay in Active for this long after their last message or your last open while still in Active, then leave. Unviewed ones stay until you open them.")})]}),e.jsxs(Q,{items:Object.fromEntries(Gn.map(y=>[String(y),S(y)])),value:String(M),onValueChange:y=>O(Number(y)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:Gn.map(y=>e.jsx(H,{value:String(y),children:S(y)},y))})]})]})]})}function Ft(t,s){return s===0?t("Never"):s===1?t("{{count}} day",{count:s}):t("{{count}} days",{count:s})}function eu(){const{t}=B(),s=w(c=>c.autoArchiveIdleDays),a=w(c=>c.setAutoArchiveIdleDays),n=w(c=>c.autoArchiveMergedWorktrees),r=w(c=>c.setAutoArchiveMergedWorktrees),o=w(c=>c.autoDeleteArchivedDays),i=w(c=>c.setAutoDeleteArchivedDays);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.autoArchiveIdleDays",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Archive idle conversations")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Move conversations that have been idle this long into Archived. Does not delete them.")})]}),e.jsxs(Q,{items:Object.fromEntries(Vn.map(c=>[String(c),Ft(t,c)])),value:String(s),onValueChange:c=>a(Number(c)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:Vn.map(c=>e.jsx(H,{value:String(c),children:Ft(t,c)},c))})]})]}),e.jsx(Ae,{rowId:"general.autoArchiveMergedWorktrees",title:t("Clean up merged worktrees"),description:t("When archiving idle conversations, also remove isolated worktrees that are merged and clean."),checked:n,onChange:r}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.autoDeleteArchivedDays",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Delete archived conversations after")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Permanently delete conversations that have been archived longer than this. This cannot be undone. Choosing a positive value deletes already-overdue archived conversations immediately.")})]}),e.jsxs(Q,{items:Object.fromEntries(qn.map(c=>[String(c),Ft(t,c)])),value:String(o),onValueChange:c=>i(Number(c)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:qn.map(c=>e.jsx(H,{value:String(c),children:Ft(t,c)},c))})]})]})]})}function tu(){const{t}=B(),s=w(o=>o.terminalShell),a=w(o=>o.setTerminalShell),n=Pi(window.electronAPI.env.platform),r=Object.fromEntries(n.map(o=>[o,o==="auto"?t("System default"):Yd[o]]));return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.terminalShell",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Terminal shell")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Applies to new side panel terminals. SSH projects keep the remote login shell.")})]}),e.jsxs(Q,{items:r,value:s,onValueChange:o=>a(o),children:[e.jsx(X,{className:"w-56",children:e.jsx(Z,{})}),e.jsx(ee,{children:n.map(o=>e.jsx(H,{value:o,children:r[o]},o))})]})]})}function su(){const{t}=B(),s=w(x=>x.worktreeRoot),a=w(x=>x.setWorktreeRoot),[n,r]=u.useState(s),[o,i]=u.useState(null);u.useEffect(()=>{r(s)},[s]);const c=x=>{const h=x.trim();if(h&&!Dd(h)){i(t("Enter an absolute path"));return}i(null),a(h)},d=async()=>{const x=await window.electronAPI.dialog.selectDirectory();x&&(r(x),c(x))};return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.worktreeRoot",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Worktree root directory")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Where isolated session worktrees are created. Leave empty to use the app data directory. Existing worktrees stay where they are.")})]}),e.jsxs("div",{className:"w-72 shrink-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:n,placeholder:t("Default location"),onChange:x=>r(x.target.value),onBlur:()=>c(n),onKeyDown:x=>{x.key==="Enter"&&c(n)}}),e.jsx(P,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{d()},children:t("Browse")})]}),o&&e.jsx("p",{className:"text-xs text-destructive",children:o})]})]})}function nu(){const{t}=B(),s=w(r=>r.windowsLocalShell),a=w(r=>r.setWindowsLocalShell),n={auto:t("Windows default (PowerShell)"),powershell:t("PowerShell"),bash:t("Git Bash")};return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.windowsLocalShell",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm",children:[t("Windows local command shell"),e.jsx(Je,{})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Only the Windows local agent command tool. SSH and other platforms stay on bash. Takes effect on the next session.")})]}),e.jsxs(Q,{items:n,value:s,onValueChange:r=>a(r),children:[e.jsx(X,{className:"w-56",children:e.jsx(Z,{})}),e.jsx(ee,{children:Object.keys(n).map(r=>e.jsx(H,{value:r,children:n[r]},r))})]})]})}function Ae({title:t,description:s,checked:a,onChange:n,rowId:r}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":r,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s})]}),e.jsx(ie,{checked:a,onCheckedChange:o=>n(o===!0)})]})}function da(t,s){window.electronAPI.proxy.apply({mode:t,customUrl:s})}function au(){const{t}=B(),s=w(l=>l.proxyMode),a=w(l=>l.customProxyUrl),n=w(l=>l.setProxyMode),r=w(l=>l.setCustomProxyUrl),[o,i]=u.useState(a),[c,d]=u.useState(null);u.useEffect(()=>{i(a)},[a]);const x=l=>{n(l),da(l,a)},h=()=>{const l=o.trim();if(l&&!Ti(l)){d(t("Enter an http(s) proxy URL"));return}d(null),r(l),da(s,l)};return e.jsxs("div",{className:"space-y-3","data-settings-row":"general.proxy",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("Network proxy")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Used by model requests, the built-in browser, and agent tools")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Proxy mode")}),e.jsxs(Q,{items:{system:t("Follow system proxy"),none:t("No proxy"),custom:t("Custom proxy")},value:s,onValueChange:l=>x(l),children:[e.jsx(X,{className:"w-56",children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(H,{value:"system",children:t("Follow system proxy")}),e.jsx(H,{value:"none",children:t("No proxy")}),e.jsx(H,{value:"custom",children:t("Custom proxy")})]})]})]}),s==="custom"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"pt-1.5 text-sm font-medium",children:t("Proxy URL")}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(K,{value:o,placeholder:"http://127.0.0.1:7890",onChange:l=>i(l.target.value),onBlur:h,onKeyDown:l=>{l.key==="Enter"&&h()}}),c&&e.jsx("p",{className:"text-xs text-destructive",children:c})]})]})]})}function ru(){const{t}=B(),s=w(j=>j.autoUpdate),a=w(j=>j.setAutoUpdate),n=w(j=>j.autoRestartWhenIdle),r=w(j=>j.setAutoRestartWhenIdle),[o,i]=u.useState(null),[c,d]=u.useState(null),[x,h]=u.useState(!1);u.useEffect(()=>{let j=!0;window.electronAPI.updater.getState().then(N=>{j&&(d(N),N.status&&i(b=>b??N.status))}).catch(()=>{});const v=window.electronAPI.updater.onStatus(i);return()=>{j=!1,v()}},[]);const l=c?.host==="server"?c:null,m=(()=>{if(!o)return null;switch(o.status){case"checking":return t("Checking for updates…");case"available":return t("New version {{version}} found",{version:o.info?.version??""});case"not-available":return t("You are on the latest version");case"downloading":return t("Downloading update… {{percent}}%",{percent:Math.round(o.progress?.percent??0)});case"downloaded":return t("New version {{version}} is ready — restart to update.",{version:o.info?.version??""});case"error":return l&&o.error?t("Update failed: {{error}}",{error:o.error}):t("Update check failed");default:return null}})(),f=o?.status==="checking"||o?.status==="downloading";return e.jsxs("div",{className:"space-y-3","data-settings-row":"general.updates",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("Updates")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?ou(l.mode,t):t("Application update settings")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm",children:[t("Current version")," · ",iu]}),m&&e.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:m})]}),o?.status==="downloaded"?e.jsx(P,{size:"sm",onClick:()=>{window.electronAPI.updater.quitAndInstall()},className:"shrink-0",children:t("Restart to update")}):l&&l.mode!=="manual"&&o?.status==="available"?e.jsx(P,{size:"sm",onClick:()=>{window.electronAPI.updater.downloadUpdate()},className:"shrink-0",children:t("Download update")}):e.jsx(P,{variant:"outline",size:"sm",disabled:f,onClick:()=>{window.electronAPI.updater.checkForUpdates()},className:"shrink-0",children:t("Check for updates")})]}),l?.canRestart&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Restart server")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Running tasks are interrupted; this page reconnects after the server is back.")})]}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"shrink-0",children:t("Restart")}),e.jsx(Br,{open:x,onOpenChange:h,title:t("Restart server?"),description:t("Running tasks are interrupted; this page reconnects after the server is back."),confirmLabel:t("Restart"),onConfirm:()=>{h(!1),window.electronAPI.updater.restart()}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Automatic updates")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Download and install updates automatically")})]}),e.jsx(ie,{checked:s,onCheckedChange:j=>{a(j),window.electronAPI.updater.setAutoUpdateEnabled(j)}})]}),e.jsxs("div",{className:`flex items-center justify-between gap-3 rounded-md border px-3 py-2.5 ${s?"":"opacity-60"}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Restart and apply when idle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("After the update is downloaded, restart automatically if no agent is running, nothing is queued, and there are no pending questions or approvals. The idle state must last 5 minutes, and a focused window also blocks it.")})]}),e.jsx(ie,{checked:s&&n,disabled:!s,onCheckedChange:j=>{r(j),window.electronAPI.updater.setAutoRestartWhenIdle(j)}})]})]})}function ou(t,s){return s(t==="npm"?"Server updates install the new version with npm and restart.":"This server must be updated on the machine itself.")}const iu="0.2.12",ua=15e3,lu=3e3;function cu(t){return!t||!t.timeoutSet&&t.timeoutMs===lu?ua:t.timeoutMs}const ma=()=>{},hs="off",xs=t=>({timeoutMs:t?.timeoutMs??Ri,...t?.timeoutSet&&{timeoutSet:!0}});function du({classifier:t,effectiveMs:s,hint:a,onChange:n}){const{t:r}=B(),[o,i]=u.useState(String(s/1e3));u.useEffect(()=>i(String(s/1e3)),[s]);const c=()=>{const d=Number(o);if(!o.trim()||!Number.isFinite(d))return i(String(s/1e3));const x=Li(d*1e3);i(String(x/1e3)),x!==s&&n({...t,timeoutMs:x,timeoutSet:!0})};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs",children:r("Timeout")}),e.jsx(K,{type:"number",value:o,min:Oi/1e3,max:Di/1e3,step:.5,className:"h-7 w-20 text-xs",onChange:d=>i(d.target.value),onBlur:c,onKeyDown:d=>{d.key==="Enter"&&d.currentTarget.blur()}}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r("seconds")}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:a})]})}function Gt({providers:t,value:s,emptyLabel:a,onSelect:n}){return e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Fe,{providers:t,providerId:s?.providerId??"",modelId:s?.modelId??"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,emptyLabel:a,side:"bottom",triggerClassName:Xe,onSelect:(r,o)=>n({providerId:r,modelId:o}),onReasoningChange:ma,onThinkingChange:ma})})}function Ut({label:t,hint:s,children:a}){return e.jsxs("div",{className:"grid grid-cols-[6rem_1fr] items-start gap-2",children:[e.jsxs("div",{className:"pt-1.5 text-xs",children:[e.jsx("div",{children:t}),s&&e.jsx("div",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx("div",{className:"min-w-0 space-y-1",children:a})]})}function bo({value:t,onChange:s,providers:a,classifierProviders:n,offLabel:r,judgeLabel:o,judgeSeed:i,description:c,effectiveTimeoutMs:d,timeoutHint:x}){const{t:h}=B(),l=t,[p,m]=u.useState(!1),f=l?.source??(p?"judge":hs),j=l?.source==="pi-classifier"?l.model.providerId:"",[v,N]=u.useState([]),[b,C]=u.useState(!1);u.useEffect(()=>{if(!j){N([]);return}let S=!1;return window.electronAPI.providers.classifierModels(j).then(y=>{S||N(y)}),()=>{S=!0}},[j]);const k=async S=>{const g=(await window.electronAPI.providers.classifierModels(S))[0];C(!g),g&&s({source:"pi-classifier",model:{providerId:S,modelId:g.id},...xs(l)})},M=S=>{if(C(!1),m(S==="judge"&&!i),S===hs)return s(void 0);if(S==="judge")return s(i?{source:"judge",model:i,...xs(l)}:void 0);const y=n[0];y&&k(y.id)},O=[{value:hs,label:r},{value:"judge",label:o},...n.length>0?[{value:"pi-classifier",label:h("Classifier model")}]:[]];return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Q,{items:O,value:f,onValueChange:S=>M(String(S)),children:[e.jsx(X,{size:"sm",className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:O.map(S=>e.jsx(H,{value:S.value,children:S.label},S.value))})]}),f==="judge"&&e.jsx(Gt,{providers:a,value:l?.source==="judge"?l.model:void 0,emptyLabel:h("Select model"),onSelect:S=>{m(!1),s({source:"judge",model:S,...xs(l)})}}),l?.source==="pi-classifier"&&e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Q,{items:n.map(S=>({value:S.id,label:S.name})),value:l.model.providerId,onValueChange:S=>{k(String(S))},children:[e.jsx(X,{size:"sm",className:"w-40",children:e.jsx(Z,{})}),e.jsx(ee,{children:n.map(S=>e.jsx(H,{value:S.id,children:S.name},S.id))})]}),e.jsxs(Q,{items:v.map(S=>({value:S.id,label:S.name})),value:l.model.modelId||null,onValueChange:S=>s({...l,model:{providerId:l.model.providerId,modelId:String(S)}}),children:[e.jsx(X,{size:"sm",className:"min-w-0 flex-1",children:e.jsx(Z,{placeholder:h("Select model")})}),e.jsx(ee,{children:v.map(S=>e.jsx(H,{value:S.id,children:S.name},S.id))})]})]}),b&&e.jsx("p",{className:"text-[10px] text-destructive",children:h("No classifier models available")}),l&&e.jsx(du,{classifier:l,effectiveMs:d??l.timeoutMs,hint:x,onChange:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:c})]})}function uu({entry:t,providers:s,classifierProviders:a,update:n}){const{t:r}=B();return t.fast?e.jsx(bo,{value:t.classifier,onChange:o=>n({classifier:o}),providers:s,classifierProviders:a,offLabel:r("Off"),judgeLabel:r("Fast model judges"),judgeSeed:t.fast,description:r("Classifies each new turn: simple turns use the fast model, complex ones the primary model. Adds a short delay before the reply."),timeoutHint:r("Uses the primary model on timeout.")}):e.jsx("p",{className:"pt-1.5 text-[11px] text-muted-foreground",children:r("Set a fast model first")})}function mu({entry:t,providers:s,classifierProviders:a}){const{t:n}=B(),r=w(x=>x.updateVirtualModel),o=w(x=>x.removeVirtualModel),i=[t.primary,...t.fast?[t.fast]:[],...t.fallbacks];let c;for(const x of s){const h=x.models.find(l=>l.enabled!==!1&&!i.some(p=>p.providerId===x.id&&p.modelId===l.id));if(h){c={providerId:x.id,modelId:h.id};break}}const d=x=>r(t.id,x);return e.jsxs("div",{"data-slot":"virtual-model-card",className:V("space-y-2 rounded-md border p-2",!t.enabled&&"bg-muted/50 text-muted-foreground"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{"aria-label":n("Enable virtual model"),checked:t.enabled,onCheckedChange:x=>d({enabled:x})}),e.jsx(K,{value:t.name,maxLength:60,placeholder:"Auto",className:"h-7 flex-1 text-xs",onChange:x=>d({name:x.target.value})}),!t.enabled&&e.jsx(te,{variant:"outline",className:"shrink-0 text-[10px] text-muted-foreground",children:n("Disabled")}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":n("Delete"),className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>o(t.id),children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]}),e.jsx(Ut,{label:n("Primary model"),hint:n("Default for each new turn"),children:e.jsx(Gt,{providers:s,value:t.primary,onSelect:x=>d({primary:x,fallbacks:t.fallbacks.filter(h=>h.providerId!==x.providerId||h.modelId!==x.modelId)})})}),e.jsx(Ut,{label:n("Fast model"),hint:n("Summaries and simple turns"),children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Gt,{providers:s,value:t.fast,emptyLabel:n("Not used"),onSelect:x=>d({fast:x})}),t.fast&&e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":n("Clear"),className:"h-6 w-6 shrink-0 text-muted-foreground",onClick:()=>d({fast:void 0}),children:e.jsx(wt,{className:"h-3.5 w-3.5"})})]})}),e.jsxs(Ut,{label:n("Fallback models"),hint:n("Used in order when a model is rate limited or down"),children:[t.fallbacks.map((x,h)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Gt,{providers:s,value:x,onSelect:l=>d({fallbacks:t.fallbacks.map((p,m)=>m===h?l:p)})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":n("Delete"),className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>d({fallbacks:t.fallbacks.filter((l,p)=>p!==h)}),children:e.jsx(wt,{className:"h-3.5 w-3.5"})})]},`${x.providerId}/${x.modelId}`)),e.jsxs(P,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:!c||t.fallbacks.length>=8,onClick:()=>{c&&d({fallbacks:[...t.fallbacks,c]})},children:[e.jsx(Ie,{className:"mr-1 h-3.5 w-3.5"}),n("Add fallback")]})]}),e.jsx(Ut,{label:n("Difficulty routing"),children:e.jsx(uu,{entry:t,providers:s,classifierProviders:a,update:d})})]})}function hu(){const{t}=B(),s=w(d=>d.virtualModels),a=w(d=>d.addVirtualModel),n=w(d=>d.defaultModel),r=He(),o=u.useMemo(()=>r.filter(_r),[r]),i=Fr(),c=u.useMemo(()=>{if(n&&o.find(x=>x.id===n.providerId)?.models.some(x=>x.id===n.modelId&&x.enabled!==!1))return n;for(const d of o){const x=d.models.find(h=>h.enabled!==!1);if(x)return{providerId:d.id,modelId:x.id}}return null},[o,n]);return e.jsxs("section",{"data-slot":"virtual-models",className:"space-y-2 rounded-lg border bg-card p-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm",children:t("Virtual models")}),e.jsx("p",{className:"mt-0.5 text-muted-foreground text-xs",children:t("A virtual model appears as one model in the picker and routes each request to a real model: fallbacks on rate limits or outages, image-capable or larger-context members when needed, and the fast model for summaries.")}),e.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:t("Applies to newly started conversations.")})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(d=>e.jsx(mu,{entry:d,providers:o,classifierProviders:i},d.id)),e.jsxs(P,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:!c,onClick:()=>{c&&a({name:"Auto",enabled:!0,primary:c,fallbacks:[]})},children:[e.jsx(Ie,{className:"mr-1 h-3.5 w-3.5"}),t("New virtual model")]}),!c&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Enable a model and configure valid provider credentials first.")})]})]})}function xu(){const{t}=B();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:t("Bot mode")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("Settings shared by all members and group chats.")})]}),e.jsx(fu,{}),e.jsx(gu,{}),e.jsx(pu,{})]})}const ha=Array.from({length:zi-Wn+1},(t,s)=>Wn+s);function pu(){const{t}=B(),s=w(n=>n.botMaxRunningTurns),a=w(n=>n.setBotMaxRunningTurns);return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"bots.maxRunningTurns",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Bot concurrency limit")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Shared by private chats, group chats, delegations and routines. Lowering it never interrupts running work; raising it may hit model rate limits.")})]}),e.jsxs(Q,{items:Object.fromEntries(ha.map(n=>[String(n),String(n)])),value:String(s),onValueChange:n=>a(Number(n)),children:[e.jsx(X,{className:"w-20",children:e.jsx(Z,{})}),e.jsx(ee,{children:ha.map(n=>e.jsx(H,{value:String(n),children:n},n))})]})]})}function fu(){const{t}=B(),s=w(i=>i.botAssistantModel),a=w(i=>i.setBotAssistantModel),n=He(),r=s?n.find(i=>i.id===s.providerId):void 0,o=r?.models.find(i=>i.id===s?.modelId);return e.jsxs("div",{className:"rounded-md border px-3 py-2.5","data-settings-row":"bots.assistantModel",children:[e.jsx("p",{className:"text-sm",children:t("Bot assistant model")}),e.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:t("Used for helper tasks such as auto-configuring member abilities.")}),e.jsx(Fe,{providers:n,providerId:o?r?.id??"":"",modelId:o?.id??"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,emptyLabel:t("Follows the default model"),side:"bottom",triggerClassName:Xe,onSelect:(i,c)=>a({providerId:i,modelId:c}),onReasoningChange:()=>{},onThinkingChange:()=>{}}),s&&!o&&e.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:t("Selected model is unavailable — falls back to the default model.")}),s&&e.jsx(P,{variant:"ghost",size:"sm",className:"mt-1",onClick:()=>a(null),children:t("Follow default model")})]})}function gu(){const{t}=B(),s=w(i=>i.botRouteClassifier),a=w(i=>i.setBotRouteClassifier),n=He(),r=u.useMemo(()=>n.filter(_r),[n]),o=Fr();return e.jsxs("div",{className:"rounded-md border px-3 py-2.5","data-settings-row":"bots.routeClassifier",children:[e.jsx("p",{className:"text-sm",children:t("Group reply picker model")}),e.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:t("When nobody is @-mentioned in a smart-routing group, this model picks which member replies.")}),e.jsx(bo,{value:s??void 0,onChange:i=>a(i??null),providers:r,classifierProviders:o,offLabel:t("Default (title model)"),judgeLabel:t("Fast chat model"),description:t("Falls back to the group owner on timeout, error or an unclear answer."),effectiveTimeoutMs:s?cu(s):void 0,timeoutHint:t("Handed to the group owner on timeout.")})]})}const ju=()=>({name:"",title:"",scope:"",summary:"",persona:"",color:en[0],tools:"all",approvalMode:"auto-edits"}),rn=(t,s)=>({key:t,name:"",title:"",scope:"",persona:"",color:en[s%en.length],tools:"all",approvalMode:"auto-edits",canDelegateTo:[],acceptFrom:[]}),vu=()=>({title:"",summary:"",bossKey:"m1",workspace:"chat-home",members:[rn("m1",0),rn("m2",1)]});function bu(t,s){const a=URL.createObjectURL(new Blob([JSON.stringify(s,null,2)],{type:"application/json"})),n=document.createElement("a");n.href=a,n.download=t,n.click(),URL.revokeObjectURL(a)}function yu(){const{t}=B(),s=Bi(!0),a=_i(!0),[n,r]=u.useState(null),[o,i]=u.useState(null),c=u.useRef(null),d=async(f,j)=>{const v=await Xi(N=>({...N,[f]:j(N[f])}));return v||Ke({type:"error",title:t("Could not save templates")}),v},x=(f,j)=>d("members",v=>f?Yn(v,f,j,sl):Qn(v,j,crypto.randomUUID())),h=(f,j)=>d("teams",v=>f?Yn(v,f,j,nl):Qn(v,j,crypto.randomUUID())),l=async f=>{const j=qi(await f.text());if(!j.ok){Ke({type:"error",title:Hn(j.error,t)});return}const v=Vr(Ki(j.team));if(!v){Ke({type:"error",title:Hn("invalid",t)});return}await h(void 0,v)&&Ke({type:"success",title:t("Imported as a custom team template")})},p=(f,j)=>d(f==="members"?"members":"teams",j),m=(f,j,v)=>e.jsxs(e.Fragment,{children:[e.jsx(ct,{label:t("Edit"),onClick:()=>v({id:j.id,data:j.data}),children:e.jsx(rt,{})}),e.jsx(ct,{label:t("Duplicate as custom"),onClick:()=>v({data:j.data}),children:e.jsx(Ur,{})}),j.source==="builtin"&&e.jsx(ct,{label:j.hidden?t("Show"):t("Hide"),onClick:()=>{p(f,N=>Zi(N,j.id,!j.hidden))},children:j.hidden?e.jsx($i,{}):e.jsx(Vi,{})}),j.modified&&e.jsx(ct,{label:t("Restore default"),onClick:()=>{p(f,N=>Xn(N,j.id))},children:e.jsx($r,{})}),j.source==="custom"&&e.jsx(ct,{label:t("Delete"),onClick:()=>{p(f,N=>Xn(N,j.id))},children:e.jsx(Ee,{})})]});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:t("Bot templates")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("Templates used when creating members and teams. Built-in templates can be edited, hidden or restored.")})]}),e.jsxs(Ot,{defaultValue:"members",children:[e.jsxs(Lt,{variant:"underline",children:[e.jsx(Ve,{value:"members",children:t("Member templates")}),e.jsx(Ve,{value:"teams",children:t("Team templates")})]}),e.jsxs(At,{value:"members",className:"space-y-2 pt-3",children:[e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>r({data:ju()}),children:[e.jsx(Ie,{}),t("New member template")]}),s.map(f=>e.jsx(xa,{item:f,avatar:e.jsx(Zs,{bot:{name:f.data.name,avatar:{color:f.data.color}}}),title:f.data.name,subtitle:f.data.title,summary:f.data.summary,actions:m("members",f,r)},f.id))]}),e.jsxs(At,{value:"teams",className:"space-y-2 pt-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>i({data:vu()}),children:[e.jsx(Ie,{}),t("New team template")]}),e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>c.current?.click(),children:[e.jsx(Fi,{}),t("Import team (JSON)")]}),e.jsx("input",{ref:c,type:"file",accept:".json,application/json",hidden:!0,onChange:f=>{const j=f.target.files?.[0];f.target.value="",j&&l(j)}})]}),a.map(f=>e.jsx(xa,{item:f,avatar:e.jsx("div",{className:"-space-x-1.5 flex shrink-0",children:f.data.members.slice(0,4).map(j=>e.jsx(Zs,{size:"sm",bot:{name:j.name,avatar:{color:j.color}}},j.key))}),title:f.data.title,subtitle:t("{{n}} members",{n:f.data.members.length}),summary:f.data.summary,actions:e.jsxs(e.Fragment,{children:[e.jsx(ct,{label:t("Export JSON"),onClick:()=>bu(`${f.data.title||"team"}.team.json`,{format:tl,version:el,exportedAt:new Date().toISOString(),team:Ui(f.data)}),children:e.jsx(pn,{})}),m("teams",f,i)]})},f.id))]})]}),n&&e.jsx(wu,{initial:n.data,onClose:()=>r(null),onSave:async f=>{await x(n.id,f)&&r(null)}}),o&&e.jsx(ku,{initial:o.data,onClose:()=>i(null),onSave:async f=>{await h(o.id,f)&&i(null)}})]})}function ct({label:t,onClick:s,disabled:a,children:n}){return e.jsx(P,{variant:"ghost",size:"icon-sm",title:t,"aria-label":t,disabled:a,onClick:s,children:n})}function xa({item:t,avatar:s,title:a,subtitle:n,summary:r,actions:o}){const{t:i}=B();return e.jsxs("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2.5","data-template-id":t.id,children:[e.jsxs("div",{className:V("flex min-w-0 flex-1 items-center gap-3",t.hidden&&"opacity-50"),children:[s,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx("span",{className:"truncate",children:a}),e.jsx("span",{className:"truncate font-normal text-muted-foreground text-xs",children:n}),e.jsx(te,{variant:"secondary",children:t.source==="custom"?i("Custom"):i("Built-in")}),t.modified&&e.jsx(te,{variant:"outline",children:i("Modified")}),t.hidden&&e.jsx(te,{variant:"outline",children:i("Hidden")})]}),e.jsx("p",{className:"truncate text-muted-foreground text-xs",children:r})]})]}),e.jsx("div",{className:"flex shrink-0 items-center",children:o})]})}function yo({title:t,error:s,onClose:a,onSave:n,children:r}){const{t:o}=B(),[i,c]=u.useState(!1);return e.jsx(we,{open:!0,onOpenChange:d=>!d&&a(),children:e.jsxs(Ne,{className:"max-h-[85vh] max-w-2xl",children:[e.jsx(ke,{children:e.jsx(Ce,{children:t})}),e.jsxs(Pe,{className:"space-y-3",children:[r,s&&e.jsx("p",{className:"text-destructive text-xs",children:s})]}),e.jsxs(Se,{children:[e.jsx(P,{variant:"outline",size:"sm",onClick:a,children:o("Cancel")}),e.jsx(P,{size:"sm",disabled:i||!!s,onClick:()=>{c(!0),n().finally(()=>c(!1))},children:o("Save")})]})]})})}function wo({value:t,onChange:s}){const{t:a}=B(),n=t.name?qr(t.name,[],a):null;return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{children:a("Name")}),e.jsx(K,{value:t.name,onChange:r=>s({name:r.target.value})}),n&&e.jsx("p",{className:"mt-1 text-destructive text-xs",children:n})]}),e.jsxs("div",{children:[e.jsx(Be,{children:a("Title")}),e.jsx(K,{value:t.title,onChange:r=>s({title:r.target.value})})]}),e.jsxs("div",{children:[e.jsx(Be,{children:a("Avatar color")}),e.jsx(Yi,{value:t.color,onChange:r=>s({color:r})})]}),e.jsxs("div",{children:[e.jsx(Be,{children:a("Tools")}),e.jsx(Kr,{value:t.tools,options:[{value:"all",label:a("All tools")},{value:"readonly",label:a("Read-only")}],onChange:r=>s({tools:r})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:a("Approval mode")}),e.jsx(Qi,{value:t.approvalMode,onChange:r=>s({approvalMode:r}),zIndex:Qe.DROPDOWN_IN_MODAL})]}),t.summary!==void 0&&e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{hint:a("Shown on the template card"),children:a("Summary")}),e.jsx(K,{value:t.summary,onChange:r=>s({summary:r.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:a("Responsibilities")}),e.jsx(K,{value:t.scope,onChange:r=>s({scope:r.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:a("Persona")}),e.jsx(at,{rows:6,value:t.persona,onChange:r=>s({persona:r.target.value})})]})]})}function wu({initial:t,onClose:s,onSave:a}){const{t:n}=B(),[r,o]=u.useState(t),i=Gi(r);return e.jsx(yo,{title:n("Member template"),error:qr(r.name,[],n)??(i?null:n("Check the template fields")),onClose:s,onSave:()=>i?a(i):Promise.resolve(),children:e.jsx(wo,{value:r,onChange:c=>o(d=>({...d,...c}))})})}function Nu(t,s){switch(t){case"title":return s("Enter a team title");case"members":return s("A team needs 2–12 members");case"name":return s("Every member needs a valid name");case"invalid":return s("Check the template fields");default:return null}}function ku({initial:t,onClose:s,onSave:a}){const{t:n}=B(),[r,o]=u.useState(t),[i,c]=u.useState(null),d=f=>r.members.find(j=>j.key===f)?.name||f,x=f=>o(j=>({...j,...f})),h=(f,j)=>o(v=>({...v,members:v.members.map(N=>N.key===f?{...N,...j}:N)})),l=()=>{const f=new Set(r.members.map(N=>N.key));let j=r.members.length+1;for(;f.has(`m${j}`);)j++;const v=`m${j}`;x({members:[...r.members,rn(v,r.members.length)]}),c(v)},p=f=>{const j=v=>v==="any"?"any":v.filter(N=>N!==f);x({members:r.members.filter(v=>v.key!==f).map(v=>({...v,canDelegateTo:j(v.canDelegateTo),acceptFrom:j(v.acceptFrom)}))})},m=Vr(r);return e.jsxs(yo,{title:n("Team template"),error:Nu(Ji(r),n),onClose:s,onSave:()=>m?a(m):Promise.resolve(),children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{children:n("Group name")}),e.jsx(K,{value:r.title,onChange:f=>x({title:f.target.value})})]}),e.jsxs("div",{children:[e.jsx(Be,{children:n("Owner")}),e.jsxs(Q,{items:r.members.map(f=>({value:f.key,label:d(f.key)})),value:r.bossKey,onValueChange:f=>x({bossKey:f}),children:[e.jsx(X,{className:"w-full",children:e.jsx(Z,{})}),e.jsx(ee,{zIndex:Qe.DROPDOWN_IN_MODAL,children:r.members.map(f=>e.jsx(H,{value:f.key,children:d(f.key)},f.key))})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{hint:n("Shown on the template card"),children:n("Summary")}),e.jsx(K,{value:r.summary,onChange:f=>x({summary:f.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:n("Shared workspace")}),e.jsx(Kr,{value:r.workspace,options:[{value:"chat-home",label:n("Standalone workspace")},{value:"project",label:n("Based on a Code project")}],onChange:f=>x({workspace:f})})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:n("Members")}),e.jsxs(P,{size:"xs",variant:"outline",disabled:r.members.length>=Wi,onClick:l,children:[e.jsx(Ie,{}),n("Add member")]})]}),e.jsx("div",{className:"space-y-1.5",children:r.members.map(f=>{const j=i===f.key,v=f.key===r.bossKey,N=r.members.filter(b=>b.key!==f.key).map(b=>b.key);return e.jsxs("div",{className:"rounded-lg border","data-member-key":f.key,children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:()=>c(j?null:f.key),children:[j?e.jsx(tn,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Rt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(Zs,{bot:{name:f.name,avatar:{color:f.color}},size:"sm"}),e.jsx("span",{className:"truncate text-sm",children:f.name||n("Unnamed")}),e.jsx("span",{className:"truncate text-muted-foreground text-xs",children:f.title}),v&&e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground",children:[e.jsx(Hi,{className:"h-3 w-3"}),n("Owner")]})]}),e.jsx(ct,{label:n("Remove"),disabled:v||r.members.length<=2,onClick:()=>p(f.key),children:e.jsx(Ee,{})})]}),j&&e.jsxs("div",{className:"space-y-3 border-t p-2.5",children:[e.jsx(wo,{value:f,onChange:b=>h(f.key,b)}),e.jsx(Jn,{label:n("Can delegate to"),value:f.canDelegateTo,options:N,nameOf:d,onChange:b=>h(f.key,{canDelegateTo:b})}),e.jsx(Jn,{label:n("Accepts delegation from"),value:f.acceptFrom,options:N,nameOf:d,onChange:b=>h(f.key,{acceptFrom:b})})]})]},f.key)})})]})]})}function No(t){return t.capturePermission==="unsupported"&&t.axPermission==="unsupported"?"unsupported":t.capturePermission==="granted"&&(t.axPermission==="granted"||t.axPermission==="unsupported")?"ready":"needs-permission"}function Cu(t){return Object.fromEntries(t.map(s=>[s.id,s]))}function ts(t,s){return t.reduce((a,n)=>{const r=s[n]?.tokens;return r==null?a:a+r},0)}function ss({row:t,pending:s}){const{t:a}=B(),n=s?"…":t?.tokens==null?"—":_e(t.tokens);return e.jsx("span",{className:"w-12 shrink-0 text-right text-muted-foreground text-xs tabular-nums",title:t?.error||a("Estimate"),children:n})}function ns({tokens:t}){return t<=0?null:e.jsx("span",{className:"ml-2 font-normal text-muted-foreground text-xs tabular-nums",children:_e(t)})}function as(t,s){const[a,n]=u.useState({}),[r,o]=u.useState(()=>t.length>0),i=t.join("\0"),c=u.useRef(s);return c.current=s,u.useEffect(()=>{let d=!1;const x=i.length===0?[]:i.split("\0");if(x.length===0){n({}),o(!1);return}return o(!0),c.current(x).then(h=>{d||n(Cu(h))}).finally(()=>{d||o(!1)}),()=>{d=!0}},[i]),{rows:a,pending:r}}const pa={replace:"Text replacement",apply_patch:"Apply patch (default)"},Su={subagent:dl,workflow:kn,todo:cl,plan:ll,ask_user:il,browser:ol,web:rl,background_tasks:al,memory:Gr,isolated_sandbox:Wc,computer:xn};function St({icon:t,title:s,description:a,control:n,children:r,rowId:o,newSession:i}){return e.jsxs("div",{className:"rounded-md border px-3 py-2.5","data-settings-row":o,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium",children:[s,i&&e.jsx(Je,{})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:a})]}),n]}),r?e.jsx("div",{className:"mt-2 space-y-2 pl-7",children:r}):null]})}function Iu({disabled:t}){const{t:s}=B(),a=w(l=>l.webSearchChain),n=w(l=>l.setWebSearchChain),r=Zt(),o=u.useMemo(()=>hl(r),[r]),[i,c]=u.useState(null),d=(l,p)=>{n(a.map((m,f)=>f===l?{...m,...p}:m))},x=l=>n(a.filter((p,m)=>m!==l)),h=(l,p)=>{if(l===p)return;const m=[...a],[f]=m.splice(l,1);f&&(m.splice(p,0,f),n(m))};return e.jsxs("div",{className:"space-y-2","data-settings-row":"tools.webSearchChain",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:s("Try these models' built-in search in order. Credentials resolve at call time; if all fail, the keyless Exa service is the permanent fallback.")}),a.length===0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:s("Default: use the current session model's built-in search when available, otherwise Exa.")}),a.map((l,p)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border px-2 py-1.5",draggable:!t,onDragStart:m=>{m.dataTransfer.effectAllowed="move",c(p)},onDragEnd:()=>c(null),onDragOver:m=>{i!==null&&i!==p&&m.preventDefault()},onDrop:m=>{m.preventDefault(),i!==null&&h(i,p),c(null)},children:[e.jsx(xl,{className:"h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground"}),e.jsx("span",{className:"w-4 shrink-0 text-center text-muted-foreground text-xs",children:p+1}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Fe,{providers:o,providerId:l.providerId,modelId:l.modelId,reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,onSelect:(m,f)=>d(p,{providerId:m,modelId:f}),onReasoningChange:()=>{},onThinkingChange:()=>{}})}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 shrink-0 p-0",disabled:t,onClick:()=>x(p),"aria-label":s("Remove"),children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]},`${l.providerId}/${l.modelId}`)),a.length<pl&&e.jsx("div",{className:"max-w-xs",children:e.jsx(Fe,{providers:o,providerId:"",modelId:"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,triggerLabel:`+ ${s("Add candidate")}`,onSelect:(l,p)=>n([...a,{providerId:l,modelId:p}]),onReasoningChange:()=>{},onThinkingChange:()=>{}})}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s("Final fallback: Exa (keyless hosted search). Not a chain entry; always last.")})]})}function Eu(){const{t}=B(),s=w(g=>g.disabledBuiltinTools),a=w(g=>g.toggleBuiltinTool),n=w(g=>g.subagentAllowedModes),r=w(g=>g.setSubagentAllowedModes),o=w(g=>g.exploreFoldEnabled),i=w(g=>g.setExploreFoldEnabled),c=w(g=>g.rtkEnabled),d=w(g=>g.setRtkEnabled),x=w(g=>g.protectedActionsInCode),h=w(g=>g.setProtectedActionsInCode),l=w(g=>g.editMode),p=w(g=>g.setEditMode),m=as(us.map(g=>g.id),()=>window.electronAPI.assets.builtinToolOccupancy()),f=ts(us.filter(g=>!s.includes(g.id)).map(g=>g.id),m.rows),[j,v]=u.useState(null),N=!s.includes("subagent"),b=(g,E)=>{r(E?[...new Set([...n,g])]:n.filter(I=>I!==g))},C=async g=>{await window.electronAPI.browser.clearData(g),v(g),setTimeout(()=>v(null),2e3)},k=!s.includes("computer"),[M,O]=u.useState(null),[S,y]=u.useState(!1);return u.useEffect(()=>{if(!k){O(null);return}let g=!1;return window.electronAPI.computer.capabilities().then(E=>{!g&&E.ok&&O(E.capabilities)}),()=>{g=!0}},[k]),u.useEffect(()=>{if(!S)return;let g=!1;const E=()=>{window.electronAPI.computer.capabilities().then(D=>{!g&&D.ok&&O(D.capabilities)})};E();const I=window.setInterval(E,2e3);return()=>{g=!0,window.clearInterval(I)}},[S]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{"data-settings-row":"tools.root",children:[e.jsxs("h3",{className:"font-medium text-lg",children:[t("Built-in tools"),e.jsx(ns,{tokens:f}),e.jsx(Je,{note:t("Turning a tool on applies to new sessions. Turning off Memory or Computer also blocks it in open sessions.")})]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t("Toggle the built-in tools available to agents.")})]}),e.jsxs("div",{className:"space-y-2",children:[us.map(g=>e.jsxs(St,{icon:Su[g.id]??Wr,title:t(g.name),description:t(g.description),control:e.jsxs(e.Fragment,{children:[e.jsx(ss,{row:m.rows[g.id],pending:m.pending&&!m.rows[g.id]}),e.jsx(ie,{checked:!s.includes(g.id),onCheckedChange:E=>{a(g.id,E),g.id==="computer"&&E&&y(!0)}})]}),children:[g.id==="web"?e.jsx(Iu,{disabled:s.includes("web")}):null,g.id==="subagent"?e.jsxs("div",{className:"space-y-2","data-settings-row":"tools.subagentModes",children:[[["task","One-shot task agents"],["coworker","Persistent coworkers"]].map(([E,I])=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:t(I)}),e.jsx(ie,{checked:n.includes(E),disabled:!N,onCheckedChange:D=>b(E,D)})]},E)),!N&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("The unified subagent tool is off. Re-enabling it keeps this mode selection.")})]}):null,g.id==="computer"&&k?e.jsx("div",{className:"space-y-2","data-settings-row":"tools.computer",children:M&&No(M)==="unsupported"?e.jsx("p",{className:"text-muted-foreground text-xs",children:t("This platform cannot operate the desktop yet.")}):e.jsxs(e.Fragment,{children:[M?.platform==="darwin"&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Computer needs Screen Recording to capture windows and Accessibility to inspect or click them. Grant both to EnsoCode, then restart the app.")}),M&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[t(M.capturePermission==="granted"?"Capture: granted":"Capture: denied"),M.axPermission!=="unsupported"&&e.jsxs(e.Fragment,{children:[" · ",t(M.axPermission==="granted"?"Input/AX: granted":"Input/AX: denied")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>y(!0),children:t("Show permission guide")}),M?.platform==="darwin"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("screen")},children:t("Open Screen Recording settings")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("accessibility")},children:t("Open Accessibility settings")})]})]})]})}):null,g.id==="browser"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Cookies and site storage of the built-in browser, separate from the app itself.")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["cookies","cache","all"].map(E=>e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{C(E)},children:t(j===E?"Cleared":E==="cookies"?"Clear cookies":E==="cache"?"Clear cache":"Clear all browsing data")},E))})]}):null]},g.id)),e.jsx(Au,{open:S,capabilities:M,onOpenChange:y}),e.jsx(St,{icon:ul,newSession:!0,title:t("Explore fold"),description:t("Let the agent mark exploratory reads and keep only a short report in later model context. Timeline stays intact."),control:e.jsx(ie,{checked:o,onCheckedChange:i})}),e.jsx(St,{rowId:"tools.rtkEnabled",newSession:!0,icon:hd,title:t("RTK command compression"),description:t("Compress supported command output before it enters the model context. Takes effect on new conversations."),control:e.jsx(ie,{checked:c,onCheckedChange:d})}),e.jsx(St,{icon:fn,newSession:!0,title:t("Protected action confirmation"),description:t("Even in full-access mode, ask before external sends, deletions, payments, deployments and secret-file access. Always on for Bot members not set to Full access. Takes effect on new conversations."),control:e.jsx(ie,{checked:x,onCheckedChange:h})}),e.jsx(St,{rowId:"tools.editMode",newSession:!0,icon:Zc,title:t("File edit mode"),description:t("Choose how files are modified. Apply patch is the default. New and cold-restored sessions use this mode; already warm sessions keep their current mode."),control:e.jsxs(Q,{items:Object.fromEntries(Zn.map(g=>[g,t(pa[g])])),value:l,onValueChange:g=>{ml(g)&&p(g)},children:[e.jsx(X,{className:"w-44 shrink-0","aria-label":t("File edit mode"),children:e.jsx(Z,{})}),e.jsx(ee,{children:Zn.map(g=>e.jsx(H,{value:g,children:t(pa[g])},g))})]})})]})]})}function Au({open:t,capabilities:s,onOpenChange:a}){const{t:n}=B(),r=s?No(s):null;return e.jsx(we,{open:t,onOpenChange:a,children:e.jsxs(Ne,{className:"max-w-md",zIndexLevel:"nested",children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:n("Grant Computer permissions")}),e.jsx($e,{children:n(r==="unsupported"?"This platform cannot operate the desktop yet.":r==="ready"?"Computer is ready. Start a new session to use it.":"The agent can screenshot windows and control the mouse and keyboard. Grant Screen Recording and Accessibility to EnsoCode, then restart. Only new sessions pick up the tool.")})]}),e.jsxs(Pe,{className:"space-y-3",children:[!s&&e.jsx("p",{className:"text-muted-foreground text-sm",children:n("Loading…")}),r==="needs-permission"&&e.jsxs("div",{className:"flex gap-2 rounded-md border border-destructive/32 bg-destructive/8 p-3 text-sm",children:[e.jsx(Ue,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsx("p",{children:n("Computer needs Screen Recording to capture windows and Accessibility to inspect or click them. Grant both to EnsoCode, then restart the app.")})]}),s?.platform==="darwin"&&r!=="unsupported"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:[n(s.capturePermission==="granted"?"Capture: granted":"Capture: denied")," · ",n(s.axPermission==="granted"?"Input/AX: granted":"Input/AX: denied"),s.detail?` · ${s.detail}`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("screen")},children:n("Open Screen Recording settings")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("accessibility")},children:n("Open Accessibility settings")})]})]})]}),e.jsx(Se,{className:"sm:justify-end",children:e.jsx(P,{size:"sm",onClick:()=>a(!1),children:n("Done")})})]})})}function Mu(t){if(t==null||!Number.isFinite(t)||t<0)return null;const s=Math.round(t);return s<1?"<1ms":`${s}ms`}var ft={},ps,fa;function Pu(){return fa||(fa=1,ps=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ps}var fs={},tt={},ga;function dt(){if(ga)return tt;ga=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return tt.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},tt.getSymbolTotalCodewords=function(n){return s[n]},tt.getBCHDigit=function(a){let n=0;for(;a!==0;)n++,a>>>=1;return n},tt.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');t=n},tt.isKanjiModeEnabled=function(){return typeof t<"u"},tt.toSJIS=function(n){return t(n)},tt}var gs={},ja;function Mn(){return ja||(ja=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+a)}}t.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},t.from=function(n,r){if(t.isValid(n))return n;try{return s(n)}catch{return r}}})(gs)),gs}var js,va;function Tu(){if(va)return js;va=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const a=Math.floor(s/8);return(this.buffer[a]>>>7-s%8&1)===1},put:function(s,a){for(let n=0;n<a;n++)this.putBit((s>>>a-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),s&&(this.buffer[a]|=128>>>this.length%8),this.length++}},js=t,js}var vs,ba;function Ru(){if(ba)return vs;ba=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,a,n,r){const o=s*this.size+a;this.data[o]=n,r&&(this.reservedBit[o]=!0)},t.prototype.get=function(s,a){return this.data[s*this.size+a]},t.prototype.xor=function(s,a,n){this.data[s*this.size+a]^=n},t.prototype.isReserved=function(s,a){return this.reservedBit[s*this.size+a]},vs=t,vs}var bs={},ya;function Du(){return ya||(ya=1,(function(t){const s=dt().getSymbolSize;t.getRowColCoords=function(n){if(n===1)return[];const r=Math.floor(n/7)+2,o=s(n),i=o===145?26:Math.ceil((o-13)/(2*r-2))*2,c=[o-7];for(let d=1;d<r-1;d++)c[d]=c[d-1]-i;return c.push(6),c.reverse()},t.getPositions=function(n){const r=[],o=t.getRowColCoords(n),i=o.length;for(let c=0;c<i;c++)for(let d=0;d<i;d++)c===0&&d===0||c===0&&d===i-1||c===i-1&&d===0||r.push([o[c],o[d]]);return r}})(bs)),bs}var ys={},wa;function Ou(){if(wa)return ys;wa=1;const t=dt().getSymbolSize,s=7;return ys.getPositions=function(n){const r=t(n);return[[0,0],[r-s,0],[0,r-s]]},ys}var ws={},Na;function Lu(){return Na||(Na=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},t.from=function(r){return t.isValid(r)?parseInt(r,10):void 0},t.getPenaltyN1=function(r){const o=r.size;let i=0,c=0,d=0,x=null,h=null;for(let l=0;l<o;l++){c=d=0,x=h=null;for(let p=0;p<o;p++){let m=r.get(l,p);m===x?c++:(c>=5&&(i+=s.N1+(c-5)),x=m,c=1),m=r.get(p,l),m===h?d++:(d>=5&&(i+=s.N1+(d-5)),h=m,d=1)}c>=5&&(i+=s.N1+(c-5)),d>=5&&(i+=s.N1+(d-5))}return i},t.getPenaltyN2=function(r){const o=r.size;let i=0;for(let c=0;c<o-1;c++)for(let d=0;d<o-1;d++){const x=r.get(c,d)+r.get(c,d+1)+r.get(c+1,d)+r.get(c+1,d+1);(x===4||x===0)&&i++}return i*s.N2},t.getPenaltyN3=function(r){const o=r.size;let i=0,c=0,d=0;for(let x=0;x<o;x++){c=d=0;for(let h=0;h<o;h++)c=c<<1&2047|r.get(x,h),h>=10&&(c===1488||c===93)&&i++,d=d<<1&2047|r.get(h,x),h>=10&&(d===1488||d===93)&&i++}return i*s.N3},t.getPenaltyN4=function(r){let o=0;const i=r.data.length;for(let d=0;d<i;d++)o+=r.data[d];return Math.abs(Math.ceil(o*100/i/5)-10)*s.N4};function a(n,r,o){switch(n){case t.Patterns.PATTERN000:return(r+o)%2===0;case t.Patterns.PATTERN001:return r%2===0;case t.Patterns.PATTERN010:return o%3===0;case t.Patterns.PATTERN011:return(r+o)%3===0;case t.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2===0;case t.Patterns.PATTERN101:return r*o%2+r*o%3===0;case t.Patterns.PATTERN110:return(r*o%2+r*o%3)%2===0;case t.Patterns.PATTERN111:return(r*o%3+(r+o)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}t.applyMask=function(r,o){const i=o.size;for(let c=0;c<i;c++)for(let d=0;d<i;d++)o.isReserved(d,c)||o.xor(d,c,a(r,d,c))},t.getBestMask=function(r,o){const i=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let x=0;x<i;x++){o(x),t.applyMask(x,r);const h=t.getPenaltyN1(r)+t.getPenaltyN2(r)+t.getPenaltyN3(r)+t.getPenaltyN4(r);t.applyMask(x,r),h<d&&(d=h,c=x)}return c}})(ws)),ws}var $t={},ka;function ko(){if(ka)return $t;ka=1;const t=Mn(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],a=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $t.getBlocksCount=function(r,o){switch(o){case t.L:return s[(r-1)*4+0];case t.M:return s[(r-1)*4+1];case t.Q:return s[(r-1)*4+2];case t.H:return s[(r-1)*4+3];default:return}},$t.getTotalCodewordsCount=function(r,o){switch(o){case t.L:return a[(r-1)*4+0];case t.M:return a[(r-1)*4+1];case t.Q:return a[(r-1)*4+2];case t.H:return a[(r-1)*4+3];default:return}},$t}var Ns={},It={},Ca;function zu(){if(Ca)return It;Ca=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let n=1;for(let r=0;r<255;r++)t[r]=n,s[n]=r,n<<=1,n&256&&(n^=285);for(let r=255;r<512;r++)t[r]=t[r-255]})(),It.log=function(n){if(n<1)throw new Error("log("+n+")");return s[n]},It.exp=function(n){return t[n]},It.mul=function(n,r){return n===0||r===0?0:t[s[n]+s[r]]},It}var Sa;function Bu(){return Sa||(Sa=1,(function(t){const s=zu();t.mul=function(n,r){const o=new Uint8Array(n.length+r.length-1);for(let i=0;i<n.length;i++)for(let c=0;c<r.length;c++)o[i+c]^=s.mul(n[i],r[c]);return o},t.mod=function(n,r){let o=new Uint8Array(n);for(;o.length-r.length>=0;){const i=o[0];for(let d=0;d<r.length;d++)o[d]^=s.mul(r[d],i);let c=0;for(;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},t.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let o=0;o<n;o++)r=t.mul(r,new Uint8Array([1,s.exp(o)]));return r}})(Ns)),Ns}var ks,Ia;function _u(){if(Ia)return ks;Ia=1;const t=Bu();function s(a){this.genPoly=void 0,this.degree=a,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(n){this.degree=n,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(n.length+this.degree);r.set(n);const o=t.mod(r,this.genPoly),i=this.degree-o.length;if(i>0){const c=new Uint8Array(this.degree);return c.set(o,i),c}return o},ks=s,ks}var Cs={},Ss={},Is={},Ea;function Co(){return Ea||(Ea=1,Is.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),Is}var qe={},Aa;function So(){if(Aa)return qe;Aa=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let a="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";a=a.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+a+`)(?:.|[\r
9
+ `?e.jsxs(u.Fragment,{children:[e.jsx("br",{}),e.jsx("br",{})]},o.id):e.jsx("span",{style:{color:o.color},children:o.text},o.id)),e.jsx("span",{className:"inline-block w-2 h-4 animate-pulse",style:{backgroundColor:t.cursor}})]})}function Ad({isFavorite:t,onClick:s,ariaLabel:a}){return e.jsx("button",{type:"button","aria-label":a,"aria-pressed":t,onClick:n=>{n.stopPropagation(),n.preventDefault(),s(n)},className:"p-1 hover:text-red-500 transition-colors",children:t?e.jsx(aa,{className:"h-4 w-4 fill-red-500 text-red-500"}):e.jsx(aa,{className:"h-4 w-4"})})}function Md({value:t,onValueChange:s,themes:a,favoriteThemes:n,onToggleFavorite:r,onThemeHover:o,showFavoritesOnly:i,onShowFavoritesOnlyChange:c,showEmptyFavoritesHint:d}){const{t:x}=B(),[h,l]=u.useState(t),[p,m]=u.useState(t),[f,j]=u.useState(!1),v=u.useRef(void 0),N=u.useRef(null),b=u.useRef(t),C=u.useRef(!1),k=u.useMemo(()=>new Set(n),[n]);u.useEffect(()=>{f||(l(t),m(t))},[t,f]);const M=u.useMemo(()=>{if(!p||p===h)return a;const E=p.toLowerCase();return a.filter(I=>I.toLowerCase().includes(E))},[a,p,h]),O=E=>{E&&(C.current=!0,l(E),m(E)),s(E)},S=E=>{j(E),E?(b.current=t,C.current=!1,l(t),m(t)):C.current||o?.(b.current)},y=E=>{clearTimeout(v.current),v.current=setTimeout(()=>{o?.(E)},50)},g=()=>{clearTimeout(v.current)};return u.useEffect(()=>{if(!f)return;const E=I=>{(I.key==="ArrowDown"||I.key==="ArrowUp")&&requestAnimationFrame(()=>{const D=N.current?.querySelector("[data-highlighted]");if(D){const _=D.getAttribute("data-value");_&&o?.(_)}})};return document.addEventListener("keydown",E,!0),()=>{document.removeEventListener("keydown",E,!0)}},[f,o]),u.useEffect(()=>()=>{clearTimeout(v.current)},[]),e.jsxs(bd,{value:h,onValueChange:O,inputValue:p,onInputValueChange:m,open:f,onOpenChange:S,children:[e.jsxs("div",{className:"relative",children:[e.jsx(yd,{placeholder:x("Search themes...")}),e.jsxs("div",{className:"absolute right-8 top-1/2 -translate-y-1/2 flex items-center gap-1.5",children:[e.jsx(We,{id:"show-favorites-only-inner",checked:i,onCheckedChange:E=>c(E===!0),onClick:E=>E.stopPropagation()}),e.jsx("label",{htmlFor:"show-favorites-only-inner",className:"text-xs text-muted-foreground cursor-pointer whitespace-nowrap",onClick:E=>E.stopPropagation(),onKeyDown:E=>E.stopPropagation(),children:x("Show favorites only")})]})]}),e.jsx(Nd,{children:e.jsxs(Cd,{ref:N,children:[M.length===0&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:x(d?"No favorite themes yet. Click the heart icon to add favorites.":"No themes found")}),M.map(E=>e.jsx(kd,{value:E,"data-value":E,onMouseEnter:()=>y(E),onMouseLeave:g,endAddon:e.jsx(Ad,{isFavorite:k.has(E),onClick:()=>r(E),ariaLabel:k.has(E)?x("Remove from favorites"):x("Add to favorites")}),children:E},E))]})})]})}const Pd={violet:"oklch(0.54 0.2 280)",indigo:"oklch(0.53 0.19 265)",teal:"oklch(0.56 0.1 185)",amber:"oklch(0.64 0.16 55)",graphite:"oklch(0.27 0.01 285)"},Td={violet:"Violet",indigo:"Indigo",teal:"Teal",amber:"Amber",graphite:"Graphite"};function Rd(){const{theme:t,setTheme:s,accentColor:a,setAccentColor:n,terminalTheme:r,setTerminalTheme:o,terminalFontSize:i,setTerminalFontSize:c,terminalFontFamily:d,setTerminalFontFamily:x,terminalFontWeight:h,setTerminalFontWeight:l,terminalFontWeightBold:p,setTerminalFontWeightBold:m,favoriteTerminalThemes:f,toggleFavoriteTerminalTheme:j}=w(),{t:v}=B(),N=[{value:"light",icon:pd,label:v("Light")},{value:"dark",icon:cd,label:v("Dark")},{value:"system",icon:xn,label:v("System")},{value:"sync-terminal",icon:Ar,label:v("Sync terminal theme")}],b=Yo.map(R=>({value:R,label:v(Td[R]),swatch:Pd[R]})),[C,k]=u.useState(i),[M,O]=u.useState(d),[S,y]=u.useState(!1);u.useEffect(()=>{k(i)},[i]),u.useEffect(()=>{O(d)},[d]);const g=u.useCallback(()=>{const R=Math.max(8,Math.min(32,C||8));R!==C&&k(R),R!==i&&c(R)},[C,i,c]),E=u.useCallback(()=>{const R=M.trim()||d;R!==M&&O(R),R!==d&&x(R)},[M,d,x]),I=u.useMemo(()=>Qo(),[]),D=u.useMemo(()=>{if(!S)return I;const R=I.filter(G=>f.includes(G));return f.includes(r)?R:[r,...R]},[I,S,f,r]),_=S&&f.length===0,A=u.useMemo(()=>Zo(r)??Xo,[r]),F=R=>{R&&o(R)},q=()=>{const R=S?D:I,G=R.indexOf(r),ne=G<=0?R.length-1:G-1;o(R[ne])},W=()=>{const R=S?D:I,G=R.indexOf(r),ne=G>=R.length-1?0:G+1;o(R[ne])};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{"data-settings-row":"appearance.theme",children:[e.jsx("h3",{className:"text-lg font-medium",children:v("Theme mode")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v("Choose interface theme")})]}),e.jsx("div",{className:"grid grid-cols-4 gap-3",children:N.map(R=>e.jsxs("button",{type:"button",onClick:()=>s(R.value),className:V("flex flex-col items-center gap-2 rounded-lg border-2 p-3 transition-colors",t===R.value?"border-primary bg-accent text-accent-foreground":"border-transparent bg-muted/50 hover:bg-muted"),children:[e.jsx("div",{className:V("flex h-10 w-10 items-center justify-center rounded-full",t===R.value?"bg-accent-foreground/20 text-accent-foreground":"bg-muted"),children:e.jsx(R.icon,{className:"h-5 w-5"})}),e.jsx("span",{className:"text-sm font-medium",children:R.label})]},R.value))}),e.jsxs("div",{"data-settings-row":"appearance.accent",children:[e.jsx("h3",{className:"text-lg font-medium",children:v("Accent color")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v("Highlight color used across the interface")})]}),e.jsx("div",{className:"flex items-center gap-3",children:b.map(R=>e.jsx("button",{type:"button",onClick:()=>n(R.value),title:R.label,"aria-label":R.label,"aria-pressed":a===R.value,style:{backgroundColor:R.swatch},className:V("size-6 rounded-full transition-shadow",a===R.value&&"ring-2 ring-offset-2 ring-offset-background ring-foreground/60")},R.value))}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-medium",children:v("Terminal")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:v("Terminal appearance")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:v("Preview")}),e.jsx(Ed,{theme:A,fontSize:C,fontFamily:M,fontWeight:h})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Color scheme")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"outline",size:"icon",onClick:q,children:e.jsx(Mr,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1",children:e.jsx(Md,{value:r,onValueChange:F,themes:D,favoriteThemes:f,onToggleFavorite:j,onThemeHover:o,showFavoritesOnly:S,onShowFavoritesOnlyChange:y,showEmptyFavoritesHint:_})}),e.jsx(P,{variant:"outline",size:"icon",onClick:W,children:e.jsx(Rt,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Font")}),e.jsx(K,{value:M,onChange:R=>O(R.target.value),onBlur:E,onKeyDown:R=>{R.nativeEvent.isComposing||R.key==="Enter"&&(E(),R.currentTarget.blur())},placeholder:"JetBrains Mono, monospace"})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Font size")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{type:"number",value:C,onChange:R=>k(Number(R.target.value)),onBlur:g,onKeyDown:R=>{R.key==="Enter"&&(g(),R.currentTarget.blur())},min:8,max:32,className:"w-20"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"px"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Font weight")}),e.jsxs(Q,{items:Bt,value:h,onValueChange:R=>l(R),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:Bt.map(R=>e.jsx(H,{value:R.value,children:R.label},R.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] items-center gap-4",children:[e.jsx("span",{className:"text-sm font-medium",children:v("Bold font weight")}),e.jsxs(Q,{items:Bt,value:p,onValueChange:R=>m(R),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:Bt.map(R=>e.jsx(H,{value:R.value,children:R.label},R.value))})]})]}),e.jsx(Id,{})]})}function Dd(t){return/^\//.test(t)||/^[A-Za-z]:[\\/]/.test(t)||/^\\\\[^\\]/.test(t)}function nn({className:t,render:s,...a}){const n={className:V("inline-flex items-center gap-2 text-base/4.5 sm:text-sm/4 font-medium",t),"data-slot":"label"};return ni({defaultTagName:"label",props:ai(n,a),render:s})}const an={checked(t){return t?{"data-checked":""}:{"data-unchecked":""}},...Er,...Tr},jo=u.createContext(void 0);function Od(){return u.useContext(jo)}const vo=u.createContext(void 0);function Ld(){const t=u.useContext(vo);if(t===void 0)throw new Error(ri(52));return t}const zd=u.forwardRef(function(s,a){const{render:n,className:r,disabled:o=!1,readOnly:i=!1,required:c=!1,"aria-labelledby":d,value:x,inputRef:h,nativeButton:l=!1,id:p,style:m,...f}=s,j=Od(),{disabled:v,readOnly:N,required:b,form:C,checkedValue:k,touched:M=!1,validation:O,name:S,setCheckedValue:y=is,setTouched:g=is,registerInputRef:E=is}=j??{},{setTouched:I,setFilled:D,state:_,disabled:A}=Rr(),F=oi(),{labelId:q,getDescriptionProps:W}=Dr(),R=A||F.disabled||v||o,G=N||i,ne=b||c,xe=C,U=j?k===x:x==="",se=u.useRef(null),L=u.useRef(null),me=O?.registerInput,oe=u.useCallback(he=>me?.(he,{controlRef:se,value:void 0}),[me]),ce=ii(h,L,E,oe);Bn(()=>{L.current?.checked&&D(!0)},[D]),Bn(()=>{if(L.current){if(R&&U){E(null);return}E(L.current)}},[U,R,E]);const le=Or(),ge=li({id:p,implicit:!1,controlRef:se}),z=l?void 0:ge,Y=ci(d,q,L,!l,z),ae={role:"radio","aria-checked":U,"aria-labelledby":Y,[fi]:U?"":void 0,id:l?ge:le,onKeyDown(he){he.key==="Enter"&&he.preventDefault()},onClick(he){if(he.defaultPrevented||R||G)return;he.preventDefault();const Ze=L.current;Ze&&pi(Ze,he)},onFocus(he){he.defaultPrevented||R||G||!M||(L.current?.click(),g(!1))}},{getButtonProps:be,buttonRef:J}=di({disabled:R,native:l,composite:!1}),je={type:"radio",ref:ce,form:xe,id:z,name:S,tabIndex:-1,style:S?hi:xi,"aria-hidden":!0,...x!==void 0?{value:ui(x)}:_n,disabled:R,checked:U,required:ne,readOnly:G,onChange(he){if(he.nativeEvent.defaultPrevented||R||G||x===void 0)return;const Ze=gi(ji,he.nativeEvent);y(x,Ze),!Ze.isCanceled&&I(!0)},onClick(he){he.stopPropagation()},onFocus(){se.current?.focus()}},Te=u.useMemo(()=>({..._,required:ne,disabled:R,readOnly:G,checked:U}),[_,R,G,U,ne]),mt=Te,$=j!==void 0,ye=[a,se,J],ve=[ae,f,be,W,O?he=>O.getValidationProps(R,he):_n],Oe=hn("span",s,{enabled:!$,state:Te,ref:ye,props:ve,stateAttributesMapping:an});return e.jsxs(vo.Provider,{value:mt,children:[$?e.jsx(mi,{tag:"span",render:n,className:r,style:m,state:Te,refs:ye,props:ve,stateAttributesMapping:an}):Oe,e.jsx("input",{...je,suppressHydrationWarning:!0})]})}),Bd=u.forwardRef(function(s,a){const{render:n,className:r,style:o,keepMounted:i=!1,...c}=s,d=Ld(),x=d.checked,{mounted:h,transitionStatus:l,setMounted:p}=Sr(x),m={...d,transitionStatus:l},f=u.useRef(null),j=i||h,v=hn("span",s,{ref:[a,f],state:m,props:c,stateAttributesMapping:an});return Ir({open:x,ref:f,onComplete(){x||p(!1)}}),j?v:null}),_d=[Si],Fd=u.forwardRef(function(s,a){const{render:n,className:r,disabled:o,readOnly:i,required:c,onValueChange:d,value:x,defaultValue:h,form:l,name:p,inputRef:m,id:f,style:j,...v}=s,{setTouched:N,setFocused:b,validationMode:C,name:k,disabled:M,state:O,validation:S,setDirty:y,setFilled:g,validityData:E}=Rr(),{labelId:I}=Dr(),{clearErrors:D,elementRef:_}=vi(),A=bi(!0),F=M||o,q=k??p,W=Or(f),[R,G]=yi({controlled:x,default:h,name:"RadioGroup",state:"value"}),[ne,xe]=u.useState(!1),U=ls((J,je)=>{d?.(J,je),!je.isCanceled&&G(J)}),se=S.getInputControl,L=u.useMemo(()=>({get current(){return se()}}),[se]),me=u.useRef(null),oe=u.useRef(null);function ce(J){let je;return m&&(typeof m=="function"?je=m(J):m.current=J),me.current=J,je}const le=ls(J=>{if(!J||J.disabled)return;oe.current||(oe.current=J);const je=me.current,Te=J.checked||je==null||je.disabled?ce(J):void 0;return()=>{oe.current===J&&(oe.current=null),me.current===J?Te?(Te(),me.current=null):ce(null):Te?.()}}),ge=ls(()=>{const J=_.current;if(!J)return R??null;for(const je of S.registeredInputs.keys())if(je.checked&&wi(je,J))return R??null;return null});Ni(L,W,R??null,ge,!F,p),ki(R,()=>{D(q),y(R!==E.initialValue),g(R!=null),S.change(R);const J=oe.current;R==null&&J&&!J.disabled&&ce(J)});const z=I??A?.legendId,Y={...O,disabled:F??!1,required:c??!1,readOnly:i??!1},ae=u.useMemo(()=>({checkedValue:R,disabled:F,form:l,validation:S,name:q,readOnly:i,registerInputRef:le,required:c,setCheckedValue:U,setTouched:xe,touched:ne}),[R,F,l,S,q,i,le,c,U,xe,ne]),be={id:f,role:"radiogroup","aria-required":c||void 0,"aria-disabled":F||void 0,"aria-readonly":i||void 0,"aria-labelledby":z,onFocus(){b(!0)},onBlur(J){Ii(J.currentTarget,J.relatedTarget)||(N(!0),b(!1),C==="onBlur"&&S.commit(R))},onKeyDownCapture(J){J.key.startsWith("Arrow")&&(xe(!0),b(!0))}};return e.jsx(jo.Provider,{value:ae,children:e.jsx(Ci,{render:n,className:r,style:j,state:Y,props:[be,v,J=>S.getValidationProps(F??!1,J)],refs:[a],stateAttributesMapping:Tr,enableHomeAndEndKeys:!1,modifierKeys:_d})})});function Ud({className:t,...s}){return e.jsx(Fd,{className:V("flex flex-col gap-3",t),"data-slot":"radio-group",...s})}function ra({className:t,...s}){return e.jsx(zd,{className:V("relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-full border border-input bg-background bg-clip-padding shadow-xs outline-none transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-full not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:bg-clip-border dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/8%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none",t),"data-slot":"radio",...s,children:e.jsx(Bd,{className:"-inset-px absolute flex size-4.5 items-center justify-center rounded-full before:size-2 before:rounded-full before:bg-primary-foreground data-unchecked:hidden data-checked:bg-primary sm:size-4 sm:before:size-1.5","data-slot":"radio-indicator"})})}const $d=[{category:"providers",label:"Model Providers"},{category:"presets",label:"Presets"},{category:"agentTypes",label:"Agent types"},{category:"skills",label:"Skills"},{category:"mcpServers",label:"MCP Servers"},{category:"instructions",label:"Instruction Files"},{category:"subagentModels",label:"Subagent Models"},{category:"settings",label:"Scalar settings"}];function Vd(){const{t}=B(),[s,a]=u.useState(!1),[n,r]=u.useState(!1),[o,i]=u.useState(null),[c,d]=u.useState(null),x=()=>{i(null),a(!0)},h=async()=>{r(!0),i(null);try{const l=await window.electronAPI.configSync.openImport();if(!l.ok){i({kind:l.cancelled?"cancelled":"error",text:l.cancelled?t("Import cancelled."):t(l.error)});return}d(l)}catch{i({kind:"error",text:t("Could not open configuration package.")})}finally{r(!1)}};return e.jsxs("section",{className:"space-y-3","data-settings-row":"general.configSync",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("Configuration transfer")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Move models, presets, agent types, skills, MCP servers and instruction files between devices.")})]}),e.jsxs("div",{className:"rounded-md border px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(Qc,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:t("Portable Enso configuration")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Export a package or preview one before importing it.")})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs(P,{variant:"outline",size:"sm",disabled:n,onClick:h,children:[n?e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(pn,{className:"h-3.5 w-3.5"}),t("Import configuration")]}),e.jsxs(P,{size:"sm",disabled:n,onClick:x,children:[e.jsx(go,{className:"h-3.5 w-3.5"}),t("Export configuration")]})]})]}),e.jsxs("div",{className:"mt-3 flex items-start gap-2 border-t pt-3 text-xs text-muted-foreground",children:[e.jsx(Wt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.jsx("p",{children:t("OAuth login sessions are never transferred. Skill, instruction, and system prompt contents require an encrypted export.")})]}),o&&e.jsx("p",{className:o.kind==="error"?"mt-2 text-xs text-destructive":"mt-2 text-xs text-muted-foreground",role:o.kind==="error"?"alert":"status",children:o.text})]}),e.jsx(qd,{open:s,onOpenChange:a}),c&&e.jsx(Kd,{file:c,onClose:()=>d(null)})]})}function qd({open:t,onOpenChange:s}){const{t:a}=B(),[n,r]=u.useState(!1),[o,i]=u.useState(""),[c,d]=u.useState(""),[x,h]=u.useState(!1),[l,p]=u.useState(null),[m,f]=u.useState(!1),[j,v]=u.useState(null),[N,b]=u.useState([]);u.useEffect(()=>{t&&(r(!1),i(""),d(""),h(!1),p(null),f(!1),v(null),b([]))},[t]);const C=()=>{x||(i(""),d(""),s(!1))},k=async()=>{if(n&&o.length<8){p(a("Password must be at least 8 characters."));return}if(n&&o!==c){p(a("Passwords do not match."));return}h(!0),p(null),f(!1);try{const M=await window.electronAPI.configSync.exportConfig({includeSecrets:n,...n?{password:o}:{}});if(i(""),d(""),!M.ok){M.cancelled?f(!0):p(a(M.error));return}v(M.filePath),b(M.skippedInstructions??[])}catch{i(""),d(""),p(a("Could not export configuration."))}finally{h(!1)}};return e.jsx(we,{open:t,onOpenChange:M=>!M&&C(),children:e.jsxs(Ne,{className:"max-w-xl",showCloseButton:!x,children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:a("Export configuration")}),e.jsx($e,{children:a("Create a portable .enso-config package for another device.")})]}),e.jsx(Pe,{className:"max-h-[55vh] space-y-4",children:j?e.jsxs(e.Fragment,{children:[e.jsxs(Le,{variant:"success",children:[e.jsx(Lr,{}),e.jsx(bt,{children:a("Configuration exported")}),e.jsxs(ze,{children:[e.jsx("p",{children:a("Saved package:")}),e.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:j})]})]}),N.length>0&&e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsxs(ze,{children:[e.jsx("p",{children:a("These instructions were skipped because their source files are missing or unreadable:")}),e.jsx("p",{className:"break-all text-foreground",children:N.join(", ")})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Le,{variant:"warning",children:[e.jsx(fn,{}),e.jsx(bt,{children:a("File contents can be private")}),e.jsx(ze,{children:a("Skill and instruction file contents may contain private data, so configurations containing them can only be exported with encryption.")})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-md border px-3 py-2.5",children:[e.jsx(We,{checked:n,onCheckedChange:M=>{const O=M===!0;r(O),p(null),O||(i(""),d(""))}}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-medium",children:a("Include sensitive configuration")}),e.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:a("Encrypt the entire package with a password. OAuth login sessions are still excluded.")})]})]}),!n&&e.jsxs(Le,{variant:"info",children:[e.jsx(Wt,{}),e.jsx(ze,{children:a("API keys, provider account links, MCP arguments and environment values, plus credentials and private URL parts in MCP endpoints, will be omitted. Configurations containing skill or instruction files require encryption.")})]}),n&&e.jsxs("div",{className:"space-y-3 rounded-md border px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(fo,{className:"h-4 w-4 text-muted-foreground"}),a("Encryption password")]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(nn,{htmlFor:"config-export-password",children:a("Password")}),e.jsx(K,{id:"config-export-password",type:"password",autoComplete:"new-password",value:o,"aria-invalid":!!(l&&o.length<8),onChange:M=>{i(M.target.value),p(null)}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(nn,{htmlFor:"config-export-confirmation",children:a("Confirm password")}),e.jsx(K,{id:"config-export-confirmation",type:"password",autoComplete:"new-password",value:c,"aria-invalid":!!(l&&c!==o),onChange:M=>{d(M.target.value),p(null)}})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("Use at least 8 characters. This password cannot be recovered.")})]}),m&&e.jsx("p",{className:"text-xs text-muted-foreground",role:"status",children:a("Export cancelled.")}),l&&e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[e.jsx(Nt,{className:"h-3.5 w-3.5 shrink-0"}),l]})]})}),e.jsx(Se,{children:j?e.jsx(P,{size:"sm",onClick:C,children:a("Done")}):e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",disabled:x,onClick:C,children:a("Cancel")}),e.jsxs(P,{size:"sm",disabled:x,onClick:()=>{k()},children:[x?e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(go,{className:"h-3.5 w-3.5"}),a(x?"Exporting…":"Export")]})]})})]})})}function Kd({file:t,onClose:s}){const{t:a}=B(),[n,r]=u.useState(t.encrypted?"password":"preview"),[o,i]=u.useState(""),[c,d]=u.useState("merge"),[x,h]=u.useState(null),[l,p]=u.useState([]),[m,f]=u.useState(null),[j,v]=u.useState(!1),[N,b]=u.useState(null),[C,k]=u.useState(null),[M,O]=u.useState(!1),S=u.useRef(0),y=u.useCallback(async(A,F)=>{const q=++S.current;b("preview"),k(null),h(null),p([]);try{const W=await window.electronAPI.configSync.previewImport({token:t.token,mode:A,...F?{password:F}:{}});if(q!==S.current)return;if(i(""),!W.ok){k(a(W.error));return}d(W.mode),h(W.summary),p(W.warnings),r("preview")}catch{q===S.current&&(i(""),k(a("Could not preview configuration package.")))}finally{q===S.current&&b(null)}},[t.token,a]);u.useEffect(()=>{t.encrypted||y("merge")},[t.encrypted,y]);const g=()=>{N||(S.current+=1,O(!1),i(""),window.electronAPI.configSync.cancelImport(t.token).catch(()=>{}),s())},E=A=>{A===c||N||(d(A),y(A))},I=!!x?.some(A=>(A.category==="skills"||A.category==="mcpServers")&&A.added+A.updated+A.skipped>0),D=x!==null,_=async()=>{if(x){b("commit"),k(null);try{const A=await window.electronAPI.configSync.commitImport({token:t.token,mode:c});if(!A.ok){h(null),p([]),k(a(A.error));return}i("");try{await w.persist.rehydrate()}catch{v(!0)}p(A.warnings),f(A.backupPath),r("success")}catch{h(null),p([]),k(a("Could not import configuration."))}finally{b(null)}}};return e.jsxs(we,{open:!0,onOpenChange:A=>!A&&g(),children:[e.jsxs(Ne,{className:"max-w-2xl",showCloseButton:N===null,children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:a(n==="success"?"Configuration imported":"Import configuration")}),e.jsx($e,{children:n==="success"?a(j?"Configuration was imported, but this window could not refresh automatically.":"This window has been refreshed with the imported settings."):a("Review {{fileName}} before changing this device.",{fileName:t.fileName})})]}),n==="password"&&e.jsxs(Pe,{className:"space-y-4",children:[e.jsxs(Le,{variant:"info",children:[e.jsx(fo,{}),e.jsx(bt,{children:a("Encrypted configuration package")}),e.jsx(ze,{children:a("Enter the export password to decrypt and preview this package.")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(nn,{htmlFor:"config-import-password",children:a("Password")}),e.jsx(K,{id:"config-import-password",type:"password",autoFocus:!0,autoComplete:"current-password",value:o,"aria-invalid":!!C,onChange:A=>{i(A.target.value),k(null)},onKeyDown:A=>{A.key==="Enter"&&o.length>0&&!N&&y("merge",o)}})]}),C&&e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-destructive",role:"alert",children:[e.jsx(Nt,{className:"h-3.5 w-3.5 shrink-0"}),C]})]}),n==="preview"&&e.jsxs(Pe,{className:"max-h-[58vh] space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:a("Import mode")}),e.jsxs(Ud,{value:c,onValueChange:A=>E(A),className:"grid gap-2 sm:grid-cols-2","aria-label":a("Import mode"),children:[e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2.5",children:[e.jsx(ra,{value:"merge",disabled:N!==null}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:a("Merge")}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:a("Add and update matching items while keeping items only on this device.")})]})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 rounded-md border px-3 py-2.5",children:[e.jsx(ra,{value:"replace",disabled:N!==null}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:a("Replace")}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:a("Replace transferred item categories, removing local-only items in them.")})]})]})]})]}),N==="preview"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 rounded-md border border-dashed py-10",children:[e.jsx(Me,{className:"h-4 w-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:a("Preparing preview…")})]}),!N&&x&&e.jsx("div",{className:"overflow-hidden rounded-md border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"px-3 py-2 text-left font-medium",children:a("Category")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Added")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Updated")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Skipped")}),e.jsx("th",{scope:"col",className:"px-3 py-2 text-right font-medium",children:a("Removed")})]})}),e.jsx("tbody",{children:$d.map(({category:A,label:F})=>{const q=x.find(W=>W.category===A);return e.jsxs("tr",{className:"border-t first:border-t-0",children:[e.jsx("th",{scope:"row",className:"px-3 py-2 text-left font-medium",children:a(F)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.added??0}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.updated??0}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.skipped??0}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:q?.removed??0})]},A)})})]})}),!N&&x?.find(A=>A.category==="settings")?.fields?.length?e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a("Portable settings changed:")," ",x.find(A=>A.category==="settings")?.fields?.join(", ")]}):null,c==="replace"&&x&&!N&&e.jsxs(Le,{variant:"error",children:[e.jsx(Ue,{}),e.jsx(bt,{children:a("Local-only configuration will be deleted")}),e.jsx(ze,{children:a("Items in transferred collections that exist only on this device will be removed. Removed counts are shown above. Included portable preferences are overwritten. A complete backup is created first.")})]}),l.map(A=>e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsx(ze,{children:a(A)})]},A)),x&&!N&&e.jsxs(Le,{variant:"warning",children:[e.jsx(fn,{}),e.jsx(bt,{children:a("Only import packages you trust")}),e.jsx(ze,{children:a("An imported package can change portable preferences and configuration. Skills and MCP servers may also run commands later when you use them. Previewing does not execute them; continue only if you trust the package.")})]}),C&&e.jsxs(Le,{variant:"error",children:[e.jsx(Nt,{}),e.jsx(ze,{children:C})]})]}),n==="success"&&m&&e.jsxs(Pe,{className:"space-y-4",children:[e.jsxs(Le,{variant:"success",children:[e.jsx(Lr,{}),e.jsx(bt,{children:a("Import complete")}),e.jsxs(ze,{children:[e.jsx("p",{children:a("Backup of previous settings:")}),e.jsx("p",{className:"break-all font-mono text-xs text-foreground",children:m})]})]}),j&&e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsx(ze,{children:a("Reopen Settings to load the imported configuration in this window.")})]}),l.map(A=>e.jsxs(Le,{variant:"warning",children:[e.jsx(Ue,{}),e.jsx(ze,{children:a(A)})]},A))]}),e.jsxs(Se,{children:[n==="password"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",disabled:N!==null,onClick:g,children:a("Cancel")}),e.jsxs(P,{size:"sm",disabled:N!==null||o.length===0,onClick:()=>{y("merge",o)},children:[N==="preview"&&e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}),a("Preview")]})]}),n==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",disabled:N!==null,onClick:g,children:a("Cancel")}),C&&!x?e.jsx(P,{size:"sm",disabled:N!==null,onClick:()=>{y(c)},children:a("Refresh preview")}):e.jsxs(P,{variant:c==="replace"?"destructive":"default",size:"sm",disabled:N!==null||!x,onClick:()=>{x&&(D?O(!0):_())},children:[N==="commit"?e.jsx(Me,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(pn,{className:"h-3.5 w-3.5"}),a(N==="commit"?"Importing…":"Import")]})]}),n==="success"&&e.jsx(P,{size:"sm",onClick:g,children:a("Done")})]})]}),e.jsx(Gd,{open:M,mode:c,hasImportedExecutableResources:I,onOpenChange:O,onConfirm:()=>{_()}})]})}function Gd({open:t,mode:s,hasImportedExecutableResources:a,onOpenChange:n,onConfirm:r}){const{t:o}=B();return e.jsx(gn,{open:t,onOpenChange:n,children:e.jsxs(jn,{className:"sm:max-w-md",zIndexLevel:"nested",children:[e.jsxs(vn,{children:[e.jsxs(bn,{className:"flex items-start gap-2 text-base",children:[e.jsx(Ue,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),o("Confirm configuration import")]}),e.jsxs(yn,{className:"space-y-2",children:[e.jsx("span",{className:"block",children:o("This package can change portable preferences and configuration. Continue only if you trust this package.")}),a&&e.jsx("span",{className:"block",children:o("It includes skills or MCP servers that may execute commands when you use them.")}),s==="replace"&&e.jsx("span",{className:"block",children:o("Replace mode removes local-only items from transferred collections and overwrites included portable preferences. A complete backup will be created first.")}),e.jsx("span",{className:"block",children:o("Do you want to continue with this import?")})]})]}),e.jsxs(wn,{variant:"bare",children:[e.jsx(Nn,{render:e.jsx(P,{variant:"outline",size:"sm"}),children:o("Cancel")}),e.jsx(P,{variant:s==="replace"?"destructive":"default",size:"sm",onClick:()=>{n(!1),r()},children:o("Confirm import")})]})]})})}function Wd(){const{t}=B(),s=w(m=>m.contextMenuOpen),a=w(m=>m.setContextMenuOpen),[n,r]=u.useState(!1),[o,i]=u.useState(!1),c=m=>m.target==="reveal"?t("File manager"):m.target==="vscode"?t("VS Code"):m.applicationPath.split(/[/\\]/).at(-1)?.replace(/\.(exe|app)$/i,"")||m.applicationPath,d=s.filter(m=>m.enabled).map(c),x=d.length?`${d.slice(0,2).join(", ")}${d.length>2?` +${d.length-2}`:""}`:t("No opening methods enabled"),h=m=>{if(m.length>32){Ke({type:"error",title:t("Context menu opening"),description:t("You can configure up to 32 opening methods.")});return}a(m)},l=(m,f)=>{const j=w.getState().contextMenuOpen;a(j.map(v=>v.id===m.id?{...v,enabled:f}:v))},p=async()=>{i(!0);try{const m=await window.electronAPI.dialog.selectFile();if(!m)return;if(!zr(m)){Ke({type:"error",title:t("Context menu opening"),description:t("The selected application path is invalid.")});return}const f=w.getState().contextMenuOpen,j=Fn(m),v=f.find(N=>N.target==="application"&&Fn(N.applicationPath)===j);if(v){h(f.map(N=>N.id===v.id?{...N,enabled:!0}:N));return}h([...f,{id:crypto.randomUUID(),target:"application",applicationPath:m,enabled:!0}])}catch(m){Ke({type:"error",title:t("Context menu opening"),description:m instanceof Error?m.message:String(m)})}finally{i(!1)}};return e.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h5",{className:"text-sm font-medium",children:t("Context menu opening")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>r(!0),children:t("Configure list")})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Select the opening methods shown in file link context menus. You can add multiple applications.")}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:d.join(", "),children:x}),e.jsx(we,{open:n,onOpenChange:r,children:e.jsxs(Ne,{zIndexLevel:"nested",children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:t("Context menu opening")}),e.jsx($e,{children:t("Select the opening methods shown in file link context menus. You can add multiple applications.")})]}),e.jsxs(Pe,{className:"space-y-2",children:[s.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:t("No opening methods enabled")}),s.map(m=>{const f=c(m);return e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-3",children:[e.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-3",children:[e.jsx(We,{checked:m.enabled,disabled:o,"aria-label":f,onCheckedChange:j=>l(m,j)}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-sm",title:f,children:f}),m.target==="application"&&e.jsx("span",{className:"block truncate text-xs text-muted-foreground",title:m.applicationPath,children:m.applicationPath})]})]}),e.jsx(P,{variant:"ghost",size:"sm",disabled:o,onClick:()=>a(w.getState().contextMenuOpen.filter(j=>j.id!==m.id)),children:t("Delete")})]},m.id)})]}),e.jsxs(Se,{children:[e.jsx(P,{variant:"outline",disabled:o,onClick:()=>{p()},children:t("Add application")}),e.jsx(P,{onClick:()=>r(!1),children:t("Close")})]})]})})]})}const oa=["internal","reveal","system","application"];function ia({extension:t,value:s,disabled:a,onChange:n}){const{t:r}=B(),o={internal:r("Open inside EnsoCode"),reveal:r("Reveal in file manager"),system:r("System default application"),application:r("Selected application")},i=qt(`file${t}`),c=Kt(`file${t}`)!==null,d=i?c?["internal","reveal"]:["reveal"]:oa,x=i&&(!c||s==="system"||s==="application")?"reveal":s;return e.jsxs(Q,{items:Object.fromEntries(d.map(h=>[h,o[h]])),value:x,disabled:a,onValueChange:h=>{oa.includes(h)&&n(h)},children:[e.jsx(X,{className:"w-52","aria-label":r("File opening"),children:e.jsx(Z,{})}),e.jsx(ee,{children:d.map(h=>e.jsx(H,{value:h,disabled:h==="internal"&&!c,children:o[h]},h))})]})}function Hd(){const{t}=B(),s=w(C=>C.fileOpenRules),a=w(C=>C.setFileOpenRules),[n,r]=u.useState(""),[o,i]=u.useState("internal"),[c,d]=u.useState(),[x,h]=u.useState(null),[l,p]=u.useState(!1),m=Ei([{extension:n,target:"reveal"}])[0]?.extension,f=C=>{Ke({type:"error",title:t("File opening"),description:C})},j=async C=>{p(!0);try{const k=await window.electronAPI.dialog.selectFile();if(k){if(!zr(k)){f(t("The selected application path is invalid."));return}C(k)}}catch(k){f(k instanceof Error?k.message:String(k))}finally{p(!1)}},v=C=>{const k=Ai(C);return k?(a(k),!0):(f(t("Could not complete the file action.")),!1)},N=(C,k,M)=>{if(k==="internal"&&!Kt(`file${C.extension}`)){f(t("This extension does not support internal preview."));return}v(s.map(O=>O.extension===C.extension?{extension:C.extension,target:k,...k==="application"?{applicationPath:M}:{}}:O))},b=()=>{if(!m){h(t("Enter a valid file extension, for example .md."));return}if(s.some(O=>O.extension===m)){h(t("This extension already has an opening rule."));return}const C=qt(`file${m}`),k=Kt(`file${m}`)!==null,M=C&&(!k||o==="system"||o==="application")?"reveal":o;if(M==="internal"&&!Kt(`file${m}`)){f(t("This extension does not support internal preview."));return}if(M==="application"&&!c){h(t("Choose an application before saving this rule."));return}v([...s,{extension:m,target:M,...M==="application"?{applicationPath:c}:{}}])&&(r(""),d(void 0),h(null))};return e.jsxs("section",{className:"space-y-3","data-settings-row":"general.fileOpening",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("File opening")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Configure how local workspace file links open by extension.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("By default, supported files open inside EnsoCode; other files are revealed in the file manager.")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Executable and installer files are always revealed in the file manager.")})]}),e.jsx(Wd,{}),s.map(C=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-md border px-3 py-2",children:[e.jsx("span",{className:"w-20 shrink-0 font-mono text-sm",children:C.extension}),e.jsx(ia,{extension:C.extension,value:C.target,disabled:l,onChange:k=>{k==="application"?j(M=>N(C,k,M)):N(C,k)}}),C.target==="application"&&!qt(`file${C.extension}`)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",title:C.applicationPath,children:C.applicationPath}),e.jsx(P,{variant:"outline",size:"sm",disabled:l,onClick:()=>{j(k=>N(C,"application",k))},children:t("Choose application")})]}),e.jsx(P,{variant:"ghost",size:"sm",disabled:l,onClick:()=>v(s.filter(k=>k.extension!==C.extension)),children:t("Delete")})]},C.extension)),e.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(K,{className:"w-24",value:n,placeholder:".md","aria-label":t("File extension"),disabled:l,onChange:C=>{r(C.target.value),h(null)},onKeyDown:C=>{C.key==="Enter"&&b()}}),e.jsx(ia,{extension:m??".md",value:o,disabled:l,onChange:C=>{i(C),h(null)}}),e.jsx(P,{variant:"outline",size:"sm",disabled:l,onClick:b,children:t("Add")})]}),o==="application"&&!qt(`file${m??".md"}`)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"outline",size:"sm",disabled:l,onClick:()=>{j(C=>{d(C),h(null)})},children:t("Choose application")}),e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",title:c,children:c})]}),x&&e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:x})]})]})}const la={auto:"Auto (by usage)",fast:"Fast",balanced:"Balanced",thorough:"Thorough"},ca={standard:"Standard",smart:"Smart compaction","codex-native":"Codex native compaction","continuous-memory":"Continuous memory (experimental)"};function Jd(){const{t}=B(),s=w(m=>m.compactStrategy),a=w(m=>m.smartCompactEnabled),n=Mi(s,a),r=w(m=>m.setCompactStrategy),o=n!=="standard",i=w(m=>m.smartCompactModel),c=w(m=>m.setSmartCompactModel),d=w(m=>m.smartCompactMode),x=w(m=>m.setSmartCompactMode),h=He(),l=i?h.find(m=>m.id===i.providerId):void 0,p=l?.models.find(m=>m.id===i?.modelId);return e.jsxs("section",{className:"space-y-2 rounded-lg border bg-card p-3","data-settings-row":"general.smartCompactEnabled",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h4",{className:"font-medium text-sm",children:[t("Context compaction strategy"),e.jsx(Je,{})]}),e.jsx("p",{className:"mt-0.5 text-muted-foreground text-xs",children:t("Standard uses default compact. Smart compaction uses Enso verified summary at compact time. Codex native compaction additionally stores an official Codex checkpoint on Codex models and uses smart compaction otherwise. Continuous memory records observations in the background so compact keeps more context; all fall back to default compact on failure. Switching strategy takes effect on the next session. The summary model and compaction mode apply to open conversations on the next compaction.")})]}),e.jsxs(Q,{items:Object.fromEntries(Un.map(m=>[m,t(ca[m])])),value:n,onValueChange:m=>r(m),children:[e.jsx(X,{className:"w-52",children:e.jsx(Z,{})}),e.jsx(ee,{children:Un.map(m=>e.jsx(H,{value:m,children:t(ca[m])},m))})]})]}),(n==="smart"||n==="codex-native")&&e.jsxs("div",{className:"flex items-center justify-between gap-4","data-smart-compact-mode":d,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Compaction mode")}),e.jsx("p",{className:"mt-0.5 text-muted-foreground/80 text-[11px]",children:t("Mode changes summary budget and how much recent tail to keep. It does not decide whether compact runs.")})]}),e.jsxs(Q,{items:Object.fromEntries($n.map(m=>[m,t(la[m])])),value:d,onValueChange:m=>x(m),children:[e.jsx(X,{className:"w-36",children:e.jsx(Z,{})}),e.jsx(ee,{children:$n.map(m=>e.jsx(H,{value:m,children:t(la[m])},m))})]})]}),o&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium text-sm",children:t(n==="continuous-memory"?"Background memory model":"Summary model")}),h.length>0&&e.jsx("div",{className:"w-full min-w-0",children:e.jsx(Fe,{providers:h,providerId:l?.id??"",modelId:p?.id??"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,emptyLabel:t("Follows the session model"),side:"bottom",triggerClassName:Xe,onSelect:(m,f)=>c({providerId:m,modelId:f}),onReasoningChange:()=>{},onThinkingChange:()=>{}})}),i&&(!l||!p)&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Selected model is unavailable — falls back to the session model.")}),i&&e.jsx(P,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>c(null),children:t("Follow session model")})]})]})}const Yd={cmd:"Command Prompt",powershell:"Windows PowerShell",pwsh:"PowerShell 7 (pwsh)","git-bash":"Git Bash",zsh:"zsh",bash:"bash",fish:"fish"};function Qd(){const{language:t,setLanguage:s}=w(),{t:a}=B();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:a("General")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("General application settings")})]}),e.jsxs("div",{className:"flex items-center gap-3","data-settings-row":"general.language",children:[e.jsx("span",{className:"text-sm font-medium",children:a("Language")}),e.jsxs(Q,{items:{en:"English",zh:"简体中文"},value:t,onValueChange:n=>s(n),children:[e.jsx(X,{className:"w-48",children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(H,{value:"en",children:"English"}),e.jsx(H,{value:"zh",children:"简体中文"})]})]})]}),e.jsx(Xd,{}),e.jsx(eu,{}),e.jsx(Zd,{}),e.jsx(Hd,{}),e.jsx(Jd,{}),e.jsx(nu,{}),e.jsx(tu,{}),e.jsx(su,{}),e.jsx(au,{}),e.jsx(Vd,{}),e.jsx(ru,{})]})}function Xd(){const{t}=B(),s=w(n=>n.notifyMainAgentOnly),a=w(n=>n.setNotifyMainAgentOnly);return e.jsx(Ae,{rowId:"general.notifyMainAgentOnly",title:t("Notify only for the main agent"),description:t("Skip coworker completion and failure notifications on this computer and the paired phone. Questions and approvals still notify."),checked:s,onChange:a})}function Zd(){const{t}=B(),s=w(y=>y.openChangesOnFileEdit),a=w(y=>y.setOpenChangesOnFileEdit),n=w(y=>y.compactReadOnlyTools),r=w(y=>y.setCompactReadOnlyTools),o=w(y=>y.expandLiveEdits),i=w(y=>y.setExpandLiveEdits),c=w(y=>y.expandLiveReasoning),d=w(y=>y.setExpandLiveReasoning),x=w(y=>y.autoCollapseTurns),h=w(y=>y.setAutoCollapseTurns),l=w(y=>y.collapseCompletedActivity),p=w(y=>y.setCollapseCompletedActivity),m=w(y=>y.pinUnfinishedTodos),f=w(y=>y.setPinUnfinishedTodos),j=w(y=>y.generationStallTimeoutMin),v=w(y=>y.setGenerationStallTimeoutMin),N=w(y=>y.autoRetryLimit),b=w(y=>y.setAutoRetryLimit),C=cs.some(y=>y===N)?[...cs]:[...cs,N].sort((y,g)=>y===ds?1:g===ds?-1:y-g),k=y=>y===0?t("Off"):y===ds?t("Unlimited"):t("{{count}} times",{count:y}),M=w(y=>y.activeRetentionMinutes),O=w(y=>y.setActiveRetentionMinutes),S=y=>y===0?t("Off"):t("{{count}} min",{count:y});return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ae,{rowId:"general.openChangesOnFileEdit",title:t("Open Changes when files are edited"),description:t("Automatically show the side panel Changes tab after the agent edits a file"),checked:s,onChange:a}),e.jsx(Ae,{rowId:"general.compactReadOnlyTools",title:t("Compact read-only tool calls"),description:t("Show read/grep/find/ls as one-line rows and fold consecutive tool calls while the agent is still running"),checked:n,onChange:r}),e.jsx(Ae,{rowId:"general.expandLiveEdits",title:t("Expand file edits while running"),description:t("Automatically unfold diffs or written content from file modification tools while the agent is still running"),checked:o,onChange:i}),e.jsx(Ae,{rowId:"general.expandLiveReasoning",title:t("Expand reasoning while streaming"),description:t("Automatically unfold the thinking block while the model is still reasoning. It collapses again when reasoning ends."),checked:c,onChange:d}),e.jsx(Ae,{rowId:"general.autoCollapseTurns",title:t("Auto-collapse previous turns"),description:t("After you send a new message, fold earlier turns down to the question, timestamp and duration; the latest turn stays expanded"),checked:x,onChange:h}),e.jsx(Ae,{rowId:"general.collapseCompletedActivity",title:t("Collapse activity after reply"),description:t("When a reply finishes, fold consecutive thinking and tool calls (including edits and commands) into one summary row; failed calls stay visible"),checked:l,onChange:p}),e.jsx(Ae,{rowId:"general.pinUnfinishedTodos",title:t("Pin unfinished todos"),description:t("Keep the latest todo list above the input while it has unfinished items, so it does not scroll away with the timeline"),checked:m,onChange:f}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.generationStallTimeout",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Stop if no output")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Abort and retry the run when no tokens or tool results arrive for this long. Thinking counts as output.")})]}),e.jsxs(Q,{items:Object.fromEntries(Kn.map(y=>[String(y),y===0?t("Never"):t("{{count}} min",{count:y})])),value:String(j),onValueChange:y=>v(Number(y)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:Kn.map(y=>e.jsx(H,{value:String(y),children:y===0?t("Never"):t("{{count}} min",{count:y})},y))})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.autoRetryLimit",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Auto-retry on transient errors")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Retry with backoff (up to 60s apart) after 429, 5xx or network errors. Quota and billing errors are never retried. Unlimited keeps retrying until you cancel.")})]}),e.jsxs(Q,{items:Object.fromEntries(C.map(y=>[String(y),k(y)])),value:String(N),onValueChange:y=>b(Number(y)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:C.map(y=>e.jsx(H,{value:String(y),children:k(y)},y))})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.activeRetentionMinutes",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Keep in Active after last message")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Viewed conversations stay in Active for this long after their last message or your last open while still in Active, then leave. Unviewed ones stay until you open them.")})]}),e.jsxs(Q,{items:Object.fromEntries(Gn.map(y=>[String(y),S(y)])),value:String(M),onValueChange:y=>O(Number(y)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:Gn.map(y=>e.jsx(H,{value:String(y),children:S(y)},y))})]})]})]})}function Ft(t,s){return s===0?t("Never"):s===1?t("{{count}} day",{count:s}):t("{{count}} days",{count:s})}function eu(){const{t}=B(),s=w(c=>c.autoArchiveIdleDays),a=w(c=>c.setAutoArchiveIdleDays),n=w(c=>c.autoArchiveMergedWorktrees),r=w(c=>c.setAutoArchiveMergedWorktrees),o=w(c=>c.autoDeleteArchivedDays),i=w(c=>c.setAutoDeleteArchivedDays);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.autoArchiveIdleDays",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Archive idle conversations")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Move conversations that have been idle this long into Archived. Does not delete them.")})]}),e.jsxs(Q,{items:Object.fromEntries(Vn.map(c=>[String(c),Ft(t,c)])),value:String(s),onValueChange:c=>a(Number(c)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:Vn.map(c=>e.jsx(H,{value:String(c),children:Ft(t,c)},c))})]})]}),e.jsx(Ae,{rowId:"general.autoArchiveMergedWorktrees",title:t("Clean up merged worktrees"),description:t("When archiving idle conversations, also remove isolated worktrees that are merged and clean."),checked:n,onChange:r}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.autoDeleteArchivedDays",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Delete archived conversations after")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Permanently delete conversations that have been archived longer than this. This cannot be undone. Choosing a positive value deletes already-overdue archived conversations immediately.")})]}),e.jsxs(Q,{items:Object.fromEntries(qn.map(c=>[String(c),Ft(t,c)])),value:String(o),onValueChange:c=>i(Number(c)),children:[e.jsx(X,{className:"w-28",children:e.jsx(Z,{})}),e.jsx(ee,{children:qn.map(c=>e.jsx(H,{value:String(c),children:Ft(t,c)},c))})]})]})]})}function tu(){const{t}=B(),s=w(o=>o.terminalShell),a=w(o=>o.setTerminalShell),n=Pi(window.electronAPI.env.platform),r=Object.fromEntries(n.map(o=>[o,o==="auto"?t("System default"):Yd[o]]));return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.terminalShell",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Terminal shell")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Applies to new side panel terminals. SSH projects keep the remote login shell.")})]}),e.jsxs(Q,{items:r,value:s,onValueChange:o=>a(o),children:[e.jsx(X,{className:"w-56",children:e.jsx(Z,{})}),e.jsx(ee,{children:n.map(o=>e.jsx(H,{value:o,children:r[o]},o))})]})]})}function su(){const{t}=B(),s=w(x=>x.worktreeRoot),a=w(x=>x.setWorktreeRoot),[n,r]=u.useState(s),[o,i]=u.useState(null);u.useEffect(()=>{r(s)},[s]);const c=x=>{const h=x.trim();if(h&&!Dd(h)){i(t("Enter an absolute path"));return}i(null),a(h)},d=async()=>{const x=await window.electronAPI.dialog.selectDirectory();x&&(r(x),c(x))};return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.worktreeRoot",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Worktree root directory")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Where isolated session worktrees are created. Leave empty to use the app data directory. Existing worktrees stay where they are.")})]}),e.jsxs("div",{className:"w-72 shrink-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{value:n,placeholder:t("Default location"),onChange:x=>r(x.target.value),onBlur:()=>c(n),onKeyDown:x=>{x.key==="Enter"&&c(n)}}),e.jsx(P,{variant:"outline",size:"sm",className:"shrink-0",onClick:()=>{d()},children:t("Browse")})]}),o&&e.jsx("p",{className:"text-xs text-destructive",children:o})]})]})}function nu(){const{t}=B(),s=w(r=>r.windowsLocalShell),a=w(r=>r.setWindowsLocalShell),n={auto:t("Windows default (PowerShell)"),powershell:t("PowerShell"),bash:t("Git Bash")};return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"general.windowsLocalShell",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm",children:[t("Windows local command shell"),e.jsx(Je,{})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Only the Windows local agent command tool. SSH and other platforms stay on bash. Takes effect on the next session.")})]}),e.jsxs(Q,{items:n,value:s,onValueChange:r=>a(r),children:[e.jsx(X,{className:"w-56",children:e.jsx(Z,{})}),e.jsx(ee,{children:Object.keys(n).map(r=>e.jsx(H,{value:r,children:n[r]},r))})]})]})}function Ae({title:t,description:s,checked:a,onChange:n,rowId:r}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":r,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s})]}),e.jsx(ie,{checked:a,onCheckedChange:o=>n(o===!0)})]})}function da(t,s){window.electronAPI.proxy.apply({mode:t,customUrl:s})}function au(){const{t}=B(),s=w(l=>l.proxyMode),a=w(l=>l.customProxyUrl),n=w(l=>l.setProxyMode),r=w(l=>l.setCustomProxyUrl),[o,i]=u.useState(a),[c,d]=u.useState(null);u.useEffect(()=>{i(a)},[a]);const x=l=>{n(l),da(l,a)},h=()=>{const l=o.trim();if(l&&!Ti(l)){d(t("Enter an http(s) proxy URL"));return}d(null),r(l),da(s,l)};return e.jsxs("div",{className:"space-y-3","data-settings-row":"general.proxy",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("Network proxy")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Used by model requests, the built-in browser, and agent tools")})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium",children:t("Proxy mode")}),e.jsxs(Q,{items:{system:t("Follow system proxy"),none:t("No proxy"),custom:t("Custom proxy")},value:s,onValueChange:l=>x(l),children:[e.jsx(X,{className:"w-56",children:e.jsx(Z,{})}),e.jsxs(ee,{children:[e.jsx(H,{value:"system",children:t("Follow system proxy")}),e.jsx(H,{value:"none",children:t("No proxy")}),e.jsx(H,{value:"custom",children:t("Custom proxy")})]})]})]}),s==="custom"&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"pt-1.5 text-sm font-medium",children:t("Proxy URL")}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx(K,{value:o,placeholder:"http://127.0.0.1:7890",onChange:l=>i(l.target.value),onBlur:h,onKeyDown:l=>{l.key==="Enter"&&h()}}),c&&e.jsx("p",{className:"text-xs text-destructive",children:c})]})]})]})}function ru(){const{t}=B(),s=w(j=>j.autoUpdate),a=w(j=>j.setAutoUpdate),n=w(j=>j.autoRestartWhenIdle),r=w(j=>j.setAutoRestartWhenIdle),[o,i]=u.useState(null),[c,d]=u.useState(null),[x,h]=u.useState(!1);u.useEffect(()=>{let j=!0;window.electronAPI.updater.getState().then(N=>{j&&(d(N),N.status&&i(b=>b??N.status))}).catch(()=>{});const v=window.electronAPI.updater.onStatus(i);return()=>{j=!1,v()}},[]);const l=c?.host==="server"?c:null,m=(()=>{if(!o)return null;switch(o.status){case"checking":return t("Checking for updates…");case"available":return t("New version {{version}} found",{version:o.info?.version??""});case"not-available":return t("You are on the latest version");case"downloading":return t("Downloading update… {{percent}}%",{percent:Math.round(o.progress?.percent??0)});case"downloaded":return t("New version {{version}} is ready — restart to update.",{version:o.info?.version??""});case"error":return l&&o.error?t("Update failed: {{error}}",{error:o.error}):t("Update check failed");default:return null}})(),f=o?.status==="checking"||o?.status==="downloading";return e.jsxs("div",{className:"space-y-3","data-settings-row":"general.updates",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium",children:t("Updates")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l?ou(l.mode,t):t("Application update settings")})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm",children:[t("Current version")," · ",iu]}),m&&e.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:m})]}),o?.status==="downloaded"?e.jsx(P,{size:"sm",onClick:()=>{window.electronAPI.updater.quitAndInstall()},className:"shrink-0",children:t("Restart to update")}):l&&l.mode!=="manual"&&o?.status==="available"?e.jsx(P,{size:"sm",onClick:()=>{window.electronAPI.updater.downloadUpdate()},className:"shrink-0",children:t("Download update")}):e.jsx(P,{variant:"outline",size:"sm",disabled:f,onClick:()=>{window.electronAPI.updater.checkForUpdates()},className:"shrink-0",children:t("Check for updates")})]}),l?.canRestart&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Restart server")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Running tasks are interrupted; this page reconnects after the server is back.")})]}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"shrink-0",children:t("Restart")}),e.jsx(Br,{open:x,onOpenChange:h,title:t("Restart server?"),description:t("Running tasks are interrupted; this page reconnects after the server is back."),confirmLabel:t("Restart"),onConfirm:()=>{h(!1),window.electronAPI.updater.restart()}})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Automatic updates")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Download and install updates automatically")})]}),e.jsx(ie,{checked:s,onCheckedChange:j=>{a(j),window.electronAPI.updater.setAutoUpdateEnabled(j)}})]}),e.jsxs("div",{className:`flex items-center justify-between gap-3 rounded-md border px-3 py-2.5 ${s?"":"opacity-60"}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Restart and apply when idle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("After the update is downloaded, restart automatically if no agent is running, nothing is queued, and there are no pending questions or approvals. The idle state must last 5 minutes, and a focused window also blocks it.")})]}),e.jsx(ie,{checked:s&&n,disabled:!s,onCheckedChange:j=>{r(j),window.electronAPI.updater.setAutoRestartWhenIdle(j)}})]})]})}function ou(t,s){return s(t==="npm"?"Server updates install the new version with npm and restart.":"This server must be updated on the machine itself.")}const iu="0.2.13",ua=15e3,lu=3e3;function cu(t){return!t||!t.timeoutSet&&t.timeoutMs===lu?ua:t.timeoutMs}const ma=()=>{},hs="off",xs=t=>({timeoutMs:t?.timeoutMs??Ri,...t?.timeoutSet&&{timeoutSet:!0}});function du({classifier:t,effectiveMs:s,hint:a,onChange:n}){const{t:r}=B(),[o,i]=u.useState(String(s/1e3));u.useEffect(()=>i(String(s/1e3)),[s]);const c=()=>{const d=Number(o);if(!o.trim()||!Number.isFinite(d))return i(String(s/1e3));const x=Li(d*1e3);i(String(x/1e3)),x!==s&&n({...t,timeoutMs:x,timeoutSet:!0})};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs",children:r("Timeout")}),e.jsx(K,{type:"number",value:o,min:Oi/1e3,max:Di/1e3,step:.5,className:"h-7 w-20 text-xs",onChange:d=>i(d.target.value),onBlur:c,onKeyDown:d=>{d.key==="Enter"&&d.currentTarget.blur()}}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r("seconds")}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:a})]})}function Gt({providers:t,value:s,emptyLabel:a,onSelect:n}){return e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Fe,{providers:t,providerId:s?.providerId??"",modelId:s?.modelId??"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,emptyLabel:a,side:"bottom",triggerClassName:Xe,onSelect:(r,o)=>n({providerId:r,modelId:o}),onReasoningChange:ma,onThinkingChange:ma})})}function Ut({label:t,hint:s,children:a}){return e.jsxs("div",{className:"grid grid-cols-[6rem_1fr] items-start gap-2",children:[e.jsxs("div",{className:"pt-1.5 text-xs",children:[e.jsx("div",{children:t}),s&&e.jsx("div",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsx("div",{className:"min-w-0 space-y-1",children:a})]})}function bo({value:t,onChange:s,providers:a,classifierProviders:n,offLabel:r,judgeLabel:o,judgeSeed:i,description:c,effectiveTimeoutMs:d,timeoutHint:x}){const{t:h}=B(),l=t,[p,m]=u.useState(!1),f=l?.source??(p?"judge":hs),j=l?.source==="pi-classifier"?l.model.providerId:"",[v,N]=u.useState([]),[b,C]=u.useState(!1);u.useEffect(()=>{if(!j){N([]);return}let S=!1;return window.electronAPI.providers.classifierModels(j).then(y=>{S||N(y)}),()=>{S=!0}},[j]);const k=async S=>{const g=(await window.electronAPI.providers.classifierModels(S))[0];C(!g),g&&s({source:"pi-classifier",model:{providerId:S,modelId:g.id},...xs(l)})},M=S=>{if(C(!1),m(S==="judge"&&!i),S===hs)return s(void 0);if(S==="judge")return s(i?{source:"judge",model:i,...xs(l)}:void 0);const y=n[0];y&&k(y.id)},O=[{value:hs,label:r},{value:"judge",label:o},...n.length>0?[{value:"pi-classifier",label:h("Classifier model")}]:[]];return e.jsxs("div",{className:"space-y-1",children:[e.jsxs(Q,{items:O,value:f,onValueChange:S=>M(String(S)),children:[e.jsx(X,{size:"sm",className:"w-48",children:e.jsx(Z,{})}),e.jsx(ee,{children:O.map(S=>e.jsx(H,{value:S.value,children:S.label},S.value))})]}),f==="judge"&&e.jsx(Gt,{providers:a,value:l?.source==="judge"?l.model:void 0,emptyLabel:h("Select model"),onSelect:S=>{m(!1),s({source:"judge",model:S,...xs(l)})}}),l?.source==="pi-classifier"&&e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Q,{items:n.map(S=>({value:S.id,label:S.name})),value:l.model.providerId,onValueChange:S=>{k(String(S))},children:[e.jsx(X,{size:"sm",className:"w-40",children:e.jsx(Z,{})}),e.jsx(ee,{children:n.map(S=>e.jsx(H,{value:S.id,children:S.name},S.id))})]}),e.jsxs(Q,{items:v.map(S=>({value:S.id,label:S.name})),value:l.model.modelId||null,onValueChange:S=>s({...l,model:{providerId:l.model.providerId,modelId:String(S)}}),children:[e.jsx(X,{size:"sm",className:"min-w-0 flex-1",children:e.jsx(Z,{placeholder:h("Select model")})}),e.jsx(ee,{children:v.map(S=>e.jsx(H,{value:S.id,children:S.name},S.id))})]})]}),b&&e.jsx("p",{className:"text-[10px] text-destructive",children:h("No classifier models available")}),l&&e.jsx(du,{classifier:l,effectiveMs:d??l.timeoutMs,hint:x,onChange:s}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:c})]})}function uu({entry:t,providers:s,classifierProviders:a,update:n}){const{t:r}=B();return t.fast?e.jsx(bo,{value:t.classifier,onChange:o=>n({classifier:o}),providers:s,classifierProviders:a,offLabel:r("Off"),judgeLabel:r("Fast model judges"),judgeSeed:t.fast,description:r("Classifies each new turn: simple turns use the fast model, complex ones the primary model. Adds a short delay before the reply."),timeoutHint:r("Uses the primary model on timeout.")}):e.jsx("p",{className:"pt-1.5 text-[11px] text-muted-foreground",children:r("Set a fast model first")})}function mu({entry:t,providers:s,classifierProviders:a}){const{t:n}=B(),r=w(x=>x.updateVirtualModel),o=w(x=>x.removeVirtualModel),i=[t.primary,...t.fast?[t.fast]:[],...t.fallbacks];let c;for(const x of s){const h=x.models.find(l=>l.enabled!==!1&&!i.some(p=>p.providerId===x.id&&p.modelId===l.id));if(h){c={providerId:x.id,modelId:h.id};break}}const d=x=>r(t.id,x);return e.jsxs("div",{"data-slot":"virtual-model-card",className:V("space-y-2 rounded-md border p-2",!t.enabled&&"bg-muted/50 text-muted-foreground"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{"aria-label":n("Enable virtual model"),checked:t.enabled,onCheckedChange:x=>d({enabled:x})}),e.jsx(K,{value:t.name,maxLength:60,placeholder:"Auto",className:"h-7 flex-1 text-xs",onChange:x=>d({name:x.target.value})}),!t.enabled&&e.jsx(te,{variant:"outline",className:"shrink-0 text-[10px] text-muted-foreground",children:n("Disabled")}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":n("Delete"),className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>o(t.id),children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]}),e.jsx(Ut,{label:n("Primary model"),hint:n("Default for each new turn"),children:e.jsx(Gt,{providers:s,value:t.primary,onSelect:x=>d({primary:x,fallbacks:t.fallbacks.filter(h=>h.providerId!==x.providerId||h.modelId!==x.modelId)})})}),e.jsx(Ut,{label:n("Fast model"),hint:n("Summaries and simple turns"),children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Gt,{providers:s,value:t.fast,emptyLabel:n("Not used"),onSelect:x=>d({fast:x})}),t.fast&&e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":n("Clear"),className:"h-6 w-6 shrink-0 text-muted-foreground",onClick:()=>d({fast:void 0}),children:e.jsx(wt,{className:"h-3.5 w-3.5"})})]})}),e.jsxs(Ut,{label:n("Fallback models"),hint:n("Used in order when a model is rate limited or down"),children:[t.fallbacks.map((x,h)=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Gt,{providers:s,value:x,onSelect:l=>d({fallbacks:t.fallbacks.map((p,m)=>m===h?l:p)})}),e.jsx(P,{type:"button",variant:"ghost",size:"icon","aria-label":n("Delete"),className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>d({fallbacks:t.fallbacks.filter((l,p)=>p!==h)}),children:e.jsx(wt,{className:"h-3.5 w-3.5"})})]},`${x.providerId}/${x.modelId}`)),e.jsxs(P,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:!c||t.fallbacks.length>=8,onClick:()=>{c&&d({fallbacks:[...t.fallbacks,c]})},children:[e.jsx(Ie,{className:"mr-1 h-3.5 w-3.5"}),n("Add fallback")]})]}),e.jsx(Ut,{label:n("Difficulty routing"),children:e.jsx(uu,{entry:t,providers:s,classifierProviders:a,update:d})})]})}function hu(){const{t}=B(),s=w(d=>d.virtualModels),a=w(d=>d.addVirtualModel),n=w(d=>d.defaultModel),r=He(),o=u.useMemo(()=>r.filter(_r),[r]),i=Fr(),c=u.useMemo(()=>{if(n&&o.find(x=>x.id===n.providerId)?.models.some(x=>x.id===n.modelId&&x.enabled!==!1))return n;for(const d of o){const x=d.models.find(h=>h.enabled!==!1);if(x)return{providerId:d.id,modelId:x.id}}return null},[o,n]);return e.jsxs("section",{"data-slot":"virtual-models",className:"space-y-2 rounded-lg border bg-card p-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm",children:t("Virtual models")}),e.jsx("p",{className:"mt-0.5 text-muted-foreground text-xs",children:t("A virtual model appears as one model in the picker and routes each request to a real model: fallbacks on rate limits or outages, image-capable or larger-context members when needed, and the fast model for summaries.")}),e.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:t("Applies to newly started conversations.")})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(d=>e.jsx(mu,{entry:d,providers:o,classifierProviders:i},d.id)),e.jsxs(P,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",disabled:!c,onClick:()=>{c&&a({name:"Auto",enabled:!0,primary:c,fallbacks:[]})},children:[e.jsx(Ie,{className:"mr-1 h-3.5 w-3.5"}),t("New virtual model")]}),!c&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Enable a model and configure valid provider credentials first.")})]})]})}function xu(){const{t}=B();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:t("Bot mode")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("Settings shared by all members and group chats.")})]}),e.jsx(fu,{}),e.jsx(gu,{}),e.jsx(pu,{})]})}const ha=Array.from({length:zi-Wn+1},(t,s)=>Wn+s);function pu(){const{t}=B(),s=w(n=>n.botMaxRunningTurns),a=w(n=>n.setBotMaxRunningTurns);return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border px-3 py-2.5","data-settings-row":"bots.maxRunningTurns",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm",children:t("Bot concurrency limit")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Shared by private chats, group chats, delegations and routines. Lowering it never interrupts running work; raising it may hit model rate limits.")})]}),e.jsxs(Q,{items:Object.fromEntries(ha.map(n=>[String(n),String(n)])),value:String(s),onValueChange:n=>a(Number(n)),children:[e.jsx(X,{className:"w-20",children:e.jsx(Z,{})}),e.jsx(ee,{children:ha.map(n=>e.jsx(H,{value:String(n),children:n},n))})]})]})}function fu(){const{t}=B(),s=w(i=>i.botAssistantModel),a=w(i=>i.setBotAssistantModel),n=He(),r=s?n.find(i=>i.id===s.providerId):void 0,o=r?.models.find(i=>i.id===s?.modelId);return e.jsxs("div",{className:"rounded-md border px-3 py-2.5","data-settings-row":"bots.assistantModel",children:[e.jsx("p",{className:"text-sm",children:t("Bot assistant model")}),e.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:t("Used for helper tasks such as auto-configuring member abilities.")}),e.jsx(Fe,{providers:n,providerId:o?r?.id??"":"",modelId:o?.id??"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,emptyLabel:t("Follows the default model"),side:"bottom",triggerClassName:Xe,onSelect:(i,c)=>a({providerId:i,modelId:c}),onReasoningChange:()=>{},onThinkingChange:()=>{}}),s&&!o&&e.jsx("p",{className:"mt-1 text-muted-foreground text-xs",children:t("Selected model is unavailable — falls back to the default model.")}),s&&e.jsx(P,{variant:"ghost",size:"sm",className:"mt-1",onClick:()=>a(null),children:t("Follow default model")})]})}function gu(){const{t}=B(),s=w(i=>i.botRouteClassifier),a=w(i=>i.setBotRouteClassifier),n=He(),r=u.useMemo(()=>n.filter(_r),[n]),o=Fr();return e.jsxs("div",{className:"rounded-md border px-3 py-2.5","data-settings-row":"bots.routeClassifier",children:[e.jsx("p",{className:"text-sm",children:t("Group reply picker model")}),e.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:t("When nobody is @-mentioned in a smart-routing group, this model picks which member replies.")}),e.jsx(bo,{value:s??void 0,onChange:i=>a(i??null),providers:r,classifierProviders:o,offLabel:t("Default (title model)"),judgeLabel:t("Fast chat model"),description:t("Falls back to the group owner on timeout, error or an unclear answer."),effectiveTimeoutMs:s?cu(s):void 0,timeoutHint:t("Handed to the group owner on timeout.")})]})}const ju=()=>({name:"",title:"",scope:"",summary:"",persona:"",color:en[0],tools:"all",approvalMode:"auto-edits"}),rn=(t,s)=>({key:t,name:"",title:"",scope:"",persona:"",color:en[s%en.length],tools:"all",approvalMode:"auto-edits",canDelegateTo:[],acceptFrom:[]}),vu=()=>({title:"",summary:"",bossKey:"m1",workspace:"chat-home",members:[rn("m1",0),rn("m2",1)]});function bu(t,s){const a=URL.createObjectURL(new Blob([JSON.stringify(s,null,2)],{type:"application/json"})),n=document.createElement("a");n.href=a,n.download=t,n.click(),URL.revokeObjectURL(a)}function yu(){const{t}=B(),s=Bi(!0),a=_i(!0),[n,r]=u.useState(null),[o,i]=u.useState(null),c=u.useRef(null),d=async(f,j)=>{const v=await Xi(N=>({...N,[f]:j(N[f])}));return v||Ke({type:"error",title:t("Could not save templates")}),v},x=(f,j)=>d("members",v=>f?Yn(v,f,j,sl):Qn(v,j,crypto.randomUUID())),h=(f,j)=>d("teams",v=>f?Yn(v,f,j,nl):Qn(v,j,crypto.randomUUID())),l=async f=>{const j=qi(await f.text());if(!j.ok){Ke({type:"error",title:Hn(j.error,t)});return}const v=Vr(Ki(j.team));if(!v){Ke({type:"error",title:Hn("invalid",t)});return}await h(void 0,v)&&Ke({type:"success",title:t("Imported as a custom team template")})},p=(f,j)=>d(f==="members"?"members":"teams",j),m=(f,j,v)=>e.jsxs(e.Fragment,{children:[e.jsx(ct,{label:t("Edit"),onClick:()=>v({id:j.id,data:j.data}),children:e.jsx(rt,{})}),e.jsx(ct,{label:t("Duplicate as custom"),onClick:()=>v({data:j.data}),children:e.jsx(Ur,{})}),j.source==="builtin"&&e.jsx(ct,{label:j.hidden?t("Show"):t("Hide"),onClick:()=>{p(f,N=>Zi(N,j.id,!j.hidden))},children:j.hidden?e.jsx($i,{}):e.jsx(Vi,{})}),j.modified&&e.jsx(ct,{label:t("Restore default"),onClick:()=>{p(f,N=>Xn(N,j.id))},children:e.jsx($r,{})}),j.source==="custom"&&e.jsx(ct,{label:t("Delete"),onClick:()=>{p(f,N=>Xn(N,j.id))},children:e.jsx(Ee,{})})]});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:t("Bot templates")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("Templates used when creating members and teams. Built-in templates can be edited, hidden or restored.")})]}),e.jsxs(Ot,{defaultValue:"members",children:[e.jsxs(Lt,{variant:"underline",children:[e.jsx(Ve,{value:"members",children:t("Member templates")}),e.jsx(Ve,{value:"teams",children:t("Team templates")})]}),e.jsxs(At,{value:"members",className:"space-y-2 pt-3",children:[e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>r({data:ju()}),children:[e.jsx(Ie,{}),t("New member template")]}),s.map(f=>e.jsx(xa,{item:f,avatar:e.jsx(Zs,{bot:{name:f.data.name,avatar:{color:f.data.color}}}),title:f.data.name,subtitle:f.data.title,summary:f.data.summary,actions:m("members",f,r)},f.id))]}),e.jsxs(At,{value:"teams",className:"space-y-2 pt-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>i({data:vu()}),children:[e.jsx(Ie,{}),t("New team template")]}),e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>c.current?.click(),children:[e.jsx(Fi,{}),t("Import team (JSON)")]}),e.jsx("input",{ref:c,type:"file",accept:".json,application/json",hidden:!0,onChange:f=>{const j=f.target.files?.[0];f.target.value="",j&&l(j)}})]}),a.map(f=>e.jsx(xa,{item:f,avatar:e.jsx("div",{className:"-space-x-1.5 flex shrink-0",children:f.data.members.slice(0,4).map(j=>e.jsx(Zs,{size:"sm",bot:{name:j.name,avatar:{color:j.color}}},j.key))}),title:f.data.title,subtitle:t("{{n}} members",{n:f.data.members.length}),summary:f.data.summary,actions:e.jsxs(e.Fragment,{children:[e.jsx(ct,{label:t("Export JSON"),onClick:()=>bu(`${f.data.title||"team"}.team.json`,{format:tl,version:el,exportedAt:new Date().toISOString(),team:Ui(f.data)}),children:e.jsx(pn,{})}),m("teams",f,i)]})},f.id))]})]}),n&&e.jsx(wu,{initial:n.data,onClose:()=>r(null),onSave:async f=>{await x(n.id,f)&&r(null)}}),o&&e.jsx(ku,{initial:o.data,onClose:()=>i(null),onSave:async f=>{await h(o.id,f)&&i(null)}})]})}function ct({label:t,onClick:s,disabled:a,children:n}){return e.jsx(P,{variant:"ghost",size:"icon-sm",title:t,"aria-label":t,disabled:a,onClick:s,children:n})}function xa({item:t,avatar:s,title:a,subtitle:n,summary:r,actions:o}){const{t:i}=B();return e.jsxs("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2.5","data-template-id":t.id,children:[e.jsxs("div",{className:V("flex min-w-0 flex-1 items-center gap-3",t.hidden&&"opacity-50"),children:[s,e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx("span",{className:"truncate",children:a}),e.jsx("span",{className:"truncate font-normal text-muted-foreground text-xs",children:n}),e.jsx(te,{variant:"secondary",children:t.source==="custom"?i("Custom"):i("Built-in")}),t.modified&&e.jsx(te,{variant:"outline",children:i("Modified")}),t.hidden&&e.jsx(te,{variant:"outline",children:i("Hidden")})]}),e.jsx("p",{className:"truncate text-muted-foreground text-xs",children:r})]})]}),e.jsx("div",{className:"flex shrink-0 items-center",children:o})]})}function yo({title:t,error:s,onClose:a,onSave:n,children:r}){const{t:o}=B(),[i,c]=u.useState(!1);return e.jsx(we,{open:!0,onOpenChange:d=>!d&&a(),children:e.jsxs(Ne,{className:"max-h-[85vh] max-w-2xl",children:[e.jsx(ke,{children:e.jsx(Ce,{children:t})}),e.jsxs(Pe,{className:"space-y-3",children:[r,s&&e.jsx("p",{className:"text-destructive text-xs",children:s})]}),e.jsxs(Se,{children:[e.jsx(P,{variant:"outline",size:"sm",onClick:a,children:o("Cancel")}),e.jsx(P,{size:"sm",disabled:i||!!s,onClick:()=>{c(!0),n().finally(()=>c(!1))},children:o("Save")})]})]})})}function wo({value:t,onChange:s}){const{t:a}=B(),n=t.name?qr(t.name,[],a):null;return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{children:a("Name")}),e.jsx(K,{value:t.name,onChange:r=>s({name:r.target.value})}),n&&e.jsx("p",{className:"mt-1 text-destructive text-xs",children:n})]}),e.jsxs("div",{children:[e.jsx(Be,{children:a("Title")}),e.jsx(K,{value:t.title,onChange:r=>s({title:r.target.value})})]}),e.jsxs("div",{children:[e.jsx(Be,{children:a("Avatar color")}),e.jsx(Yi,{value:t.color,onChange:r=>s({color:r})})]}),e.jsxs("div",{children:[e.jsx(Be,{children:a("Tools")}),e.jsx(Kr,{value:t.tools,options:[{value:"all",label:a("All tools")},{value:"readonly",label:a("Read-only")}],onChange:r=>s({tools:r})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:a("Approval mode")}),e.jsx(Qi,{value:t.approvalMode,onChange:r=>s({approvalMode:r}),zIndex:Qe.DROPDOWN_IN_MODAL})]}),t.summary!==void 0&&e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{hint:a("Shown on the template card"),children:a("Summary")}),e.jsx(K,{value:t.summary,onChange:r=>s({summary:r.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:a("Responsibilities")}),e.jsx(K,{value:t.scope,onChange:r=>s({scope:r.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:a("Persona")}),e.jsx(at,{rows:6,value:t.persona,onChange:r=>s({persona:r.target.value})})]})]})}function wu({initial:t,onClose:s,onSave:a}){const{t:n}=B(),[r,o]=u.useState(t),i=Gi(r);return e.jsx(yo,{title:n("Member template"),error:qr(r.name,[],n)??(i?null:n("Check the template fields")),onClose:s,onSave:()=>i?a(i):Promise.resolve(),children:e.jsx(wo,{value:r,onChange:c=>o(d=>({...d,...c}))})})}function Nu(t,s){switch(t){case"title":return s("Enter a team title");case"members":return s("A team needs 2–12 members");case"name":return s("Every member needs a valid name");case"invalid":return s("Check the template fields");default:return null}}function ku({initial:t,onClose:s,onSave:a}){const{t:n}=B(),[r,o]=u.useState(t),[i,c]=u.useState(null),d=f=>r.members.find(j=>j.key===f)?.name||f,x=f=>o(j=>({...j,...f})),h=(f,j)=>o(v=>({...v,members:v.members.map(N=>N.key===f?{...N,...j}:N)})),l=()=>{const f=new Set(r.members.map(N=>N.key));let j=r.members.length+1;for(;f.has(`m${j}`);)j++;const v=`m${j}`;x({members:[...r.members,rn(v,r.members.length)]}),c(v)},p=f=>{const j=v=>v==="any"?"any":v.filter(N=>N!==f);x({members:r.members.filter(v=>v.key!==f).map(v=>({...v,canDelegateTo:j(v.canDelegateTo),acceptFrom:j(v.acceptFrom)}))})},m=Vr(r);return e.jsxs(yo,{title:n("Team template"),error:Nu(Ji(r),n),onClose:s,onSave:()=>m?a(m):Promise.resolve(),children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(Be,{children:n("Group name")}),e.jsx(K,{value:r.title,onChange:f=>x({title:f.target.value})})]}),e.jsxs("div",{children:[e.jsx(Be,{children:n("Owner")}),e.jsxs(Q,{items:r.members.map(f=>({value:f.key,label:d(f.key)})),value:r.bossKey,onValueChange:f=>x({bossKey:f}),children:[e.jsx(X,{className:"w-full",children:e.jsx(Z,{})}),e.jsx(ee,{zIndex:Qe.DROPDOWN_IN_MODAL,children:r.members.map(f=>e.jsx(H,{value:f.key,children:d(f.key)},f.key))})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{hint:n("Shown on the template card"),children:n("Summary")}),e.jsx(K,{value:r.summary,onChange:f=>x({summary:f.target.value})})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(Be,{children:n("Shared workspace")}),e.jsx(Kr,{value:r.workspace,options:[{value:"chat-home",label:n("Standalone workspace")},{value:"project",label:n("Based on a Code project")}],onChange:f=>x({workspace:f})})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:n("Members")}),e.jsxs(P,{size:"xs",variant:"outline",disabled:r.members.length>=Wi,onClick:l,children:[e.jsx(Ie,{}),n("Add member")]})]}),e.jsx("div",{className:"space-y-1.5",children:r.members.map(f=>{const j=i===f.key,v=f.key===r.bossKey,N=r.members.filter(b=>b.key!==f.key).map(b=>b.key);return e.jsxs("div",{className:"rounded-lg border","data-member-key":f.key,children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left",onClick:()=>c(j?null:f.key),children:[j?e.jsx(tn,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Rt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx(Zs,{bot:{name:f.name,avatar:{color:f.color}},size:"sm"}),e.jsx("span",{className:"truncate text-sm",children:f.name||n("Unnamed")}),e.jsx("span",{className:"truncate text-muted-foreground text-xs",children:f.title}),v&&e.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground",children:[e.jsx(Hi,{className:"h-3 w-3"}),n("Owner")]})]}),e.jsx(ct,{label:n("Remove"),disabled:v||r.members.length<=2,onClick:()=>p(f.key),children:e.jsx(Ee,{})})]}),j&&e.jsxs("div",{className:"space-y-3 border-t p-2.5",children:[e.jsx(wo,{value:f,onChange:b=>h(f.key,b)}),e.jsx(Jn,{label:n("Can delegate to"),value:f.canDelegateTo,options:N,nameOf:d,onChange:b=>h(f.key,{canDelegateTo:b})}),e.jsx(Jn,{label:n("Accepts delegation from"),value:f.acceptFrom,options:N,nameOf:d,onChange:b=>h(f.key,{acceptFrom:b})})]})]},f.key)})})]})]})}function No(t){return t.capturePermission==="unsupported"&&t.axPermission==="unsupported"?"unsupported":t.capturePermission==="granted"&&(t.axPermission==="granted"||t.axPermission==="unsupported")?"ready":"needs-permission"}function Cu(t){return Object.fromEntries(t.map(s=>[s.id,s]))}function ts(t,s){return t.reduce((a,n)=>{const r=s[n]?.tokens;return r==null?a:a+r},0)}function ss({row:t,pending:s}){const{t:a}=B(),n=s?"…":t?.tokens==null?"—":_e(t.tokens);return e.jsx("span",{className:"w-12 shrink-0 text-right text-muted-foreground text-xs tabular-nums",title:t?.error||a("Estimate"),children:n})}function ns({tokens:t}){return t<=0?null:e.jsx("span",{className:"ml-2 font-normal text-muted-foreground text-xs tabular-nums",children:_e(t)})}function as(t,s){const[a,n]=u.useState({}),[r,o]=u.useState(()=>t.length>0),i=t.join("\0"),c=u.useRef(s);return c.current=s,u.useEffect(()=>{let d=!1;const x=i.length===0?[]:i.split("\0");if(x.length===0){n({}),o(!1);return}return o(!0),c.current(x).then(h=>{d||n(Cu(h))}).finally(()=>{d||o(!1)}),()=>{d=!0}},[i]),{rows:a,pending:r}}const pa={replace:"Text replacement",apply_patch:"Apply patch (default)"},Su={subagent:dl,workflow:kn,todo:cl,plan:ll,ask_user:il,browser:ol,web:rl,background_tasks:al,memory:Gr,isolated_sandbox:Wc,computer:xn};function St({icon:t,title:s,description:a,control:n,children:r,rowId:o,newSession:i}){return e.jsxs("div",{className:"rounded-md border px-3 py-2.5","data-settings-row":o,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium",children:[s,i&&e.jsx(Je,{})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:a})]}),n]}),r?e.jsx("div",{className:"mt-2 space-y-2 pl-7",children:r}):null]})}function Iu({disabled:t}){const{t:s}=B(),a=w(l=>l.webSearchChain),n=w(l=>l.setWebSearchChain),r=Zt(),o=u.useMemo(()=>hl(r),[r]),[i,c]=u.useState(null),d=(l,p)=>{n(a.map((m,f)=>f===l?{...m,...p}:m))},x=l=>n(a.filter((p,m)=>m!==l)),h=(l,p)=>{if(l===p)return;const m=[...a],[f]=m.splice(l,1);f&&(m.splice(p,0,f),n(m))};return e.jsxs("div",{className:"space-y-2","data-settings-row":"tools.webSearchChain",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:s("Try these models' built-in search in order. Credentials resolve at call time; if all fail, the keyless Exa service is the permanent fallback.")}),a.length===0&&e.jsx("p",{className:"text-muted-foreground text-xs",children:s("Default: use the current session model's built-in search when available, otherwise Exa.")}),a.map((l,p)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border px-2 py-1.5",draggable:!t,onDragStart:m=>{m.dataTransfer.effectAllowed="move",c(p)},onDragEnd:()=>c(null),onDragOver:m=>{i!==null&&i!==p&&m.preventDefault()},onDrop:m=>{m.preventDefault(),i!==null&&h(i,p),c(null)},children:[e.jsx(xl,{className:"h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground"}),e.jsx("span",{className:"w-4 shrink-0 text-center text-muted-foreground text-xs",children:p+1}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Fe,{providers:o,providerId:l.providerId,modelId:l.modelId,reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,onSelect:(m,f)=>d(p,{providerId:m,modelId:f}),onReasoningChange:()=>{},onThinkingChange:()=>{}})}),e.jsx(P,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 shrink-0 p-0",disabled:t,onClick:()=>x(p),"aria-label":s("Remove"),children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]},`${l.providerId}/${l.modelId}`)),a.length<pl&&e.jsx("div",{className:"max-w-xs",children:e.jsx(Fe,{providers:o,providerId:"",modelId:"",reasoningEnabled:!1,thinkingLevel:"medium",showReasoningControls:!1,triggerLabel:`+ ${s("Add candidate")}`,onSelect:(l,p)=>n([...a,{providerId:l,modelId:p}]),onReasoningChange:()=>{},onThinkingChange:()=>{}})}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s("Final fallback: Exa (keyless hosted search). Not a chain entry; always last.")})]})}function Eu(){const{t}=B(),s=w(g=>g.disabledBuiltinTools),a=w(g=>g.toggleBuiltinTool),n=w(g=>g.subagentAllowedModes),r=w(g=>g.setSubagentAllowedModes),o=w(g=>g.exploreFoldEnabled),i=w(g=>g.setExploreFoldEnabled),c=w(g=>g.rtkEnabled),d=w(g=>g.setRtkEnabled),x=w(g=>g.protectedActionsInCode),h=w(g=>g.setProtectedActionsInCode),l=w(g=>g.editMode),p=w(g=>g.setEditMode),m=as(us.map(g=>g.id),()=>window.electronAPI.assets.builtinToolOccupancy()),f=ts(us.filter(g=>!s.includes(g.id)).map(g=>g.id),m.rows),[j,v]=u.useState(null),N=!s.includes("subagent"),b=(g,E)=>{r(E?[...new Set([...n,g])]:n.filter(I=>I!==g))},C=async g=>{await window.electronAPI.browser.clearData(g),v(g),setTimeout(()=>v(null),2e3)},k=!s.includes("computer"),[M,O]=u.useState(null),[S,y]=u.useState(!1);return u.useEffect(()=>{if(!k){O(null);return}let g=!1;return window.electronAPI.computer.capabilities().then(E=>{!g&&E.ok&&O(E.capabilities)}),()=>{g=!0}},[k]),u.useEffect(()=>{if(!S)return;let g=!1;const E=()=>{window.electronAPI.computer.capabilities().then(D=>{!g&&D.ok&&O(D.capabilities)})};E();const I=window.setInterval(E,2e3);return()=>{g=!0,window.clearInterval(I)}},[S]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{"data-settings-row":"tools.root",children:[e.jsxs("h3",{className:"font-medium text-lg",children:[t("Built-in tools"),e.jsx(ns,{tokens:f}),e.jsx(Je,{note:t("Turning a tool on applies to new sessions. Turning off Memory or Computer also blocks it in open sessions.")})]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:t("Toggle the built-in tools available to agents.")})]}),e.jsxs("div",{className:"space-y-2",children:[us.map(g=>e.jsxs(St,{icon:Su[g.id]??Wr,title:t(g.name),description:t(g.description),control:e.jsxs(e.Fragment,{children:[e.jsx(ss,{row:m.rows[g.id],pending:m.pending&&!m.rows[g.id]}),e.jsx(ie,{checked:!s.includes(g.id),onCheckedChange:E=>{a(g.id,E),g.id==="computer"&&E&&y(!0)}})]}),children:[g.id==="web"?e.jsx(Iu,{disabled:s.includes("web")}):null,g.id==="subagent"?e.jsxs("div",{className:"space-y-2","data-settings-row":"tools.subagentModes",children:[[["task","One-shot task agents"],["coworker","Persistent coworkers"]].map(([E,I])=>e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-sm",children:t(I)}),e.jsx(ie,{checked:n.includes(E),disabled:!N,onCheckedChange:D=>b(E,D)})]},E)),!N&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("The unified subagent tool is off. Re-enabling it keeps this mode selection.")})]}):null,g.id==="computer"&&k?e.jsx("div",{className:"space-y-2","data-settings-row":"tools.computer",children:M&&No(M)==="unsupported"?e.jsx("p",{className:"text-muted-foreground text-xs",children:t("This platform cannot operate the desktop yet.")}):e.jsxs(e.Fragment,{children:[M?.platform==="darwin"&&e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Computer needs Screen Recording to capture windows and Accessibility to inspect or click them. Grant both to EnsoCode, then restart the app.")}),M&&e.jsxs("p",{className:"text-muted-foreground text-xs",children:[t(M.capturePermission==="granted"?"Capture: granted":"Capture: denied"),M.axPermission!=="unsupported"&&e.jsxs(e.Fragment,{children:[" · ",t(M.axPermission==="granted"?"Input/AX: granted":"Input/AX: denied")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>y(!0),children:t("Show permission guide")}),M?.platform==="darwin"&&e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("screen")},children:t("Open Screen Recording settings")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("accessibility")},children:t("Open Accessibility settings")})]})]})]})}):null,g.id==="browser"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-muted-foreground text-xs",children:t("Cookies and site storage of the built-in browser, separate from the app itself.")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:["cookies","cache","all"].map(E=>e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{C(E)},children:t(j===E?"Cleared":E==="cookies"?"Clear cookies":E==="cache"?"Clear cache":"Clear all browsing data")},E))})]}):null]},g.id)),e.jsx(Au,{open:S,capabilities:M,onOpenChange:y}),e.jsx(St,{icon:ul,newSession:!0,title:t("Explore fold"),description:t("Let the agent mark exploratory reads and keep only a short report in later model context. Timeline stays intact."),control:e.jsx(ie,{checked:o,onCheckedChange:i})}),e.jsx(St,{rowId:"tools.rtkEnabled",newSession:!0,icon:hd,title:t("RTK command compression"),description:t("Compress supported command output before it enters the model context. Takes effect on new conversations."),control:e.jsx(ie,{checked:c,onCheckedChange:d})}),e.jsx(St,{icon:fn,newSession:!0,title:t("Protected action confirmation"),description:t("Even in full-access mode, ask before external sends, deletions, payments, deployments and secret-file access. Always on for Bot members not set to Full access. Takes effect on new conversations."),control:e.jsx(ie,{checked:x,onCheckedChange:h})}),e.jsx(St,{rowId:"tools.editMode",newSession:!0,icon:Zc,title:t("File edit mode"),description:t("Choose how files are modified. Apply patch is the default. New and cold-restored sessions use this mode; already warm sessions keep their current mode."),control:e.jsxs(Q,{items:Object.fromEntries(Zn.map(g=>[g,t(pa[g])])),value:l,onValueChange:g=>{ml(g)&&p(g)},children:[e.jsx(X,{className:"w-44 shrink-0","aria-label":t("File edit mode"),children:e.jsx(Z,{})}),e.jsx(ee,{children:Zn.map(g=>e.jsx(H,{value:g,children:t(pa[g])},g))})]})})]})]})}function Au({open:t,capabilities:s,onOpenChange:a}){const{t:n}=B(),r=s?No(s):null;return e.jsx(we,{open:t,onOpenChange:a,children:e.jsxs(Ne,{className:"max-w-md",zIndexLevel:"nested",children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:n("Grant Computer permissions")}),e.jsx($e,{children:n(r==="unsupported"?"This platform cannot operate the desktop yet.":r==="ready"?"Computer is ready. Start a new session to use it.":"The agent can screenshot windows and control the mouse and keyboard. Grant Screen Recording and Accessibility to EnsoCode, then restart. Only new sessions pick up the tool.")})]}),e.jsxs(Pe,{className:"space-y-3",children:[!s&&e.jsx("p",{className:"text-muted-foreground text-sm",children:n("Loading…")}),r==="needs-permission"&&e.jsxs("div",{className:"flex gap-2 rounded-md border border-destructive/32 bg-destructive/8 p-3 text-sm",children:[e.jsx(Ue,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsx("p",{children:n("Computer needs Screen Recording to capture windows and Accessibility to inspect or click them. Grant both to EnsoCode, then restart the app.")})]}),s?.platform==="darwin"&&r!=="unsupported"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-muted-foreground text-xs",children:[n(s.capturePermission==="granted"?"Capture: granted":"Capture: denied")," · ",n(s.axPermission==="granted"?"Input/AX: granted":"Input/AX: denied"),s.detail?` · ${s.detail}`:""]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("screen")},children:n("Open Screen Recording settings")}),e.jsx(P,{variant:"outline",size:"sm",onClick:()=>{window.electronAPI.computer.openPermissions("accessibility")},children:n("Open Accessibility settings")})]})]})]}),e.jsx(Se,{className:"sm:justify-end",children:e.jsx(P,{size:"sm",onClick:()=>a(!1),children:n("Done")})})]})})}function Mu(t){if(t==null||!Number.isFinite(t)||t<0)return null;const s=Math.round(t);return s<1?"<1ms":`${s}ms`}var ft={},ps,fa;function Pu(){return fa||(fa=1,ps=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ps}var fs={},tt={},ga;function dt(){if(ga)return tt;ga=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return tt.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},tt.getSymbolTotalCodewords=function(n){return s[n]},tt.getBCHDigit=function(a){let n=0;for(;a!==0;)n++,a>>>=1;return n},tt.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');t=n},tt.isKanjiModeEnabled=function(){return typeof t<"u"},tt.toSJIS=function(n){return t(n)},tt}var gs={},ja;function Mn(){return ja||(ja=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+a)}}t.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},t.from=function(n,r){if(t.isValid(n))return n;try{return s(n)}catch{return r}}})(gs)),gs}var js,va;function Tu(){if(va)return js;va=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const a=Math.floor(s/8);return(this.buffer[a]>>>7-s%8&1)===1},put:function(s,a){for(let n=0;n<a;n++)this.putBit((s>>>a-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),s&&(this.buffer[a]|=128>>>this.length%8),this.length++}},js=t,js}var vs,ba;function Ru(){if(ba)return vs;ba=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,a,n,r){const o=s*this.size+a;this.data[o]=n,r&&(this.reservedBit[o]=!0)},t.prototype.get=function(s,a){return this.data[s*this.size+a]},t.prototype.xor=function(s,a,n){this.data[s*this.size+a]^=n},t.prototype.isReserved=function(s,a){return this.reservedBit[s*this.size+a]},vs=t,vs}var bs={},ya;function Du(){return ya||(ya=1,(function(t){const s=dt().getSymbolSize;t.getRowColCoords=function(n){if(n===1)return[];const r=Math.floor(n/7)+2,o=s(n),i=o===145?26:Math.ceil((o-13)/(2*r-2))*2,c=[o-7];for(let d=1;d<r-1;d++)c[d]=c[d-1]-i;return c.push(6),c.reverse()},t.getPositions=function(n){const r=[],o=t.getRowColCoords(n),i=o.length;for(let c=0;c<i;c++)for(let d=0;d<i;d++)c===0&&d===0||c===0&&d===i-1||c===i-1&&d===0||r.push([o[c],o[d]]);return r}})(bs)),bs}var ys={},wa;function Ou(){if(wa)return ys;wa=1;const t=dt().getSymbolSize,s=7;return ys.getPositions=function(n){const r=t(n);return[[0,0],[r-s,0],[0,r-s]]},ys}var ws={},Na;function Lu(){return Na||(Na=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},t.from=function(r){return t.isValid(r)?parseInt(r,10):void 0},t.getPenaltyN1=function(r){const o=r.size;let i=0,c=0,d=0,x=null,h=null;for(let l=0;l<o;l++){c=d=0,x=h=null;for(let p=0;p<o;p++){let m=r.get(l,p);m===x?c++:(c>=5&&(i+=s.N1+(c-5)),x=m,c=1),m=r.get(p,l),m===h?d++:(d>=5&&(i+=s.N1+(d-5)),h=m,d=1)}c>=5&&(i+=s.N1+(c-5)),d>=5&&(i+=s.N1+(d-5))}return i},t.getPenaltyN2=function(r){const o=r.size;let i=0;for(let c=0;c<o-1;c++)for(let d=0;d<o-1;d++){const x=r.get(c,d)+r.get(c,d+1)+r.get(c+1,d)+r.get(c+1,d+1);(x===4||x===0)&&i++}return i*s.N2},t.getPenaltyN3=function(r){const o=r.size;let i=0,c=0,d=0;for(let x=0;x<o;x++){c=d=0;for(let h=0;h<o;h++)c=c<<1&2047|r.get(x,h),h>=10&&(c===1488||c===93)&&i++,d=d<<1&2047|r.get(h,x),h>=10&&(d===1488||d===93)&&i++}return i*s.N3},t.getPenaltyN4=function(r){let o=0;const i=r.data.length;for(let d=0;d<i;d++)o+=r.data[d];return Math.abs(Math.ceil(o*100/i/5)-10)*s.N4};function a(n,r,o){switch(n){case t.Patterns.PATTERN000:return(r+o)%2===0;case t.Patterns.PATTERN001:return r%2===0;case t.Patterns.PATTERN010:return o%3===0;case t.Patterns.PATTERN011:return(r+o)%3===0;case t.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(o/3))%2===0;case t.Patterns.PATTERN101:return r*o%2+r*o%3===0;case t.Patterns.PATTERN110:return(r*o%2+r*o%3)%2===0;case t.Patterns.PATTERN111:return(r*o%3+(r+o)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}t.applyMask=function(r,o){const i=o.size;for(let c=0;c<i;c++)for(let d=0;d<i;d++)o.isReserved(d,c)||o.xor(d,c,a(r,d,c))},t.getBestMask=function(r,o){const i=Object.keys(t.Patterns).length;let c=0,d=1/0;for(let x=0;x<i;x++){o(x),t.applyMask(x,r);const h=t.getPenaltyN1(r)+t.getPenaltyN2(r)+t.getPenaltyN3(r)+t.getPenaltyN4(r);t.applyMask(x,r),h<d&&(d=h,c=x)}return c}})(ws)),ws}var $t={},ka;function ko(){if(ka)return $t;ka=1;const t=Mn(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],a=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $t.getBlocksCount=function(r,o){switch(o){case t.L:return s[(r-1)*4+0];case t.M:return s[(r-1)*4+1];case t.Q:return s[(r-1)*4+2];case t.H:return s[(r-1)*4+3];default:return}},$t.getTotalCodewordsCount=function(r,o){switch(o){case t.L:return a[(r-1)*4+0];case t.M:return a[(r-1)*4+1];case t.Q:return a[(r-1)*4+2];case t.H:return a[(r-1)*4+3];default:return}},$t}var Ns={},It={},Ca;function zu(){if(Ca)return It;Ca=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let n=1;for(let r=0;r<255;r++)t[r]=n,s[n]=r,n<<=1,n&256&&(n^=285);for(let r=255;r<512;r++)t[r]=t[r-255]})(),It.log=function(n){if(n<1)throw new Error("log("+n+")");return s[n]},It.exp=function(n){return t[n]},It.mul=function(n,r){return n===0||r===0?0:t[s[n]+s[r]]},It}var Sa;function Bu(){return Sa||(Sa=1,(function(t){const s=zu();t.mul=function(n,r){const o=new Uint8Array(n.length+r.length-1);for(let i=0;i<n.length;i++)for(let c=0;c<r.length;c++)o[i+c]^=s.mul(n[i],r[c]);return o},t.mod=function(n,r){let o=new Uint8Array(n);for(;o.length-r.length>=0;){const i=o[0];for(let d=0;d<r.length;d++)o[d]^=s.mul(r[d],i);let c=0;for(;c<o.length&&o[c]===0;)c++;o=o.slice(c)}return o},t.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let o=0;o<n;o++)r=t.mul(r,new Uint8Array([1,s.exp(o)]));return r}})(Ns)),Ns}var ks,Ia;function _u(){if(Ia)return ks;Ia=1;const t=Bu();function s(a){this.genPoly=void 0,this.degree=a,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(n){this.degree=n,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(n.length+this.degree);r.set(n);const o=t.mod(r,this.genPoly),i=this.degree-o.length;if(i>0){const c=new Uint8Array(this.degree);return c.set(o,i),c}return o},ks=s,ks}var Cs={},Ss={},Is={},Ea;function Co(){return Ea||(Ea=1,Is.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),Is}var qe={},Aa;function So(){if(Aa)return qe;Aa=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let a="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";a=a.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+a+`)(?:.|[\r
10
10
  ]))+`;qe.KANJI=new RegExp(a,"g"),qe.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),qe.BYTE=new RegExp(n,"g"),qe.NUMERIC=new RegExp(t,"g"),qe.ALPHANUMERIC=new RegExp(s,"g");const r=new RegExp("^"+a+"$"),o=new RegExp("^"+t+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return qe.testKanji=function(d){return r.test(d)},qe.testNumeric=function(d){return o.test(d)},qe.testAlphanumeric=function(d){return i.test(d)},qe}var Ma;function ut(){return Ma||(Ma=1,(function(t){const s=Co(),a=So();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(o,i){if(!o.ccBits)throw new Error("Invalid mode: "+o);if(!s.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?o.ccBits[0]:i<27?o.ccBits[1]:o.ccBits[2]},t.getBestModeForData=function(o){return a.testNumeric(o)?t.NUMERIC:a.testAlphanumeric(o)?t.ALPHANUMERIC:a.testKanji(o)?t.KANJI:t.BYTE},t.toString=function(o){if(o&&o.id)return o.id;throw new Error("Invalid mode")},t.isValid=function(o){return o&&o.bit&&o.ccBits};function n(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+r)}}t.from=function(o,i){if(t.isValid(o))return o;try{return n(o)}catch{return i}}})(Ss)),Ss}var Pa;function Fu(){return Pa||(Pa=1,(function(t){const s=dt(),a=ko(),n=Mn(),r=ut(),o=Co(),i=7973,c=s.getBCHDigit(i);function d(p,m,f){for(let j=1;j<=40;j++)if(m<=t.getCapacity(j,f,p))return j}function x(p,m){return r.getCharCountIndicator(p,m)+4}function h(p,m){let f=0;return p.forEach(function(j){const v=x(j.mode,m);f+=v+j.getBitsLength()}),f}function l(p,m){for(let f=1;f<=40;f++)if(h(p,f)<=t.getCapacity(f,m,r.MIXED))return f}t.from=function(m,f){return o.isValid(m)?parseInt(m,10):f},t.getCapacity=function(m,f,j){if(!o.isValid(m))throw new Error("Invalid QR Code version");typeof j>"u"&&(j=r.BYTE);const v=s.getSymbolTotalCodewords(m),N=a.getTotalCodewordsCount(m,f),b=(v-N)*8;if(j===r.MIXED)return b;const C=b-x(j,m);switch(j){case r.NUMERIC:return Math.floor(C/10*3);case r.ALPHANUMERIC:return Math.floor(C/11*2);case r.KANJI:return Math.floor(C/13);case r.BYTE:default:return Math.floor(C/8)}},t.getBestVersionForData=function(m,f){let j;const v=n.from(f,n.M);if(Array.isArray(m)){if(m.length>1)return l(m,v);if(m.length===0)return 1;j=m[0]}else j=m;return d(j.mode,j.getLength(),v)},t.getEncodedBits=function(m){if(!o.isValid(m)||m<7)throw new Error("Invalid QR Code version");let f=m<<12;for(;s.getBCHDigit(f)-c>=0;)f^=i<<s.getBCHDigit(f)-c;return m<<12|f}})(Cs)),Cs}var Es={},Ta;function Uu(){if(Ta)return Es;Ta=1;const t=dt(),s=1335,a=21522,n=t.getBCHDigit(s);return Es.getEncodedBits=function(o,i){const c=o.bit<<3|i;let d=c<<10;for(;t.getBCHDigit(d)-n>=0;)d^=s<<t.getBCHDigit(d)-n;return(c<<10|d)^a},Es}var As={},Ms,Ra;function $u(){if(Ra)return Ms;Ra=1;const t=ut();function s(a){this.mode=t.NUMERIC,this.data=a.toString()}return s.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){let r,o,i;for(r=0;r+3<=this.data.length;r+=3)o=this.data.substr(r,3),i=parseInt(o,10),n.put(i,10);const c=this.data.length-r;c>0&&(o=this.data.substr(r),i=parseInt(o,10),n.put(i,c*3+1))},Ms=s,Ms}var Ps,Da;function Vu(){if(Da)return Ps;Da=1;const t=ut(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function a(n){this.mode=t.ALPHANUMERIC,this.data=n}return a.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},a.prototype.getLength=function(){return this.data.length},a.prototype.getBitsLength=function(){return a.getBitsLength(this.data.length)},a.prototype.write=function(r){let o;for(o=0;o+2<=this.data.length;o+=2){let i=s.indexOf(this.data[o])*45;i+=s.indexOf(this.data[o+1]),r.put(i,11)}this.data.length%2&&r.put(s.indexOf(this.data[o]),6)},Ps=a,Ps}var Ts,Oa;function qu(){if(Oa)return Ts;Oa=1;const t=ut();function s(a){this.mode=t.BYTE,typeof a=="string"?this.data=new TextEncoder().encode(a):this.data=new Uint8Array(a)}return s.getBitsLength=function(n){return n*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(a){for(let n=0,r=this.data.length;n<r;n++)a.put(this.data[n],8)},Ts=s,Ts}var Rs,La;function Ku(){if(La)return Rs;La=1;const t=ut(),s=dt();function a(n){this.mode=t.KANJI,this.data=n}return a.getBitsLength=function(r){return r*13},a.prototype.getLength=function(){return this.data.length},a.prototype.getBitsLength=function(){return a.getBitsLength(this.data.length)},a.prototype.write=function(n){let r;for(r=0;r<this.data.length;r++){let o=s.toSJIS(this.data[r]);if(o>=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
11
11
  Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),n.put(o,13)}},Rs=a,Rs}var Ds={exports:{}},za;function Gu(){return za||(za=1,(function(t){var s={single_source_shortest_paths:function(a,n,r){var o={},i={};i[n]=0;var c=s.PriorityQueue.make();c.push(n,0);for(var d,x,h,l,p,m,f,j,v;!c.empty();){d=c.pop(),x=d.value,l=d.cost,p=a[x]||{};for(h in p)p.hasOwnProperty(h)&&(m=p[h],f=l+m,j=i[h],v=typeof i[h]>"u",(v||j>f)&&(i[h]=f,c.push(h,f),o[h]=x))}if(typeof r<"u"&&typeof i[r]>"u"){var N=["Could not find a path from ",n," to ",r,"."].join("");throw new Error(N)}return o},extract_shortest_path_from_predecessor_list:function(a,n){for(var r=[],o=n;o;)r.push(o),a[o],o=a[o];return r.reverse(),r},find_path:function(a,n,r){var o=s.single_source_shortest_paths(a,n,r);return s.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(a){var n=s.PriorityQueue,r={},o;a=a||{};for(o in n)n.hasOwnProperty(o)&&(r[o]=n[o]);return r.queue=[],r.sorter=a.sorter||n.default_sorter,r},default_sorter:function(a,n){return a.cost-n.cost},push:function(a,n){var r={value:a,cost:n};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=s})(Ds)),Ds.exports}var Ba;function Wu(){return Ba||(Ba=1,(function(t){const s=ut(),a=$u(),n=Vu(),r=qu(),o=Ku(),i=So(),c=dt(),d=Gu();function x(N){return unescape(encodeURIComponent(N)).length}function h(N,b,C){const k=[];let M;for(;(M=N.exec(C))!==null;)k.push({data:M[0],index:M.index,mode:b,length:M[0].length});return k}function l(N){const b=h(i.NUMERIC,s.NUMERIC,N),C=h(i.ALPHANUMERIC,s.ALPHANUMERIC,N);let k,M;return c.isKanjiModeEnabled()?(k=h(i.BYTE,s.BYTE,N),M=h(i.KANJI,s.KANJI,N)):(k=h(i.BYTE_KANJI,s.BYTE,N),M=[]),b.concat(C,k,M).sort(function(S,y){return S.index-y.index}).map(function(S){return{data:S.data,mode:S.mode,length:S.length}})}function p(N,b){switch(b){case s.NUMERIC:return a.getBitsLength(N);case s.ALPHANUMERIC:return n.getBitsLength(N);case s.KANJI:return o.getBitsLength(N);case s.BYTE:return r.getBitsLength(N)}}function m(N){return N.reduce(function(b,C){const k=b.length-1>=0?b[b.length-1]:null;return k&&k.mode===C.mode?(b[b.length-1].data+=C.data,b):(b.push(C),b)},[])}function f(N){const b=[];for(let C=0;C<N.length;C++){const k=N[C];switch(k.mode){case s.NUMERIC:b.push([k,{data:k.data,mode:s.ALPHANUMERIC,length:k.length},{data:k.data,mode:s.BYTE,length:k.length}]);break;case s.ALPHANUMERIC:b.push([k,{data:k.data,mode:s.BYTE,length:k.length}]);break;case s.KANJI:b.push([k,{data:k.data,mode:s.BYTE,length:x(k.data)}]);break;case s.BYTE:b.push([{data:k.data,mode:s.BYTE,length:x(k.data)}])}}return b}function j(N,b){const C={},k={start:{}};let M=["start"];for(let O=0;O<N.length;O++){const S=N[O],y=[];for(let g=0;g<S.length;g++){const E=S[g],I=""+O+g;y.push(I),C[I]={node:E,lastCount:0},k[I]={};for(let D=0;D<M.length;D++){const _=M[D];C[_]&&C[_].node.mode===E.mode?(k[_][I]=p(C[_].lastCount+E.length,E.mode)-p(C[_].lastCount,E.mode),C[_].lastCount+=E.length):(C[_]&&(C[_].lastCount=E.length),k[_][I]=p(E.length,E.mode)+4+s.getCharCountIndicator(E.mode,b))}}M=y}for(let O=0;O<M.length;O++)k[M[O]].end=0;return{map:k,table:C}}function v(N,b){let C;const k=s.getBestModeForData(N);if(C=s.from(b,k),C!==s.BYTE&&C.bit<k.bit)throw new Error('"'+N+'" cannot be encoded with mode '+s.toString(C)+`.
12
12
  Suggested mode is: `+s.toString(k));switch(C===s.KANJI&&!c.isKanjiModeEnabled()&&(C=s.BYTE),C){case s.NUMERIC:return new a(N);case s.ALPHANUMERIC:return new n(N);case s.KANJI:return new o(N);case s.BYTE:return new r(N)}}t.fromArray=function(b){return b.reduce(function(C,k){return typeof k=="string"?C.push(v(k,null)):k.data&&C.push(v(k.data,k.mode)),C},[])},t.fromString=function(b,C){const k=l(b,c.isKanjiModeEnabled()),M=f(k),O=j(M,C),S=d.find_path(O.map,"start","end"),y=[];for(let g=1;g<S.length-1;g++)y.push(O.table[S[g]].node);return t.fromArray(m(y))},t.rawSplit=function(b){return t.fromArray(l(b,c.isKanjiModeEnabled()))}})(As)),As}var _a;function Hu(){if(_a)return fs;_a=1;const t=dt(),s=Mn(),a=Tu(),n=Ru(),r=Du(),o=Ou(),i=Lu(),c=ko(),d=_u(),x=Fu(),h=Uu(),l=ut(),p=Wu();function m(O,S){const y=O.size,g=o.getPositions(S);for(let E=0;E<g.length;E++){const I=g[E][0],D=g[E][1];for(let _=-1;_<=7;_++)if(!(I+_<=-1||y<=I+_))for(let A=-1;A<=7;A++)D+A<=-1||y<=D+A||(_>=0&&_<=6&&(A===0||A===6)||A>=0&&A<=6&&(_===0||_===6)||_>=2&&_<=4&&A>=2&&A<=4?O.set(I+_,D+A,!0,!0):O.set(I+_,D+A,!1,!0))}}function f(O){const S=O.size;for(let y=8;y<S-8;y++){const g=y%2===0;O.set(y,6,g,!0),O.set(6,y,g,!0)}}function j(O,S){const y=r.getPositions(S);for(let g=0;g<y.length;g++){const E=y[g][0],I=y[g][1];for(let D=-2;D<=2;D++)for(let _=-2;_<=2;_++)D===-2||D===2||_===-2||_===2||D===0&&_===0?O.set(E+D,I+_,!0,!0):O.set(E+D,I+_,!1,!0)}}function v(O,S){const y=O.size,g=x.getEncodedBits(S);let E,I,D;for(let _=0;_<18;_++)E=Math.floor(_/3),I=_%3+y-8-3,D=(g>>_&1)===1,O.set(E,I,D,!0),O.set(I,E,D,!0)}function N(O,S,y){const g=O.size,E=h.getEncodedBits(S,y);let I,D;for(I=0;I<15;I++)D=(E>>I&1)===1,I<6?O.set(I,8,D,!0):I<8?O.set(I+1,8,D,!0):O.set(g-15+I,8,D,!0),I<8?O.set(8,g-I-1,D,!0):I<9?O.set(8,15-I-1+1,D,!0):O.set(8,15-I-1,D,!0);O.set(g-8,8,1,!0)}function b(O,S){const y=O.size;let g=-1,E=y-1,I=7,D=0;for(let _=y-1;_>0;_-=2)for(_===6&&_--;;){for(let A=0;A<2;A++)if(!O.isReserved(E,_-A)){let F=!1;D<S.length&&(F=(S[D]>>>I&1)===1),O.set(E,_-A,F),I--,I===-1&&(D++,I=7)}if(E+=g,E<0||y<=E){E-=g,g=-g;break}}}function C(O,S,y){const g=new a;y.forEach(function(A){g.put(A.mode.bit,4),g.put(A.getLength(),l.getCharCountIndicator(A.mode,O)),A.write(g)});const E=t.getSymbolTotalCodewords(O),I=c.getTotalCodewordsCount(O,S),D=(E-I)*8;for(g.getLengthInBits()+4<=D&&g.put(0,4);g.getLengthInBits()%8!==0;)g.putBit(0);const _=(D-g.getLengthInBits())/8;for(let A=0;A<_;A++)g.put(A%2?17:236,8);return k(g,O,S)}function k(O,S,y){const g=t.getSymbolTotalCodewords(S),E=c.getTotalCodewordsCount(S,y),I=g-E,D=c.getBlocksCount(S,y),_=g%D,A=D-_,F=Math.floor(g/D),q=Math.floor(I/D),W=q+1,R=F-q,G=new d(R);let ne=0;const xe=new Array(D),U=new Array(D);let se=0;const L=new Uint8Array(O.buffer);for(let ge=0;ge<D;ge++){const z=ge<A?q:W;xe[ge]=L.slice(ne,ne+z),U[ge]=G.encode(xe[ge]),ne+=z,se=Math.max(se,z)}const me=new Uint8Array(g);let oe=0,ce,le;for(ce=0;ce<se;ce++)for(le=0;le<D;le++)ce<xe[le].length&&(me[oe++]=xe[le][ce]);for(ce=0;ce<R;ce++)for(le=0;le<D;le++)me[oe++]=U[le][ce];return me}function M(O,S,y,g){let E;if(Array.isArray(O))E=p.fromArray(O);else if(typeof O=="string"){let F=S;if(!F){const q=p.rawSplit(O);F=x.getBestVersionForData(q,y)}E=p.fromString(O,F||40)}else throw new Error("Invalid data");const I=x.getBestVersionForData(E,y);if(!I)throw new Error("The amount of data is too big to be stored in a QR Code");if(!S)S=I;else if(S<I)throw new Error(`