upfynai-code 2.4.1 → 2.5.0

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 (147) hide show
  1. package/client/dist/assets/AppContent-CRld2UWX.js +513 -0
  2. package/client/dist/assets/CanvasPanel-CB4sweQq.js +34 -0
  3. package/client/dist/assets/CanvasPanel-WhZulBJw.css +1 -0
  4. package/client/dist/assets/DashboardPanel-BXaA-b9z.js +1 -0
  5. package/client/dist/assets/LoginModal-BwkvjfPR.js +19 -0
  6. package/client/dist/assets/{Onboarding-CtIoXiTp.js → Onboarding-2A_5fPxy.js} +1 -1
  7. package/client/dist/assets/{SetupForm-B4p8im5O.js → SetupForm-CH5EA5W0.js} +1 -1
  8. package/client/dist/assets/WorkflowsPanel-CO5g5yGG.js +1 -0
  9. package/client/dist/assets/{ar-SA-G6X2FPQ2-2gfmdvHk.js → ar-SA-G6X2FPQ2-DoJuo98H.js} +2 -2
  10. package/client/dist/assets/{arc-DCZSHhoJ.js → arc-B0wBaTeh.js} +1 -1
  11. package/client/dist/assets/az-AZ-76LH7QW2-xdrt1Z13.js +1 -0
  12. package/client/dist/assets/{bg-BG-XCXSNQG7-D6__XtOK.js → bg-BG-XCXSNQG7-D8NAiF6Y.js} +2 -2
  13. package/client/dist/assets/{blockDiagram-38ab4fdb-Cfbaeyp6.js → blockDiagram-38ab4fdb-DSnyKzK4.js} +2 -2
  14. package/client/dist/assets/{bn-BD-2XOGV67Q-DHNJw3OG.js → bn-BD-2XOGV67Q-B0qWv8_J.js} +2 -2
  15. package/client/dist/assets/{c4Diagram-3d4e48cf-BBCnjOTy.js → c4Diagram-3d4e48cf-DoZJ13XA.js} +2 -2
  16. package/client/dist/assets/{ca-ES-6MX7JW3Y-r5g4o3zQ.js → ca-ES-6MX7JW3Y-RgLhfbZZ.js} +3 -3
  17. package/client/dist/assets/channel-BmO6nY0W.js +1 -0
  18. package/client/dist/assets/classDiagram-70f12bd4-GNyDrRCk.js +2 -0
  19. package/client/dist/assets/classDiagram-v2-f2320105-CxdGhHm2.js +2 -0
  20. package/client/dist/assets/clone-xuHMqFoD.js +1 -0
  21. package/client/dist/assets/{createText-2e5e7dd3-B8jCDmF_.js → createText-2e5e7dd3-DiPywQOa.js} +1 -1
  22. package/client/dist/assets/{cs-CZ-2BRQDIVT-p08jRLRC.js → cs-CZ-2BRQDIVT-BAjmnuoC.js} +2 -2
  23. package/client/dist/assets/{da-DK-5WZEPLOC-CnhOImFf.js → da-DK-5WZEPLOC-JxKVGt8o.js} +2 -2
  24. package/client/dist/assets/{de-DE-XR44H4JA-BunSXZ-Y.js → de-DE-XR44H4JA-CrnRlt4z.js} +2 -2
  25. package/client/dist/assets/{edges-e0da2a9e-CGBBhG8k.js → edges-e0da2a9e-DDsXzXLJ.js} +1 -1
  26. package/client/dist/assets/{el-GR-BZB4AONW-D4wv1oIz.js → el-GR-BZB4AONW-DQd8iogq.js} +2 -2
  27. package/client/dist/assets/{erDiagram-9861fffd-CYaF3q1I.js → erDiagram-9861fffd-CBiCC4rl.js} +2 -2
  28. package/client/dist/assets/{es-ES-U4NZUMDT-CGeTKXgd.js → es-ES-U4NZUMDT-vvUblc5i.js} +2 -2
  29. package/client/dist/assets/{eu-ES-A7QVB2H4-Cayx1TxR.js → eu-ES-A7QVB2H4-De4NNCc1.js} +2 -2
  30. package/client/dist/assets/{fa-IR-HGAKTJCU-CmUg8pmw.js → fa-IR-HGAKTJCU-DFBXqIqq.js} +2 -2
  31. package/client/dist/assets/{fi-FI-Z5N7JZ37-xvHcPhsU.js → fi-FI-Z5N7JZ37-DV9zESPg.js} +2 -2
  32. package/client/dist/assets/{flowDb-956e92f1-C-_LFz70.js → flowDb-956e92f1-BhdSHbdO.js} +1 -1
  33. package/client/dist/assets/{flowDiagram-66a62f08-C1sHdSjn.js → flowDiagram-66a62f08-M-fp1_Ie.js} +2 -2
  34. package/client/dist/assets/flowDiagram-v2-96b9c2cf-C5eiN8Pg.js +1 -0
  35. package/client/dist/assets/{flowchart-elk-definition-4a651766-CNGfpudb.js → flowchart-elk-definition-4a651766-Bp0SonQx.js} +2 -2
  36. package/client/dist/assets/{fr-FR-RHASNOE6-DBoHEcNj.js → fr-FR-RHASNOE6-CKTMXuGk.js} +2 -2
  37. package/client/dist/assets/ganttDiagram-c361ad54-iA737GUS.js +257 -0
  38. package/client/dist/assets/{gitGraphDiagram-72cf32ee-DojCDvlS.js → gitGraphDiagram-72cf32ee-BX-wj-PV.js} +2 -2
  39. package/client/dist/assets/{gl-ES-HMX3MZ6V-p6hrn2cN.js → gl-ES-HMX3MZ6V-Cdiqq4jY.js} +2 -2
  40. package/client/dist/assets/{graph-DXM7lcy1.js → graph-Rxkx3sEa.js} +1 -1
  41. package/client/dist/assets/{he-IL-6SHJWFNN-y2jEX6-0.js → he-IL-6SHJWFNN-gYmR5_KT.js} +2 -2
  42. package/client/dist/assets/{hi-IN-IWLTKZ5I-99pNfyWr.js → hi-IN-IWLTKZ5I-pyqK94AR.js} +2 -2
  43. package/client/dist/assets/{hu-HU-A5ZG7DT2-hygceGMS.js → hu-HU-A5ZG7DT2-DpacJgJy.js} +2 -2
  44. package/client/dist/assets/{id-ID-SAP4L64H-CyIqi1hv.js → id-ID-SAP4L64H-CAvIX-mj.js} +2 -2
  45. package/client/dist/assets/{index-3862675e-4idOQN2N.js → index-3862675e-BX3Fpn6V.js} +1 -1
  46. package/client/dist/assets/{index-BHZfFT_V.js → index-BBlwbHq_.js} +4 -4
  47. package/client/dist/assets/{index-BGmwbRlb.js → index-ClfzLIqY.js} +6 -6
  48. package/client/dist/assets/index-Td4UdtLF.css +1 -0
  49. package/client/dist/assets/{infoDiagram-f8f76790-CFLrHqtc.js → infoDiagram-f8f76790-Ckv8imiv.js} +2 -2
  50. package/client/dist/assets/{it-IT-JPQ66NNP-DzVvVdQI.js → it-IT-JPQ66NNP-BtpNRSce.js} +2 -2
  51. package/client/dist/assets/{ja-JP-DBVTYXUO-BI4fPexV.js → ja-JP-DBVTYXUO-CwJRyY6M.js} +2 -2
  52. package/client/dist/assets/{journeyDiagram-49397b02-C3CFDo8z.js → journeyDiagram-49397b02-DWWZssji.js} +2 -2
  53. package/client/dist/assets/kaa-6HZHGXH3-DIWQEb4A.js +1 -0
  54. package/client/dist/assets/{kab-KAB-ZGHBKWFO-DBI_ri48.js → kab-KAB-ZGHBKWFO-DjGbqhUg.js} +2 -2
  55. package/client/dist/assets/kk-KZ-P5N5QNE5-B_VzJdWf.js +1 -0
  56. package/client/dist/assets/{km-KH-HSX4SM5Z-DOMFSres.js → km-KH-HSX4SM5Z-DUD5mi0o.js} +2 -2
  57. package/client/dist/assets/{ko-KR-MTYHY66A-tb08hXzd.js → ko-KR-MTYHY66A--sDB10db.js} +3 -3
  58. package/client/dist/assets/{ku-TR-6OUDTVRD-DlIQCCY4.js → ku-TR-6OUDTVRD-CKvKrkcX.js} +2 -2
  59. package/client/dist/assets/{layout-B_11mCXA.js → layout-CkB7sSeq.js} +1 -1
  60. package/client/dist/assets/{line-B-qmK_vI.js → line-DC7MA9qY.js} +1 -1
  61. package/client/dist/assets/{linear-Ph6uuYcX.js → linear-C1lBBthf.js} +1 -1
  62. package/client/dist/assets/{lt-LT-XHIRWOB4--qWy24_Z.js → lt-LT-XHIRWOB4-MSZf7xYG.js} +2 -2
  63. package/client/dist/assets/{lv-LV-5QDEKY6T-Bnd_1GDb.js → lv-LV-5QDEKY6T-C-gvvmBB.js} +2 -2
  64. package/client/dist/assets/{mindmap-definition-fc14e90a-Do79tIc0.js → mindmap-definition-fc14e90a-B3O7hztq.js} +2 -2
  65. package/client/dist/assets/{mr-IN-CRQNXWMA-BsV6HaD9.js → mr-IN-CRQNXWMA-XHtBUWQH.js} +2 -2
  66. package/client/dist/assets/my-MM-5M5IBNSE-D9eD2edL.js +1 -0
  67. package/client/dist/assets/{nb-NO-T6EIAALU-Cvf9FdSF.js → nb-NO-T6EIAALU-BlImC6gp.js} +3 -3
  68. package/client/dist/assets/{nl-NL-IS3SIHDZ-DA1yqpXw.js → nl-NL-IS3SIHDZ-CPFhnaSP.js} +2 -2
  69. package/client/dist/assets/{nn-NO-6E72VCQL-89lm3vku.js → nn-NO-6E72VCQL-BMvoJSKQ.js} +2 -2
  70. package/client/dist/assets/{oc-FR-POXYY2M6-BsrjTJQh.js → oc-FR-POXYY2M6-Buye63LS.js} +2 -2
  71. package/client/dist/assets/{pa-IN-N4M65BXN-CczefYaj.js → pa-IN-N4M65BXN-D9uQ3niy.js} +2 -2
  72. package/client/dist/assets/{percentages-BXMCSKIN-Be6p9phi.js → percentages-BXMCSKIN-BzXIakGM.js} +7 -7
  73. package/client/dist/assets/{pieDiagram-8a3498a8-CfblQHdm.js → pieDiagram-8a3498a8-BU38mzx-.js} +3 -3
  74. package/client/dist/assets/{pl-PL-T2D74RX3-DdhH-zcK.js → pl-PL-T2D74RX3-BqM4xdcg.js} +2 -2
  75. package/client/dist/assets/{pt-BR-5N22H2LF-gpwlheL6.js → pt-BR-5N22H2LF-rAjrxGyI.js} +2 -2
  76. package/client/dist/assets/{pt-PT-UZXXM6DQ-Cs87vICi.js → pt-PT-UZXXM6DQ-DXsqcwLt.js} +2 -2
  77. package/client/dist/assets/{quadrantDiagram-120e2f19-CRMSamSP.js → quadrantDiagram-120e2f19-HhK4H1WU.js} +2 -2
  78. package/client/dist/assets/{requirementDiagram-deff3bca-D3LBN016.js → requirementDiagram-deff3bca-aDrcyj-A.js} +2 -2
  79. package/client/dist/assets/{ro-RO-JPDTUUEW-CWTSJ1Dt.js → ro-RO-JPDTUUEW-D_F9UKer.js} +2 -2
  80. package/client/dist/assets/{ru-RU-B4JR7IUQ-Bq7aN2ep.js → ru-RU-B4JR7IUQ-MirqN29p.js} +2 -2
  81. package/client/dist/assets/sankeyDiagram-04a897e0-C6ij7qbQ.js +8 -0
  82. package/client/dist/assets/{sequenceDiagram-704730f1-BRYXVDGX.js → sequenceDiagram-704730f1-C0EKO3th.js} +2 -2
  83. package/client/dist/assets/si-LK-N5RQ5JYF-DyZC3mkC.js +1 -0
  84. package/client/dist/assets/{sk-SK-C5VTKIMK-ByjKQzUb.js → sk-SK-C5VTKIMK-D-ksz-WY.js} +2 -2
  85. package/client/dist/assets/{sl-SI-NN7IZMDC-B8WCyMBU.js → sl-SI-NN7IZMDC-CknuYoQ1.js} +2 -2
  86. package/client/dist/assets/stateDiagram-587899a1-CYoq2VjL.js +1 -0
  87. package/client/dist/assets/stateDiagram-v2-d93cdb3a-C5lbp5px.js +1 -0
  88. package/client/dist/assets/{styles-6aaf32cf-Dr-lfIOW.js → styles-6aaf32cf-Dkfsk8gt.js} +1 -1
  89. package/client/dist/assets/{styles-9a916d00-DS4wRpL7.js → styles-9a916d00-CMYqtcEN.js} +1 -1
  90. package/client/dist/assets/{styles-c10674c1-nKRF6NrH.js → styles-c10674c1-Bp-5OlRU.js} +1 -1
  91. package/client/dist/assets/{subset-shared.chunk-KT79s7KG.js → subset-shared.chunk-kfIB1Zam.js} +3 -3
  92. package/client/dist/assets/subset-worker.chunk-DwQBgc4z.js +1 -0
  93. package/client/dist/assets/{sv-SE-XGPEYMSR-BiIPUVbv.js → sv-SE-XGPEYMSR-DwN13se1.js} +2 -2
  94. package/client/dist/assets/{svgDrawCommon-08f97a94-C3uP9PYr.js → svgDrawCommon-08f97a94-CEgCMqs4.js} +1 -1
  95. package/client/dist/assets/{ta-IN-2NMHFXQM-Cidadso2.js → ta-IN-2NMHFXQM-ejDfFhwa.js} +2 -2
  96. package/client/dist/assets/th-TH-HPSO5L25-Bqc90ZNn.js +2 -0
  97. package/client/dist/assets/{timeline-definition-85554ec2-BSsLsIgF.js → timeline-definition-85554ec2-BmGdKqG0.js} +2 -2
  98. package/client/dist/assets/{tr-TR-DEFEU3FU-DaFcI-KL.js → tr-TR-DEFEU3FU-CJvlPbcW.js} +2 -2
  99. package/client/dist/assets/{uk-UA-QMV73CPH-DkBW36St.js → uk-UA-QMV73CPH-D26-cbWL.js} +3 -3
  100. package/client/dist/assets/vendor-codemirror-D_s0aGBu.js +35 -0
  101. package/client/dist/assets/{vendor-icons-Dh9m_Ydt.js → vendor-icons-aNdOvTr_.js} +159 -119
  102. package/client/dist/assets/{vi-VN-M7AON7JQ-KrtfxOzl.js → vi-VN-M7AON7JQ-MbqIIwYM.js} +2 -2
  103. package/client/dist/assets/{xychartDiagram-e933f94c-CgNgZ4pp.js → xychartDiagram-e933f94c-gfcTauxU.js} +2 -2
  104. package/client/dist/assets/{zh-CN-LNUGB5OW-BQu12RoD.js → zh-CN-LNUGB5OW-BZSmhUdL.js} +3 -3
  105. package/client/dist/assets/zh-HK-E62DVLB3-BJqejpiX.js +1 -0
  106. package/client/dist/assets/{zh-TW-RAJ6MFWO-ffJWgVxn.js → zh-TW-RAJ6MFWO-BBXtV-Uz.js} +2 -2
  107. package/client/dist/index.html +3 -3
  108. package/package.json +5 -2
  109. package/server/cli.js +1 -1
  110. package/server/database/auth.db +0 -0
  111. package/server/database/db.js +203 -1
  112. package/server/index.js +111 -18
  113. package/server/middleware/auth.js +11 -6
  114. package/server/projects.js +95 -202
  115. package/server/relay-client.js +47 -10
  116. package/server/routes/auth.js +6 -0
  117. package/server/routes/dashboard.js +52 -0
  118. package/server/routes/projects.js +38 -35
  119. package/server/routes/voice.js +198 -0
  120. package/server/routes/webhooks.js +166 -0
  121. package/server/routes/workflows.js +118 -0
  122. package/server/services/whisperService.js +84 -0
  123. package/server/services/workflowScheduler.js +186 -0
  124. package/client/dist/assets/AppContent-DTZ2FbvM.js +0 -513
  125. package/client/dist/assets/CanvasPanel-DlTW6Jh6.js +0 -6
  126. package/client/dist/assets/CanvasPanel-q4HEqNtV.css +0 -1
  127. package/client/dist/assets/LoginModal-CWoFm0au.js +0 -19
  128. package/client/dist/assets/az-AZ-76LH7QW2-CDdeucRZ.js +0 -1
  129. package/client/dist/assets/channel-O3ovC0x9.js +0 -1
  130. package/client/dist/assets/classDiagram-70f12bd4-D0lhAcxU.js +0 -2
  131. package/client/dist/assets/classDiagram-v2-f2320105-BuwUsF3F.js +0 -2
  132. package/client/dist/assets/clone-BG9u7vLi.js +0 -1
  133. package/client/dist/assets/flowDiagram-v2-96b9c2cf-Cd0Iascd.js +0 -1
  134. package/client/dist/assets/ganttDiagram-c361ad54-B8HJQqjt.js +0 -257
  135. package/client/dist/assets/index-B8wwD_Xo.css +0 -1
  136. package/client/dist/assets/kaa-6HZHGXH3-fwOleoQB.js +0 -1
  137. package/client/dist/assets/kk-KZ-P5N5QNE5-zpl7uvyF.js +0 -1
  138. package/client/dist/assets/my-MM-5M5IBNSE-kZQURVIi.js +0 -1
  139. package/client/dist/assets/sankeyDiagram-04a897e0-CsFqOQZN.js +0 -8
  140. package/client/dist/assets/si-LK-N5RQ5JYF-BBjcNYQh.js +0 -1
  141. package/client/dist/assets/stateDiagram-587899a1-BHoy9LtD.js +0 -1
  142. package/client/dist/assets/stateDiagram-v2-d93cdb3a-BvMUA6bS.js +0 -1
  143. package/client/dist/assets/subset-worker.chunk-BMx1eyv3.js +0 -1
  144. package/client/dist/assets/th-TH-HPSO5L25-CFNnJwSv.js +0 -2
  145. package/client/dist/assets/vendor-codemirror-langs-BH1ZcKHY.js +0 -20
  146. package/client/dist/assets/vendor-codemirror-rix45NST.js +0 -16
  147. package/client/dist/assets/zh-HK-E62DVLB3-zx9CvERq.js +0 -1
@@ -0,0 +1,513 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownPreview-CYdvwJaV.js","assets/vendor-react-9mUTKBHH.js","assets/vendor-markdown-BXEi_H3G.js","assets/vendor-syntax-DnmwQQJF.js","assets/CanvasPanel-CB4sweQq.js","assets/vendor-icons-aNdOvTr_.js","assets/CanvasPanel-WhZulBJw.css","assets/WorkflowsPanel-CO5g5yGG.js","assets/index-ClfzLIqY.js","assets/vendor-i18n-DCFGyhQR.js","assets/index-Td4UdtLF.css","assets/DashboardPanel-BXaA-b9z.js"])))=>i.map(i=>d[i]);
2
+ import{r as c,j as e,v as Ft,e as ss,g as lo,u as Ti,f as Ii}from"./vendor-react-9mUTKBHH.js";import{e as mr,f as He,h as Ta,a as Ee,i as Yr,l as Ka,d as Ia,j as Ar,k as Ai}from"./index-ClfzLIqY.js";import{v as Di,w as Qe,t as Ht,x as Va,R as Ut,P as lt,y as Mi,z as dr,X as qe,B as xs,o as Ds,i as Qr,k as qr,h as ht,C as Tt,g as $i,n as vt,D as er,I as tr,J as Ja,K as Kr,c as Ot,W as co,G as Gt,N as Aa,b as jr,a as mo,O as ur,Q as uo,V as Da,E as Ya,Y as Li,L as Fi,_ as qt,$ as Pt,a0 as Ms,a1 as ct,a2 as Vr,Z as cr,a3 as po,a4 as oa,a5 as ia,a6 as Pi,a7 as _i,a8 as Ma,a9 as $s,aa as xo,ab as gs,F as it,ac as Cr,ad as zi,S as fs,ae as Oi,af as go,ag as $a,ah as ho,ai as bs,m as fo,aj as Ri,f as Bi,ak as Wi,al as Ui,am as Xt,an as Rr,ao as la,ap as ca,aq as da,ar as Br,as as Nr,at as ma,au as Sr,av as ua,aw as Wr,ax as bo,ay as yr,az as vr,aA as $r,aB as Lr,aC as kr,aD as Hi,aE as Vt,aF as Qa,aG as Gi,aH as Xa,aI as Fr,aJ as Pr,aK as qi,aL as Ki,aM as _r,aN as Za,aO as Vi,aP as Ji,aQ as hs,aR as as,aS as ys,H as en,aT as qs,aU as Yi,d as Qi,e as La,aV as Xi,aW as yo,aX as vo,aY as Zi,aZ as el,a_ as tl,a$ as rl,b0 as sl,b1 as al,b2 as nl,b3 as tn,b4 as ol}from"./vendor-icons-aNdOvTr_.js";import{a as il,b as ll,C as cl,u as Ge,L as dl,S as ko,c as ml}from"./LoginModal-BwkvjfPR.js";import{h as ul,p as pl,b as Ls}from"./vendor-syntax-DnmwQQJF.js";import{a as xl,b as gl,d as hl,M as fl}from"./vendor-markdown-BXEi_H3G.js";import{F as wo,E as Zt,S as bl,V as Fa,c as Er,a as yl,f as vl,u as kl,b as wl,T as rn,l as jl,h as sn,s as Nl,d as Cl,e as Sl,g as El,i as Ks,j as Tl,R as jo,o as No,k as Il,m as Co,n as Al,p as Dl,q as Ml,r as $l,t as Ll,v as Fl}from"./vendor-codemirror-D_s0aGBu.js";const an=t=>typeof window>"u"?!1:window.innerWidth<t,nn=()=>{if(typeof window>"u")return!1;const t=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!t.standalone||document.referrer.includes("android-app://")};function Pa(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=c.useState(()=>s?an(r):!1),[i,l]=c.useState(()=>a?nn():!1);return c.useEffect(()=>{if(!s||typeof window>"u")return;const m=()=>{o(an(r))};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[r,s]),c.useEffect(()=>{if(!a||typeof window>"u")return;const m=window.matchMedia("(display-mode: standalone)"),d=()=>{l(nn())};return d(),typeof m.addEventListener=="function"?(m.addEventListener("change",d),()=>{m.removeEventListener("change",d)}):(m.addListener(d),()=>{m.removeListener(d)})},[a]),{isMobile:n,isPWA:i}}const on="2.5.0",Pl=(t,r)=>{const s=t.split(".").map(Number),a=r.split(".").map(Number);for(let n=0;n<Math.max(s.length,a.length);n++){const o=s[n]||0,i=a[n]||0;if(o!==i)return o-i}return 0},So=(t,r)=>{const[s,a]=c.useState(!1),[n,o]=c.useState(null),[i,l]=c.useState(null);return c.useEffect(()=>{const m=async()=>{try{const g=await(await fetch(`https://api.github.com/repos/${t}/${r}/releases/latest`)).json();if(g.tag_name){const p=g.tag_name.replace(/^v/,"");o(p),a(Pl(p,on)>0),l({title:g.name||g.tag_name,body:g.body||"",htmlUrl:g.html_url||`https://github.com/${t}/${r}/releases/latest`,publishedAt:g.published_at})}else a(!1),o(null),l(null)}catch(u){console.error("Version check failed:",u),a(!1),o(null),l(null)}};m();const d=setInterval(m,300*1e3);return()=>clearInterval(d)},[t,r]),{updateAvailable:s,latestVersion:n,currentVersion:on,releaseInfo:i}},or={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},vs=Object.keys(or),_l=new Set(vs),Vs="ui-preferences:sync",ks=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},zl=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return ks(a,r)}catch{return r}},Ol=t=>{if(typeof window>"u")return or;try{const r=localStorage.getItem(t);if(r){const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;return vs.reduce((n,o)=>(n[o]=ks(a[o],or[o]),n),{...or})}}}catch{}return vs.reduce((r,s)=>(r[s]=zl(s,or[s]),r),{...or})};function Rl(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!_l.has(s))return t;const n=ks(a,t[s]);return t[s]===n?t:{...t,[s]:n}}case"set_many":{const s=r.value||{};let a=!1;const n={...t};for(const o of vs){if(!(o in s))continue;const i=s[o],l=ks(i,t[o]);n[o]!==l&&(n[o]=l,a=!0)}return a?n:t}case"reset":return{...or,...r.value||{}};default:return t}}function _a(t="uiPreferences"){const r=c.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=c.useReducer(Rl,t,Ol);return c.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(Vs,{detail:{storageKey:t,sourceId:r.current,value:s}})))},[s,t]),c.useEffect(()=>{if(typeof window>"u")return;const l=u=>{!u||typeof u!="object"||Array.isArray(u)||a({type:"set_many",value:u})},m=u=>{if(!(u.key!==t||u.newValue===null))try{const g=JSON.parse(u.newValue);l(g)}catch{}},d=u=>{const p=u.detail;!p||p.storageKey!==t||p.sourceId===r.current||l(p.value)};return window.addEventListener("storage",m),window.addEventListener(Vs,d),()=>{window.removeEventListener("storage",m),window.removeEventListener(Vs,d)}},[t]),{preferences:s,setPreference:(l,m)=>{a({type:"set",key:l,value:m})},setPreferences:l=>{a({type:"set_many",value:l})},resetPreferences:l=>{a({type:"reset",value:l})},dispatch:a}}const Bl=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},Wl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},Ul=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},ws=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),Hl=(t,r)=>t.__provider==="cursor"?t.name||r("projects.untitledSession"):t.__provider==="codex"?t.summary||t.name||r("projects.codexSession"):t.summary||r("projects.newSession"),Gl=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),ql=(t,r,s)=>{const a=ws(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:Hl(t,s),sessionTime:Gl(t),messageCount:Number(t.messageCount||0)}},Eo=(t,r)=>{const s=[...t.sessions||[],...r[t.name]||[]].map(o=>({...o,__provider:"claude"})),a=(t.cursorSessions||[]).map(o=>({...o,__provider:"cursor"})),n=(t.codexSessions||[]).map(o=>({...o,__provider:"codex"}));return[...s,...a,...n].sort((o,i)=>ws(i).getTime()-ws(o).getTime())},ln=(t,r)=>{const s=Eo(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=ws(n);return o>a?o:a},new Date(0))},Kl=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const l=s.has(o.name),m=s.has(i.name);return l&&!m?-1:!l&&m?1:r==="date"?ln(i,a).getTime()-ln(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},Vl=(t,r)=>{const s=r.trim().toLowerCase();return s?t.filter(a=>{const n=(a.displayName||a.name).toLowerCase(),o=a.name.toLowerCase();return n.includes(s)||o.includes(s)}):t},Jl=(t,r)=>{var n;const s=!!((n=t.taskmaster)!=null&&n.hasTaskmaster),a=!!(r!=null&&r.hasMCPServer&&(r!=null&&r.isConfigured));return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Yl=t=>{const r=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.name,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.name,fullPath:r,path:typeof t.path=="string"&&t.path.length>0?t.path:r}};function Ql({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:l,onSessionSelect:m,onSessionDelete:d,onProjectDelete:u,setCurrentProject:g,setSidebarVisible:p,sidebarVisible:x}){const{addToast:f}=mr(),[h,b]=c.useState(new Set),[C,I]=c.useState(null),[y,v]=c.useState(!1),[A,M]=c.useState(""),[$,k]=c.useState({}),[T,W]=c.useState({}),[U,S]=c.useState(new Set),[H,w]=c.useState(new Date),[P,j]=c.useState("name"),[F,G]=c.useState(!1),[X,D]=c.useState({}),[oe,E]=c.useState(null),[se,J]=c.useState(""),[B,K]=c.useState(""),[V,z]=c.useState(new Set),[O,ne]=c.useState(null),[me,q]=c.useState(null),[N,_]=c.useState(!1),[re,te]=c.useState(()=>Wl()),ve=!n&&!x;c.useEffect(()=>{const ae=setInterval(()=>{w(new Date)},6e4);return()=>clearInterval(ae)},[]),c.useEffect(()=>{W({}),S(new Set),D({})},[t]),c.useEffect(()=>{r&&b(ae=>{if(ae.has(r.name))return ae;const ke=new Set(ae);return ke.add(r.name),ke})},[s,r]),c.useEffect(()=>{if(t.length>0&&!a){const ae=new Set;t.forEach(ke=>{ke.sessions&&ke.sessions.length>=0&&ae.add(ke.name)}),S(ae)}},[t,a]),c.useEffect(()=>{const ae=()=>{j(Bl())};ae();const ke=Ue=>{Ue.key==="claude-settings"&&ae()};window.addEventListener("storage",ke);const Be=setInterval(()=>{document.hasFocus()&&ae()},1e3);return()=>{window.removeEventListener("storage",ke),clearInterval(Be)}},[]);const je=c.useCallback(ae=>ke=>{const Be=ke.target;Be.closest(".overflow-y-auto")||Be.closest("[data-scroll-container]")||(ke.preventDefault(),ke.stopPropagation(),ae())},[]),Ne=c.useCallback(ae=>{b(ke=>{const Be=new Set;return ke.has(ae)||Be.add(ae),Be})},[]),we=c.useCallback((ae,ke)=>{m({...ae,__projectName:ke})},[m]),Ie=c.useCallback(ae=>{te(ke=>{const Be=new Set(ke);return Be.has(ae)?Be.delete(ae):Be.add(ae),Ul(Be),Be})},[]),Re=c.useCallback(ae=>re.has(ae),[re]),Z=c.useCallback(ae=>Eo(ae,T),[T]),ye=c.useMemo(()=>t.map(ae=>{const ke=X[ae.name];return ke===void 0?ae:{...ae,sessionMeta:{...ae.sessionMeta,hasMore:ke}}}),[X,t]),Y=c.useMemo(()=>Kl(ye,P,re,T),[T,P,ye,re]),ie=c.useMemo(()=>Vl(Y,B),[B,Y]),De=c.useCallback(ae=>{I(ae.name),M(ae.displayName)},[]),de=c.useCallback(()=>{I(null),M("")},[]),$e=c.useCallback(async ae=>{try{(await He.renameProject(ae,A)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(ke){console.error("Error renaming project:",ke)}finally{I(null),M("")}},[A]),Le=c.useCallback((ae,ke,Be,Ue="claude")=>{q({projectName:ae,sessionId:ke,sessionTitle:Be,provider:Ue})},[]),Je=c.useCallback(async()=>{if(!me)return;const{projectName:ae,sessionId:ke,provider:Be}=me;q(null),d==null||d(ke);try{const Ue=Be==="codex"?await He.deleteCodexSession(ke):await He.deleteSession(ae,ke);Ue.ok||console.error("[Sidebar] Failed to delete session:",Ue.status)}catch(Ue){console.error("[Sidebar] Error deleting session:",Ue)}},[d,me,o]),Ve=c.useCallback(ae=>{ne({project:ae,sessionCount:Z(ae).length})},[Z]),ge=c.useCallback(async()=>{if(!O)return;const{project:ae,sessionCount:ke}=O,Be=ke===0;ne(null),z(Ue=>new Set([...Ue,ae.name]));try{const Ue=await He.deleteProject(ae.name,!Be);if(Ue.ok)u==null||u(ae.name);else{const mt=await Ue.json();f(mt.error||o("messages.deleteProjectFailed"),"error")}}catch(Ue){console.error("Error deleting project:",Ue),f(o("messages.deleteProjectError"),"error")}finally{z(Ue=>{const mt=new Set(Ue);return mt.delete(ae.name),mt})}},[O,u,o]),Fe=c.useCallback(async ae=>{var Ue,mt,It;const ke=X[ae.name];if(!(!(ke!==void 0?ke:((Ue=ae.sessionMeta)==null?void 0:Ue.hasMore)===!0)||$[ae.name])){k(pt=>({...pt,[ae.name]:!0}));try{const pt=(((mt=ae.sessions)==null?void 0:mt.length)||0)+(((It=T[ae.name])==null?void 0:It.length)||0),kt=await He.sessions(ae.name,5,pt);if(!kt.ok)return;const le=await kt.json();W(pe=>({...pe,[ae.name]:[...pe[ae.name]||[],...le.sessions||[]]})),le.hasMore===!1&&D(pe=>({...pe,[ae.name]:!1}))}catch(pt){console.error("Error loading more sessions:",pt)}finally{k(pt=>({...pt,[ae.name]:!1}))}}},[T,$,X]),Ce=c.useCallback(ae=>{l(ae),g(ae)},[l,g]),ze=c.useCallback(async()=>{G(!0);try{await i()}finally{G(!1)}},[i]),Pe=c.useCallback(async(ae,ke,Be)=>{E(null),J("")},[]),_e=c.useCallback(()=>{p(!1)},[p]),Ke=c.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:ve,expandedProjects:h,editingProject:C,showNewProject:y,editingName:A,loadingSessions:$,additionalSessions:T,initialSessionsLoaded:U,currentTime:H,projectSortOrder:P,isRefreshing:F,editingSession:oe,editingSessionName:se,searchFilter:B,deletingProjects:V,deleteConfirmation:O,sessionDeleteConfirmation:me,showVersionModal:N,starredProjects:re,filteredProjects:ie,handleTouchClick:je,toggleProject:Ne,handleSessionClick:we,toggleStarProject:Ie,isProjectStarred:Re,getProjectSessions:Z,startEditing:De,cancelEditing:de,saveProjectName:$e,showDeleteSessionConfirmation:Le,confirmDeleteSession:Je,requestProjectDelete:Ve,confirmDeleteProject:ge,loadMoreSessions:Fe,handleProjectSelect:Ce,refreshProjects:ze,updateSessionSummary:Pe,collapseSidebar:_e,expandSidebar:Ke,setShowNewProject:v,setEditingName:M,setEditingSession:E,setEditingSessionName:J,setSearchFilter:K,setDeleteConfirmation:ne,setSessionDeleteConfirmation:q,setShowVersionModal:_}}function Xl({onExpand:t,onShowSettings:r,updateAvailable:s,onShowVersionModal:a,t:n}){return e.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[e.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("common:versionUpdate.ariaLabels.showSidebar"),title:n("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx(Di,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),e.jsx("div",{className:"nav-divider w-6 my-1"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("actions.settings"),title:n("actions.settings"),children:e.jsx(Qe,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),s&&e.jsxs("button",{onClick:a,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":n("common:versionUpdate.ariaLabels.updateAvailable"),title:n("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(Ht,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function To(t){var r,s,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(r=0;r<n;r++)t[r]&&(s=To(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function Io(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=To(t))&&(a&&(a+=" "),a+=r);return a}const Zl=(t,r)=>{const s=new Array(t.length+r.length);for(let a=0;a<t.length;a++)s[a]=t[a];for(let a=0;a<r.length;a++)s[t.length+a]=r[a];return s},ec=(t,r)=>({classGroupId:t,validator:r}),Ao=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),js="-",cn=[],tc="arbitrary..",rc=t=>{const r=ac(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return sc(i);const l=i.split(js),m=l[0]===""&&l.length>1?1:0;return Do(l,m,r)},getConflictingClassGroupIds:(i,l)=>{if(l){const m=a[i],d=s[i];return m?d?Zl(d,m):m:d||cn}return s[i]||cn}}},Do=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const d=Do(t,r+1,o);if(d)return d}const i=s.validators;if(i===null)return;const l=r===0?t.join(js):t.slice(r).join(js),m=i.length;for(let d=0;d<m;d++){const u=i[d];if(u.validator(l))return u.classGroupId}},sc=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=t.slice(1,-1),s=r.indexOf(":"),a=r.slice(0,s);return a?tc+a:void 0})(),ac=t=>{const{theme:r,classGroups:s}=t;return nc(s,r)},nc=(t,r)=>{const s=Ao();for(const a in t){const n=t[a];za(n,s,a,r)}return s},za=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];oc(i,r,s,a)}},oc=(t,r,s,a)=>{if(typeof t=="string"){ic(t,r,s);return}if(typeof t=="function"){lc(t,r,s,a);return}cc(t,r,s,a)},ic=(t,r,s)=>{const a=t===""?r:Mo(r,t);a.classGroupId=s},lc=(t,r,s,a)=>{if(dc(t)){za(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(ec(s,t))},cc=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[l,m]=n[i];za(m,Mo(r,l),s,a)}},Mo=(t,r)=>{let s=t;const a=r.split(js),n=a.length;for(let o=0;o<n;o++){const i=a[o];let l=s.nextPart.get(i);l||(l=Ao(),s.nextPart.set(i,l)),s=l}return s},dc=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,mc=t=>{if(t<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),a=Object.create(null);const n=(o,i)=>{s[o]=i,r++,r>t&&(r=0,a=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=a[o])!==void 0)return n(o,i),i},set(o,i){o in s?s[o]=i:n(o,i)}}},pa="!",dn=":",uc=[],mn=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),pc=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,l=0,m=0,d;const u=n.length;for(let h=0;h<u;h++){const b=n[h];if(i===0&&l===0){if(b===dn){o.push(n.slice(m,h)),m=h+1;continue}if(b==="/"){d=h;continue}}b==="["?i++:b==="]"?i--:b==="("?l++:b===")"&&l--}const g=o.length===0?n:n.slice(m);let p=g,x=!1;g.endsWith(pa)?(p=g.slice(0,-1),x=!0):g.startsWith(pa)&&(p=g.slice(1),x=!0);const f=d&&d>m?d-m:void 0;return mn(o,x,p,f)};if(r){const n=r+dn,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):mn(uc,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},xc=t=>{const r=new Map;return t.orderSensitiveModifiers.forEach((s,a)=>{r.set(s,1e6+a)}),s=>{const a=[];let n=[];for(let o=0;o<s.length;o++){const i=s[o],l=i[0]==="[",m=r.has(i);l||m?(n.length>0&&(n.sort(),a.push(...n),n=[]),a.push(i)):n.push(i)}return n.length>0&&(n.sort(),a.push(...n)),a}},gc=t=>({cache:mc(t.cacheSize),parseClassName:pc(t),sortModifiers:xc(t),...rc(t)}),hc=/\s+/,fc=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],l=t.trim().split(hc);let m="";for(let d=l.length-1;d>=0;d-=1){const u=l[d],{isExternal:g,modifiers:p,hasImportantModifier:x,baseClassName:f,maybePostfixModifierPosition:h}=s(u);if(g){m=u+(m.length>0?" "+m:m);continue}let b=!!h,C=a(b?f.substring(0,h):f);if(!C){if(!b){m=u+(m.length>0?" "+m:m);continue}if(C=a(f),!C){m=u+(m.length>0?" "+m:m);continue}b=!1}const I=p.length===0?"":p.length===1?p[0]:o(p).join(":"),y=x?I+pa:I,v=y+C;if(i.indexOf(v)>-1)continue;i.push(v);const A=n(C,b);for(let M=0;M<A.length;++M){const $=A[M];i.push(y+$)}m=u+(m.length>0?" "+m:m)}return m},bc=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=$o(s))&&(n&&(n+=" "),n+=a);return n},$o=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=$o(t[a]))&&(s&&(s+=" "),s+=r);return s},yc=(t,...r)=>{let s,a,n,o;const i=m=>{const d=r.reduce((u,g)=>g(u),t());return s=gc(d),a=s.cache.get,n=s.cache.set,o=l,l(m)},l=m=>{const d=a(m);if(d)return d;const u=fc(m,s);return n(m,u),u};return o=i,(...m)=>o(bc(...m))},vc=[],ot=t=>{const r=s=>s[t]||vc;return r.isThemeGetter=!0,r},Lo=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Fo=/^\((?:(\w[\w-]*):)?(.+)\)$/i,kc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,wc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,jc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Nc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Cc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Sc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Jt=t=>kc.test(t),Oe=t=>!!t&&!Number.isNaN(Number(t)),Yt=t=>!!t&&Number.isInteger(Number(t)),Js=t=>t.endsWith("%")&&Oe(t.slice(0,-1)),Wt=t=>wc.test(t),Po=()=>!0,Ec=t=>jc.test(t)&&!Nc.test(t),Oa=()=>!1,Tc=t=>Cc.test(t),Ic=t=>Sc.test(t),Ac=t=>!he(t)&&!fe(t),Dc=t=>rr(t,Oo,Oa),he=t=>Lo.test(t),nr=t=>rr(t,Ro,Ec),un=t=>rr(t,Oc,Oe),Mc=t=>rr(t,Wo,Po),$c=t=>rr(t,Bo,Oa),pn=t=>rr(t,_o,Oa),Lc=t=>rr(t,zo,Ic),ns=t=>rr(t,Uo,Tc),fe=t=>Fo.test(t),zr=t=>pr(t,Ro),Fc=t=>pr(t,Bo),xn=t=>pr(t,_o),Pc=t=>pr(t,Oo),_c=t=>pr(t,zo),os=t=>pr(t,Uo,!0),zc=t=>pr(t,Wo,!0),rr=(t,r,s)=>{const a=Lo.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},pr=(t,r,s=!1)=>{const a=Fo.exec(t);return a?a[1]?r(a[1]):s:!1},_o=t=>t==="position"||t==="percentage",zo=t=>t==="image"||t==="url",Oo=t=>t==="length"||t==="size"||t==="bg-size",Ro=t=>t==="length",Oc=t=>t==="number",Bo=t=>t==="family-name",Wo=t=>t==="number"||t==="weight",Uo=t=>t==="shadow",Rc=()=>{const t=ot("color"),r=ot("font"),s=ot("text"),a=ot("font-weight"),n=ot("tracking"),o=ot("leading"),i=ot("breakpoint"),l=ot("container"),m=ot("spacing"),d=ot("radius"),u=ot("shadow"),g=ot("inset-shadow"),p=ot("text-shadow"),x=ot("drop-shadow"),f=ot("blur"),h=ot("perspective"),b=ot("aspect"),C=ot("ease"),I=ot("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...v(),fe,he],M=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto","contain","none"],k=()=>[fe,he,m],T=()=>[Jt,"full","auto",...k()],W=()=>[Yt,"none","subgrid",fe,he],U=()=>["auto",{span:["full",Yt,fe,he]},Yt,fe,he],S=()=>[Yt,"auto",fe,he],H=()=>["auto","min","max","fr",fe,he],w=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],j=()=>["auto",...k()],F=()=>[Jt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...k()],G=()=>[Jt,"screen","full","dvw","lvw","svw","min","max","fit",...k()],X=()=>[Jt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...k()],D=()=>[t,fe,he],oe=()=>[...v(),xn,pn,{position:[fe,he]}],E=()=>["no-repeat",{repeat:["","x","y","space","round"]}],se=()=>["auto","cover","contain",Pc,Dc,{size:[fe,he]}],J=()=>[Js,zr,nr],B=()=>["","none","full",d,fe,he],K=()=>["",Oe,zr,nr],V=()=>["solid","dashed","dotted","double"],z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],O=()=>[Oe,Js,xn,pn],ne=()=>["","none",f,fe,he],me=()=>["none",Oe,fe,he],q=()=>["none",Oe,fe,he],N=()=>[Oe,fe,he],_=()=>[Jt,"full",...k()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Wt],breakpoint:[Wt],color:[Po],container:[Wt],"drop-shadow":[Wt],ease:["in","out","in-out"],font:[Ac],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Wt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Wt],shadow:[Wt],spacing:["px",Oe],text:[Wt],"text-shadow":[Wt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Jt,he,fe,b]}],container:["container"],columns:[{columns:[Oe,he,fe,l]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:$()}],"overscroll-x":[{"overscroll-x":$()}],"overscroll-y":[{"overscroll-y":$()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[Yt,"auto",fe,he]}],basis:[{basis:[Jt,"full","auto",l,...k()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Oe,Jt,"auto","initial","none",he]}],grow:[{grow:["",Oe,fe,he]}],shrink:[{shrink:["",Oe,fe,he]}],order:[{order:[Yt,"first","last","none",fe,he]}],"grid-cols":[{"grid-cols":W()}],"col-start-end":[{col:U()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":W()}],"row-start-end":[{row:U()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":H()}],"auto-rows":[{"auto-rows":H()}],gap:[{gap:k()}],"gap-x":[{"gap-x":k()}],"gap-y":[{"gap-y":k()}],"justify-content":[{justify:[...w(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...w()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":w()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:k()}],px:[{px:k()}],py:[{py:k()}],ps:[{ps:k()}],pe:[{pe:k()}],pbs:[{pbs:k()}],pbe:[{pbe:k()}],pt:[{pt:k()}],pr:[{pr:k()}],pb:[{pb:k()}],pl:[{pl:k()}],m:[{m:j()}],mx:[{mx:j()}],my:[{my:j()}],ms:[{ms:j()}],me:[{me:j()}],mbs:[{mbs:j()}],mbe:[{mbe:j()}],mt:[{mt:j()}],mr:[{mr:j()}],mb:[{mb:j()}],ml:[{ml:j()}],"space-x":[{"space-x":k()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":k()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...G()]}],"min-inline-size":[{"min-inline":["auto",...G()]}],"max-inline-size":[{"max-inline":["none",...G()]}],"block-size":[{block:["auto",...X()]}],"min-block-size":[{"min-block":["auto",...X()]}],"max-block-size":[{"max-block":["none",...X()]}],w:[{w:[l,"screen",...F()]}],"min-w":[{"min-w":[l,"screen","none",...F()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[i]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",s,zr,nr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,zc,Mc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Js,he]}],"font-family":[{font:[Fc,$c,r]}],"font-features":[{"font-features":[he]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,fe,he]}],"line-clamp":[{"line-clamp":[Oe,"none",fe,un]}],leading:[{leading:[o,...k()]}],"list-image":[{"list-image":["none",fe,he]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",fe,he]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...V(),"wavy"]}],"text-decoration-thickness":[{decoration:[Oe,"from-font","auto",fe,nr]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[Oe,"auto",fe,he]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:k()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",fe,he]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",fe,he]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:E()}],"bg-size":[{bg:se()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Yt,fe,he],radial:["",fe,he],conic:[Yt,fe,he]},_c,Lc]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:K()}],"border-w-x":[{"border-x":K()}],"border-w-y":[{"border-y":K()}],"border-w-s":[{"border-s":K()}],"border-w-e":[{"border-e":K()}],"border-w-bs":[{"border-bs":K()}],"border-w-be":[{"border-be":K()}],"border-w-t":[{"border-t":K()}],"border-w-r":[{"border-r":K()}],"border-w-b":[{"border-b":K()}],"border-w-l":[{"border-l":K()}],"divide-x":[{"divide-x":K()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":K()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...V(),"hidden","none"]}],"divide-style":[{divide:[...V(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-bs":[{"border-bs":D()}],"border-color-be":[{"border-be":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...V(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Oe,fe,he]}],"outline-w":[{outline:["",Oe,zr,nr]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",u,os,ns]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",g,os,ns]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:K()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[Oe,nr]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":K()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",p,os,ns]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[Oe,fe,he]}],"mix-blend":[{"mix-blend":[...z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Oe]}],"mask-image-linear-from-pos":[{"mask-linear-from":O()}],"mask-image-linear-to-pos":[{"mask-linear-to":O()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":O()}],"mask-image-t-to-pos":[{"mask-t-to":O()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":O()}],"mask-image-r-to-pos":[{"mask-r-to":O()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":O()}],"mask-image-b-to-pos":[{"mask-b-to":O()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":O()}],"mask-image-l-to-pos":[{"mask-l-to":O()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":O()}],"mask-image-x-to-pos":[{"mask-x-to":O()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":O()}],"mask-image-y-to-pos":[{"mask-y-to":O()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[fe,he]}],"mask-image-radial-from-pos":[{"mask-radial-from":O()}],"mask-image-radial-to-pos":[{"mask-radial-to":O()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[Oe]}],"mask-image-conic-from-pos":[{"mask-conic-from":O()}],"mask-image-conic-to-pos":[{"mask-conic-to":O()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:E()}],"mask-size":[{mask:se()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",fe,he]}],filter:[{filter:["","none",fe,he]}],blur:[{blur:ne()}],brightness:[{brightness:[Oe,fe,he]}],contrast:[{contrast:[Oe,fe,he]}],"drop-shadow":[{"drop-shadow":["","none",x,os,ns]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",Oe,fe,he]}],"hue-rotate":[{"hue-rotate":[Oe,fe,he]}],invert:[{invert:["",Oe,fe,he]}],saturate:[{saturate:[Oe,fe,he]}],sepia:[{sepia:["",Oe,fe,he]}],"backdrop-filter":[{"backdrop-filter":["","none",fe,he]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[Oe,fe,he]}],"backdrop-contrast":[{"backdrop-contrast":[Oe,fe,he]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Oe,fe,he]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Oe,fe,he]}],"backdrop-invert":[{"backdrop-invert":["",Oe,fe,he]}],"backdrop-opacity":[{"backdrop-opacity":[Oe,fe,he]}],"backdrop-saturate":[{"backdrop-saturate":[Oe,fe,he]}],"backdrop-sepia":[{"backdrop-sepia":["",Oe,fe,he]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":k()}],"border-spacing-x":[{"border-spacing-x":k()}],"border-spacing-y":[{"border-spacing-y":k()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",fe,he]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Oe,"initial",fe,he]}],ease:[{ease:["linear","initial",C,fe,he]}],delay:[{delay:[Oe,fe,he]}],animate:[{animate:["none",I,fe,he]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,fe,he]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:me()}],"rotate-x":[{"rotate-x":me()}],"rotate-y":[{"rotate-y":me()}],"rotate-z":[{"rotate-z":me()}],scale:[{scale:q()}],"scale-x":[{"scale-x":q()}],"scale-y":[{"scale-y":q()}],"scale-z":[{"scale-z":q()}],"scale-3d":["scale-3d"],skew:[{skew:N()}],"skew-x":[{"skew-x":N()}],"skew-y":[{"skew-y":N()}],transform:[{transform:[fe,he,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:_()}],"translate-x":[{"translate-x":_()}],"translate-y":[{"translate-y":_()}],"translate-z":[{"translate-z":_()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",fe,he]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":k()}],"scroll-mx":[{"scroll-mx":k()}],"scroll-my":[{"scroll-my":k()}],"scroll-ms":[{"scroll-ms":k()}],"scroll-me":[{"scroll-me":k()}],"scroll-mbs":[{"scroll-mbs":k()}],"scroll-mbe":[{"scroll-mbe":k()}],"scroll-mt":[{"scroll-mt":k()}],"scroll-mr":[{"scroll-mr":k()}],"scroll-mb":[{"scroll-mb":k()}],"scroll-ml":[{"scroll-ml":k()}],"scroll-p":[{"scroll-p":k()}],"scroll-px":[{"scroll-px":k()}],"scroll-py":[{"scroll-py":k()}],"scroll-ps":[{"scroll-ps":k()}],"scroll-pe":[{"scroll-pe":k()}],"scroll-pbs":[{"scroll-pbs":k()}],"scroll-pbe":[{"scroll-pbe":k()}],"scroll-pt":[{"scroll-pt":k()}],"scroll-pr":[{"scroll-pr":k()}],"scroll-pb":[{"scroll-pb":k()}],"scroll-pl":[{"scroll-pl":k()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",fe,he]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[Oe,zr,nr,un]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Bc=yc(Rc);function be(...t){return Bc(Io(t))}function Wc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const Ra=c.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:be(t,"relative overflow-hidden"),...s,children:e.jsx("div",{ref:a,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));Ra.displayName="ScrollArea";function Uc({updateAvailable:t,releaseInfo:r,latestVersion:s,onShowVersionModal:a,onShowSettings:n,t:o}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Va,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),e.jsx("div",{className:"md:hidden px-3 py-2",children:e.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Va,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:n,children:[e.jsx(Qe,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),e.jsx("div",{className:"md:hidden p-3 pb-20",children:e.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:e.jsx(Qe,{className:"w-4.5 h-4.5 text-muted-foreground"})}),e.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const gn=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,hn=Io,Ho=(t,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return hn(t,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(d=>{const u=s==null?void 0:s[d],g=o==null?void 0:o[d];if(u===null)return null;const p=gn(u)||gn(g);return n[d][p]}),l=s&&Object.entries(s).reduce((d,u)=>{let[g,p]=u;return p===void 0||(d[g]=p),d},{}),m=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((d,u)=>{let{class:g,className:p,...x}=u;return Object.entries(x).every(f=>{let[h,b]=f;return Array.isArray(b)?b.includes({...o,...l}[h]):{...o,...l}[h]===b})?[...d,g,p]:d},[]);return hn(t,i,m,s==null?void 0:s.class,s==null?void 0:s.className)},Hc=Ho("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),xe=c.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:be(Hc({variant:r,size:s,className:t})),ref:n,...a}));xe.displayName="Button";const st=c.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:be("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...s}));st.displayName="Input";function Gc({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:l,isRefreshing:m,onCreateProject:d,onCollapseSidebar:u,t:g}){const p=()=>e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("div",{className:"w-7 h-7 bg-primary/90 rounded-lg flex items-center justify-center shadow-sm flex-shrink-0",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-primary-foreground",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:g("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(xe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:l,disabled:m,title:g("tooltips.refresh"),children:e.jsx(Ut,{className:`w-3.5 h-3.5 ${m?"animate-spin":""}`})}),e.jsx(xe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:d,title:g("tooltips.createProject"),children:e.jsx(lt,{className:"w-3.5 h-3.5"})}),e.jsx(xe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:u,title:g("tooltips.hideSidebar"),children:e.jsx(Mi,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(dr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),e.jsx(st,{type:"text",placeholder:g("projects.searchPlaceholder"),value:n,onChange:x=>o(x.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:e.jsx(qe,{className:"w-3 h-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"hidden md:block nav-divider"}),e.jsxs("div",{className:"md:hidden p-3 pb-2",style:t&&r?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{}),e.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:l,disabled:m,children:e.jsx(Ut,{className:`w-4 h-4 text-muted-foreground ${m?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:d,children:e.jsx(xs,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(dr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(st,{type:"text",placeholder:g("projects.searchPlaceholder"),value:n,onChange:x=>o(x.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:e.jsx(qe,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),e.jsx("div",{className:"md:hidden nav-divider"})]})}const qc=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Qr,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Qe,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:Ds,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:qe,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),i=o.icon,l={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},m={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:be("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.bgColor,o.color,s),title:o.title,children:[e.jsx(i,{className:l[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:be("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,m[r],s),title:o.title,children:e.jsx(i,{className:be(l[r],o.color)})})},Kc=Ho("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Dt({className:t,variant:r,...s}){return e.jsx("div",{className:be(Kc({variant:r}),t),...s})}const fn=(t,r,s)=>{const a=new Date(t),n=r;if(isNaN(a.getTime()))return s?s("status.unknown"):"Unknown";const o=n.getTime()-a.getTime(),i=Math.floor(o/1e3),l=Math.floor(o/(1e3*60)),m=Math.floor(o/(1e3*60*60)),d=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":l===1?s?s("time.oneMinuteAgo"):"1 min ago":l<60?s?s("time.minutesAgo",{count:l}):`${l} mins ago`:m===1?s?s("time.oneHourAgo"):"1 hour ago":m<24?s?s("time.hoursAgo",{count:m}):`${m} hours ago`:d===1?s?s("time.oneDayAgo"):"1 day ago":d<7?s?s("time.daysAgo",{count:d}):`${d} days ago`:a.toLocaleDateString()};function At({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(il,{className:r}):t==="codex"?e.jsx(ll,{className:r}):e.jsx(cl,{className:r})}function Vc({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:l,onCancelEditingSession:m,onSaveEditingSession:d,onProjectSelect:u,onSessionSelect:g,onDeleteSession:p,touchHandlerFactory:x,t:f}){const h=ql(r,a,f),b=(s==null?void 0:s.id)===r.id,C=()=>{u(t),g(r,t.name)},I=()=>{d(t.name,r.id,o)},y=()=>{p(t.name,r.id,h.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[h.isActive&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:be("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",b?"bg-primary/5 border-primary/20":"",!b&&h.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:C,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:be("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",b?"bg-primary/10":"bg-muted/50"),children:e.jsx(At,{provider:r.__provider,className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:h.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(qr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:fn(h.sessionTime,a,f)}),h.messageCount>0&&e.jsx(Dt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:h.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(At,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!h.isCursorSession&&e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:v=>{v.stopPropagation(),y()},children:e.jsx(ht,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(xe,{variant:"ghost",className:be("w-full justify-start px-2 py-2.5 h-auto min-h-[48px] font-normal text-left hover:bg-accent/50 transition-colors duration-200",b&&"bg-accent text-accent-foreground"),onClick:()=>g(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full pr-14",children:[e.jsx(At,{provider:r.__provider,className:"w-3 h-3 mt-1 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground leading-5",children:h.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(qr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:fn(h.sessionTime,a,f)}),h.messageCount>0&&e.jsx(Dt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:h.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(At,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!h.isCursorSession&&e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-all duration-200 bg-accent/80 backdrop-blur-sm rounded-md px-1 py-0.5",children:n===r.id&&!h.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:v=>i(v.target.value),onKeyDown:v=>{v.stopPropagation(),v.key==="Enter"?I():v.key==="Escape"&&m()},onClick:v=>v.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),I()},title:f("tooltips.save"),children:e.jsx(Tt,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),m()},title:f("tooltips.cancel"),children:e.jsx(qe,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[!h.isCodexSession&&e.jsx("button",{className:"w-7 h-7 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),l(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx($i,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-7 h-7 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:v=>{v.stopPropagation(),y()},title:f("tooltips.deleteSession"),children:e.jsx(ht,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function Jc(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,r)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+r*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},r))})}function Yc({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:l,editingSessionName:m,onEditingSessionNameChange:d,onStartEditingSession:u,onCancelEditingSession:g,onSaveEditingSession:p,onProjectSelect:x,onSessionSelect:f,onDeleteSession:h,onLoadMoreSessions:b,onNewSession:C,touchHandlerFactory:I,t:y}){var M;if(!r)return null;const v=s.length>0,A=((M=t.sessionMeta)==null?void 0:M.hasMore)===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!v&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:y("sessions.noSessions")})}):s.map($=>e.jsx(Vc,{project:t,session:$,selectedSession:a,currentTime:i,editingSession:l,editingSessionName:m,onEditingSessionNameChange:d,onStartEditingSession:u,onCancelEditingSession:g,onSaveEditingSession:p,onProjectSelect:x,onSessionSelect:f,onDeleteSession:h,touchHandlerFactory:I,t:y},$.id)):e.jsx(Jc,{}),v&&A&&e.jsx(xe,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>b(t),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),y("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"w-3 h-3"}),y("sessions.showMore")]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{x(t),C(t)},children:[e.jsx(lt,{className:"w-3 h-3"}),y("sessions.newSession")]})}),e.jsxs(xe,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>C(t),children:[e.jsx(lt,{className:"w-3 h-3"}),y("sessions.newSession")]})]})}const Qc=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function Xc({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:l,sessions:m,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:g,editingSession:p,editingSessionName:x,tasksEnabled:f,mcpServerStatus:h,onEditingNameChange:b,onToggleProject:C,onProjectSelect:I,onToggleStarProject:y,onStartEditingProject:v,onCancelEditingProject:A,onSaveProjectName:M,onDeleteProject:$,onSessionSelect:k,onDeleteSession:T,onLoadMoreSessions:W,onNewSession:U,onEditingSessionNameChange:S,onStartEditingSession:H,onCancelEditingSession:w,onSaveEditingSession:P,touchHandlerFactory:j,t:F}){var z;const G=(r==null?void 0:r.name)===t.name,X=i===t.name,D=((z=t.sessionMeta)==null?void 0:z.hasMore)===!0,oe=Qc(m,D),E=`${oe} session${m.length===1?"":"s"}`,se=Jl(t,h),J=()=>C(t.name),B=()=>y(t.name),K=()=>{M(t.name)},V=()=>{(r==null?void 0:r.name)!==t.name&&I(t),J()};return e.jsxs("div",{className:be("md:space-y-1",n&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:be("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",G&&"bg-primary/5 border-primary/20",o&&!G&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:J,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:be("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(er,{className:"w-4 h-4 text-primary"}):e.jsx(tr,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:X?e.jsx("input",{type:"text",value:l,onChange:O=>b(O.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:F("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:O=>O.stopPropagation(),onKeyDown:O=>{O.key==="Enter"&&K(),O.key==="Escape"&&A()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.displayName}),f&&e.jsx(qc,{status:se,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:E})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:X?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:O=>{O.stopPropagation(),K()},children:e.jsx(Tt,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:O=>{O.stopPropagation(),A()},children:e.jsx(qe,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:be("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",o?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:O=>{O.stopPropagation(),B()},title:F(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Ja,{className:be("w-4 h-4 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:O=>{O.stopPropagation(),$(t)},children:e.jsx(ht,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:O=>{O.stopPropagation(),v(t)},children:e.jsx(Kr,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:a?e.jsx(vt,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(Ot,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(xe,{variant:"ghost",className:be("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",G&&"bg-accent text-accent-foreground",o&&!G&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:V,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a?e.jsx(er,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(tr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:X?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:l,onChange:O=>b(O.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:F("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:O=>{O.key==="Enter"&&K(),O.key==="Escape"&&A()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[oe,t.fullPath!==t.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:t.fullPath,children:[" - ",t.fullPath.length>25?`...${t.fullPath.slice(-22)}`:t.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:X?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:O=>{O.stopPropagation(),K()},children:e.jsx(Tt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:O=>{O.stopPropagation(),A()},children:e.jsx(qe,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:be("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",o?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:O=>{O.stopPropagation(),B()},title:F(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Ja,{className:be("w-3 h-3 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:O=>{O.stopPropagation(),v(t)},title:F("tooltips.renameProject"),children:e.jsx(Kr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:O=>{O.stopPropagation(),$(t)},title:F("tooltips.deleteProject"),children:e.jsx(ht,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(vt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(Ot,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Yc,{project:t,isExpanded:a,sessions:m,selectedSession:s,initialSessionsLoaded:d,isLoadingSessions:u,currentTime:g,editingSession:p,editingSessionName:x,onEditingSessionNameChange:S,onStartEditingSession:H,onCancelEditingSession:w,onSaveEditingSession:P,onProjectSelect:I,onSessionSelect:k,onDeleteSession:T,onLoadMoreSessions:W,onNewSession:U,touchHandlerFactory:j,t:F})]})}function Zc({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=Ta();return t?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.loadingProjects")}),r&&r.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${r.current/r.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.current,"/",r.total," ",n("projects.projects")]}),r.currentProject&&e.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:r.currentProject,children:r.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.fetchingProjects")})]}):s===0?o?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(tr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.runClaudeCli")})]}):e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(co,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"No machine connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your machine to see projects"})]}):a===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(dr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.tryDifferentSearch")})]}):null}function ed({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:l,editingName:m,loadingSessions:d,initialSessionsLoaded:u,currentTime:g,editingSession:p,editingSessionName:x,deletingProjects:f,tasksEnabled:h,mcpServerStatus:b,getProjectSessions:C,isProjectStarred:I,onEditingNameChange:y,onToggleProject:v,onProjectSelect:A,onToggleStarProject:M,onStartEditingProject:$,onCancelEditingProject:k,onSaveProjectName:T,onDeleteProject:W,onSessionSelect:U,onDeleteSession:S,onLoadMoreSessions:H,onNewSession:w,onEditingSessionNameChange:P,onStartEditingSession:j,onCancelEditingSession:F,onSaveEditingSession:G,touchHandlerFactory:X,t:D}){const oe=e.jsx(Zc,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:D}),E=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:E?r.map(se=>e.jsx(Xc,{project:se,selectedProject:s,selectedSession:a,isExpanded:i.has(se.name),isDeleting:f.has(se.name),isStarred:I(se.name),editingProject:l,editingName:m,sessions:C(se),initialSessionsLoaded:u.has(se.name),isLoadingSessions:!!d[se.name],currentTime:g,editingSession:p,editingSessionName:x,tasksEnabled:h,mcpServerStatus:b,onEditingNameChange:y,onToggleProject:v,onProjectSelect:A,onToggleStarProject:M,onStartEditingProject:$,onCancelEditingProject:k,onSaveProjectName:T,onDeleteProject:W,onSessionSelect:U,onDeleteSession:S,onLoadMoreSessions:H,onNewSession:w,onEditingSessionNameChange:P,onStartEditingSession:j,onCancelEditingSession:F,onSaveEditingSession:G,touchHandlerFactory:X,t:D},se.name)):oe})}function td({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:l,isRefreshing:m,onCreateProject:d,onCollapseSidebar:u,updateAvailable:g,releaseInfo:p,latestVersion:x,onShowVersionModal:f,onShowSettings:h,projectListProps:b,t:C}){return e.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[e.jsx(Gc,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:l,isRefreshing:m,onCreateProject:d,onCollapseSidebar:u,t:C}),e.jsx(Ra,{className:"flex-1 md:px-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(ed,{...b})}),e.jsx(Uc,{updateAvailable:g,releaseInfo:p,latestVersion:x,onShowVersionModal:f,onShowSettings:h,t:C})]})}const rd=({onClose:t,onProjectCreated:r})=>{var Re;const{t:s}=Ge(),[a,n]=c.useState(1),[o,i]=c.useState("existing"),[l,m]=c.useState(""),[d,u]=c.useState(""),[g,p]=c.useState(""),[x,f]=c.useState("stored"),[h,b]=c.useState(""),[C,I]=c.useState(!1),[y,v]=c.useState(null),[A,M]=c.useState([]),[$,k]=c.useState(!1),[T,W]=c.useState([]),[U,S]=c.useState(!1),[H,w]=c.useState(!1),[P,j]=c.useState("~"),[F,G]=c.useState([]),[X,D]=c.useState(!1),[oe,E]=c.useState(!1),[se,J]=c.useState(!1),[B,K]=c.useState(""),[V,z]=c.useState(!1),[O,ne]=c.useState("");c.useEffect(()=>{a===2&&o==="new"&&d&&me()},[a,o,d]),c.useEffect(()=>{l.length>2?q(l):(W([]),S(!1))},[l]);const me=async()=>{try{k(!0);const Y=((await(await He.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(ie=>ie.is_active);M(Y),Y.length>0&&!g&&p(Y[0].id.toString())}catch(Z){console.error("Error loading GitHub tokens:",Z)}finally{k(!1)}},q=async Z=>{try{const ye=Z.lastIndexOf("/"),Y=ye>0?Z.substring(0,ye):"~",De=await(await He.browseFilesystem(Y)).json();if(De.suggestions){const de=De.suggestions.filter($e=>$e.path.toLowerCase().startsWith(Z.toLowerCase())&&$e.path.toLowerCase()!==Z.toLowerCase());W(de.slice(0,5)),S(de.length>0)}}catch(ye){console.error("Error loading path suggestions:",ye)}},N=()=>{if(v(null),a===1){if(!o){v(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!l.trim()){v(s("projectWizard.errors.providePath"));return}n(3)}},_=()=>{v(null),n(a-1)},re=async()=>{I(!0),v(null),ne("");try{if(o==="new"&&d){const ie=new URLSearchParams({path:l.trim(),githubUrl:d.trim()});x==="stored"&&g?ie.append("githubTokenId",g):x==="new"&&h&&ie.append("newGithubToken",h.trim());const De=`/api/projects/clone-progress?${ie}`;await new Promise((de,$e)=>{const Le=new EventSource(De);Le.onmessage=Je=>{try{const Ve=JSON.parse(Je.data);Ve.type==="progress"?ne(Ve.message):Ve.type==="complete"?(Le.close(),r&&r(Ve.project),t(),de()):Ve.type==="error"&&(Le.close(),$e(new Error(Ve.message)))}catch(Ve){console.error("Error parsing SSE event:",Ve)}},Le.onerror=()=>{Le.close(),$e(new Error("Connection lost during clone"))}});return}const Z={workspaceType:o,path:l.trim()},ye=await He.createWorkspace(Z),Y=await ye.json();if(!ye.ok)throw new Error(Y.details||Y.error||s("projectWizard.errors.failedToCreate"));r&&r(Y.project),t()}catch(Z){console.error("Error creating workspace:",Z),v(Z.message||s("projectWizard.errors.failedToCreate"))}finally{I(!1)}},te=Z=>{m(Z.path),S(!1)},ve=async()=>{w(!0),await je("~")},je=async Z=>{try{D(!0);const Y=await(await He.browseFilesystem(Z)).json();j(Y.path||Z),G(Y.suggestions||[])}catch(ye){console.error("Error loading folders:",ye)}finally{D(!1)}},Ne=(Z,ye=!1)=>{m(Z),w(!1),ye&&n(3)},we=async Z=>{await je(Z)},Ie=async()=>{if(B.trim()){z(!0),v(null);try{const Z=P.includes("\\")?"\\":"/",ye=`${P}${Z}${B.trim()}`,Y=await He.createFolder(ye),ie=await Y.json();if(!Y.ok)throw new Error(ie.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));K(""),J(!1),await je(ie.path||ye)}catch(Z){console.error("Error creating folder:",Z),v(Z.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{z(!1)}}};return e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(xs,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:C,children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-6 pt-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(Z=>e.jsxs(Ft.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${Z<a?"bg-green-500 text-white":Z===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:Z<a?e.jsx(Tt,{className:"w-4 h-4"}):Z}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(Z===1?"projectWizard.steps.type":Z===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),Z<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${Z<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},Z))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[y&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(Ds,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:y})})]}),a===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:s("projectWizard.step1.question")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(xs,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.existing.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.existing.description")})]})]})}),e.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(Gt,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.new.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.new.description")})]})]})})]})]})}),a===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s(o==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(st,{type:"text",value:l,onChange:Z=>m(Z.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),U&&T.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:T.map((Z,ye)=>e.jsxs("button",{onClick:()=>te(Z),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:Z.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:Z.path})]},ye))})]}),e.jsx(xe,{type:"button",variant:"outline",onClick:ve,className:"px-3",title:"Browse folders",children:e.jsx(er,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s(o==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),o==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.githubUrl")}),e.jsx(st,{type:"text",value:d,onChange:Z=>u(Z.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.githubHelp")})]}),d&&!d.startsWith("git@")&&!d.startsWith("ssh://")&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(Aa,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:s("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step2.githubAuthHelp")})]})]}),$?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(jr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):A.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${x==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${x==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{f("none"),p(""),b("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${x==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.nonePublic")})]}),x==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.selectToken")}),e.jsxs("select",{value:g,onChange:Z=>p(Z.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:s("projectWizard.step2.selectTokenPlaceholder")}),A.map(Z=>e.jsx("option",{value:Z.id,children:Z.credential_name},Z.id))]})]}):x==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.newToken")}),e.jsx(st,{type:"password",value:h,onChange:Z=>b(Z.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.tokenHelp")})]}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.optionalTokenPublic")}),e.jsx(st,{type:"password",value:h,onChange:Z=>b(Z.target.value),placeholder:s("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),a===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:s("projectWizard.step3.reviewConfig")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.workspaceType")}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s(o==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.path")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:l})]}),o==="new"&&d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:d})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:x==="stored"&&g?`${s("projectWizard.step3.usingStoredToken")} ${((Re=A.find(Z=>Z.id.toString()===g))==null?void 0:Re.credential_name)||"Unknown"}`:x==="new"&&h?s("projectWizard.step3.usingProvidedToken"):d.startsWith("git@")||d.startsWith("ssh://")?s("projectWizard.step3.sshKey","SSH Key"):s("projectWizard.step3.noAuthentication")})]})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:C&&O?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("projectWizard.step3.cloningRepository","Cloning repository...")}),e.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:O})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s(o==="existing"?"projectWizard.step3.existingInfo":d?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(xe,{variant:"outline",onClick:a===1?t:_,disabled:C,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(mo,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(xe,{onClick:a===3?re:N,disabled:C||a===1&&!o,children:C?e.jsxs(e.Fragment,{children:[e.jsx(jr,{className:"w-4 h-4 mr-2 animate-spin"}),d?s("projectWizard.buttons.cloning","Cloning..."):s("projectWizard.buttons.creating")]}):a===3?e.jsxs(e.Fragment,{children:[e.jsx(Tt,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(Ot,{className:"w-4 h-4 ml-1"})]})})]})]}),H&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(er,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>E(!oe),className:`p-2 rounded-md transition-colors ${oe?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:oe?"Hide hidden folders":"Show hidden folders",children:oe?e.jsx(ur,{className:"w-5 h-5"}):e.jsx(uo,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>J(!se),className:`p-2 rounded-md transition-colors ${se?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:e.jsx(lt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>w(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(qe,{className:"w-5 h-5"})})]})]}),se&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(st,{type:"text",value:B,onChange:Z=>K(Z.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:Z=>{Z.key==="Enter"&&Ie(),Z.key==="Escape"&&(J(!1),K(""))},autoFocus:!0}),e.jsx(xe,{size:"sm",onClick:Ie,disabled:!B.trim()||V,children:V?e.jsx(jr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(xe,{size:"sm",variant:"ghost",onClick:()=>{J(!1),K("")},children:"Cancel"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:X?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(jr,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[P!=="~"&&P!=="/"&&!/^[A-Za-z]:\\?$/.test(P)&&e.jsxs("button",{onClick:()=>{const Z=Math.max(P.lastIndexOf("/"),P.lastIndexOf("\\"));let ye;Z<=0?ye="/":Z===2&&/^[A-Za-z]:/.test(P)?ye=P.substring(0,3):ye=P.substring(0,Z),we(ye)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),F.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):F.filter(Z=>oe||!Z.name.startsWith(".")).sort((Z,ye)=>Z.name.toLowerCase().localeCompare(ye.name.toLowerCase())).map((Z,ye)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>we(Z.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(xs,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:Z.name})]}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>Ne(Z.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},ye))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:P})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(xe,{variant:"outline",onClick:()=>{w(!1),J(!1),K("")},children:"Cancel"}),e.jsx(xe,{variant:"outline",onClick:()=>Ne(P,o==="existing"),children:"Use this folder"})]})]})]})})]})},sd="2.5.0";function ad(){const{t}=Ge("settings"),[r,s]=c.useState([]),[a,n]=c.useState([]),[o,i]=c.useState(!0),[l,m]=c.useState(!1),[d,u]=c.useState(!1),[g,p]=c.useState(""),[x,f]=c.useState(""),[h,b]=c.useState(""),[C,I]=c.useState(""),[y,v]=c.useState({}),[A,M]=c.useState(null),[$,k]=c.useState(null),{updateAvailable:T,latestVersion:W,releaseInfo:U}=So("thinqmesh","upfynai-code");c.useEffect(()=>{S()},[]);const S=async()=>{try{i(!0);const oe=await(await Ee("/api/settings/api-keys")).json();s(oe.apiKeys||[]);const se=await(await Ee("/api/settings/credentials?type=github_token")).json();n(se.credentials||[])}catch(D){console.error("Error fetching settings:",D)}finally{i(!1)}},H=async()=>{if(g.trim())try{const oe=await(await Ee("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:g})})).json();oe.success&&(k(oe.apiKey),p(""),m(!1),S())}catch(D){console.error("Error creating API key:",D)}},w=async D=>{if(confirm(t("apiKeys.confirmDelete")))try{await Ee(`/api/settings/api-keys/${D}`,{method:"DELETE"}),S()}catch(oe){console.error("Error deleting API key:",oe)}},P=async(D,oe)=>{try{await Ee(`/api/settings/api-keys/${D}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!oe})}),S()}catch(E){console.error("Error toggling API key:",E)}},j=async()=>{if(!(!x.trim()||!h.trim()))try{(await(await Ee("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:x,credentialType:"github_token",credentialValue:h,description:C})})).json()).success&&(f(""),b(""),I(""),u(!1),S())}catch(D){console.error("Error creating GitHub credential:",D)}},F=async D=>{if(confirm(t("apiKeys.github.confirmDelete")))try{await Ee(`/api/settings/credentials/${D}`,{method:"DELETE"}),S()}catch(oe){console.error("Error deleting GitHub credential:",oe)}},G=async(D,oe)=>{try{await Ee(`/api/settings/credentials/${D}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!oe})}),S()}catch(E){console.error("Error toggling GitHub credential:",E)}},X=(D,oe)=>{navigator.clipboard.writeText(D),M(oe),setTimeout(()=>M(null),2e3)};return o?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs("div",{className:"space-y-8",children:[$&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:t("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:$.apiKey}),e.jsx(xe,{size:"sm",variant:"outline",onClick:()=>X($.apiKey,"new"),children:A==="new"?e.jsx(Tt,{className:"h-4 w-4"}):e.jsx(Da,{className:"h-4 w-4"})})]}),e.jsx(xe,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>k(null),children:t("apiKeys.newKey.iveSavedIt")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Aa,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(xe,{size:"sm",onClick:()=>m(!l),children:[e.jsx(lt,{className:"h-4 w-4 mr-1"}),t("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[t("apiKeys.apiDocsLink"),e.jsx(Ya,{className:"h-3 w-3"})]})]}),l&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(st,{placeholder:t("apiKeys.form.placeholder"),value:g,onChange:D=>p(D.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{onClick:H,children:t("apiKeys.form.createButton")}),e.jsx(xe,{variant:"outline",onClick:()=>m(!1),children:t("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.empty")}):r.map(D=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:D.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:D.api_key}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.list.created")," ",new Date(D.created_at).toLocaleDateString(),D.last_used&&` • ${t("apiKeys.list.lastUsed")} ${new Date(D.last_used).toLocaleDateString()}`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{size:"sm",variant:D.is_active?"outline":"secondary",onClick:()=>P(D.id,D.is_active),children:D.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(xe,{size:"sm",variant:"ghost",onClick:()=>w(D.id),children:e.jsx(ht,{className:"h-4 w-4"})})]})]},D.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Li,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(xe,{size:"sm",onClick:()=>u(!d),children:[e.jsx(lt,{className:"h-4 w-4 mr-1"}),t("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("apiKeys.github.descriptionAlt")}),d&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[e.jsx(st,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:x,onChange:D=>f(D.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(st,{type:y.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:h,onChange:D=>b(D.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>v({...y,new:!y.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:y.new?e.jsx(uo,{className:"h-4 w-4"}):e.jsx(ur,{className:"h-4 w-4"})})]}),e.jsx(st,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:C,onChange:D=>I(D.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{onClick:j,children:t("apiKeys.github.form.addButton")}),e.jsx(xe,{variant:"outline",onClick:()=>{u(!1),f(""),b(""),I("")},children:t("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:t("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.github.empty")}):a.map(D=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:D.credential_name}),D.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:D.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.github.added")," ",new Date(D.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{size:"sm",variant:D.is_active?"outline":"secondary",onClick:()=>G(D.id,D.is_active),children:D.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(xe,{size:"sm",variant:"ghost",onClick:()=>F(D.id),children:e.jsx(ht,{className:"h-4 w-4"})})]})]},D.id))})]}),e.jsx("div",{className:"pt-6 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[e.jsxs("a",{href:(U==null?void 0:U.htmlUrl)||"https://github.com/thinqmesh/upfynai-code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",sd]}),T&&W&&e.jsxs("a",{href:(U==null?void 0:U.htmlUrl)||"https://github.com/thinqmesh/upfynai-code/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[e.jsx("span",{className:"text-[10px]",children:t("apiKeys.version.updateAvailable",{version:W})}),e.jsx(Ya,{className:"h-2.5 w-2.5"})]})]})})]})}function nd(){const{t}=Ge("settings"),[r,s]=c.useState(""),[a,n]=c.useState(""),[o,i]=c.useState(!1),[l,m]=c.useState(!1),[d,u]=c.useState(null);c.useEffect(()=>{g()},[]);const g=async()=>{try{i(!0);const x=await Ee("/api/user/git-config");if(x.ok){const f=await x.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(x){console.error("Error loading git config:",x)}finally{i(!1)}},p=async()=>{try{m(!0);const x=await Ee("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(x.ok)u("success"),setTimeout(()=>u(null),3e3);else{const f=await x.json();u("error"),console.error("Failed to save git config:",f.error)}}catch(x){console.error("Error saving git config:",x),u("error")}finally{m(!1)}};return e.jsx("div",{className:"space-y-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Gt,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("git.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("git.description")}),e.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:t("git.name.label")}),e.jsx(st,{id:"settings-git-name",type:"text",value:r,onChange:x=>s(x.target.value),placeholder:"John Doe",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.name.help")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:t("git.email.label")}),e.jsx(st,{id:"settings-git-email",type:"email",value:a,onChange:x=>n(x.target.value),placeholder:"john@example.com",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.email.help")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{onClick:p,disabled:l||!r||!a,children:t(l?"git.actions.saving":"git.actions.save")}),d==="success"&&e.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[e.jsx(Tt,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function od(){const{t}=Ge("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=Yr();return e.jsx("div",{className:"space-y-8",children:n?e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:e.jsx("code",{children:t("tasks.notInstalled.installCommand")})}),e.jsx("div",{children:e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),t("tasks.notInstalled.viewOnGitHub"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:t("tasks.notInstalled.afterInstallation")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[e.jsx("li",{children:t("tasks.notInstalled.steps.restart")}),e.jsx("li",{children:t("tasks.notInstalled.steps.autoAvailable")}),e.jsx("li",{children:t("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),a&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t("tasks.settings.enableLabel")}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("tasks.settings.enableDescription")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>s(o.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const id={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},ld={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function wr({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=Ge("settings"),i=id[t],l=ld[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${l.borderBottom} ${l.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(At,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),(r==null?void 0:r.authenticated)&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${l.border} ${l.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(At,{provider:t,className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:i.name})]}),e.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:r!=null&&r.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${l.dot}`}),e.jsx("span",{className:"truncate max-w-[120px]",title:r.email,children:r.email||o("agents.authStatus.connected")})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),e.jsx("span",{children:o("agents.authStatus.notConnected")})]})})]})}const cd={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function dd({agent:t,authStatus:r,onLogin:s}){const{t:a}=Ge("settings"),n=cd[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(At,{provider:t,className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`)})]})]}),e.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.loading?a("agents.authStatus.checkingAuth"):r!=null&&r.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r!=null&&r.loading?e.jsx(Dt,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsx(Dt,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(Dt,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:n.name})})]}),e.jsxs(xe,{onClick:s,className:`${n.buttonClass} text-white`,size:"sm",children:[e.jsx(Fi,{className:"w-4 h-4 mr-2"}),r!=null&&r.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),(r==null?void 0:r.error)&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:r.error})})})]})})]})}const md=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],ud=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function pd({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:l,newDisallowedTool:m,setNewDisallowedTool:d}){const{t:u}=Ge("settings"),g=h=>{h&&!s.includes(h)&&(a([...s,h]),l(""))},p=h=>{a(s.filter(b=>b!==h))},x=h=>{h&&!n.includes(h)&&(o([...n,h]),d(""))},f=h=>{o(n.filter(b=>b!==h))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qt,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:h=>r(h.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:u("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:u("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(st,{value:i,onChange:h=>l(h.target.value),placeholder:u("permissions.allowedTools.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(lt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:u("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:md.map(h=>e.jsx(xe,{variant:"outline",size:"sm",onClick:()=>g(h),disabled:s.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(h=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:h}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>p(h),className:"text-green-600 hover:text-green-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qt,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(st,{value:m,onChange:h=>d(h.target.value),placeholder:u("permissions.blockedTools.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),x(m))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>x(m),disabled:!m,size:"sm",className:"h-10 px-4",children:[e.jsx(lt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(h=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:h}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>f(h),className:"text-red-600 hover:text-red-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:u("permissions.toolExamples.title")}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",u("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",u("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",u("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",u("permissions.toolExamples.bashRm")]})]})]})]})}function xd({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:l,newDisallowedCommand:m,setNewDisallowedCommand:d}){const{t:u}=Ge("settings"),g=h=>{h&&!s.includes(h)&&(a([...s,h]),l(""))},p=h=>{a(s.filter(b=>b!==h))},x=h=>{h&&!n.includes(h)&&(o([...n,h]),d(""))},f=h=>{o(n.filter(b=>b!==h))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qt,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:h=>r(h.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:u("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:u("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(st,{value:i,onChange:h=>l(h.target.value),placeholder:u("permissions.allowedCommands.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),g(i))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>g(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(lt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:u("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ud.map(h=>e.jsx(xe,{variant:"outline",size:"sm",onClick:()=>g(h),disabled:s.includes(h),className:"text-xs h-8",children:h},h))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(h=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:h}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>p(h),className:"text-green-600 hover:text-green-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qt,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(st,{value:m,onChange:h=>d(h.target.value),placeholder:u("permissions.blockedCommands.placeholder"),onKeyPress:h=>{h.key==="Enter"&&(h.preventDefault(),x(m))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>x(m),disabled:!m,size:"sm",className:"h-10 px-4",children:[e.jsx(lt,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:u("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(h=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:h}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>f(h),className:"text-red-600 hover:text-red-700",children:e.jsx(qe,{className:"w-4 h-4"})})]},h)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:u("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:u("permissions.shellExamples.title")}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",u("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",u("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",u("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",u("permissions.shellExamples.rmRf")]})]})]})]})}function gd({permissionMode:t,setPermissionMode:r}){const{t:s}=Ge("settings");return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pt,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:s("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("permissions.codex.description")}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:s("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:s("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:s("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[s("permissions.codex.modes.bypassPermissions.title"),e.jsx(qt,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:s("permissions.codex.modes.bypassPermissions.description")})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:s("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.default.title"),":"]})," ",s("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.acceptEdits.title"),":"]})," ",s("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.bypassPermissions.title"),":"]})," ",s("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:s("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function Ys({agent:t,...r}){return t==="claude"?e.jsx(pd,{...r}):t==="cursor"?e.jsx(xd,{...r}):t==="codex"?e.jsx(gd,{...r}):null}const hd=t=>{switch(t){case"stdio":return e.jsx(ct,{className:"w-4 h-4"});case"sse":return e.jsx(cr,{className:"w-4 h-4"});case"http":return e.jsx(Vr,{className:"w-4 h-4"});default:return e.jsx(Ms,{className:"w-4 h-4"})}};function fd({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:l,toolsLoading:m}){const{t:d}=Ge("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ms,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:d("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d("mcpServers.description.claude")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(xe,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(lt,{className:"w-4 h-4 mr-2"}),d("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(u=>{var g,p,x,f;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[hd(u.type),e.jsx("span",{className:"font-medium text-foreground",children:u.name}),e.jsx(Dt,{variant:"outline",className:"text-xs",children:u.type}),e.jsx(Dt,{variant:"outline",className:"text-xs",children:u.scope==="local"?d("mcpServers.scope.local"):u.scope==="user"?d("mcpServers.scope.user"):u.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[u.type==="stdio"&&((g=u.config)==null?void 0:g.command)&&e.jsxs("div",{children:[d("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.command})]}),(u.type==="sse"||u.type==="http")&&((p=u.config)==null?void 0:p.url)&&e.jsxs("div",{children:[d("mcpServers.config.url"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.url})]}),((x=u.config)==null?void 0:x.args)&&u.config.args.length>0&&e.jsxs("div",{children:[d("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:u.config.args.join(" ")})]})]}),(i==null?void 0:i[u.id])&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[u.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[u.id].message})}),(l==null?void 0:l[u.id])&&((f=l[u.id].tools)==null?void 0:f.length)>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:[d("mcpServers.tools.title")," ",d("mcpServers.tools.count",{count:l[u.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[l[u.id].tools.slice(0,5).map((h,b)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:h.name},b)),l[u.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:d("mcpServers.tools.more",{count:l[u.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(xe,{onClick:()=>s(u),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:d("mcpServers.actions.edit"),children:e.jsx(Kr,{className:"w-4 h-4"})}),e.jsx(xe,{onClick:()=>a(u.id,u.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:d("mcpServers.actions.delete"),children:e.jsx(ht,{className:"w-4 h-4"})})]})]})},u.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:d("mcpServers.empty")})]})]})}function bd({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=Ge("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ms,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.cursor")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(xe,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(lt,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ct,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(Dt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(xe,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Kr,{className:"w-4 h-4"})}),e.jsx(xe,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(ht,{className:"w-4 h-4"})})]})]})},o.name||o.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]})]})}function yd({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=Ge("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ms,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.codex")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(xe,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(lt,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i,l,m;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ct,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(Dt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),((l=o.config)==null?void 0:l.args)&&o.config.args.length>0&&e.jsxs("div",{children:[n("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),((m=o.config)==null?void 0:m.env)&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:[n("mcpServers.config.environment"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([d,u])=>`${d}=${u}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(xe,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Kr,{className:"w-4 h-4"})}),e.jsx(xe,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(ht,{className:"w-4 h-4"})})]})]})},o.name)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:n("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:n("mcpServers.help.description")})]})]})}function Qs({agent:t,...r}){return t==="claude"?e.jsx(fd,{...r}):t==="cursor"?e.jsx(bd,{...r}):t==="codex"?e.jsx(yd,{...r}):null}function Go({compact:t=!1}){const{i18n:r,t:s}=Ge("settings"),a=n=>{const o=n.target.value;r.changeLanguage(o)};return t?e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(po,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s("account.language")]}),e.jsx("select",{value:r.language,onChange:a,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:Ka.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:s("account.languageLabel")}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("account.languageDescription")})]}),e.jsx("select",{value:r.language,onChange:a,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:Ka.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function vd({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){var Gs,ts,Ga,qa;const{isDarkMode:n,toggleDarkMode:o}=Ia(),{t:i}=Ge("settings"),{addToast:l}=mr(),[m,d]=c.useState([]),[u,g]=c.useState([]),[p,x]=c.useState(""),[f,h]=c.useState(""),[b,C]=c.useState(!1),[I,y]=c.useState(!1),[v,A]=c.useState(null),[M,$]=c.useState("name"),[k,T]=c.useState([]),[W,U]=c.useState(!1),[S,H]=c.useState(null),[w,P]=c.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[j,F]=c.useState(!1),[G,X]=c.useState({}),[D,oe]=c.useState({}),[E,se]=c.useState({}),[J,B]=c.useState(a),[K,V]=c.useState(""),[z,O]=c.useState("claude"),[ne,me]=c.useState("account"),[q,N]=c.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[_,re]=c.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[te,ve]=c.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[je,Ne]=c.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[we,Ie]=c.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[Re,Z]=c.useState([]),[ye,Y]=c.useState([]),[ie,De]=c.useState(!1),[de,$e]=c.useState(""),[Le,Je]=c.useState(""),[Ve,ge]=c.useState([]),[Fe,Ce]=c.useState([]),[ze,Pe]=c.useState("default"),[_e,Ke]=c.useState(!1),[ae,ke]=c.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[Be,Ue]=c.useState(null),[mt,It]=c.useState(!1),[pt,kt]=c.useState(!1),[le,pe]=c.useState(""),[ue,Se]=c.useState(null),[We,Xe]=c.useState({authenticated:!1,email:null,loading:!0,error:null}),[Ze,dt]=c.useState({authenticated:!1,email:null,loading:!0,error:null}),[Mt,bt]=c.useState({authenticated:!1,email:null,loading:!0,error:null}),wt=async()=>{try{const L=await Ee("/api/cursor/mcp");if(L.ok){const Q=await L.json();ge(Q.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(L){console.error("Error fetching Cursor MCP servers:",L)}},nt=async()=>{try{const L=await Ee("/api/codex/mcp/config/read");if(L.ok){const ce=await L.json();if(ce.success&&ce.servers){Ce(ce.servers);return}}const Q=await Ee("/api/codex/mcp/cli/list");if(Q.ok){const ce=await Q.json();if(ce.success&&ce.servers){const Te=ce.servers.map(tt=>({id:tt.name,name:tt.name,type:tt.type||"stdio",scope:"user",config:{command:tt.command||"",args:tt.args||[],env:tt.env||{}}}));Ce(Te)}}}catch(L){console.error("Error fetching Codex MCP servers:",L)}},at=async()=>{try{const L=await Ee("/api/mcp/config/read");if(L.ok){const Te=await L.json();if(Te.success&&Te.servers){T(Te.servers);return}}const Q=await Ee("/api/mcp/cli/list");if(Q.ok){const Te=await Q.json();if(Te.success&&Te.servers){const tt=Te.servers.map(ut=>({id:ut.name,name:ut.name,type:ut.type,scope:"user",config:{command:ut.command||"",args:ut.args||[],env:ut.env||{},url:ut.url||"",headers:ut.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));T(tt);return}}const ce=await Ee("/api/mcp/servers?scope=user");if(ce.ok){const Te=await ce.json();T(Te.servers||[])}else console.error("Failed to fetch MCP servers")}catch(L){console.error("Error fetching MCP servers:",L)}},Rt=async L=>{var Q,ce,Te,tt,ut;try{S&&await Bt(S.id,"user");const br=await Ee("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:L.name,type:L.type,scope:L.scope,projectPath:L.projectPath,command:(Q=L.config)==null?void 0:Q.command,args:((ce=L.config)==null?void 0:ce.args)||[],url:(Te=L.config)==null?void 0:Te.url,headers:((tt=L.config)==null?void 0:tt.headers)||{},env:((ut=L.config)==null?void 0:ut.env)||{}})});if(br.ok){const rs=await br.json();if(rs.success)return await at(),!0;throw new Error(rs.error||"Failed to save server via Claude CLI")}else{const rs=await br.json();throw new Error(rs.error||"Failed to save server")}}catch(br){throw console.error("Error saving MCP server:",br),br}},Bt=async(L,Q="user")=>{try{const ce=await Ee(`/api/mcp/cli/remove/${L}?scope=${Q}`,{method:"DELETE"});if(ce.ok){const Te=await ce.json();if(Te.success)return await at(),!0;throw new Error(Te.error||"Failed to delete server via Claude CLI")}else{const Te=await ce.json();throw new Error(Te.error||"Failed to delete server")}}catch(ce){throw console.error("Error deleting MCP server:",ce),ce}},gr=async(L,Q="user")=>{try{const ce=await Ee(`/api/mcp/servers/${L}/test?scope=${Q}`,{method:"POST"});if(ce.ok)return(await ce.json()).testResult;{const Te=await ce.json();throw new Error(Te.error||"Failed to test server")}}catch(ce){throw console.error("Error testing MCP server:",ce),ce}},hr=async(L,Q="user")=>{try{const ce=await Ee(`/api/mcp/servers/${L}/tools?scope=${Q}`,{method:"POST"});if(ce.ok)return(await ce.json()).toolsResult;{const Te=await ce.json();throw new Error(Te.error||"Failed to discover tools")}}catch(ce){throw console.error("Error discovering MCP tools:",ce),ce}},R=async L=>{var Q,ce,Te;try{Be&&await ee(Be.id);const tt=await Ee("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:L.name,command:(Q=L.config)==null?void 0:Q.command,args:((ce=L.config)==null?void 0:ce.args)||[],env:((Te=L.config)==null?void 0:Te.env)||{}})});if(tt.ok){const ut=await tt.json();if(ut.success)return await nt(),!0;throw new Error(ut.error||"Failed to save Codex MCP server")}else{const ut=await tt.json();throw new Error(ut.error||"Failed to save server")}}catch(tt){throw console.error("Error saving Codex MCP server:",tt),tt}},ee=async L=>{try{const Q=await Ee(`/api/codex/mcp/cli/remove/${L}`,{method:"DELETE"});if(Q.ok){const ce=await Q.json();if(ce.success)return await nt(),!0;throw new Error(ce.error||"Failed to delete Codex MCP server")}else{const ce=await Q.json();throw new Error(ce.error||"Failed to delete server")}}catch(Q){throw console.error("Error deleting Codex MCP server:",Q),Q}},Ae=()=>{ke({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),Ue(null),Ke(!1)},et=(L=null)=>{var Q,ce,Te;L?(Ue(L),ke({name:L.name,type:L.type||"stdio",config:{command:((Q=L.config)==null?void 0:Q.command)||"",args:((ce=L.config)==null?void 0:ce.args)||[],env:((Te=L.config)==null?void 0:Te.env)||{}}})):Ae(),Ke(!0)},jt=async L=>{L.preventDefault(),It(!0);try{Be&&await ee(Be.name),await R(ae),Ae(),A("success")}catch(Q){l(`Error: ${Q.message}`,"error"),A("error")}finally{It(!1)}},xt=async L=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await ee(L),A("success")}catch(Q){l(`Error: ${Q.message}`,"error"),A("error")}};c.useEffect(()=>{t&&(_s(),Xr(),Zr(),es(),B(a))},[t,a]),c.useEffect(()=>{localStorage.setItem("codeEditorTheme",q),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[q]),c.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",_.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[_]),c.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",te.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[te]),c.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",je.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[je]),c.useEffect(()=>{localStorage.setItem("codeEditorFontSize",we),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[we]);const _s=async()=>{try{const L=localStorage.getItem("claude-settings");if(L){const Te=JSON.parse(L);d(Te.allowedTools||[]),g(Te.disallowedTools||[]),C(Te.skipPermissions||!1),$(Te.projectSortOrder||"name")}else d([]),g([]),C(!1),$("name");const Q=localStorage.getItem("cursor-tools-settings");if(Q){const Te=JSON.parse(Q);Z(Te.allowedCommands||[]),Y(Te.disallowedCommands||[]),De(Te.skipPermissions||!1)}else Z([]),Y([]),De(!1);const ce=localStorage.getItem("codex-settings");if(ce){const Te=JSON.parse(ce);Pe(Te.permissionMode||"default")}else Pe("default");await at(),await wt(),await nt()}catch(L){console.error("Error loading tool settings:",L),d([]),g([]),C(!1),$("name")}},Xr=async()=>{try{const L=await Ee("/api/cli/claude/status");if(L.ok){const Q=await L.json();Xe({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else Xe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Claude auth status:",L),Xe({authenticated:!1,email:null,loading:!1,error:L.message})}},Zr=async()=>{try{const L=await Ee("/api/cli/cursor/status");if(L.ok){const Q=await L.json();dt({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else dt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Cursor auth status:",L),dt({authenticated:!1,email:null,loading:!1,error:L.message})}},es=async()=>{try{const L=await Ee("/api/cli/codex/status");if(L.ok){const Q=await L.json();bt({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else bt({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(L){console.error("Error checking Codex auth status:",L),bt({authenticated:!1,email:null,loading:!1,error:L.message})}},zs=()=>{pe("claude"),Se((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),kt(!0)},Os=()=>{pe("cursor"),Se((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),kt(!0)},Rs=()=>{pe("codex"),Se((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),kt(!0)},fr=L=>{L===0&&(A("success"),le==="claude"?Xr():le==="cursor"?Zr():le==="codex"&&es())},Bs=()=>{y(!0),A(null);try{const L={allowedTools:m,disallowedTools:u,skipPermissions:b,projectSortOrder:M,lastUpdated:new Date().toISOString()},Q={allowedCommands:Re,disallowedCommands:ye,skipPermissions:ie,lastUpdated:new Date().toISOString()},ce={permissionMode:ze,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(L)),localStorage.setItem("cursor-tools-settings",JSON.stringify(Q)),localStorage.setItem("codex-settings",JSON.stringify(ce)),A("success"),setTimeout(()=>{r()},1e3)}catch(L){console.error("Error saving tool settings:",L),A("error")}finally{y(!1)}},ar=()=>{P({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),H(null),U(!1),V("")},Mr=(L=null)=>{L?(H(L),P({name:L.name,type:L.type,scope:L.scope,projectPath:L.projectPath||"",config:{...L.config},raw:L.raw,importMode:"form",jsonInput:""})):ar(),U(!0)},Ws=async L=>{L.preventDefault(),F(!0);try{if(w.importMode==="json"){const Q=await Ee("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:w.name,jsonConfig:w.jsonInput,scope:w.scope,projectPath:w.projectPath})});if(Q.ok){const ce=await Q.json();if(ce.success)await at(),ar(),A("success");else throw new Error(ce.error||"Failed to add server via JSON")}else{const ce=await Q.json();throw new Error(ce.error||"Failed to add server")}}else await Rt(w),ar(),A("success")}catch(Q){l(`Error: ${Q.message}`,"error"),A("error")}finally{F(!1)}},Us=async(L,Q)=>{if(confirm("Are you sure you want to delete this MCP server?"))try{await Bt(L,Q),A("success")}catch(ce){l(`Error: ${ce.message}`,"error"),A("error")}},Hs=async(L,Q)=>{try{X({...G,[L]:{loading:!0}});const ce=await gr(L,Q);X({...G,[L]:ce})}catch(ce){X({...G,[L]:{success:!1,message:ce.message,details:[]}})}},Nt=async(L,Q)=>{try{se({...E,[L]:!0});const ce=await hr(L,Q);oe({...D,[L]:ce})}catch{oe({...D,[L]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{se({...E,[L]:!1})}},Et=(L,Q)=>{P(ce=>({...ce,config:{...ce.config,[L]:Q}}))};return t?e.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Qe,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex px-4 md:px-6",children:[e.jsx("button",{onClick:()=>B("agents"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${J==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.agents")}),e.jsx("button",{onClick:()=>B("appearance"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${J==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),e.jsxs("button",{onClick:()=>B("git"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${J==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Gt,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>B("api"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${J==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Aa,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>B("tasks"),className:`px-4 py-3 text-sm font-medium border-b-2 transition-colors ${J==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.tasks")})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[J==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:J==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),e.jsxs("button",{onClick:o,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":n,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${n?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:n?e.jsx(oa,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(ia,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(Go,{})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),e.jsxs("select",{value:M,onChange:L=>$(L.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),e.jsxs("button",{onClick:()=>N(q==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":q==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${q==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:q==="dark"?e.jsx(oa,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(ia,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),e.jsxs("button",{onClick:()=>re(!_),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":_,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${_?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),e.jsxs("button",{onClick:()=>ve(!te),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":te,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${te?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>Ne(!je),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":je,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${je?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),e.jsxs("select",{value:we,onChange:L=>Ie(L.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),J==="git"&&e.jsx(nd,{}),J==="agents"&&e.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[e.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex",children:[e.jsx(wr,{agentId:"claude",authStatus:We,isSelected:z==="claude",onClick:()=>O("claude"),isMobile:!0}),e.jsx(wr,{agentId:"cursor",authStatus:Ze,isSelected:z==="cursor",onClick:()=>O("cursor"),isMobile:!0}),e.jsx(wr,{agentId:"codex",authStatus:Mt,isSelected:z==="codex",onClick:()=>O("codex"),isMobile:!0})]})}),e.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"p-2",children:[e.jsx(wr,{agentId:"claude",authStatus:We,isSelected:z==="claude",onClick:()=>O("claude")}),e.jsx(wr,{agentId:"cursor",authStatus:Ze,isSelected:z==="cursor",onClick:()=>O("cursor")}),e.jsx(wr,{agentId:"codex",authStatus:Mt,isSelected:z==="codex",onClick:()=>O("codex")})]})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>me("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${ne==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.account")}),e.jsx("button",{onClick:()=>me("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${ne==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.permissions")}),e.jsx("button",{onClick:()=>me("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${ne==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.mcpServers")})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[ne==="account"&&e.jsx(dd,{agent:z,authStatus:z==="claude"?We:z==="cursor"?Ze:Mt,onLogin:z==="claude"?zs:z==="cursor"?Os:Rs}),ne==="permissions"&&z==="claude"&&e.jsx(Ys,{agent:"claude",skipPermissions:b,setSkipPermissions:C,allowedTools:m,setAllowedTools:d,disallowedTools:u,setDisallowedTools:g,newAllowedTool:p,setNewAllowedTool:x,newDisallowedTool:f,setNewDisallowedTool:h}),ne==="permissions"&&z==="cursor"&&e.jsx(Ys,{agent:"cursor",skipPermissions:ie,setSkipPermissions:De,allowedCommands:Re,setAllowedCommands:Z,disallowedCommands:ye,setDisallowedCommands:Y,newAllowedCommand:de,setNewAllowedCommand:$e,newDisallowedCommand:Le,setNewDisallowedCommand:Je}),ne==="permissions"&&z==="codex"&&e.jsx(Ys,{agent:"codex",permissionMode:ze,setPermissionMode:Pe}),ne==="mcp"&&z==="claude"&&e.jsx(Qs,{agent:"claude",servers:k,onAdd:()=>Mr(),onEdit:L=>Mr(L),onDelete:(L,Q)=>Us(L,Q),onTest:(L,Q)=>Hs(L,Q),onDiscoverTools:(L,Q)=>Nt(L,Q),testResults:G,serverTools:D,toolsLoading:E}),ne==="mcp"&&z==="cursor"&&e.jsx(Qs,{agent:"cursor",servers:Ve,onAdd:()=>{},onEdit:L=>{},onDelete:L=>{}}),ne==="mcp"&&z==="codex"&&e.jsx(Qs,{agent:"codex",servers:Fe,onAdd:()=>et(),onEdit:L=>et(L),onDelete:L=>xt(L)})]})]})]}),W&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(S?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:ar,children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Ws,className:"p-4 space-y-4",children:[!S&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>P(L=>({...L,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${w.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>P(L=>({...L,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${w.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),w.importMode==="form"&&S&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.scope==="user"?e.jsx(Vr,{className:"w-4 h-4"}):e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:w.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),w.scope==="local"&&w.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",w.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),w.importMode==="form"&&!S&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>P(L=>({...L,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${w.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(Vr,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>P(L=>({...L,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${w.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:w.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),w.scope==="local"&&!S&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:w.projectPath,onChange:L=>P(Q=>({...Q,projectPath:L.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:w.scope==="local",children:[e.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),s.map(L=>e.jsx("option",{value:L.path||L.fullPath,children:L.displayName||L.name},L.name))]}),w.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:w.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:w.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(st,{value:w.name,onChange:L=>{P(Q=>({...Q,name:L.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),w.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),e.jsxs("select",{value:w.type,onChange:L=>{P(Q=>({...Q,type:L.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),S&&w.raw&&w.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:S.scope==="global"?"~/.claude.json":"project config"})}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(w.raw,null,2)})]}),w.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:w.jsonInput,onChange:L=>{P(Q=>({...Q,jsonInput:L.target.value}));try{if(L.target.value.trim()){const Q=JSON.parse(L.target.value);Q.type?Q.type==="stdio"&&!Q.command?V(i("mcpForm.validation.stdioRequiresCommand")):(Q.type==="http"||Q.type==="sse")&&!Q.url?V(i("mcpForm.validation.httpRequiresUrl",{type:Q.type})):V(""):V(i("mcpForm.validation.missingType"))}}catch{L.target.value.trim()?V(i("mcpForm.validation.invalidJson")):V("")}},className:`w-full px-3 py-2 border ${K?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
3
+ "type": "stdio",
4
+ "command": "/path/to/server",
5
+ "args": ["--api-key", "abc123"],
6
+ "env": {
7
+ "CACHE_DIR": "/tmp"
8
+ }
9
+ }`,required:!0}),K&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:K}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i("mcpForm.validation.jsonHelp"),e.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',e.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),w.importMode==="form"&&w.type==="stdio"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),e.jsx(st,{value:w.config.command,onChange:L=>Et("command",L.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),e.jsx("textarea",{value:Array.isArray(w.config.args)?w.config.args.join(`
10
+ `):"",onChange:L=>Et("args",L.target.value.split(`
11
+ `).filter(Q=>Q.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`--api-key
12
+ abc123`})]})]}),w.importMode==="form"&&(w.type==="sse"||w.type==="http")&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.url")," *"]}),e.jsx(st,{value:w.config.url,onChange:L=>Et("url",L.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),w.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),e.jsx("textarea",{value:Object.entries(w.config.env||{}).map(([L,Q])=>`${L}=${Q}`).join(`
13
+ `),onChange:L=>{const Q={};L.target.value.split(`
14
+ `).forEach(ce=>{const[Te,...tt]=ce.split("=");Te&&Te.trim()&&(Q[Te.trim()]=tt.join("=").trim())}),Et("env",Q)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`API_KEY=your-key
15
+ DEBUG=true`})]}),w.importMode==="form"&&(w.type==="sse"||w.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.headers")}),e.jsx("textarea",{value:Object.entries(w.config.headers||{}).map(([L,Q])=>`${L}=${Q}`).join(`
16
+ `),onChange:L=>{const Q={};L.target.value.split(`
17
+ `).forEach(ce=>{const[Te,...tt]=ce.split("=");Te&&Te.trim()&&(Q[Te.trim()]=tt.join("=").trim())}),Et("headers",Q)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`Authorization=Bearer token
18
+ X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(xe,{type:"button",variant:"outline",onClick:ar,children:i("mcpForm.actions.cancel")}),e.jsx(xe,{type:"submit",disabled:j,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(j?"mcpForm.actions.saving":S?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),_e&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(Be?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:Ae,children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:jt,className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(st,{value:ae.name,onChange:L=>ke(Q=>({...Q,name:L.target.value})),placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),e.jsx(st,{value:((Gs=ae.config)==null?void 0:Gs.command)||"",onChange:L=>ke(Q=>({...Q,config:{...Q.config,command:L.target.value}})),placeholder:"npx @my-org/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),e.jsx("textarea",{value:(((ts=ae.config)==null?void 0:ts.args)||[]).join(`
19
+ `),onChange:L=>ke(Q=>({...Q,config:{...Q.config,args:L.target.value.split(`
20
+ `).filter(ce=>ce.trim())}})),placeholder:`--port
21
+ 3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),e.jsx("textarea",{value:Object.entries(((Ga=ae.config)==null?void 0:Ga.env)||{}).map(([L,Q])=>`${L}=${Q}`).join(`
22
+ `),onChange:L=>{const Q={};L.target.value.split(`
23
+ `).forEach(ce=>{const[Te,...tt]=ce.split("=");Te&&tt.length>0&&(Q[Te.trim()]=tt.join("=").trim())}),ke(ce=>({...ce,config:{...ce.config,env:Q}}))},placeholder:`API_KEY=xxx
24
+ DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[e.jsx(xe,{type:"button",variant:"outline",onClick:Ae,children:i("mcpForm.actions.cancel")}),e.jsx(xe,{type:"submit",disabled:mt||!ae.name||!((qa=ae.config)!=null&&qa.command),className:"bg-green-600 hover:bg-green-700 text-white",children:i(mt?"mcpForm.actions.saving":Be?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),J==="tasks"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(od,{})}),J==="api"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(ad,{})})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[v==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),v==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(xe,{variant:"outline",onClick:r,disabled:I,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),e.jsx(xe,{onClick:Bs,disabled:I,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:I?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),e.jsx(dl,{isOpen:pt,onClose:()=>kt(!1),provider:le,project:ue,onComplete:fr,isAuthenticated:le==="claude"?We.authenticated:le==="cursor"?Ze.authenticated:le==="codex"?Mt.authenticated:!1},le)]}):null}function kd({isOpen:t,onClose:r,releaseInfo:s,currentVersion:a,latestVersion:n}){const{t:o}=Ge("common"),[i,l]=c.useState(!1),[m,d]=c.useState(""),[u,g]=c.useState(""),p=c.useCallback(async()=>{l(!0),d(`Starting update...
25
+ `),g("");try{const x=await Ee("/api/system/update",{method:"POST"}),f=await x.json();x.ok?(d(h=>h+f.output+`
26
+ `),d(h=>h+`
27
+ ✅ Update completed successfully!
28
+ `),d(h=>h+`Please restart the server to apply changes.
29
+ `)):(g(f.error||"Update failed"),d(h=>h+`
30
+ ❌ Update failed: `+(f.error||"Unknown error")+`
31
+ `))}catch(x){g(x.message),d(f=>f+`
32
+ ❌ Update failed: `+x.message+`
33
+ `)}finally{l(!1)}},[]);return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:r,"aria-label":o("versionUpdate.ariaLabels.closeModal")}),e.jsxs("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-2xl mx-4 p-6 space-y-4 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/30 rounded-lg flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o("versionUpdate.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:(s==null?void 0:s.title)||o("versionUpdate.newVersionReady")})]})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 dark:bg-gray-700/50 rounded-lg",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:o("versionUpdate.currentVersion")}),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white font-mono",children:a})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-700",children:[e.jsx("span",{className:"text-sm font-medium text-blue-700 dark:text-blue-300",children:o("versionUpdate.latestVersion")}),e.jsx("span",{className:"text-sm text-blue-900 dark:text-blue-100 font-mono",children:n})]})]}),(s==null?void 0:s.body)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o("versionUpdate.whatsNew")}),(s==null?void 0:s.htmlUrl)&&e.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline flex items-center gap-1",children:[o("versionUpdate.viewFullRelease"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 border border-gray-200 dark:border-gray-600 max-h-64 overflow-y-auto",children:e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap prose prose-sm dark:prose-invert max-w-none",children:wd(s.body)})})]}),(m||u)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o("versionUpdate.updateProgress")}),e.jsx("div",{className:"bg-gray-900 dark:bg-gray-950 rounded-lg p-4 border border-gray-700 max-h-48 overflow-y-auto",children:e.jsx("pre",{className:"text-xs text-green-400 font-mono whitespace-pre-wrap",children:m})}),u&&e.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900/40 dark:bg-red-900/20 dark:text-red-200",children:u})]}),!i&&!m&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white",children:o("versionUpdate.manualUpgrade")}),e.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border",children:e.jsx("code",{className:"text-sm text-gray-800 dark:text-gray-200 font-mono",children:"git checkout main && git pull && npm install"})}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:o("versionUpdate.manualUpgradeHint")})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{onClick:r,className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:o(m?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!m&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{navigator.clipboard.writeText("git checkout main && git pull && npm install")},className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition-colors",children:o("versionUpdate.buttons.copyCommand")}),e.jsx("button",{onClick:p,disabled:i,className:"flex-1 px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 disabled:cursor-not-allowed rounded-md transition-colors flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),o("versionUpdate.buttons.updating")]}):o("versionUpdate.buttons.updateNow")})]})]})]})]}):null}const wd=t=>t?t.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
34
+
35
+ `).trim():"",jd=vd;function Nd(t){return e.jsx(jd,{...t})}function Cd({projects:t,showSettings:r,settingsInitialTab:s,onCloseSettings:a,showNewProject:n,onCloseNewProject:o,onProjectCreated:i,deleteConfirmation:l,onCancelDeleteProject:m,onConfirmDeleteProject:d,sessionDeleteConfirmation:u,onCancelDeleteSession:g,onConfirmDeleteSession:p,showVersionModal:x,onCloseVersionModal:f,releaseInfo:h,currentVersion:b,latestVersion:C,t:I}){const y=c.useMemo(()=>t.map(Yl),[t]);return e.jsxs(e.Fragment,{children:[n&&ss.createPortal(e.jsx(rd,{onClose:o,onProjectCreated:i}),document.body),r&&ss.createPortal(e.jsx(Nd,{isOpen:r,onClose:a,projects:y,initialTab:s}),document.body),l&&ss.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx(qt,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:I("deleteConfirmation.deleteProject")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[I("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:l.project.displayName||l.project.name}),"?"]}),l.sessionCount>0&&e.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:I("deleteConfirmation.sessionCount",{count:l.sessionCount})}),e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:I("deleteConfirmation.allConversationsDeleted")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:I("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(xe,{variant:"outline",className:"flex-1",onClick:m,children:I("actions.cancel")}),e.jsxs(xe,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:d,children:[e.jsx(ht,{className:"w-4 h-4 mr-2"}),I("actions.delete")]})]})]})}),document.body),u&&ss.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx(qt,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:I("deleteConfirmation.deleteSession")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[I("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:u.sessionTitle||I("sessions.unnamed")}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:I("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(xe,{variant:"outline",className:"flex-1",onClick:g,children:I("actions.cancel")}),e.jsxs(xe,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:p,children:[e.jsx(ht,{className:"w-4 h-4 mr-2"}),I("actions.delete")]})]})]})}),document.body),e.jsx(kd,{isOpen:x,onClose:f,releaseInfo:h,currentVersion:b,latestVersion:C})]})}function bn({projects:t,selectedProject:r,selectedSession:s,onProjectSelect:a,onSessionSelect:n,onNewSession:o,onSessionDelete:i,onProjectDelete:l,isLoading:m,loadingProgress:d,onRefresh:u,onShowSettings:g,showSettings:p,settingsInitialTab:x,onCloseSettings:f,isMobile:h}){const{t:b}=Ge(["sidebar","common"]),{isPWA:C}=Pa({trackMobile:!1}),{updateAvailable:I,latestVersion:y,currentVersion:v,releaseInfo:A}=So("thinqmesh","upfynai-code"),{preferences:M,setPreference:$}=_a(),{sidebarVisible:k}=M,{setCurrentProject:T,mcpServerStatus:W}=Ar(),{tasksEnabled:U}=Yr(),{isSidebarCollapsed:S,expandedProjects:H,editingProject:w,showNewProject:P,editingName:j,loadingSessions:F,initialSessionsLoaded:G,currentTime:X,isRefreshing:D,editingSession:oe,editingSessionName:E,searchFilter:se,deletingProjects:J,deleteConfirmation:B,sessionDeleteConfirmation:K,showVersionModal:V,filteredProjects:z,handleTouchClick:O,toggleProject:ne,handleSessionClick:me,toggleStarProject:q,isProjectStarred:N,getProjectSessions:_,startEditing:re,cancelEditing:te,saveProjectName:ve,showDeleteSessionConfirmation:je,confirmDeleteSession:Ne,requestProjectDelete:we,confirmDeleteProject:Ie,loadMoreSessions:Re,handleProjectSelect:Z,refreshProjects:ye,updateSessionSummary:Y,collapseSidebar:ie,expandSidebar:De,setShowNewProject:de,setEditingName:$e,setEditingSession:Le,setEditingSessionName:Je,setSearchFilter:Ve,setDeleteConfirmation:ge,setSessionDeleteConfirmation:Fe,setShowVersionModal:Ce}=Ql({projects:t,selectedProject:r,selectedSession:s,isLoading:m,isMobile:h,t:b,onRefresh:u,onProjectSelect:a,onSessionSelect:n,onSessionDelete:i,onProjectDelete:l,setCurrentProject:T,setSidebarVisible:_e=>$("sidebarVisible",_e),sidebarVisible:k});c.useEffect(()=>{typeof document>"u"||(document.documentElement.classList.toggle("pwa-mode",C),document.body.classList.toggle("pwa-mode",C))},[C]);const ze=()=>{if(window.refreshProjects){window.refreshProjects();return}window.location.reload()},Pe={projects:t,filteredProjects:z,selectedProject:r,selectedSession:s,isLoading:m,loadingProgress:d,expandedProjects:H,editingProject:w,editingName:j,loadingSessions:F,initialSessionsLoaded:G,currentTime:X,editingSession:oe,editingSessionName:E,deletingProjects:J,tasksEnabled:U,mcpServerStatus:W,getProjectSessions:_,isProjectStarred:N,onEditingNameChange:$e,onToggleProject:ne,onProjectSelect:Z,onToggleStarProject:q,onStartEditingProject:re,onCancelEditingProject:te,onSaveProjectName:_e=>{ve(_e)},onDeleteProject:we,onSessionSelect:me,onDeleteSession:je,onLoadMoreSessions:_e=>{Re(_e)},onNewSession:o,onEditingSessionNameChange:Je,onStartEditingSession:(_e,Ke)=>{Le(_e),Je(Ke)},onCancelEditingSession:()=>{Le(null),Je("")},onSaveEditingSession:(_e,Ke,ae)=>{Y(_e,Ke,ae)},touchHandlerFactory:O,t:b};return e.jsxs(e.Fragment,{children:[e.jsx(Cd,{projects:t,showSettings:p,settingsInitialTab:x,onCloseSettings:f,showNewProject:P,onCloseNewProject:()=>de(!1),onProjectCreated:ze,deleteConfirmation:B,onCancelDeleteProject:()=>ge(null),onConfirmDeleteProject:Ie,sessionDeleteConfirmation:K,onCancelDeleteSession:()=>Fe(null),onConfirmDeleteSession:Ne,showVersionModal:V,onCloseVersionModal:()=>Ce(!1),releaseInfo:A,currentVersion:v,latestVersion:y,t:b}),S?e.jsx(Xl,{onExpand:De,onShowSettings:g,updateAvailable:I,onShowVersionModal:()=>Ce(!0),t:b}):e.jsx(e.Fragment,{children:e.jsx(td,{isPWA:C,isMobile:h,isLoading:m,projects:t,searchFilter:se,onSearchFilterChange:Ve,onClearSearchFilter:()=>Ve(""),onRefresh:()=>{ye()},isRefreshing:D,onCreateProject:()=>de(!0),onCollapseSidebar:ie,updateAvailable:I,releaseInfo:A,latestVersion:y,onShowVersionModal:()=>Ce(!0),onShowSettings:g,projectListProps:Pe,t:b})})]})}function Sd(){const{isDarkMode:t,toggleDarkMode:r}=Ia();return e.jsxs("button",{onClick:r,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const Ed=()=>{const{t}=Ge("settings"),[r,s]=c.useState(!1),[a,n]=c.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:o}=Ia(),{isMobile:i}=Pa({trackPWA:!1}),{preferences:l,setPreference:m}=_a(),{autoExpandTools:d,showRawParameters:u,showThinking:g,autoScrollToBottom:p,sendByCtrlEnter:x}=l,[f,h]=c.useState(()=>{const j=localStorage.getItem("quickSettingsHandlePosition");if(j)try{return JSON.parse(j).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[b,C]=c.useState(!1),[I,y]=c.useState(0),[v,A]=c.useState(0),[M,$]=c.useState(!1),k=c.useRef(null),T=c.useRef({min:10,max:90}),W=5;c.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:f}))},[f]);const U=c.useCallback(()=>i?{bottom:`${window.innerHeight*f/100}px`}:{top:`${f}%`,transform:"translateY(-50%)"},[f,i]),S=c.useCallback(j=>{j.stopPropagation();const F=j.type.includes("touch")?j.touches[0].clientY:j.clientY;y(F),A(f),$(!1),C(!1)},[f]),H=c.useCallback(j=>{if(I===0)return;const F=j.type.includes("touch")?j.touches[0].clientY:j.clientY,G=Math.abs(F-I);if(!b&&G>W&&(C(!0),$(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",j.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!b)return;j.type.includes("touch")&&j.preventDefault();const X=F-I;let D;i?D=-(X/window.innerHeight)*100:D=X/window.innerHeight*100;let oe=v+D;oe=Math.max(T.current.min,Math.min(T.current.max,oe)),h(oe)},[b,I,v,i,W]),w=c.useCallback(()=>{C(!1),y(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);c.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),c.useEffect(()=>{if(I!==0){const j=D=>H(D),F=()=>w(),G=D=>H(D),X=()=>w();return document.addEventListener("mousemove",j),document.addEventListener("mouseup",F),document.addEventListener("touchmove",G,{passive:!1}),document.addEventListener("touchend",X),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",F),document.removeEventListener("touchmove",G),document.removeEventListener("touchend",X)}}},[I,H,w]);const P=j=>{if(M){j.preventDefault(),$(!1);return}s(F=>!F)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:k,onClick:P,onMouseDown:j=>{S(j)},onTouchStart:j=>{S(j)},className:`fixed ${r?"right-64":"right-0"} z-50 ${b?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${b?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${b?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...U(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":t(b?"quickSettings.dragHandle.dragging":r?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:t(b?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:b?e.jsx(Pi,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):r?e.jsx(Ot,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(mo,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${r?"translate-x-0":"translate-x-full"} ${i?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(_i,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),t("quickSettings.title")]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${i?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.appearance")}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[o?e.jsx(oa,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(ia,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.darkMode")]}),e.jsx(Sd,{})]}),e.jsx("div",{children:e.jsx(Go,{compact:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.toolDisplay")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(Ma,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoExpandTools")]}),e.jsx("input",{type:"checkbox",checked:d,onChange:j=>m("autoExpandTools",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ur,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showRawParameters")]}),e.jsx("input",{type:"checkbox",checked:u,onChange:j=>m("showRawParameters",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx($s,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showThinking")]}),e.jsx("input",{type:"checkbox",checked:g,onChange:j=>m("showThinking",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.viewOptions")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(xo,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoScrollToBottom")]}),e.jsx("input",{type:"checkbox",checked:p,onChange:j=>m("autoScrollToBottom",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.inputSettings")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(po,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.sendByCtrlEnter")]}),e.jsx("input",{type:"checkbox",checked:x,onChange:j=>m("sendByCtrlEnter",j.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:t("quickSettings.sendByCtrlEnterDescription")})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.whisperDictation")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:a==="default",onChange:()=>{n("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(gs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.default")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.defaultDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:a==="prompt",onChange:()=>{n("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Ht,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.prompt")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.promptDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:a==="vibe"||a==="instructions"||a==="architect",onChange:()=>{n("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(it,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.vibe")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),r&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:P})]})};function _t(t){return t&&t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function Td(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function is(t){if(!t||typeof t!="string")return t;const r=[],s="__MATH_BLOCK_",a="__";let n=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,o=>{const i=r.length;return r.push(o),`${s}${i}${a}`});return n=n.replace(/\\n/g,`
36
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${s}(\\d+)${a}`,"g"),(o,i)=>r[parseInt(i,10)]),n}function qo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function xa(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,s)=>{let a=parseInt(s,10);if(!Number.isFinite(a))return r;a<1e12&&(a*=1e3);const n=new Date(a),o=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),l=i>=0?"+":"-",m=Math.abs(i),d=Math.floor(m/60),u=m%60,g=`GMT${l}${d}${u?":"+String(u).padStart(2,"0"):""}`,f=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,I=>I.toUpperCase()),h=f?`${g} (${f})`:g,b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],C=`${n.getDate()} ${b[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${o} ${h}** - ${C}`})}catch{return t}}const Id=({node:t,inline:r,className:s,children:a,...n})=>{const{t:o}=Ge("chat"),[i,l]=c.useState(!1),m=Array.isArray(a)?a.join(""):String(a??""),d=/[\r\n]/.test(m);if(r||t&&t.type==="inlineCode"||!d)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${s||""}`,...n,children:a});const p=/language-(\w+)/.exec(s||""),x=p?p[1]:"text",f=m,h=()=>{const b=()=>{l(!0),setTimeout(()=>l(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(f).then(b).catch(()=>{const C=document.createElement("textarea");C.value=f,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy")}catch{}document.body.removeChild(C),b()});else{const C=document.createElement("textarea");C.value=f,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy")}catch{}document.body.removeChild(C),b()}}catch{}};return e.jsxs("div",{className:"relative group my-2",children:[x&&x!=="text"&&e.jsx("div",{className:"absolute top-2 left-3 z-10 text-xs text-gray-400 font-medium uppercase",children:x}),e.jsx("button",{type:"button",onClick:h,className:"absolute top-2 right-2 z-10 opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-1 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:o(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":o(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),o("codeBlock.copied")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),o("codeBlock.copy")]})}),e.jsx(ul,{language:x,style:pl,customStyle:{margin:0,borderRadius:"0.5rem",fontSize:"0.875rem",padding:x&&x!=="text"?"2rem 1rem 1rem 1rem":"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:m})]})},Ad={code:Id,blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})};function Ur({children:t,className:r}){const s=Td(String(t??"")),a=c.useMemo(()=>[xl,gl],[]),n=c.useMemo(()=>[hl],[]);return e.jsx("div",{className:r,children:e.jsx(fl,{remarkPlugins:a,rehypePlugins:n,components:Ad,children:s})})}const Ko="claude-settings",gt={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const s=JSON.parse(r);if(Array.isArray(s)&&s.length>50){const a=s.slice(-50);r=JSON.stringify(a)}}catch(s){console.warn("Could not parse chat messages for truncation:",s)}localStorage.setItem(t,r)}catch(s){if((s==null?void 0:s.name)==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const a=Object.keys(localStorage),n=a.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i)}),a.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const l=JSON.parse(r);if(Array.isArray(l)&&l.length>10){const m=l.slice(-10);localStorage.setItem(t,JSON.stringify(m))}}catch(l){console.error("Final save attempt failed:",l)}}}else console.error("localStorage error:",s)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}};function Ba(){const t=gt.getItem(Ko);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function ga(t,r){if(!t)return null;if(t!=="Bash")return t;const s=Wc(r),a=typeof(s==null?void 0:s.command)=="string"?s.command.trim():"";if(!a)return t;const n=a.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function yn(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Dd(t,r){var i;if(r!=="claude"||!((i=t==null?void 0:t.toolResult)!=null&&i.isError))return null;const s=t==null?void 0:t.toolName,a=ga(s,t.toolInput);if(!a)return null;const o=Ba().allowedTools.includes(a);return{toolName:s||"UnknownTool",entry:a,isAllowed:o}}function Md(t){if(!t)return{success:!1};const r=Ba(),s=r.allowedTools.includes(t),a=s?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),o={...r,allowedTools:a,disallowedTools:n,lastUpdated:new Date().toISOString()};return gt.setItem(Ko,JSON.stringify(o)),{success:!0,alreadyAllowed:s,updatedSettings:o}}const vn={Bash:{input:{type:"one-line",icon:"terminal",getValue:t=>t.command,getSecondary:t=>t.description,action:"copy",style:"terminal",wrapText:!0,colorScheme:{primary:"text-green-400 font-mono",secondary:"text-gray-400",background:"",border:"border-green-500 dark:border-green-400",icon:"text-green-500 dark:text-green-400"}},result:{hideOnSuccess:!0,type:"special"}},Read:{input:{type:"one-line",label:"Read",getValue:t=>t.file_path||"",action:"open-file",colorScheme:{primary:"text-gray-700 dark:text-gray-300",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"}},result:{hidden:!0}},Edit:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Edit",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Write:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:"",newContent:t.content,filePath:t.file_path,badge:"New",badgeColor:"green"})},result:{hideOnSuccess:!0}},ApplyPatch:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Patch",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Grep:{input:{type:"one-line",label:"Grep",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},Glob:{input:{type:"one-line",label:"Glob",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},TodoWrite:{input:{type:"collapsible",title:"Updating todo list",defaultOpen:!1,contentType:"todo-list",getContentProps:t=>({todos:t.todos})},result:{type:"collapsible",contentType:"success-message",getMessage:()=>"Todo list updated"}},TodoRead:{input:{type:"one-line",label:"TodoRead",getValue:()=>"reading list",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500"}},result:{type:"collapsible",contentType:"todo-list",getContentProps:t=>{try{const r=String(t.content||"");let s=null;return r.startsWith("[")&&(s=JSON.parse(r)),{todos:s,isResult:!0}}catch{return{todos:[],isResult:!0}}}}},TaskCreate:{input:{type:"one-line",label:"Task",getValue:t=>t.subject||"Creating task",getSecondary:t=>t.status||void 0,action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskUpdate:{input:{type:"one-line",label:"Task",getValue:t=>{const r=[];return t.taskId&&r.push(`#${t.taskId}`),t.status&&r.push(t.status),t.subject&&r.push(`"${t.subject}"`),r.join(" → ")||"updating"},action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskList:{input:{type:"one-line",label:"Tasks",getValue:()=>"listing tasks",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task list",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},TaskGet:{input:{type:"one-line",label:"Task",getValue:t=>t.taskId?`#${t.taskId}`:"fetching",action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task details",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},Task:{input:{type:"collapsible",title:t=>{const r=t.subagent_type||"Agent",s=t.description||"Running task";return`Subagent / ${r}: ${s}`},defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t.prompt&&!t.model&&!t.resume)return{content:t.prompt||""};const s=[];return t.model&&s.push(`**Model:** ${t.model}`),t.prompt&&s.push(`**Prompt:**
37
+ ${t.prompt}`),t.resume&&s.push(`**Resuming from:** ${t.resume}`),{content:s.join(`
38
+
39
+ `)}},colorScheme:{border:"border-purple-500 dark:border-purple-400",icon:"text-purple-500 dark:text-purple-400"}},result:{type:"collapsible",title:"Subagent result",defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t&&t.content){let r=t.content;if(typeof r=="string")try{const s=JSON.parse(r);Array.isArray(s)&&(r=s)}catch{return{content:r}}return Array.isArray(r)?{content:r.filter(a=>a.type==="text").map(a=>a.text).join(`
40
+
41
+ `)||"No response text"}:{content:String(r)}}return{content:String(t||"No response")}}}},AskUserQuestion:{input:{type:"collapsible",title:t=>{var a,n;const r=((a=t.questions)==null?void 0:a.length)||0,s=t.answers&&Object.keys(t.answers).length>0;if(r===1){const o=((n=t.questions[0])==null?void 0:n.header)||"Question";return s?`${o} — answered`:o}return s?`${r} questions — answered`:`${r} questions`},defaultOpen:!0,contentType:"question-answer",getContentProps:t=>({questions:t.questions||[],answers:t.answers||{}})},result:{hideOnSuccess:!0}},exit_plan_mode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>{var r;return{content:((r=t.plan)==null?void 0:r.replace(/\\n/g,`
42
+ `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
43
+ `))||s.plan}}catch{return{content:""}}}}},ExitPlanMode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>{var r;return{content:((r=t.plan)==null?void 0:r.replace(/\\n/g,`
44
+ `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
45
+ `))||s.plan}}catch{return{content:""}}}}},Default:{input:{type:"collapsible",title:"Parameters",defaultOpen:!1,contentType:"text",getContentProps:t=>({content:typeof t=="string"?t:JSON.stringify(t,null,2),format:"code"})},result:{type:"collapsible",contentType:"text",getContentProps:t=>({content:String((t==null?void 0:t.content)||""),format:"plain"})}}};function Vo(t){return vn[t]||vn.Default}function $d(t,r){const s=Vo(t);return s.result?!!(s.result.hidden||s.result.hideOnSuccess&&r&&!r.isError):!1}const Jo=({title:t,toolName:r,open:s=!1,action:a,onTitleClick:n,children:o,className:i=""})=>e.jsxs("details",{className:`relative group/details ${i}`,open:s,children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-xs cursor-pointer py-0.5 select-none group-open/details:sticky group-open/details:top-0 group-open/details:z-10 group-open/details:bg-background group-open/details:-mx-1 group-open/details:px-1",children:[e.jsx("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open/details:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r&&e.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-400 flex-shrink-0",children:r}),r&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] flex-shrink-0",children:"/"}),n?e.jsx("button",{onClick:l=>{l.preventDefault(),l.stopPropagation(),n()},className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline truncate flex-1 text-left transition-colors",children:t}):e.jsx("span",{className:"text-gray-600 dark:text-gray-400 truncate flex-1",children:t}),a&&e.jsx("span",{className:"flex-shrink-0 ml-1",children:a})]}),e.jsx("div",{className:"mt-1.5 pl-[18px]",children:o})]}),Ld=({oldContent:t,newContent:r,filePath:s,createDiff:a,onFileClick:n,badge:o="Diff",badgeColor:i="gray"})=>{const l=i==="green"?"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400",m=c.useMemo(()=>a(t,r),[a,t,r]);return e.jsxs("div",{className:"border border-gray-200/60 dark:border-gray-700/50 rounded overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1 bg-gray-50/80 dark:bg-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/50",children:[n?e.jsx("button",{onClick:n,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer transition-colors",children:s}):e.jsx("span",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 truncate",children:s}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded ${l} flex-shrink-0 ml-2`,children:o})]}),e.jsx("div",{className:"text-[11px] font-mono leading-[18px]",children:m.map((d,u)=>e.jsxs("div",{className:"flex",children:[e.jsx("span",{className:`w-6 text-center select-none flex-shrink-0 ${d.type==="removed"?"bg-red-50 dark:bg-red-950/30 text-red-400 dark:text-red-500":"bg-green-50 dark:bg-green-950/30 text-green-400 dark:text-green-500"}`,children:d.type==="removed"?"-":"+"}),e.jsx("span",{className:`px-2 flex-1 whitespace-pre-wrap ${d.type==="removed"?"bg-red-50/50 dark:bg-red-950/20 text-red-800 dark:text-red-200":"bg-green-50/50 dark:bg-green-950/20 text-green-800 dark:text-green-200"}`,children:d.content})]},u))})]})},Fd=t=>{if(typeof document>"u"||!document.body)return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",document.body.appendChild(r),r.select(),r.setSelectionRange(0,t.length);let s=!1;try{s=document.execCommand("copy")}catch{s=!1}finally{document.body.removeChild(r)}return s},Pd=async t=>{var r;if(typeof navigator<"u"&&typeof window<"u"&&window.isSecureContext&&((r=navigator.clipboard)!=null&&r.writeText))try{return await navigator.clipboard.writeText(t),!0}catch{}return Fd(t)},_d=({toolName:t,icon:r,label:s,value:a,secondary:n,action:o="none",onAction:i,style:l,wrapText:m=!1,colorScheme:d={primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"},resultId:u,toolResult:g,toolId:p})=>{const[x,f]=c.useState(!1),h=l==="terminal",b=async()=>{if(o==="copy"&&a){if(!await Pd(a))return;f(!0),setTimeout(()=>f(!1),2e3)}else i&&i()},C=()=>e.jsx("button",{onClick:b,className:"opacity-0 group-hover:opacity-100 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-all ml-1 flex-shrink-0",title:"Copy to clipboard","aria-label":"Copy to clipboard",children:x?e.jsx("svg",{className:"w-3 h-3 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})});if(h)return e.jsxs("div",{className:"group my-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0 pt-0.5",children:e.jsx("svg",{className:"w-3 h-3 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[e.jsx("div",{className:"bg-gray-900 dark:bg-black rounded px-2.5 py-1 flex-1 min-w-0",children:e.jsxs("code",{className:`text-xs text-green-400 font-mono ${m?"whitespace-pre-wrap break-all":"block truncate"}`,children:[e.jsx("span",{className:"text-green-600 dark:text-green-500 select-none",children:"$ "}),a]})}),o==="copy"&&C()]})]}),n&&e.jsx("div",{className:"ml-7 mt-1",children:e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:n})})]});if(o==="open-file"){const I=a.split("/").pop()||a;return e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("button",{onClick:b,className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline transition-colors truncate",title:a,children:I})]})}return o==="jump-to-results"?e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono truncate flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic flex-shrink-0",children:n}),g&&e.jsx("a",{href:`#tool-result-${p}`,className:"flex-shrink-0 text-[11px] text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors flex items-center gap-0.5",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}):e.jsxs("div",{className:`group flex items-center gap-1.5 ${d.background||""} border-l-2 ${d.border} pl-3 py-0.5 my-0.5`,children:[r&&r!=="terminal"&&e.jsx("span",{className:`${d.icon} flex-shrink-0 text-xs`,children:r}),!r&&(s||t)&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),(r||s||t)&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono ${m?"whitespace-pre-wrap break-all":"truncate"} flex-1 min-w-0 ${d.primary}`,children:a}),n&&e.jsx("span",{className:`text-[11px] ${d.secondary} italic flex-shrink-0`,children:n}),o==="copy"&&C()]})},kn={edit:"border-l-amber-500 dark:border-l-amber-400",search:"border-l-gray-400 dark:border-l-gray-500",bash:"border-l-green-500 dark:border-l-green-400",todo:"border-l-violet-500 dark:border-l-violet-400",task:"border-l-violet-500 dark:border-l-violet-400",agent:"border-l-purple-500 dark:border-l-purple-400",plan:"border-l-indigo-500 dark:border-l-indigo-400",question:"border-l-blue-500 dark:border-l-blue-400",default:"border-l-gray-300 dark:border-l-gray-600"},zd=({toolName:t,title:r,defaultOpen:s=!1,action:a,onTitleClick:n,children:o,showRawParameters:i=!1,rawContent:l,className:m="",toolCategory:d})=>{const u=kn[d||"default"]||kn.default;return e.jsx("div",{className:`border-l-2 ${u} pl-3 py-0.5 my-1 ${m}`,children:e.jsxs(Jo,{title:r,toolName:t,open:s,action:a,onTitleClick:n,children:[o,i&&l&&e.jsxs("details",{className:"relative mt-2 group/raw",children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-[11px] text-gray-400 dark:text-gray-500 cursor-pointer hover:text-gray-600 dark:hover:text-gray-300 py-0.5",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/raw:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),e.jsx("pre",{className:"mt-1 text-[11px] bg-gray-50 dark:bg-gray-900/50 border border-gray-200/40 dark:border-gray-700/40 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-600 dark:text-gray-400 font-mono",children:l})]})]})})},ls=(t,r)=>{var a;const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(t){case"Read":case"Write":case"Edit":case"ApplyPatch":return((a=s.file_path)==null?void 0:a.split("/").pop())||s.file_path||"";case"Grep":case"Glob":return s.pattern||"";case"Bash":const n=s.command||"";return n.length>40?`${n.slice(0,40)}...`:n;case"Task":return s.description||s.subagent_type||"";case"WebFetch":case"WebSearch":return s.url||s.query||"";default:return""}},Od=({toolInput:t,toolResult:r,subagentState:s})=>{const a=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return{}}})():t||{},n=(a==null?void 0:a.subagent_type)||"Agent",o=(a==null?void 0:a.description)||"Running task",i=(a==null?void 0:a.prompt)||"",{childTools:l,currentToolIndex:m,isComplete:d}=s,u=m>=0?l[m]:null,g=`Subagent / ${n}: ${o}`;return e.jsx("div",{className:"border-l-2 border-l-purple-500 dark:border-l-purple-400 pl-3 py-0.5 my-1",children:e.jsxs(Jo,{title:g,toolName:"Task",open:!1,children:[i&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2 whitespace-pre-wrap break-words line-clamp-4",children:i}),u&&!d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-1",children:[e.jsx("span",{className:"animate-pulse w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Currently:"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:u.toolName}),ls(u.toolName,u.toolInput)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"/"}),e.jsx("span",{className:"font-mono truncate text-gray-500 dark:text-gray-400",children:ls(u.toolName,u.toolInput)})]})]}),d&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400 mt-1",children:[e.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsxs("span",{children:["Completed (",l.length," ",l.length===1?"tool":"tools",")"]})]}),l.length>0&&e.jsxs("details",{className:"mt-2 group/history",children:[e.jsxs("summary",{className:"cursor-pointer text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/history:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsxs("span",{children:["View tool history (",l.length,")"]})]}),e.jsx("div",{className:"mt-1 pl-3 border-l border-gray-200 dark:border-gray-700 space-y-0.5",children:l.map((p,x)=>{var f;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 w-4 text-right flex-shrink-0",children:[x+1,"."]}),e.jsx("span",{className:"font-medium",children:p.toolName}),ls(p.toolName,p.toolInput)&&e.jsx("span",{className:"font-mono truncate text-gray-400 dark:text-gray-500",children:ls(p.toolName,p.toolInput)}),((f=p.toolResult)==null?void 0:f.isError)&&e.jsx("span",{className:"text-red-500 flex-shrink-0",children:"(error)"})]},p.toolId)})})]}),d&&r&&e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:(()=>{let p=r.content;if(typeof p=="string")try{const x=JSON.parse(p);if(Array.isArray(x)){const f=x.filter(h=>h.type==="text"&&h.text).map(h=>h.text);f.length>0&&(p=f.join(`
46
+ `))}}catch{}else if(Array.isArray(p)){const x=p.filter(f=>f.type==="text"&&f.text).map(f=>f.text);x.length>0&&(p=x.join(`
47
+ `))}return typeof p=="string"?e.jsx("div",{className:"whitespace-pre-wrap break-words line-clamp-6",children:p}):p?e.jsx("pre",{className:"whitespace-pre-wrap break-words line-clamp-6 font-mono text-[11px]",children:JSON.stringify(p,null,2)}):null})()})]})})},Rd=({content:t,className:r="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>e.jsx(Ur,{className:r,children:t}),Bd=({files:t,onFileClick:r,title:s})=>e.jsxs("div",{children:[s&&e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mb-1",children:s}),e.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5 max-h-48 overflow-y-auto",children:t.map((a,n)=>{const o=typeof a=="string"?a:a.path,i=o.split("/").pop()||o,l=typeof a=="string"?()=>r==null?void 0:r(a):a.onClick;return e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("button",{onClick:l,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline transition-colors",title:o,children:i}),n<t.length-1&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] ml-1",children:","})]},n)})})]}),Wd=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const s=o=>{switch(o){case"completed":return e.jsx(zi,{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(qr,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(Cr,{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500"})}},a=o=>{switch(o){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},n=o=>{switch(o){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-1.5",children:[r&&e.jsxs("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1.5",children:["Todo List (",t.length," ",t.length===1?"item":"items",")"]}),t.map((o,i)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s(o.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:`text-xs font-medium ${o.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:o.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(Dt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${n(o.priority)}`,children:o.priority}),e.jsx(Dt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${a(o.status)}`,children:o.status.replace("_"," ")})]})]})})]},o.id||`todo-${i}`))]})},Ud=({todos:t,isResult:r=!1})=>e.jsx(Wd,{todos:t,isResult:r});function Hd(t){const r=[],s=t.split(`
48
+ `);for(const a of s){const n=a.match(/#(\d+)\.?\s*(?:\[(\w+)\]\s*)?(.+?)(?:\s*\((?:owner:\s*\w+)?\))?$/);if(n){const[,o,i,l]=n,m=a.match(/blockedBy:\s*\[([^\]]*)\]/);r.push({id:o,subject:l.trim(),status:i||"pending",blockedBy:m?m[1].split(",").map(d=>d.trim()).filter(Boolean):void 0})}}return r}const wn={completed:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"line-through text-gray-400 dark:text-gray-500",badgeClass:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800"},in_progress:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"text-gray-900 dark:text-gray-100",badgeClass:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800"},pending:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})}),textClass:"text-gray-700 dark:text-gray-300",badgeClass:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},Gd=({content:t})=>{const r=Hd(t);if(r.length===0)return e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:t});const s=r.filter(n=>n.status==="completed").length,a=r.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[s,"/",a," completed"]}),e.jsx("div",{className:"flex-1 h-1 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 dark:bg-green-400 rounded-full transition-all",style:{width:`${a>0?s/a*100:0}%`}})})]}),e.jsx("div",{className:"space-y-px",children:r.map(n=>{const o=wn[n.status]||wn.pending;return e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 group",children:[e.jsx("span",{className:"flex-shrink-0",children:o.icon}),e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:["#",n.id]}),e.jsx("span",{className:`text-xs truncate flex-1 ${o.textClass}`,children:n.subject}),e.jsx("span",{className:`text-[10px] px-1 py-px rounded border flex-shrink-0 ${o.badgeClass}`,children:n.status.replace("_"," ")})]},n.id)})})]})},qd=({content:t,format:r="plain",className:s=""})=>{if(r==="json"){let a=t;try{const n=JSON.parse(t);a=JSON.stringify(n,null,2)}catch{}return e.jsx("pre",{className:`mt-1 text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 p-2.5 rounded overflow-x-auto font-mono ${s}`,children:a})}return r==="code"?e.jsx("pre",{className:`mt-1 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/50 dark:border-gray-700/50 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono ${s}`,children:t}):e.jsx("div",{className:`mt-1 text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap ${s}`,children:t})},Kd=({questions:t,answers:r,className:s=""})=>{const[a,n]=c.useState(null);if(!t||t.length===0)return null;const o=Object.keys(r||{}).length>0,i=t.length;return e.jsxs("div",{className:`space-y-2 ${s}`,children:[t.map((l,m)=>{const d=r==null?void 0:r[l.question],u=d?d.split(", "):[],g=!d,p=a===m;return e.jsxs("div",{className:"rounded-lg border border-gray-150 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/30 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(p?null:m),className:"w-full text-left px-3 py-2 flex items-start gap-2.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${u.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:u.length>0?e.jsx("svg",{className:"w-2.5 h-2.5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100/80 dark:border-blue-800/40",children:l.header}),i>1&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[m+1,"/",i]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 leading-snug",children:l.question}),!p&&u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:u.map(x=>{const f=!l.options.some(h=>h.label===x);return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded-md bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium",children:[x,f&&e.jsx("span",{className:"text-[9px] text-blue-400 dark:text-blue-500 font-normal",children:"(custom)"})]},x)})}),!p&&g&&o&&e.jsx("span",{className:"inline-block mt-1 text-[10px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]}),e.jsx("svg",{className:`w-3.5 h-3.5 mt-0.5 text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform duration-200 ${p?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),p&&e.jsx("div",{className:"px-3 pb-2.5 pt-0.5 border-t border-gray-100 dark:border-gray-700/40",children:e.jsxs("div",{className:"space-y-1 ml-6.5",children:[l.options.map(x=>{const f=u.includes(x.label);return e.jsxs("div",{className:`flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] ${f?"bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40":"text-gray-400 dark:text-gray-500"}`,children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${l.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] flex items-center justify-center ${f?"border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500":"border-gray-300 dark:border-gray-600"}`,children:f&&e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:f?"text-gray-900 dark:text-gray-100 font-medium":"",children:x.label}),x.description&&e.jsx("span",{className:`block text-[11px] mt-0.5 ${f?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-600"}`,children:x.description})]})]},x.label)}),u.filter(x=>!l.options.some(f=>f.label===x)).map(x=>e.jsxs("div",{className:"flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${l.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500 flex items-center justify-center`,children:e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:x}),e.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 ml-1",children:"(custom)"})]})]},x)),g&&o&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic px-2.5 py-1",children:"No answer provided"})]})})]},m)}),!o&&i===1&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]})},Vd=({request:t,onDecision:r})=>{const s=t.input,a=(s==null?void 0:s.questions)||[],[n,o]=c.useState(0),[i,l]=c.useState(()=>new Map),[m,d]=c.useState(()=>new Map),[u,g]=c.useState(()=>new Map),[p,x]=c.useState(!1),f=c.useRef(null),h=c.useRef(null);c.useEffect(()=>{requestAnimationFrame(()=>x(!0))},[]),c.useEffect(()=>{var j;u.get(n)||(j=f.current)==null||j.focus()},[n,u]),c.useEffect(()=>{var j;u.get(n)&&((j=h.current)==null||j.focus())},[u,n]);const b=c.useCallback((j,F,G)=>{l(X=>{const D=new Map(X),oe=new Set(D.get(j)||[]);return G?oe.has(F)?oe.delete(F):oe.add(F):(oe.clear(),oe.add(F),g(E=>{const se=new Map(E);return se.set(j,!1),se})),D.set(j,oe),D})},[]),C=c.useCallback((j,F)=>{g(G=>{const X=new Map(G),D=X.get(j)||!1;return X.set(j,!D),!F&&!D&&l(oe=>{const E=new Map(oe);return E.set(j,new Set),E}),X})},[]),I=c.useCallback((j,F)=>{d(G=>{const X=new Map(G);return X.set(j,F),X})},[]),y=c.useCallback(()=>{const j={};return a.forEach((F,G)=>{const X=Array.from(i.get(G)||[]),D=u.get(G)||!1,oe=(m.get(G)||"").trim();D&&oe&&X.push(oe),X.length>0&&(j[F.question]=X.join(", "))}),j},[a,i,u,m]),v=c.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:y()}})},[r,t.requestId,s,y]),A=c.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:{}}})},[r,t.requestId,s]),M=c.useCallback(j=>{if(j.target instanceof HTMLInputElement)return;const F=a[n];if(!F)return;const G=F.multiSelect||!1,X=F.options.length,D=parseInt(j.key);if(!isNaN(D)&&D>=1&&D<=X){j.preventDefault(),b(n,F.options[D-1].label,G);return}if(j.key==="0"){j.preventDefault(),C(n,G);return}if(j.key==="Enter"){j.preventDefault(),n===a.length-1?v():o(E=>E+1);return}if(j.key==="Escape"){j.preventDefault(),A();return}},[n,a,b,C,v,A]);if(a.length===0)return null;const $=a.length,k=$===1,T=a[n],W=T.multiSelect||!1,U=i.get(n)||new Set,S=u.get(n)||!1,H=n===$-1,w=n===0,P=U.size>0||S&&(m.get(n)||"").trim().length>0;return e.jsx("div",{ref:f,tabIndex:-1,onKeyDown:M,className:`w-full outline-none transition-all duration-500 ease-out ${p?"opacity-100 translate-y-0":"opacity-0 translate-y-3"}`,children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-gray-700/50 bg-white dark:bg-gray-800/90 shadow-lg dark:shadow-2xl",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-cyan-400 to-teal-400"}),e.jsxs("div",{className:"px-4 pt-3.5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-500/10 dark:from-blue-400/15 dark:to-cyan-400/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.75,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827m0 3h.01"})})}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-cyan-400 dark:bg-cyan-500 animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[10px] font-medium tracking-wide uppercase text-gray-400 dark:text-gray-500",children:"Claude needs your input"}),T.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-px rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-800/50",children:T.header})]}),!k&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500 flex-shrink-0",children:[n+1,"/",$]})]}),!k&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.map((j,F)=>e.jsx("button",{type:"button",onClick:()=>o(F),className:`h-[3px] rounded-full transition-all duration-300 ${F===n?"w-5 bg-blue-500 dark:bg-blue-400":F<n?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},F))}),e.jsx("p",{className:"text-[14px] leading-snug font-medium text-gray-900 dark:text-gray-100",children:T.question}),W&&e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:"Select all that apply"})]}),e.jsx("div",{className:"px-4 pb-2 max-h-48 overflow-y-auto scrollbar-thin",role:W?"group":"radiogroup","aria-label":T.question,children:e.jsxs("div",{className:"space-y-1",children:[T.options.map((j,F)=>{const G=U.has(j.label);return e.jsxs("button",{type:"button",onClick:()=>b(n,j.label,W),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${G?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${G?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:F+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${G?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300"}`,children:j.label}),j.description&&e.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${G?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:j.description})]}),G&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},j.label)}),e.jsxs("button",{type:"button",onClick:()=>C(n,W),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${S?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-dashed border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${S?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:"0"}),e.jsx("span",{className:`text-[13px] leading-tight transition-colors ${S?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-500 dark:text-gray-400"}`,children:"Other..."}),S&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]}),S&&e.jsx("div",{className:"pl-[30px] pr-0.5",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:h,type:"text",value:m.get(n)||"",onChange:j=>I(n,j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),H?v():o(F=>F+1)),j.stopPropagation()},placeholder:"Type your answer...",className:"w-full text-[13px] rounded-lg border-0 bg-gray-50 dark:bg-gray-900/60 text-gray-900 dark:text-gray-100 px-3 py-1.5 outline-none ring-1 ring-gray-200 dark:ring-gray-700 focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 placeholder:text-gray-400 dark:placeholder:text-gray-600 transition-shadow duration-200"}),e.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[9px] font-mono text-gray-300 dark:text-gray-600 bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:"Enter"})]})})]})}),e.jsxs("div",{className:"px-4 py-2 border-t border-gray-100 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/50 flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:A,className:"text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:[k?"Skip":"Skip all",e.jsx("span",{className:"ml-1 text-[9px] text-gray-300 dark:text-gray-600",children:"Esc"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[!k&&!w&&e.jsxs("button",{type:"button",onClick:()=>o(j=>j-1),className:"inline-flex items-center gap-0.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-all duration-150",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),H?e.jsxs("button",{type:"button",onClick:v,disabled:!P&&!Object.keys(y()).length,className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-all duration-200",children:["Submit",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]}):e.jsxs("button",{type:"button",onClick:()=>o(j=>j+1),className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md transition-all duration-200",children:["Next",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]})]})]})]})})};function Jd(t){return["Edit","Write","ApplyPatch"].includes(t)?"edit":["Grep","Glob"].includes(t)?"search":t==="Bash"?"bash":["TodoWrite","TodoRead"].includes(t)?"todo":["TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(t)?"task":t==="Task"?"agent":t==="exit_plan_mode"||t==="ExitPlanMode"?"plan":t==="AskUserQuestion"?"question":"default"}const ha=c.memo(({toolName:t,toolInput:r,toolResult:s,toolId:a,mode:n,onFileOpen:o,createDiff:i,selectedProject:l,autoExpandTools:m=!1,showRawParameters:d=!1,rawToolInput:u,isSubagentContainer:g,subagentState:p})=>{var C,I,y,v,A;if(g&&p)return n==="result"?null:e.jsx(Od,{toolInput:r,toolResult:s,subagentState:p});const x=Vo(t),f=n==="input"?x.input:x.result,h=c.useMemo(()=>{try{const M=n==="input"?r:s;return typeof M=="string"?JSON.parse(M):M}catch{return n==="input"?r:s}},[n,r,s]),b=c.useCallback(()=>{var M;if((f==null?void 0:f.action)==="open-file"&&o){const $=((M=f.getValue)==null?void 0:M.call(f,h))||"";o($)}},[f,h,o]);if(!f)return null;if(f.type==="one-line"){const M=((C=f.getValue)==null?void 0:C.call(f,h))||"",$=(I=f.getSecondary)==null?void 0:I.call(f,h);return e.jsx(_d,{toolName:t,toolResult:s,toolId:a,icon:f.icon,label:f.label,value:M,secondary:$,action:f.action,onAction:b,style:f.style,wrapText:f.wrapText,colorScheme:f.colorScheme,resultId:n==="input"?`tool-result-${a}`:void 0})}if(f.type==="collapsible"){const M=typeof f.title=="function"?f.title(h):f.title||"Details",$=f.defaultOpen!==void 0?f.defaultOpen:m,k=((y=f.getContentProps)==null?void 0:y.call(f,h,{selectedProject:l,createDiff:i,onFileOpen:o}))||{};let T=null;switch(f.contentType){case"diff":i&&(T=e.jsx(Ld,{...k,createDiff:i,onFileClick:()=>o==null?void 0:o(k.filePath)}));break;case"markdown":T=e.jsx(Rd,{content:k.content||""});break;case"file-list":T=e.jsx(Bd,{files:k.files||[],onFileClick:o,title:k.title});break;case"todo-list":((v=k.todos)==null?void 0:v.length)>0&&(T=e.jsx(Ud,{todos:k.todos,isResult:k.isResult}));break;case"task":T=e.jsx(Gd,{content:k.content||""});break;case"question-answer":T=e.jsx(Kd,{questions:k.questions||[],answers:k.answers||{}});break;case"text":T=e.jsx(qd,{content:k.content||"",format:k.format||"plain"});break;case"success-message":{const U=((A=f.getMessage)==null?void 0:A.call(f,h))||"Success";T=e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),U]});break}}const W=(t==="Edit"||t==="Write"||t==="ApplyPatch")&&k.filePath&&o?()=>o(k.filePath,{old_string:k.oldContent,new_string:k.newContent}):void 0;return e.jsx(zd,{toolName:t,toolId:a,title:M,defaultOpen:$,onTitleClick:W,showRawParameters:n==="input"&&d,rawContent:u,toolCategory:Jd(t),children:T})}return null});ha.displayName="ToolRenderer";const Yd=c.memo(({message:t,index:r,prevMessage:s,createDiff:a,onFileOpen:n,onShowSettings:o,onGrantToolPermission:i,autoExpandTools:l,showRawParameters:m,showThinking:d,selectedProject:u,provider:g})=>{const{t:p}=Ge("chat"),x=s&&s.type===t.type&&(s.type==="assistant"||s.type==="user"||s.type==="tool"||s.type==="error"),f=Ft.useRef(null),[h,b]=Ft.useState(!1),C=Dd(t,g),[I,y]=Ft.useState("idle");Ft.useEffect(()=>{y("idle")},[C==null?void 0:C.entry,t.toolId]),Ft.useEffect(()=>{const M=f.current;if(!l||!M||!t.isToolUse)return;const $=new IntersectionObserver(k=>{k.forEach(T=>{T.isIntersecting&&!h&&(b(!0),M.querySelectorAll("details").forEach(U=>{U.open=!0}))})},{threshold:.1});return $.observe(M),()=>{$.unobserve(M)}},[l,h,t.isToolUse]);const v=c.useMemo(()=>new Date(t.timestamp).toLocaleTimeString(),[t.timestamp]);return t.isThinking&&!d?null:e.jsx("div",{ref:f,className:`chat-message ${t.type} ${x?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((M,$)=>e.jsx("img",{src:M.data,alt:M.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(M.data,"_blank")},M.name||$))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:v})]}),!x&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):t.isTaskNotification?e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${t.taskStatus==="completed"?"bg-green-400 dark:bg-green-500":"bg-amber-400 dark:bg-amber-500"}`}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.content})]})}):e.jsxs("div",{className:"w-full",children:[!x&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(At,{provider:g,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?p("messageTypes.error"):t.type==="tool"?p("messageTypes.tool"):p(g==="cursor"?"messageTypes.cursor":g==="codex"?"messageTypes.codex":"messageTypes.claude")})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Ur,{className:"prose prose-sm max-w-none dark:prose-invert",children:String(t.displayText||"")})})}),t.toolInput&&e.jsx(ha,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"input",onFileOpen:n,createDiff:a,selectedProject:u,autoExpandTools:l,showRawParameters:m,rawToolInput:typeof t.toolInput=="string"?t.toolInput:void 0,isSubagentContainer:t.isSubagentContainer,subagentState:t.subagentState}),t.toolResult&&!$d(t.toolName||"UnknownTool",t.toolResult)&&(t.toolResult.isError?e.jsxs("div",{id:`tool-result-${t.toolId}`,className:"relative mt-2 p-3 rounded border scroll-mt-4 bg-red-50/50 dark:bg-red-950/10 border-red-200/60 dark:border-red-800/40",children:[e.jsxs("div",{className:"relative flex items-center gap-1.5 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:p("messageTypes.error")})]}),e.jsxs("div",{className:"relative text-sm text-red-900 dark:text-red-100",children:[e.jsx(Ur,{className:"prose prose-sm max-w-none prose-red dark:prose-invert",children:String(t.toolResult.content||"")}),C&&e.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!i)return;const M=i(C);M!=null&&M.success?y("granted"):y("error")},disabled:C.isAllowed||I==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${C.isAllowed||I==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:C.isAllowed||I==="granted"?p("permissions.added"):p("permissions.grant",{tool:C.toolName})}),o&&e.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),o()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:p("permissions.openSettings")})]}),e.jsx("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:p("permissions.addTo",{entry:C.entry})}),I==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:p("permissions.error")}),(C.isAllowed||I==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:p("permissions.retry")})]})]})]}):e.jsx("div",{id:`tool-result-${t.toolId}`,className:"scroll-mt-4",children:e.jsx(ha,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"result",onFileOpen:n,createDiff:a,selectedProject:u,autoExpandTools:l})}))]}):t.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:p("interactive.title")}),(()=>{const M=(t.content||"").split(`
49
+ `).filter(T=>T.trim()),$=M.find(T=>T.includes("?"))||M[0]||"",k=[];return M.forEach(T=>{const W=T.match(/[❯\s]*(\d+)\.\s+(.+)/);if(W){const U=T.includes("❯");k.push({number:W[1],text:W[2].trim(),isSelected:U})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:$}),e.jsx("div",{className:"space-y-2 mb-4",children:k.map(T=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${T.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${T.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:T.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:T.text}),T.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},T.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:p("interactive.waiting")}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:p("interactive.instruction")})]})]})})()]})]})}):t.isThinking?e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.jsxs("details",{className:"group",children:[e.jsxs("summary",{className:"cursor-pointer text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-3 h-3 transition-transform group-open:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("span",{children:p("thinking.emoji")})]}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Ur,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[d&&t.reasoning&&e.jsxs("details",{className:"mb-3",children:[e.jsx("summary",{className:"cursor-pointer text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 font-medium",children:p("thinking.emoji")}),e.jsx("div",{className:"mt-2 pl-4 border-l-2 border-gray-300 dark:border-gray-600 italic text-gray-600 dark:text-gray-400 text-sm",children:e.jsx("div",{className:"whitespace-pre-wrap",children:t.reasoning})})]}),(()=>{const M=xa(String(t.content||"")),$=M.trim();if(($.startsWith("{")||$.startsWith("["))&&($.endsWith("}")||$.endsWith("]")))try{const k=JSON.parse($),T=JSON.stringify(k,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:p("json.response")})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:T})})})]})}catch{}return t.type==="assistant"?e.jsx(Ur,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:M}):e.jsx("div",{className:"whitespace-pre-wrap",children:M})})()]}),!x&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:v})]})]})})}),Yo=({task:t,onClose:r,onEdit:s,onStatusChange:a,onTaskClick:n,isOpen:o=!0,className:i=""})=>{var U;const{addToast:l}=mr(),[m,d]=c.useState(!1),[u,g]=c.useState(t||{}),[p,x]=c.useState(!1),[f,h]=c.useState(!1),[b,C]=c.useState(!1),{currentProject:I,refreshTasks:y}=Ar();if(!o||!t)return null;const v=async()=>{if(I){x(!0);try{const S={};if(u.title!==t.title&&(S.title=u.title),u.description!==t.description&&(S.description=u.description),u.details!==t.details&&(S.details=u.details),Object.keys(S).length>0){const H=await He.taskmaster.updateTask(I.name,t.id,S);if(H.ok)y==null||y(),s==null||s(u),d(!1);else{const w=await H.json();console.error("Failed to update task:",w),l(`Failed to update task: ${w.message}`,"error")}}else d(!1)}catch(S){console.error("Error updating task:",S),l("Error updating task. Please try again.","error")}finally{x(!1)}}},A=()=>{navigator.clipboard.writeText(t.id.toString())},M=S=>{switch(S){case"done":return{icon:Qr,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:qr,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:Ds,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:ho,color:"text-gray-500 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"};case"cancelled":return{icon:qe,color:"text-red-600 dark:text-red-400",bg:"bg-red-50 dark:bg-red-950"};default:return{icon:Cr,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},$=M(t.status),k=$.icon,T=S=>{switch(S){case"high":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950";case"medium":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950";case"low":return"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950";default:return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}},W=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];return e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[100] md:p-4 bg-black/50",children:e.jsxs("div",{className:be("bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl","w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",i),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(k,{className:be("w-6 h-6",$.color)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("button",{onClick:A,className:"flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Click to copy task ID",children:[e.jsxs("span",{children:["Task ",t.id]}),e.jsx(Da,{className:"w-3 h-3"})]}),t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Subtask of Task ",t.parentId]})]}),m?e.jsx("input",{type:"text",value:u.title||"",onChange:S=>g({...u,title:S.target.value}),className:"w-full text-lg font-semibold bg-transparent border-b-2 border-blue-500 focus:outline-none text-gray-900 dark:text-white",placeholder:"Task title"}):e.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white line-clamp-2",children:t.title})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:v,disabled:p,className:"p-2 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p?"Saving...":"Save changes",children:e.jsx(fs,{className:be("w-5 h-5",p&&"animate-spin")})}),e.jsx("button",{onClick:()=>{d(!1),g(t)},disabled:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel editing",children:e.jsx(qe,{className:"w-5 h-5"})})]}):e.jsx("button",{onClick:()=>d(!0),className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Edit task",children:e.jsx(Oi,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Close",children:e.jsx(qe,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 space-y-6 min-h-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),e.jsx("div",{className:be("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",$.bg,$.color),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium capitalize",children:((U=W.find(S=>S.value===t.status))==null?void 0:U.label)||t.status})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),e.jsxs("div",{className:be("px-3 py-2 rounded-md text-sm font-medium capitalize",T(t.priority)),children:[e.jsx(go,{className:"w-4 h-4 inline mr-2"}),t.priority||"Not set"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),t.dependencies&&t.dependencies.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:t.dependencies.map(S=>e.jsxs("button",{onClick:()=>n&&n({id:S}),className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded text-sm hover:bg-blue-200 dark:hover:bg-blue-800 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50",disabled:!n,title:n?`Click to view Task ${S}`:`Task ${S}`,children:[e.jsx($a,{className:"w-3 h-3 inline mr-1"}),S]},S))}):e.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No dependencies"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),m?e.jsx("textarea",{value:u.description||"",onChange:S=>g({...u,description:S.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Task description"}):e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.description||"No description provided"})]}),t.details&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>h(!f),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),f?e.jsx(vt,{className:"w-4 h-4 text-gray-500"}):e.jsx(Ot,{className:"w-4 h-4 text-gray-500"})]}),f&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:m?e.jsx("textarea",{value:u.details||"",onChange:S=>g({...u,details:S.target.value}),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Implementation details"}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.details})})})]}),t.testStrategy&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>C(!b),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),b?e.jsx(vt,{className:"w-4 h-4 text-gray-500"}):e.jsx(Ot,{className:"w-4 h-4 text-gray-500"})]}),b&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-950 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.testStrategy})})})]}),t.subtasks&&t.subtasks.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Subtasks (",t.subtasks.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.subtasks.map(S=>{const H=M(S.status),w=H.icon;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx(w,{className:be("w-4 h-4",H.color)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:S.title}),S.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:S.description})]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:S.id})]},S.id)})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Task ID: ",t.id]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:r,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Close"})})]})]})})},jn=({onShowAllTasks:t,onStartTask:r,className:s=""})=>{const{nextTask:a,tasks:n,currentProject:o,isLoadingTasks:i,projectTaskMaster:l,refreshTasks:m,refreshProjects:d}=Ar(),{addToast:u}=mr(),[g,p]=c.useState(!1),[x,f]=c.useState(!1),[h,b]=c.useState(!1),[C,I]=c.useState(!1),[y,v]=c.useState(!1),[A,M]=c.useState(!1),[$,k]=c.useState(!1),T=async()=>{if(o){k(!0);try{const H=await He.taskmaster.init(o.name);if(H.ok)await d(),f(!1);else{const w=await H.json();console.error("Failed to initialize TaskMaster:",w),u(`Failed to initialize TaskMaster: ${w.message}`,"error")}}catch(H){console.error("Error initializing TaskMaster:",H),u("Error initializing TaskMaster. Please try again.","error")}finally{k(!1)}}},W=()=>{b(!0),f(!1)},U=()=>{I(!0),f(!1)};if(!o||i)return null;let S;if((!n||n.length===0)&&!(l!=null&&l.hasTaskmaster))S=e.jsxs("div",{className:be("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bs,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:T,disabled:$,className:"text-xs px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors flex items-center gap-1 disabled:opacity-50",children:[e.jsx(cr,{className:"w-3 h-3"}),$?"Initializing...":"Initialize TaskMaster AI"]}),e.jsx("button",{onClick:()=>f(!x),className:"text-xs px-1.5 py-1 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-600 dark:text-slate-400 rounded transition-colors",title:"More options",children:x?e.jsx(fo,{className:"w-3 h-3"}):e.jsx(vt,{className:"w-3 h-3"})})]})]}),x&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!(l!=null&&l.hasTaskmaster)&&e.jsxs("div",{className:"mb-3 p-3 bg-blue-50 dark:bg-blue-900/50 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-2",children:"🎯 What is TaskMaster?"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",e.jsx("strong",{children:"AI-Powered Task Management:"})," Break complex projects into manageable subtasks"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"PRD Templates:"})," Generate tasks from Product Requirements Documents"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Dependency Tracking:"})," Understand task relationships and execution order"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Progress Visualization:"})," Kanban boards and detailed task analytics"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"CLI Integration:"})," Use taskmaster commands for advanced workflows"]})]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:l!=null&&l.hasTaskmaster?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 p-2 bg-green-50 dark:bg-green-900/30 rounded text-xs text-green-800 dark:text-green-200",children:[e.jsx("strong",{children:"Add more tasks:"})," Create additional tasks manually or generate them from a PRD template"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:W,disabled:$,children:[e.jsx(lt,{className:"w-3 h-3"}),"Create a new task manually"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-purple-100 dark:bg-purple-900 hover:bg-purple-200 dark:hover:bg-purple-800 text-purple-800 dark:text-purple-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:U,disabled:$,children:[e.jsx(it,{className:"w-3 h-3"}),$?"Parsing...":"Generate tasks from PRD template"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"text-xs px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:T,disabled:$,children:[e.jsx(cr,{className:"w-3 h-3"}),$?"Initializing...":"Initialize TaskMaster (Auto)"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded transition-colors text-left flex items-center gap-2",onClick:()=>v(!0),children:[e.jsx(ct,{className:"w-3 h-3"}),"Initialize via Terminal (Advanced)"]})]})})]})]});else if(a)S=e.jsx("div",{className:be("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/50 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx(Ri,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})}),e.jsxs("span",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Task ",a.id]}),a.priority==="high"&&e.jsx("div",{className:"w-4 h-4 rounded bg-red-100 dark:bg-red-900/50 flex items-center justify-center",title:"High Priority",children:e.jsx(cr,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})}),a.priority==="medium"&&e.jsx("div",{className:"w-4 h-4 rounded bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",title:"Medium Priority",children:e.jsx(go,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})}),a.priority==="low"&&e.jsx("div",{className:"w-4 h-4 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center",title:"Low Priority",children:e.jsx(Cr,{className:"w-2.5 h-2.5 text-gray-400 dark:text-gray-500"})})]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-1",children:a.title})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>r==null?void 0:r(),className:"text-xs px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium transition-colors shadow-sm flex items-center gap-1",children:[e.jsx(Bi,{className:"w-3 h-3"}),"Start Task"]}),e.jsx("button",{onClick:()=>M(!0),className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View task details",children:e.jsx(ur,{className:"w-3 h-3"})}),t&&e.jsx("button",{onClick:t,className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View all tasks",children:e.jsx(bs,{className:"w-3 h-3"})})]})]})});else if(n&&n.length>0){const H=n.filter(P=>P.status==="done").length,w=n.length;S=e.jsx("div",{className:be("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qr,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:H===w?"All done! 🎉":"No pending tasks"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[H,"/",w]}),e.jsx("button",{onClick:t,className:"text-xs px-2 py-1 bg-purple-600 hover:bg-purple-700 text-white rounded transition-colors",children:"Review"})]})]})})}else S=null;return e.jsxs(e.Fragment,{children:[S,h&&e.jsx(Qd,{currentProject:o,onClose:()=>b(!1),onTaskCreated:()=>{m(),b(!1)}}),C&&e.jsx(Xd,{currentProject:o,onClose:()=>I(!1),onTemplateApplied:()=>{m(),I(!1)}}),y&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(ct,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"TaskMaster Setup"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Interactive CLI for ",o==null?void 0:o.displayName]})]})]}),e.jsx("button",{onClick:()=>v(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",children:e.jsx(ko,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"TaskMaster initialization will start automatically"}),e.jsx("button",{onClick:()=>v(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Close"})]})})]})}),A&&a&&e.jsx(Yo,{task:a,isOpen:A,onClose:()=>M(!1),onStatusChange:()=>m==null?void 0:m(),onTaskClick:null})]})},Qd=({currentProject:t,onClose:r,onTaskCreated:s})=>{const[a,n]=c.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[o,i]=c.useState(!1),l=async m=>{if(m.preventDefault(),!!t){i(!0);try{const d=a.useAI?{prompt:a.prompt,priority:a.priority}:{title:a.title,description:a.description,priority:a.priority},u=await He.taskmaster.addTask(t.name,d);if(u.ok)s();else{const g=await u.json();console.error("Failed to create task:",g),addToast(`Failed to create task: ${g.message}`,"error")}}catch(d){console.error("Error creating task:",d),addToast("Error creating task. Please try again.","error")}finally{i(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create New Task"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(qe,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:l,className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:a.useAI,onChange:m=>n(d=>({...d,useAI:m.target.checked}))}),"Use AI to generate task details"]})}),a.useAI?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Description (AI will generate details)"}),e.jsx("textarea",{value:a.prompt,onChange:m=>n(d=>({...d,prompt:m.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe what you want to accomplish...",required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Title"}),e.jsx("input",{type:"text",value:a.title,onChange:m=>n(d=>({...d,title:m.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter task title...",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Description"}),e.jsx("textarea",{value:a.description,onChange:m=>n(d=>({...d,description:m.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe the task...",required:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Priority"}),e.jsxs("select",{value:a.priority,onChange:m=>n(d=>({...d,priority:m.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:r,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded disabled:opacity-50",disabled:o||a.useAI&&!a.prompt.trim()||!a.useAI&&(!a.title.trim()||!a.description.trim()),children:o?"Creating...":"Create Task"})]})]})]})})},Xd=({currentProject:t,onClose:r,onTemplateApplied:s})=>{const[a,n]=c.useState([]),[o,i]=c.useState(null),[l,m]=c.useState({}),[d,u]=c.useState("prd.txt"),[g,p]=c.useState(!0),[x,f]=c.useState(!1),[h,b]=c.useState("select");useEffect(()=>{(async()=>{try{const v=await He.taskmaster.getTemplates();if(v.ok){const A=await v.json();n(A.templates)}}catch(v){console.error("Error loading templates:",v)}finally{p(!1)}})()},[]);const C=y=>{i(y);const v=y.content.match(/\[([^\]]+)\]/g)||[],A=[...new Set(v.map($=>$.slice(1,-1)))],M={};A.forEach($=>{M[$]=""}),m(M),b("customize")},I=async()=>{if(!(!o||!t)){f(!0);try{const y=await He.taskmaster.applyTemplate(t.name,{templateId:o.id,fileName:d,customizations:l});if(!y.ok){const A=await y.json();throw new Error(A.message||"Failed to apply template")}const v=await He.taskmaster.parsePRD(t.name,{fileName:d,numTasks:10});if(!v.ok){const A=await v.json();throw new Error(A.message||"Failed to generate tasks")}b("generate"),setTimeout(()=>{s()},2e3)}catch(y){console.error("Error applying template:",y),addToast(`Error: ${y.message}`,"error"),f(!1)}}};return g?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading templates..."})]})})}):e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:h==="select"?"Select PRD Template":h==="customize"?"Customize Template":"Generating Tasks"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(qe,{className:"w-4 h-4"})})]}),h==="select"&&e.jsx("div",{className:"space-y-3",children:a.map(y=>e.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors",onClick:()=>C(y),children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:y.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:y.description}),e.jsx("span",{className:"inline-block text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded mt-2",children:y.category})]}),e.jsx($a,{className:"w-4 h-4 text-gray-400 mt-1"})]})},y.id))}),h==="customize"&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"File Name"}),e.jsx("input",{type:"text",value:d,onChange:y=>u(y.target.value),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"prd.txt"})]}),Object.keys(l).length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Customize Template"}),e.jsx("div",{className:"space-y-3",children:Object.entries(l).map(([y,v])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:y.replace(/([A-Z])/g," $1").replace(/^./,A=>A.toUpperCase())}),e.jsx("input",{type:"text",value:v,onChange:A=>m(M=>({...M,[y]:A.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:`Enter ${y.toLowerCase()}`})]},y))})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{onClick:()=>b("select"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Back"}),e.jsx("button",{onClick:I,className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded disabled:opacity-50",disabled:x,children:x?"Applying...":"Apply & Generate Tasks"})]})]}),h==="generate"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Qr,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),e.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Template Applied Successfully!"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Your PRD has been created and tasks are being generated..."})]})]})})},Qo={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},Xo={OPTIONS:[{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"composer-1",label:"Composer 1"},{value:"auto",label:"Auto"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-high",label:"GPT-5.1 Codex High"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"opus-4.1",label:"Claude 4.1 Opus"},{value:"grok",label:"Grok"}],DEFAULT:"gpt-5"},Zo={OPTIONS:[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"o3",label:"O3"},{value:"o4-mini",label:"O4-mini"}],DEFAULT:"gpt-5.2"},Zd=[{id:"claude",name:"Claude Code",infoKey:"providerSelection.providerInfo.anthropic",accent:"border-primary",ring:"ring-primary/15",check:"bg-primary text-primary-foreground"},{id:"cursor",name:"Cursor",infoKey:"providerSelection.providerInfo.cursorEditor",accent:"border-violet-500 dark:border-violet-400",ring:"ring-violet-500/15",check:"bg-violet-500 text-white"},{id:"codex",name:"Codex",infoKey:"providerSelection.providerInfo.openai",accent:"border-emerald-600 dark:border-emerald-400",ring:"ring-emerald-600/15",check:"bg-emerald-600 dark:bg-emerald-500 text-white"}];function em(t){return t==="claude"?Qo:t==="codex"?Zo:Xo}function tm(t,r,s,a){return t==="claude"?r:t==="codex"?a:s}function rm({selectedSession:t,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:o,setClaudeModel:i,cursorModel:l,setCursorModel:m,codexModel:d,setCodexModel:u,tasksEnabled:g,isTaskMasterInstalled:p,onShowAllTasks:x,setInput:f}){const{t:h}=Ge("chat"),b=h("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),C=A=>{a(A),localStorage.setItem("selected-provider",A),setTimeout(()=>{var M;return(M=n.current)==null?void 0:M.focus()},100)},I=A=>{s==="claude"?(i(A),localStorage.setItem("claude-model",A)):s==="codex"?(u(A),localStorage.setItem("codex-model",A)):(m(A),localStorage.setItem("cursor-model",A))},y=em(s),v=tm(s,o,l,d);return!t&&!r?e.jsx("div",{className:"flex items-center justify-center h-full px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:h("providerSelection.title")}),e.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:h("providerSelection.description")})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:Zd.map(A=>{const M=s===A.id;return e.jsxs("button",{onClick:()=>C(A.id),className:`
50
+ relative flex flex-col items-center gap-2.5 pt-5 pb-4 px-2
51
+ rounded-xl border-[1.5px] transition-all duration-150
52
+ active:scale-[0.97]
53
+ ${M?`${A.accent} ${A.ring} ring-2 bg-card shadow-sm`:"border-border bg-card/60 hover:bg-card hover:border-border/80"}
54
+ `,children:[e.jsx(At,{provider:A.id,className:`w-9 h-9 transition-transform duration-150 ${M?"scale-110":""}`}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground leading-none",children:A.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 leading-tight",children:h(A.infoKey)})]}),M&&e.jsx("div",{className:`absolute -top-1 -right-1 w-[18px] h-[18px] rounded-full ${A.check} flex items-center justify-center shadow-sm`,children:e.jsx(Tt,{className:"w-2.5 h-2.5",strokeWidth:3})})]},A.id)})}),e.jsxs("div",{className:`transition-all duration-200 ${s?"opacity-100 translate-y-0":"opacity-0 translate-y-1 pointer-events-none"}`,children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-5",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:h("providerSelection.selectModel")}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:v,onChange:A=>I(A.target.value),tabIndex:-1,className:"appearance-none pl-3 pr-7 py-1.5 text-sm font-medium bg-muted/50 border border-border/60 rounded-lg text-foreground cursor-pointer hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20",children:y.OPTIONS.map(({value:A,label:M})=>e.jsx("option",{value:A,children:M},A))}),e.jsx(vt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground pointer-events-none"})]})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground/70",children:s==="claude"?h("providerSelection.readyPrompt.claude",{model:o}):s==="cursor"?h("providerSelection.readyPrompt.cursor",{model:l}):s==="codex"?h("providerSelection.readyPrompt.codex",{model:d}):h("providerSelection.readyPrompt.default")})]}),s&&g&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(jn,{onStartTask:()=>f(b),onShowAllTasks:x})})]})}):t?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center px-6 max-w-md",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground mb-1.5",children:h("session.continue.title")}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:h("session.continue.description")}),g&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(jn,{onStartTask:()=>f(b),onShowAllTasks:x})})]})}):null}function sm({selectedProvider:t}){return e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(At,{provider:t,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t==="cursor"?"Cursor":t==="codex"?"Codex":"Claude"})]}),e.jsx("div",{className:"w-full text-sm text-gray-500 dark:text-gray-400 pl-3 sm:pl-0",children:e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx("div",{className:"animate-pulse",children:"."}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.2s"},children:"."}),e.jsx("div",{className:"animate-pulse",style:{animationDelay:"0.4s"},children:"."}),e.jsx("span",{className:"ml-2",children:"Thinking..."})]})})]})})}const am=t=>{if(typeof t!="string"&&typeof t!="number")return null;const r=String(t).trim();return r.length>0?r:null},nm=t=>{const r=[t.id,t.messageId,t.toolId,t.toolCallId,t.blobId,t.rowid,t.sequence];for(const o of r){const i=am(o);if(i)return`message-${t.type}-${i}`}const s=new Date(t.timestamp).getTime();if(!Number.isFinite(s))return null;const a=typeof t.content=="string"?t.content.slice(0,48):"",n=typeof t.toolName=="string"?t.toolName:"";return`message-${t.type}-${s}-${n}-${a}`};function om({scrollContainerRef:t,onWheel:r,onTouchMove:s,isLoadingSessionMessages:a,chatMessages:n,selectedSession:o,currentSessionId:i,provider:l,setProvider:m,textareaRef:d,claudeModel:u,setClaudeModel:g,cursorModel:p,setCursorModel:x,codexModel:f,setCodexModel:h,tasksEnabled:b,isTaskMasterInstalled:C,onShowAllTasks:I,setInput:y,isLoadingMoreMessages:v,hasMoreMessages:A,totalMessages:M,sessionMessagesCount:$,visibleMessageCount:k,visibleMessages:T,loadEarlierMessages:W,loadAllMessages:U,allMessagesLoaded:S,isLoadingAllMessages:H,loadAllJustFinished:w,showLoadAllOverlay:P,createDiff:j,onFileOpen:F,onShowSettings:G,onGrantToolPermission:X,autoExpandTools:D,showRawParameters:oe,showThinking:E,selectedProject:se,isLoading:J}){const{t:B}=Ge("chat"),K=c.useRef(new WeakMap),V=c.useRef(new Set),z=c.useRef(0),O=c.useCallback(ne=>{const me=K.current.get(ne);if(me)return me;const q=nm(ne);let N=q;if(!N||V.current.has(N))do z.current+=1,N=q?`${q}-${z.current}`:`message-generated-${z.current}`;while(V.current.has(N));return V.current.add(N),K.current.set(ne,N),N},[]);return e.jsxs("div",{ref:t,onWheel:r,onTouchMove:s,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 pb-24 space-y-3 sm:space-y-4 relative",children:[a&&n.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:B("session.loading.sessionMessages")})]})}):n.length===0?e.jsx(rm,{selectedSession:o,currentSessionId:i,provider:l,setProvider:m,textareaRef:d,claudeModel:u,setClaudeModel:g,cursorModel:p,setCursorModel:x,codexModel:f,setCodexModel:h,tasksEnabled:b,isTaskMasterInstalled:C,onShowAllTasks:I,setInput:y}):e.jsxs(e.Fragment,{children:[v&&!H&&!S&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:B("session.loading.olderMessages")})]})}),A&&!v&&!S&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:M>0&&e.jsxs("span",{children:[B("session.messages.showingOf",{shown:$,total:M})," ",e.jsx("span",{className:"text-xs",children:B("session.messages.scrollToLoad")})]})}),(P||H||w)&&e.jsx("div",{className:"sticky top-2 z-20 flex justify-center pointer-events-none",children:w?e.jsxs("div",{className:"px-4 py-1.5 text-xs font-medium text-white bg-green-600 dark:bg-green-500 rounded-full shadow-lg flex items-center space-x-2",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:B("session.messages.allLoaded")})]}):e.jsxs("button",{className:"pointer-events-auto px-4 py-1.5 text-xs font-medium text-white bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 rounded-full shadow-lg transition-all duration-200 hover:scale-105 disabled:opacity-75 disabled:cursor-wait flex items-center space-x-2",onClick:U,disabled:H,children:[H&&e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-2 border-white/30 border-t-white"}),e.jsx("span",{children:H?B("session.messages.loadingAll"):e.jsxs(e.Fragment,{children:[B("session.messages.loadAll")," ",M>0&&`(${M})`]})})]})}),S&&e.jsx("div",{className:"text-center text-amber-600 dark:text-amber-400 text-xs py-1.5 bg-amber-50 dark:bg-amber-900/20 border-b border-amber-200 dark:border-amber-800",children:B("session.messages.perfWarning")}),!A&&n.length>k&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:[B("session.messages.showingLast",{count:k,total:n.length})," |",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:W,children:B("session.messages.loadEarlier")})," | ",e.jsx("button",{className:"text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 underline",onClick:U,children:B("session.messages.loadAll")})]}),T.map((ne,me)=>{const q=me>0?T[me-1]:null;return e.jsx(Yd,{message:ne,index:me,prevMessage:q,createDiff:j,onFileOpen:F,onShowSettings:G,onGrantToolPermission:X,autoExpandTools:D,showRawParameters:oe,showThinking:E,selectedProject:se,provider:l},O(ne))})]}),J&&e.jsx(sm,{selectedProvider:l})]})}const im=({commands:t=[],selectedIndex:r=-1,onSelect:s,onClose:a,position:n={top:0,left:0},isOpen:o=!1,frequentCommands:i=[]})=>{const l=c.useRef(null),m=c.useRef(null),u=(()=>{const y=window.innerWidth<640,v=window.innerHeight;return y?{position:"fixed",bottom:`${n.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(n.top,v-316))}px`,left:`${n.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(c.useEffect(()=>{const y=v=>{l.current&&!l.current.contains(v.target)&&o&&a()};if(o)return document.addEventListener("mousedown",y),()=>{document.removeEventListener("mousedown",y)}},[o,a]),c.useEffect(()=>{if(m.current&&l.current){const y=l.current.getBoundingClientRect(),v=m.current.getBoundingClientRect();v.bottom>y.bottom?m.current.scrollIntoView({block:"nearest",behavior:"smooth"}):v.top<y.top&&m.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!o)return null;if(t.length===0)return e.jsx("div",{ref:l,className:"command-menu command-menu-empty",style:{...u,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const g=i.length>0,p=y=>`${y.name}::${y.namespace||y.type||"other"}::${y.path||""}`,x=new Set(i.map(p)),f=t.reduce((y,v)=>{if(g&&x.has(p(v)))return y;const A=v.namespace||v.type||"other";return y[A]||(y[A]=[]),y[A].push(v),y},{});g&&(f.frequent=i);const b=(g?["frequent","builtin","project","user","other"]:["builtin","project","user","other"]).filter(y=>f[y]),C={frequent:"⭐ Frequently Used",builtin:"Built-in Commands",project:"Project Commands",user:"User Commands",other:"Other Commands"},I=new Map;return t.forEach((y,v)=>{const A=p(y);I.has(A)||I.set(A,v)}),e.jsxs("div",{ref:l,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...u,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:o?1:0,transform:o?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[b.map(y=>e.jsxs("div",{className:"command-group",children:[b.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:C[y]||y}),f[y].map(v=>{var k;const A=p(v),M=I.get(A)??-1,$=M===r;return e.jsxs("div",{ref:$?m:null,role:"option","aria-selected":$,className:"command-item",onMouseEnter:()=>{s&&M>=0&&s(v,M,!0)},onClick:()=>{s&&s(v,M,!1)},style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:$?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:T=>T.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:v.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[y==="builtin"&&"⚡",y==="project"&&"📁",y==="user"&&"👤",y==="other"&&"📝",y==="frequent"&&"⭐"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:v.name}),((k=v.metadata)==null?void 0:k.type)&&e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",fontWeight:500},children:v.metadata.type})]}),v.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.description})]}),$&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${y}-${v.name}-${v.path||""}`)})]},y)),e.jsx("style",{children:`
55
+ .command-menu {
56
+ background-color: white;
57
+ border: 1px solid #e5e7eb;
58
+ }
59
+ .command-menu-empty {
60
+ color: #6b7280;
61
+ }
62
+
63
+ @media (prefers-color-scheme: dark) {
64
+ .command-menu {
65
+ background-color: #1f2937 !important;
66
+ border: 1px solid #374151 !important;
67
+ }
68
+ .command-menu-empty {
69
+ color: #9ca3af !important;
70
+ }
71
+ .command-item[aria-selected="true"] {
72
+ background-color: #1e40af !important;
73
+ }
74
+ .command-item span:not(.command-metadata-badge) {
75
+ color: #f3f4f6 !important;
76
+ }
77
+ .command-metadata-badge {
78
+ background-color: #f3f4f6 !important;
79
+ color: #6b7280 !important;
80
+ }
81
+ .command-item div {
82
+ color: #d1d5db !important;
83
+ }
84
+ .command-group > div:first-child {
85
+ color: #9ca3af !important;
86
+ }
87
+ }
88
+ `})]})};function lm({status:t,onAbort:r,isLoading:s,provider:a="claude"}){const[n,o]=c.useState(0),[i,l]=c.useState(0),[m,d]=c.useState(0);if(c.useEffect(()=>{if(!s){o(0),d(0);return}const C=Date.now(),I=30+Math.random()*20,y=setInterval(()=>{const v=Math.floor((Date.now()-C)/1e3);o(v),d(Math.floor(v*I))},1e3);return()=>clearInterval(y)},[s]),c.useEffect(()=>{if(!s)return;const C=setInterval(()=>{l(I=>(I+1)%4)},500);return()=>clearInterval(C)},[s]),!s)return null;const u=["Thinking","Processing","Analyzing","Working","Computing","Reasoning"],g=Math.floor(n/3)%u.length,p=(t==null?void 0:t.text)||u[g],x=(t==null?void 0:t.tokens)||m,f=(t==null?void 0:t.can_interrupt)!==!1,b=["✻","✹","✸","✶"][i];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:be("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:b}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[p,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),x>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",x.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"esc to stop"})]})})]})}),f&&r&&e.jsxs("button",{onClick:r,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"Stop"})]})]})})}async function cm(t,r){const s=new FormData,a=`recording_${Date.now()}.webm`,n=new File([t],a,{type:t.type});s.append("audio",n);const o=window.localStorage.getItem("whisperMode")||"default";s.append("mode",o);try{const i=await He.transcribe(s);if(!i.ok){const m=await i.json().catch(()=>({}));throw new Error(m.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function ei({onTranscript:t,className:r=""}){const[s,a]=c.useState("idle"),[n,o]=c.useState(null),[i,l]=c.useState(!0),m=c.useRef(null),d=c.useRef(null),u=c.useRef([]),g=c.useRef(0);c.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){l(!1),o("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){l(!1),o("Microphone requires HTTPS. Please use a secure connection.");return}l(!0),o(null)})()},[]);const p=async()=>{try{if(console.log("Starting recording..."),o(null),u.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const y=await navigator.mediaDevices.getUserMedia({audio:!0});d.current=y;const v=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",A=new MediaRecorder(y,{mimeType:v});m.current=A,A.ondataavailable=M=>{M.data.size>0&&u.current.push(M.data)},A.onstop=async()=>{console.log("Recording stopped, creating blob...");const M=new Blob(u.current,{type:v});d.current&&(d.current.getTracks().forEach(W=>W.stop()),d.current=null),a("transcribing");const $=window.localStorage.getItem("whisperMode")||"default",k=$==="prompt"||$==="vibe"||$==="instructions"||$==="architect";let T;k&&(T=setTimeout(()=>{a("processing")},2e3));try{const W=await cm(M);W&&t&&t(W)}catch(W){console.error("Transcription error:",W),o(W.message)}finally{T&&clearTimeout(T),a("idle")}},A.start(),a("recording"),console.log("Recording started successfully")}catch(y){console.error("Failed to start recording:",y);let v="Microphone access failed";y.name==="NotAllowedError"?v="Microphone access denied. Please allow microphone permissions.":y.name==="NotFoundError"?v="No microphone found. Please check your audio devices.":y.name==="NotSupportedError"?v="Microphone not supported by this browser.":y.name==="NotReadableError"?v="Microphone is being used by another application.":y.message.includes("HTTPS")&&(v=y.message),o(v),a("idle")}},x=()=>{console.log("Stopping recording..."),m.current&&m.current.state==="recording"?m.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),d.current&&(d.current.getTracks().forEach(y=>y.stop()),d.current=null),a("idle"))},f=y=>{if(y&&(y.preventDefault(),y.stopPropagation()),!i)return;const v=Date.now();if(v-g.current<300){console.log("Ignoring rapid tap");return}g.current=v,console.log("Button clicked, current state:",s),s==="idle"?p():s==="recording"&&x()};c.useEffect(()=>()=>{d.current&&d.current.getTracks().forEach(y=>y.stop())},[]);const h=()=>{if(!i)return{icon:e.jsx(gs,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(s){case"recording":return{icon:e.jsx(gs,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(jr,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx($s,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(gs,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:b,className:C,disabled:I}=h();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:s==="recording"?"#ef4444":s==="transcribing"?"#3b82f6":s==="processing"?"#a855f7":"#374151"},className:`
89
+ flex items-center justify-center
90
+ w-12 h-12 rounded-full
91
+ text-white transition-all duration-200
92
+ focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500
93
+ dark:ring-offset-gray-800
94
+ touch-action-manipulation
95
+ ${I?"cursor-not-allowed opacity-75":"cursor-pointer"}
96
+ ${s==="recording"?"animate-pulse":""}
97
+ hover:opacity-90
98
+ ${r}
99
+ `,onClick:f,disabled:I,children:b}),n&&e.jsx("div",{className:`absolute top-full mt-2 left-1/2 transform -translate-x-1/2 \r
100
+ bg-red-500 text-white text-xs px-2 py-1 rounded whitespace-nowrap z-10\r
101
+ animate-fade-in`,children:n}),s==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),s==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const dm=({file:t,onRemove:r,uploadProgress:s,error:a})=>{const[n,o]=c.useState(void 0);return c.useEffect(()=>{const i=URL.createObjectURL(t);return o(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),s!==void 0&&s<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{type:"button",onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus:opacity-100 transition-opacity","aria-label":"Remove image",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},ti={};function mm(t,r){ti[t]=r}function um(t){return ti[t]||null}mm("AskUserQuestion",Vd);function pm({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}){return t.length?e.jsx("div",{className:"mb-3 space-y-2",children:t.map(a=>{const n=um(a.toolName);if(n)return e.jsx(n,{request:a,onDecision:r},a.requestId);const o=yn(a.input),i=ga(a.toolName,o),l=Ba(),m=i?l.allowedTools.includes(i):!1,d=m?"Allow (saved)":"Allow & remember",u=i?t.filter(g=>ga(g.toolName,yn(g.input))===i).map(g=>g.requestId):[a.requestId];return e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"Permission required"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["Tool: ",e.jsx("span",{className:"font-mono",children:a.toolName})]})]}),i&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Allow rule: ",e.jsx("span",{className:"font-mono",children:i})]})]}),o&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"View tool input"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:o})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"Allow once"}),e.jsx("button",{type:"button",onClick:()=>{i&&!m&&s({entry:i,toolName:a.toolName}),r(u,{allow:!0,rememberEntry:i})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${i?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!i,children:d}),e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!1,message:"User denied tool use"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"Deny"})]})]},a.requestId)})}):null}const ri=[{id:"none",name:"Standard",description:"Regular Claude response",icon:null,prefix:"",color:"text-gray-600"},{id:"think",name:"Think",description:"Basic extended thinking",icon:$s,prefix:"think",color:"text-blue-600"},{id:"think-hard",name:"Think Hard",description:"More thorough evaluation",icon:cr,prefix:"think hard",color:"text-purple-600"},{id:"think-harder",name:"Think Harder",description:"Deep analysis with alternatives",icon:Ht,prefix:"think harder",color:"text-indigo-600"},{id:"ultrathink",name:"Ultrathink",description:"Maximum thinking budget",icon:Wi,prefix:"ultrathink",color:"text-red-600"}];function xm({selectedMode:t,onModeChange:r,onClose:s,className:a=""}){const{t:n}=Ge("chat"),o={"think-hard":"thinkHard","think-harder":"thinkHarder"},i=ri.map(p=>{const x=o[p.id]||p.id;return{...p,name:n(`thinkingMode.modes.${x}.name`),description:n(`thinkingMode.modes.${x}.description`),prefix:n(`thinkingMode.modes.${x}.prefix`)}}),[l,m]=c.useState(!1),d=c.useRef(null);c.useEffect(()=>{const p=x=>{d.current&&!d.current.contains(x.target)&&(m(!1),s&&s())};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);const u=i.find(p=>p.id===t)||i[0],g=u.icon||$s;return e.jsxs("div",{className:`relative ${a}`,ref:d,children:[e.jsx("button",{type:"button",onClick:()=>m(!l),className:`w-10 h-10 sm:w-10 sm:h-10 rounded-full flex items-center justify-center transition-all duration-200 ${t==="none"?"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900 dark:hover:bg-blue-800"}`,title:n("thinkingMode.buttonTitle",{mode:u.name}),children:e.jsx(g,{className:`w-5 h-5 ${u.color}`})}),l&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n("thinkingMode.selector.title")}),e.jsx("button",{onClick:()=>{m(!1),s&&s()},className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:e.jsx(qe,{className:"w-4 h-4 text-gray-500"})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:n("thinkingMode.selector.description")})]}),e.jsx("div",{className:"py-1",children:i.map(p=>{const x=p.icon,f=p.id===t;return e.jsx("button",{onClick:()=>{r(p.id),m(!1),s&&s()},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${f?"bg-gray-50 dark:bg-gray-700":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 ${p.icon?p.color:"text-gray-400"}`,children:x?e.jsx(x,{className:"w-5 h-5"}):e.jsx("div",{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium text-sm ${f?"text-gray-900 dark:text-white":"text-gray-700 dark:text-gray-300"}`,children:p.name}),f&&e.jsx("span",{className:"text-xs bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 px-2 py-0.5 rounded",children:n("thinkingMode.selector.active")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:p.description}),p.prefix&&e.jsx("code",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded mt-1 inline-block",children:p.prefix})]})]})},p.id)})}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Tip:"})," ",n("thinkingMode.selector.tip")]})})]})]})}function gm({used:t,total:r}){if(t==null||r==null||r<=0)return null;const s=Math.min(100,t/r*100),a=10,n=2*Math.PI*a,o=n-s/100*n,i=()=>s<50?"#3b82f6":s<75?"#f59e0b":"#ef4444";return e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"transform -rotate-90",children:[e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-300 dark:text-gray-600"}),e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:i(),strokeWidth:"2",strokeDasharray:n,strokeDashoffset:o,strokeLinecap:"round"})]}),e.jsxs("span",{title:`${t.toLocaleString()} / ${r.toLocaleString()} tokens`,children:[s.toFixed(1),"%"]})]})}function hm({permissionMode:t,onModeSwitch:r,provider:s,thinkingMode:a,setThinkingMode:n,tokenBudget:o,slashCommandsCount:i,onToggleCommandMenu:l,hasInput:m,onClearInput:d,isUserScrolledUp:u,hasMessages:g,onScrollToBottom:p}){const{t:x}=Ge("chat");return e.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:r,className:`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${t==="default"?"bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted":t==="acceptEdits"?"bg-green-50 dark:bg-green-900/15 text-green-700 dark:text-green-300 border-green-300/60 dark:border-green-600/40 hover:bg-green-100 dark:hover:bg-green-900/25":t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/15 text-orange-700 dark:text-orange-300 border-orange-300/60 dark:border-orange-600/40 hover:bg-orange-100 dark:hover:bg-orange-900/25":"bg-primary/5 text-primary border-primary/20 hover:bg-primary/10"}`,title:x("input.clickToChangeMode"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t==="default"?"bg-muted-foreground":t==="acceptEdits"?"bg-green-500":t==="bypassPermissions"?"bg-orange-500":"bg-primary"}`}),e.jsxs("span",{children:[t==="default"&&x("codex.modes.default"),t==="acceptEdits"&&x("codex.modes.acceptEdits"),t==="bypassPermissions"&&x("codex.modes.bypassPermissions"),t==="plan"&&x("codex.modes.plan")]})]})}),s==="claude"&&e.jsx(xm,{selectedMode:a,onModeChange:n,onClose:()=>{},className:""}),e.jsx(gm,{used:(o==null?void 0:o.used)||0,total:(o==null?void 0:o.total)||parseInt(void 0)||16e4}),e.jsxs("button",{type:"button",onClick:l,className:"relative w-7 h-7 sm:w-8 sm:h-8 text-muted-foreground hover:text-foreground rounded-lg flex items-center justify-center transition-colors hover:bg-accent/60",title:x("input.showAllCommands"),children:[e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),i>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-primary text-primary-foreground text-[10px] font-bold rounded-full w-4 h-4 sm:w-5 sm:h-5 flex items-center justify-center",children:i})]}),m&&e.jsx("button",{type:"button",onClick:d,className:"w-7 h-7 sm:w-8 sm:h-8 bg-card hover:bg-accent/60 border border-border/50 rounded-lg flex items-center justify-center transition-all duration-200 group shadow-sm",title:x("input.clearInput",{defaultValue:"Clear input"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-muted-foreground group-hover:text-foreground transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),u&&g&&e.jsx("button",{onClick:p,className:"w-7 h-7 sm:w-8 sm:h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-lg shadow-sm flex items-center justify-center transition-all duration-200 hover:scale-105",title:x("input.scrollToBottom",{defaultValue:"Scroll to bottom"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})}const Nn="upfynai-voice-output-enabled",Cn="upfynai-voice-id",fm=2e3;function si(){const[t,r]=c.useState(!1),[s,a]=c.useState(()=>localStorage.getItem(Nn)==="true"),[n,o]=c.useState(()=>localStorage.getItem(Cn)||"en-US-AriaNeural"),i=c.useRef(null),l=c.useRef(null),m=c.useCallback(async p=>{if(!(!s||!p)&&!(p.length>fm))try{r(!0);const x=await Ee("/api/voice/tts",{method:"POST",body:JSON.stringify({text:p,voice:n})});if(!x.ok)throw new Error("TTS failed");const f=await x.blob(),h=URL.createObjectURL(f);i.current&&(i.current.pause(),i.current=null),l.current&&URL.revokeObjectURL(l.current),l.current=h;const b=new Audio(h);i.current=b,b.onended=()=>{r(!1),URL.revokeObjectURL(h),l.current=null,i.current=null},b.onerror=()=>{r(!1),URL.revokeObjectURL(h),l.current=null,i.current=null},await b.play()}catch{r(!1)}},[s,n]),d=c.useCallback(()=>{i.current&&(i.current.pause(),i.current=null),l.current&&(URL.revokeObjectURL(l.current),l.current=null),r(!1)},[]),u=c.useCallback(()=>{const p=!s;a(p),localStorage.setItem(Nn,String(p)),p||d()},[s,d]),g=c.useCallback(p=>{o(p),localStorage.setItem(Cn,p)},[]);return{speak:m,stop:d,isPlaying:t,voiceEnabled:s,toggleVoice:u,selectedVoice:n,changeVoice:g}}function bm({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s,claudeStatus:a,isLoading:n,onAbortSession:o,provider:i,permissionMode:l,onModeSwitch:m,thinkingMode:d,setThinkingMode:u,tokenBudget:g,slashCommandsCount:p,onToggleCommandMenu:x,hasInput:f,onClearInput:h,isUserScrolledUp:b,hasMessages:C,onScrollToBottom:I,onSubmit:y,isDragActive:v,attachedImages:A,onRemoveImage:M,uploadingImages:$,imageErrors:k,showFileDropdown:T,filteredFiles:W,selectedFileIndex:U,onSelectFile:S,filteredCommands:H,selectedCommandIndex:w,onCommandSelect:P,onCloseCommandMenu:j,isCommandMenuOpen:F,frequentCommands:G,getRootProps:X,getInputProps:D,openImagePicker:oe,inputHighlightRef:E,renderInputWithMentions:se,textareaRef:J,input:B,onInputChange:K,onTextareaClick:V,onTextareaKeyDown:z,onTextareaPaste:O,onTextareaScrollSync:ne,onTextareaInput:me,onInputFocusChange:q,isInputFocused:N,placeholder:_,isTextareaExpanded:re,sendByCtrlEnter:te,onTranscript:ve}){var De;const{t:je}=Ge("chat"),{voiceEnabled:Ne,toggleVoice:we,isPlaying:Ie}=si(),Re=im,Z=(De=J.current)==null?void 0:De.getBoundingClientRect(),ye={top:Z?Math.max(16,Z.top-316):0,left:Z?Z.left:16,bottom:Z?window.innerHeight-Z.top+8:90},Y=t.some(de=>de.toolName==="AskUserQuestion"),ie=N?"max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:right-0 max-sm:z-50 max-sm:bg-background max-sm:shadow-[0_-4px_20px_rgba(0,0,0,0.15)]":"";return e.jsxs("div",{className:`sticky bottom-0 z-30 bg-background p-2 sm:p-3 flex-shrink-0 pb-2 ${ie}`,children:[!Y&&e.jsx("div",{className:"flex-1",children:e.jsx(lm,{status:a,isLoading:n,onAbort:o,provider:i})}),e.jsxs("div",{className:"max-w-4xl mx-auto mb-3",children:[e.jsx(pm,{pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}),!Y&&e.jsx(hm,{permissionMode:l,onModeSwitch:m,provider:i,thinkingMode:d,setThinkingMode:u,tokenBudget:g,slashCommandsCount:p,onToggleCommandMenu:x,hasInput:f,onClearInput:h,isUserScrolledUp:b,hasMessages:C,onScrollToBottom:I})]}),!Y&&e.jsxs("form",{onSubmit:y,className:"relative max-w-4xl mx-auto",children:[v&&e.jsx("div",{className:"absolute inset-0 bg-primary/15 border-2 border-dashed border-primary/50 rounded-2xl flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-xl p-4 shadow-lg border border-border/30",children:[e.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"Drop images here"})]})}),A.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-muted/40 rounded-xl",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:A.map((de,$e)=>e.jsx(dm,{file:de,onRemove:()=>M($e),uploadProgress:$.get(de.name),error:k.get(de.name)},$e))})}),T&&W.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-card/95 backdrop-blur-md border border-border/50 rounded-xl shadow-lg max-h-48 overflow-y-auto z-50",children:W.map((de,$e)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-border/30 last:border-b-0 touch-manipulation ${$e===U?"bg-primary/8 text-primary":"hover:bg-accent/50 text-foreground"}`,onMouseDown:Le=>{Le.preventDefault(),Le.stopPropagation()},onClick:Le=>{Le.preventDefault(),Le.stopPropagation(),S(de)},children:[e.jsx("div",{className:"font-medium text-sm",children:de.name}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:de.path})]},de.path))}),e.jsx(Re,{commands:H,selectedIndex:w,onSelect:P,onClose:j,position:ye,isOpen:F,frequentCommands:G}),e.jsxs("div",{...X(),className:`relative bg-card/80 backdrop-blur-sm rounded-2xl shadow-sm border border-border/50 focus-within:shadow-md focus-within:border-primary/30 focus-within:ring-1 focus-within:ring-primary/15 transition-all duration-200 overflow-hidden ${re?"chat-input-expanded":""}`,children:[e.jsx("input",{...D()}),e.jsx("div",{ref:E,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-2xl",children:e.jsx("div",{className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 text-transparent text-base leading-6 whitespace-pre-wrap break-words",children:se(B)})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("textarea",{ref:J,value:B,onChange:K,onClick:V,onKeyDown:z,onPaste:O,onScroll:de=>ne(de.target),onFocus:()=>q==null?void 0:q(!0),onBlur:()=>q==null?void 0:q(!1),onInput:me,placeholder:_,disabled:n,className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-foreground placeholder-muted-foreground/50 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-base leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:oe,className:"absolute left-2 top-1/2 transform -translate-y-1/2 p-2 hover:bg-accent/60 rounded-xl transition-colors",title:je("input.attachImages"),children:e.jsx("svg",{className:"w-5 h-5 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"absolute right-[88px] sm:right-[88px] top-1/2 transform -translate-y-1/2 flex items-center gap-0.5",children:[e.jsx(ei,{onTranscript:ve,className:"w-8 h-8 sm:w-9 sm:h-9"}),e.jsx("button",{type:"button",onClick:we,className:`w-8 h-8 sm:w-9 sm:h-9 flex items-center justify-center rounded-lg transition-colors ${Ne?"text-primary hover:bg-primary/10":"text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/50"} ${Ie?"animate-pulse":""}`,title:Ne?"Disable voice output":"Enable voice output",children:Ne?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.536 8.464a5 5 0 010 7.072M18.364 5.636a9 9 0 010 12.728M11 5L6 9H2v6h4l5 4V5z"})}):e.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707A1 1 0 0112 5v14a1 1 0 01-1.707.707L5.586 15z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]})})]}),e.jsx("button",{type:"submit",disabled:!B.trim()||n,onMouseDown:de=>{de.preventDefault(),y(de)},onTouchStart:de=>{de.preventDefault(),y(de)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-10 h-10 sm:w-11 sm:h-11 bg-primary hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed rounded-xl flex items-center justify-center transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:ring-offset-1 focus:ring-offset-background",children:e.jsx("svg",{className:"w-4 h-4 sm:w-[18px] sm:h-[18px] text-primary-foreground transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-12 right-14 sm:right-40 text-xs text-muted-foreground/50 pointer-events-none hidden sm:block transition-opacity duration-200 ${B.trim()?"opacity-0":"opacity-100"}`,children:je(te?"input.hintText.ctrlEnter":"input.hintText.enter")})]})]})]})]})}function ym({selectedSession:t}){const[r,s]=c.useState("default"),[a,n]=c.useState([]),[o,i]=c.useState(()=>localStorage.getItem("selected-provider")||"claude"),[l,m]=c.useState(()=>localStorage.getItem("cursor-model")||Xo.DEFAULT),[d,u]=c.useState(()=>localStorage.getItem("claude-model")||Qo.DEFAULT),[g,p]=c.useState(()=>localStorage.getItem("codex-model")||Zo.DEFAULT),x=c.useRef(o);c.useEffect(()=>{if(!(t!=null&&t.id))return;const h=localStorage.getItem(`permissionMode-${t.id}`);s(h||"default")},[t==null?void 0:t.id]),c.useEffect(()=>{!(t!=null&&t.__provider)||t.__provider===o||(i(t.__provider),localStorage.setItem("selected-provider",t.__provider))},[o,t]),c.useEffect(()=>{x.current!==o&&(n([]),x.current=o)},[o]),c.useEffect(()=>{n(h=>h.filter(b=>!b.sessionId||b.sessionId===(t==null?void 0:t.id)))},[t==null?void 0:t.id]),c.useEffect(()=>{o==="cursor"&&Ee("/api/cursor/config").then(h=>h.json()).then(h=>{var C,I;if(!h.success||!((I=(C=h.config)==null?void 0:C.model)!=null&&I.modelId))return;const b=h.config.model.modelId;localStorage.getItem("cursor-model")||m(b)}).catch(h=>{console.error("Error loading Cursor config:",h)})},[o]);const f=c.useCallback(()=>{const h=o==="codex"?["default","acceptEdits","bypassPermissions"]:["default","acceptEdits","bypassPermissions","plan"],C=(h.indexOf(r)+1)%h.length,I=h[C];s(I),t!=null&&t.id&&localStorage.setItem(`permissionMode-${t.id}`,I)},[r,o,t==null?void 0:t.id]);return{provider:o,setProvider:i,cursorModel:l,setCursorModel:m,claudeModel:d,setClaudeModel:u,codexModel:g,setCodexModel:p,permissionMode:r,setPermissionMode:s,pendingPermissionRequests:a,setPendingPermissionRequests:n,cyclePermissionMode:f}}const vm=t=>Array.isArray(t)?t:[],Gr=t=>{if(!t)return!0;const r=t.trim();return r.startsWith("<command-name>")||r.startsWith("<command-message>")||r.startsWith("<command-args>")||r.startsWith("<local-command-stdout>")||r.startsWith("<system-reminder>")||r.startsWith("<INSTRUCTIONS>")||r.startsWith("<instructions>")||r.startsWith("Caveat:")||r.startsWith("This session is being continued from a previous")||r.startsWith("[Request interrupted")||/^#\s+AGENTS\.md instructions for/i.test(r)||r.startsWith("# AGENTS.md")||r.includes("## Skills")&&r.includes("### Available skills")||r.includes("### How to use skills")&&r.includes("Trigger rules:")||r.startsWith("A skill is a set of local instructions")||/^<system[_-]?prompt>/i.test(r)||r.startsWith("## System Information")&&r.includes("Operating System:")},Ns=t=>{if(t==null||t==="")return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}},Xs=(t,r)=>r&&(r.startsWith("/")?r:`${t}/${r}`),km=(t,r)=>{const s=t.split(`
102
+ `),a=r.split(`
103
+ `),n=Array.from({length:s.length+1},()=>new Array(a.length+1).fill(0));for(let m=s.length-1;m>=0;m-=1)for(let d=a.length-1;d>=0;d-=1)s[m]===a[d]?n[m][d]=n[m+1][d+1]+1:n[m][d]=Math.max(n[m+1][d],n[m][d+1]);const o=[];let i=0,l=0;for(;i<s.length&&l<a.length;){const m=s[i],d=a[l];if(m===d){i+=1,l+=1;continue}if(n[i+1][l]>=n[i][l+1]){o.push({type:"removed",content:m,lineNum:i+1}),i+=1;continue}o.push({type:"added",content:d,lineNum:l+1}),l+=1}for(;i<s.length;)o.push({type:"removed",content:s[i],lineNum:i+1}),i+=1;for(;l<a.length;)o.push({type:"added",content:a[l],lineNum:l+1}),l+=1;return o},wm=()=>{const t=new Map;return(r,s)=>{const a=JSON.stringify([r,s]),n=t.get(a);if(n)return n;const o=km(r,s);if(t.set(a,o),t.size>100){const i=t.keys().next().value;i&&t.delete(i)}return o}},jm=(t,r)=>{var n,o;const s=[],a={};for(let i=0;i<t.length;i+=1){const l=t[i],m=l.content;let d="",u="assistant",g=null;try{if(m!=null&&m.role&&(m!=null&&m.content)){if(m.role==="system")continue;if(m.role==="tool"){const p=vm(m.content);for(const x of p){if((x==null?void 0:x.type)!=="tool-result")continue;const f=x.toolName==="ApplyPatch"?"Edit":x.toolName||"Unknown Tool",h=x.toolCallId||m.id,b=x.result||"";h&&a[h]?a[h].toolResult={content:b,isError:!1}:s.push({type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid,isToolUse:!0,toolName:f,toolId:h,toolInput:Ns(null),toolResult:{content:b,isError:!1}})}continue}if(u=m.role==="user"?"user":"assistant",Array.isArray(m.content)){const p=[];for(const x of m.content){if((x==null?void 0:x.type)==="text"&&(x!=null&&x.text)){p.push(_t(x.text));continue}if((x==null?void 0:x.type)==="reasoning"&&(x!=null&&x.text)){g=_t(x.text);continue}if((x==null?void 0:x.type)==="tool-call"||(x==null?void 0:x.type)==="tool_use"){(p.length>0||g)&&(s.push({type:u,content:p.join(`
104
+ `),reasoning:g??void 0,timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid}),p.length=0,g=null);const f=x.toolName||x.name||"Unknown Tool",h=f==="ApplyPatch"?"Edit":f,b=x.toolCallId||x.id||`tool_${i}`;let C=x.args||x.input;if(h==="Edit"&&x.args)if(x.args.patch){const y=String(x.args.patch).split(`
105
+ `),v=[],A=[];let M=!1;y.forEach($=>{if($.startsWith("@@")){M=!0;return}M&&($.startsWith("-")?v.push($.slice(1)):$.startsWith("+")?A.push($.slice(1)):$.startsWith(" ")&&(v.push($.slice(1)),A.push($.slice(1))))}),C={file_path:Xs(r,x.args.file_path),old_string:v.join(`
106
+ `)||x.args.patch,new_string:A.join(`
107
+ `)||x.args.patch}}else C=x.args;else if(h==="Read"&&x.args){const y=x.args.path||x.args.file_path;C={file_path:Xs(r,y)}}else if(h==="Write"&&x.args){const y=x.args.path||x.args.file_path;C={file_path:Xs(r,y),content:x.args.contents||x.args.content}}const I={type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid,isToolUse:!0,toolName:h,toolId:b,toolInput:Ns(C),toolResult:null};s.push(I),a[b]=I;continue}typeof x=="string"&&p.push(x)}p.length>0?(d=p.join(`
108
+ `),g&&!d&&(s.push({type:u,content:"",reasoning:g,timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid}),d="")):d=""}else typeof m.content=="string"&&(d=m.content)}else if((n=m==null?void 0:m.message)!=null&&n.role&&((o=m==null?void 0:m.message)!=null&&o.content)){if(m.message.role==="system")continue;u=m.message.role==="user"?"user":"assistant",Array.isArray(m.message.content)?d=m.message.content.map(p=>typeof p=="string"?p:(p==null?void 0:p.text)||"").filter(Boolean).join(`
109
+ `):typeof m.message.content=="string"&&(d=m.message.content)}}catch(p){console.log("Error parsing blob content:",p)}if(d&&d.trim()&&!Gr(d)){const p={type:u,content:d,timestamp:new Date(Date.now()+i*1e3),blobId:l.id,sequence:l.sequence,rowid:l.rowid};g&&(p.reasoning=g),s.push(p)}}return s.sort((i,l)=>i.sequence!==void 0&&l.sequence!==void 0?Number(i.sequence)-Number(l.sequence):i.rowid!==void 0&&l.rowid!==void 0?Number(i.rowid)-Number(l.rowid):new Date(i.timestamp).getTime()-new Date(l.timestamp).getTime()),s},Nm=t=>{const r=[],s=new Map;return t.forEach(a=>{var n,o;((n=a.message)==null?void 0:n.role)==="user"&&Array.isArray((o=a.message)==null?void 0:o.content)&&a.message.content.forEach(i=>{i.type==="tool_result"&&s.set(i.tool_use_id,{content:i.content,isError:!!i.is_error,timestamp:new Date(a.timestamp||Date.now()),toolUseResult:a.toolUseResult||null,subagentTools:a.subagentTools})})}),t.forEach(a=>{var n,o,i,l,m,d,u;if(((n=a.message)==null?void 0:n.role)==="user"&&((o=a.message)!=null&&o.content)){let g="";if(Array.isArray(a.message.content)){const x=[];a.message.content.forEach(f=>{f.type==="text"&&x.push(_t(f.text))}),g=x.join(`
110
+ `)}else typeof a.message.content=="string"?g=_t(a.message.content):g=_t(String(a.message.content));if(!(!g||Gr(g))){const f=/<task-notification>\s*<task-id>[^<]*<\/task-id>\s*<output-file>[^<]*<\/output-file>\s*<status>([^<]*)<\/status>\s*<summary>([^<]*)<\/summary>\s*<\/task-notification>/g.exec(g);if(f){const h=((i=f[1])==null?void 0:i.trim())||"completed",b=((l=f[2])==null?void 0:l.trim())||"Background task finished";r.push({type:"assistant",content:b,timestamp:a.timestamp||new Date().toISOString(),isTaskNotification:!0,taskStatus:h})}else r.push({type:"user",content:is(g),timestamp:a.timestamp||new Date().toISOString()})}return}if(a.type==="thinking"&&((m=a.message)!=null&&m.content)){r.push({type:"assistant",content:is(a.message.content),timestamp:a.timestamp||new Date().toISOString(),isThinking:!0});return}if(a.type==="tool_use"&&a.toolName){r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:a.toolName,toolInput:Ns(a.toolInput),toolCallId:a.toolCallId});return}if(a.type==="tool_result"){for(let g=r.length-1;g>=0;g-=1){const p=r[g];if(!(!p.isToolUse||p.toolResult)&&(!a.toolCallId||p.toolCallId===a.toolCallId)){p.toolResult={content:a.output||"",isError:!1};break}}return}if(((d=a.message)==null?void 0:d.role)==="assistant"&&((u=a.message)!=null&&u.content)){if(Array.isArray(a.message.content)){a.message.content.forEach(g=>{if(g.type==="text"){let p=g.text;if(typeof p=="string"){if(Gr(p))return;p=is(p)}r.push({type:"assistant",content:p,timestamp:a.timestamp||new Date().toISOString()});return}if(g.type==="tool_use"){const p=s.get(g.id),x=g.name==="Task",f=[];if(x&&(p!=null&&p.subagentTools)&&Array.isArray(p.subagentTools))for(const h of p.subagentTools)f.push({toolId:h.toolId,toolName:h.toolName,toolInput:h.toolInput,toolResult:h.toolResult||null,timestamp:new Date(h.timestamp||Date.now())});r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:g.name,toolInput:Ns(g.input),toolId:g.id,toolResult:p?{content:typeof p.content=="string"?p.content:JSON.stringify(p.content),isError:p.isError,toolUseResult:p.toolUseResult}:null,toolError:(p==null?void 0:p.isError)||!1,toolResultTimestamp:(p==null?void 0:p.timestamp)||new Date,isSubagentContainer:x,subagentState:x?{childTools:f,currentToolIndex:f.length>0?f.length-1:-1,isComplete:!!p}:void 0})}});return}typeof a.message.content=="string"&&!Gr(a.message.content)&&r.push({type:"assistant",content:is(a.message.content),timestamp:a.timestamp||new Date().toISOString()})}}),r},Cm=20,cs=100;function Sm({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:n,externalMessageUpdate:o,processingSessions:i,resetStreamingState:l,pendingViewSessionRef:m}){const[d,u]=c.useState(()=>{if(typeof window<"u"&&t){const ge=gt.getItem(`chat_messages_${t.name}`);if(ge)try{return JSON.parse(ge)}catch{return console.error("Failed to parse saved chat messages, resetting"),gt.removeItem(`chat_messages_${t.name}`),[]}return[]}return[]}),[g,p]=c.useState(!1),[x,f]=c.useState((r==null?void 0:r.id)||null),[h,b]=c.useState([]),[C,I]=c.useState(!1),[y,v]=c.useState(!1),[A,M]=c.useState(!1),[$,k]=c.useState(0),[T,W]=c.useState(!1),[U,S]=c.useState(!1),[H,w]=c.useState(!1),[P,j]=c.useState(null),[F,G]=c.useState(cs),[X,D]=c.useState(null),[oe,E]=c.useState(!1),[se,J]=c.useState(!1),[B,K]=c.useState(!1),[V,z]=c.useState(!1),O=c.useRef(null),ne=c.useRef(!1),me=c.useRef(!1),q=c.useRef(!1),N=c.useRef(!1),_=c.useRef(null),re=c.useRef(!0),te=c.useRef(0),ve=c.useRef({height:0,top:0}),je=c.useRef(null),Ne=c.useRef(null),we=c.useMemo(()=>wm(),[]),Ie=c.useCallback(async(ge,Fe,Ce=!1,ze="claude")=>{var _e;if(!ge||!Fe)return[];const Pe=!Ce;Pe?I(!0):v(!0);try{const Ke=Ce?te.current:0,ae=await He.sessionMessages(ge,Fe,Cm,Ke,ze);if(!ae.ok)throw new Error("Failed to load session messages");const ke=await ae.json();if(Pe&&ke.tokenUsage&&j(ke.tokenUsage),ke.hasMore!==void 0){const Ue=((_e=ke.messages)==null?void 0:_e.length)||0;return M(!!ke.hasMore),k(Number(ke.total||0)),te.current=Ke+Ue,ke.messages||[]}const Be=ke.messages||[];return M(!1),k(Be.length),te.current=Be.length,Be}catch(Ke){return console.error("Error loading session messages:",Ke),[]}finally{Pe?I(!1):v(!1)}},[]),Re=c.useCallback(async(ge,Fe)=>{var Ce;if(!ge||!Fe)return[];I(!0);try{const ze=`/api/cursor/sessions/${encodeURIComponent(Fe)}?projectPath=${encodeURIComponent(ge)}`,Pe=await Ee(ze);if(!Pe.ok)return[];const _e=await Pe.json(),Ke=((Ce=_e==null?void 0:_e.session)==null?void 0:Ce.messages)||[];return jm(Ke,ge)}catch(ze){return console.error("Error loading Cursor session messages:",ze),[]}finally{I(!1)}},[]),Z=c.useMemo(()=>Nm(h),[h]),ye=c.useCallback(()=>{const ge=O.current;ge&&(ge.scrollTop=ge.scrollHeight)},[]),Y=c.useCallback(()=>{ye(),oe&&(G(cs),E(!1),q.current=!1)},[oe,ye]),ie=c.useCallback(()=>{const ge=O.current;if(!ge)return!1;const{scrollTop:Fe,scrollHeight:Ce,clientHeight:ze}=ge;return Ce-Fe-ze<50},[]),De=c.useCallback(async ge=>{if(!ge||me.current||y||q.current||!A||!r||!t)return!1;const Fe=r.__provider||"claude";if(Fe==="cursor")return!1;me.current=!0;const Ce=ge.scrollHeight,ze=ge.scrollTop;try{const Pe=await Ie(t.name,r.id,!0,Fe);return Pe.length===0?!1:(_.current={height:Ce,top:ze},b(_e=>[...Pe,..._e]),G(_e=>_e+Pe.length),!0)}finally{me.current=!1}},[A,y,Ie,t,r]),de=c.useCallback(async()=>{const ge=O.current;if(!ge)return;const Fe=ie();if(w(!Fe),!q.current){if(!(ge.scrollTop<100)){N.current=!1;return}if(N.current){ge.scrollTop>20&&(N.current=!1);return}await De(ge)&&(N.current=!0)}},[ie,De]);c.useLayoutEffect(()=>{if(!_.current||!O.current)return;const{height:ge,top:Fe}=_.current,Ce=O.current,Pe=Ce.scrollHeight-ge;Ce.scrollTop=Fe+Math.max(Pe,0),_.current=null},[d.length]),c.useEffect(()=>{re.current=!0,N.current=!1,_.current=null,G(cs),w(!1)},[t==null?void 0:t.name,r==null?void 0:r.id]),c.useEffect(()=>{if(!(!re.current||!O.current||C)){if(d.length===0){re.current=!1;return}re.current=!1,setTimeout(()=>{ye()},200)}},[d.length,C,ye]),c.useEffect(()=>{(async()=>{if(r&&t){const Fe=localStorage.getItem("selected-provider")||"claude";if(ne.current=!0,x!==null&&x!==r.id?(T||(l(),m.current=null,u([]),b([]),D(null),S(!1)),te.current=0,M(!1),k(0),G(cs),E(!1),q.current=!1,J(!1),K(!1),z(!1),Ne.current&&clearTimeout(Ne.current),je.current&&clearTimeout(je.current),j(null),p(!1),s&&a({type:"check-session-status",sessionId:r.id,provider:Fe})):x===null&&(te.current=0,M(!1),k(0),s&&a({type:"check-session-status",sessionId:r.id,provider:Fe})),Fe==="cursor")if(f(r.id),sessionStorage.setItem("cursorSessionId",r.id),T)W(!1);else{const ze=t.fullPath||t.path||"",Pe=await Re(ze,r.id);b([]),u(Pe)}else if(f(r.id),T)W(!1);else{const ze=await Ie(t.name,r.id,!1,r.__provider||"claude");b(ze)}}else T||(l(),m.current=null,u([]),b([]),D(null),S(!1),p(!1)),f(null),sessionStorage.removeItem("cursorSessionId"),te.current=0,M(!1),k(0),j(null);setTimeout(()=>{ne.current=!1},250)})()},[T,Re,Ie,m,l,t,r,a,s]),c.useEffect(()=>{if(!o||!r||!t)return;(async()=>{try{if((localStorage.getItem("selected-provider")||"claude")==="cursor"){const Pe=t.fullPath||t.path||"",_e=await Re(Pe,r.id);b([]),u(_e);return}const Ce=await Ie(t.name,r.id,!1,r.__provider||"claude");b(Ce),!!n&&ie()&&setTimeout(()=>ye(),200)}catch(Fe){console.error("Error reloading messages from external update:",Fe)}})()},[n,o,ie,Re,Ie,ye,t,r]),c.useEffect(()=>{r!=null&&r.id&&(m.current=null)},[m,r==null?void 0:r.id]),c.useEffect(()=>{h.length>0&&u(Z)},[Z,h.length]),c.useEffect(()=>{t&&d.length>0&&gt.setItem(`chat_messages_${t.name}`,JSON.stringify(d))},[d,t]),c.useEffect(()=>{if(!t||!(r!=null&&r.id)||r.id.startsWith("new-session-")){j(null);return}if((r.__provider||"claude")!=="claude")return;(async()=>{try{const Ce=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,ze=await Ee(Ce);if(ze.ok){const Pe=await ze.json();j(Pe)}else j(null)}catch(Ce){console.error("Failed to fetch initial token usage:",Ce)}})()},[t,r==null?void 0:r.id,r==null?void 0:r.__provider]);const $e=c.useMemo(()=>d.length<=F?d:d.slice(-F),[d,F]);c.useEffect(()=>{if(!n&&O.current){const ge=O.current;ve.current={height:ge.scrollHeight,top:ge.scrollTop}}}),c.useEffect(()=>{if(!O.current||d.length===0||me.current||y||_.current)return;if(n){H||setTimeout(()=>ye(),50);return}const ge=O.current,Fe=ve.current.height,Ce=ve.current.top,Pe=ge.scrollHeight-Fe;Pe>0&&Ce>0&&(ge.scrollTop=Ce+Pe)},[n,d.length,y,H,ye]),c.useEffect(()=>{const ge=O.current;if(ge)return ge.addEventListener("scroll",de),()=>ge.removeEventListener("scroll",de)},[de]),c.useEffect(()=>{const ge=(r==null?void 0:r.id)||x;if(!ge||!i)return;i.has(ge)&&!g&&(p(!0),S(!0))},[x,g,i,r==null?void 0:r.id]);const Le=c.useRef(!1);c.useEffect(()=>{const ge=Le.current;return Le.current=y,ge&&!y&&A&&(Ne.current&&clearTimeout(Ne.current),z(!0),Ne.current=setTimeout(()=>{z(!1)},2e3)),!A&&!y&&(Ne.current&&clearTimeout(Ne.current),z(!1)),()=>{Ne.current&&clearTimeout(Ne.current)}},[y,A]);const Je=c.useCallback(async()=>{if(!r||!t||se)return;const ge=r.__provider||"claude";if(ge==="cursor"){G(1/0),E(!0),q.current=!0,K(!0),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{K(!1),z(!1)},1e3);return}const Fe=r.id;q.current=!0,me.current=!0,J(!0),z(!0);const Ce=O.current,ze=Ce?Ce.scrollHeight:0,Pe=Ce?Ce.scrollTop:0;try{const _e=await He.sessionMessages(t.name,Fe,null,0,ge);if(x!==Fe)return;if(_e.ok){const Ke=await _e.json(),ae=Ke.messages||Ke;Ce&&(_.current={height:ze,top:Pe}),b(Array.isArray(ae)?ae:[]),M(!1),k(Array.isArray(ae)?ae.length:0),te.current=Array.isArray(ae)?ae.length:0,G(1/0),E(!0),K(!0),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{K(!1),z(!1)},1e3)}else q.current=!1,z(!1)}catch(_e){console.error("Error loading all messages:",_e),q.current=!1,z(!1)}finally{me.current=!1,J(!1)}},[r,t,se,x]),Ve=c.useCallback(()=>{G(ge=>ge+100)},[]);return{chatMessages:d,setChatMessages:u,isLoading:g,setIsLoading:p,currentSessionId:x,setCurrentSessionId:f,sessionMessages:h,setSessionMessages:b,isLoadingSessionMessages:C,isLoadingMoreMessages:y,hasMoreMessages:A,totalMessages:$,isSystemSessionChange:T,setIsSystemSessionChange:W,canAbortSession:U,setCanAbortSession:S,isUserScrolledUp:H,setIsUserScrolledUp:w,tokenBudget:P,setTokenBudget:j,visibleMessageCount:F,visibleMessages:$e,loadEarlierMessages:Ve,loadAllMessages:Je,allMessagesLoaded:oe,isLoadingAllMessages:se,loadAllJustFinished:B,showLoadAllOverlay:V,claudeStatus:X,setClaudeStatus:D,createDiff:we,scrollContainerRef:O,scrollToBottom:ye,scrollToBottomAndReset:Y,isNearBottom:ie,handleScroll:de,loadSessionMessages:Ie,loadCursorSessionMessages:Re}}const ds=(t,r,s=!1)=>{r&&t(a=>{const n=[...a],o=n.length-1,i=n[o];if(i&&i.type==="assistant"&&!i.isToolUse&&i.isStreaming){const l=s?i.content?`${i.content}
111
+ ${r}`:r:`${i.content||""}${r}`;n[o]={...i,content:l}}else n.push({type:"assistant",content:r,timestamp:new Date,isStreaming:!0});return n})},Em=t=>{t(r=>{const s=[...r],a=s.length-1,n=s[a];return n&&n.type==="assistant"&&n.isStreaming&&(s[a]={...n,isStreaming:!1}),s})};function Tm({latestMessage:t,provider:r,selectedProject:s,selectedSession:a,currentSessionId:n,setCurrentSessionId:o,setChatMessages:i,setIsLoading:l,setCanAbortSession:m,setClaudeStatus:d,setTokenBudget:u,setIsSystemSessionChange:g,setPendingPermissionRequests:p,pendingViewSessionRef:x,streamBufferRef:f,streamTimerRef:h,onSessionInactive:b,onSessionProcessing:C,onSessionNotProcessing:I,onReplaceTemporarySession:y,onNavigateToSession:v,onResponseComplete:A}){const M=c.useRef(null);c.useEffect(()=>{var J,B,K,V,z,O,ne,me,q;if(!t||M.current===t)return;M.current=t;const $=((J=t.data)==null?void 0:J.message)||t.data,k=$&&typeof $=="object"?$:null,T=t.data&&typeof t.data=="object"?t.data:null,U=["projects_updated","taskmaster-project-updated","session-created"].includes(String(t.type)),S=new Set(["claude-complete","codex-complete","cursor-result","session-aborted","claude-error","cursor-error","codex-error"]),H=t.type==="claude-response"&&k&&k.type==="system"&&k.subtype==="init",w=t.type==="cursor-system"&&T&&T.type==="system"&&T.subtype==="init",P=H?k==null?void 0:k.session_id:w?T==null?void 0:T.session_id:null,j=(a==null?void 0:a.id)||n||((B=x.current)==null?void 0:B.sessionId)||null,F=P&&(!j||P===j),G=U||!!F,X=!t.sessionId&&x.current&&!x.current.sessionId&&(t.type==="claude-error"||t.type==="cursor-error"||t.type==="codex-error"),D=N=>{N&&(b==null||b(N),I==null||I(N))},oe=(...N)=>Array.from(new Set(N.filter(_=>typeof _=="string"&&_.length>0))),E=()=>{l(!1),m(!1),d(null)},se=(...N)=>{oe(...N).forEach(re=>{b==null||b(re),I==null||I(re)})};if(!G){if(!j&&(t.sessionId&&S.has(String(t.type))&&D(t.sessionId),!X)||!t.sessionId&&!X)return;if(t.sessionId!==j){t.sessionId&&S.has(String(t.type))&&D(t.sessionId),console.log("Skipping message for different session:",t.sessionId,"current:",j);return}}switch(t.type){case"session-created":t.sessionId&&!n&&(sessionStorage.setItem("pendingSessionId",t.sessionId),x.current&&!x.current.sessionId&&(x.current.sessionId=t.sessionId),g(!0),y==null||y(t.sessionId),p(N=>N.map(_=>_.sessionId?_:{..._,sessionId:t.sessionId})));break;case"token-budget":t.data&&u(t.data);break;case"claude-response":{if($&&typeof $=="object"&&$.type){if($.type==="content_block_delta"&&((K=$.delta)!=null&&K.text)){const N=_t($.delta.text);f.current+=N,h.current||(h.current=window.setTimeout(()=>{const _=f.current;f.current="",h.current=null,ds(i,_,!1)},100));return}if($.type==="content_block_stop"){h.current&&(clearTimeout(h.current),h.current=null);const N=f.current;f.current="",ds(i,N,!1),Em(i);return}}if((k==null?void 0:k.type)==="system"&&k.subtype==="init"&&k.session_id&&n&&k.session_id!==n&&F){console.log("Claude CLI session duplication detected:",{originalSession:n,newSession:k.session_id}),g(!0),v==null||v(k.session_id);return}if((k==null?void 0:k.type)==="system"&&k.subtype==="init"&&k.session_id&&!n&&F){console.log("New session init detected:",{newSession:k.session_id}),g(!0),v==null||v(k.session_id);return}if((k==null?void 0:k.type)==="system"&&k.subtype==="init"&&k.session_id&&n&&k.session_id===n&&F){console.log("System init message for current session, ignoring");return}if(k&&Array.isArray(k.content)){const N=T==null?void 0:T.parentToolUseId;k.content.forEach(_=>{var re;if(_.type==="tool_use"){const te=_.input?JSON.stringify(_.input,null,2):"";if(N){i(je=>je.map(Ne=>{var we;if(Ne.toolId===N&&Ne.isSubagentContainer){const Ie={toolId:_.id,toolName:_.name,toolInput:_.input,toolResult:null,timestamp:new Date},Re=((we=Ne.subagentState)==null?void 0:we.childTools)||[];return{...Ne,subagentState:{childTools:[...Re,Ie],currentToolIndex:Re.length,isComplete:!1}}}return Ne}));return}const ve=_.name==="Task";i(je=>[...je,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:_.name,toolInput:te,toolId:_.id,toolResult:null,isSubagentContainer:ve,subagentState:ve?{childTools:[],currentToolIndex:-1,isComplete:!1}:void 0}]);return}if(_.type==="text"&&((re=_.text)!=null&&re.trim())){let te=_t(_.text);te=xa(te),i(ve=>[...ve,{type:"assistant",content:te,timestamp:new Date}])}})}else if(k&&typeof k.content=="string"&&k.content.trim()){let N=_t(k.content);N=xa(N),i(_=>[..._,{type:"assistant",content:N,timestamp:new Date}])}if((k==null?void 0:k.role)==="user"&&Array.isArray(k.content)){const N=T==null?void 0:T.parentToolUseId;k.content.forEach(_=>{_.type==="tool_result"&&i(re=>re.map(te=>{if(N&&te.toolId===N&&te.isSubagentContainer)return{...te,subagentState:{...te.subagentState,childTools:te.subagentState.childTools.map(ve=>ve.toolId===_.tool_use_id?{...ve,toolResult:{content:_.content,isError:_.is_error,timestamp:new Date}}:ve)}};if(te.isToolUse&&te.toolId===_.tool_use_id){const ve={...te,toolResult:{content:_.content,isError:_.is_error,timestamp:new Date}};return te.isSubagentContainer&&te.subagentState&&(ve.subagentState={...te.subagentState,isComplete:!0}),ve}return te}))})}break}case"claude-output":{const N=String(t.data||"");N.trim()&&(f.current+=f.current?`
112
+ ${N}`:N,h.current||(h.current=window.setTimeout(()=>{const _=f.current;f.current="",h.current=null,ds(i,_,!0)},100)));break}case"claude-interactive-prompt":{const N=typeof t.data=="string"?t.data:JSON.stringify(t.data??"",null,2);i(_=>[..._,{type:"assistant",content:N,timestamp:new Date,isInteractivePrompt:!0}])}break;case"claude-permission-request":if(r!=="claude"||!t.requestId)break;{const N=t.requestId;p(_=>_.some(re=>re.requestId===N)?_:[..._,{requestId:N,toolName:t.toolName||"UnknownTool",input:t.input,context:t.context,sessionId:t.sessionId||null,receivedAt:new Date}])}l(!0),m(!0),d({text:"Waiting for permission",tokens:0,can_interrupt:!0});break;case"claude-permission-cancelled":if(!t.requestId)break;p(N=>N.filter(_=>_.requestId!==t.requestId));break;case"claude-error":i(N=>[...N,{type:"error",content:`Error: ${t.error}`,timestamp:new Date}]);break;case"cursor-system":try{const N=t.data;if(N&&N.type==="system"&&N.subtype==="init"&&N.session_id){if(!F)return;if(n&&N.session_id!==n){console.log("Cursor session switch detected:",{originalSession:n,newSession:N.session_id}),g(!0),v==null||v(N.session_id);return}if(!n){console.log("Cursor new session init detected:",{newSession:N.session_id}),g(!0),v==null||v(N.session_id);return}}}catch(N){console.warn("Error handling cursor-system message:",N)}break;case"cursor-user":break;case"cursor-tool-use":i(N=>[...N,{type:"assistant",content:`Using tool: ${t.tool} ${t.input?`with ${t.input}`:""}`,timestamp:new Date,isToolUse:!0,toolName:t.tool,toolInput:t.input}]);break;case"cursor-error":i(N=>[...N,{type:"error",content:`Cursor error: ${t.error||"Unknown error"}`,timestamp:new Date}]);break;case"cursor-result":{const N=t.sessionId||n,_=sessionStorage.getItem("pendingSessionId");E(),se(N,n,a==null?void 0:a.id,_);try{const re=t.data||{},te=typeof re.result=="string"?re.result:"";h.current&&(clearTimeout(h.current),h.current=null);const ve=f.current;f.current="",i(je=>{const Ne=[...je],we=Ne.length-1,Ie=Ne[we];if(Ie&&Ie.type==="assistant"&&!Ie.isToolUse&&Ie.isStreaming){const Re=te&&te.trim()?te:`${Ie.content||""}${ve||""}`;Ne[we]={...Ie,content:Re,isStreaming:!1}}else te&&te.trim()&&Ne.push({type:re.is_error?"error":"assistant",content:te,timestamp:new Date,isStreaming:!1});return Ne})}catch(re){console.warn("Error handling cursor-result message:",re)}N&&!n&&N===_&&(o(N),sessionStorage.removeItem("pendingSessionId"),window.refreshProjects&&setTimeout(()=>{var re;return(re=window.refreshProjects)==null?void 0:re.call(window)},500));break}case"cursor-output":try{const _=String(t.data??"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").trim();_&&(f.current+=f.current?`
113
+ ${_}`:_,h.current||(h.current=window.setTimeout(()=>{const re=f.current;f.current="",h.current=null,ds(i,re,!0)},100)))}catch(N){console.warn("Error handling cursor-output message:",N)}break;case"claude-complete":{const N=sessionStorage.getItem("pendingSessionId"),_=t.sessionId||n||N;E(),se(_,n,a==null?void 0:a.id,N),N&&!n&&t.exitCode===0&&(o(N),sessionStorage.removeItem("pendingSessionId"),console.log("New session complete, ID set to:",N)),s&&t.exitCode===0&&gt.removeItem(`chat_messages_${s.name}`),p([]),A&&i(re=>{for(let te=re.length-1;te>=0;te--)if(re[te].type==="assistant"&&re[te].content&&!re[te].isToolUse){A(re[te].content);break}return re});break}case"codex-response":{const N=t.data;if(!N)break;if(N.type==="item")switch(N.itemType){case"agent_message":if((z=(V=N.message)==null?void 0:V.content)!=null&&z.trim()){const _=_t(N.message.content);Gr(_)||i(re=>[...re,{type:"assistant",content:_,timestamp:new Date}])}break;case"reasoning":if((ne=(O=N.message)==null?void 0:O.content)!=null&&ne.trim()){const _=_t(N.message.content);i(re=>[...re,{type:"assistant",content:_,timestamp:new Date,isThinking:!0}])}break;case"command_execution":N.command&&i(_=>[..._,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:N.command,toolResult:N.output||null,exitCode:N.exitCode}]);break;case"file_change":if(((me=N.changes)==null?void 0:me.length)>0){const _=N.changes.map(re=>`${re.kind}: ${re.path}`).join(`
114
+ `);i(re=>[...re,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:_,toolResult:{content:`Status: ${N.status}`,isError:!1}}])}break;case"mcp_tool_call":i(_=>{var re;return[..._,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${N.server}:${N.tool}`,toolInput:JSON.stringify(N.arguments,null,2),toolResult:N.result?JSON.stringify(N.result,null,2):((re=N.error)==null?void 0:re.message)||null}]});break;case"error":(q=N.message)!=null&&q.content&&i(_=>[..._,{type:"error",content:N.message.content,timestamp:new Date}]);break;default:console.log("[Codex] Unhandled item type:",N.itemType,N)}N.type==="turn_complete"&&(E(),se(t.sessionId,n,a==null?void 0:a.id)),N.type==="turn_failed"&&(E(),se(t.sessionId,n,a==null?void 0:a.id),i(_=>{var re;return[..._,{type:"error",content:((re=N.error)==null?void 0:re.message)||"Turn failed",timestamp:new Date}]}));break}case"codex-complete":{const N=sessionStorage.getItem("pendingSessionId"),_=t.actualSessionId||N,re=t.sessionId||n||N;E(),se(re,_,n,a==null?void 0:a.id,N),N&&!n&&(o(_),g(!0),_&&(v==null||v(_)),sessionStorage.removeItem("pendingSessionId"),console.log("Codex session complete, ID set to:",N)),s&&gt.removeItem(`chat_messages_${s.name}`);break}case"codex-error":l(!1),m(!1),i(N=>[...N,{type:"error",content:t.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{const N=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,_=t.sessionId||n;t.success!==!1?(E(),se(_,n,a==null?void 0:a.id,N),N&&(!_||N===_)&&sessionStorage.removeItem("pendingSessionId"),p([]),i(te=>[...te,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}])):i(te=>[...te,{type:"error",content:"Stop request failed. The session is still running.",timestamp:new Date}]);break}case"session-status":{const N=t.sessionId;(N===n||a&&N===a.id)&&t.isProcessing&&(l(!0),m(!0),C==null||C(N));break}case"claude-status":{const N=t.data;if(!N)break;const _={text:"Working...",tokens:0,can_interrupt:!0};N.message?_.text=N.message:N.status?_.text=N.status:typeof N=="string"&&(_.text=N),N.tokens?_.tokens=N.tokens:N.token_count&&(_.tokens=N.token_count),N.can_interrupt!==void 0&&(_.can_interrupt=N.can_interrupt),d(_),l(!0),m(_.can_interrupt);break}}},[t,r,s,a,n,o,i,l,m,d,u,g,p,b,C,I,y,v])}var Zs={exports:{}},ea,Sn;function Im(){if(Sn)return ea;Sn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ea=t,ea}var ta,En;function Am(){if(En)return ta;En=1;var t=Im();function r(){}function s(){}return s.resetWarningCache=r,ta=function(){function a(i,l,m,d,u,g){if(g!==t){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}a.isRequired=a;function n(){return a}var o={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:n,element:a,elementType:a,instanceOf:n,node:a,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:s,resetWarningCache:r};return o.PropTypes=o,o},ta}var Tn;function Dm(){return Tn||(Tn=1,Zs.exports=Am()()),Zs.exports}var Mm=Dm();const Ye=lo(Mm);var In=function(){return In=Object.assign||function(r){for(var s,a=1,n=arguments.length;a<n;a++){s=arguments[a];for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])}return r},In.apply(this,arguments)};function $x(t,r){var s={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(t);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(t,a[n])&&(s[a[n]]=t[a[n]]);return s}function xr(t,r,s,a){function n(o){return o instanceof s?o:new s(function(i){i(o)})}return new(s||(s=Promise))(function(o,i){function l(u){try{d(a.next(u))}catch(g){i(g)}}function m(u){try{d(a.throw(u))}catch(g){i(g)}}function d(u){u.done?o(u.value):n(u.value).then(l,m)}d((a=a.apply(t,r||[])).next())})}function Lx(t,r,s){if(s||arguments.length===2)for(var a=0,n=r.length,o;a<n;a++)(o||!(a in r))&&(o||(o=Array.prototype.slice.call(r,0,a)),o[a]=r[a]);return t.concat(o||Array.prototype.slice.call(r))}const $m=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function Tr(t,r,s){const a=Lm(t),{webkitRelativePath:n}=t,o=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof a.path!="string"&&An(a,"path",o),An(a,"relativePath",o),a}function Lm(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const a=r.split(".").pop().toLowerCase(),n=$m.get(a);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function An(t,r,s){Object.defineProperty(t,r,{value:s,writable:!1,configurable:!1,enumerable:!0})}const Fm=[".DS_Store","Thumbs.db"];function Pm(t){return xr(this,void 0,void 0,function*(){return Cs(t)&&_m(t.dataTransfer)?Bm(t.dataTransfer,t.type):zm(t)?Om(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Rm(t):[]})}function _m(t){return Cs(t)}function zm(t){return Cs(t)&&Cs(t.target)}function Cs(t){return typeof t=="object"&&t!==null}function Om(t){return fa(t.target.files).map(r=>Tr(r))}function Rm(t){return xr(this,void 0,void 0,function*(){return(yield Promise.all(t.map(s=>s.getFile()))).map(s=>Tr(s))})}function Bm(t,r){return xr(this,void 0,void 0,function*(){if(t.items){const s=fa(t.items).filter(n=>n.kind==="file");if(r!=="drop")return s;const a=yield Promise.all(s.map(Wm));return Dn(ai(a))}return Dn(fa(t.files).map(s=>Tr(s)))})}function Dn(t){return t.filter(r=>Fm.indexOf(r.name)===-1)}function fa(t){if(t===null)return[];const r=[];for(let s=0;s<t.length;s++){const a=t[s];r.push(a)}return r}function Wm(t){if(typeof t.webkitGetAsEntry!="function")return Mn(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?ni(r):Mn(t,r)}function ai(t){return t.reduce((r,s)=>[...r,...Array.isArray(s)?ai(s):[s]],[])}function Mn(t,r){return xr(this,void 0,void 0,function*(){var s;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const o=yield t.getAsFileSystemHandle();if(o===null)throw new Error(`${t} is not a File`);if(o!==void 0){const i=yield o.getFile();return i.handle=o,Tr(i)}}const a=t.getAsFile();if(!a)throw new Error(`${t} is not a File`);return Tr(a,(s=r==null?void 0:r.fullPath)!==null&&s!==void 0?s:void 0)})}function Um(t){return xr(this,void 0,void 0,function*(){return t.isDirectory?ni(t):Hm(t)})}function ni(t){const r=t.createReader();return new Promise((s,a)=>{const n=[];function o(){r.readEntries(i=>xr(this,void 0,void 0,function*(){if(i.length){const l=Promise.all(i.map(Um));n.push(l),o()}else try{const l=yield Promise.all(n);s(l)}catch(l){a(l)}}),i=>{a(i)})}o()})}function Hm(t){return xr(this,void 0,void 0,function*(){return new Promise((r,s)=>{t.file(a=>{const n=Tr(a,t.fullPath);r(n)},a=>{s(a)})})})}var ms={},$n;function Gm(){return $n||($n=1,ms.__esModule=!0,ms.default=function(t,r){if(t&&r){var s=Array.isArray(r)?r:r.split(",");if(s.length===0)return!0;var a=t.name||"",n=(t.type||"").toLowerCase(),o=n.replace(/\/.*$/,"");return s.some(function(i){var l=i.trim().toLowerCase();return l.charAt(0)==="."?a.toLowerCase().endsWith(l):l.endsWith("/*")?o===l.replace(/\/.*$/,""):n===l})}return!0}),ms}var qm=Gm();const ra=lo(qm);function Ln(t){return Jm(t)||Vm(t)||ii(t)||Km()}function Km(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
115
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vm(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Jm(t){if(Array.isArray(t))return ba(t)}function Fn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Pn(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Fn(Object(s),!0).forEach(function(a){oi(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Fn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function oi(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Jr(t,r){return Xm(t)||Qm(t,r)||ii(t,r)||Ym()}function Ym(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
116
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ii(t,r){if(t){if(typeof t=="string")return ba(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return ba(t,r)}}function ba(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function Qm(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,l;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(m){o=!0,l=m}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw l}}return a}}function Xm(t){if(Array.isArray(t))return t}var Zm=typeof ra=="function"?ra:ra.default,eu="file-invalid-type",tu="file-too-large",ru="file-too-small",su="too-many-files",au=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",s=r.split(","),a=s.length>1?"one of ".concat(s.join(", ")):s[0];return{code:eu,message:"File type must be ".concat(a)}},_n=function(r){return{code:tu,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},zn=function(r){return{code:ru,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},nu={code:su,message:"Too many files"};function ou(t){return t.type===""&&typeof t.getAsFile=="function"}function li(t,r){var s=t.type==="application/x-moz-file"||Zm(t,r)||ou(t);return[s,s?null:au(r)]}function ci(t,r,s){if(ir(t.size))if(ir(r)&&ir(s)){if(t.size>s)return[!1,_n(s)];if(t.size<r)return[!1,zn(r)]}else{if(ir(r)&&t.size<r)return[!1,zn(r)];if(ir(s)&&t.size>s)return[!1,_n(s)]}return[!0,null]}function ir(t){return t!=null}function iu(t){var r=t.files,s=t.accept,a=t.minSize,n=t.maxSize,o=t.multiple,i=t.maxFiles,l=t.validator;return!o&&r.length>1||o&&i>=1&&r.length>i?!1:r.every(function(m){var d=li(m,s),u=Jr(d,1),g=u[0],p=ci(m,a,n),x=Jr(p,1),f=x[0],h=l?l(m):null;return g&&f&&!h})}function Ss(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function Or(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!t.target&&!!t.target.files}function On(t){t.preventDefault()}function lu(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function cu(t){return t.indexOf("Edge/")!==-1}function du(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return lu(t)||cu(t)}function $t(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return function(a){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.some(function(l){return!Ss(a)&&l&&l.apply(void 0,[a].concat(o)),Ss(a)})}}function mu(){return"showOpenFilePicker"in window}function uu(t){if(ir(t)){var r=Object.entries(t).filter(function(s){var a=Jr(s,2),n=a[0],o=a[1],i=!0;return di(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(o)||!o.every(mi))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(s,a){var n=Jr(a,2),o=n[0],i=n[1];return Pn(Pn({},s),{},oi({},o,i))},{});return[{description:"Files",accept:r}]}return t}function pu(t){if(ir(t))return Object.entries(t).reduce(function(r,s){var a=Jr(s,2),n=a[0],o=a[1];return[].concat(Ln(r),[n],Ln(o))},[]).filter(function(r){return di(r)||mi(r)}).join(",")}function xu(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function gu(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function di(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function mi(t){return/^.*\.[\w]+$/.test(t)}var hu=["children"],fu=["open"],bu=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],yu=["refKey","onChange","onClick"];function Rn(t){return wu(t)||ku(t)||ui(t)||vu()}function vu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
117
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ku(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function wu(t){if(Array.isArray(t))return ya(t)}function sa(t,r){return Cu(t)||Nu(t,r)||ui(t,r)||ju()}function ju(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
118
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ui(t,r){if(t){if(typeof t=="string")return ya(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return ya(t,r)}}function ya(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function Nu(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,l;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(m){o=!0,l=m}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw l}}return a}}function Cu(t){if(Array.isArray(t))return t}function Bn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function rt(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Bn(Object(s),!0).forEach(function(a){va(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Bn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function va(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function Es(t,r){if(t==null)return{};var s=Su(t,r),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(s[a]=t[a])}return s}function Su(t,r){if(t==null)return{};var s={},a=Object.keys(t),n,o;for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&(s[n]=t[n]);return s}var Wa=c.forwardRef(function(t,r){var s=t.children,a=Es(t,hu),n=xi(a),o=n.open,i=Es(n,fu);return c.useImperativeHandle(r,function(){return{open:o}},[o]),Ft.createElement(c.Fragment,null,s(rt(rt({},i),{},{open:o})))});Wa.displayName="Dropzone";var pi={disabled:!1,getFilesFromEvent:Pm,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};Wa.defaultProps=pi;Wa.propTypes={children:Ye.func,accept:Ye.objectOf(Ye.arrayOf(Ye.string)),multiple:Ye.bool,preventDropOnDocument:Ye.bool,noClick:Ye.bool,noKeyboard:Ye.bool,noDrag:Ye.bool,noDragEventsBubbling:Ye.bool,minSize:Ye.number,maxSize:Ye.number,maxFiles:Ye.number,disabled:Ye.bool,getFilesFromEvent:Ye.func,onFileDialogCancel:Ye.func,onFileDialogOpen:Ye.func,useFsAccessApi:Ye.bool,autoFocus:Ye.bool,onDragEnter:Ye.func,onDragLeave:Ye.func,onDragOver:Ye.func,onDrop:Ye.func,onDropAccepted:Ye.func,onDropRejected:Ye.func,onError:Ye.func,validator:Ye.func};var ka={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function xi(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=rt(rt({},pi),t),s=r.accept,a=r.disabled,n=r.getFilesFromEvent,o=r.maxSize,i=r.minSize,l=r.multiple,m=r.maxFiles,d=r.onDragEnter,u=r.onDragLeave,g=r.onDragOver,p=r.onDrop,x=r.onDropAccepted,f=r.onDropRejected,h=r.onFileDialogCancel,b=r.onFileDialogOpen,C=r.useFsAccessApi,I=r.autoFocus,y=r.preventDropOnDocument,v=r.noClick,A=r.noKeyboard,M=r.noDrag,$=r.noDragEventsBubbling,k=r.onError,T=r.validator,W=c.useMemo(function(){return pu(s)},[s]),U=c.useMemo(function(){return uu(s)},[s]),S=c.useMemo(function(){return typeof b=="function"?b:Wn},[b]),H=c.useMemo(function(){return typeof h=="function"?h:Wn},[h]),w=c.useRef(null),P=c.useRef(null),j=c.useReducer(Eu,ka),F=sa(j,2),G=F[0],X=F[1],D=G.isFocused,oe=G.isFileDialogActive,E=c.useRef(typeof window<"u"&&window.isSecureContext&&C&&mu()),se=function(){!E.current&&oe&&setTimeout(function(){if(P.current){var ie=P.current.files;ie.length||(X({type:"closeDialog"}),H())}},300)};c.useEffect(function(){return window.addEventListener("focus",se,!1),function(){window.removeEventListener("focus",se,!1)}},[P,oe,H,E]);var J=c.useRef([]),B=c.useRef([]),K=function(ie){w.current&&w.current.contains(ie.target)||(ie.preventDefault(),J.current=[])};c.useEffect(function(){return y&&(document.addEventListener("dragover",On,!1),document.addEventListener("drop",K,!1)),function(){y&&(document.removeEventListener("dragover",On),document.removeEventListener("drop",K))}},[w,y]),c.useEffect(function(){var Y=function(Le){B.current=[].concat(Rn(B.current),[Le.target]),Or(Le)&&X({isDragGlobal:!0,type:"setDragGlobal"})},ie=function(Le){B.current=B.current.filter(function(Je){return Je!==Le.target&&Je!==null}),!(B.current.length>0)&&X({isDragGlobal:!1,type:"setDragGlobal"})},De=function(){B.current=[],X({isDragGlobal:!1,type:"setDragGlobal"})},de=function(){B.current=[],X({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",Y,!1),document.addEventListener("dragleave",ie,!1),document.addEventListener("dragend",De,!1),document.addEventListener("drop",de,!1),function(){document.removeEventListener("dragenter",Y),document.removeEventListener("dragleave",ie),document.removeEventListener("dragend",De),document.removeEventListener("drop",de)}},[w]),c.useEffect(function(){return!a&&I&&w.current&&w.current.focus(),function(){}},[w,I,a]);var V=c.useCallback(function(Y){k?k(Y):console.error(Y)},[k]),z=c.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ie(Y),J.current=[].concat(Rn(J.current),[Y.target]),Or(Y)&&Promise.resolve(n(Y)).then(function(ie){if(!(Ss(Y)&&!$)){var De=ie.length,de=De>0&&iu({files:ie,accept:W,minSize:i,maxSize:o,multiple:l,maxFiles:m,validator:T}),$e=De>0&&!de;X({isDragAccept:de,isDragReject:$e,isDragActive:!0,type:"setDraggedFiles"}),d&&d(Y)}}).catch(function(ie){return V(ie)})},[n,d,V,$,W,i,o,l,m,T]),O=c.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ie(Y);var ie=Or(Y);if(ie&&Y.dataTransfer)try{Y.dataTransfer.dropEffect="copy"}catch{}return ie&&g&&g(Y),!1},[g,$]),ne=c.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ie(Y);var ie=J.current.filter(function(de){return w.current&&w.current.contains(de)}),De=ie.indexOf(Y.target);De!==-1&&ie.splice(De,1),J.current=ie,!(ie.length>0)&&(X({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Or(Y)&&u&&u(Y))},[w,u,$]),me=c.useCallback(function(Y,ie){var De=[],de=[];Y.forEach(function($e){var Le=li($e,W),Je=sa(Le,2),Ve=Je[0],ge=Je[1],Fe=ci($e,i,o),Ce=sa(Fe,2),ze=Ce[0],Pe=Ce[1],_e=T?T($e):null;if(Ve&&ze&&!_e)De.push($e);else{var Ke=[ge,Pe];_e&&(Ke=Ke.concat(_e)),de.push({file:$e,errors:Ke.filter(function(ae){return ae})})}}),(!l&&De.length>1||l&&m>=1&&De.length>m)&&(De.forEach(function($e){de.push({file:$e,errors:[nu]})}),De.splice(0)),X({acceptedFiles:De,fileRejections:de,isDragReject:de.length>0,type:"setFiles"}),p&&p(De,de,ie),de.length>0&&f&&f(de,ie),De.length>0&&x&&x(De,ie)},[X,l,W,i,o,m,p,x,f,T]),q=c.useCallback(function(Y){Y.preventDefault(),Y.persist(),Ie(Y),J.current=[],Or(Y)&&Promise.resolve(n(Y)).then(function(ie){Ss(Y)&&!$||me(ie,Y)}).catch(function(ie){return V(ie)}),X({type:"reset"})},[n,me,V,$]),N=c.useCallback(function(){if(E.current){X({type:"openDialog"}),S();var Y={multiple:l,types:U};window.showOpenFilePicker(Y).then(function(ie){return n(ie)}).then(function(ie){me(ie,null),X({type:"closeDialog"})}).catch(function(ie){xu(ie)?(H(ie),X({type:"closeDialog"})):gu(ie)?(E.current=!1,P.current?(P.current.value=null,P.current.click()):V(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):V(ie)});return}P.current&&(X({type:"openDialog"}),S(),P.current.value=null,P.current.click())},[X,S,H,C,me,V,U,l]),_=c.useCallback(function(Y){!w.current||!w.current.isEqualNode(Y.target)||(Y.key===" "||Y.key==="Enter"||Y.keyCode===32||Y.keyCode===13)&&(Y.preventDefault(),N())},[w,N]),re=c.useCallback(function(){X({type:"focus"})},[]),te=c.useCallback(function(){X({type:"blur"})},[]),ve=c.useCallback(function(){v||(du()?setTimeout(N,0):N())},[v,N]),je=function(ie){return a?null:ie},Ne=function(ie){return A?null:je(ie)},we=function(ie){return M?null:je(ie)},Ie=function(ie){$&&ie.stopPropagation()},Re=c.useMemo(function(){return function(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ie=Y.refKey,De=ie===void 0?"ref":ie,de=Y.role,$e=Y.onKeyDown,Le=Y.onFocus,Je=Y.onBlur,Ve=Y.onClick,ge=Y.onDragEnter,Fe=Y.onDragOver,Ce=Y.onDragLeave,ze=Y.onDrop,Pe=Es(Y,bu);return rt(rt(va({onKeyDown:Ne($t($e,_)),onFocus:Ne($t(Le,re)),onBlur:Ne($t(Je,te)),onClick:je($t(Ve,ve)),onDragEnter:we($t(ge,z)),onDragOver:we($t(Fe,O)),onDragLeave:we($t(Ce,ne)),onDrop:we($t(ze,q)),role:typeof de=="string"&&de!==""?de:"presentation"},De,w),!a&&!A?{tabIndex:0}:{}),Pe)}},[w,_,re,te,ve,z,O,ne,q,A,M,a]),Z=c.useCallback(function(Y){Y.stopPropagation()},[]),ye=c.useMemo(function(){return function(){var Y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ie=Y.refKey,De=ie===void 0?"ref":ie,de=Y.onChange,$e=Y.onClick,Le=Es(Y,yu),Je=va({accept:W,multiple:l,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:je($t(de,q)),onClick:je($t($e,Z)),tabIndex:-1},De,P);return rt(rt({},Je),Le)}},[P,s,l,q,a]);return rt(rt({},G),{},{isFocused:D&&!a,getRootProps:Re,getInputProps:ye,rootRef:w,inputRef:P,open:je(N)})}function Eu(t,r){switch(r.type){case"focus":return rt(rt({},t),{},{isFocused:!0});case"blur":return rt(rt({},t),{},{isFocused:!1});case"openDialog":return rt(rt({},ka),{},{isFileDialogActive:!0});case"closeDialog":return rt(rt({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return rt(rt({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return rt(rt({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"setDragGlobal":return rt(rt({},t),{},{isDragGlobal:r.isDragGlobal});case"reset":return rt({},ka);default:return t}}function Wn(){}const gi=(t,r="")=>{let s=[];return t.forEach(a=>{const n=r?`${r}/${a.name}`:a.name;if(a.type==="directory"&&a.children){s=s.concat(gi(a.children,n));return}a.type==="file"&&s.push({name:a.name,path:n,relativePath:a.path})}),s};function Tu({selectedProject:t,input:r,setInput:s,textareaRef:a}){const[n,o]=c.useState([]),[i,l]=c.useState([]),[m,d]=c.useState([]),[u,g]=c.useState(!1),[p,x]=c.useState(-1),[f,h]=c.useState(0),[b,C]=c.useState(-1);c.useEffect(()=>{const T=new AbortController;return(async()=>{const U=t==null?void 0:t.name;if(o([]),d([]),!!U)try{const S=await He.getFiles(U,{signal:T.signal});if(!S.ok)return;const H=await S.json();o(gi(H))}catch(S){if((S==null?void 0:S.name)==="AbortError")return;console.error("Error fetching files:",S)}})(),()=>{T.abort()}},[t==null?void 0:t.name]),c.useEffect(()=>{const T=r.slice(0,f),W=T.lastIndexOf("@");if(W===-1){g(!1),C(-1);return}const U=T.slice(W+1);if(U.includes(" ")){g(!1),C(-1);return}C(W),g(!0),x(-1);const S=n.filter(H=>H.name.toLowerCase().includes(U.toLowerCase())||H.path.toLowerCase().includes(U.toLowerCase())).slice(0,10);d(S)},[r,f,n]);const I=c.useMemo(()=>!r||i.length===0?[]:i.filter(T=>r.includes(T)),[i,r]),y=c.useMemo(()=>I.length===0?[]:Array.from(new Set(I)).sort((W,U)=>U.length-W.length),[I]),v=c.useMemo(()=>{if(y.length===0)return null;const T=y.map(qo).join("|");return new RegExp(`(${T})`,"g")},[y]),A=c.useMemo(()=>new Set(y),[y]),M=c.useCallback(T=>T?v?T.split(v).map((U,S)=>A.has(U)?e.jsx("span",{className:"bg-blue-200/70 -ml-0.5 dark:bg-blue-300/40 px-0.5 rounded-md box-decoration-clone text-transparent",children:U},`mention-${S}`):e.jsx("span",{children:U},`text-${S}`)):T:"",[v,A]),$=c.useCallback(T=>{const W=r.slice(0,b),U=r.slice(b),S=U.indexOf(" "),H=S!==-1?U.slice(S):"",w=`${W}${T.path} ${H}`,P=W.length+T.path.length+1;a.current&&!a.current.matches(":focus")&&a.current.focus(),s(w),h(P),l(j=>j.includes(T.path)?j:[...j,T.path]),g(!1),C(-1),a.current&&requestAnimationFrame(()=>{a.current&&(a.current.setSelectionRange(P,P),a.current.matches(":focus")||a.current.focus())})},[r,b,a,s]),k=c.useCallback(T=>!u||m.length===0?!1:T.key==="ArrowDown"?(T.preventDefault(),x(W=>W<m.length-1?W+1:0),!0):T.key==="ArrowUp"?(T.preventDefault(),x(W=>W>0?W-1:m.length-1),!0):T.key==="Tab"||T.key==="Enter"?(T.preventDefault(),p>=0?$(m[p]):m.length>0&&$(m[0]),!0):T.key==="Escape"?(T.preventDefault(),g(!1),!0):!1,[u,m,p,$]);return{showFileDropdown:u,filteredFiles:m,selectedFileIndex:p,renderInputWithMentions:M,selectFile:$,setCursorPosition:h,handleFileMentionsKeyDown:k}}function Kt(t){return Array.isArray?Array.isArray(t):bi(t)==="[object Array]"}function Iu(t){if(typeof t=="string")return t;let r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Au(t){return t==null?"":Iu(t)}function zt(t){return typeof t=="string"}function hi(t){return typeof t=="number"}function Du(t){return t===!0||t===!1||Mu(t)&&bi(t)=="[object Boolean]"}function fi(t){return typeof t=="object"}function Mu(t){return fi(t)&&t!==null}function St(t){return t!=null}function aa(t){return!t.trim().length}function bi(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const $u="Incorrect 'index' type",Lu=t=>`Invalid value for key ${t}`,Fu=t=>`Pattern length exceeds max of ${t}.`,Pu=t=>`Missing ${t} property in key`,_u=t=>`Property 'weight' in key '${t}' must be a positive integer`,Un=Object.prototype.hasOwnProperty;class zu{constructor(r){this._keys=[],this._keyMap={};let s=0;r.forEach(a=>{let n=yi(a);this._keys.push(n),this._keyMap[n.id]=n,s+=n.weight}),this._keys.forEach(a=>{a.weight/=s})}get(r){return this._keyMap[r]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function yi(t){let r=null,s=null,a=null,n=1,o=null;if(zt(t)||Kt(t))a=t,r=Hn(t),s=wa(t);else{if(!Un.call(t,"name"))throw new Error(Pu("name"));const i=t.name;if(a=i,Un.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(_u(i));r=Hn(i),s=wa(i),o=t.getFn}return{path:r,id:s,weight:n,src:a,getFn:o}}function Hn(t){return Kt(t)?t:t.split(".")}function wa(t){return Kt(t)?t.join("."):t}function Ou(t,r){let s=[],a=!1;const n=(o,i,l)=>{if(St(o))if(!i[l])s.push(o);else{let m=i[l];const d=o[m];if(!St(d))return;if(l===i.length-1&&(zt(d)||hi(d)||Du(d)))s.push(Au(d));else if(Kt(d)){a=!0;for(let u=0,g=d.length;u<g;u+=1)n(d[u],i,l+1)}else i.length&&n(d,i,l+1)}};return n(t,zt(r)?r.split("."):r,0),a?s:s[0]}const Ru={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Bu={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,r)=>t.score===r.score?t.idx<r.idx?-1:1:t.score<r.score?-1:1},Wu={location:0,threshold:.6,distance:100},Uu={useExtendedSearch:!1,getFn:Ou,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Me={...Bu,...Ru,...Wu,...Uu};const Hu=/[^ ]+/g;function Gu(t=1,r=3){const s=new Map,a=Math.pow(10,r);return{get(n){const o=n.match(Hu).length;if(s.has(o))return s.get(o);const i=1/Math.pow(o,.5*t),l=parseFloat(Math.round(i*a)/a);return s.set(o,l),l},clear(){s.clear()}}}class Ua{constructor({getFn:r=Me.getFn,fieldNormWeight:s=Me.fieldNormWeight}={}){this.norm=Gu(s,3),this.getFn=r,this.isCreated=!1,this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((s,a)=>{this._keysMap[s.id]=a})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,zt(this.docs[0])?this.docs.forEach((r,s)=>{this._addString(r,s)}):this.docs.forEach((r,s)=>{this._addObject(r,s)}),this.norm.clear())}add(r){const s=this.size();zt(r)?this._addString(r,s):this._addObject(r,s)}removeAt(r){this.records.splice(r,1);for(let s=r,a=this.size();s<a;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(r,s){return r[this._keysMap[s]]}size(){return this.records.length}_addString(r,s){if(!St(r)||aa(r))return;let a={v:r,i:s,n:this.norm.get(r)};this.records.push(a)}_addObject(r,s){let a={i:s,$:{}};this.keys.forEach((n,o)=>{let i=n.getFn?n.getFn(r):this.getFn(r,n.path);if(St(i)){if(Kt(i)){let l=[];const m=[{nestedArrIndex:-1,value:i}];for(;m.length;){const{nestedArrIndex:d,value:u}=m.pop();if(St(u))if(zt(u)&&!aa(u)){let g={v:u,i:d,n:this.norm.get(u)};l.push(g)}else Kt(u)&&u.forEach((g,p)=>{m.push({nestedArrIndex:p,value:g})})}a.$[o]=l}else if(zt(i)&&!aa(i)){let l={v:i,n:this.norm.get(i)};a.$[o]=l}}}),this.records.push(a)}toJSON(){return{keys:this.keys,records:this.records}}}function vi(t,r,{getFn:s=Me.getFn,fieldNormWeight:a=Me.fieldNormWeight}={}){const n=new Ua({getFn:s,fieldNormWeight:a});return n.setKeys(t.map(yi)),n.setSources(r),n.create(),n}function qu(t,{getFn:r=Me.getFn,fieldNormWeight:s=Me.fieldNormWeight}={}){const{keys:a,records:n}=t,o=new Ua({getFn:r,fieldNormWeight:s});return o.setKeys(a),o.setIndexRecords(n),o}function us(t,{errors:r=0,currentLocation:s=0,expectedLocation:a=0,distance:n=Me.distance,ignoreLocation:o=Me.ignoreLocation}={}){const i=r/t.length;if(o)return i;const l=Math.abs(a-s);return n?i+l/n:l?1:i}function Ku(t=[],r=Me.minMatchCharLength){let s=[],a=-1,n=-1,o=0;for(let i=t.length;o<i;o+=1){let l=t[o];l&&a===-1?a=o:!l&&a!==-1&&(n=o-1,n-a+1>=r&&s.push([a,n]),a=-1)}return t[o-1]&&o-a>=r&&s.push([a,o-1]),s}const lr=32;function Vu(t,r,s,{location:a=Me.location,distance:n=Me.distance,threshold:o=Me.threshold,findAllMatches:i=Me.findAllMatches,minMatchCharLength:l=Me.minMatchCharLength,includeMatches:m=Me.includeMatches,ignoreLocation:d=Me.ignoreLocation}={}){if(r.length>lr)throw new Error(Fu(lr));const u=r.length,g=t.length,p=Math.max(0,Math.min(a,g));let x=o,f=p;const h=l>1||m,b=h?Array(g):[];let C;for(;(C=t.indexOf(r,f))>-1;){let $=us(r,{currentLocation:C,expectedLocation:p,distance:n,ignoreLocation:d});if(x=Math.min($,x),f=C+u,h){let k=0;for(;k<u;)b[C+k]=1,k+=1}}f=-1;let I=[],y=1,v=u+g;const A=1<<u-1;for(let $=0;$<u;$+=1){let k=0,T=v;for(;k<T;)us(r,{errors:$,currentLocation:p+T,expectedLocation:p,distance:n,ignoreLocation:d})<=x?k=T:v=T,T=Math.floor((v-k)/2+k);v=T;let W=Math.max(1,p-T+1),U=i?g:Math.min(p+T,g)+u,S=Array(U+2);S[U+1]=(1<<$)-1;for(let w=U;w>=W;w-=1){let P=w-1,j=s[t.charAt(P)];if(h&&(b[P]=+!!j),S[w]=(S[w+1]<<1|1)&j,$&&(S[w]|=(I[w+1]|I[w])<<1|1|I[w+1]),S[w]&A&&(y=us(r,{errors:$,currentLocation:P,expectedLocation:p,distance:n,ignoreLocation:d}),y<=x)){if(x=y,f=P,f<=p)break;W=Math.max(1,2*p-f)}}if(us(r,{errors:$+1,currentLocation:p,expectedLocation:p,distance:n,ignoreLocation:d})>x)break;I=S}const M={isMatch:f>=0,score:Math.max(.001,y)};if(h){const $=Ku(b,l);$.length?m&&(M.indices=$):M.isMatch=!1}return M}function Ju(t){let r={};for(let s=0,a=t.length;s<a;s+=1){const n=t.charAt(s);r[n]=(r[n]||0)|1<<a-s-1}return r}const Ts=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class ki{constructor(r,{location:s=Me.location,threshold:a=Me.threshold,distance:n=Me.distance,includeMatches:o=Me.includeMatches,findAllMatches:i=Me.findAllMatches,minMatchCharLength:l=Me.minMatchCharLength,isCaseSensitive:m=Me.isCaseSensitive,ignoreDiacritics:d=Me.ignoreDiacritics,ignoreLocation:u=Me.ignoreLocation}={}){if(this.options={location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:l,isCaseSensitive:m,ignoreDiacritics:d,ignoreLocation:u},r=m?r:r.toLowerCase(),r=d?Ts(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;const g=(x,f)=>{this.chunks.push({pattern:x,alphabet:Ju(x),startIndex:f})},p=this.pattern.length;if(p>lr){let x=0;const f=p%lr,h=p-f;for(;x<h;)g(this.pattern.substr(x,lr),x),x+=lr;if(f){const b=p-lr;g(this.pattern.substr(b),b)}}else g(this.pattern,0)}searchIn(r){const{isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n}=this.options;if(r=s?r:r.toLowerCase(),r=a?Ts(r):r,this.pattern===r){let h={isMatch:!0,score:0};return n&&(h.indices=[[0,r.length-1]]),h}const{location:o,distance:i,threshold:l,findAllMatches:m,minMatchCharLength:d,ignoreLocation:u}=this.options;let g=[],p=0,x=!1;this.chunks.forEach(({pattern:h,alphabet:b,startIndex:C})=>{const{isMatch:I,score:y,indices:v}=Vu(r,h,b,{location:o+C,distance:i,threshold:l,findAllMatches:m,minMatchCharLength:d,includeMatches:n,ignoreLocation:u});I&&(x=!0),p+=y,I&&v&&(g=[...g,...v])});let f={isMatch:x,score:x?p/this.chunks.length:1};return x&&n&&(f.indices=g),f}}class sr{constructor(r){this.pattern=r}static isMultiMatch(r){return Gn(r,this.multiRegex)}static isSingleMatch(r){return Gn(r,this.singleRegex)}search(){}}function Gn(t,r){const s=t.match(r);return s?s[1]:null}class Yu extends sr{constructor(r){super(r)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(r){const s=r===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Qu extends sr{constructor(r){super(r)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(r){const a=r.indexOf(this.pattern)===-1;return{isMatch:a,score:a?0:1,indices:[0,r.length-1]}}}class Xu extends sr{constructor(r){super(r)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(r){const s=r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Zu extends sr{constructor(r){super(r)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(r){const s=!r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class ep extends sr{constructor(r){super(r)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(r){const s=r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[r.length-this.pattern.length,r.length-1]}}}class tp extends sr{constructor(r){super(r)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(r){const s=!r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class wi extends sr{constructor(r,{location:s=Me.location,threshold:a=Me.threshold,distance:n=Me.distance,includeMatches:o=Me.includeMatches,findAllMatches:i=Me.findAllMatches,minMatchCharLength:l=Me.minMatchCharLength,isCaseSensitive:m=Me.isCaseSensitive,ignoreDiacritics:d=Me.ignoreDiacritics,ignoreLocation:u=Me.ignoreLocation}={}){super(r),this._bitapSearch=new ki(r,{location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:l,isCaseSensitive:m,ignoreDiacritics:d,ignoreLocation:u})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(r){return this._bitapSearch.searchIn(r)}}class ji extends sr{constructor(r){super(r)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(r){let s=0,a;const n=[],o=this.pattern.length;for(;(a=r.indexOf(this.pattern,s))>-1;)s=a+o,n.push([a,s-1]);const i=!!n.length;return{isMatch:i,score:i?0:1,indices:n}}}const ja=[Yu,ji,Xu,Zu,tp,ep,Qu,wi],qn=ja.length,rp=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,sp="|";function ap(t,r={}){return t.split(sp).map(s=>{let a=s.trim().split(rp).filter(o=>o&&!!o.trim()),n=[];for(let o=0,i=a.length;o<i;o+=1){const l=a[o];let m=!1,d=-1;for(;!m&&++d<qn;){const u=ja[d];let g=u.isMultiMatch(l);g&&(n.push(new u(g,r)),m=!0)}if(!m)for(d=-1;++d<qn;){const u=ja[d];let g=u.isSingleMatch(l);if(g){n.push(new u(g,r));break}}}return n})}const np=new Set([wi.type,ji.type]);class op{constructor(r,{isCaseSensitive:s=Me.isCaseSensitive,ignoreDiacritics:a=Me.ignoreDiacritics,includeMatches:n=Me.includeMatches,minMatchCharLength:o=Me.minMatchCharLength,ignoreLocation:i=Me.ignoreLocation,findAllMatches:l=Me.findAllMatches,location:m=Me.location,threshold:d=Me.threshold,distance:u=Me.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n,minMatchCharLength:o,findAllMatches:l,ignoreLocation:i,location:m,threshold:d,distance:u},r=s?r:r.toLowerCase(),r=a?Ts(r):r,this.pattern=r,this.query=ap(this.pattern,this.options)}static condition(r,s){return s.useExtendedSearch}searchIn(r){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:a,isCaseSensitive:n,ignoreDiacritics:o}=this.options;r=n?r:r.toLowerCase(),r=o?Ts(r):r;let i=0,l=[],m=0;for(let d=0,u=s.length;d<u;d+=1){const g=s[d];l.length=0,i=0;for(let p=0,x=g.length;p<x;p+=1){const f=g[p],{isMatch:h,indices:b,score:C}=f.search(r);if(h){if(i+=1,m+=C,a){const I=f.constructor.type;np.has(I)?l=[...l,...b]:l.push(b)}}else{m=0,i=0,l.length=0;break}}if(i){let p={isMatch:!0,score:m/i};return a&&(p.indices=l),p}}return{isMatch:!1,score:1}}}const Na=[];function ip(...t){Na.push(...t)}function Ca(t,r){for(let s=0,a=Na.length;s<a;s+=1){let n=Na[s];if(n.condition(t,r))return new n(t,r)}return new ki(t,r)}const Is={AND:"$and",OR:"$or"},Sa={PATH:"$path",PATTERN:"$val"},Ea=t=>!!(t[Is.AND]||t[Is.OR]),lp=t=>!!t[Sa.PATH],cp=t=>!Kt(t)&&fi(t)&&!Ea(t),Kn=t=>({[Is.AND]:Object.keys(t).map(r=>({[r]:t[r]}))});function Ni(t,r,{auto:s=!0}={}){const a=n=>{let o=Object.keys(n);const i=lp(n);if(!i&&o.length>1&&!Ea(n))return a(Kn(n));if(cp(n)){const m=i?n[Sa.PATH]:o[0],d=i?n[Sa.PATTERN]:n[m];if(!zt(d))throw new Error(Lu(m));const u={keyId:wa(m),pattern:d};return s&&(u.searcher=Ca(d,r)),u}let l={children:[],operator:o[0]};return o.forEach(m=>{const d=n[m];Kt(d)&&d.forEach(u=>{l.children.push(a(u))})}),l};return Ea(t)||(t=Kn(t)),a(t)}function dp(t,{ignoreFieldNorm:r=Me.ignoreFieldNorm}){t.forEach(s=>{let a=1;s.matches.forEach(({key:n,norm:o,score:i})=>{const l=n?n.weight:null;a*=Math.pow(i===0&&l?Number.EPSILON:i,(l||1)*(r?1:o))}),s.score=a})}function mp(t,r){const s=t.matches;r.matches=[],St(s)&&s.forEach(a=>{if(!St(a.indices)||!a.indices.length)return;const{indices:n,value:o}=a;let i={indices:n,value:o};a.key&&(i.key=a.key.src),a.idx>-1&&(i.refIndex=a.idx),r.matches.push(i)})}function up(t,r){r.score=t.score}function pp(t,r,{includeMatches:s=Me.includeMatches,includeScore:a=Me.includeScore}={}){const n=[];return s&&n.push(mp),a&&n.push(up),t.map(o=>{const{idx:i}=o,l={item:r[i],refIndex:i};return n.length&&n.forEach(m=>{m(o,l)}),l})}class Dr{constructor(r,s={},a){this.options={...Me,...s},this.options.useExtendedSearch,this._keyStore=new zu(this.options.keys),this.setCollection(r,a)}setCollection(r,s){if(this._docs=r,s&&!(s instanceof Ua))throw new Error($u);this._myIndex=s||vi(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(r){St(r)&&(this._docs.push(r),this._myIndex.add(r))}remove(r=()=>!1){const s=[];for(let a=0,n=this._docs.length;a<n;a+=1){const o=this._docs[a];r(o,a)&&(this.removeAt(a),a-=1,n-=1,s.push(o))}return s}removeAt(r){this._docs.splice(r,1),this._myIndex.removeAt(r)}getIndex(){return this._myIndex}search(r,{limit:s=-1}={}){const{includeMatches:a,includeScore:n,shouldSort:o,sortFn:i,ignoreFieldNorm:l}=this.options;let m=zt(r)?zt(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r);return dp(m,{ignoreFieldNorm:l}),o&&m.sort(i),hi(s)&&s>-1&&(m=m.slice(0,s)),pp(m,this._docs,{includeMatches:a,includeScore:n})}_searchStringList(r){const s=Ca(r,this.options),{records:a}=this._myIndex,n=[];return a.forEach(({v:o,i,n:l})=>{if(!St(o))return;const{isMatch:m,score:d,indices:u}=s.searchIn(o);m&&n.push({item:o,idx:i,matches:[{score:d,value:o,norm:l,indices:u}]})}),n}_searchLogical(r){const s=Ni(r,this.options),a=(l,m,d)=>{if(!l.children){const{keyId:g,searcher:p}=l,x=this._findMatches({key:this._keyStore.get(g),value:this._myIndex.getValueForItemAtKeyId(m,g),searcher:p});return x&&x.length?[{idx:d,item:m,matches:x}]:[]}const u=[];for(let g=0,p=l.children.length;g<p;g+=1){const x=l.children[g],f=a(x,m,d);if(f.length)u.push(...f);else if(l.operator===Is.AND)return[]}return u},n=this._myIndex.records,o={},i=[];return n.forEach(({$:l,i:m})=>{if(St(l)){let d=a(s,l,m);d.length&&(o[m]||(o[m]={idx:m,item:l,matches:[]},i.push(o[m])),d.forEach(({matches:u})=>{o[m].matches.push(...u)}))}}),i}_searchObjectList(r){const s=Ca(r,this.options),{keys:a,records:n}=this._myIndex,o=[];return n.forEach(({$:i,i:l})=>{if(!St(i))return;let m=[];a.forEach((d,u)=>{m.push(...this._findMatches({key:d,value:i[u],searcher:s}))}),m.length&&o.push({idx:l,item:i,matches:m})}),o}_findMatches({key:r,value:s,searcher:a}){if(!St(s))return[];let n=[];if(Kt(s))s.forEach(({v:o,i,n:l})=>{if(!St(o))return;const{isMatch:m,score:d,indices:u}=a.searchIn(o);m&&n.push({score:d,key:r,value:o,idx:i,norm:l,indices:u})});else{const{v:o,n:i}=s,{isMatch:l,score:m,indices:d}=a.searchIn(o);l&&n.push({score:m,key:r,value:o,norm:i,indices:d})}return n}}Dr.version="7.1.0";Dr.createIndex=vi;Dr.parseIndex=qu;Dr.config=Me;Dr.parseQuery=Ni;ip(op);const xp=150,Ci=t=>`command_history_${t}`,na=t=>{const r=gt.getItem(Ci(t));if(!r)return{};try{return JSON.parse(r)}catch(s){return console.error("Error parsing command history:",s),{}}},gp=(t,r)=>{gt.setItem(Ci(t),JSON.stringify(r))},Vn=t=>!!t&&typeof t.then=="function";function hp({selectedProject:t,input:r,setInput:s,textareaRef:a,onExecuteCommand:n}){const[o,i]=c.useState([]),[l,m]=c.useState([]),[d,u]=c.useState(!1),[g,p]=c.useState(""),[x,f]=c.useState(-1),[h,b]=c.useState(-1),C=c.useRef(null),I=c.useCallback(()=>{C.current!==null&&(window.clearTimeout(C.current),C.current=null)},[]),y=c.useCallback(()=>{u(!1),b(-1),p(""),f(-1),I()},[I]);c.useEffect(()=>{(async()=>{if(!t){i([]),m([]);return}try{const H=await Ee("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.fullPath||t.path})});if(!H.ok)throw new Error("Failed to fetch commands");const w=await H.json(),P=[...(w.builtIn||[]).map(G=>({...G,type:"built-in"})),...(w.custom||[]).map(G=>({...G,type:"custom"}))],j=na(t.name),F=[...P].sort((G,X)=>{const D=j[G.name]||0;return(j[X.name]||0)-D});i(F)}catch(H){console.error("Error fetching slash commands:",H),i([])}})()},[t]),c.useEffect(()=>{d||f(-1)},[d]);const v=c.useMemo(()=>o.length?new Dr(o,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[o]);c.useEffect(()=>{if(!g){m(o);return}if(!v){m([]);return}const S=v.search(g);m(S.map(H=>H.item))},[g,o,v]);const A=c.useMemo(()=>{if(!t||o.length===0)return[];const S=na(t.name);return o.map(H=>({...H,usageCount:S[H.name]||0})).filter(H=>H.usageCount>0).sort((H,w)=>w.usageCount-H.usageCount).slice(0,5)},[t,o]),M=c.useCallback(S=>{if(!t)return;const H=na(t.name);H[S.name]=(H[S.name]||0)+1,gp(t.name,H)},[t]),$=c.useCallback(S=>{const H=r.slice(0,h),w=r.slice(h),P=w.indexOf(" "),j=P!==-1?w.slice(P):"",F=`${H}${S.name} ${j}`;s(F),y();const G=n(S);Vn(G)&&G.catch(()=>{})},[r,h,s,y,n]),k=c.useCallback((S,H,w)=>{if(!S||!t)return;if(w){f(H);return}M(S);const P=n(S);Vn(P)?(P.then(()=>{y()}),P.catch(()=>{})):y()},[t,M,n,y]),T=c.useCallback(()=>{var H;const S=!d;u(S),p(""),f(-1),S&&m(o),(H=a.current)==null||H.focus()},[d,o,a]),W=c.useCallback((S,H)=>{if(!S.trim()){y();return}const w=S.slice(0,H);if((w.match(/```/g)||[]).length%2===1){y();return}const F=/(^|\s)\/(\S*)$/,G=w.match(F);if(!G){y();return}const X=(G.index||0)+G[1].length,D=G[2];b(X),u(!0),f(-1),I(),C.current=window.setTimeout(()=>{p(D)},xp)},[y,I]),U=c.useCallback(S=>d?l.length?S.key==="ArrowDown"?(S.preventDefault(),f(H=>H<l.length-1?H+1:0),!0):S.key==="ArrowUp"?(S.preventDefault(),f(H=>H>0?H-1:l.length-1),!0):S.key==="Tab"||S.key==="Enter"?(S.preventDefault(),x>=0?$(l[x]):l.length>0&&$(l[0]),!0):S.key==="Escape"?(S.preventDefault(),y(),!0):!1:S.key==="Escape"?(S.preventDefault(),y(),!0):!1:!1,[d,l,y,$,x]);return c.useEffect(()=>()=>{I()},[I]),{slashCommands:o,slashCommandsCount:o.length,filteredCommands:l,frequentCommands:A,commandQuery:g,showCommandMenu:d,selectedCommandIndex:x,resetCommandMenuState:y,handleCommandSelect:k,handleToggleCommandMenu:T,handleCommandInputChange:W,handleCommandMenuKeyDown:U}}const fp=()=>({preventDefault:()=>{}}),bp=t=>!!(t&&t.startsWith("new-session-"));function yp({selectedProject:t,selectedSession:r,currentSessionId:s,provider:a,permissionMode:n,cyclePermissionMode:o,cursorModel:i,claudeModel:l,codexModel:m,isLoading:d,canAbortSession:u,tokenBudget:g,sendMessage:p,sendByCtrlEnter:x,onSessionActive:f,onInputFocusChange:h,onFileOpen:b,onShowSettings:C,pendingViewSessionRef:I,scrollToBottom:y,setChatMessages:v,setSessionMessages:A,setIsLoading:M,setCanAbortSession:$,setClaudeStatus:k,setIsUserScrolledUp:T,setPendingPermissionRequests:W}){const[U,S]=c.useState(()=>typeof window<"u"&&t&&gt.getItem(`draft_input_${t.name}`)||""),[H,w]=c.useState([]),[P,j]=c.useState(new Map),[F,G]=c.useState(new Map),[X,D]=c.useState(!1),[oe,E]=c.useState("none"),se=c.useRef(null),J=c.useRef(null),B=c.useRef(null),K=c.useRef(U),V=c.useCallback(le=>{const{action:pe,data:ue}=le;switch(pe){case"clear":v([]),A==null||A([]);break;case"help":v(Se=>[...Se,{type:"assistant",content:ue.content,timestamp:Date.now()}]);break;case"model":v(Se=>[...Se,{type:"assistant",content:`**Current Model**: ${ue.current.model}
119
+
120
+ **Available Models**:
121
+
122
+ Claude: ${ue.available.claude.join(", ")}
123
+
124
+ Cursor: ${ue.available.cursor.join(", ")}`,timestamp:Date.now()}]);break;case"cost":{const Se=`**Token Usage**: ${ue.tokenUsage.used.toLocaleString()} / ${ue.tokenUsage.total.toLocaleString()} (${ue.tokenUsage.percentage}%)
125
+
126
+ **Estimated Cost**:
127
+ - Input: $${ue.cost.input}
128
+ - Output: $${ue.cost.output}
129
+ - **Total**: $${ue.cost.total}
130
+
131
+ **Model**: ${ue.model}`;v(We=>[...We,{type:"assistant",content:Se,timestamp:Date.now()}]);break}case"status":{const Se=`**System Status**
132
+
133
+ - Version: ${ue.version}
134
+ - Uptime: ${ue.uptime}
135
+ - Model: ${ue.model}
136
+ - Provider: ${ue.provider}
137
+ - Node.js: ${ue.nodeVersion}
138
+ - Platform: ${ue.platform}`;v(We=>[...We,{type:"assistant",content:Se,timestamp:Date.now()}]);break}case"memory":ue.error?v(Se=>[...Se,{type:"assistant",content:`⚠️ ${ue.message}`,timestamp:Date.now()}]):(v(Se=>[...Se,{type:"assistant",content:`📝 ${ue.message}
139
+
140
+ Path: \`${ue.path}\``,timestamp:Date.now()}]),ue.exists&&b&&b(ue.path));break;case"config":C==null||C();break;case"rewind":ue.error?v(Se=>[...Se,{type:"assistant",content:`⚠️ ${ue.message}`,timestamp:Date.now()}]):(v(Se=>Se.slice(0,-ue.steps*2)),v(Se=>[...Se,{type:"assistant",content:`⏪ ${ue.message}`,timestamp:Date.now()}]));break;default:console.warn("Unknown built-in command action:",pe)}},[b,C,v,A]),z=c.useCallback(async le=>{const{content:pe,hasBashCommands:ue}=le;if(ue&&!window.confirm("This command contains bash commands that will be executed. Do you want to proceed?")){v(Xe=>[...Xe,{type:"assistant",content:"❌ Command execution cancelled",timestamp:Date.now()}]);return}const Se=pe||"";S(Se),K.current=Se,setTimeout(()=>{B.current&&B.current(fp())},0)},[v]),O=c.useCallback(async le=>{if(!(!le||!t))try{const pe=U.match(new RegExp(`${qo(le.name)}\\s*(.*)`)),ue=pe&&pe[1]?pe[1].trim().split(/\s+/):[],Se={projectPath:t.fullPath||t.path,projectName:t.name,sessionId:s,provider:a,model:a==="cursor"?i:a==="codex"?m:l,tokenUsage:g},We=await Ee("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:le.name,commandPath:le.path,args:ue,context:Se})});if(!We.ok){let Ze=`Failed to execute command (${We.status})`;try{const dt=await We.json();Ze=(dt==null?void 0:dt.message)||(dt==null?void 0:dt.error)||Ze}catch{}throw new Error(Ze)}const Xe=await We.json();Xe.type==="builtin"?(V(Xe),S(""),K.current=""):Xe.type==="custom"&&await z(Xe)}catch(pe){const ue=pe instanceof Error?pe.message:"Unknown error";console.error("Error executing command:",pe),v(Se=>[...Se,{type:"assistant",content:`Error executing command: ${ue}`,timestamp:Date.now()}])}},[l,m,s,i,V,z,U,a,t,v,g]),{slashCommandsCount:ne,filteredCommands:me,frequentCommands:q,commandQuery:N,showCommandMenu:_,selectedCommandIndex:re,resetCommandMenuState:te,handleCommandSelect:ve,handleToggleCommandMenu:je,handleCommandInputChange:Ne,handleCommandMenuKeyDown:we}=hp({selectedProject:t,input:U,setInput:S,textareaRef:se,onExecuteCommand:O}),{showFileDropdown:Ie,filteredFiles:Re,selectedFileIndex:Z,renderInputWithMentions:ye,selectFile:Y,setCursorPosition:ie,handleFileMentionsKeyDown:De}=Tu({selectedProject:t,input:U,setInput:S,textareaRef:se}),de=c.useCallback(le=>{!J.current||!le||(J.current.scrollTop=le.scrollTop,J.current.scrollLeft=le.scrollLeft)},[]),$e=c.useCallback(le=>{const pe=le.filter(ue=>{try{if(!ue||typeof ue!="object")return console.warn("Invalid file object:",ue),!1;if(!ue.type||!ue.type.startsWith("image/"))return!1;if(!ue.size||ue.size>5242880){const Se=ue.name||"Unknown file";return G(We=>{const Xe=new Map(We);return Xe.set(Se,"File too large (max 5MB)"),Xe}),!1}return!0}catch(Se){return console.error("Error validating file:",Se,ue),!1}});pe.length>0&&w(ue=>[...ue,...pe].slice(0,5))},[]),Le=c.useCallback(le=>{const pe=Array.from(le.clipboardData.items);if(pe.forEach(ue=>{if(!ue.type.startsWith("image/"))return;const Se=ue.getAsFile();Se&&$e([Se])}),pe.length===0&&le.clipboardData.files.length>0){const Se=Array.from(le.clipboardData.files).filter(We=>We.type.startsWith("image/"));Se.length>0&&$e(Se)}},[$e]),{getRootProps:Je,getInputProps:Ve,isDragActive:ge,open:Fe}=xi({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:$e,noClick:!0,noKeyboard:!0}),Ce=c.useCallback(async le=>{le.preventDefault();const pe=K.current;if(!pe.trim()||d||!t)return;let ue=pe;const Se=ri.find(nt=>nt.id===oe);Se&&Se.prefix&&(ue=`${Se.prefix}: ${pe}`);let We=[];if(H.length>0){const nt=new FormData;H.forEach(at=>{nt.append("images",at)});try{const at=await Ee(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:nt});if(!at.ok)throw new Error("Failed to upload images");We=(await at.json()).images}catch(at){const Rt=at instanceof Error?at.message:"Unknown error";console.error("Image upload failed:",at),v(Bt=>[...Bt,{type:"error",content:`Failed to upload images: ${Rt}`,timestamp:new Date}]);return}}const Xe={type:"user",content:pe,images:We,timestamp:new Date};v(nt=>[...nt,Xe]),M(!0),$(!0),k({text:"Processing",tokens:0,can_interrupt:!0}),T(!1),setTimeout(()=>y(),100);const Ze=s||(r==null?void 0:r.id)||sessionStorage.getItem("cursorSessionId"),dt=Ze||`new-session-${Date.now()}`;!Ze&&!(r!=null&&r.id)&&(typeof window<"u"&&sessionStorage.removeItem("pendingSessionId"),I.current={sessionId:null,startedAt:Date.now()}),f==null||f(dt);const bt=(()=>{try{const nt=a==="cursor"?"cursor-tools-settings":a==="codex"?"codex-settings":"claude-settings",at=gt.getItem(nt);if(at)return JSON.parse(at)}catch(nt){console.error("Error loading tools settings:",nt)}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})(),wt=t.fullPath||t.path||"";p(a==="cursor"?{type:"cursor-command",command:ue,sessionId:Ze,options:{cwd:wt,projectPath:wt,sessionId:Ze,resume:!!Ze,model:i,skipPermissions:(bt==null?void 0:bt.skipPermissions)||!1,toolsSettings:bt}}:a==="codex"?{type:"codex-command",command:ue,sessionId:Ze,options:{cwd:wt,projectPath:wt,sessionId:Ze,resume:!!Ze,model:m,permissionMode:n==="plan"?"default":n}}:{type:"claude-command",command:ue,options:{projectPath:wt,cwd:wt,sessionId:Ze,resume:!!Ze,toolsSettings:bt,permissionMode:n,model:l,images:We}}),S(""),K.current="",te(),w([]),j(new Map),G(new Map),D(!1),E("none"),se.current&&(se.current.style.height="auto"),gt.removeItem(`draft_input_${t.name}`)},[H,l,m,s,i,d,f,I,n,a,te,y,t,r==null?void 0:r.id,p,$,v,k,M,T,oe]);c.useEffect(()=>{B.current=Ce},[Ce]),c.useEffect(()=>{K.current=U},[U]),c.useEffect(()=>{if(!t)return;const le=gt.getItem(`draft_input_${t.name}`)||"";S(pe=>{const ue=pe===le?pe:le;return K.current=ue,ue})},[t==null?void 0:t.name]),c.useEffect(()=>{t&&(U!==""?gt.setItem(`draft_input_${t.name}`,U):gt.removeItem(`draft_input_${t.name}`))},[U,t]),c.useEffect(()=>{if(!se.current)return;se.current.style.height="auto",se.current.style.height=`${se.current.scrollHeight}px`;const le=parseInt(window.getComputedStyle(se.current).lineHeight),pe=se.current.scrollHeight>le*2;D(pe)},[U]),c.useEffect(()=>{!se.current||U.trim()||(se.current.style.height="auto",D(!1))},[U]);const ze=c.useCallback(le=>{const pe=le.target.value,ue=le.target.selectionStart;if(S(pe),K.current=pe,ie(ue),!pe.trim()){le.target.style.height="auto",D(!1),te();return}Ne(pe,ue)},[Ne,te,ie]),Pe=c.useCallback(le=>{if(!we(le)&&!De(le)){if(le.key==="Tab"&&!Ie&&!_){le.preventDefault(),o();return}if(le.key==="Enter"){if(le.nativeEvent.isComposing)return;((le.ctrlKey||le.metaKey)&&!le.shiftKey||!le.shiftKey&&!le.ctrlKey&&!le.metaKey&&!x)&&(le.preventDefault(),Ce(le))}}},[o,we,De,Ce,x,_,Ie]),_e=c.useCallback(le=>{ie(le.currentTarget.selectionStart)},[ie]),Ke=c.useCallback(le=>{const pe=le.currentTarget;pe.style.height="auto",pe.style.height=`${pe.scrollHeight}px`,ie(pe.selectionStart),de(pe);const ue=parseInt(window.getComputedStyle(pe).lineHeight);D(pe.scrollHeight>ue*2)},[ie,de]),ae=c.useCallback(()=>{S(""),K.current="",te(),se.current&&(se.current.style.height="auto",se.current.focus()),D(!1)},[te]),ke=c.useCallback(()=>{var We;if(!u)return;const le=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,pe=typeof window<"u"?sessionStorage.getItem("cursorSessionId"):null,Se=[s,((We=I.current)==null?void 0:We.sessionId)||null,le,a==="cursor"?pe:null,(r==null?void 0:r.id)||null].find(Xe=>!!Xe&&!bp(Xe))||null;if(!Se){console.warn("Abort requested but no concrete session ID is available yet.");return}p({type:"abort-session",sessionId:Se,provider:a})},[u,s,I,a,r==null?void 0:r.id,p]),Be=c.useCallback(le=>{le.trim()&&S(pe=>{const ue=pe.trim()?`${pe} ${le}`:le;return K.current=ue,setTimeout(()=>{if(!se.current)return;se.current.style.height="auto",se.current.style.height=`${se.current.scrollHeight}px`;const Se=parseInt(window.getComputedStyle(se.current).lineHeight);D(se.current.scrollHeight>Se*2)},0),ue})},[]),Ue=c.useCallback(le=>!le||a!=="claude"?{success:!1}:Md(le.entry),[a]),mt=c.useCallback((le,pe)=>{const Se=(Array.isArray(le)?le:[le]).filter(Boolean);Se.length!==0&&(Se.forEach(We=>{p({type:"claude-permission-response",requestId:We,allow:!!(pe!=null&&pe.allow),updatedInput:pe==null?void 0:pe.updatedInput,message:pe==null?void 0:pe.message,rememberEntry:pe==null?void 0:pe.rememberEntry})}),W(We=>{const Xe=We.filter(Ze=>!Se.includes(Ze.requestId));return Xe.length===0&&k(null),Xe}))},[p,k,W]),[It,pt]=c.useState(!1),kt=c.useCallback(le=>{pt(le),h==null||h(le)},[h]);return{input:U,setInput:S,textareaRef:se,inputHighlightRef:J,isTextareaExpanded:X,thinkingMode:oe,setThinkingMode:E,slashCommandsCount:ne,filteredCommands:me,frequentCommands:q,commandQuery:N,showCommandMenu:_,selectedCommandIndex:re,resetCommandMenuState:te,handleCommandSelect:ve,handleToggleCommandMenu:je,showFileDropdown:Ie,filteredFiles:Re,selectedFileIndex:Z,renderInputWithMentions:ye,selectFile:Y,attachedImages:H,setAttachedImages:w,uploadingImages:P,imageErrors:F,getRootProps:Je,getInputProps:Ve,isDragActive:ge,openImagePicker:Fe,handleSubmit:Ce,handleInputChange:ze,handleKeyDown:Pe,handlePaste:Le,handleTextareaClick:_e,handleTextareaInput:Ke,syncInputOverlayScroll:de,handleClearInput:ae,handleAbortSession:ke,handleTranscript:Be,handlePermissionDecision:mt,handleGrantToolPermission:Ue,handleInputFocusChange:kt,isInputFocused:It}}const vp=[{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:chat|conversation)\b/i,tab:"chat"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:terminal|shell|console|command line)\b/i,tab:"shell"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:files?|file\s*(?:tree|explorer|browser|manager))\b/i,tab:"files"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:git|version control|source control)\b/i,tab:"git"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:canvas|whiteboard|board|draw)\b/i,tab:"canvas"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:workflows?|automations?|cron)\b/i,tab:"workflows"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:tasks?|task\s*master)\b/i,tab:"tasks"}],kp=[{pattern:/\b(?:run|execute)\s+git\s+status\b/i,action:"git-status"},{pattern:/\b(?:run|execute)\s+git\s+(.+)/i,action:"git-command",extractArgs:t=>t[1]},{pattern:/\b(?:create|start|new)\s+(?:a\s+)?(?:new\s+)?session\b/i,action:"new-session"},{pattern:/\b(?:clear|reset)\s+(?:the\s+)?(?:chat|conversation)\b/i,action:"clear-chat"},{pattern:/\bscroll\s+(?:to\s+)?(?:the\s+)?(?:bottom|down)\b/i,action:"scroll-bottom"},{pattern:/\b(?:stop|cancel|abort)\s+(?:the\s+)?(?:session|response|generation)\b/i,action:"abort"}];function Jn(t){const r=t.trim();if(!r)return null;for(const{pattern:s,tab:a}of vp)if(s.test(r))return{type:"navigate",tab:a};for(const{pattern:s,action:a,extractArgs:n}of kp){const o=r.match(s);if(o)return{type:"action",action:a,args:n?n(o):void 0}}return null}function wp({setActiveTab:t,onChatInput:r,onAbortSession:s,onScrollToBottom:a}){return{routeTranscript:c.useCallback(o=>{const i=Jn(o);if(!i){r(o);return}if(i.type==="navigate"){t(i.tab);return}if(i.type==="action")switch(i.action){case"abort":s==null||s();return;case"scroll-bottom":a==null||a();return;case"new-session":t("chat");return;case"git-status":case"git-command":t("git");return;case"clear-chat":t("chat");return;default:r(o)}},[t,r,s,a]),parseIntent:Jn}}function jp({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,latestMessage:n,onFileOpen:o,onInputFocusChange:i,onSessionActive:l,onSessionInactive:m,onSessionProcessing:d,onSessionNotProcessing:u,processingSessions:g,onReplaceTemporarySession:p,onNavigateToSession:x,onShowSettings:f,autoExpandTools:h,showRawParameters:b,showThinking:C,autoScrollToBottom:I,sendByCtrlEnter:y,externalMessageUpdate:v,onShowAllTasks:A,setActiveTab:M}){const{tasksEnabled:$,isTaskMasterInstalled:k}=Yr(),{t:T}=Ge("chat"),{speak:W}=si(),U=c.useRef(""),S=c.useRef(null),H=c.useRef(null),w=c.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),U.current=""},[]),{provider:P,setProvider:j,cursorModel:F,setCursorModel:G,claudeModel:X,setClaudeModel:D,codexModel:oe,setCodexModel:E,permissionMode:se,pendingPermissionRequests:J,setPendingPermissionRequests:B,cyclePermissionMode:K}=ym({selectedSession:r}),{chatMessages:V,setChatMessages:z,isLoading:O,setIsLoading:ne,currentSessionId:me,setCurrentSessionId:q,sessionMessages:N,setSessionMessages:_,isLoadingSessionMessages:re,isLoadingMoreMessages:te,hasMoreMessages:ve,totalMessages:je,setIsSystemSessionChange:Ne,canAbortSession:we,setCanAbortSession:Ie,isUserScrolledUp:Re,setIsUserScrolledUp:Z,tokenBudget:ye,setTokenBudget:Y,visibleMessageCount:ie,visibleMessages:De,loadEarlierMessages:de,loadAllMessages:$e,allMessagesLoaded:Le,isLoadingAllMessages:Je,loadAllJustFinished:Ve,showLoadAllOverlay:ge,claudeStatus:Fe,setClaudeStatus:Ce,createDiff:ze,scrollContainerRef:Pe,scrollToBottom:_e,scrollToBottomAndReset:Ke,handleScroll:ae}=Sm({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:I,externalMessageUpdate:v,processingSessions:g,resetStreamingState:w,pendingViewSessionRef:H}),{input:ke,setInput:Be,textareaRef:Ue,inputHighlightRef:mt,isTextareaExpanded:It,thinkingMode:pt,setThinkingMode:kt,slashCommandsCount:le,filteredCommands:pe,frequentCommands:ue,commandQuery:Se,showCommandMenu:We,selectedCommandIndex:Xe,resetCommandMenuState:Ze,handleCommandSelect:dt,handleToggleCommandMenu:Mt,showFileDropdown:bt,filteredFiles:wt,selectedFileIndex:nt,renderInputWithMentions:at,selectFile:Rt,attachedImages:Bt,setAttachedImages:gr,uploadingImages:hr,imageErrors:R,getRootProps:ee,getInputProps:Ae,isDragActive:et,openImagePicker:jt,handleSubmit:xt,handleInputChange:_s,handleKeyDown:Xr,handlePaste:Zr,handleTextareaClick:es,handleTextareaInput:zs,syncInputOverlayScroll:Os,handleClearInput:Rs,handleAbortSession:fr,handleTranscript:Bs,handlePermissionDecision:ar,handleGrantToolPermission:Mr,handleInputFocusChange:Ws,isInputFocused:Us}=yp({selectedProject:t,selectedSession:r,currentSessionId:me,provider:P,permissionMode:se,cyclePermissionMode:K,cursorModel:F,claudeModel:X,codexModel:oe,isLoading:O,canAbortSession:we,tokenBudget:ye,sendMessage:a,sendByCtrlEnter:y,onSessionActive:l,onInputFocusChange:i,onFileOpen:o,onShowSettings:f,pendingViewSessionRef:H,scrollToBottom:_e,setChatMessages:z,setSessionMessages:_,setIsLoading:ne,setCanAbortSession:Ie,setClaudeStatus:Ce,setIsUserScrolledUp:Z,setPendingPermissionRequests:B});Tm({latestMessage:n,provider:P,selectedProject:t,selectedSession:r,currentSessionId:me,setCurrentSessionId:q,setChatMessages:z,setIsLoading:ne,setCanAbortSession:Ie,setClaudeStatus:Ce,setTokenBudget:Y,setIsSystemSessionChange:Ne,setPendingPermissionRequests:B,pendingViewSessionRef:H,streamBufferRef:U,streamTimerRef:S,onSessionInactive:m,onSessionProcessing:d,onSessionNotProcessing:u,onReplaceTemporarySession:p,onNavigateToSession:x,onResponseComplete:W});const{routeTranscript:Hs}=wp({setActiveTab:M||(()=>{}),onChatInput:Bs,onAbortSession:fr,onScrollToBottom:Ke});if(c.useEffect(()=>{if(!O||!we)return;const Nt=Et=>{Et.key!=="Escape"||Et.repeat||Et.defaultPrevented||(Et.preventDefault(),fr())};return document.addEventListener("keydown",Nt,{capture:!0}),()=>{document.removeEventListener("keydown",Nt,{capture:!0})}},[we,fr,O]),c.useEffect(()=>{const Nt=(r==null?void 0:r.id)||me;Nt&&O&&d&&d(Nt)},[me,O,d,r==null?void 0:r.id]),c.useEffect(()=>()=>{w()},[w]),!t){const Nt=T(P==="cursor"?"messageTypes.cursor":P==="codex"?"messageTypes.codex":"messageTypes.claude");return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:T("projectSelection.startChatWithProvider",{provider:Nt,defaultValue:"Select a project to start chatting with {{provider}}"})})})})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(om,{scrollContainerRef:Pe,onWheel:ae,onTouchMove:ae,isLoadingSessionMessages:re,chatMessages:V,selectedSession:r,currentSessionId:me,provider:P,setProvider:Nt=>j(Nt),textareaRef:Ue,claudeModel:X,setClaudeModel:D,cursorModel:F,setCursorModel:G,codexModel:oe,setCodexModel:E,tasksEnabled:$,isTaskMasterInstalled:k,onShowAllTasks:A,setInput:Be,isLoadingMoreMessages:te,hasMoreMessages:ve,totalMessages:je,sessionMessagesCount:N.length,visibleMessageCount:ie,visibleMessages:De,loadEarlierMessages:de,loadAllMessages:$e,allMessagesLoaded:Le,isLoadingAllMessages:Je,loadAllJustFinished:Ve,showLoadAllOverlay:ge,createDiff:ze,onFileOpen:o,onShowSettings:f,onGrantToolPermission:Mr,autoExpandTools:h,showRawParameters:b,showThinking:C,selectedProject:t,isLoading:O}),e.jsx(bm,{pendingPermissionRequests:J,handlePermissionDecision:ar,handleGrantToolPermission:Mr,claudeStatus:Fe,isLoading:O,onAbortSession:fr,provider:P,permissionMode:se,onModeSwitch:K,thinkingMode:pt,setThinkingMode:kt,tokenBudget:ye,slashCommandsCount:le,onToggleCommandMenu:Mt,hasInput:!!ke.trim(),onClearInput:Rs,isUserScrolledUp:Re,hasMessages:V.length>0,onScrollToBottom:Ke,onSubmit:xt,isDragActive:et,attachedImages:Bt,onRemoveImage:Nt=>gr(Et=>Et.filter((Gs,ts)=>ts!==Nt)),uploadingImages:hr,imageErrors:R,showFileDropdown:bt,filteredFiles:wt,selectedFileIndex:nt,onSelectFile:Rt,filteredCommands:pe,selectedCommandIndex:Xe,onCommandSelect:dt,onCloseCommandMenu:Ze,isCommandMenuOpen:We,frequentCommands:Se?[]:ue,getRootProps:ee,getInputProps:Ae,openImagePicker:jt,inputHighlightRef:mt,renderInputWithMentions:at,textareaRef:Ue,input:ke,onInputChange:_s,onTextareaClick:es,onTextareaKeyDown:Xr,onTextareaPaste:Zr,onTextareaScrollSync:Os,onTextareaInput:zs,onInputFocusChange:Ws,isInputFocused:Us,placeholder:T("input.placeholder",{provider:T(P==="cursor"?"messageTypes.cursor":P==="codex"?"messageTypes.codex":"messageTypes.claude")}),isTextareaExpanded:It,sendByCtrlEnter:y,onTranscript:Hs})]}),e.jsx(Ed,{})]})}const Np=Ft.memo(jp);function Cp({file:t,onClose:r}){const s=`/api/projects/${t.projectName}/files/content?path=${encodeURIComponent(t.path)}`,[a,n]=c.useState(null),[o,i]=c.useState(null),[l,m]=c.useState(!0);return c.useEffect(()=>{let d;const u=new AbortController;return(async()=>{try{m(!0),i(null),n(null);const p=await Ee(s,{signal:u.signal});if(!p.ok)throw new Error(`Request failed with status ${p.status}`);const x=await p.blob();d=URL.createObjectURL(x),n(d)}catch(p){if(p.name==="AbortError")return;console.error("Error loading image:",p),i("Unable to load image")}finally{m(!1)}})(),()=>{u.abort(),d&&URL.revokeObjectURL(d)}},[s]),e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t.name}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:e.jsx(qe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[l&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"Loading image…"})}),!l&&a&&e.jsx("img",{src:a,alt:t.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!l&&!a&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:o||"Unable to load image"}),e.jsx("p",{className:"text-sm mt-2 break-all",children:t.path})]})]}),e.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:t.path})})]})})}const Sp="w-4 h-4 flex-shrink-0",Yn={js:{icon:Fr,color:"text-yellow-500"},jsx:{icon:Fr,color:"text-yellow-500"},mjs:{icon:Fr,color:"text-yellow-500"},cjs:{icon:Fr,color:"text-yellow-500"},ts:{icon:Pr,color:"text-blue-500"},tsx:{icon:Pr,color:"text-blue-500"},mts:{icon:Pr,color:"text-blue-500"},py:{icon:hs,color:"text-emerald-500"},pyw:{icon:hs,color:"text-emerald-500"},pyi:{icon:hs,color:"text-emerald-400"},ipynb:{icon:Ji,color:"text-orange-500"},rs:{icon:Br,color:"text-orange-600"},toml:{icon:Qe,color:"text-gray-500"},go:{icon:Rr,color:"text-cyan-500"},rb:{icon:ua,color:"text-red-500"},erb:{icon:ua,color:"text-red-400"},php:{icon:Vi,color:"text-violet-500"},java:{icon:Za,color:"text-red-600"},jar:{icon:Za,color:"text-red-500"},kt:{icon:Rr,color:"text-violet-500"},kts:{icon:Rr,color:"text-violet-400"},c:{icon:_r,color:"text-blue-600"},h:{icon:_r,color:"text-blue-400"},cpp:{icon:_r,color:"text-blue-700"},hpp:{icon:_r,color:"text-blue-500"},cc:{icon:_r,color:"text-blue-700"},cs:{icon:Rr,color:"text-purple-600"},swift:{icon:ma,color:"text-orange-500"},lua:{icon:Ki,color:"text-blue-500"},r:{icon:qi,color:"text-blue-600"},html:{icon:Vr,color:"text-orange-600"},htm:{icon:Vr,color:"text-orange-600"},css:{icon:Nr,color:"text-blue-500"},scss:{icon:Nr,color:"text-pink-500"},sass:{icon:Nr,color:"text-pink-400"},less:{icon:Nr,color:"text-indigo-500"},vue:{icon:Pr,color:"text-emerald-500"},svelte:{icon:Pr,color:"text-orange-500"},json:{icon:Sr,color:"text-yellow-600"},jsonc:{icon:Sr,color:"text-yellow-500"},json5:{icon:Sr,color:"text-yellow-500"},yaml:{icon:Qe,color:"text-purple-400"},yml:{icon:Qe,color:"text-purple-400"},xml:{icon:Fr,color:"text-orange-500"},csv:{icon:Xa,color:"text-green-600"},tsv:{icon:Xa,color:"text-green-500"},sql:{icon:Gi,color:"text-blue-500"},graphql:{icon:Qa,color:"text-pink-500"},gql:{icon:Qa,color:"text-pink-500"},proto:{icon:Wr,color:"text-green-500"},env:{icon:Pt,color:"text-yellow-600"},md:{icon:da,color:"text-blue-500"},mdx:{icon:da,color:"text-blue-400"},txt:{icon:it,color:"text-gray-500"},doc:{icon:it,color:"text-blue-600"},docx:{icon:it,color:"text-blue-600"},pdf:{icon:ca,color:"text-red-600"},rtf:{icon:it,color:"text-gray-500"},tex:{icon:la,color:"text-teal-600"},rst:{icon:it,color:"text-gray-400"},sh:{icon:ct,color:"text-green-500"},bash:{icon:ct,color:"text-green-500"},zsh:{icon:ct,color:"text-green-400"},fish:{icon:ct,color:"text-green-400"},ps1:{icon:ct,color:"text-blue-400"},bat:{icon:ct,color:"text-gray-500"},cmd:{icon:ct,color:"text-gray-500"},png:{icon:Vt,color:"text-purple-500"},jpg:{icon:Vt,color:"text-purple-500"},jpeg:{icon:Vt,color:"text-purple-500"},gif:{icon:Vt,color:"text-purple-400"},webp:{icon:Vt,color:"text-purple-400"},ico:{icon:Vt,color:"text-purple-400"},bmp:{icon:Vt,color:"text-purple-400"},tiff:{icon:Vt,color:"text-purple-400"},svg:{icon:Hi,color:"text-amber-500"},mp3:{icon:kr,color:"text-pink-500"},wav:{icon:kr,color:"text-pink-500"},ogg:{icon:kr,color:"text-pink-400"},flac:{icon:kr,color:"text-pink-400"},aac:{icon:kr,color:"text-pink-400"},m4a:{icon:kr,color:"text-pink-400"},mp4:{icon:Lr,color:"text-rose-500"},mov:{icon:Lr,color:"text-rose-500"},avi:{icon:Lr,color:"text-rose-500"},webm:{icon:Lr,color:"text-rose-400"},mkv:{icon:Lr,color:"text-rose-400"},ttf:{icon:$r,color:"text-red-500"},otf:{icon:$r,color:"text-red-500"},woff:{icon:$r,color:"text-red-400"},woff2:{icon:$r,color:"text-red-400"},eot:{icon:$r,color:"text-red-400"},zip:{icon:vr,color:"text-amber-600"},tar:{icon:vr,color:"text-amber-600"},gz:{icon:vr,color:"text-amber-600"},bz2:{icon:vr,color:"text-amber-600"},rar:{icon:vr,color:"text-amber-500"},"7z":{icon:vr,color:"text-amber-500"},lock:{icon:Xt,color:"text-gray-500"},exe:{icon:yr,color:"text-gray-500"},bin:{icon:yr,color:"text-gray-500"},dll:{icon:yr,color:"text-gray-400"},so:{icon:yr,color:"text-gray-400"},dylib:{icon:yr,color:"text-gray-400"},wasm:{icon:yr,color:"text-purple-500"},ini:{icon:Qe,color:"text-gray-500"},cfg:{icon:Qe,color:"text-gray-500"},conf:{icon:Qe,color:"text-gray-500"},log:{icon:la,color:"text-gray-400"},map:{icon:bo,color:"text-gray-400"}},Qn={Dockerfile:{icon:Wr,color:"text-blue-500"},"docker-compose.yml":{icon:Wr,color:"text-blue-500"},"docker-compose.yaml":{icon:Wr,color:"text-blue-500"},".dockerignore":{icon:Wr,color:"text-gray-500"},".gitignore":{icon:Qe,color:"text-gray-500"},".gitmodules":{icon:Qe,color:"text-gray-500"},".gitattributes":{icon:Qe,color:"text-gray-500"},".editorconfig":{icon:Qe,color:"text-gray-500"},".prettierrc":{icon:Qe,color:"text-pink-400"},".prettierignore":{icon:Qe,color:"text-gray-500"},".eslintrc":{icon:Qe,color:"text-violet-500"},".eslintrc.js":{icon:Qe,color:"text-violet-500"},".eslintrc.json":{icon:Qe,color:"text-violet-500"},".eslintrc.cjs":{icon:Qe,color:"text-violet-500"},"eslint.config.js":{icon:Qe,color:"text-violet-500"},"eslint.config.mjs":{icon:Qe,color:"text-violet-500"},".env":{icon:Pt,color:"text-yellow-600"},".env.local":{icon:Pt,color:"text-yellow-600"},".env.development":{icon:Pt,color:"text-yellow-500"},".env.production":{icon:Pt,color:"text-yellow-600"},".env.example":{icon:Pt,color:"text-yellow-400"},"package.json":{icon:Sr,color:"text-green-500"},"package-lock.json":{icon:Xt,color:"text-gray-500"},"yarn.lock":{icon:Xt,color:"text-blue-400"},"pnpm-lock.yaml":{icon:Xt,color:"text-orange-400"},"bun.lockb":{icon:Xt,color:"text-gray-400"},"Cargo.toml":{icon:Br,color:"text-orange-600"},"Cargo.lock":{icon:Xt,color:"text-orange-400"},Gemfile:{icon:ua,color:"text-red-500"},"Gemfile.lock":{icon:Xt,color:"text-red-400"},Makefile:{icon:ct,color:"text-gray-500"},"CMakeLists.txt":{icon:Br,color:"text-blue-500"},"tsconfig.json":{icon:Sr,color:"text-blue-500"},"jsconfig.json":{icon:Sr,color:"text-yellow-500"},"vite.config.ts":{icon:ma,color:"text-purple-500"},"vite.config.js":{icon:ma,color:"text-purple-500"},"webpack.config.js":{icon:Br,color:"text-blue-500"},"tailwind.config.js":{icon:Nr,color:"text-cyan-500"},"tailwind.config.ts":{icon:Nr,color:"text-cyan-500"},"postcss.config.js":{icon:Br,color:"text-red-400"},"babel.config.js":{icon:Qe,color:"text-yellow-500"},".babelrc":{icon:Qe,color:"text-yellow-500"},"README.md":{icon:da,color:"text-blue-500"},LICENSE:{icon:ca,color:"text-gray-500"},"LICENSE.md":{icon:ca,color:"text-gray-500"},"CHANGELOG.md":{icon:la,color:"text-blue-400"},"requirements.txt":{icon:it,color:"text-emerald-400"},"go.mod":{icon:Rr,color:"text-cyan-500"},"go.sum":{icon:Xt,color:"text-cyan-400"}};function Ep(t){var s;if(Qn[t])return Qn[t];if(t.startsWith(".env"))return{icon:Pt,color:"text-yellow-600"};const r=(s=t.split(".").pop())==null?void 0:s.toLowerCase();return r&&Yn[r]?Yn[r]:{icon:bo,color:"text-muted-foreground"}}function Tp({selectedProject:t,onFileOpen:r}){const{t:s}=Ge(),[a,n]=c.useState([]),[o,i]=c.useState(!1),[l,m]=c.useState(new Set),[d,u]=c.useState(null),[g,p]=c.useState("detailed"),[x,f]=c.useState(""),[h,b]=c.useState([]);c.useEffect(()=>{t&&I()},[t]),c.useEffect(()=>{const w=localStorage.getItem("file-tree-view-mode");w&&["simple","detailed","compact"].includes(w)&&p(w)},[]),c.useEffect(()=>{if(!x.trim())b(a);else{const w=C(a,x.toLowerCase());b(w);const P=j=>{j.forEach(F=>{F.type==="directory"&&F.children&&F.children.length>0&&(m(G=>new Set(G.add(F.path))),P(F.children))})};P(w)}},[a,x]);const C=(w,P)=>w.reduce((j,F)=>{const G=F.name.toLowerCase().includes(P);let X=[];return F.type==="directory"&&F.children&&(X=C(F.children,P)),(G||X.length>0)&&j.push({...F,children:X}),j},[]),I=async()=>{i(!0);try{const w=await He.getFiles(t.name);if(!w.ok){const j=await w.text();console.error("❌ File fetch failed:",w.status,j),n([]);return}const P=await w.json();n(P)}catch(w){console.error("❌ Error fetching files:",w),n([])}finally{i(!1)}},y=w=>{const P=new Set(l);P.has(w)?P.delete(w):P.add(w),m(P)},v=w=>{p(w),localStorage.setItem("file-tree-view-mode",w)},A=w=>{if(!w||w===0)return"0 B";const P=1024,j=["B","KB","MB","GB"],F=Math.floor(Math.log(w)/Math.log(P));return parseFloat((w/Math.pow(P,F)).toFixed(1))+" "+j[F]},M=w=>{if(!w)return"-";const P=new Date,j=new Date(w),F=Math.floor((P-j)/1e3);return F<60?s("fileTree.justNow"):F<3600?s("fileTree.minAgo",{count:Math.floor(F/60)}):F<86400?s("fileTree.hoursAgo",{count:Math.floor(F/3600)}):F<2592e3?s("fileTree.daysAgo",{count:Math.floor(F/86400)}):j.toLocaleDateString()},$=w=>{var F;const P=(F=w.split(".").pop())==null?void 0:F.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(P)},k=w=>{const{icon:P,color:j}=Ep(w);return e.jsx(P,{className:be(Sp,j)})},T=w=>{w.type==="directory"?y(w.path):$(w.name)?u({name:w.name,path:w.path,projectPath:t.path,projectName:t.name}):r&&r(w.path)},W=w=>{const P=w.type==="directory",j=l.has(w.path);return P?e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(Ot,{className:be("w-3.5 h-3.5 text-muted-foreground/70 transition-transform duration-150",j&&"rotate-90")}),j?e.jsx(er,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(tr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})]}):e.jsx("span",{className:"flex items-center flex-shrink-0 ml-[18px]",children:k(w.name)})},U=(w,P=0)=>w.map(j=>{const F=j.type==="directory",G=F&&l.has(j.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:be("group flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer rounded-sm","hover:bg-accent/60 transition-colors duration-100",F&&G&&"border-l-2 border-primary/30",F&&!G&&"border-l-2 border-transparent",!F&&"border-l-2 border-transparent"),style:{paddingLeft:`${P*16+4}px`},onClick:()=>T(j),children:[W(j),e.jsx("span",{className:be("text-[13px] leading-tight truncate",F?"font-medium text-foreground":"text-foreground/90"),children:j.name})]}),F&&G&&j.children&&j.children.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${P*16+14}px`},"aria-hidden":"true"}),U(j.children,P+1)]})]},j.path)}),S=(w,P=0)=>w.map(j=>{const F=j.type==="directory",G=F&&l.has(j.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:be("group grid grid-cols-12 gap-2 py-[3px] pr-2 hover:bg-accent/60 cursor-pointer items-center rounded-sm transition-colors duration-100",F&&G&&"border-l-2 border-primary/30",F&&!G&&"border-l-2 border-transparent",!F&&"border-l-2 border-transparent"),style:{paddingLeft:`${P*16+4}px`},onClick:()=>T(j),children:[e.jsxs("div",{className:"col-span-5 flex items-center gap-1.5 min-w-0",children:[W(j),e.jsx("span",{className:be("text-[13px] leading-tight truncate",F?"font-medium text-foreground":"text-foreground/90"),children:j.name})]}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground tabular-nums",children:j.type==="file"?A(j.size):""}),e.jsx("div",{className:"col-span-3 text-sm text-muted-foreground",children:M(j.modified)}),e.jsx("div",{className:"col-span-2 text-sm text-muted-foreground font-mono",children:j.permissionsRwx||""})]}),F&&G&&j.children&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${P*16+14}px`},"aria-hidden":"true"}),S(j.children,P+1)]})]},j.path)}),H=(w,P=0)=>w.map(j=>{const F=j.type==="directory",G=F&&l.has(j.path);return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{className:be("group flex items-center justify-between py-[3px] pr-2 hover:bg-accent/60 cursor-pointer rounded-sm transition-colors duration-100",F&&G&&"border-l-2 border-primary/30",F&&!G&&"border-l-2 border-transparent",!F&&"border-l-2 border-transparent"),style:{paddingLeft:`${P*16+4}px`},onClick:()=>T(j),children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[W(j),e.jsx("span",{className:be("text-[13px] leading-tight truncate",F?"font-medium text-foreground":"text-foreground/90"),children:j.name})]}),e.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground flex-shrink-0 ml-2",children:j.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tabular-nums",children:A(j.size)}),e.jsx("span",{className:"font-mono",children:j.permissionsRwx})]})})]}),F&&G&&j.children&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${P*16+14}px`},"aria-hidden":"true"}),H(j.children,P+1)]})]},j.path)});return o?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"text-muted-foreground text-sm",children:s("fileTree.loading")})}):e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 border-b border-border space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s("fileTree.files")}),e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx(xe,{variant:g==="simple"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>v("simple"),title:s("fileTree.simpleView"),children:e.jsx(bs,{className:"w-3.5 h-3.5"})}),e.jsx(xe,{variant:g==="compact"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>v("compact"),title:s("fileTree.compactView"),children:e.jsx(ur,{className:"w-3.5 h-3.5"})}),e.jsx(xe,{variant:g==="detailed"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>v("detailed"),title:s("fileTree.detailedView"),children:e.jsx(Ui,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(dr,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(st,{type:"text",placeholder:s("fileTree.searchPlaceholder"),value:x,onChange:w=>f(w.target.value),className:"pl-8 pr-8 h-8 text-sm"}),x&&e.jsx(xe,{variant:"ghost",size:"sm",className:"absolute right-0.5 top-1/2 transform -translate-y-1/2 h-5 w-5 p-0 hover:bg-accent",onClick:()=>f(""),title:s("fileTree.clearSearch"),children:e.jsx(qe,{className:"w-3 h-3"})})]})]}),g==="detailed"&&h.length>0&&e.jsx("div",{className:"px-3 pt-1.5 pb-1 border-b border-border",children:e.jsxs("div",{className:"grid grid-cols-12 gap-2 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:[e.jsx("div",{className:"col-span-5",children:s("fileTree.name")}),e.jsx("div",{className:"col-span-2",children:s("fileTree.size")}),e.jsx("div",{className:"col-span-3",children:s("fileTree.modified")}),e.jsx("div",{className:"col-span-2",children:s("fileTree.permissions")})]})}),e.jsx(Ra,{className:"flex-1 px-2 py-1",children:a.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(tr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:s("fileTree.noFilesFound")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("fileTree.checkProjectPath")})]}):h.length===0&&x?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(dr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:s("fileTree.noMatchesFound")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("fileTree.tryDifferentSearch")})]}):e.jsxs("div",{children:[g==="simple"&&U(h),g==="compact"&&H(h),g==="detailed"&&S(h)]})}),d&&e.jsx(Cp,{file:d,onClose:()=>u(null)})]})}function Xn({diff:t,fileName:r,isMobile:s,wrapText:a}){if(!t)return e.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No diff available"});const n=(o,i)=>{const l=o.startsWith("+")&&!o.startsWith("+++"),m=o.startsWith("-")&&!o.startsWith("---"),d=o.startsWith("@@");return e.jsx("div",{className:`font-mono text-xs px-3 py-0.5 ${s&&a?"whitespace-pre-wrap break-all":"whitespace-pre overflow-x-auto"} ${l?"bg-green-50 dark:bg-green-950/50 text-green-700 dark:text-green-300":m?"bg-red-50 dark:bg-red-950/50 text-red-700 dark:text-red-300":d?"bg-primary/5 text-primary":"text-muted-foreground/70"}`,children:o},i)};return e.jsx("div",{className:"diff-viewer",children:t.split(`
141
+ `).map((o,i)=>n(o,i))})}function Ip({selectedProject:t,isMobile:r,onFileOpen:s}){var Xe,Ze,dt,Mt,bt,wt,nt,at,Rt,Bt,gr,hr;const{addToast:a}=mr(),[n,o]=c.useState(null),[i,l]=c.useState({}),[m,d]=c.useState(!1),[u,g]=c.useState(""),[p,x]=c.useState(new Set),[f,h]=c.useState(new Set),[b,C]=c.useState(!1),[I,y]=c.useState(""),[v,A]=c.useState([]),[M,$]=c.useState(!0),[k,T]=c.useState(!1),[W,U]=c.useState(!1),[S,H]=c.useState(!1),[w,P]=c.useState(""),[j,F]=c.useState(!1),[G,X]=c.useState("changes"),[D,oe]=c.useState([]),[E,se]=c.useState(new Set),[J,B]=c.useState({}),[K,V]=c.useState(!1),[z,O]=c.useState(null),[ne,me]=c.useState(!1),[q,N]=c.useState(!1),[_,re]=c.useState(!1),[te,ve]=c.useState(!1),[je,Ne]=c.useState(r),[we,Ie]=c.useState(null),[Re,Z]=c.useState(!1),ye=c.useRef(null),Y=c.useRef(null),[ie,De]=c.useState(()=>localStorage.getItem("selected-provider")||"claude");c.useEffect(()=>{const R=()=>{const ee=localStorage.getItem("selected-provider")||"claude";De(ee)};return window.addEventListener("storage",R),()=>window.removeEventListener("storage",R)},[]),c.useEffect(()=>{y(""),A([]),o(null),O(null),h(new Set),t&&(de(),$e(),Le())},[t]),c.useEffect(()=>{!t||G!=="history"||Be()},[t,G]),c.useEffect(()=>{const R=ee=>{Y.current&&!Y.current.contains(ee.target)&&U(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[]);const de=async()=>{if(t){d(!0);try{const ee=await(await Ee(`/api/git/status?project=${encodeURIComponent(t.name)}`)).json();if(ee.error)console.error("Git status error:",ee.error),o({error:ee.error,details:ee.details}),y(""),h(new Set);else{o(ee),y(ee.branch||"main");const Ae=new Set([...ee.modified||[],...ee.added||[],...ee.deleted||[],...ee.untracked||[]]);h(Ae);for(const et of ee.modified||[])ae(et);for(const et of ee.added||[])ae(et);for(const et of ee.deleted||[])ae(et);for(const et of ee.untracked||[])ae(et)}}catch(R){console.error("Error fetching git status:",R),o({error:"Git operation failed",details:String(R)}),y(""),h(new Set)}finally{d(!1)}}},$e=async()=>{try{const ee=await(await Ee(`/api/git/branches?project=${encodeURIComponent(t.name)}`)).json();!ee.error&&ee.branches?A(ee.branches):A([])}catch(R){console.error("Error fetching branches:",R),A([])}},Le=async()=>{if(t)try{const ee=await(await Ee(`/api/git/remote-status?project=${encodeURIComponent(t.name)}`)).json();ee.error?O(null):O(ee)}catch(R){console.error("Error fetching remote status:",R),O(null)}},Je=async R=>{try{const Ae=await(await Ee("/api/git/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:R})})).json();Ae.success?(y(R),U(!1),de()):console.error("Failed to switch branch:",Ae.error)}catch(ee){console.error("Error switching branch:",ee)}},Ve=async()=>{if(w.trim()){F(!0);try{const ee=await(await Ee("/api/git/create-branch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:w.trim()})})).json();ee.success?(y(w.trim()),H(!1),U(!1),P(""),$e(),de()):console.error("Failed to create branch:",ee.error)}catch(R){console.error("Error creating branch:",R)}finally{F(!1)}}},ge=async()=>{me(!0);try{const ee=await(await Ee("/api/git/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();ee.success?(de(),Le()):console.error("Fetch failed:",ee.error)}catch(R){console.error("Error fetching from remote:",R)}finally{me(!1)}},Fe=async()=>{N(!0);try{const ee=await(await Ee("/api/git/pull",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();ee.success?(de(),Le()):console.error("Pull failed:",ee.error)}catch(R){console.error("Error pulling from remote:",R)}finally{N(!1)}},Ce=async()=>{re(!0);try{const ee=await(await Ee("/api/git/push",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();ee.success?(de(),Le()):console.error("Push failed:",ee.error)}catch(R){console.error("Error pushing to remote:",R)}finally{re(!1)}},ze=async()=>{ve(!0);try{const ee=await(await Ee("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,branch:I})})).json();ee.success?(de(),Le()):console.error("Publish failed:",ee.error)}catch(R){console.error("Error publishing branch:",R)}finally{ve(!1)}},Pe=async R=>{try{const Ae=await(await Ee("/api/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,file:R})})).json();Ae.success?(h(et=>{const jt=new Set(et);return jt.delete(R),jt}),de()):console.error("Discard failed:",Ae.error)}catch(ee){console.error("Error discarding changes:",ee)}},_e=async R=>{try{const Ae=await(await Ee("/api/git/delete-untracked",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,file:R})})).json();Ae.success?(h(et=>{const jt=new Set(et);return jt.delete(R),jt}),de()):console.error("Delete failed:",Ae.error)}catch(ee){console.error("Error deleting untracked file:",ee)}},Ke=async()=>{if(!we)return;const{type:R,file:ee,message:Ae}=we;Ie(null);try{switch(R){case"discard":await Pe(ee);break;case"delete":await _e(ee);break;case"commit":await le();break;case"pull":await Fe();break;case"push":await Ce();break;case"publish":await ze();break}}catch(et){console.error(`Error executing ${R}:`,et)}},ae=async R=>{try{const Ae=await(await Ee(`/api/git/diff?project=${encodeURIComponent(t.name)}&file=${encodeURIComponent(R)}`)).json();!Ae.error&&Ae.diff&&l(et=>({...et,[R]:Ae.diff}))}catch(ee){console.error("Error fetching file diff:",ee)}},ke=async R=>{if(s)try{const Ae=await(await Ee(`/api/git/file-with-diff?project=${encodeURIComponent(t.name)}&file=${encodeURIComponent(R)}`)).json();if(Ae.error){console.error("Error fetching file with diff:",Ae.error),s(R);return}const et={old_string:Ae.oldContent||"",new_string:Ae.currentContent||""};s(R,et)}catch(ee){console.error("Error opening file:",ee),s(R)}},Be=async()=>{try{const ee=await(await Ee(`/api/git/commits?project=${encodeURIComponent(t.name)}&limit=10`)).json();!ee.error&&ee.commits&&oe(ee.commits)}catch(R){console.error("Error fetching commits:",R)}},Ue=async R=>{try{const Ae=await(await Ee(`/api/git/commit-diff?project=${encodeURIComponent(t.name)}&commit=${R}`)).json();!Ae.error&&Ae.diff&&B(et=>({...et,[R]:Ae.diff}))}catch(ee){console.error("Error fetching commit diff:",ee)}},mt=async()=>{V(!0);try{const ee=await(await Ee("/api/git/generate-commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,files:Array.from(f),provider:ie})})).json();ee.message?g(ee.message):console.error("Failed to generate commit message:",ee.error)}catch(R){console.error("Error generating commit message:",R)}finally{V(!1)}},It=R=>{x(ee=>{const Ae=new Set(ee);return Ae.has(R)?Ae.delete(R):Ae.add(R),Ae})},pt=R=>{se(ee=>{const Ae=new Set(ee);return Ae.has(R)?Ae.delete(R):(Ae.add(R),J[R]||Ue(R)),Ae})},kt=R=>{h(ee=>{const Ae=new Set(ee);return Ae.has(R)?Ae.delete(R):Ae.add(R),Ae})},le=async()=>{if(!(!u.trim()||f.size===0)){C(!0);try{const ee=await(await Ee("/api/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name,message:u,files:Array.from(f)})})).json();ee.success?(g(""),h(new Set),de(),Le()):console.error("Commit failed:",ee.error)}catch(R){console.error("Error committing changes:",R)}finally{C(!1)}}},pe=async()=>{Z(!0);try{const ee=await(await Ee("/api/git/initial-commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t.name})})).json();ee.success?(de(),Le()):(console.error("Initial commit failed:",ee.error),a(ee.error||"Failed to create initial commit","error"))}catch(R){console.error("Error creating initial commit:",R),a("Failed to create initial commit","error")}finally{Z(!1)}},ue=R=>{switch(R){case"M":return"Modified";case"A":return"Added";case"D":return"Deleted";case"U":return"Untracked";default:return R}},Se=R=>{const ee=E.has(R.hash),Ae=J[R.hash];return e.jsxs("div",{className:"border-b border-border last:border-0",children:[e.jsxs("div",{className:"flex items-start p-3 hover:bg-accent/50 cursor-pointer transition-colors",onClick:()=>pt(R.hash),children:[e.jsx("div",{className:"mr-2 mt-1 p-0.5 hover:bg-accent rounded",children:ee?e.jsx(vt,{className:"w-3 h-3"}):e.jsx(Ot,{className:"w-3 h-3"})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:R.message}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[R.author," • ",R.date]})]}),e.jsx("span",{className:"text-sm font-mono text-muted-foreground/60 flex-shrink-0",children:R.hash.substring(0,7)})]})})]}),ee&&Ae&&e.jsx("div",{className:"bg-muted/50",children:e.jsxs("div",{className:"max-h-96 overflow-y-auto p-2",children:[e.jsx("div",{className:"text-sm font-mono text-muted-foreground mb-2",children:R.stats}),e.jsx(Xn,{diff:Ae,fileName:"commit",isMobile:r,wrapText:M})]})})]},R.hash)},We=(R,ee)=>{const Ae=p.has(R),et=f.has(R),jt=i[R];return e.jsxs("div",{className:"border-b border-border last:border-0",children:[e.jsxs("div",{className:`flex items-center hover:bg-accent/50 transition-colors ${r?"px-2 py-1.5":"px-3 py-2"}`,children:[e.jsx("input",{type:"checkbox",checked:et,onChange:()=>kt(R),onClick:xt=>xt.stopPropagation(),className:`rounded border-border text-primary focus:ring-primary/40 bg-background checked:bg-primary ${r?"mr-1.5":"mr-2"}`}),e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:`p-0.5 hover:bg-accent rounded cursor-pointer ${r?"mr-1":"mr-2"}`,onClick:xt=>{xt.stopPropagation(),It(R)},children:e.jsx(Ot,{className:`w-3 h-3 transition-transform duration-200 ease-in-out ${Ae?"rotate-90":"rotate-0"}`})}),e.jsx("span",{className:`flex-1 truncate ${r?"text-xs":"text-sm"} cursor-pointer hover:text-primary hover:underline`,onClick:xt=>{xt.stopPropagation(),ke(R)},title:"Click to open file",children:R}),e.jsxs("div",{className:"flex items-center gap-1",children:[(ee==="M"||ee==="D")&&e.jsxs("button",{onClick:xt=>{xt.stopPropagation(),Ie({type:"discard",file:R,message:`Discard all changes to "${R}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-destructive/10 rounded text-destructive font-medium flex items-center gap-1`,title:"Discard changes",children:[e.jsx(ht,{className:"w-3 h-3"}),r&&e.jsx("span",{children:"Discard"})]}),ee==="U"&&e.jsxs("button",{onClick:xt=>{xt.stopPropagation(),Ie({type:"delete",file:R,message:`Delete untracked file "${R}"? This action cannot be undone.`})},className:`${r?"px-2 py-1 text-xs":"p-1"} hover:bg-destructive/10 rounded text-destructive font-medium flex items-center gap-1`,title:"Delete untracked file",children:[e.jsx(ht,{className:"w-3 h-3"}),r&&e.jsx("span",{children:"Delete"})]}),e.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-[10px] font-bold border ${ee==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800/50":ee==="A"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 border-green-200 dark:border-green-800/50":ee==="D"?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 border-red-200 dark:border-red-800/50":"bg-muted text-muted-foreground border-border"}`,title:ue(ee),children:ee})]})]})]}),e.jsxs("div",{className:`bg-muted/50 transition-all duration-400 ease-in-out overflow-hidden ${Ae&&jt?"max-h-[600px] opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-1"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-2 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-flex items-center justify-center w-5 h-5 rounded text-[10px] font-bold border ${ee==="M"?"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800/50":ee==="A"?"bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 border-green-200 dark:border-green-800/50":ee==="D"?"bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 border-red-200 dark:border-red-800/50":"bg-muted text-muted-foreground border-border"}`,children:ee}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:ue(ee)})]}),r&&e.jsx("button",{onClick:xt=>{xt.stopPropagation(),$(!M)},className:"text-sm text-muted-foreground hover:text-foreground transition-colors",title:M?"Switch to horizontal scroll":"Switch to text wrap",children:M?"↔️ Scroll":"↩️ Wrap"})]}),e.jsx("div",{className:"max-h-96 overflow-y-auto",children:jt&&e.jsx(Xn,{diff:jt,fileName:R,isMobile:r,wrapText:M})})]})]},R)};return t?e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsxs("div",{className:`flex items-center justify-between border-b border-border/60 ${r?"px-3 py-2":"px-4 py-3"}`,children:[e.jsxs("div",{className:"relative",ref:Y,children:[e.jsxs("button",{onClick:()=>U(!W),className:`flex items-center hover:bg-accent rounded-lg transition-colors ${r?"space-x-1 px-2 py-1":"space-x-2 px-3 py-1.5"}`,children:[e.jsx(Gt,{className:`text-muted-foreground ${r?"w-3 h-3":"w-4 h-4"}`}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`font-medium ${r?"text-xs":"text-sm"}`,children:I}),(z==null?void 0:z.hasRemote)&&e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[z.ahead>0&&e.jsxs("span",{className:"text-green-600 dark:text-green-400",title:`${z.ahead} commit${z.ahead!==1?"s":""} ahead`,children:["↑",z.ahead]}),z.behind>0&&e.jsxs("span",{className:"text-primary",title:`${z.behind} commit${z.behind!==1?"s":""} behind`,children:["↓",z.behind]}),z.isUpToDate&&e.jsx("span",{className:"text-muted-foreground",title:"Up to date with remote",children:"✓"})]})]}),e.jsx(vt,{className:`w-3 h-3 text-muted-foreground transition-transform ${W?"rotate-180":""}`})]}),W&&e.jsxs("div",{className:"absolute top-full left-0 mt-1 w-64 bg-card rounded-xl shadow-lg border border-border z-50 overflow-hidden",children:[e.jsx("div",{className:"py-1 max-h-64 overflow-y-auto",children:v.map(R=>e.jsx("button",{onClick:()=>Je(R),className:`w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors ${R===I?"bg-accent/50 text-foreground":"text-muted-foreground"}`,children:e.jsxs("div",{className:"flex items-center space-x-2",children:[R===I&&e.jsx(Tt,{className:"w-3 h-3 text-primary"}),e.jsx("span",{className:R===I?"font-medium":"",children:R})]})},R))}),e.jsx("div",{className:"border-t border-border py-1",children:e.jsxs("button",{onClick:()=>{H(!0),U(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-accent transition-colors flex items-center space-x-2",children:[e.jsx(lt,{className:"w-3 h-3"}),e.jsx("span",{children:"Create new branch"})]})})]})]}),e.jsxs("div",{className:`flex items-center ${r?"gap-1":"gap-2"}`,children:[(z==null?void 0:z.hasRemote)&&e.jsxs(e.Fragment,{children:[!(z!=null&&z.hasUpstream)&&e.jsxs("button",{onClick:()=>Ie({type:"publish",message:`Publish branch "${I}" to ${z.remoteName}?`}),disabled:te,className:"px-2.5 py-1 text-sm bg-purple-600 text-white rounded-lg hover:bg-purple-700 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Publish branch "${I}" to ${z.remoteName}`,children:[e.jsx(as,{className:`w-3 h-3 ${te?"animate-pulse":""}`}),e.jsx("span",{children:te?"Publishing...":"Publish"})]}),(z==null?void 0:z.hasUpstream)&&!(z!=null&&z.isUpToDate)&&e.jsxs(e.Fragment,{children:[z.behind>0&&e.jsxs("button",{onClick:()=>Ie({type:"pull",message:`Pull ${z.behind} commit${z.behind!==1?"s":""} from ${z.remoteName}?`}),disabled:q,className:"px-2.5 py-1 text-sm bg-green-600 text-white rounded-lg hover:bg-green-700 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Pull ${z.behind} commit${z.behind!==1?"s":""} from ${z.remoteName}`,children:[e.jsx(ys,{className:`w-3 h-3 ${q?"animate-pulse":""}`}),e.jsx("span",{children:q?"Pulling...":`Pull ${z.behind}`})]}),z.ahead>0&&e.jsxs("button",{onClick:()=>Ie({type:"push",message:`Push ${z.ahead} commit${z.ahead!==1?"s":""} to ${z.remoteName}?`}),disabled:_,className:"px-2.5 py-1 text-sm bg-orange-600 text-white rounded-lg hover:bg-orange-700 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Push ${z.ahead} commit${z.ahead!==1?"s":""} to ${z.remoteName}`,children:[e.jsx(as,{className:`w-3 h-3 ${_?"animate-pulse":""}`}),e.jsx("span",{children:_?"Pushing...":`Push ${z.ahead}`})]}),(z.ahead>0||z.behind>0&&z.ahead>0)&&e.jsxs("button",{onClick:ge,disabled:ne,className:"px-2.5 py-1 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 flex items-center gap-1 transition-colors",title:`Fetch from ${z.remoteName}`,children:[e.jsx(Ut,{className:`w-3 h-3 ${ne?"animate-spin":""}`}),e.jsx("span",{children:ne?"Fetching...":"Fetch"})]})]})]}),e.jsx("button",{onClick:()=>{de(),$e(),Le()},disabled:m,className:`hover:bg-accent rounded-lg transition-colors ${r?"p-1":"p-1.5"}`,children:e.jsx(Ut,{className:`text-muted-foreground ${m?"animate-spin":""} ${r?"w-3 h-3":"w-4 h-4"}`})})]})]}),n!=null&&n.error?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-muted-foreground px-6 py-12",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/50 flex items-center justify-center mb-6",children:e.jsx(Gt,{className:"w-8 h-8 opacity-40"})}),e.jsx("h3",{className:"text-lg font-medium mb-3 text-center text-foreground",children:n.error}),n.details&&e.jsx("p",{className:"text-sm text-center leading-relaxed mb-6 max-w-md",children:n.details}),e.jsx("div",{className:"p-4 bg-primary/5 rounded-xl border border-primary/10 max-w-md",children:e.jsxs("p",{className:"text-sm text-primary text-center",children:[e.jsx("strong",{children:"Tip:"})," Run ",e.jsx("code",{className:"bg-primary/10 px-2 py-1 rounded-md font-mono text-xs",children:"git init"})," in your project directory to initialize git source control."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex border-b border-border/60 transition-all duration-300 ease-in-out ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[e.jsx("button",{onClick:()=>X("changes"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${G==="changes"?"text-primary border-b-2 border-primary":"text-muted-foreground hover:text-foreground"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(it,{className:"w-4 h-4"}),e.jsx("span",{children:"Changes"})]})}),e.jsx("button",{onClick:()=>X("history"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${G==="history"?"text-primary border-b-2 border-primary":"text-muted-foreground hover:text-foreground"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(en,{className:"w-4 h-4"}),e.jsx("span",{children:"History"})]})})]}),G==="changes"&&e.jsx(e.Fragment,{children:e.jsx("div",{className:`transition-all duration-300 ease-in-out ${p.size===0?"max-h-96 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:r&&je?e.jsx("div",{className:"px-4 py-2 border-b border-border/60",children:e.jsxs("button",{onClick:()=>Ne(!1),className:"w-full flex items-center justify-center gap-2 px-3 py-2 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors",children:[e.jsx(qs,{className:"w-4 h-4"}),e.jsxs("span",{children:["Commit ",f.size," file",f.size!==1?"s":""]}),e.jsx(vt,{className:"w-3 h-3"})]})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"px-4 py-3 border-b border-border/60",children:[r&&e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Commit Changes"}),e.jsx("button",{onClick:()=>Ne(!0),className:"p-1 hover:bg-accent rounded-lg transition-colors",children:e.jsx(vt,{className:"w-4 h-4 rotate-180"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:ye,value:u,onChange:R=>g(R.target.value),placeholder:"Message (Ctrl+Enter to commit)",className:"w-full px-3 py-2 text-sm border border-border rounded-xl bg-background text-foreground placeholder:text-muted-foreground resize-none pr-20 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30",rows:"3",onKeyDown:R=>{R.key==="Enter"&&(R.ctrlKey||R.metaKey)&&le()}}),e.jsxs("div",{className:"absolute right-2 top-2 flex gap-1",children:[e.jsx("button",{onClick:mt,disabled:f.size===0||K,className:"p-1.5 text-muted-foreground hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Generate commit message",children:K?e.jsx(Ut,{className:"w-4 h-4 animate-spin"}):e.jsx(Ht,{className:"w-4 h-4"})}),e.jsx("div",{style:{display:"none"},children:e.jsx(ei,{onTranscript:R=>g(R),mode:"default",className:"p-1.5"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f.size," file",f.size!==1?"s":""," selected"]}),e.jsxs("button",{onClick:()=>Ie({type:"commit",message:`Commit ${f.size} file${f.size!==1?"s":""} with message: "${u.trim()}"?`}),disabled:!u.trim()||f.size===0||b,className:"px-3 py-1.5 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-1 transition-colors",children:[e.jsx(Tt,{className:"w-3 h-3"}),e.jsx("span",{children:b?"Committing...":"Commit"})]})]})]})})})}),G==="changes"&&n&&!n.error&&e.jsxs("div",{className:`border-b border-border/60 flex items-center justify-between transition-all duration-300 ease-in-out ${r?"px-3 py-1.5":"px-4 py-2"} ${p.size===0?"max-h-16 opacity-100 translate-y-0":"max-h-0 opacity-0 -translate-y-2 overflow-hidden"}`,children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[f.size," of ",(((Xe=n==null?void 0:n.modified)==null?void 0:Xe.length)||0)+(((Ze=n==null?void 0:n.added)==null?void 0:Ze.length)||0)+(((dt=n==null?void 0:n.deleted)==null?void 0:dt.length)||0)+(((Mt=n==null?void 0:n.untracked)==null?void 0:Mt.length)||0)," ",r?"":"files"," selected"]}),e.jsxs("div",{className:`flex ${r?"gap-1":"gap-2"}`,children:[e.jsx("button",{onClick:()=>{const R=new Set([...(n==null?void 0:n.modified)||[],...(n==null?void 0:n.added)||[],...(n==null?void 0:n.deleted)||[],...(n==null?void 0:n.untracked)||[]]);h(R)},className:"text-sm text-primary hover:text-primary/80 transition-colors",children:r?"All":"Select All"}),e.jsx("span",{className:"text-border",children:"|"}),e.jsx("button",{onClick:()=>h(new Set),className:"text-sm text-primary hover:text-primary/80 transition-colors",children:r?"None":"Deselect All"})]})]}),!(n!=null&&n.error)&&!r&&e.jsxs("div",{className:"border-b border-border/60",children:[e.jsxs("button",{onClick:()=>T(!k),className:"w-full px-4 py-2 bg-muted/30 hover:bg-muted/50 text-sm text-muted-foreground flex items-center justify-center gap-1 transition-colors",children:[e.jsx(Yi,{className:"w-3 h-3"}),e.jsx("span",{children:"File Status Guide"}),k?e.jsx(vt,{className:"w-3 h-3"}):e.jsx(Ot,{className:"w-3 h-3"})]}),k&&e.jsx("div",{className:"px-4 py-3 bg-muted/30 text-sm",children:e.jsxs("div",{className:`${r?"grid grid-cols-2 gap-3 justify-items-center":"flex justify-center gap-6"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-yellow-100 text-yellow-700 dark:bg-yellow-900/40 dark:text-yellow-300 rounded border border-yellow-200 dark:border-yellow-800/50 font-bold text-[10px]",children:"M"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Modified"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 rounded border border-green-200 dark:border-green-800/50 font-bold text-[10px]",children:"A"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Added"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300 rounded border border-red-200 dark:border-red-800/50 font-bold text-[10px]",children:"D"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Deleted"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 bg-muted text-muted-foreground rounded border border-border font-bold text-[10px]",children:"U"}),e.jsx("span",{className:"text-muted-foreground italic",children:"Untracked"})]})]})})]})]}),G==="changes"&&!(n!=null&&n.error)&&e.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:m?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(Ut,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):(n==null?void 0:n.hasCommits)===!1?e.jsxs("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-muted/50 flex items-center justify-center mb-4",children:e.jsx(Gt,{className:"w-7 h-7 text-muted-foreground/50"})}),e.jsx("h3",{className:"text-lg font-medium mb-2 text-foreground",children:"No commits yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-md",children:"This repository doesn't have any commits yet. Create your first commit to start tracking changes."}),e.jsx("button",{onClick:pe,disabled:Re,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 transition-colors",children:Re?e.jsxs(e.Fragment,{children:[e.jsx(Ut,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:"Creating Initial Commit..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(qs,{className:"w-4 h-4"}),e.jsx("span",{children:"Create Initial Commit"})]})})]}):!n||!((bt=n.modified)!=null&&bt.length)&&!((wt=n.added)!=null&&wt.length)&&!((nt=n.deleted)!=null&&nt.length)&&!((at=n.untracked)!=null&&at.length)?e.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-muted-foreground",children:[e.jsx(qs,{className:"w-10 h-10 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No changes detected"})]}):e.jsxs("div",{className:r?"pb-4":"",children:[(Rt=n.modified)==null?void 0:Rt.map(R=>We(R,"M")),(Bt=n.added)==null?void 0:Bt.map(R=>We(R,"A")),(gr=n.deleted)==null?void 0:gr.map(R=>We(R,"D")),(hr=n.untracked)==null?void 0:hr.map(R=>We(R,"U"))]})}),G==="history"&&!(n!=null&&n.error)&&e.jsx("div",{className:`flex-1 overflow-y-auto ${r?"pb-mobile-nav":""}`,children:m?e.jsx("div",{className:"flex items-center justify-center h-32",children:e.jsx(Ut,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):D.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-32 text-muted-foreground",children:[e.jsx(en,{className:"w-10 h-10 mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No commits found"})]}):e.jsx("div",{className:r?"pb-4":"",children:D.map(R=>Se(R))})}),S&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>H(!1)}),e.jsx("div",{className:"relative bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:e.jsxs("div",{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"Create New Branch"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground/80 mb-2",children:"Branch Name"}),e.jsx("input",{type:"text",value:w,onChange:R=>P(R.target.value),onKeyDown:R=>{R.key==="Enter"&&!j&&Ve()},placeholder:"feature/new-feature",className:"w-full px-3 py-2 border border-border rounded-xl bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/30",autoFocus:!0})]}),e.jsxs("div",{className:"text-sm text-muted-foreground mb-4",children:["This will create a new branch from the current branch (",I,")"]}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>{H(!1),P("")},className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",children:"Cancel"}),e.jsx("button",{onClick:Ve,disabled:!w.trim()||j,className:"px-4 py-2 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2 transition-colors",children:j?e.jsxs(e.Fragment,{children:[e.jsx(Ut,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Creating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(lt,{className:"w-3 h-3"}),e.jsx("span",{children:"Create Branch"})]})})]})]})})]}),we&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>Ie(null)}),e.jsx("div",{className:"relative bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:`p-2 rounded-full mr-3 ${we.type==="discard"||we.type==="delete"?"bg-red-100 dark:bg-red-900/30":"bg-yellow-100 dark:bg-yellow-900/30"}`,children:e.jsx(qt,{className:`w-5 h-5 ${we.type==="discard"||we.type==="delete"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400"}`})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:we.type==="discard"?"Discard Changes":we.type==="delete"?"Delete File":we.type==="commit"?"Confirm Commit":we.type==="pull"?"Confirm Pull":we.type==="publish"?"Publish Branch":"Confirm Push"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:we.message}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>Ie(null),className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground hover:bg-accent rounded-lg transition-colors",children:"Cancel"}),e.jsx("button",{onClick:Ke,className:`px-4 py-2 text-sm text-white rounded-lg transition-colors ${we.type==="discard"||we.type==="delete"?"bg-red-600 hover:bg-red-700":we.type==="commit"?"bg-primary hover:bg-primary/90":we.type==="pull"?"bg-green-600 hover:bg-green-700":we.type==="publish"?"bg-purple-600 hover:bg-purple-700":"bg-orange-600 hover:bg-orange-700"} flex items-center space-x-2`,children:we.type==="discard"?e.jsxs(e.Fragment,{children:[e.jsx(ht,{className:"w-4 h-4"}),e.jsx("span",{children:"Discard"})]}):we.type==="delete"?e.jsxs(e.Fragment,{children:[e.jsx(ht,{className:"w-4 h-4"}),e.jsx("span",{children:"Delete"})]}):we.type==="commit"?e.jsxs(e.Fragment,{children:[e.jsx(Tt,{className:"w-4 h-4"}),e.jsx("span",{children:"Commit"})]}):we.type==="pull"?e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"w-4 h-4"}),e.jsx("span",{children:"Pull"})]}):we.type==="publish"?e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"w-4 h-4"}),e.jsx("span",{children:"Publish"})]}):e.jsxs(e.Fragment,{children:[e.jsx(as,{className:"w-4 h-4"}),e.jsx("span",{children:"Push"})]})})]})]})})]})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:e.jsx("p",{children:"Select a project to view source control"})})}class Zn extends Ft.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,s){console.error("ErrorBoundary caught an error:",r,s),this.setState({error:r,errorInfo:s})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 max-w-md",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsx("h3",{className:"ml-3 text-sm font-medium text-red-800",children:"Something went wrong"})]}),e.jsxs("div",{className:"text-sm text-red-700",children:[e.jsx("p",{className:"mb-2",children:"An error occurred while loading the chat interface."}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono",children:"Error Details"}),e.jsxs("pre",{className:"mt-2 text-xs bg-red-100 p-2 rounded overflow-auto max-h-40",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-red-600 text-white px-4 py-2 rounded text-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500",children:"Try Again"})})]})}):this.props.children}}function Ap(t){const r=c.useRef(!1),s=c.useCallback(o=>{o&&(o.preventDefault(),o.stopPropagation()),t()},[t]),a=c.useCallback(o=>{r.current=!0,s(o),window.setTimeout(()=>{r.current=!1},350)},[s]);return{handleMobileMenuClick:c.useCallback(o=>{if(r.current){o.preventDefault(),o.stopPropagation();return}s(o)},[s]),handleMobileMenuTouchEnd:a}}function Si({onMenuClick:t,compact:r=!1}){const{handleMobileMenuClick:s,handleMobileMenuTouchEnd:a}=Ap(t),n=r?"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 pwa-menu-button":"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0";return e.jsx("button",{onClick:s,onTouchEnd:a,className:n,"aria-label":"Open menu",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}const Lt=({children:t,content:r,position:s="top",className:a="",delay:n=500})=>{const[o,i]=c.useState(!1),[l,m]=c.useState(null),d=()=>{const x=setTimeout(()=>{i(!0)},n);m(x)},u=()=>{l&&(clearTimeout(l),m(null)),i(!1)},g=()=>{switch(s){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},p=()=>{switch(s){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:d,onMouseLeave:u,children:[t,o&&e.jsxs("div",{className:be("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",g(),a),children:[r,e.jsx("div",{className:be("absolute w-0 h-0 border-4 border-transparent",p())})]})]}):t},eo=[{id:"dashboard",labelKey:"Dashboard",icon:Qi},{id:"chat",labelKey:"tabs.chat",icon:La},{id:"canvas",labelKey:"Canvas",icon:Xi},{id:"shell",labelKey:"tabs.shell",icon:ct},{id:"files",labelKey:"tabs.files",icon:tr},{id:"git",labelKey:"tabs.git",icon:Gt},{id:"workflows",labelKey:"Workflows",icon:cr}],Dp={id:"tasks",labelKey:"tabs.tasks",icon:yo};function Mp({activeTab:t,setActiveTab:r,shouldShowTasksTab:s}){const{t:a}=Ge(),n=s?[...eo,Dp]:eo;return e.jsx("div",{className:"inline-flex items-center bg-muted/60 rounded-lg p-[3px] gap-[2px]",children:n.map(o=>{const i=o.icon,l=o.id===t;return e.jsx(Lt,{content:a(o.labelKey),position:"bottom",children:e.jsxs("button",{onClick:()=>r(o.id),className:`relative flex items-center gap-1.5 px-2.5 py-[5px] text-sm font-medium rounded-md transition-all duration-150 ${l?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(i,{className:"w-3.5 h-3.5",strokeWidth:l?2.2:1.8}),e.jsx("span",{className:"hidden lg:inline",children:a(o.labelKey)})]})},o.id)})})}function $p(t,r,s){return t==="files"?s("mainContent.projectFiles"):t==="git"?s("tabs.git"):t==="tasks"&&r?"TaskMaster":"Project"}function Lp(t){return t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}function Fp({activeTab:t,selectedProject:r,selectedSession:s,shouldShowTasksTab:a}){const{t:n}=Ge(),o=t==="chat"&&!!s,i=t==="chat"&&!s;return e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[o&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(At,{provider:s==null?void 0:s.__provider,className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:t==="chat"&&s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground whitespace-nowrap overflow-x-auto scrollbar-hide leading-tight",children:Lp(s)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]}):i?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground leading-tight",children:n("mainContent.newSession")}),e.jsx("div",{className:"text-xs text-muted-foreground truncate leading-tight",children:r.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground leading-tight",children:$p(t,a,n)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]})})]})}function Pp({activeTab:t,setActiveTab:r,selectedProject:s,selectedSession:a,shouldShowTasksTab:n,isMobile:o,onMenuClick:i}){return e.jsx("div",{className:"bg-background border-b border-border/60 px-3 py-1.5 sm:px-4 sm:py-2 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o&&e.jsx(Si,{onMenuClick:i}),e.jsx(Fp,{activeTab:t,selectedProject:s,selectedSession:a,shouldShowTasksTab:n})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsx(Mp,{activeTab:t,setActiveTab:r,shouldShowTasksTab:n})})]})})}function to({mode:t,isMobile:r,onMenuClick:s}){const{t:a}=Ge(),n=t==="loading";return e.jsxs("div",{className:"h-full flex flex-col",children:[r&&e.jsx("div",{className:"bg-background/80 backdrop-blur-sm border-b border-border/50 p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx(Si,{onMenuClick:s,compact:!0})}),n?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("div",{className:"w-10 h-10 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-[3px] border-muted border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:a("mainContent.loading")}),e.jsx("p",{className:"text-sm",children:a("mainContent.settingUpWorkspace")})]})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-14 h-14 mx-auto mb-5 bg-muted/50 rounded-2xl flex items-center justify-center",children:e.jsx(tr,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2 text-foreground",children:a("mainContent.chooseProject")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5 leading-relaxed",children:a("mainContent.selectProjectDescription")}),e.jsx("div",{className:"bg-primary/5 rounded-xl p-3.5 border border-primary/10",children:e.jsxs("p",{className:"text-sm text-primary",children:[e.jsxs("strong",{children:[a("mainContent.tip"),":"]})," ",a(r?"mainContent.createProjectMobile":"mainContent.createProjectDesktop")]})})]})})]})}var _p=function(t,r){var s={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(t);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(t,a[n])&&(s[a[n]]=t[a[n]]);return s};const ft=wo.define({combine:t=>{const r=[];for(let s of t){if(!s)continue;const{create:a,gutters:n}=s,o=_p(s,["create","gutters"]);r.push(Object.assign(Object.assign({},o),{enabled:!0,gutters:n?n.filter(i=>Object.keys(i).length>0):void 0}))}return yl(r,{enabled:r.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),Ct={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},zp=Zt.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),Qt=Ct.PixelMultiplier*Ct.SizeRatio,Op=Fa.fromClass(class{constructor(t){this.view=t,this._isDragging=!1,t.state.facet(ft).enabled&&this.create(t)}create(t){this.container=Er("div",{class:"cm-minimap-overlay-container"}),this.dom=Er("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const r=t.dom.querySelector(".cm-minimap-inner");r&&r.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(t){const r=t.startState.facet(ft).enabled,s=t.state.facet(ft).enabled;if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.computeShowOverlay(),t.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const t=this.view.dom.clientHeight/Qt;this.dom.style.height=t+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:t,scrollHeight:r,scrollTop:s}=this.view.scrollDOM,a=r-t,n=s/Qt,o=t/Qt,i=t-o;let l=s/a;isNaN(l)&&(l=0);const m=i*l,d=Math.min(m,n);this.dom.style.top=d+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:t}=this.view.state.facet(ft);t==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:r,scrollHeight:s}=this.view.scrollDOM;r===s?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(t){if(!this.container||t.button===2)return;const{clientY:r,target:s}=t;if(s===this.dom){this._dragStartY=t.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:a,scrollHeight:n,scrollTop:o}=this.view.scrollDOM,i=s.getBoundingClientRect().top,l=(r-i)*Qt,m=o/(n-a),u=(a*Qt-a)*m,g=Math.max(0,o-u);this.view.scrollDOM.scrollTop=g+l-a/2}onMouseUp(t){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(t){if(!this._isDragging||!this.dom)return;if(t.preventDefault(),t.stopPropagation(),!this._dragStartY){this._dragStartY=t.clientY;return}const r=t.clientY-this._dragStartY,s=r<0,a=r>0;this._dragStartY=t.clientY;const n=this.dom.getBoundingClientRect().height,o=this.dom.getBoundingClientRect().y,i=o+n,l=parseFloat(this.dom.style.top),m=this.view.scrollDOM.scrollTop,d=this.view.scrollDOM.clientHeight,u=this.view.scrollDOM.scrollHeight,g=m===0,p=Math.round(m)>=Math.round(u-d);if(g&&s||g&&t.clientY<o||p&&a||p&&t.clientY>i)return;const x=this.view.scrollDOM.scrollHeight,f=this.view.scrollDOM.clientHeight,h=(x-f)/Qt,b=f-f/Qt,C=l+r,I=C/b,y=(x-f)*I,v=C*Qt;this.view.scrollDOM.scrollTop=Math.max(y,v);const A=Math.min(Math.max(0,C),Math.min(b,h));this.dom.style.top=A+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),Rp=[zp,Op];class Ha{constructor(r){this.map=new Map,this.view=r}get(r){return this.map.get(r)}set(r,s){this.map.set(r,s)}}function ro(t){var r;if(!t.facet(ft).enabled)return[];const s=[],a=t.doc.iterLines(),n=wl(t).iter();let o=0;for(a.next();!a.done;){const i=a.value;let l=o,m=l+i.length;for(;n.value&&n.to<l;)n.next();const{from:d,to:u}=n,g=l>=d&&l<u,p=m>d&&m<=u;if(g){let x=(r=s.pop())!==null&&r!==void 0?r:[],f=x.pop();f&&f.folded&&(f.to=u),f&&x.push(f),(!f||!f.folded)&&x.push({from:d,to:u,folded:!0}),p||x.push({from:u,to:m,folded:!1}),s.push(x)}else p?s.push([{from:l,to:d,folded:!1},{from:d,to:u,folded:!0}]):s.push([{from:l,to:m,folded:!1}]);o=m+1,a.next()}return s}const Ir=bl.define({create:t=>ro(t),update:(t,r)=>Fs([r])||r.docChanged?ro(r.state):t});function Fs(t){return t.find(r=>r.effects.find(s=>s.is(vl)||s.is(kl)))}class Bp extends Ha{constructor(r){super(r),this.count=void 0}shouldUpdate(r){if(!r.state.facet(ft).enabled)return!1;if(r.docChanged)return!0;for(const s of r.transactions)for(const a of s.effects)if(a.is(Nl))return!0;return!!(Fs(r.transactions)||this.count===void 0)}update(r){if(!this.shouldUpdate(r))return;this.map.clear();const s=r.state.field(Ir);this.count=Cl(r.state),Sl(r.state,(a,n,o)=>{const i=this.findLine(n,s),l=this.findLine(o,s);let m=a.severity;for(let d=i;d<=l;d++){const u=this.get(d);u&&(m=[m,u].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(d,m)}})}drawLine(r,s){const{context:a,lineHeight:n,offsetX:o,offsetY:i}=r,l=this.get(s);l&&(a.globalAlpha=.65,a.beginPath(),a.rect(o,i,a.canvas.width-o,n),a.fillStyle=this.color(l),a.fill())}findLine(r,s){return s.findIndex(n=>{const o=n.slice(0,1)[0],i=n.slice(-1)[0];return!o||!i?!1:o.from<=r&&r<=i.to})+1}color(r){return r==="error"?"#d11":r==="warning"?"orange":"#999"}sort(r,s){return this.score(s)-this.score(r)}score(r){switch(r){case"error":return 3;case"warning":return 2;default:return 1}}}function Wp(t){return new Bp(t)}class Up extends Ha{constructor(r){super(r),this.getDrawInfo(),this._themeClasses=r.dom.classList.value}shouldUpdate(r){return r.state.facet(ft).enabled?!!(r.docChanged||r.selectionSet||this._themeClasses!==this.view.dom.classList.value||Fs(r.transactions)):!1}update(r){if(!this.shouldUpdate(r))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:s}=r.state.selection;let a=0;for(const[n,o]of r.state.field(Ir).entries()){const i=[];let l=0;for(const d of o){do{if(a>=s.length||d.to<s[a].from)continue;if(s[a].from===s[a].to){a++;continue}const u=s[a],g={from:l+Math.max(d.from,u.from)-d.from,to:l+Math.min(d.to,u.to)-d.from,extends:u.to>d.to},p=i.slice(-1)[0];if(p&&p.to===g.from){let{to:x}=g;d.folded&&g.extends?x=g.from+1:d.folded&&!g.extends&&(x=p.to),i[i.length-1]=Object.assign(Object.assign({},p),{to:x,extends:g.extends})}else d.folded||i.push(g);if(g.extends)break;a++}while(a<s.length&&d.to>=s[a].from);l+=d.folded?1:d.to-d.from}if(i.length===0)continue;const m=n+1;this.map.set(m,i)}}drawLine(r,s){let{context:a,lineHeight:n,charWidth:o,offsetX:i,offsetY:l}=r;const m=this.get(s);if(m)for(const d of m){const u=i+d.from*o,g=(d.to-d.from)*o,p=a.canvas.width-u;d.extends&&(a.globalAlpha=.65,a.beginPath(),a.rect(u,l,p,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()),a.globalAlpha=1,a.beginPath(),a.rect(u,l,g,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const r=document.createElement("span");r.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(r);const a={backgroundColor:window.getComputedStyle(r).backgroundColor};return this._drawInfo=a,this.view.dom.removeChild(r),a}}function Hp(t){return new Up(t)}class Gp extends Ha{constructor(r){super(r),this._fontInfoMap=new Map,this._themeClasses=new Set(r.dom.classList.values()),r.state.facet(ft).enabled&&this.updateImpl(r.state)}shouldUpdate(r){return!!(r.docChanged||r.state.facet(ft)!==r.startState.facet(ft)||this.themeChanged()||Fs(r.transactions))}update(r){this.shouldUpdate(r)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(r.state,r.changes))}updateImpl(r,s){var a;this.map.clear(),this._displayText=r.facet(ft).displayText,this.themeChanged()&&this._fontInfoMap.clear();let n;if(this._previousTree&&s){const g=rn.addTree(this._previousTree),p=[];s.iterChangedRanges((x,f,h,b)=>p.push({fromA:x,toA:f,fromB:h,toB:b})),n=rn.applyChanges(g,p)}const o=r.doc.toString(),i=(a=r.facet(jl))===null||a===void 0?void 0:a.parser,l=i?i.parse(o,n):void 0;this._previousTree=l;const m={style:g=>El(r,g)};let d=[];if(l){const g=r.doc.lineAt(this.view.viewport.from).number,p=r.doc.lineAt(this.view.viewport.to).number,x=p-g,f=g/(r.doc.lines-x),{SizeRatio:h,PixelMultiplier:b}=Ct,C=x*h*b,I=f*C,y=Math.max(1,Math.floor(g-I)),v=Math.min(p+Math.floor(C-I),r.doc.lines);sn(l,m,(A,M,$)=>{d.push({from:A,to:M,tags:$})},r.doc.line(y).from,r.doc.line(v).to)}this.updateMapImpl(r,d),d=[];const u=()=>{l&&(sn(l,m,(g,p,x)=>{d.push({from:g,to:p,tags:x})}),this.updateMapImpl(r,d),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(u):setTimeout(u)}updateMapImpl(r,s){this.map.clear();const a=r.doc.toString(),n=s.values();let o=n.next();for(const[i,l]of r.field(Ir).entries()){const m=[];for(const u of l){if(u.from===u.to)continue;if(u.folded){m.push({text:"…",tags:""});continue}let g=u.from;for(;!o.done&&o.value.from<u.to;){const{from:p,to:x,tags:f}=o.value;if(x<g){o=n.next();continue}p>g&&m.push({text:a.slice(g,p),tags:""});const h=Math.max(p,u.from),b=Math.min(x,u.to);if(m.push({text:a.slice(h,b),tags:f}),g=b,x>b)break;o=n.next()}g!==u.to&&m.push({text:a.slice(g,u.to),tags:""})}const d=i+1;this.map.set(d,m)}}measure(r){const{color:s,font:a,lineHeight:n}=this.getFontInfo("");return r.textBaseline="ideographic",r.fillStyle=s,r.font=a,{charWidth:r.measureText("_").width,lineHeight:n}}beforeDraw(){this._fontInfoMap.clear()}drawLine(r,s){const a=this.get(s);if(!a)return;let{context:n,charWidth:o,lineHeight:i,offsetX:l,offsetY:m}=r,d;n.textBaseline="ideographic";for(const u of a){const g=this.getFontInfo(u.tags);switch((!d||d.color!==g.color)&&(n.fillStyle=g.color),(!d||d.font!==g.font)&&(n.font=g.font),d=g,i=Math.max(i,g.lineHeight),this._displayText){case"characters":{n.fillText(u.text,l,m+i),l+=u.text.length*o;break}case"blocks":{const p=/\S+/g;let x;for(;(x=p.exec(u.text))!==null;){const f=l+x.index*o;let h=(p.lastIndex-x.index)*o;if(f>n.canvas.width)break;f+h>n.canvas.width&&(h=n.canvas.width-f);const b=2/Ct.SizeRatio,C=i-b;n.fillStyle=g.color,n.globalAlpha=.65,n.beginPath(),n.rect(f,m,h,C),n.fill()}l+=u.text.length*o;break}}}}getFontInfo(r){const s=this._fontInfoMap.get(r);if(s)return s;const a=Er("span",{class:r}),n=Er("div",{class:"cm-line",style:"display: none"},a);this.view.contentDOM.appendChild(n);const o=window.getComputedStyle(a),i=parseFloat(o.lineHeight)/Ct.SizeRatio,l={color:o.color,font:`${o.fontStyle} ${o.fontWeight} ${i}px ${o.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(r,l),this.view.contentDOM.removeChild(n),l}themeChanged(){const r=this._themeClasses,s=new Set(this.view.dom.classList.values());if(this._themeClasses=s,!r||(r.delete("cm-focused"),s.delete("cm-focused"),r.size!==s.size))return!0;let a=!0;return r.forEach(n=>{s.has(n)||(a=!1)}),!a}}function qp(t){return new Gp(t)}const Ei=4;function Kp(t,r,s){const a=t[s];a&&(r.context.fillStyle=a,r.context.globalAlpha=1,r.context.beginPath(),r.context.rect(r.offsetX,r.offsetY,Ei,r.lineHeight),r.context.fill())}const Vp=Zt.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),so=6,Jp=Fa.fromClass(class{constructor(t){this.view=t,this.text=qp(t),this.selection=Hp(t),this.diagnostic=Wp(t),t.state.facet(Hr)&&this.create(t)}create(t){const r=t.state.facet(Hr);if(!r)throw Error("Expected nonnull");this.inner=Er("div",{class:"cm-minimap-inner"}),this.canvas=Er("canvas"),this.dom=r.create(t).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const s in this.view.state.facet(ft).eventHandlers){const a=this.view.state.facet(ft).eventHandlers[s];a&&this.dom.addEventListener(s,n=>a(n,this.view))}}remove(){this.dom&&this.dom.remove()}update(t){const r=t.startState.facet(Hr),s=t.state.facet(Hr);if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.text.update(t),this.selection.update(t),this.diagnostic.update(t),this.render())}getWidth(){const t=this.view.dom.clientWidth;if(t<=Ct.MaxWidth*so){const r=t/(Ct.MaxWidth*so);return Ct.MaxWidth*r}return Ct.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*Ct.PixelMultiplier;const t=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=t+"px",this.canvas.height=t*Ct.PixelMultiplier,this.canvas.style.height=t+"px";const r=this.canvas.getContext("2d");if(!r)return;r.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:s,lineHeight:a}=this.text.measure(r);let{startIndex:n,endIndex:o,offsetY:i}=this.canvasStartAndEndIndex(r,a);const l=this.view.state.facet(ft).gutters;for(let m=n;m<o;m++){const d=this.view.state.field(Ir);if(m>=d.length)break;const u={offsetX:0,offsetY:i,context:r,lineHeight:a,charWidth:s};if(l.length){u.offsetX+=2;for(let g of l)Kp(g,u,m+1),u.offsetX+=Ei;u.offsetX+=2}this.text.drawLine(u,m+1),this.selection.drawLine(u,m+1),this.diagnostic.drawLine(u,m+1),i+=a}r.restore()}canvasStartAndEndIndex(t,r){let{top:s,bottom:a}=this.view.documentPadding;s/=Ct.SizeRatio,a/=Ct.SizeRatio;const n=t.canvas.height,{clientHeight:o,scrollHeight:i,scrollTop:l}=this.view.scrollDOM;let m=l/(i-o);isNaN(m)&&(m=0);const d=this.view.state.field(Ir).length,u=s+a+d*r,g=Math.max(0,m*(u-n)),p=Math.max(0,s-g),x=Math.round(Math.max(0,g-s)/r),f=Math.round((n-p)/r);return{startIndex:x,endIndex:x+f,offsetY:p}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:t,scrollWidth:r,scrollLeft:s}=this.view.scrollDOM;t+s<r?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:t=>Zt.scrollMargins.of(r=>{var s;const a=(s=r.plugin(t))===null||s===void 0?void 0:s.getWidth();return a?{right:a}:null})}),Hr=wo.define({combine:t=>{var r;return(r=t.find(s=>s!==null))!==null&&r!==void 0?r:null},enables:t=>[[ft.compute([t],r=>r.facet(t)),Vp,Ir,Jp,Rp]]}),Yp=c.lazy(()=>Ls(()=>import("./MarkdownPreview-CYdvwJaV.js"),__vite__mapDeps([0,1,2,3]))),ao=Fl.define({token(t){return t.match(/^#.*/)?"comment":t.sol()&&t.match(/^[A-Za-z_][A-Za-z0-9_.]*(?==)/)?"variableName.definition":t.match(/^=/)?"operator":t.match(/^"(?:[^"\\]|\\.)*"?/)||t.match(/^'(?:[^'\\]|\\.)*'?/)?"string":t.match(/^\$\{[^}]*\}?/)||t.match(/^\$[A-Za-z_][A-Za-z0-9_]*/)?"variableName.special":t.match(/^\d+/)?"number":(t.next(),null)}});function Qp({file:t,onClose:r,projectPath:s,isSidebar:a=!1,isExpanded:n=!1,onToggleExpand:o=null,onPopOut:i=null}){const{t:l}=Ge("codeEditor"),{addToast:m}=mr(),[d,u]=c.useState(""),[g,p]=c.useState(!0),[x,f]=c.useState(!1),[h,b]=c.useState(!1),[C,I]=c.useState(()=>{const V=localStorage.getItem("codeEditorTheme");return V?V==="dark":!0}),[y,v]=c.useState(!1),[A,M]=c.useState(!!t.diffInfo),[$,k]=c.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[T,W]=c.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[U,S]=c.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[H,w]=c.useState(()=>localStorage.getItem("codeEditorFontSize")||"12"),[P,j]=c.useState(!1),F=c.useRef(null),G=c.useMemo(()=>{var z;const V=(z=t.name.split(".").pop())==null?void 0:z.toLowerCase();return V==="md"||V==="markdown"},[t.name]),X=c.useMemo(()=>{if(!t.diffInfo||!A||!T)return[];const V={};return[Hr.compute(["doc"],z=>{const O=Ks(z),ne=(O==null?void 0:O.chunks)||[];return Object.keys(V).forEach(me=>delete V[me]),ne.forEach(me=>{const q=z.doc.lineAt(me.fromB).number,N=z.doc.lineAt(Math.min(me.toB,z.doc.length)).number;for(let _=q;_<=N;_++)V[_]=C?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[V]}})]},[t.diffInfo,A,T,C]),D=c.useMemo(()=>!t.diffInfo||!A?[]:[Fa.fromClass(class{constructor(V){setTimeout(()=>{const z=Ks(V.state),O=(z==null?void 0:z.chunks)||[];if(O.length>0){const ne=O[0];V.dispatch({effects:Zt.scrollIntoView(ne.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[t.diffInfo,A]),oe=!!(t.diffInfo||a&&i||a&&o),E=c.useMemo(()=>{if(!oe)return[];const V=z=>{const O=document.createElement("div");O.className="cm-editor-toolbar-panel";let ne=0;const me=()=>{const q=t.diffInfo&&A,N=q?Ks(z.state):null,_=(N==null?void 0:N.chunks)||[],re=_.length;let te='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(te+='<div style="display: flex; align-items: center; gap: 8px;">',q&&(te+=`
142
+ <span style="font-weight: 500;">${re>0?`${ne+1}/${re}`:"0"} ${l("toolbar.changes")}</span>
143
+ <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${l("toolbar.previousChange")}" ${re===0?"disabled":""}>
144
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
145
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
146
+ </svg>
147
+ </button>
148
+ <button class="cm-diff-nav-btn cm-diff-nav-next" title="${l("toolbar.nextChange")}" ${re===0?"disabled":""}>
149
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
150
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
151
+ </svg>
152
+ </button>
153
+ `),te+="</div>",te+='<div style="display: flex; align-items: center; gap: 4px;">',t.diffInfo&&(te+=`
154
+ <button class="cm-toolbar-btn cm-toggle-diff-btn" title="${l(A?"toolbar.hideDiff":"toolbar.showDiff")}">
155
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
156
+ ${A?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />'}
157
+ </svg>
158
+ </button>
159
+ `),a&&i&&(te+=`
160
+ <button class="cm-toolbar-btn cm-popout-btn" title="Open in modal">
161
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
162
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3" />
163
+ </svg>
164
+ </button>
165
+ `),a&&o&&(te+=`
166
+ <button class="cm-toolbar-btn cm-expand-btn" title="${l(n?"toolbar.collapse":"toolbar.expand")}">
167
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
168
+ ${n?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
169
+ </svg>
170
+ </button>
171
+ `),te+="</div>",te+="</div>",O.innerHTML=te,q){const ve=O.querySelector(".cm-diff-nav-prev"),je=O.querySelector(".cm-diff-nav-next");ve==null||ve.addEventListener("click",()=>{if(_.length===0)return;ne=ne>0?ne-1:_.length-1;const Ne=_[ne];Ne&&z.dispatch({effects:Zt.scrollIntoView(Ne.fromB,{y:"center"})}),me()}),je==null||je.addEventListener("click",()=>{if(_.length===0)return;ne=ne<_.length-1?ne+1:0;const Ne=_[ne];Ne&&z.dispatch({effects:Zt.scrollIntoView(Ne.fromB,{y:"center"})}),me()})}if(t.diffInfo){const ve=O.querySelector(".cm-toggle-diff-btn");ve==null||ve.addEventListener("click",()=>{M(!A)})}if(a&&i){const ve=O.querySelector(".cm-popout-btn");ve==null||ve.addEventListener("click",()=>{i()})}if(a&&o){const ve=O.querySelector(".cm-expand-btn");ve==null||ve.addEventListener("click",()=>{o()})}};return me(),{top:!0,dom:O,update:me}};return[Tl.of(V)]},[t.diffInfo,A,a,n,o,i]),se=V=>{var ne;const z=V.toLowerCase();if(z===".env"||z.startsWith(".env."))return[ao];const O=(ne=V.split(".").pop())==null?void 0:ne.toLowerCase();switch(O){case"js":case"jsx":case"ts":case"tsx":return[Ll({jsx:!0,typescript:O.includes("ts")})];case"py":return[$l()];case"html":case"htm":return[Ml()];case"css":case"scss":case"less":return[Dl()];case"json":return[Al()];case"md":case"markdown":return[Co()];case"env":return[ao];default:return[]}};c.useEffect(()=>{(async()=>{try{if(p(!0),t.diffInfo&&t.diffInfo.new_string!==void 0&&t.diffInfo.old_string!==void 0){u(t.diffInfo.new_string),p(!1);return}const z=await He.readFile(t.projectName,t.path);if(!z.ok)throw new Error(`Failed to load file: ${z.status} ${z.statusText}`);const O=await z.json();u(O.content)}catch(z){console.error("Error loading file:",z),u(`// Error loading file: ${z.message}
172
+ // File: ${t.name}
173
+ // Path: ${t.path}`)}finally{p(!1)}})()},[t,s]);const J=async()=>{f(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:d==null?void 0:d.length});const V=await He.saveFile(t.projectName,t.path,d);if(console.log("Save response:",{status:V.status,ok:V.ok,contentType:V.headers.get("content-type")}),!V.ok){const O=V.headers.get("content-type");if(O&&O.includes("application/json")){const ne=await V.json();throw new Error(ne.error||`Save failed: ${V.status}`)}else{const ne=await V.text();throw console.error("Non-JSON error response:",ne),new Error(`Save failed: ${V.status} ${V.statusText}`)}}const z=await V.json();console.log("Save successful:",z),v(!0),setTimeout(()=>v(!1),2e3)}catch(V){console.error("Error saving file:",V),m(`Error saving file: ${V.message}`,"error")}finally{f(!1)}},B=()=>{const V=new Blob([d],{type:"text/plain"}),z=URL.createObjectURL(V),O=document.createElement("a");O.href=z,O.download=t.name,document.body.appendChild(O),O.click(),document.body.removeChild(O),URL.revokeObjectURL(z)},K=()=>{b(!h)};return c.useEffect(()=>{localStorage.setItem("codeEditorTheme",C?"dark":"light")},[C]),c.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",$.toString())},[$]),c.useEffect(()=>{const V=()=>{const z=localStorage.getItem("codeEditorTheme");z&&I(z==="dark");const O=localStorage.getItem("codeEditorWordWrap");O!==null&&k(O==="true");const ne=localStorage.getItem("codeEditorShowMinimap");ne!==null&&W(ne!=="false");const me=localStorage.getItem("codeEditorLineNumbers");me!==null&&S(me!=="false");const q=localStorage.getItem("codeEditorFontSize");q&&w(q)};return window.addEventListener("storage",V),window.addEventListener("codeEditorSettingsChanged",V),()=>{window.removeEventListener("storage",V),window.removeEventListener("codeEditorSettingsChanged",V)}},[]),c.useEffect(()=>{const V=z=>{(z.ctrlKey||z.metaKey)&&(z.key==="s"?(z.preventDefault(),J()):z.key==="Escape"&&(z.preventDefault(),r()))};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[d]),g?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
174
+ .code-editor-loading {
175
+ background-color: ${C?"#111827":"#ffffff"} !important;
176
+ }
177
+ .code-editor-loading:hover {
178
+ background-color: ${C?"#111827":"#ffffff"} !important;
179
+ }
180
+ `}),a?e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:l("loading",{fileName:t.name})})]})}):e.jsx("div",{className:"fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:l("loading",{fileName:t.name})})]})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
181
+ /* Light background for full line changes */
182
+ .cm-deletedChunk {
183
+ background-color: ${C?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
184
+ border-left: 3px solid ${C?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
185
+ padding-left: 4px !important;
186
+ }
187
+
188
+ .cm-insertedChunk {
189
+ background-color: ${C?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
190
+ border-left: 3px solid ${C?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
191
+ padding-left: 4px !important;
192
+ }
193
+
194
+ /* Override linear-gradient underline and use solid darker background for partial changes */
195
+ .cm-editor.cm-merge-b .cm-changedText {
196
+ background: ${C?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
197
+ padding-top: 2px !important;
198
+ padding-bottom: 2px !important;
199
+ margin-top: -2px !important;
200
+ margin-bottom: -2px !important;
201
+ }
202
+
203
+ .cm-editor .cm-deletedChunk .cm-changedText {
204
+ background: ${C?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
205
+ padding-top: 2px !important;
206
+ padding-bottom: 2px !important;
207
+ margin-top: -2px !important;
208
+ margin-bottom: -2px !important;
209
+ }
210
+
211
+ /* Minimap gutter styling */
212
+ .cm-gutter.cm-gutter-minimap {
213
+ background-color: ${C?"#1e1e1e":"#f5f5f5"};
214
+ }
215
+
216
+ /* Editor toolbar panel styling */
217
+ .cm-editor-toolbar-panel {
218
+ padding: 4px 10px;
219
+ background-color: ${C?"#1f2937":"#ffffff"};
220
+ border-bottom: 1px solid ${C?"#374151":"#e5e7eb"};
221
+ color: ${C?"#d1d5db":"#374151"};
222
+ font-size: 12px;
223
+ }
224
+
225
+ .cm-diff-nav-btn,
226
+ .cm-toolbar-btn {
227
+ padding: 3px;
228
+ background: transparent;
229
+ border: none;
230
+ cursor: pointer;
231
+ border-radius: 4px;
232
+ display: inline-flex;
233
+ align-items: center;
234
+ justify-content: center;
235
+ color: inherit;
236
+ transition: background-color 0.2s;
237
+ }
238
+
239
+ .cm-diff-nav-btn:hover,
240
+ .cm-toolbar-btn:hover {
241
+ background-color: ${C?"#374151":"#f3f4f6"};
242
+ }
243
+
244
+ .cm-diff-nav-btn:disabled {
245
+ opacity: 0.5;
246
+ cursor: not-allowed;
247
+ }
248
+ `}),e.jsx("div",{className:a?"w-full h-full flex flex-col":`fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${h?"md:p-0":""}`,children:e.jsxs("div",{className:a?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(h?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border flex-shrink-0 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:t.name}),t.diffInfo&&e.jsx("span",{className:"text-[10px] bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-300 px-1.5 py-0.5 rounded whitespace-nowrap",children:l("header.showingChanges")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.path})]})}),e.jsxs("div",{className:"flex items-center gap-0.5 md:gap-1 flex-shrink-0",children:[G&&e.jsx("button",{onClick:()=>j(!P),className:`p-1.5 rounded-md min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center transition-colors ${P?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:l(P?"actions.editMarkdown":"actions.previewMarkdown"),children:P?e.jsx(hs,{className:"w-4 h-4"}):e.jsx(ur,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{var V;return(V=window.openSettings)==null?void 0:V.call(window,"appearance")},className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:l("toolbar.settings"),children:e.jsx(Qe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:B,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:l("actions.download"),children:e.jsx(ys,{className:"w-4 h-4"})}),e.jsx("button",{onClick:J,disabled:x,className:`p-1.5 rounded-md disabled:opacity-50 flex items-center justify-center transition-colors min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 ${y?"text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:l(y?"actions.saved":x?"actions.saving":"actions.save"),children:y?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx(fs,{className:"w-4 h-4"})}),!a&&e.jsx("button",{onClick:K,className:"hidden md:flex p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:l(h?"actions.exitFullscreen":"actions.fullscreen"),children:h?e.jsx(vo,{className:"w-4 h-4"}):e.jsx(Ma,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:l("actions.close"),children:e.jsx(qe,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:P&&G?e.jsx("div",{className:"h-full overflow-y-auto bg-white dark:bg-gray-900",children:e.jsx("div",{className:"max-w-4xl mx-auto px-8 py-6 prose prose-sm dark:prose-invert prose-headings:font-semibold prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:text-sm prose-pre:bg-gray-900 prose-img:rounded-lg max-w-none",children:e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"text-muted-foreground text-sm p-4",children:"Loading preview..."}),children:e.jsx(Yp,{content:d})})})}):e.jsx(jo,{ref:F,value:d,onChange:u,extensions:[...se(t.name),...E,...t.diffInfo&&A&&t.diffInfo.old_string!==void 0?[Il({original:t.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...X,...D]:[],...$?[Zt.lineWrapping]:[]],theme:C?No:void 0,height:"100%",style:{fontSize:`${H}px`,height:"100%"},basicSetup:{lineNumbers:U,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-border bg-muted flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:[l("footer.lines")," ",d.split(`
249
+ `).length]}),e.jsxs("span",{children:[l("footer.characters")," ",d.length]})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:l("footer.shortcuts")})]})]})})]})}const no=Qp;function Xp({editingFile:t,isMobile:r,editorExpanded:s,editorWidth:a,resizeHandleRef:n,onResizeStart:o,onCloseEditor:i,onToggleEditorExpand:l,projectPath:m,fillSpace:d}){const[u,g]=c.useState(!1);if(!t)return null;if(r||u)return e.jsx(no,{file:t,onClose:()=>{g(!1),i()},projectPath:m,isSidebar:!1});const p=s||d;return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{ref:n,onMouseDown:o,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${p?"flex-1":""}`,style:p?void 0:{width:`${a}px`},children:e.jsx(no,{file:t,onClose:i,projectPath:m,isSidebar:!0,isExpanded:s,onToggleExpand:l,onPopOut:()=>g(!0)})})]})}const oo=({task:t,onClick:r,showParent:s=!1,className:a=""})=>{const o=(l=>{switch(l){case"done":return{icon:Qr,bgColor:"bg-green-50 dark:bg-green-950",borderColor:"border-green-200 dark:border-green-800",iconColor:"text-green-600 dark:text-green-400",textColor:"text-green-900 dark:text-green-100",statusText:"Done"};case"in-progress":return{icon:qr,bgColor:"bg-blue-50 dark:bg-blue-950",borderColor:"border-blue-200 dark:border-blue-800",iconColor:"text-blue-600 dark:text-blue-400",textColor:"text-blue-900 dark:text-blue-100",statusText:"In Progress"};case"review":return{icon:Ds,bgColor:"bg-amber-50 dark:bg-amber-950",borderColor:"border-amber-200 dark:border-amber-800",iconColor:"text-amber-600 dark:text-amber-400",textColor:"text-amber-900 dark:text-amber-100",statusText:"Review"};case"deferred":return{icon:ho,bgColor:"bg-gray-50 dark:bg-gray-800",borderColor:"border-gray-200 dark:border-gray-700",iconColor:"text-gray-500 dark:text-gray-400",textColor:"text-gray-700 dark:text-gray-300",statusText:"Deferred"};case"cancelled":return{icon:qe,bgColor:"bg-red-50 dark:bg-red-950",borderColor:"border-red-200 dark:border-red-800",iconColor:"text-red-600 dark:text-red-400",textColor:"text-red-900 dark:text-red-100",statusText:"Cancelled"};case"pending":default:return{icon:Cr,bgColor:"bg-slate-50 dark:bg-slate-800",borderColor:"border-slate-200 dark:border-slate-700",iconColor:"text-slate-500 dark:text-slate-400",textColor:"text-slate-900 dark:text-slate-100",statusText:"Pending"}}})(t.status);o.icon;const i=l=>{switch(l){case"high":return e.jsx(Lt,{content:"High Priority",children:e.jsx("div",{className:"w-4 h-4 bg-red-100 dark:bg-red-900/30 rounded flex items-center justify-center",children:e.jsx(fo,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})});case"medium":return e.jsx(Lt,{content:"Medium Priority",children:e.jsx("div",{className:"w-4 h-4 bg-amber-100 dark:bg-amber-900/30 rounded flex items-center justify-center",children:e.jsx(Zi,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})})});case"low":return e.jsx(Lt,{content:"Low Priority",children:e.jsx("div",{className:"w-4 h-4 bg-blue-100 dark:bg-blue-900/30 rounded flex items-center justify-center",children:e.jsx(Cr,{className:"w-1.5 h-1.5 text-blue-600 dark:text-blue-400 fill-current"})})});default:return e.jsx(Lt,{content:"No Priority Set",children:e.jsx("div",{className:"w-4 h-4 bg-gray-100 dark:bg-gray-800 rounded flex items-center justify-center",children:e.jsx(Cr,{className:"w-1.5 h-1.5 text-gray-400 dark:text-gray-500"})})})}};return e.jsxs("div",{className:be("bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700","hover:shadow-md hover:border-blue-300 dark:hover:border-blue-600 transition-all duration-200 cursor-pointer","p-3 space-y-3",r&&"hover:-translate-y-0.5",a),onClick:r,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx(Lt,{content:`Task ID: ${t.id}`,children:e.jsx("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded",children:t.id})})}),e.jsx("h3",{className:"font-medium text-sm text-gray-900 dark:text-white line-clamp-2 leading-tight",children:t.title}),s&&t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["Task ",t.parentId]})]}),e.jsx("div",{className:"flex-shrink-0",children:i(t.priority)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:t.dependencies&&Array.isArray(t.dependencies)&&t.dependencies.length>0&&e.jsx(Lt,{content:`Depends on: ${t.dependencies.map(l=>`Task ${l}`).join(", ")}`,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[e.jsx($a,{className:"w-3 h-3"}),e.jsxs("span",{children:["Depends on: ",t.dependencies.join(", ")]})]})})}),e.jsx(Lt,{content:`Status: ${o.statusText}`,children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:be("w-2 h-2 rounded-full",o.iconColor.replace("text-","bg-"))}),e.jsx("span",{className:be("text-xs font-medium",o.textColor),children:o.statusText})]})})]}),t.subtasks&&t.subtasks.length>0&&e.jsx("div",{className:"ml-3",children:e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Progress:"}),e.jsx(Lt,{content:`${t.subtasks.filter(l=>l.status==="done").length} of ${t.subtasks.length} subtasks completed`,children:e.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-1.5",children:e.jsx("div",{className:be("h-full rounded-full transition-all duration-300",t.status==="done"?"bg-green-500":"bg-blue-500"),style:{width:`${Math.round(t.subtasks.filter(l=>l.status==="done").length/t.subtasks.length*100)}%`}})})}),e.jsx(Lt,{content:`${t.subtasks.filter(l=>l.status==="done").length} completed, ${t.subtasks.filter(l=>l.status==="pending").length} pending, ${t.subtasks.filter(l=>l.status==="in-progress").length} in progress`,children:e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t.subtasks.filter(l=>l.status==="done").length,"/",t.subtasks.length]})})]})})]})},Zp=({currentProject:t,onClose:r,onTaskCreated:s})=>e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ht,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create AI-Generated Task"})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ht,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:"You can simply ask your AI assistant in the chat to create tasks for you. The AI assistant will automatically generate detailed tasks with research-backed insights."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-blue-200 dark:border-blue-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Example:"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono",children:'"Please add a new task to implement user profile image uploads using Cloudinary, research the best approach."'})]}),e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:"This runs:"})," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900/50 px-1 rounded text-xs",children:'task-master add-task --prompt="Implement user profile image uploads using Cloudinary" --research'})]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:r,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),ex=({tasks:t=[],onTaskClick:r,className:s="",showParentTasks:a=!1,defaultView:n="kanban",currentProject:o,onTaskCreated:i,onShowPRDEditor:l,existingPRDs:m=[],onRefreshPRDs:d})=>{var ne,me;const[u,g]=c.useState(""),[p,x]=c.useState("all"),[f,h]=c.useState("all"),[b,C]=c.useState("id"),[I,y]=c.useState("asc"),[v,A]=c.useState(n),[M,$]=c.useState(!1),[k,T]=c.useState(!1),[W,U]=c.useState(!1),[S,H]=c.useState(!1),[w,P]=c.useState(!1),[j,F]=c.useState(!1),{projectTaskMaster:G,refreshProjects:X,refreshTasks:D,setCurrentProject:oe}=Ar(),{t:E}=Ge("tasks");c.useEffect(()=>{const q=N=>{j&&!N.target.closest(".relative")&&F(!1)};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[j]);const se=c.useMemo(()=>{const q=new Set(t.map(N=>N.status).filter(Boolean));return Array.from(q).sort()},[t]),J=c.useMemo(()=>{const q=new Set(t.map(N=>N.priority).filter(Boolean));return Array.from(q).sort()},[t]),B=c.useMemo(()=>{let q=t.filter(N=>{var je;const _=u.toLowerCase(),re=!u||N.title.toLowerCase().includes(_)||((je=N.description)==null?void 0:je.toLowerCase().includes(_))||N.id.toString().includes(_),te=p==="all"||N.status===p,ve=f==="all"||N.priority===f;return re&&te&&ve});return q.sort((N,_)=>{let re,te;switch(b){case"title":re=N.title.toLowerCase(),te=_.title.toLowerCase();break;case"status":const ve={pending:1,"in-progress":2,done:3,blocked:4,deferred:5,cancelled:6};re=ve[N.status]||99,te=ve[_.status]||99;break;case"priority":const je={high:3,medium:2,low:1};re=je[N.priority]||0,te=je[_.priority]||0;break;case"updated":re=new Date(N.updatedAt||N.createdAt||0),te=new Date(_.updatedAt||_.createdAt||0);break;case"id":default:const Ne=Re=>Re.toString().split(".").map(ye=>parseInt(ye,10)),we=Ne(N.id),Ie=Ne(_.id);for(let Re=0;Re<Math.max(we.length,Ie.length);Re++){const Z=we[Re]||0,ye=Ie[Re]||0;if(Z!==ye){re=Z,te=ye;break}}break}return b==="updated"?I==="asc"?re-te:te-re:typeof re=="string"?I==="asc"?re.localeCompare(te):te.localeCompare(re):I==="asc"?re-te:te-re}),q},[t,u,p,f,b,I]),K=c.useMemo(()=>{const q=[{id:"pending",title:E("kanban.pending"),status:"pending",color:"bg-slate-50 dark:bg-slate-900/50 border-slate-200 dark:border-slate-700",headerColor:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200"},{id:"in-progress",title:E("kanban.inProgress"),status:"in-progress",color:"bg-blue-50 dark:bg-blue-900/50 border-blue-200 dark:border-blue-700",headerColor:"bg-blue-100 dark:bg-blue-800 text-blue-800 dark:text-blue-200"},{id:"done",title:E("kanban.done"),status:"done",color:"bg-emerald-50 dark:bg-emerald-900/50 border-emerald-200 dark:border-emerald-700",headerColor:"bg-emerald-100 dark:bg-emerald-800 text-emerald-800 dark:text-emerald-200"},{id:"blocked",title:E("kanban.blocked"),status:"blocked",color:"bg-red-50 dark:bg-red-900/50 border-red-200 dark:border-red-700",headerColor:"bg-red-100 dark:bg-red-800 text-red-800 dark:text-red-200"},{id:"deferred",title:E("kanban.deferred"),status:"deferred",color:"bg-amber-50 dark:bg-amber-900/50 border-amber-200 dark:border-amber-700",headerColor:"bg-amber-100 dark:bg-amber-800 text-amber-800 dark:text-amber-200"},{id:"cancelled",title:E("kanban.cancelled"),status:"cancelled",color:"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700",headerColor:"bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200"}],N=["pending","in-progress","done"];return q.filter(re=>{const te=B.some(je=>je.status===re.status),ve=N.includes(re.status);return te||ve}).map(re=>({...re,tasks:B.filter(te=>te.status===re.status)}))},[B,E]),V=q=>{b===q?y(I==="asc"?"desc":"asc"):(C(q),y("asc"))},z=()=>{g(""),x("all"),h("all")},O=q=>b!==q?e.jsx(al,{className:"w-4 h-4"}):I==="asc"?e.jsx(nl,{className:"w-4 h-4"}):e.jsx(xo,{className:"w-4 h-4"});if(t.length===0){const q=(o==null?void 0:o.taskMasterConfigured)||((ne=o==null?void 0:o.taskmaster)==null?void 0:ne.hasTaskmaster)||(G==null?void 0:G.hasTaskmaster);return e.jsxs("div",{className:be("text-center py-12",s),children:[q?e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-xl border border-blue-200 dark:border-blue-800 p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(it,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:E("gettingStarted.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:E("gettingStarted.subtitle")})]})]}),e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:E("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:E("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{l==null||l()},className:"inline-flex items-center gap-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-2 py-1 rounded hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(it,{className:"w-3 h-3"}),E("gettingStarted.steps.createPRD.addButton")]}),m.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:E("gettingStarted.steps.createPRD.existingPRDs")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:m.map(N=>e.jsxs("button",{onClick:async()=>{try{const _=await He.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(N.name)}`);if(_.ok){const re=await _.json();l==null||l({name:N.name,content:re.content,isExisting:!0})}else console.error("Failed to load PRD:",_.statusText)}catch(_){console.error("Error loading PRD:",_)}},className:"inline-flex items-center gap-1 text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 px-2 py-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(it,{className:"w-3 h-3"}),N.name]},N.name))})]})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:E("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:E("gettingStarted.steps.generateTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:E("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:E("gettingStarted.steps.analyzeTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:E("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:E("gettingStarted.steps.startBuilding.description")})]})]})]}),e.jsx("div",{className:"flex gap-3 pt-4 border-t border-blue-200 dark:border-blue-700",children:e.jsxs("button",{onClick:N=>{N.preventDefault(),N.stopPropagation(),l==null||l()},className:"flex items-center gap-2 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg font-medium transition-colors cursor-pointer",style:{zIndex:10},children:[e.jsx(it,{className:"w-4 h-4"}),E("buttons.addPRD")]})})]})]}),e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mb-2",children:E("gettingStarted.tip")})})]}):e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("div",{className:"text-blue-600 dark:text-blue-400 mb-4",children:e.jsx(Qe,{className:"w-12 h-12 mx-auto mb-4"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:E("notConfigured.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:E("notConfigured.description")}),e.jsxs("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-950 rounded-lg text-left",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-3",children:E("notConfigured.whatIsTitle")}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",E("notConfigured.features.aiPowered")]}),e.jsxs("p",{children:["• ",E("notConfigured.features.prdTemplates")]}),e.jsxs("p",{children:["• ",E("notConfigured.features.dependencyTracking")]}),e.jsxs("p",{children:["• ",E("notConfigured.features.progressVisualization")]}),e.jsxs("p",{children:["• ",E("notConfigured.features.cliIntegration")]})]})]}),e.jsxs("button",{onClick:()=>{P(!1),U(!0)},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors flex items-center gap-2 mx-auto",children:[e.jsx(ct,{className:"w-4 h-4"}),E("notConfigured.initializeButton")]})]}),W&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center p-4 pt-16 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(ct,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:E("setupModal.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:E("setupModal.subtitle",{projectName:o==null?void 0:o.displayName})})]})]}),e.jsx("button",{onClick:()=>{U(!1),setTimeout(()=>{X(),o&&oe(o)},1e3)},className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(lt,{className:"w-5 h-5 rotate-45"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",onClick:N=>{const _=N.currentTarget.querySelector(".xterm-screen");_&&_.focus()},children:e.jsx(ko,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0,onProcessComplete:N=>{P(!0),N===0&&setTimeout(()=>{X(),o&&oe(o)},1e3)}})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:w?e.jsxs("span",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),E("setupModal.completed")]}):E("setupModal.willStart")}),e.jsx("button",{onClick:()=>{U(!1),P(!1),setTimeout(()=>{X(),o&&oe(o)},1e3)},className:be("px-4 py-2 text-sm font-medium rounded-md transition-colors",w?"bg-green-600 hover:bg-green-700 text-white":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"),children:E(w?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})]})}return e.jsxs("div",{className:be("space-y-4",s),children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(dr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),e.jsx("input",{type:"text",placeholder:E("search.placeholder"),value:u,onChange:q=>g(q.target.value),className:"pl-10 pr-4 py-2 w-full border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>A("kanban"),className:be("p-2 rounded-md transition-colors",v==="kanban"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:E("views.kanban"),children:e.jsx(el,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>A("list"),className:be("p-2 rounded-md transition-colors",v==="list"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:E("views.list"),children:e.jsx(bs,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>A("grid"),className:be("p-2 rounded-md transition-colors",v==="grid"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:E("views.grid"),children:e.jsx(tl,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>$(!M),className:be("flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors",M?"bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[e.jsx(rl,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:E("filters.button")}),e.jsx(vt,{className:be("w-4 h-4 transition-transform",M&&"rotate-180")})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>H(!0),className:"p-2 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors border border-gray-300 dark:border-gray-600",title:E("buttons.help"),children:e.jsx(sl,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative",children:m.length>0?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>F(!j),className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:E("buttons.prdsAvailable",{count:m.length}),children:[e.jsx(it,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:E("buttons.prds")}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-purple-500 rounded-full min-w-[1.25rem] text-center",children:m.length}),e.jsx(vt,{className:be("w-3 h-3 transition-transform hidden sm:block",j&&"rotate-180")})]}),j&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl z-30",children:e.jsxs("div",{className:"p-2",children:[e.jsxs("button",{onClick:()=>{l==null||l(),F(!1)},className:"w-full text-left px-3 py-2 text-sm font-medium text-purple-700 dark:text-purple-300 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded flex items-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),E("buttons.createNewPRD")]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 px-3 py-1 font-medium",children:E("gettingStarted.steps.createPRD.existingPRDs")}),m.map(q=>e.jsxs("button",{onClick:async()=>{try{const N=await He.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(q.name)}`);if(N.ok){const _=await N.json();l==null||l({name:q.name,content:_.content,isExisting:!0}),F(!1)}}catch(N){console.error("Error loading PRD:",N)}},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded flex items-center gap-2",title:E("prd.modified",{date:new Date(q.modified).toLocaleDateString()}),children:[e.jsx(it,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:q.name})]},q.name))]})})]}):e.jsxs("button",{onClick:()=>{l==null||l()},className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:E("buttons.addPRD"),children:[e.jsx(it,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:E("buttons.addPRD")})]})}),((o==null?void 0:o.taskMasterConfigured)||((me=o==null?void 0:o.taskmaster)==null?void 0:me.hasTaskmaster)||(G==null?void 0:G.hasTaskmaster)||t.length>0)&&e.jsxs("button",{onClick:()=>T(!0),className:"flex items-center gap-2 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium",title:E("buttons.addTask"),children:[e.jsx(lt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:E("buttons.addTask")})]})]})]})]}),M&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:E("filters.status")}),e.jsxs("select",{value:p,onChange:q=>x(q.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:E("filters.allStatuses")}),se.map(q=>e.jsx("option",{value:q,children:E(`statuses.${q}`,q.charAt(0).toUpperCase()+q.slice(1).replace("-"," "))},q))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:E("filters.priority")}),e.jsxs("select",{value:f,onChange:q=>h(q.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:E("filters.allPriorities")}),J.map(q=>e.jsx("option",{value:q,children:E(`priorities.${q}`,q.charAt(0).toUpperCase()+q.slice(1))},q))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:E("filters.sortBy")}),e.jsxs("select",{value:`${b}-${I}`,onChange:q=>{const[N,_]=q.target.value.split("-");C(N),y(_)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"id-asc",children:E("sort.idAsc")}),e.jsx("option",{value:"id-desc",children:E("sort.idDesc")}),e.jsx("option",{value:"title-asc",children:E("sort.titleAsc")}),e.jsx("option",{value:"title-desc",children:E("sort.titleDesc")}),e.jsx("option",{value:"status-asc",children:E("sort.statusAsc")}),e.jsx("option",{value:"status-desc",children:E("sort.statusDesc")}),e.jsx("option",{value:"priority-asc",children:E("sort.priorityAsc")}),e.jsx("option",{value:"priority-desc",children:E("sort.priorityDesc")})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:E("filters.showing",{filtered:B.length,total:t.length})}),e.jsx("button",{onClick:z,className:"text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:E("filters.clearFilters")})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>V("id"),className:be("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="id"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[E("sort.id")," ",O("id")]}),e.jsxs("button",{onClick:()=>V("status"),className:be("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="status"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[E("sort.status")," ",O("status")]}),e.jsxs("button",{onClick:()=>V("priority"),className:be("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",b==="priority"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[E("sort.priority")," ",O("priority")]})]}),B.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsxs("div",{className:"text-gray-500 dark:text-gray-400",children:[e.jsx(dr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:E("noMatchingTasks.title")}),e.jsx("p",{className:"text-sm",children:E("noMatchingTasks.description")})]})}):v==="kanban"?e.jsx("div",{className:be("grid gap-6",K.length===1&&"grid-cols-1 max-w-md mx-auto",K.length===2&&"grid-cols-1 md:grid-cols-2",K.length===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",K.length===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",K.length===5&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5",K.length>=6&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"),children:K.map(q=>e.jsxs("div",{className:be("rounded-xl border shadow-sm transition-shadow hover:shadow-md",q.color),children:[e.jsx("div",{className:be("px-4 py-3 rounded-t-xl border-b",q.headerColor),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-sm",children:q.title}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-xs font-medium px-2 py-1 bg-white/60 dark:bg-black/20 rounded-full",children:q.tasks.length})})]})}),e.jsx("div",{className:"p-3 space-y-3 min-h-[200px] max-h-[calc(100vh-300px)] overflow-y-auto",children:q.tasks.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-400 dark:text-gray-500",children:[e.jsx("div",{className:"w-8 h-8 mx-auto mb-2 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:E("kanban.noTasksYet")}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:q.status==="pending"?E("kanban.tasksWillAppear"):q.status==="in-progress"?E("kanban.moveTasksHere"):q.status==="done"?E("kanban.completedTasksHere"):E("kanban.statusTasksHere")})]}):q.tasks.map(N=>e.jsx("div",{className:"transform transition-transform hover:scale-[1.02]",children:e.jsx(oo,{task:N,onClick:()=>r==null?void 0:r(N),showParent:a,className:"w-full shadow-sm hover:shadow-md transition-shadow cursor-pointer"})},N.id))})]},q.id))}):e.jsx("div",{className:be("gap-4",v==="grid"?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3":"space-y-4"),children:B.map(q=>e.jsx(oo,{task:q,onClick:()=>r==null?void 0:r(q),showParent:a,className:v==="grid"?"h-full":""},q.id))}),k&&e.jsx(Zp,{currentProject:o,onClose:()=>T(!1),onTaskCreated:()=>{T(!1),i&&i()}}),S&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(it,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:E("helpGuide.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:E("helpGuide.subtitle")})]})]}),e.jsx("button",{onClick:()=>H(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-blue-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:E("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:E("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{l==null||l(),H(!1)},className:"inline-flex items-center gap-2 text-sm bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-3 py-1.5 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(it,{className:"w-4 h-4"}),E("buttons.addPRD")]})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-green-50 to-emerald-50 dark:from-green-950/50 dark:to-emerald-950/50 rounded-lg border border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-green-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:E("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:E("gettingStarted.steps.generateTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-green-200 dark:border-green-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:E("helpGuide.examples.parsePRD")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/50 dark:to-orange-950/50 rounded-lg border border-amber-200 dark:border-amber-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-amber-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:E("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:E("gettingStarted.steps.analyzeTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-amber-200 dark:border-amber-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:E("helpGuide.examples.expandTask")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-950/50 dark:to-pink-950/50 rounded-lg border border-purple-200 dark:border-purple-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-purple-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:E("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:E("gettingStarted.steps.startBuilding.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-purple-200 dark:border-purple-700/50 p-3 mb-3",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:E("helpGuide.examples.addTask")})}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:E("helpGuide.moreExamples")})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-3",children:E("helpGuide.proTips.title")}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),E("helpGuide.proTips.search")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full mt-2 flex-shrink-0"}),E("helpGuide.proTips.views")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full mt-2 flex-shrink-0"}),E("helpGuide.proTips.filters")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-orange-500 rounded-full mt-2 flex-shrink-0"}),E("helpGuide.proTips.details")]})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 dark:bg-blue-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-3",children:E("helpGuide.learnMore.title")}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:E("helpGuide.learnMore.description")}),e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded-lg font-medium transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),E("helpGuide.learnMore.githubButton"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})})]})})]})},tx=({file:t,onClose:r,projectPath:s,project:a,initialContent:n="",isNewFile:o=!1,onSave:i})=>{const{addToast:l}=mr(),[m,d]=c.useState(n),[u,g]=c.useState(!o),[p,x]=c.useState(!1),[f,h]=c.useState(!1),[b,C]=c.useState(!0),[I,y]=c.useState(!1),[v,A]=c.useState(!1),[M,$]=c.useState(!0),[k,T]=c.useState(""),[W,U]=c.useState(!1),[S,H]=c.useState(!1),[w,P]=c.useState([]),j=c.useRef(null),F=`# Product Requirements Document - Example Project
250
+
251
+ ## 1. Overview
252
+ **Product Name:** AI-Powered Task Manager
253
+ **Version:** 1.0
254
+ **Date:** 2024-12-27
255
+ **Author:** Development Team
256
+
257
+ This document outlines the requirements for building an AI-powered task management application that integrates with development workflows and provides intelligent task breakdown and prioritization.
258
+
259
+ ## 2. Objectives
260
+ - Create an intuitive task management system that works seamlessly with developer tools
261
+ - Provide AI-powered task generation from high-level requirements
262
+ - Enable real-time collaboration and progress tracking
263
+ - Integrate with popular development environments (VS Code, Cursor, etc.)
264
+
265
+ ### Success Metrics
266
+ - User adoption rate > 80% within development teams
267
+ - Task completion rate improvement of 25%
268
+ - Time-to-delivery reduction of 15%
269
+
270
+ ## 3. User Stories
271
+
272
+ ### Core Functionality
273
+ - As a project manager, I want to create PRDs that automatically generate detailed tasks so I can save time on project planning
274
+ - As a developer, I want to see my next task clearly highlighted so I can maintain focus
275
+ - As a team lead, I want to track progress across multiple projects so I can provide accurate status updates
276
+ - As a developer, I want tasks to be broken down into implementable subtasks so I can work more efficiently
277
+
278
+ ### AI Integration
279
+ - As a user, I want to describe a feature in natural language and get detailed implementation tasks so I can start working immediately
280
+ - As a project manager, I want the AI to analyze task complexity and suggest appropriate time estimates
281
+ - As a developer, I want intelligent task prioritization based on dependencies and deadlines
282
+
283
+ ### Collaboration
284
+ - As a team member, I want to see real-time updates when tasks are completed so I can coordinate my work
285
+ - As a stakeholder, I want to view project progress through intuitive dashboards
286
+ - As a developer, I want to add implementation notes to tasks for future reference
287
+
288
+ ## 4. Functional Requirements
289
+
290
+ ### Task Management
291
+ - Create, edit, and delete tasks with rich metadata (priority, status, dependencies, estimates)
292
+ - Hierarchical task structure with subtasks and sub-subtasks
293
+ - Real-time status updates and progress tracking
294
+ - Dependency management with circular dependency detection
295
+ - Bulk operations (move, update status, assign)
296
+
297
+ ### AI Features
298
+ - Natural language PRD parsing to generate structured tasks
299
+ - Intelligent task breakdown with complexity analysis
300
+ - Automated subtask generation with implementation details
301
+ - Smart dependency suggestion
302
+ - Progress prediction based on historical data
303
+
304
+ ### Integration Features
305
+ - VS Code/Cursor extension for in-editor task management
306
+ - Git integration for linking commits to tasks
307
+ - API for third-party tool integration
308
+ - Webhook support for external notifications
309
+ - CLI tool for command-line task management
310
+
311
+ ### User Interface
312
+ - Responsive web application (desktop and mobile)
313
+ - Multiple view modes (Kanban, list, calendar)
314
+ - Dark/light theme support
315
+ - Drag-and-drop task organization
316
+ - Advanced filtering and search capabilities
317
+ - Keyboard shortcuts for power users
318
+
319
+ ## 5. Technical Requirements
320
+
321
+ ### Frontend
322
+ - React.js with TypeScript for type safety
323
+ - Modern UI framework (Tailwind CSS)
324
+ - State management (Context API or Redux)
325
+ - Real-time updates via WebSockets
326
+ - Progressive Web App (PWA) support
327
+ - Accessibility compliance (WCAG 2.1 AA)
328
+
329
+ ### Backend
330
+ - Node.js with Express.js framework
331
+ - RESTful API design with OpenAPI documentation
332
+ - Real-time communication via Socket.io
333
+ - Background job processing
334
+ - Rate limiting and security middleware
335
+
336
+ ### AI Integration
337
+ - Integration with multiple AI providers (OpenAI, Anthropic, etc.)
338
+ - Fallback model support
339
+ - Context-aware prompt engineering
340
+ - Token usage optimization
341
+ - Model response caching
342
+
343
+ ### Database
344
+ - Primary: PostgreSQL for relational data
345
+ - Cache: Redis for session management and real-time features
346
+ - Full-text search capabilities
347
+ - Database migrations and seeding
348
+ - Backup and recovery procedures
349
+
350
+ ### Infrastructure
351
+ - Docker containerization
352
+ - Cloud deployment (AWS/GCP/Azure)
353
+ - Auto-scaling capabilities
354
+ - Monitoring and logging (structured logging)
355
+ - CI/CD pipeline with automated testing
356
+
357
+ ## 6. Non-Functional Requirements
358
+
359
+ ### Performance
360
+ - Page load time < 2 seconds
361
+ - API response time < 500ms for 95% of requests
362
+ - Support for 1000+ concurrent users
363
+ - Efficient handling of large task lists (10,000+ tasks)
364
+
365
+ ### Security
366
+ - JWT-based authentication with refresh tokens
367
+ - Role-based access control (RBAC)
368
+ - Data encryption at rest and in transit
369
+ - Regular security audits and penetration testing
370
+ - GDPR and privacy compliance
371
+
372
+ ### Reliability
373
+ - 99.9% uptime SLA
374
+ - Graceful error handling and recovery
375
+ - Data backup every 6 hours with point-in-time recovery
376
+ - Disaster recovery plan with RTO < 4 hours
377
+
378
+ ### Scalability
379
+ - Horizontal scaling for both frontend and backend
380
+ - Database read replicas for query optimization
381
+ - CDN for static asset delivery
382
+ - Microservices architecture for future expansion
383
+
384
+ ## 7. User Experience Design
385
+
386
+ ### Information Architecture
387
+ - Intuitive navigation with breadcrumbs
388
+ - Context-aware menus and actions
389
+ - Progressive disclosure of complex features
390
+ - Consistent design patterns throughout
391
+
392
+ ### Interaction Design
393
+ - Smooth animations and transitions
394
+ - Immediate feedback for user actions
395
+ - Undo/redo functionality for critical operations
396
+ - Smart defaults and auto-save features
397
+
398
+ ### Visual Design
399
+ - Modern, clean interface with plenty of whitespace
400
+ - Consistent color scheme and typography
401
+ - Clear visual hierarchy with proper contrast ratios
402
+ - Iconography that supports comprehension
403
+
404
+ ## 8. Integration Requirements
405
+
406
+ ### Development Tools
407
+ - VS Code extension with task panel and quick actions
408
+ - Cursor IDE integration with AI task suggestions
409
+ - Terminal CLI for command-line workflow
410
+ - Browser extension for web-based tools
411
+
412
+ ### Third-Party Services
413
+ - GitHub/GitLab integration for issue sync
414
+ - Slack/Discord notifications
415
+ - Calendar integration (Google Calendar, Outlook)
416
+ - Time tracking tools (Toggl, Harvest)
417
+
418
+ ### APIs and Webhooks
419
+ - RESTful API with comprehensive documentation
420
+ - GraphQL endpoint for complex queries
421
+ - Webhook system for external integrations
422
+ - SDK development for major programming languages
423
+
424
+ ## 9. Implementation Phases
425
+
426
+ ### Phase 1: Core MVP (8-10 weeks)
427
+ - Basic task management (CRUD operations)
428
+ - Simple AI task generation
429
+ - Web interface with essential features
430
+ - User authentication and basic permissions
431
+
432
+ ### Phase 2: Enhanced Features (6-8 weeks)
433
+ - Advanced AI features (complexity analysis, subtask generation)
434
+ - Real-time collaboration
435
+ - Mobile-responsive design
436
+ - Integration with one development tool (VS Code)
437
+
438
+ ### Phase 3: Enterprise Features (4-6 weeks)
439
+ - Advanced user management and permissions
440
+ - API and webhook system
441
+ - Performance optimization
442
+ - Comprehensive testing and security audit
443
+
444
+ ### Phase 4: Ecosystem Expansion (4-6 weeks)
445
+ - Additional tool integrations
446
+ - Mobile app development
447
+ - Advanced analytics and reporting
448
+ - Third-party marketplace preparation
449
+
450
+ ## 10. Risk Assessment
451
+
452
+ ### Technical Risks
453
+ - AI model reliability and cost management
454
+ - Real-time synchronization complexity
455
+ - Database performance with large datasets
456
+ - Integration complexity with multiple tools
457
+
458
+ ### Business Risks
459
+ - User adoption in competitive market
460
+ - AI provider dependency
461
+ - Data privacy and security concerns
462
+ - Feature scope creep and timeline delays
463
+
464
+ ### Mitigation Strategies
465
+ - Implement robust error handling and fallback systems
466
+ - Develop comprehensive testing strategy
467
+ - Create detailed documentation and user guides
468
+ - Establish clear project scope and change management process
469
+
470
+ ## 11. Success Criteria
471
+
472
+ ### Development Milestones
473
+ - Alpha version with core features completed
474
+ - Beta version with selected user group feedback
475
+ - Production-ready version with full feature set
476
+ - Post-launch iterations based on user feedback
477
+
478
+ ### Business Metrics
479
+ - User engagement and retention rates
480
+ - Task completion and productivity metrics
481
+ - Customer satisfaction scores (NPS > 50)
482
+ - Revenue targets and subscription growth
483
+
484
+ ## 12. Appendices
485
+
486
+ ### Glossary
487
+ - **PRD**: Product Requirements Document
488
+ - **AI**: Artificial Intelligence
489
+ - **CRUD**: Create, Read, Update, Delete
490
+ - **API**: Application Programming Interface
491
+ - **CI/CD**: Continuous Integration/Continuous Deployment
492
+
493
+ ### References
494
+ - Industry best practices for task management
495
+ - AI integration patterns and examples
496
+ - Security and compliance requirements
497
+ - Performance benchmarking data
498
+
499
+ ---
500
+
501
+ **Document Control:**
502
+ - Version: 1.0
503
+ - Last Updated: December 27, 2024
504
+ - Next Review: January 15, 2025
505
+ - Approved By: Product Owner, Technical Lead`;c.useEffect(()=>{(async()=>{if(t!=null&&t.name)T(t.name.replace(/\.(txt|md)$/,""));else if(o){const K=new Date().toISOString().split("T")[0];T(`prd-${K}`)}if(o){d(F),g(!1);return}if(t.content){d(t.content),g(!1);return}try{g(!0);const B=await He.readFile(t.projectName,t.path);if(!B.ok)throw new Error(`Failed to load file: ${B.status} ${B.statusText}`);const K=await B.json();d(K.content||F)}catch(B){console.error("Error loading PRD file:",B),d(`# Error Loading PRD
506
+
507
+ Error: ${B.message}
508
+
509
+ File: ${(t==null?void 0:t.name)||"New PRD"}
510
+ Path: ${(t==null?void 0:t.path)||"Not saved yet"}
511
+
512
+ ${F}`)}finally{g(!1)}})()},[t,s,o]),c.useEffect(()=>{(async()=>{if(!(a!=null&&a.name)){console.log("No project name available:",a);return}try{console.log("Fetching PRDs for project:",a.name);const B=await He.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(B.ok){const K=await B.json();console.log("Fetched existing PRDs:",K.prds),P(K.prds||[])}else console.log("Failed to fetch PRDs:",B.status,B.statusText)}catch(B){console.error("Error fetching existing PRDs:",B)}})()},[a==null?void 0:a.name]);const G=async()=>{if(!m.trim()){l("Please add content before saving.","warning");return}if(!k.trim()){l("Please provide a filename for the PRD.","warning");return}const J=k.endsWith(".txt")||k.endsWith(".md")?k:`${k}.txt`,B=w.find(K=>K.name===J);if(console.log("Save check:",{fullFileName:J,existingPRDs:w,existingFile:B,isExisting:t==null?void 0:t.isExisting,fileObject:t,shouldShowModal:B&&!(t!=null&&t.isExisting)}),B&&!(t!=null&&t.isExisting)){console.log("Showing overwrite confirmation modal"),H(!0);return}await X()},X=async()=>{x(!0);try{const J=k.endsWith(".txt")||k.endsWith(".md")?k:`${k}.txt`,B=await Ee(`/api/taskmaster/prd/${encodeURIComponent(a==null?void 0:a.name)}`,{method:"POST",body:JSON.stringify({fileName:J,content:m})});if(!B.ok){const V=await B.json();throw new Error(V.message||`Save failed: ${B.status}`)}y(!0),setTimeout(()=>y(!1),2e3);const K=await He.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(K.ok){const V=await K.json();P(V.prds||[])}i&&await i()}catch(J){console.error("Error saving PRD:",J),l(`Error saving PRD: ${J.message}`,"error")}finally{x(!1)}},D=()=>{const J=new Blob([m],{type:"text/markdown"}),B=URL.createObjectURL(J),K=document.createElement("a");K.href=B;const V=k?`${k}.txt`:"prd.txt";K.download=V,document.body.appendChild(K),K.click(),document.body.removeChild(K),URL.revokeObjectURL(B)},oe=async()=>{if(!m.trim()){l("Please add content to the PRD before generating tasks.","warning");return}U(!0)},E=()=>{h(!f)};c.useEffect(()=>{const J=B=>{(B.ctrlKey||B.metaKey)&&(B.key==="s"?(B.preventDefault(),G()):B.key==="Escape"&&(B.preventDefault(),r()))};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[m]);const se=J=>J.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/^\- (.*$)/gim,"<li>$1</li>").replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>").replace(/\n\n/gim,"</p><p>").replace(/^(?!<[h|u|l])(.*$)/gim,"<p>$1</p>").replace(/<\/ul>\s*<ul>/gim,"");return u?e.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center bg-white dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):e.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${f?"md:p-0":""}`,children:[e.jsxs("div",{className:be("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",f?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:e.jsx(it,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center min-w-0 flex-1 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md px-3 py-2 focus-within:ring-2 focus-within:ring-purple-500 focus-within:border-purple-500 dark:focus-within:ring-purple-400 dark:focus-within:border-purple-400",children:[e.jsx("input",{type:"text",value:k,onChange:J=>{const B=J.target.value.replace(/[<>:"/\\|?*]/g,"");T(B)},className:"font-medium text-gray-900 dark:text-white bg-transparent border-none outline-none min-w-0 flex-1 text-base sm:text-sm placeholder-gray-400 dark:placeholder-gray-500",placeholder:"Enter PRD filename",maxLength:100}),e.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),e.jsx("button",{onClick:()=>{var J;return(J=document.querySelector('input[placeholder="Enter PRD filename"]'))==null?void 0:J.focus()},className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-300 px-2 py-1 rounded whitespace-nowrap",children:"📋 PRD"}),o&&e.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-300 px-2 py-1 rounded whitespace-nowrap",children:"✨ New"})]})]}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>A(!v),className:be("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",v?"text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:v?"Switch to edit mode":"Preview markdown",children:e.jsx(ur,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:()=>$(!M),className:be("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",M?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:M?"Disable word wrap":"Enable word wrap",children:e.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),e.jsx("button",{onClick:()=>C(!b),className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Toggle theme",children:e.jsx("span",{className:"text-lg md:text-base",children:b?"☀️":"🌙"})}),e.jsx("button",{onClick:D,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download PRD",children:e.jsx(ys,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsxs("button",{onClick:oe,disabled:!m.trim(),className:be("px-3 py-2 rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors text-sm font-medium","bg-purple-600 hover:bg-purple-700 text-white","min-h-[44px] md:min-h-0"),title:"Generate tasks from PRD content",children:[e.jsx(Ht,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),e.jsx("button",{onClick:G,disabled:p,className:be("px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors","min-h-[44px] md:min-h-0",I?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:I?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),e.jsx("button",{onClick:E,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:f?"Exit fullscreen":"Fullscreen",children:f?e.jsx(vo,{className:"w-4 h-4"}):e.jsx(Ma,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(qe,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:v?e.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:e.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:se(m)}})}):e.jsx(jo,{ref:j,value:m,onChange:d,extensions:[Co(),...M?[Zt.lineWrapping]:[]],theme:b?No:void 0,height:"100%",style:{fontSize:"14px",height:"100%"},basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",m.split(`
513
+ `).length]}),e.jsxs("span",{children:["Characters: ",m.length]}),e.jsxs("span",{children:["Words: ",m.split(/\s+/).filter(J=>J.length>0).length]}),e.jsx("span",{children:"Format: Markdown"})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),W&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ht,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),e.jsx("button",{onClick:()=>U(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(qe,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ht,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask your AI assistant in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),e.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,k.endsWith(".txt")||k.endsWith(".md")?k:`${k}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),e.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[e.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:()=>U(!1),className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),S&&e.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>H(!1)}),e.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:e.jsx(qt,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',k.endsWith(".txt")||k.endsWith(".md")?k:`${k}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>H(!1),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:async()=>{H(!1),await X()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[e.jsx(fs,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},rx=ex,sx=Yo,ax=tx,nx="PRD saved successfully!";function ox(t){return t.prdFiles||t.prds||[]}function ix({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=Ar(),[n,o]=c.useState(null),[i,l]=c.useState(!1),[m,d]=c.useState(!1),[u,g]=c.useState(null),[p,x]=c.useState([]),[f,h]=c.useState(null),b=c.useRef(null),C=c.useCallback(W=>{b.current&&clearTimeout(b.current),h(W),b.current=setTimeout(()=>{h(null),b.current=null},3e3)},[]),I=c.useCallback(async()=>{if(!(s!=null&&s.name)){x([]);return}try{const W=await He.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!W.ok){x([]);return}const U=await W.json();x(ox(U))}catch(W){console.error("Failed to load existing PRDs:",W),x([])}},[s==null?void 0:s.name]),y=c.useCallback(async(W=!1)=>{await I(),W&&C(nx)},[I,C]);c.useEffect(()=>{I()},[I]),c.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const v=c.useCallback(W=>{if(!(!W||typeof W!="object"||!("id"in W))){if(!("title"in W)||!W.title){const U=r.find(S=>String(S.id)===String(W.id));U&&(o(U),l(!0));return}o(W),l(!0)}},[r]),A=c.useCallback(()=>{l(!1),o(null)},[]),M=c.useCallback((W,U)=>{console.log("Update task status:",W,U),a==null||a()},[a]),$=c.useCallback((W=null)=>{g(W),d(!0)},[]),k=c.useCallback(()=>{d(!1),g(null)},[]),T=c.useCallback(async()=>{k(),await y(!0),a==null||a()},[k,y,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`h-full ${t?"block":"hidden"}`,children:e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx(rx,{tasks:r,onTaskClick:v,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:$,existingPRDs:p,onRefreshPRDs:(W=!1)=>{y(W)}})})}),i&&n&&e.jsx(sx,{task:n,isOpen:i,onClose:A,onStatusChange:M,onTaskClick:v}),m&&e.jsx(ax,{project:s,projectPath:(s==null?void 0:s.fullPath)||(s==null?void 0:s.path),onClose:k,isNewFile:!(u!=null&&u.isExisting),file:{name:(u==null?void 0:u.name)||"prd.txt",content:(u==null?void 0:u.content)||""},onSave:T}),f&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"font-medium",children:f})]})})]})}function lx(){const{isRelayConnected:t,isChecking:r}=Ta(),[s,a]=c.useState(null),[n,o]=c.useState(!1),[i,l]=c.useState(!1),[m,d]=c.useState(!1),[u,g]=c.useState(!1);c.useEffect(()=>{if(t||g(!0),t&&u){d(!0),a(null);const h=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(h)}},[t,u]);const p=c.useCallback(async()=>{try{o(!0);const h=await He.relay.createToken(`web-${Date.now()}`);if(h.ok){const b=await h.json();a(b.token)}}catch{}finally{o(!1)}},[]),x=window.location.origin,f=c.useCallback(()=>{if(!s)return;const h=`npx upfynai-code connect --server ${x} --key ${s}`;navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),2e3)},[s,x]);return r||t&&!m?null:t&&m?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-green-500/10 border-b border-green-500/20 text-green-400 text-sm",children:[e.jsx(tn,{className:"w-4 h-4"}),e.jsx("span",{children:"Machine connected"})]}):e.jsxs("div",{className:"border-b border-amber-500/20 bg-amber-500/10",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(co,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-amber-300",children:"Connect your machine to get started"}),!s&&e.jsxs("button",{onClick:p,disabled:n,className:"ml-auto flex items-center gap-1.5 px-3 py-1 text-xs font-medium rounded-md bg-amber-500/20 hover:bg-amber-500/30 text-amber-300 transition-colors disabled:opacity-50",children:[n?e.jsx(jr,{className:"w-3 h-3 animate-spin"}):e.jsx(tn,{className:"w-3 h-3"}),"Start Listening"]})]}),s&&e.jsxs("div",{className:"px-4 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border p-2",children:[e.jsxs("code",{className:"text-xs text-foreground flex-1 overflow-x-auto whitespace-nowrap",children:["npx upfynai-code connect --server ",x," --key ",s]}),e.jsx("button",{onClick:f,className:"flex-shrink-0 p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy command",children:i?e.jsx(Tt,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(Da,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1.5",children:"Run this command in your terminal to connect"})]})]})}function ps({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=Ta();return s||a?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:r}),e.jsx("div",{className:"h-full w-full opacity-30 pointer-events-none select-none","aria-hidden":!0,children:t})]})}function Ps({icon:t,label:r}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",children:[e.jsx(t,{className:"w-10 h-10 opacity-40"}),e.jsxs("p",{className:"text-sm font-medium",children:[r," requires a connected machine"]}),e.jsx("p",{className:"text-xs opacity-60",children:"Connect your machine to get started"})]})}function cx(){return e.jsx(Ps,{icon:La,label:"Chat"})}function dx(){return e.jsx(Ps,{icon:ct,label:"Shell"})}function mx(){return e.jsx(Ps,{icon:ol,label:"Files"})}function ux(){return e.jsx(Ps,{icon:Gt,label:"Git"})}function px({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=c.useState(null),[o,i]=c.useState(s),[l,m]=c.useState(!1),[d,u]=c.useState(!1),g=c.useRef(null),p=c.useCallback((b,C=null)=>{const y=b.replace(/\\/g,"/").split("/").pop()||b;n({name:y,path:b,projectName:t==null?void 0:t.name,diffInfo:C})},[t==null?void 0:t.name]),x=c.useCallback(()=>{n(null),m(!1)},[]),f=c.useCallback(()=>{m(b=>!b)},[]),h=c.useCallback(b=>{r||(u(!0),b.preventDefault())},[r]);return c.useEffect(()=>{const b=I=>{var k;if(!d)return;const y=(k=g.current)==null?void 0:k.parentElement;if(!y)return;const v=y.getBoundingClientRect(),A=v.right-I.clientX,M=300,$=v.width*.8;A>=M&&A<=$&&i(A)},C=()=>{u(!1)};return d&&(document.addEventListener("mousemove",b),document.addEventListener("mouseup",C),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",C),document.body.style.cursor="",document.body.style.userSelect=""}},[d]),{editingFile:a,editorWidth:o,editorExpanded:l,resizeHandleRef:g,handleFileOpen:p,handleCloseEditor:x,handleToggleEditorExpand:f,handleResizeStart:h}}const xx=c.lazy(()=>Ls(()=>import("./CanvasPanel-CB4sweQq.js"),__vite__mapDeps([4,3,1,2,5,6]))),gx=c.lazy(()=>Ls(()=>import("./WorkflowsPanel-CO5g5yGG.js"),__vite__mapDeps([7,1,8,3,2,5,9,10]))),hx=c.lazy(()=>Ls(()=>import("./DashboardPanel-BXaA-b9z.js"),__vite__mapDeps([11,1,8,3,2,5,9,10]))),fx=ml,bx=Ip;function yx({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:l,onMenuClick:m,isLoading:d,onInputFocusChange:u,onSessionActive:g,onSessionInactive:p,onSessionProcessing:x,onSessionNotProcessing:f,processingSessions:h,onReplaceTemporarySession:b,onNavigateToSession:C,onShowSettings:I,externalMessageUpdate:y}){const{preferences:v}=_a(),{autoExpandTools:A,showRawParameters:M,showThinking:$,autoScrollToBottom:k,sendByCtrlEnter:T}=v,{currentProject:W,setCurrentProject:U}=Ar(),{tasksEnabled:S,isTaskMasterInstalled:H}=Yr(),w=S!==!1,{editingFile:P,editorWidth:j,editorExpanded:F,resizeHandleRef:G,handleFileOpen:X,handleCloseEditor:D,handleToggleEditorExpand:oe,handleResizeStart:E}=px({selectedProject:t,isMobile:l});return c.useEffect(()=>{t&&t!==W&&(U==null||U(t))},[t,W,U]),c.useEffect(()=>{!w&&s==="tasks"&&a("chat")},[w,s,a]),d?e.jsx(to,{mode:"loading",isMobile:l,onMenuClick:m}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Pp,{activeTab:s,setActiveTab:a,selectedProject:t,selectedSession:r,shouldShowTasksTab:w,isMobile:l,onMenuClick:m}),e.jsx(lx,{}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex flex-col min-h-0 overflow-hidden ${F?"hidden":""} ${s==="files"&&P?"w-[280px] flex-shrink-0":"flex-1"}`,children:[s==="dashboard"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading dashboard..."}),children:e.jsx(hx,{selectedProject:t})})}),e.jsx("div",{className:`h-full ${s==="chat"?"block":"hidden"}`,children:e.jsx(ps,{fallback:e.jsx(cx,{}),children:e.jsx(Zn,{showDetails:!0,children:e.jsx(Np,{selectedProject:t,selectedSession:r,ws:n,sendMessage:o,latestMessage:i,onFileOpen:X,onInputFocusChange:u,onSessionActive:g,onSessionInactive:p,onSessionProcessing:x,onSessionNotProcessing:f,processingSessions:h,onReplaceTemporarySession:b,onNavigateToSession:C,onShowSettings:I,autoExpandTools:A,showRawParameters:M,showThinking:$,autoScrollToBottom:k,sendByCtrlEnter:T,externalMessageUpdate:y,onShowAllTasks:S?()=>a("tasks"):null,setActiveTab:a})})})}),s==="canvas"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Zn,{showDetails:!0,children:e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading canvas..."}),children:e.jsx(xx,{selectedProject:t,ws:n,sendMessage:o,latestMessage:i})})})}),s==="files"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(ps,{fallback:e.jsx(mx,{}),children:e.jsx(Tp,{selectedProject:t,onFileOpen:X})})}),s==="shell"&&e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsx(ps,{fallback:e.jsx(dx,{}),children:e.jsx(fx,{project:t,session:r,showHeader:!1,multiTab:!0})})}),s==="git"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(ps,{fallback:e.jsx(ux,{}),children:e.jsx(bx,{selectedProject:t,isMobile:l,onFileOpen:X})})}),s==="workflows"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading workflows..."}),children:e.jsx(gx,{selectedProject:t})})}),w&&e.jsx(ix,{isVisible:s==="tasks"}),e.jsx("div",{className:`h-full overflow-hidden ${s==="preview"?"block":"hidden"}`})]}),e.jsx(Xp,{editingFile:P,isMobile:l,editorExpanded:F,editorWidth:j,resizeHandleRef:G,onResizeStart:E,onCloseEditor:D,onToggleEditorExpand:oe,projectPath:t.path,fillSpace:s==="files"})]})]}):e.jsx(to,{mode:"empty",isMobile:l,onMenuClick:m})}const vx=Ft.memo(yx);function kx({activeTab:t,setActiveTab:r,isInputFocused:s}){const{tasksEnabled:a,isTaskMasterInstalled:n}=Yr(),i=[{id:"chat",icon:La,label:"Chat",onClick:()=>r("chat")},{id:"shell",icon:ct,label:"Shell",onClick:()=>r("shell")},{id:"files",icon:tr,label:"Files",onClick:()=>r("files")},{id:"git",icon:Gt,label:"Git",onClick:()=>r("git")},{id:"workflows",icon:cr,label:"Workflows",onClick:()=>r("workflows")},...!!(a&&n)?[{id:"tasks",icon:yo,label:"Tasks",onClick:()=>r("tasks")}]:[]];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 px-3 pb-[max(8px,env(safe-area-inset-bottom))] transform transition-transform duration-300 ease-in-out ${s?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"nav-glass mobile-nav-float rounded-2xl border border-border/30",children:e.jsx("div",{className:"flex items-center justify-around px-1 py-1.5 gap-0.5",children:i.map(l=>{const m=l.icon,d=t===l.id;return e.jsxs("button",{onClick:l.onClick,onTouchStart:u=>{u.preventDefault(),l.onClick()},className:`flex flex-col items-center justify-center gap-0.5 px-3 py-2 rounded-xl flex-1 relative touch-manipulation transition-all duration-200 active:scale-95 ${d?"text-primary":"text-muted-foreground hover:text-foreground"}`,"aria-label":l.label,"aria-current":d?"page":void 0,children:[d&&e.jsx("div",{className:"absolute inset-0 bg-primary/8 dark:bg-primary/12 rounded-xl"}),e.jsx(m,{className:`relative z-10 transition-all duration-200 ${d?"w-5 h-5":"w-[18px] h-[18px]"}`,strokeWidth:d?2.4:1.8}),e.jsx("span",{className:`relative z-10 text-[10px] font-medium transition-all duration-200 ${d?"opacity-100":"opacity-60"}`,children:l.label})]},l.id)})})})})}function wx(){const[t,r]=c.useState(new Set),[s,a]=c.useState(new Set),n=c.useCallback(d=>{d&&r(u=>new Set([...u,d]))},[]),o=c.useCallback(d=>{d&&r(u=>{const g=new Set(u);return g.delete(d),g})},[]),i=c.useCallback(d=>{d&&a(u=>new Set([...u,d]))},[]),l=c.useCallback(d=>{d&&a(u=>{const g=new Set(u);return g.delete(d),g})},[]),m=c.useCallback(d=>{d&&r(u=>{const g=new Set;for(const p of u)p.startsWith("new-session-")||g.add(p);return g.add(d),g})},[]);return{activeSessions:t,processingSessions:s,markSessionAsActive:n,markSessionAsInactive:o,markSessionAsProcessing:i,markSessionAsNotProcessing:l,replaceTemporarySession:m}}const yt=t=>JSON.stringify(t??null),io=(t,r,s)=>t.length!==r.length?!0:r.some((a,n)=>{const o=t[n];return!o||a.name!==o.name||a.displayName!==o.displayName||a.fullPath!==o.fullPath||yt(a.sessionMeta)!==yt(o.sessionMeta)||yt(a.sessions)!==yt(o.sessions)?!0:yt(a.cursorSessions)!==yt(o.cursorSessions)||yt(a.codexSessions)!==yt(o.codexSessions)}),As=t=>[...t.sessions??[],...t.codexSessions??[],...t.cursorSessions??[]],jx=(t,r,s,a)=>{if(!s||!a)return!0;const n=t.find(m=>m.name===s.name),o=r.find(m=>m.name===s.name);if(!n||!o)return!1;const i=As(n).find(m=>m.id===a.id),l=As(o).find(m=>m.id===a.id);return!i||!l?!1:i.id===l.id&&i.title===l.title&&i.created_at===l.created_at&&i.updated_at===l.updated_at};function Nx({sessionId:t,navigate:r,latestMessage:s,isMobile:a,activeSessions:n}){const[o,i]=c.useState([]),[l,m]=c.useState(null),[d,u]=c.useState(null),[g,p]=c.useState("chat"),[x,f]=c.useState(!1),[h,b]=c.useState(!0),[C,I]=c.useState(null),[y,v]=c.useState(!1),[A,M]=c.useState(!1),[$,k]=c.useState("agents"),[T,W]=c.useState(0),U=c.useRef(null),S=c.useRef(new Set),H=c.useCallback(async()=>{try{b(!0);const se=await(await He.projects()).json();i(J=>J.length===0||io(J,se,!0)?se:J)}catch(E){console.error("Error fetching projects:",E)}finally{b(!1)}},[]),w=c.useCallback((E="tools")=>{k(E),M(!0)},[]);c.useEffect(()=>{H()},[H]),c.useEffect(()=>{!h&&o.length===1&&!l&&!t&&m(o[0])},[h,o,l,t]),c.useEffect(()=>{if(!s)return;if(s.type==="loading_progress"){U.current&&(clearTimeout(U.current),U.current=null),I(s),s.phase==="complete"&&(U.current=setTimeout(()=>{I(null),U.current=null},500));return}if(s.type!=="projects_updated")return;const E=s;if(E.changedFile&&d&&l){const z=E.changedFile.replace(/\\/g,"/").split("/");z.length>=2&&z[z.length-1].replace(".jsonl","")===d.id&&(n.has(d.id)||W(q=>q+1))}const se=d&&n.has(d.id)||n.size>0&&Array.from(n).some(V=>V.startsWith("new-session-")),J=E.projects;if(se&&!jx(o,J,l,d)||(i(J),!l))return;const B=J.find(V=>V.name===l.name);if(!B||(yt(B)!==yt(l)&&m(B),!d))return;As(B).find(V=>V.id===d.id)||u(null)},[s,l,d,n,o]),c.useEffect(()=>()=>{U.current&&(clearTimeout(U.current),U.current=null)},[]),c.useEffect(()=>{var se,J,B;if(!t||o.length===0)return;const E=!d||d.id!==t;for(const K of o){const V=(se=K.sessions)==null?void 0:se.find(ne=>ne.id===t);if(V){const ne=(l==null?void 0:l.name)!==K.name,me=(d==null?void 0:d.id)!==t||d.__provider!=="claude";ne&&m(K),me&&u({...V,__provider:"claude"}),E&&p("chat");return}const z=(J=K.cursorSessions)==null?void 0:J.find(ne=>ne.id===t);if(z){const ne=(l==null?void 0:l.name)!==K.name,me=(d==null?void 0:d.id)!==t||d.__provider!=="cursor";ne&&m(K),me&&u({...z,__provider:"cursor"}),E&&p("chat");return}const O=(B=K.codexSessions)==null?void 0:B.find(ne=>ne.id===t);if(O){const ne=(l==null?void 0:l.name)!==K.name,me=(d==null?void 0:d.id)!==t||d.__provider!=="codex";ne&&m(K),me&&u({...O,__provider:"codex"}),E&&p("chat");return}}},[t,o,l==null?void 0:l.name,d==null?void 0:d.id,d==null?void 0:d.__provider]);const P=c.useCallback(E=>{m(E),u(null),r("/"),a&&f(!1)},[a,r]),j=c.useCallback(E=>{if(u(E),g!=="git"&&g!=="preview"&&p("chat"),(localStorage.getItem("selected-provider")||"claude")==="cursor"&&sessionStorage.setItem("cursorSessionId",E.id),a){const J=E.__projectName,B=l==null?void 0:l.name;J!==B&&f(!1)}r(`/session/${E.id}`)},[g,a,r,l==null?void 0:l.name]),F=c.useCallback(E=>{m(E),u(null),p("chat"),r("/"),a&&f(!1)},[a,r]),G=c.useCallback(E=>{S.current.add(E),setTimeout(()=>S.current.delete(E),3e4),(d==null?void 0:d.id)===E&&(u(null),r("/")),i(se=>se.map(J=>{var B,K;return{...J,sessions:((B=J.sessions)==null?void 0:B.filter(V=>V.id!==E))??[],sessionMeta:{...J.sessionMeta,total:Math.max(0,(((K=J.sessionMeta)==null?void 0:K.total)??0)-1)}}}))},[r,d==null?void 0:d.id]),X=c.useCallback(async()=>{try{let se=await(await He.projects()).json();if(S.current.size>0&&(se=se.map(K=>{var V;return{...K,sessions:((V=K.sessions)==null?void 0:V.filter(z=>!S.current.has(z.id)))??[]}})),i(K=>io(K,se,!0)?se:K),!l)return;const J=se.find(K=>K.name===l.name);if(!J||(yt(J)!==yt(l)&&m(J),!d))return;const B=As(J).find(K=>K.id===d.id);if(B){const K=B.__provider||!d.__provider?B:{...B,__provider:d.__provider};yt(K)!==yt(d)&&u(K)}}catch(E){console.error("Error refreshing sidebar:",E)}},[l,d]),D=c.useCallback(E=>{(l==null?void 0:l.name)===E&&(m(null),u(null),r("/")),i(se=>se.filter(J=>J.name!==E))},[r,l==null?void 0:l.name]),oe=c.useMemo(()=>({projects:o,selectedProject:l,selectedSession:d,onProjectSelect:P,onSessionSelect:j,onNewSession:F,onSessionDelete:G,onProjectDelete:D,isLoading:h,loadingProgress:C,onRefresh:X,onShowSettings:()=>M(!0),showSettings:A,settingsInitialTab:$,onCloseSettings:()=>M(!1),isMobile:a}),[F,D,P,G,j,X,h,a,C,o,$,l,d,A]);return{projects:o,selectedProject:l,selectedSession:d,activeTab:g,sidebarOpen:x,isLoadingProjects:h,loadingProgress:C,isInputFocused:y,showSettings:A,settingsInitialTab:$,externalMessageUpdate:T,setActiveTab:p,setSidebarOpen:f,setIsInputFocused:v,setShowSettings:M,openSettings:w,fetchProjects:H,sidebarSharedProps:oe,handleProjectSelect:P,handleSessionSelect:j,handleNewSession:F,handleSessionDelete:G,handleProjectDelete:D,handleSidebarRefresh:X}}function Cx(){const t=Ti(),{sessionId:r}=Ii(),{t:s}=Ge("common"),{isMobile:a}=Pa({trackPWA:!1}),{ws:n,sendMessage:o,latestMessage:i}=Ai(),{activeSessions:l,processingSessions:m,markSessionAsActive:d,markSessionAsInactive:u,markSessionAsProcessing:g,markSessionAsNotProcessing:p,replaceTemporarySession:x}=wx(),{selectedProject:f,selectedSession:h,activeTab:b,sidebarOpen:C,isLoadingProjects:I,isInputFocused:y,externalMessageUpdate:v,setActiveTab:A,setSidebarOpen:M,setIsInputFocused:$,setShowSettings:k,openSettings:T,fetchProjects:W,sidebarSharedProps:U}=Nx({sessionId:r,navigate:t,latestMessage:i,isMobile:a,activeSessions:l});return c.useEffect(()=>(window.refreshProjects=W,()=>{window.refreshProjects===W&&delete window.refreshProjects}),[W]),c.useEffect(()=>(window.openSettings=T,()=>{window.openSettings===T&&delete window.openSettings}),[T]),e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[a?e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${C?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/60 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:S=>{S.stopPropagation(),M(!1)},onTouchStart:S=>{S.preventDefault(),S.stopPropagation(),M(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border/40 transform transition-transform duration-150 ease-out ${C?"translate-x-0":"-translate-x-full"}`,onClick:S=>S.stopPropagation(),onTouchStart:S=>S.stopPropagation(),children:e.jsx(bn,{...U})})]}):e.jsx("div",{className:"h-full flex-shrink-0 border-r border-border/50",children:e.jsx(bn,{...U})}),e.jsx("div",{className:`flex-1 flex flex-col min-w-0 ${a?"pb-mobile-nav":""}`,children:e.jsx(vx,{selectedProject:f,selectedSession:h,activeTab:b,setActiveTab:A,ws:n,sendMessage:o,latestMessage:i,isMobile:a,onMenuClick:()=>M(!0),isLoading:I,onInputFocusChange:$,onSessionActive:d,onSessionInactive:u,onSessionProcessing:g,onSessionNotProcessing:p,processingSessions:m,onReplaceTemporarySession:x,onNavigateToSession:S=>t(`/session/${S}`),onShowSettings:()=>k(!0),externalMessageUpdate:v})}),a&&e.jsx(kx,{activeTab:b,setActiveTab:A,isInputFocused:y})]})}const Fx=Object.freeze(Object.defineProperty({__proto__:null,default:Cx},Symbol.toStringTag,{value:"Module"}));export{Fx as A,In as _,$x as a,Lx as b};