@forsion/unit 2.13.0 → 2.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.mjs +23 -3
- package/package.json +1 -1
- package/release.json +5 -5
- package/web/assets/{ArtificialView-BSv3Mx5C.js → ArtificialView-Bs_6B211.js} +1 -1
- package/web/assets/{AutomationBuilder-BuiHtVB-.js → AutomationBuilder-C-IFaaBp.js} +1 -1
- package/web/assets/CalendarConfigView-DEsNvVkD.js +1 -0
- package/web/assets/CalendarView-D7ZUE_dr.js +1 -0
- package/web/assets/{CapabilityMenu-kx1TIJYN.js → CapabilityMenu-CrsaTtDe.js} +1 -1
- package/web/assets/{CheckboxInput-eW7xdiRS.js → CheckboxInput-DVO2-1J7.js} +1 -1
- package/web/assets/{Chrome-B77-lQyh.js → Chrome-BvpbCvo1.js} +1 -1
- package/web/assets/{CodeView-Df3AiSIi.js → CodeView-CB4kG7Y6.js} +3 -3
- package/web/assets/DashboardGridView-hpRmBr9B.css +1 -0
- package/web/assets/DashboardGridView-tgaj9-SM.js +17 -0
- package/web/assets/{EventCard-CDmeCbI8.js → EventCard-c6s4uGBu.js} +1 -1
- package/web/assets/ExcalidrawCanvas-NdV86AR3.js +1 -0
- package/web/assets/{FloatingToc-tART_jC4.js → FloatingToc-ldOYWe2C.js} +1 -1
- package/web/assets/HomepageView-4joJWYlg.js +1 -0
- package/web/assets/HomepageView-Cxf3AWBu.css +1 -0
- package/web/assets/ImageStudioPanels-DgMYAsHj.js +3 -0
- package/web/assets/{ImageStudioView-KJhx0wJk.js → ImageStudioView-_CYHoOoG.js} +1 -1
- package/web/assets/InlineFiles-BIfsx3R-.js +1 -0
- package/web/assets/MarkdownBlock-wYEaBBOr.js +58 -0
- package/web/assets/ModelPill-DveHcLqq.js +2 -0
- package/web/assets/MuseLibraryView-Do9RnKiq.js +2 -0
- package/web/assets/{MuseView-Cb6R_l4i.js → MuseView-3GL4Ltoj.js} +2 -2
- package/web/assets/{PageHistoryPanel-BQs9IWTP.js → PageHistoryPanel-BMQC-V_l.js} +2 -2
- package/web/assets/{PdfAnnotator-BFTBkxvO.js → PdfAnnotator-CyAw8sgq.js} +1 -1
- package/web/assets/PenRow-BSB-h5Pb.js +1 -0
- package/web/assets/{ProductView-mB-S0j81.js → ProductView-B96OeHOP.js} +1 -1
- package/web/assets/{RightPanel-BVZeVO3c.js → RightPanel-BgSeCLnw.js} +3 -3
- package/web/assets/RunLocationPicker-CEmFio4n.css +1 -0
- package/web/assets/RunLocationPicker-M1UoJyjf.js +38 -0
- package/web/assets/{SketchCard-CAAr_cqF.js → SketchCard-DAD0jR0i.js} +212 -8
- package/web/assets/{StudioGuestSurface-DthpuVGg.js → StudioGuestSurface-DlUKXBXv.js} +1 -1
- package/web/assets/TodoListView-_yFkPUrw.js +1 -0
- package/web/assets/{Tooltip-D9Dt9ZTr.js → Tooltip-DXuy9-1_.js} +1 -1
- package/web/assets/UnifiedPage-EJNWKzxN.js +68 -0
- package/web/assets/{amadeus-manual.en-D5wZKuag.js → amadeus-manual.en-DzRWr4BL.js} +15 -15
- package/web/assets/{amadeus-manual.zh-Br5fidrj.js → amadeus-manual.zh-DW32DkL7.js} +15 -15
- package/web/assets/{appStore-B1ynyt42.js → appStore-CidPWYa0.js} +242 -134
- package/web/assets/appStore-DeaC1U32.css +1 -0
- package/web/assets/{arrow-up-right-R10mR2I6.js → arrow-up-right-KPFbRA41.js} +1 -1
- package/web/assets/{astryxBridge-CU_kQTEl.js → astryxBridge-Bupzouso.js} +3 -3
- package/web/assets/{automationListSource-B8EIRmDW.js → automationListSource-1aOVKBLw.js} +1 -1
- package/web/assets/boardSurface-BHuMoQN-.js +1 -0
- package/web/assets/{book-open-DBJ3dDpw.js → book-open-CBeNsIpo.js} +1 -1
- package/web/assets/{calendarNavStore-DGvUlU5N.js → calendarNavStore-Duyhbmm_.js} +1 -1
- package/web/assets/{canvasPrefs-DwL_OAAo.js → canvasPrefs-CxfyDTMT.js} +1 -1
- package/web/assets/{chatBoxSurface-Lq-2qfd3.js → chatBoxSurface-OBzO1Z5E.js} +1 -1
- package/web/assets/{circle-question-mark-HPZpZQxd.js → circle-question-mark-M8QUJJYk.js} +1 -1
- package/web/assets/{circle-x-BZfe7d6S.js → circle-x-Szwop5L_.js} +1 -1
- package/web/assets/{client-DxGbwZLy.js → client-CPUljePZ.js} +1 -1
- package/web/assets/{code-xml-joKQ-qGS.js → code-xml-n9mgGgkv.js} +1 -1
- package/web/assets/{codeStudioStore-C7rGKlOC.js → codeStudioStore-DXMQwRzG.js} +1 -1
- package/web/assets/codingNavigation-CCjs1kon.js +53 -0
- package/web/assets/codingNavigation-yp19w6uu.css +1 -0
- package/web/assets/{create-BjBRKATq.js → create-C19zqt5N.js} +2 -2
- package/web/assets/dashboardSurface-BwcH16Qc.js +1 -0
- package/web/assets/{deskCapture-DnGWk1iq.js → deskCapture-B_LKZSPt.js} +1 -1
- package/web/assets/{diff2html-Cd1rVi_Z.js → diff2html-DrCCWvpR.js} +1 -1
- package/web/assets/{docx-preview-CK0k1mUD.js → docx-preview-Bi7wekSM.js} +1 -1
- package/web/assets/{emoji-Cjm3bKiF.js → emoji-DczIG8SO.js} +1 -1
- package/web/assets/{floatingTocSurface-Dd1pT5j5.js → floatingTocSurface-rc1ZC7-I.js} +1 -1
- package/web/assets/foldActions-BGocXE-o.js +1 -0
- package/web/assets/{folder-CvZyHIgb.js → folder-CoOsfQ64.js} +1 -1
- package/web/assets/{folder-plus-BRScGQ9m.js → folder-plus-d5MwIMlf.js} +1 -1
- package/web/assets/{gestures-CZQVefU0.js → gestures-CXFaEydn.js} +1 -1
- package/web/assets/{hand-D3QspKYq.js → hand-fuehbnkI.js} +1 -1
- package/web/assets/{hard-drive-BQsHSala.js → hard-drive-Bh1DmZg0.js} +1 -1
- package/web/assets/i18n-DjziAw8r.css +1 -0
- package/web/assets/{i18n.generated-BZRHO2Nc.js → i18n.generated-BiQFRL2U.js} +1 -1
- package/web/assets/{imageStudio-Cy3_437s.js → imageStudio-Dgl1wZNB.js} +2 -2
- package/web/assets/{index-0AYHATDX.js → index-2tD0kijW.js} +1 -1
- package/web/assets/{index-DJLWTPtq.js → index-38xsQSS9.js} +1 -1
- package/web/assets/{index-B5GxvbNm.js → index-7kdR1oL8.js} +1 -1
- package/web/assets/index-B5UW6SaE.js +297 -0
- package/web/assets/{index-D6mpAJ9S.js → index-B8Co6KG3.js} +1 -1
- package/web/assets/{index-C9yo04Ck.js → index-BCG8Wnc4.js} +1 -1
- package/web/assets/{index-Bpc3R3DS.js → index-BPqoEOV_.js} +1 -1
- package/web/assets/{index-BaRySZ-M.js → index-BqGpbntz.js} +1 -1
- package/web/assets/{index-Dj-PygjB.js → index-CPLtf9Vc.js} +1 -1
- package/web/assets/{index-8ag1K7AZ.js → index-Ce1sNSS8.js} +1 -1
- package/web/assets/{index-BgDZGDqt.js → index-Ch0FIsJX.js} +1 -1
- package/web/assets/{index-CcOag8eb.js → index-CnDAYLti.js} +1 -1
- package/web/assets/{index-Dkd-nl1u.js → index-D4CSH-v1.js} +1 -1
- package/web/assets/{index-BnWj6ggb.js → index-Dc8iMctf.js} +1 -1
- package/web/assets/{index-D0FLFLfh.js → index-DcRyQ3eU.js} +1 -1
- package/web/assets/{index-DElrDw66.js → index-Df9jregv.js} +1 -1
- package/web/assets/{index-4E9nrhwf.js → index-Dff-DL1v.js} +1 -1
- package/web/assets/{index-BdZaheMZ.js → index-DvOrTnw2.js} +1 -1
- package/web/assets/{index-BPhwi4-v.js → index-Dx9aIoyo.js} +1 -1
- package/web/assets/{index-BcVGjCAJ.js → index-Dy07SBfH.js} +1 -1
- package/web/assets/{index-GjLSlygt.js → index-QjVOA7QM.js} +1 -1
- package/web/assets/{index-BgtO11q8.js → index-YRWOePBS.js} +1 -1
- package/web/assets/{index-9BmmlTjY.js → index-e-MxdHFO.js} +1 -1
- package/web/assets/{index-DNE_PBJt.js → index-fViJsYjM.js} +1 -1
- package/web/assets/{index-1FhRiJ_X.js → index-lfow5R3O.js} +1 -1
- package/web/assets/{invitePage-B4gMvEKi.js → invitePage-Dgl3-c_m.js} +1 -1
- package/web/assets/{ipc-CPhL3bPp.js → ipc-CNlIRMtU.js} +1 -1
- package/web/assets/{jszip.min-DAJT9RUA.js → jszip.min-tyV0GaJg.js} +1 -1
- package/web/assets/{layout-grid-DfUfnvDS.js → layout-grid-DFmwM9NU.js} +1 -1
- package/web/assets/linkFollow-iP2zfbA3.js +8 -0
- package/web/assets/{list-tree-DaGpnIYu.js → list-tree-i07HsP3D.js} +1 -1
- package/web/assets/{listFold-Q_8mh5ZG.js → listFold-Aea6I0Sa.js} +1 -1
- package/web/assets/{lock-DQ_yL4nF.js → lock-TSDKuCod.js} +1 -1
- package/web/assets/{log-out-DFwTeh2X.js → log-out-DK84lW5n.js} +1 -1
- package/web/assets/{main-NgUPPqDn.css → main-BiS_5wrB.css} +1 -1
- package/web/assets/main-D7CEGndC.js +20 -0
- package/web/assets/markdownEditorSurface-DISu_twy.js +3 -0
- package/web/assets/{message-square-plus-CEHkduIL.js → message-square-plus-3wFslIMY.js} +1 -1
- package/web/assets/{messages-CBtmbpur.js → messages-DEAGRsC3.js} +1 -1
- package/web/assets/minus-BBdfT_sc.js +1 -0
- package/web/assets/mobileEntry-5UaAITwY.js +13 -0
- package/web/assets/{nativeDownload-CziEyW_p.js → nativeDownload-B3JGkABw.js} +1 -1
- package/web/assets/pageChrome-BDHHmRnt.css +1 -0
- package/web/assets/{pageChrome-DFz_AAzZ.js → pageChrome-DFi9zs6F.js} +1 -1
- package/web/assets/{pageTree-yVO1_fSy.js → pageTree-DZ7Eiro-.js} +4 -4
- package/web/assets/{pen-tool-uxsFELYC.js → pen-tool-ChGmX6g_.js} +1 -1
- package/web/assets/{pencil-BSbra1Ra.js → pencil-CJsJD7M_.js} +1 -1
- package/web/assets/phoneList-DrxIwJxQ.js +9 -0
- package/web/assets/phoneList-DvpzD3zT.css +1 -0
- package/web/assets/pluginChat-0QI9a8Q1.js +2 -0
- package/web/assets/{redo-2-BK5LMNa5.js → redo-2-CI57sDFr.js} +1 -1
- package/web/assets/{rotate-ccw-HedfU4na.js → rotate-ccw-xgT_0UN9.js} +1 -1
- package/web/assets/{sharePage-CpzDpuU1.js → sharePage-C2Yqx0NQ.js} +2 -2
- package/web/assets/{shareViewer-BwzH2bIs.js → shareViewer-DKPWhTJv.js} +2 -2
- package/web/assets/{star-CgYon3z4.js → star-C9KTji9N.js} +1 -1
- package/web/assets/tableSurface-cYs6dX6B.js +1 -0
- package/web/assets/{terminal-krsPf1mc.js → terminal-DPZazOQ2.js} +1 -1
- package/web/assets/{terminalView-4e2_u5_I.js → terminalView-CsJmxE_m.js} +1 -1
- package/web/assets/{theme-C6D3tMGV.css → theme-Dgqst5S9.css} +1 -1
- package/web/assets/{type-GJYLEhY-.js → type-C5J875vb.js} +1 -1
- package/web/assets/{undo-2-DCTs4Ro4.js → undo-2-BOUt5qks.js} +1 -1
- package/web/assets/{unitAccount-D3xjX3cu.js → unitAccount-BIAIxKNp.js} +1 -1
- package/web/assets/unitBridge-b2C6zb3a.js +1 -0
- package/web/assets/{unitCloudTransport-B44L3x6M.js → unitCloudTransport-NGtDDKWo.js} +1 -1
- package/web/assets/{unitOwnerAccess-CRUHWGpf.js → unitOwnerAccess-CwH9ApZT.js} +1 -1
- package/web/assets/{unitShim-_VzxvdEG.js → unitShim-CY8EVkKD.js} +3 -3
- package/web/assets/{upload-MVVRQtkj.js → upload-CrbEAW8C.js} +1 -1
- package/web/assets/userSpaces-B_Njvel_.js +1 -0
- package/web/assets/viewportLock-Bi3orrUs.css +1 -0
- package/web/assets/viewportLock-DZ927PNz.js +629 -0
- package/web/assets/{workflow-DzeW9OXR.js → workflow-DY2Cnaei.js} +1 -1
- package/web/assets/{zoom-in-CovPsw4g.js → zoom-in-BcuPvIYd.js} +1 -1
- package/web/index.html +28 -11
- package/web/assets/CalendarConfigView-BJtG6cqN.js +0 -1
- package/web/assets/CalendarView-C-FX1RED.js +0 -1
- package/web/assets/DashboardGridView-Ck3LKkOb.css +0 -1
- package/web/assets/DashboardGridView-MlO1dpuo.js +0 -17
- package/web/assets/ExcalidrawCanvas-D9vkBh_5.js +0 -1
- package/web/assets/HomepageView-BNabJQfP.css +0 -1
- package/web/assets/HomepageView-Trqmd3RV.js +0 -1
- package/web/assets/ImageStudioPanels-BfCVTnKC.js +0 -3
- package/web/assets/InlineFiles-BHwivGbQ.js +0 -1
- package/web/assets/MarkdownBlock-D8LgHFYY.js +0 -58
- package/web/assets/ModelPill-DrW2cG0l.js +0 -2
- package/web/assets/MuseLibraryView-CW78Uivf.js +0 -2
- package/web/assets/RunLocationPicker-BE5mxnab.css +0 -1
- package/web/assets/RunLocationPicker-CyVa0RJa.js +0 -38
- package/web/assets/SidebarRow-CsWEqPKX.css +0 -1
- package/web/assets/SidebarRow-D77yrSLf.js +0 -9
- package/web/assets/TodoListView-C3ZkMIIf.js +0 -1
- package/web/assets/UnifiedPage-C75y-MKT.js +0 -68
- package/web/assets/appStore-BC_CQv-L.css +0 -1
- package/web/assets/codingNavigation-CZB4v1ZW.css +0 -1
- package/web/assets/codingNavigation-CjeWG4xm.js +0 -47
- package/web/assets/dashboardSurface-Cojgf_-U.js +0 -1
- package/web/assets/foldActions-Dm-uAt3L.js +0 -1
- package/web/assets/i18n-ecQQxiMQ.css +0 -1
- package/web/assets/index-Bh_nLVTc.js +0 -298
- package/web/assets/linkFollow-C6PHGUxk.js +0 -8
- package/web/assets/main-CwqZ_ymb.js +0 -19
- package/web/assets/markdownEditorSurface-e_oMhqx-.js +0 -3
- package/web/assets/mdMarkStore-DjN4bf1T.js +0 -2
- package/web/assets/mdMarks-cmL6vzR-.js +0 -1
- package/web/assets/minus-BUT48dAC.js +0 -1
- package/web/assets/mobileEntry-qR7BAROr.js +0 -13
- package/web/assets/pageChrome-CovzZPdb.css +0 -1
- package/web/assets/pluginChat-BMFnf_j2.js +0 -2
- package/web/assets/tableSurface-CmDwnKnd.js +0 -1
- package/web/assets/unitBridge-D5JcIkAP.js +0 -1
- package/web/assets/userSpaces-CI4eqEgh.js +0 -1
- package/web/assets/viewportLock-BH26xHQO.js +0 -611
- package/web/assets/viewportLock-IP1zaVkz.css +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CodeView-Df3AiSIi.js","./index-Bh_nLVTc.js","./appStore-B1ynyt42.js","./nativeDownload-CziEyW_p.js","./ipc-CPhL3bPp.js","./client-DxGbwZLy.js","./appStore-BC_CQv-L.css","./create-BjBRKATq.js","./create-BgE3edmZ.css","./docx-preview-CK0k1mUD.js","./jszip.min-DAJT9RUA.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{R as Za,j as e,d as c,t as Ne,r as te,u as V,_ as mt,x as eo,E as xs,F as to,G as no,H as so,I as ws,J as ao,K as oo}from"./index-Bh_nLVTc.js";import{N as ys,a2 as $e,a3 as io,a4 as ro,a5 as lo,a6 as js,a7 as co,a8 as uo,a9 as ho,aa as po,ab as mo,c as fo,$ as go,a0 as vo,a1 as xo,C as wo}from"./RunLocationPicker-CyVa0RJa.js";import{F as oe,aa as en,p as Le,b0 as bs,u as P,ch as de,bA as ks,cn as yo,hL as jo,kq as bo,kr as Dn,ks as ko,kt as So,ku as No,c_ as zo,b as ot,jw as Co,i_ as Eo,kv as Rt,kw as Ss,kx as Nt,ky as Mt,kz as At,aN as Ie,cA as qe,kA as Ns,kB as To,cr as Pt,aO as nt,iv as zs,fD as Cs,aE as Ye,ip as Ro,iq as Mo,aM as Oe,ga as Ao,U as Po,bI as ft,gP as Io,s as ze,kC as Do,gO as _o,gN as Fo,ho as $o,kD as Lo,hG as qo,hZ as Es,k1 as Oo,kE as Bo,bl as Ho,gu as Wo,gv as Vo,iy as Uo,c6 as Ts,Z as gn,kF as Ko,ar as it,c4 as we,hy as vn,kG as It,cN as Rs,cc as Ms,aJ as As,K as Ke,bn as Go,kH as Yo,kI as Jo,kJ as Qo,ax as tn,kK as Xo,kL as _n,bT as ht,cJ as zt,ic as Fn,a2 as Zo,kM as ei,kN as ti,kO as ni,co as si,fr as ai,ei as oi,kP as Ps,kQ as ii,aI as ri,c2 as li,kR as ci,a4 as st,ap as di,R as ui,W as hi,kS as pi,kT as Dt,kU as mi,kV as Is,kW as fi,kX as gi,kY as vi,kZ as xi,hv as Wt,k_ as $n,aD as bt,k$ as Ds,l0 as Ln,l1 as wi,cU as xn,g4 as wn,j as yi,l2 as ji,f6 as bi,l3 as qn,l4 as _s,hJ as ki,l5 as Fs,fk as $s,h as Si,l6 as Ni,l7 as zi,ay as Ci,aB as Ei,hT as Ae,gh as Ls,l8 as Ti,hS as nn,aS as qs,G as Os,l9 as Ri,la as Mi,cg as Ai,lb as Pi,lc as Ii,ld as Di,bo as _i,i1 as sn,i0 as Fi,i4 as Vt,cK as $i,le as Li,i2 as qi,lf as Oi,lg as Bi,ej as Hi,lh as an,li as Bs,lj as Hs,lk as Ws,ll as Wi,lm as Vi,e5 as On,eo as Ui,ln as Ki,lo as Gi,lp as Yi,a5 as Ji,hN as Qi,kc as Xi,hk as Zi,kd as er,ke as tr,hO as nr,hU as sr,hK as ar,lq as or,lr as ir,ls as rr,bB as lr,br as cr,g as dr,bH as ur,hr as Bn,lt as hr,lu as pr,ag as mr,lv as Hn,lw as fr,lx as gr,ly as vr}from"./appStore-B1ynyt42.js";import{D as yn}from"./create-BjBRKATq.js";import{p as xr}from"./pdf.worker.min-CGb3BKV9.js";import{m as wr,d as yr,f as Vs,n as _t,r as jn,t as Us,e as Ks,C as jr,A as br}from"./SidebarRow-D77yrSLf.js";import{C as Ct}from"./code-xml-joKQ-qGS.js";import{Z as Gs,a as Ys}from"./zoom-in-CovPsw4g.js";import{I as kr,t as Sr}from"./InlineFiles-BHwivGbQ.js";import{c as Nr}from"./client-DxGbwZLy.js";import{c as Js,n as ue}from"./nativeDownload-CziEyW_p.js";import{B as zr}from"./book-open-DBJ3dDpw.js";import{U as bn}from"./undo-2-DCTs4Ro4.js";import{S as Cr,s as Er,a as Wn,F as Tr}from"./SketchCard-CAAr_cqF.js";import{T as Rr}from"./terminal-krsPf1mc.js";import{C as Ft}from"./circle-x-BZfe7d6S.js";import{C as kn}from"./circle-question-mark-HPZpZQxd.js";import{P as at}from"./pencil-BSbra1Ra.js";import{n as xt,u as on,b as Mr}from"./codeStudioStore-C7rGKlOC.js";import{M as Qs}from"./message-square-plus-CEHkduIL.js";import{R as $t}from"./rotate-ccw-HedfU4na.js";import{F as Ar}from"./FloatingToc-tART_jC4.js";import{P as Pr}from"./MarkdownBlock-D8LgHFYY.js";import{C as Xs,j as pt}from"./RightPanel-BVZeVO3c.js";import"./pageChrome-DFz_AAzZ.js";import{F as Lt}from"./folder-CvZyHIgb.js";import{F as Ut}from"./folder-plus-BRScGQ9m.js";import{b as Kt}from"./mdMarkStore-DjN4bf1T.js";import{A as Ir}from"./arrow-up-right-R10mR2I6.js";import{e as Dr}from"./ipc-CPhL3bPp.js";const _r=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],Fr=oe("arrow-left-right",_r);const $r=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.35 2.69A10 10 0 0 1 21.3 15.65",key:"1pfsoa"}],["path",{d:"M19.08 19.08A10 10 0 1 1 4.92 4.92",key:"1ablyi"}]],Lr=oe("circle-off",$r);const qr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],rn=oe("circle-pause",qr);const Or=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Br=oe("circle-stop",Or);const Hr=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Wr=oe("file-code-corner",Hr);const Vr=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],De=oe("file-exclamation-point",Vr);const Ur=[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],Gt=oe("file-plus-corner",Ur);const Kr=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Vn=oe("folder-input",Kr);const Gr=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],ln=oe("folder-search",Gr);const Yr=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Jr=oe("git-branch",Yr);const Qr=[["path",{d:"M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21",key:"9csbqa"}],["path",{d:"m14 19.5 3-3 3 3",key:"9vmjn0"}],["path",{d:"M17 22v-5.5",key:"1aa6fl"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Xr=oe("image-up",Qr);const Zr=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Zs=oe("maximize",Zr);const el=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],tl=oe("message-circle-question-mark",el);const nl=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],ea=oe("minimize-2",nl);const sl=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],al=oe("power-off",sl);const ol=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],il=oe("quote",ol);const rl=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],ll=oe("square-check-big",rl);const cl=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],ta=oe("text-align-justify",cl);const dl=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],na=oe("text-wrap",dl);const ul=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],hl=oe("timer",ul);const pl=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],sa=oe("triangle-alert",pl);const ml=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],fl=oe("volume-2",ml);const gl=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],cn=oe("wifi-off",gl);class vl extends Za.Component{state={error:null};static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,s){console.error("[tangu] render crash:",n,s?.componentStack)}render(){const{error:n}=this.state;if(!n)return this.props.children;const s=(document.documentElement.lang||"").startsWith("zh"),a=`${n.message}
|
|
3
|
-
|
|
4
|
-
${n.stack||""}`.trim();return e.jsxs("div",{"data-error-boundary":!0,style:{padding:24,maxWidth:720,margin:"0 auto",overflow:"auto",height:"100%",boxSizing:"border-box"},children:[e.jsx("h3",{style:{margin:"8px 0"},children:s?"界面渲染出错":"Something broke while rendering"}),e.jsx("p",{style:{opacity:.8,fontSize:"var(--ui-font-body, 13px)",margin:"4px 0 12px"},children:s?"这一部分崩溃了。可重试、或切换/新建会话避开它;请把下面的错误发给开发者。":"This view crashed. Retry, or switch/start a new chat to avoid it; send the error below to the developer."}),e.jsx("pre",{style:{whiteSpace:"pre-wrap",fontSize:12,background:"var(--danger-light)",color:"var(--danger)",padding:12,borderRadius:8,maxHeight:280,overflow:"auto"},children:a}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[e.jsx("button",{style:{padding:"6px 12px"},onClick:()=>this.setState({error:null}),children:s?"重试":"Retry"}),e.jsx("button",{style:{padding:"6px 12px"},onClick:()=>{try{navigator.clipboard.writeText(a)}catch{}},children:s?"复制错误":"Copy error"}),e.jsx("button",{style:{padding:"6px 12px"},onClick:()=>location.reload(),children:s?"重新加载":"Reload"})]})]})}}function Sn(t,n){en("agents"),Le.getState().openView("agent-profile",{reuseKey:"primary",agentSlug:t,creating:!1,...n?{section:n,sectionAt:Date.now()}:{}},"main")}const Nn="forsion_chat_wait_details",dn="forsion:chat-wait-details";function xl(){try{return localStorage.getItem(Nn)==="1"}catch{return!1}}function zu(t){try{localStorage.setItem(Nn,t?"1":"0")}catch{}try{window.dispatchEvent(new Event(dn))}catch{}}function wl(t){if(typeof window>"u")return()=>{};const n=s=>{s.key===Nn&&t()};return window.addEventListener(dn,t),window.addEventListener("storage",n),()=>{window.removeEventListener(dn,t),window.removeEventListener("storage",n)}}function yl(){return c.useSyncExternalStore(wl,xl,()=>!1)}const zn="forsion_chat_avatars";function jl(){try{return localStorage.getItem(zn)!=="0"}catch{return!0}}function un(){jl()?delete document.documentElement.dataset.chatAvatars:document.documentElement.dataset.chatAvatars="off"}function Cu(t){try{localStorage.setItem(zn,t?"1":"0")}catch{}un()}typeof document<"u"&&(un(),window.addEventListener("storage",t=>{t.key===zn&&un()}));te({"btw.title":{zh:"顺便问",en:"By the way"},"btw.windowTitle":{zh:"顺便问 · {title}",en:"By the way · {title}"},"btw.context":{zh:"当前对话",en:"Conversation"},"btw.hint":{zh:"带着本会话上下文提问,不会加入对话,也不打断正在跑的任务",en:"Uses this conversation as context. Not added to it, and never interrupts a running task."},"btw.empty":{zh:"问点与当前对话有关的事:概念、代码、刚才那步为什么这么做……",en:"Ask about anything in this conversation: a concept, some code, why a step was taken…"},"btw.placeholder":{zh:"顺便问点什么…",en:"Ask a side question…"},"btw.defaultQuestion":{zh:"解释一下这段",en:"Explain this"},"btw.send":{zh:"发送",en:"Send"},"btw.stop":{zh:"停止",en:"Stop"},"btw.clear":{zh:"清空旁聊",en:"Clear side chat"},"btw.copy":{zh:"复制",en:"Copy"},"btw.copied":{zh:"已复制",en:"Copied"},"btw.quoteToChat":{zh:"引用到对话",en:"Quote in chat"},"btw.quoted":{zh:"已引用到输入框",en:"Quoted in the chat box"},"btw.removeQuote":{zh:"移除引用",en:"Remove quote"},"btw.thinking":{zh:"思考中…",en:"Thinking…"},"btw.stopped":{zh:"已停止",en:"Stopped"},"btw.noTools":{zh:"旁聊不能用工具,上面提到的操作都没有执行。",en:"Side chats have no tools. Nothing mentioned above was run."},"btw.errCut":{zh:"连接中断,回答不完整",en:"The connection dropped before the answer finished"},"btw.errUnsupported":{zh:"当前引擎还不支持旁聊,请更新 Forsion",en:"This engine does not support side questions yet. Update Forsion."},"btw.close":{zh:"关闭",en:"Close"},"btw.selectionAction":{zh:"顺便问",en:"Ask aside"},"btw.cmd":{zh:"顺便问(旁聊)",en:"Ask a side question"}});const He=new Map,Un=new Set;let bl=0;function Eu(t){return Un.has(t.nonce)?!1:(Un.add(t.nonce),!0)}function Tu(t,n){return!!t&&(!t.scope||t.scope===n)}function Ru(t){const n=o=>typeof t?.[o]=="string"&&t[o]?t[o]:void 0,s=n("sessionId"),a=n("nonce");return s&&a?{sessionId:s,nonce:a,scope:n("scope"),title:n("title"),quote:n("quote"),question:n("question"),modelId:n("modelId")}:null}const kl=Js((t,n)=>({threads:{},webOpen:null,ask:async(s,a,o,i)=>{if(!a.trim()||He.has(s))return;const r=n().threads[s]||[],u=`btw-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`,p=g=>t(w=>({threads:{...w.threads,[s]:(w.threads[s]||[]).map(x=>x.id===u?{...x,...g(x)}:x)}}));t(g=>({threads:{...g.threads,[s]:[...r,{id:u,question:a,quote:o,answer:"",status:"streaming"}]}}));const f=new AbortController;He.set(s,f);const m=r.filter(g=>g.status==="done"&&g.answer).slice(-20).map(g=>({question:g.question,quote:g.quote,answer:g.answer}));try{await Sl(s,{question:a,quote:o,thread:m,model_id:i||void 0},g=>{g.type==="delta"?p(w=>({answer:w.answer+String(g.text??"")})):g.type==="done"?p(w=>({answer:String(g.content||w.answer),status:"done",toolCallText:!!g.toolCallText})):g.type==="error"&&p(()=>({status:"error",error:Kn(String(g.error||""))}))},f.signal),p(g=>g.status==="streaming"?{status:"error",error:Ne("btw.errCut")}:{})}catch(g){p(w=>w.status!=="streaming"?{}:f.signal.aborted?{status:"stopped"}:{status:"error",error:Kn(String(g?.message||g))})}finally{He.get(s)===f&&He.delete(s)}},stop:s=>He.get(s)?.abort(),clear:s=>{He.get(s)?.abort(),He.delete(s),t(a=>({threads:{...a.threads,[s]:[]}}))},closeWeb:()=>t({webOpen:null})})),Kn=t=>/token_quota_exceeded/i.test(t)?Ne("chat.err.quota"):t;async function Sl(t,n,s,a){const o=de(t);let i;try{i=await ks(o,`/agent/sessions/${encodeURIComponent(t)}/aside`,{method:"POST",signal:a,body:JSON.stringify({...n,app_id:jo,client:yo()})})}catch(f){if(o.via==="unit"&&!a.aborted){const m=bo(f);throw new Error(Dn(o,m,f?.code)||String(f?.message||f))}throw f}if(!i.ok||!i.body){const f=await i.text().catch(()=>"");let m="",g,w=null;try{w=JSON.parse(f),m=String(w?.detail||"");const x=w?.code;g=typeof x=="string"?x:void 0}catch{}if(o.via==="unit"){const x=ko(i.status,{code:g});So(o.key,x,No(w));const z=Dn(o,x,g,w);if(z&&x!=="fatal")throw new Error(z)}throw new Error(m||(i.status===404?Ne("btw.errUnsupported"):`HTTP ${i.status}`))}const r=i.body.getReader(),u=new TextDecoder;let p="";for(;;){const{done:f,value:m}=await r.read();if(f)break;p+=u.decode(m,{stream:!0});const g=p.split(`
|
|
5
|
-
`);p=g.pop()||"";for(const w of g)if(w.startsWith("data:"))try{s(JSON.parse(w.slice(5)))}catch{}}}function Gn(t){const n=bs()==="main"?P.getState().activeId:null,s={...t,title:t.title||void 0,scope:n,nonce:`${Date.now().toString(36)}-${++bl}`},a=window.tangu;if(a?.openFloatingPanel){a.openFloatingPanel({id:`btw:${t.sessionId}`,title:Ne("btw.windowTitle",{title:t.title||Ne("btw.title")}),builtin:"btw",params:{...s},...n?{sessionId:n}:{}});return}kl.setState({webOpen:s})}function Mu(t){const n=t.trim().slice(0,2e4);if(!n)return;if(bs()!=="main"&&window.tangu?.requestMainAction){window.tangu.requestMainAction("chat-quote",n);return}const s=Le.getState(),a=s.rightVisible&&s.rightTabs.some(o=>o.type==="chat-panel"&&o.active);P.getState().setPendingChatQuote(a?"chat-panel":"chat",n),a||s.openView("chat",{followActive:!0,reuseKey:"primary"},"main")}const aa="forsion.noteRemind.fired",Nl=168*36e5,zl=24*36e5;function Cl(){try{const t=JSON.parse(localStorage.getItem(aa)||"{}"),n=Date.now();return Object.fromEntries(Object.entries(t).filter(([,s])=>n-s<Nl))}catch{return{}}}const oa=(t,n)=>`${t}|${n.path}|${n.remind}|${n.text}`;function El(t,n,s,a){return t.filter(o=>{if(!o.remind)return!1;const i=Eo(o.remind.split("/")[0]).getTime();return i<=n&&n-i<zl&&!s[oa(a,o)]})}const Tl=new Set(["harness_candidates","harness_adopted","harness_confirm","project_memory_candidates","project_memory_compacted"]);function Rl(t,n){const s=n?t.filter(o=>Tl.has(o.action)&&!n.has(o.id)):[],a=new Set(n??[]);for(const o of t)a.add(o.id);return{fresh:s,seen:a}}const Ee=(t,n)=>P.getState().tr(t,n);let Yn=!1;function Au(){if(Yn)return;Yn=!0;const t={};window.amadeusSync?.onStatus?.(r=>{const u=r,p=u.binding?`entry:${u.binding}`:`mirror:${u.side??"own"}`,f=t[p];t[p]=u.state,!(!u.enabled||f===u.state)&&(u.state==="error"||u.state==="auth-required"?ue({event:"sync.error",level:"error",text:Ee("ntf.syncError",{e:u.error?zo(u.error):u.state}),dedupeKey:`sync.error:${p}`}):f==="syncing"&&u.state==="idle"&&ue({event:"sync.doneOnline",level:"success",text:Ee("ntf.syncDone"),dedupeKey:"sync.done"}))});let n=!1;window.remoteSync?.onStatus?.(r=>{if(n&&!r.running&&r.lastReport){const u=r.lastReport;if(!u.ok||u.errors?.length)ue({event:"sync.error",level:"error",text:Ee("ntf.remoteSyncFail",{e:u.errors?.[0]||""}),dedupeKey:"remotesync.error"});else{u.conflicts>0&&ue({event:"sync.error",level:"warning",text:Ee("ntf.remoteSyncConflicts",{n:u.conflicts}),dedupeKey:"remotesync.conflict"}),u.pendingDeletions>0&&ue({event:"sync.error",level:"warning",text:Ee("ntf.remoteSyncPendingDel",{n:u.pendingDeletions}),dedupeKey:"remotesync.pendingDel",action:{label:Ee("ntf.actionReview"),run:()=>P.getState().openSettings("sync")}});const p=u.pushed+u.pulled+u.deletedLocal+u.deletedRemote;p>0&&ue({event:"sync.done",level:"success",text:Ee("ntf.remoteSyncDone",{n:p}),dedupeKey:"remotesync.done"})}}n=r.running});let s=P.getState().runningBySession;P.subscribe(r=>{if(r.runningBySession===s)return;const u=s;s=r.runningBySession;for(const p of Object.keys(u)){if(r.runningBySession[p]||p===r.activeId)continue;const m=[...r.messagesBySession[p]||[]].reverse().find(x=>x.role==="assistant");if(m?.status!=="done"&&m?.status!=="error")continue;const g=m.status==="error",w=r.sessions.find(x=>x.id===p)||r.archivedSessions.find(x=>x.id===p);ue({event:"agent.done",level:g?"error":"success",text:Ee(g?"ntf.agentFail":"ntf.agentDone",{name:w?.title||"Agent"})})}});let a=Cl();const o=()=>{const r=Date.now(),u=ot.getState().vaultRoot??"";for(const p of El(Kt.getState().marks,r,a,u)){a={...a,[oa(u,p)]:r};try{localStorage.setItem(aa,JSON.stringify(a))}catch{}ue({event:"note.reminder",level:"info",sticky:!0,title:Ee("ntf.noteReminder",{src:p.title}),text:p.text,action:{label:Ee("ntf.view"),run:()=>{Co(p.path,p.heading)}}})}},i=async()=>{await Kt.getState().load(),o()};Kt.subscribe(o),i(),setInterval(()=>{i()},6e4)}const Ml=Ao(()=>mt(()=>import("./CodeView-Df3AiSIi.js").then(t=>t.K),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),ia=({path:t,text:n,title:s,nonce:a})=>{const o=!!(t?window.tangu?.codePreviewServePath:window.tangu?.codePreviewServeHtml),[i,r]=c.useState(null),[u,p]=c.useState(!1);if(c.useEffect(()=>{if(!o)return;let f=!1;return p(!1),r(null),(t?window.tangu.codePreviewServePath(t):window.tangu.codePreviewServeHtml(n)).then(g=>{f||r(g.url)}).catch(()=>{f||p(!0)}),()=>{f=!0}},[t,o,t?"":n]),o&&!u){if(!i)return e.jsx("div",{className:"wsfile-frame"});const f=a?`${i}?n=${a}`:i;return e.jsx(Ro,{className:"wsfile-frame",src:f,partition:Mo,allowpopups:"true",style:{display:"flex",background:"#fff"}},`${i}#${a}`)}return e.jsx("iframe",{className:"wsfile-frame",srcDoc:n,sandbox:"allow-scripts allow-popups allow-forms allow-modals",title:s},a)},ra=new Set(["html","code","markdown","csv","json","text","diff"]),la=new Set(["image","video","audio"]),et=500,Al={type:"spring",stiffness:300,damping:26,mass:.9},hn=t=>Math.min(8,Math.max(.1,t)),Ge=()=>e.jsx("div",{className:"wsfile-center",children:e.jsx(Oe,{size:20,className:"spin"})});function Pl(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'|'/g,"'").replace(/&/g,"&")}const xe=t=>e.jsx("div",{className:"wsfile-cmwrap",children:e.jsx(c.Suspense,{fallback:e.jsx(Ge,{}),children:e.jsx(Ml,{...t})})}),qt=({t,download:n})=>e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:t("preview.loadFailed")}),n&&e.jsxs("button",{className:"btn ghost sm",onClick:n,children:[e.jsx(Ie,{size:13})," ",t("preview.download")]})]}),ca=({src:t,alt:n,view:s,setView:a})=>{const o=c.useRef(null);return e.jsx("div",{className:"wsfile-imgwrap",onWheel:i=>{const r=i.currentTarget.getBoundingClientRect(),u=i.clientX-r.left-r.width/2,p=i.clientY-r.top-r.height/2,f=i.deltaY<0?1.12:1/1.12;a(m=>{const g=hn(m.s*f),w=g/m.s;return{s:g,x:u-(u-m.x)*w,y:p-(p-m.y)*w}})},onPointerDown:i=>{o.current={x:i.clientX,y:i.clientY,sx:s.x,sy:s.y},i.currentTarget.setPointerCapture(i.pointerId)},onPointerMove:i=>{const r=o.current;r&&a(u=>({...u,x:r.sx+(i.clientX-r.x),y:r.sy+(i.clientY-r.y)}))},onPointerUp:()=>{o.current=null},onDoubleClick:()=>a({s:1,x:0,y:0}),children:e.jsx("img",{src:t,alt:n,draggable:!1,style:{transform:`translate(${s.x}px, ${s.y}px) scale(${s.s})`}})})},da=({bytes:t,download:n})=>{const{t:s}=V(),a=c.useRef(null),[o,i]=c.useState(!1),[r,u]=c.useState(!0);return c.useEffect(()=>{let p=!1;return i(!1),u(!0),(async()=>{try{const f=await mt(()=>import("./docx-preview-CK0k1mUD.js"),__vite__mapDeps([9,10,1]),import.meta.url);if(p||!a.current)return;a.current.innerHTML="",await f.renderAsync(t,a.current,void 0,{className:"docx",inWrapper:!0,breakPages:!0,ignoreLastRenderedPageBreak:!0}),p||u(!1)}catch{p||(i(!0),u(!1))}})(),()=>{p=!0}},[t]),o?e.jsx(qt,{t:s,download:n}):e.jsxs("div",{className:"wsfile-doc wsfile-docx",children:[e.jsx("div",{ref:a}),r&&e.jsx(Ge,{})]})},Il=100,ua=({bytes:t,download:n})=>{const{t:s}=V(),a=c.useRef(null),[o,i]=c.useState(!1),[r,u]=c.useState(!0),[p,f]=c.useState(null);return c.useEffect(()=>{let m=!1,g=null;return i(!1),u(!0),f(null),(async()=>{try{const w=await mt(()=>import("./pdf-C2_sJa3b.js"),[],import.meta.url);if(w.GlobalWorkerOptions.workerSrc=xr,g=await w.getDocument({data:t.slice()}).promise,m||!a.current)return;a.current.innerHTML="";const x=Math.min(window.devicePixelRatio||1,2),z=Math.min(g.numPages,Il);for(let k=1;k<=z&&!m;k++){const y=await g.getPage(k),N=y.getViewport({scale:1.3*x}),d=document.createElement("canvas");d.className="wsfile-pdf-page",d.width=N.width,d.height=N.height,d.style.width=`${N.width/x}px`,a.current?.appendChild(d),await y.render({canvasContext:d.getContext("2d"),viewport:N}).promise}m||(u(!1),g.numPages>z&&f({shown:z,total:g.numPages}))}catch{m||(i(!0),u(!1))}})(),()=>{if(m=!0,g)try{g.destroy()}catch{}}},[t]),o?e.jsx(qt,{t:s,download:n}):e.jsxs("div",{className:"wsfile-doc wsfile-pdf",children:[e.jsx("div",{ref:a}),r&&e.jsx(Ge,{}),p&&e.jsx("div",{className:"panel-note",children:s("preview.pdfPages",{n:String(p.shown),total:String(p.total)})})]})};async function ha(t,n){if(n==="xlsx"){const p=await mt(()=>import("./xlsx-CNerDvZX.js"),[],import.meta.url),f=p.read?p:p.default,m=f.read(t,{type:"array"});return{kind:"xlsx",sheets:m.SheetNames.map(g=>({name:g,html:f.utils.sheet_to_html(m.Sheets[g])}))}}const s=await mt(()=>import("./jszip.min-DAJT9RUA.js").then(p=>p.j),__vite__mapDeps([10,1]),import.meta.url),o=await(s.loadAsync?s:s.default??s).loadAsync(t),i=p=>parseInt(p.match(/(\d+)\.xml$/)?.[1]||"0",10),r=Object.keys(o.files).filter(p=>/^ppt\/slides\/slide\d+\.xml$/.test(p)).sort((p,f)=>i(p)-i(f)),u=[];for(const p of r){const f=await o.files[p].async("text");u.push([...f.matchAll(/<a:t>([^<]*)<\/a:t>/g)].map(m=>Pl(m[1])).join(`
|
|
6
|
-
`))}return{kind:"pptx",slides:u}}const Dl=({target:t,onClose:n})=>{const{t:s}=V(),[a,o]=c.useState(!0),[i,r]=c.useState(null),[u,p]=c.useState(null),[f,m]=c.useState(null),[g,w]=c.useState(null),[x,z]=c.useState(!1),[k,y]=c.useState("preview"),[N,d]=c.useState(0),[_,b]=c.useState(!1),[C,j]=c.useState(!0),[h,S]=c.useState({s:1,x:0,y:0}),B=Rt(u?.mimeType||"",t.name),J=Ss(t.name),L=u?Nt(u.mimeType,t.name):"binary";c.useEffect(()=>{let I=!1,O=null;return o(!0),r(null),p(null),m(null),w(null),y("preview"),S({s:1,x:0,y:0}),(async()=>{try{const Y=await t.load();if(I)return;if(!Y){r("not-found"),o(!1);return}if("tooLarge"in Y){m(Y.size),o(!1);return}if(la.has(Nt(Y.mimeType,t.name))){const ee=Mt(t.name)||Y.mimeType||"application/octet-stream";O=URL.createObjectURL(new Blob([Y.bytes],{type:ee})),w(O)}p(Y),o(!1)}catch(Y){I||(r(Y?.message||"error"),o(!1))}})(),()=>{I=!0,O&&URL.revokeObjectURL(O)}},[t]),c.useEffect(()=>{const I=O=>{O.key==="Escape"&&(x?z(!1):n())};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[x,n]);const K=c.useMemo(()=>u&&ra.has(L)?new TextDecoder("utf-8",{fatal:!1}).decode(u.bytes):"",[u,L]),[D,q]=c.useState(null),[E,F]=c.useState(!1),[W,X]=c.useState(0);c.useEffect(()=>{if(!u||L!=="xlsx"&&L!=="pptx"){q(null),F(!1);return}let I=!1;return q(null),F(!1),X(0),ha(u.bytes,L).then(O=>{I||q(O)}).catch(()=>{I||F(!0)}),()=>{I=!0}},[u,L]);const ae=()=>{if(E)return e.jsx(qt,{t:s,download:t.download});if(!D)return e.jsx(Ge,{});if(D.kind==="xlsx"){const I=D.sheets[W]??D.sheets[0];return e.jsxs("div",{className:"wsfile-sheetwrap",children:[D.sheets.length>1&&e.jsx("div",{className:"wsfile-seg wsfile-sheet-tabs",children:D.sheets.map((O,Y)=>e.jsx("button",{className:Y===W?"active":"",onClick:()=>X(Y),children:O.name},Y))}),e.jsx("div",{className:"wsfile-doc wsfile-sheet",dangerouslySetInnerHTML:{__html:I?.html??""}})]})}return e.jsx("div",{className:"wsfile-doc wsfile-pptx",children:D.slides.map((I,O)=>{const Y=I.split(`
|
|
7
|
-
`);return e.jsxs("div",{className:"wsfile-slide",children:[e.jsx("div",{className:"wsfile-slide-no",children:s("preview.slide",{n:String(O+1)})}),Y[0]&&e.jsx("div",{className:"wsfile-slide-title",children:Y[0]}),e.jsx("pre",{children:Y.slice(1).join(`
|
|
8
|
-
`)||(Y[0]?"":"—")})]},O)})})};let Q;if(a)Q=e.jsx(Ge,{});else if(f!==null)Q=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:s("preview.tooLarge",{size:At(f)})}),t.download&&e.jsxs("button",{className:"btn ghost sm",onClick:t.download,children:[e.jsx(Ie,{size:13})," ",s("preview.download")]})]});else if(i||!u)Q=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:s(i==="not-found"?"preview.notFound":"preview.loadFailed")}),t.download&&e.jsxs("button",{className:"btn ghost sm",onClick:t.download,children:[e.jsx(Ie,{size:13})," ",s("preview.download")]})]});else if(L==="image")Q=g?e.jsx(ca,{src:g,alt:t.name,view:h,setView:S}):null;else if(L==="pdf")Q=e.jsx(ua,{bytes:u.bytes,download:t.download});else if(L==="video")Q=e.jsx("div",{className:"wsfile-media",children:g&&e.jsx("video",{src:g,controls:!0})});else if(L==="audio")Q=e.jsx("div",{className:"wsfile-media wsfile-audio",children:g&&e.jsx("audio",{src:g,controls:!0})});else if(L==="markdown")Q=k==="preview"?e.jsx("div",{className:"wsfile-doc msg-content",children:e.jsx(qe,{content:K})}):xe({value:K,fileName:t.name,wrap:_});else if(L==="json"){let I=K;try{I=JSON.stringify(JSON.parse(K),null,2)}catch{}Q=xe({value:I,fileName:"x.json",language:"json",wrap:_})}else if(L==="code")Q=xe({value:K,fileName:t.name,wrap:_});else if(L==="text")Q=xe({value:K,fileName:t.name,wrap:_});else if(L==="diff")Q=e.jsx(yn,{text:K,side:C});else if(L==="csv"){const I=Ns(K,J==="tsv"?" ":","),O=I.slice(0,et),Y=O[0]??[];Q=e.jsxs("div",{className:"wsfile-doc",children:[e.jsxs("table",{className:"wsfile-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:Y.map((ee,ce)=>e.jsx("th",{children:ee},ce))})}),e.jsx("tbody",{children:O.slice(1).map((ee,ce)=>e.jsx("tr",{children:Y.map((G,A)=>e.jsx("td",{children:ee[A]??""},A))},ce))})]}),I.length>et&&e.jsx("div",{className:"panel-note",children:s("preview.csvTruncated",{shown:String(et),total:String(I.length)})})]})}else L==="html"?Q=k==="preview"?e.jsx(ia,{path:t.path,text:K,title:t.name,nonce:N}):xe({value:K,language:"html",wrap:_}):L==="docx"?Q=e.jsx(da,{bytes:u.bytes,download:t.download}):L==="xlsx"||L==="pptx"?Q=ae():Q=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:s("preview.notAvailable")}),t.download&&e.jsxs("button",{className:"btn ghost sm",onClick:t.download,children:[e.jsx(Ie,{size:13})," ",s("preview.download")]})]});const H=!a&&!i&&f===null&&!!u,le=L==="markdown"||L==="html",ne=L==="code"||L==="json"||L==="text"||le&&k==="source";return e.jsx(wr.div,{className:"wsfile-overlay",initial:{opacity:0,y:24,scale:.92},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.94},transition:Al,style:{transformOrigin:"bottom center"},children:e.jsxs("div",{className:`wsfile-panel${x?" expanded":""}${L==="html"&&k==="preview"&&H?" fill":""}`,children:[e.jsxs("div",{className:"wsfile-head",children:[e.jsx(B,{size:14,className:"wsfile-head-icon"}),e.jsxs("div",{className:"wsfile-title",title:t.name,children:[e.jsx("span",{className:"wsfile-name",children:To(t.name)}),J&&e.jsx("span",{className:"wsfile-ext",children:J})]}),H&&le&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:k==="preview"?"active":"",title:s("preview.htmlPreview"),onClick:()=>y("preview"),children:e.jsx(Pt,{size:13})}),e.jsx("button",{className:k==="source"?"active":"",title:s("preview.htmlCode"),onClick:()=>y("source"),children:e.jsx(Ct,{size:13})}),L==="html"&&k==="preview"&&e.jsx("button",{title:s("preview.reload"),onClick:()=>d(I=>I+1),children:e.jsx(nt,{size:12})})]}),H&&L==="diff"&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:C?"active":"",title:s("preview.diffSideBySide"),onClick:()=>j(!0),children:e.jsx(zs,{size:13})}),e.jsx("button",{className:C?"":"active",title:s("preview.diffLineByLine"),onClick:()=>j(!1),children:e.jsx(ta,{size:13})})]}),H&&ne&&e.jsx("button",{className:`icon-btn${_?" active":""}`,title:s("preview.wrap"),onClick:()=>b(I=>!I),children:e.jsx(na,{size:14})}),H&&L==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"icon-btn",title:s("preview.zoomOut"),onClick:()=>S(I=>({...I,s:hn(I.s*.8)})),children:e.jsx(Gs,{size:14})}),e.jsx("button",{className:"icon-btn",title:s("preview.zoomIn"),onClick:()=>S(I=>({...I,s:hn(I.s*1.25)})),children:e.jsx(Ys,{size:14})}),e.jsx("button",{className:"icon-btn",title:s("preview.fit"),onClick:()=>S({s:1,x:0,y:0}),children:e.jsx(Zs,{size:14})})]}),t.download&&e.jsx("button",{className:"icon-btn",title:s("preview.download"),onClick:t.download,children:e.jsx(Ie,{size:14})}),e.jsx("button",{className:"icon-btn",title:s(x?"preview.collapse":"preview.expand"),onClick:()=>z(I=>!I),children:x?e.jsx(ea,{size:14}):e.jsx(Cs,{size:14})}),e.jsx("button",{className:"icon-btn",title:s("preview.close"),onClick:n,children:e.jsx(Ye,{size:15})})]}),e.jsx("div",{className:"wsfile-body",children:Q})]})})};te({"team.editor.titleNew":{zh:"新建团队",en:"New team"},"team.editor.titleEdit":{zh:"编辑团队",en:"Edit team"},"team.editor.name":{zh:"团队名称(可空)",en:"Team name (optional)"},"team.editor.namePlaceholder":{zh:"留空 = 按成员名自动命名",en:"Leave empty to name it after the members"},"team.editor.avatar":{zh:"团队头像",en:"Team avatar"},"team.editor.avatarImage":{zh:"上传图片",en:"Upload image"},"team.editor.avatarRemove":{zh:"移除图片",en:"Remove image"},"team.editor.avatarEmoji":{zh:"Emoji 标识",en:"Emoji emblem"},"team.editor.avatarHint":{zh:"支持 PNG、JPEG、GIF、WebP(不超过 1 MB);也可使用 Emoji,留空显示成员组合头像。",en:"PNG, JPEG, GIF or WebP up to 1 MB. You can also use an emoji, or leave it empty for the member avatar stack."},"team.editor.avatarTooLarge":{zh:"头像不能超过 1 MB",en:"The avatar must be no larger than 1 MB"},"team.editor.avatarReadFailed":{zh:"读取团队头像失败",en:"Could not read the team avatar"},"team.editor.members":{zh:"成员(勾选顺序 = 发言顺序)",en:"Members (pick order = speaking order)"},"team.editor.rolePlaceholder":{zh:"角色 / 分工(可选)",en:"Role (optional)"},"team.editor.doc":{zh:"TEAM.md(团队约定,模型读取,建议英文)",en:"TEAM.md (team charter read by the models; English recommended)"},"team.editor.docPlaceholder":{zh:`# Team
|
|
9
|
-
## Mission
|
|
10
|
-
## Roles
|
|
11
|
-
## Workflow
|
|
12
|
-
## Protocol`,en:`# Team
|
|
13
|
-
## Mission
|
|
14
|
-
## Roles
|
|
15
|
-
## Workflow
|
|
16
|
-
## Protocol`},"team.editor.needTwo":{zh:"至少选择 2 名在册成员",en:"Pick at least 2 members that still exist"},"team.editor.missing":{zh:"已不存在",en:"missing"},"team.editor.save":{zh:"保存",en:"Save"},"team.editor.create":{zh:"创建团队",en:"Create team"},"team.editor.cancel":{zh:"取消",en:"Cancel"},"team.editor.saved":{zh:"团队已保存",en:"Team saved"},"team.editor.failed":{zh:"保存失败:{e}",en:"Save failed: {e}"}});const _l=({agents:t,team:n,initialMembers:s,onSaved:a,onClose:o})=>{const{t:i}=V(),r=c.useMemo(()=>t.filter(E=>E.createdBy!=="system"),[t]),u=c.useMemo(()=>new Set(r.map(E=>E.slug)),[r]),[p,f]=c.useState(n?.name||""),[m,g]=c.useState(n?.avatar||""),[w,x]=c.useState(null),[z,k]=c.useState(!1),[y,N]=c.useState(()=>n?n.members.map(E=>({...E})):(s||[]).filter(E=>r.some(F=>F.slug===E)).map(E=>({slug:E,role:""}))),[d,_]=c.useState(n?.doc||""),[b,C]=c.useState(!1),j=y.filter(E=>u.has(E.slug)).length,h=y.map(E=>r.find(F=>F.slug===E.slug)?.name||E.slug).join(" & "),S=n?n.name:h||i("team.editor.namePlaceholder"),B=j>=2&&!b,J=E=>N(F=>F.some(W=>W.slug===E)?F.filter(W=>W.slug!==E):[...F,{slug:E,role:""}]),L=(E,F)=>N(W=>W.map(X=>X.slug===E?{...X,role:F}:X)),K=eo(m),D=E=>{const F=E.target.files?.[0];if(E.target.value="",!!F){if(F.size>1048576){P.getState().toast(i("team.editor.avatarTooLarge"),!0);return}x(F),g(""),k(!1)}},q=async()=>{if(!B)return;C(!0);const E=P.getState();try{const F={name:p.trim(),avatar:z?"":m.trim(),members:y,doc:d};let W=n?await Io(ze(),n.slug,F):await Do(ze(),F);if(z&&n&&(await _o(ze(),W.slug),W={...W,avatar:""}),w){const X=await new Promise((Q,H)=>{const le=new FileReader;le.onload=()=>Q(String(le.result)),le.onerror=()=>H(new Error(i("team.editor.avatarReadFailed"))),le.readAsDataURL(w)}),ae=await Fo(ze(),W.slug,X,w.type);W={...W,avatar:ae.avatar}}await E.refreshTeams(),E.toast(i("team.editor.saved")),a(W)}catch(F){E.toast(i("team.editor.failed",{e:F?.message||String(F)}),!0)}finally{C(!1)}};return e.jsx("div",{onClick:o,style:{position:"fixed",inset:0,background:"var(--overlay-scrim)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:e.jsxs("div",{className:"team-editor",onClick:E=>E.stopPropagation(),style:{width:520,maxWidth:"92vw",maxHeight:"86vh",overflow:"auto",borderRadius:"var(--radius-md, 12px)",background:"var(--bg)",color:"var(--text)",border:"1px solid var(--border)",boxShadow:"var(--card-shadow)",padding:18},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[e.jsx(Po,{size:18}),e.jsx("strong",{style:{fontSize:"var(--ui-font-heading, 14px)",flex:1},children:i(n?"team.editor.titleEdit":"team.editor.titleNew")}),e.jsx("button",{className:"icon-btn",onClick:o,title:i("team.editor.cancel"),children:e.jsx(Ye,{size:16})})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:i("team.editor.name")}),e.jsx("input",{type:"text",value:p,placeholder:S,onChange:E=>f(E.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:i("team.editor.avatar")}),e.jsxs("div",{className:"agent-avatar-actions",children:[e.jsxs("label",{className:"btn sm",children:[e.jsx(Xr,{size:13}),i("team.editor.avatarImage"),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",disabled:b,onChange:D})]}),(K||w)&&e.jsxs("button",{type:"button",className:"btn ghost sm",disabled:b,onClick:()=>{x(null),g(""),k(!!n&&K)},children:[e.jsx(ft,{size:13}),i("team.editor.avatarRemove")]}),w&&e.jsx("small",{children:w.name})]}),e.jsx("input",{type:"text","aria-label":i("team.editor.avatarEmoji"),value:K?"":m,disabled:K||!!w,maxLength:16,placeholder:"🧭",onChange:E=>{g(E.target.value),k(!1)}}),e.jsx("small",{children:i("team.editor.avatarHint")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:i("team.editor.members")}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:220,overflow:"auto"},children:[...r,...y.filter(E=>!u.has(E.slug)).map(E=>({slug:E.slug,name:`${E.slug} (${i("team.editor.missing")})`}))].map(E=>{const F=y.findIndex(X=>X.slug===E.slug),W=F>=0;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,minWidth:160,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:W,onChange:()=>J(E.slug)}),W&&e.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-muted)",minWidth:14},children:F+1}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name})]}),W&&e.jsx("input",{type:"text",value:y[F].role,placeholder:i("team.editor.rolePlaceholder"),style:{flex:1},onChange:X=>L(E.slug,X.target.value)})]},E.slug)})}),j<2&&e.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--danger)",marginTop:4},children:i("team.editor.needTwo")})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:i("team.editor.doc")}),e.jsx("textarea",{rows:7,value:d,placeholder:i("team.editor.docPlaceholder"),onChange:E=>_(E.target.value)})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{className:"btn sm",onClick:o,children:i("team.editor.cancel")}),e.jsx("button",{className:"btn primary sm",onClick:()=>{q()},disabled:!B,children:i(n?"team.editor.save":"team.editor.create")})]})]})})};function Fl(t){const n=s=>String(s).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}const $l=4e3,Ll="Track this task; report to the user only when something changed, and remove this entry when it is done. ";async function Jn(t,n){const s=P.getState();try{return await Es(ze(),t,n,"pending"),!0}catch(a){return s.toast(a?.code==="todo_not_pending"?s.tr("chat.task.doneTodo"):s.tr("chat.task.todoSyncFail",{e:a?.message||String(a)}),!0),!1}}async function ql(t){const n=P.getState();await Es(ze(),t,"pending","injected").catch(s=>{n.toast(n.tr("chat.task.todoSyncFail",{e:s?.message||String(s)}),!0)})}async function Ol(t,n,s){const a=P.getState(),o=r=>{Oo(ze(),r).catch(()=>{})},i=`task-card "${t.title.slice(0,80)}"`;if(n==="here"||n==="new"){if(t.todo&&!await Jn(t.todo,"injected"))return!1;let r=!1;try{n==="new"&&$o(),r=!!await P.getState().send(t.prompt,[],void 0,void 0,void 0,n==="here"?s:null)}finally{!r&&t.todo&&await ql(t.todo)}return r&&o(`${i} accepted: ${n==="here"?"run here":"run in a new session"}`),r}if(n==="muse"&&t.todo)try{return await Lo(ze(),t.todo),a.toast(a.tr("chat.task.handedDo")),!0}catch(r){return a.toast(r?.code==="muse_disabled"?a.tr("chat.task.museOff"):r?.code==="todo_not_pending"?a.tr("chat.task.doneTodo"):a.tr("chat.task.trackFail",{e:r?.message||String(r)}),!0),!1}if(n==="muse"){const r=Ll+t.prompt;if(r.length>$l)return a.toast(a.tr("chat.task.tooLong"),!0),!1;try{return await qo(ze(),"muse",{name:t.title.slice(0,120),date:Fl(new Date(Date.now()+36e5)),repeat:"1d",auto:!0,prompt:r,description:`${t.tldr?`${t.tldr} · `:""}source session ${s||"-"}`.slice(0,500),todo:!0}),a.toast(a.tr("chat.task.tracked")),o(`${i} handed to Muse for tracking`),!0}catch(u){return a.toast(a.tr("chat.task.trackFail",{e:u?.message||String(u)}),!0),!1}}return t.todo?Jn(t.todo,"dismissed"):(o(`${i} ignored`),!0)}function Bl(t){if(!t.trim())return;P.getState().setPendingChatQuote("chat-panel",t);const n=Le.getState();n.rightVisible&&n.rightTabs.some(a=>a.type==="chat-panel"&&a.active)||n.showSideView("right","chat-panel")}te({"chat.action.insertNote":{zh:"插入笔记",en:"Insert into note"},"chat.insertNote.none":{zh:"没有可写入的笔记:开着的笔记是只读或已锁定",en:"No writable note: the open notes are read-only or locked"},"chat.insertNote.done":{zh:"已插入「{name}」",en:"Inserted into “{name}”"},"chat.insertNote.failed":{zh:"没能插入:笔记是只读、已锁定或处在源码模式",en:"Couldn’t insert: the note is read-only, locked, or in source mode"},"chat.insertNote.undo":{zh:"撤销",en:"Undo"},"chat.insertNote.undoStale":{zh:"笔记之后又有改动,请在笔记里撤销",en:"The note has changed since — undo it in the note"}});const Hl=/^> — \[\[([^\]|#\n]+)(?:#([^\]|\n]+))?\]\]\s*$/;function Wl(t){const n=t.split(`
|
|
17
|
-
`);for(let s=n.length-1;s>=0;s--){const a=Hl.exec(n[s]);if(!a)continue;const o=[];for(let u=s-1;u>=0&&n[u].startsWith(">");u--)o.unshift(n[u].replace(/^> ?/,""));const i=a[2]?.trim(),r=o.join(`
|
|
18
|
-
`).trim();return{path:a[1].trim(),anchor:{...i?{heading:i}:{},...r?{text:r}:{}}}}return null}function Vl(t,n){const s=t.findIndex(a=>a.id===n);for(let a=(s<0?t.length:s)-1;a>=0;a--){const o=t[a];if(o.role!=="user")continue;const i=Wl(o.content);if(i)return i}return null}function Ul(t){return Bo(t).trim()}function Kl(t){return(t.split("/").pop()||t).replace(/\.md$/i,"")}function Gl(t,n){const s=Ul(t);if(!s)return!1;if(!xs())return ue({text:Ne("chat.insertNote.none"),level:"info",inAppOnly:!0}),!1;const a=to(s,n);return a?(ue({text:Ne("chat.insertNote.done",{name:Kl(a.path)}),level:"success",receipt:!0,durationMs:8e3,action:{label:Ne("chat.insertNote.undo"),run:()=>{a.undo()||ue({text:Ne("chat.insertNote.undoStale"),level:"info",inAppOnly:!0})}}}),!0):(ue({text:Ne("chat.insertNote.failed"),level:"warning",inAppOnly:!0}),!1)}const Yl=()=>so()?xs()?"ready":"disabled":"hidden";function Jl(){return c.useSyncExternalStore(no,Yl)}const pn=Js(()=>({subject:null}));function pa(){const t=Le.getState(),n=t.api?.panels||[],a=(t.api?Ho(t.api):n.find(o=>o.id===t.focusedChatLeafId&&o.params?.__loc==="main"))?.params;return a?.followActive===!1&&typeof a.sessionId=="string"?a.sessionId:P.getState().activeId}const Qn=()=>{const t=pn.getState().subject;t&&t.from!==pa()&&pn.setState({subject:null})};let Xn=!1;function Ot(t){Xn||(Xn=!0,P.subscribe(Qn),Le.subscribe(Qn)),pn.setState({subject:{...t,from:pa()}}),ma(5)}function ma(t){const n=Le.getState();if(!n.rightVisible&&!!n.api?.panels.some(a=>a.params?.__loc==="right")&&t>0){setTimeout(()=>ma(t-1),120);return}n.rightVisible||n.toggleSidebar("right"),Le.getState().openView("tangu-details",{},"right")}const Et="forsion:human-changed",Pu=t=>t.kind==="agent"?`agent:${t.slug}`:`project:${t.sessionId}`,Ql=t=>t.kind==="agent"?`/agent/agents/${encodeURIComponent(t.slug)}/human`:"/agent/project-context/human";async function Cn(t,n,s,a="",o){const i=n.kind==="project"?{sessionId:n.sessionId}:{},r=s==="GET"&&n.kind==="project"?`?sessionId=${encodeURIComponent(n.sessionId)}`:"",u=await ks(t,`${Ql(n)}${a}${r}`,{method:s,...s==="GET"?{}:{body:JSON.stringify({...o,...i})}}),p=await u.json();if(!u.ok)throw Object.assign(new Error(p.detail||`HTTP ${u.status}`),{status:u.status,code:p.error});return s!=="GET"&&window.dispatchEvent(new CustomEvent(Et)),p}const Xl=(t,n)=>Cn(t,n,"GET"),Iu=(t,n,s,a,o)=>Cn(t,n,"PUT","",{content:s,expectedVersion:a,summary:o}),Zl=(t,n,s)=>Cn(t,n,"POST","/undo",{changeId:s.id,expectedVersion:s.afterVersion});function ec(t=[]){const n=new Map;for(const s of t)if(!(s.name!=="manage_human"||!s.done||s.isError||!s.result))try{const a=JSON.parse(s.result),o=a.change;if(a.kind!=="human_update"||!o||typeof o.id!="string"||!/^[a-f0-9-]{36}$/.test(o.id)||typeof o.summary!="string"||typeof o.evidence!="string"||typeof o.at!="string"||o.actor!=="agent"||!/^[a-f0-9]{64}$/.test(o.beforeVersion)||!/^[a-f0-9]{64}$/.test(o.afterVersion)||!(o.scope?.kind==="agent"&&typeof o.scope.slug=="string"&&/^[a-z0-9][a-z0-9-]*$/.test(o.scope.slug)||o.scope?.kind==="project"&&typeof o.scope.cwd=="string"&&o.scope.cwd.length>0))continue;n.set(o.id,o)}catch{}return[...n.values()]}te({"agentProfile.human":{zh:"协作",en:"Collaboration"},"projectProfile.tab.human":{zh:"协作",en:"Collaboration"},"human.title":{zh:"协作说明",en:"Collaboration handbook"},"human.agentScope":{zh:"与 {name} 的长期协作",en:"Long-term collaboration with {name}"},"human.projectScope":{zh:"在这个项目中如何配合",en:"How we work together on this project"},"human.empty":{zh:"还没有协作说明。你可以自己写下,也可以在对话中让 Agent 根据实际合作逐步整理。",en:"No collaboration handbook yet. Write one yourself, or let your agent build it from your work together."},"human.edit":{zh:"编辑",en:"Edit"},"human.editLabel":{zh:"编辑协作说明",en:"Edit collaboration handbook"},"human.save":{zh:"保存",en:"Save"},"human.cancel":{zh:"放弃修改",en:"Discard changes"},"human.saved":{zh:"已保存,后续对话会读取这份说明。",en:"Saved. Subsequent turns will read this handbook."},"human.userEdit":{zh:"你修改了协作说明",en:"You edited the collaboration handbook"},"human.more":{zh:"更多操作",en:"More actions"},"human.source":{zh:"查看原文",en:"View source"},"human.preview":{zh:"阅读视图",en:"Reading view"},"human.history":{zh:"修改历史",en:"Change history"},"human.noHistory":{zh:"此设备还没有修改记录。",en:"No changes recorded on this device yet."},"human.path":{zh:"文件位置",en:"File location"},"human.updatedAt":{zh:"更新于 {time}",en:"Updated {time}"},"human.updated":{zh:"协作说明已更新",en:"Collaboration handbook updated"},"human.applied":{zh:"已生效",en:"Applied"},"human.view":{zh:"查看说明",en:"View handbook"},"human.revise":{zh:"修改",en:"Revise"},"human.undo":{zh:"撤销本次更新",en:"Undo this update"},"human.undone":{zh:"本次更新已撤销",en:"This update was undone"},"human.evidence":{zh:"更新依据",en:"Reason for this update"},"human.project":{zh:"项目协作",en:"Project collaboration"},"human.agent":{zh:"长期协作",en:"Long-term collaboration"},"human.inherited":{zh:"同时适用:与 {name} 的长期协作",en:"Also applies: collaboration with {name}"},"human.loading":{zh:"正在读取协作说明…",en:"Loading the collaboration handbook…"},"human.retry":{zh:"重试",en:"Retry"},"human.conflict":{zh:"说明已在别处修改。你的草稿仍保留,请查看最新内容后再合并修改。",en:"The handbook changed elsewhere. Your draft is preserved; review the latest version before merging your changes."},"human.undoConflict":{zh:"已有后续修改。请打开说明调整,避免覆盖新的内容。",en:"Newer changes exist. Open the handbook to revise it without overwriting them."},"human.latest":{zh:"查看最新内容",en:"Review latest version"},"human.merge":{zh:"已合并,使用最新版本保存",en:"Merged; save against the latest version"},"human.localOnly":{zh:"协作说明需要连接本地引擎。",en:"Connect to a local engine to use collaboration handbooks."},"human.remoteDenied":{zh:"请在宿主设备上查看和修改协作说明。",en:"View and edit collaboration handbooks on the host device."},"human.template":{zh:`# 我们怎么配合
|
|
19
|
-
|
|
20
|
-
## 我会怎么配合你
|
|
21
|
-
|
|
22
|
-
## 需要你参与的部分
|
|
23
|
-
|
|
24
|
-
## 可能帮助我们提高效率的事情
|
|
25
|
-
`,en:`# How we work together
|
|
26
|
-
|
|
27
|
-
## How I will help
|
|
28
|
-
|
|
29
|
-
## Where I need your input
|
|
30
|
-
|
|
31
|
-
## What could help us work better
|
|
32
|
-
`},"human.changed":{zh:"有新的协作说明,打开后可查看。",en:"The collaboration handbook has changed. Open it to see the latest version."}});function tc({changes:t,cfg:n,sessionId:s}){const{t:a}=V(),o=t.map(r=>r.id).join(","),i=de(s);return c.useEffect(()=>{o&&window.dispatchEvent(new CustomEvent(Et))},[o]),t.length?e.jsxs("section",{className:"human-update-card","data-human-updates":!0,children:[e.jsxs("div",{className:"human-update-head",children:[e.jsx(zr,{size:15}),e.jsx("strong",{children:a("human.updated")})]}),t.map(r=>e.jsx(nc,{change:r,engine:i,cfg:n,sessionId:s},JSON.stringify([i.key,i.base,n.token,r.id])))]}):null}function nc({change:t,engine:n,cfg:s,sessionId:a}){const{t:o}=V(),i=t.scope,r=P(b=>i.kind==="agent"?b.agentDefs.find(C=>C.slug===i.slug)?.name||i.slug:i.cwd.split(/[\\/]/).filter(Boolean).at(-1)),u=P(b=>[...b.sessions,...b.archivedSessions].find(C=>C.id===a)?.project_path),[p,f]=c.useState(null),[m,g]=c.useState(""),[w,x]=c.useState(!1),z=t.scope.kind==="agent"?t.scope:{kind:"project",sessionId:a},k=b=>b.scope.kind===i.kind&&(b.scope.kind==="agent"&&i.kind==="agent"?b.scope.slug===i.slug:b.scope.kind==="project"&&i.kind==="project"&&b.scope.cwd===i.cwd);c.useEffect(()=>{let b=!0;const C=()=>{Xl(n,z).then(j=>{b&&k(j)&&f(j)}).catch(()=>{})};return C(),window.addEventListener(Et,C),()=>{b=!1,window.removeEventListener(Et,C)}},[n.key,n.base,s.token,t.id,a]);const y=!!p?.history.some(b=>b.undoOf===t.id),N=!!p?.history.some(b=>b.id===t.id&&b.canUndo),d=(b=!1)=>Ot({...t.scope.kind==="agent"?{kind:"agent",slug:t.scope.slug}:{kind:"project",path:u||t.scope.cwd},human:{at:Date.now(),edit:b,changeId:t.id}}),_=async()=>{if(!w){x(!0),g("");try{const b=await Zl(n,z,t);f(b.document)}catch(b){g(b?.status===409?o("human.undoConflict"):String(b?.message||b))}finally{x(!1)}}};return e.jsxs("article",{"data-human-update":t.id,children:[e.jsxs("div",{className:"human-scope",children:[r," · ",o(t.scope.kind==="agent"?"human.agent":"human.project")," · ",e.jsx("span",{className:"human-applied",children:o(y?"human.undone":"human.applied")})]}),e.jsx("p",{children:t.summary}),t.evidence&&e.jsxs("details",{children:[e.jsx("summary",{children:o("human.evidence")}),e.jsx("p",{children:t.evidence})]}),e.jsxs("div",{className:"human-actions",children:[e.jsx("button",{type:"button",className:"profile-text-action",onClick:()=>d(),children:o("human.view")}),e.jsx("button",{type:"button",className:"profile-text-action",onClick:()=>d(!0),children:o("human.revise")}),!y&&e.jsxs("button",{type:"button",className:"profile-text-action",disabled:w||!N,title:!N&&p?o("human.undoConflict"):void 0,onClick:()=>{_()},children:[e.jsx(bn,{size:12}),o("human.undo")]})]}),m&&e.jsx("p",{className:"agent-profile-error",role:"alert",children:m})]})}const wt="forsion:harness-changed",sc=new Set(["create","revise","delete","rollback"]),Zn=t=>t===void 0||Array.isArray(t)&&t.every(n=>typeof n=="string");function ac(t=[]){const n=new Map;for(const s of t)if(!(s.name!=="manage_harness"||!s.done||s.isError||!s.result))try{const a=JSON.parse(s.result),o=a.change;if(a.kind!=="harness_update"||!o||typeof o.rev!="string"||!/^[a-f0-9-]{36}$/.test(o.rev)||typeof o.agent!="string"||!/^[a-z0-9][a-z0-9-]*$/.test(o.agent)||typeof o.entryId!="string"||!/^[A-Za-z0-9_-]{1,64}$/.test(o.entryId)||!sc.has(o.action)||typeof o.title!="string"||typeof o.body!="string"||typeof o.evidence!="string"||typeof o.kind!="string"||typeof o.at!="string"||typeof o.version!="number"||!Zn(o.tools)||!Zn(o.skills))continue;n.set(o.rev,o)}catch{}return[...n.values()]}function oc(t,n){const s=t.filter(o=>o.entryId===n.entryId),a=s.findIndex(o=>o.rev===n.rev);return a<0?"superseded":a===s.length-1?"current":a===s.length-2&&s[a+1].action==="rollback"?"undone":"superseded"}te({"harness.updated":{zh:"进化记录已更新",en:"Evolution record updated"},"harness.act.create":{zh:"新增",en:"Added"},"harness.act.revise":{zh:"修订",en:"Revised"},"harness.act.delete":{zh:"删除",en:"Removed"},"harness.act.rollback":{zh:"恢复上一版",en:"Restored previous version"},"harness.applied":{zh:"已生效",en:"Applied"},"harness.undone":{zh:"本次更新已撤销",en:"This update was undone"},"harness.evidence":{zh:"更新依据",en:"Reason for this update"},"harness.view":{zh:"查看进化记录",en:"View evolution record"},"harness.undo":{zh:"撤销本次更新",en:"Undo this update"},"harness.undoConflict":{zh:"这条记录后来又改过。请打开进化记录调整,避免覆盖新的内容。",en:"This entry changed again later. Open the evolution record to revise it without overwriting newer changes."}});function ic({changes:t,sessionId:n}){const{t:s,locale:a}=V(),o=a==="zh"?"、":", ",i=de(n),r=[...new Set(t.map(y=>y.agent))].join(","),u=t.map(y=>y.rev).join(","),[p,f]=c.useState({}),[m,g]=c.useState(""),[w,x]=c.useState({}),z=P(y=>y.agentDefs);if(c.useEffect(()=>{if(!r)return;let y=!0;const N=()=>{for(const d of r.split(","))Wo(i,d).then(_=>{y&&f(b=>({...b,[d]:_.journal}))}).catch(()=>{})};return N(),window.addEventListener(wt,N),()=>{y=!1,window.removeEventListener(wt,N)}},[i.key,i.base,r,u]),c.useEffect(()=>{u&&window.dispatchEvent(new CustomEvent(wt))},[u]),!t.length)return null;const k=async y=>{if(!m){g(y.rev),x(N=>({...N,[y.rev]:""}));try{await Vo(i,y.agent,y.entryId,y.rev)}catch(N){x(d=>({...d,[y.rev]:N?.status===409?s("harness.undoConflict"):String(N?.message||N)}))}finally{g(""),window.dispatchEvent(new CustomEvent(wt))}}};return e.jsxs("section",{className:"human-update-card","data-harness-updates":!0,children:[e.jsxs("div",{className:"human-update-head",children:[e.jsx(ys,{size:15}),e.jsx("strong",{children:s("harness.updated")})]}),t.map(y=>{const N=p[y.agent],d=N?oc(N,y):null;return e.jsxs("article",{"data-harness-update":y.rev,"data-harness-state":d||void 0,children:[e.jsxs("div",{className:"human-scope",children:[z.find(_=>_.slug===y.agent)?.name||y.agent," · ",s(`harness.act.${y.action}`)," · ",e.jsx("span",{className:"human-applied",children:s(d==="undone"?"harness.undone":"harness.applied")})]}),e.jsx("p",{children:e.jsx("strong",{children:y.title})}),e.jsx("p",{children:y.body}),!!y.tools?.length&&e.jsx("p",{className:"human-scope",children:s("settings.agents.harnessShelvedTools",{names:y.tools.join(o)})}),!!y.skills?.length&&e.jsx("p",{className:"human-scope",children:s("settings.agents.harnessShelvedSkills",{names:y.skills.join(o)})}),y.evidence&&e.jsxs("details",{children:[e.jsx("summary",{children:s("harness.evidence")}),e.jsx("p",{children:y.evidence})]}),e.jsxs("div",{className:"human-actions",children:[e.jsx("button",{type:"button",className:"profile-text-action",onClick:()=>Ot({kind:"agent",slug:y.agent,evolution:Date.now()}),children:s("harness.view")}),d!=="undone"&&e.jsxs("button",{type:"button",className:"profile-text-action",disabled:!!m||d!=="current",title:d==="superseded"?s("harness.undoConflict"):void 0,onClick:()=>{k(y)},children:[e.jsx(bn,{size:12}),s("harness.undo")]})]}),w[y.rev]&&e.jsx("p",{className:"agent-profile-error",role:"alert",children:w[y.rev]})]},y.rev)})]})}const rc=({text:t,stored:n,anchorPrefix:s})=>{const{t:a}=V(),o=c.useRef(null),i=c.useRef(null),[r,u]=c.useState(!1),[p,f]=c.useState(!1),[m,g]=c.useState(0),[w,x]=c.useState(0),[z,k]=c.useState(!1),[y,N]=c.useState(null);c.useEffect(()=>()=>{o.current?.pause(),i.current&&URL.revokeObjectURL(i.current)},[]);const d=async()=>{if(o.current)return o.current;u(!0),N(null);try{const j=await Ko(ze(),n,t);i.current=j;const h=new Audio(j);return h.onloadedmetadata=()=>g(h.duration||0),h.ontimeupdate=()=>x(h.currentTime||0),h.onended=()=>{f(!1),x(0)},h.onpause=()=>f(!1),h.onplay=()=>f(!0),o.current=h,h}catch(j){return N(j?.message==="EMPTY"||j?.message==="NO_MODEL"?a("tts.noText"):a("tts.failed",{e:j?.message||j})),null}finally{u(!1)}},_=async()=>{const j=await d();j&&(j.paused?j.play():j.pause())},b=m?Math.max(1,Math.round(m)):0,C=m?Math.min(100,w/m*100):0;return e.jsxs("div",{className:"t2-voice",children:[e.jsxs("div",{className:"t2-voice-bar",children:[e.jsx("button",{className:"t2-voice-play",onClick:_,title:a(p?"voice.pause":"voice.play"),children:r?e.jsx(Oe,{size:15,className:"spin"}):p?e.jsx(Uo,{size:15}):e.jsx(Ts,{size:15})}),e.jsx("div",{className:"t2-voice-track",children:e.jsx("span",{style:{width:`${C}%`}})}),e.jsx("span",{className:"t2-voice-dur",children:b?`${b}″`:a("voice.label")}),e.jsx("button",{className:"t2-voice-txt",onClick:()=>k(j=>!j),title:a("voice.toText"),children:e.jsx(gn,{size:13})})]}),y&&e.jsx("div",{className:"t2-dim",style:{marginTop:4},children:y}),z&&e.jsx("div",{className:"t2-content",style:{marginTop:6},children:e.jsx(qe,{content:t,anchorPrefix:s})})]})},lc=({content:t})=>{const{t:n}=V(),[s,a]=c.useState(!1);return t?e.jsxs("div",{className:"thinking-block",children:[e.jsxs("button",{className:"thinking-toggle",onClick:()=>a(!s),children:[s?e.jsx(it,{size:13}):e.jsx(we,{size:13}),e.jsx(Cr,{size:12}),n("chat.systemPrompt"),e.jsx("span",{style:{opacity:.7},children:n("thinking.charCount",{count:t.length})})]}),e.jsx($e,{open:s,children:e.jsx("pre",{className:"thinking-content",style:{whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:360,overflow:"auto",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:"var(--ui-font-meta, 12px)",margin:0},children:t})})]}):null},ge=23,cc={up:{x:0,y:-1},right:{x:1,y:0},down:{x:0,y:1},left:{x:-1,y:0}},dc={up:"down",right:"left",down:"up",left:"right"},es=(t,n)=>t.x===n.x&&t.y===n.y;function fa(t,n){const s=[];for(let a=0;a<ge;a++)for(let o=0;o<ge;o++)t.some(i=>i.x===o&&i.y===a)||s.push({x:o,y:a});return s[Math.min(s.length-1,Math.floor(n()*s.length))]||{x:0,y:0}}function Yt(t=Math.random){const n=Math.floor(ge/2),s=Math.floor(ge/2)+2,a=Array.from({length:5},(o,i)=>({x:s-i,y:n}));return{body:a,direction:"right",queuedDirection:"right",food:fa(a,t),score:0,alive:!0}}function uc(t,n){return!t.alive||t.queuedDirection!==t.direction||dc[t.direction]===n?t:{...t,queuedDirection:n}}function hc(t,n=Math.random){if(!t.alive)return t;const s=t.queuedDirection,a=cc[s],o=t.body[0],r={x:(o.x+a.x+ge)%ge,y:o.y+a.y},u=es(r,t.food),p=u?t.body:t.body.slice(0,-1),f=r.y<0||r.y>=ge,m=p.some(w=>es(w,r));if(f||m)return{...t,direction:s,queuedDirection:s,alive:!1};const g=[r,...t.body];return u||g.pop(),{body:g,direction:s,queuedDirection:s,food:u?fa(g,n):t.food,score:t.score+(u?1:0),alive:!0}}te({"imageGeneration.loading":{zh:"正在生成图片…",en:"Generating image…"},"imageGeneration.play":{zh:"点击点阵开启贪吃蛇彩蛋",en:"Click the dot grid to play Snake"},"imageGeneration.controls":{zh:"贪吃蛇:方向键、WASD 或滑动控制,再次点击退出",en:"Snake: use arrow keys, WASD, or swipe to steer; click again to exit"},"imageGeneration.snake":{zh:"贪吃蛇 · {score}",en:"Snake · {score}"},"imageGeneration.retry":{zh:"撞到了,马上再来一局…",en:"Game over — restarting…"}});const kt=276,ga=12,Ve=(kt-ga*2)/(ge-1);function Ze(t,n,s){return getComputedStyle(t).getPropertyValue(n).trim()||s}function va(t){const n=Math.min(window.devicePixelRatio||1,2),s=Math.round(kt*n);(t.width!==s||t.height!==s)&&(t.width=s,t.height=s);const a=t.getContext("2d");return a?(a.setTransform(n,0,0,n,0,0),a.clearRect(0,0,kt,kt),a):null}function Re(t){return ga+t*Ve}function pc(t,n){const s=va(t);if(!s)return;const a=Ze(t,"--accent-ink","#4d7ff0"),o=Ze(t,"--text-faint","#777"),i=n*42e-5,r=.5+Math.cos(i*1.13)*.2,u=.5+Math.sin(i*.91)*.2;for(let p=0;p<ge;p++)for(let f=0;f<ge;f++){const m=f/(ge-1),g=p/(ge-1),w=m-r,x=g-u,z=Math.exp(-(w*w/.055+x*x/.08)),k=.5+Math.sin(m*5.7+i*2.2)*.17,y=Math.exp(-Math.pow(g-k,2)/.024)*(.35+.3*Math.sin(i+m*3.4)),N=Math.max(0,Math.min(1,z*.92+y*.42));s.beginPath(),s.arc(Re(f),Re(p),1+N*2.05,0,Math.PI*2),s.fillStyle=N>.16?a:o,s.globalAlpha=.16+N*.78,s.fill()}s.globalAlpha=1}function Jt(t,n){const s=va(t);if(!s)return;const a=Ze(t,"--accent-ink","#4d7ff0"),o=Ze(t,"--text-faint","#777"),i=Ze(t,"--bg","#fff"),r=Ze(t,"--danger","#b85848");for(let k=0;k<ge;k++)for(let y=0;y<ge;y++)s.beginPath(),s.arc(Re(y),Re(k),1,0,Math.PI*2),s.fillStyle=o,s.globalAlpha=.2,s.fill();s.globalAlpha=1,s.beginPath(),s.arc(Re(n.food.x),Re(n.food.y),Ve*.42,0,Math.PI*2),s.fillStyle=r,s.fill(),n.body.forEach((k,y)=>{s.beginPath(),s.arc(Re(k.x),Re(k.y),Ve*(y===0?.47:.4),0,Math.PI*2),s.fillStyle=n.alive?a:r,s.globalAlpha=y===0?1:Math.max(.48,.94-y*.035),s.fill()}),s.globalAlpha=1;const u=n.body[0];if(!u)return;const p={up:[0,-1],right:[1,0],down:[0,1],left:[-1,0]},[f,m]=p[n.direction],g=-m*Ve*.14,w=f*Ve*.14,x=f*Ve*.15,z=m*Ve*.15;for(const k of[-1,1])s.beginPath(),s.arc(Re(u.x)+x+g*k,Re(u.y)+z+w*k,.85,0,Math.PI*2),s.fillStyle=i,s.fill()}const mc=t=>({ArrowUp:"up",w:"up",W:"up",ArrowRight:"right",d:"right",D:"right",ArrowDown:"down",s:"down",S:"down",ArrowLeft:"left",a:"left",A:"left"})[t]||null;function fc(){const{t}=V(),n=c.useRef(null),s=c.useRef(Yt()),a=c.useRef(!1),o=c.useRef(null),i=c.useRef(!1),[r,u]=c.useState(!1),[p,f]=c.useState(0),[m,g]=c.useState(!1);c.useEffect(()=>{if(r)return;const b=n.current;if(!b)return;const C=window.matchMedia("(prefers-reduced-motion: reduce)");let j=0,h=-1/0;const S=L=>{L-h>=32&&(pc(b,C.matches?0:L),h=L),C.matches||(j=requestAnimationFrame(S))};S(0);const B=()=>{cancelAnimationFrame(j),h=-1/0,S(performance.now())};C.addEventListener?.("change",B);const J=new MutationObserver(B);return J.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-mode","data-skin","data-bg","data-theme"]}),()=>{cancelAnimationFrame(j),C.removeEventListener?.("change",B),J.disconnect()}},[r]),c.useEffect(()=>{if(!r)return;const b=n.current;if(!b)return;Jt(b,s.current);let C=0;const j=window.setInterval(()=>{if(a.current)return;const h=hc(s.current);s.current=h,f(h.score),Jt(b,h),h.alive||(a.current=!0,g(!0),C=window.setTimeout(()=>{const S=Yt();s.current=S,a.current=!1,g(!1),f(0),Jt(b,S)},900))},118);return()=>{window.clearInterval(j),window.clearTimeout(C)}},[r]);const w=c.useCallback(()=>{if(r)return;const b=Yt();s.current=b,a.current=!1,f(0),g(!1),u(!0)},[r]),x=c.useCallback(()=>{if(!r){w();return}a.current=!1,g(!1),u(!1)},[r,w]),z=c.useCallback(b=>{s.current=uc(s.current,b)},[]),k=b=>{const C=mc(b.key);C&&(b.preventDefault(),r||w(),z(C))},y=b=>{i.current=!1,o.current={x:b.clientX,y:b.clientY},b.currentTarget.setPointerCapture?.(b.pointerId)},N=b=>{const C=o.current;if(o.current=null,!C||!r)return;const j=b.clientX-C.x,h=b.clientY-C.y;Math.max(Math.abs(j),Math.abs(h))<18||(i.current=!0,z(Math.abs(j)>Math.abs(h)?j>0?"right":"left":h>0?"down":"up"))},d=()=>{if(i.current){i.current=!1;return}x()},_=m?t("imageGeneration.retry"):r?t("imageGeneration.snake",{score:p}):t("imageGeneration.loading");return e.jsxs("div",{className:`image-generation-loader${r?" playing":""}`,"data-image-generation":r?"snake":"ambient",children:[e.jsx("div",{className:"image-generation-status",role:"status","aria-live":"polite",children:_}),e.jsx("button",{type:"button",className:"image-generation-stage","aria-label":t(r?"imageGeneration.controls":"imageGeneration.play"),title:t(r?"imageGeneration.controls":"imageGeneration.play"),onClick:d,onKeyDown:k,onPointerDown:y,onPointerUp:N,children:e.jsx("canvas",{ref:n,className:"image-generation-canvas","aria-hidden":"true"})})]})}te({"tool.parked.waiting":{zh:"已挂起,等你在输入框上方批准。Agent 先做别的,拍板后结果会补在这里。",en:"Parked until you approve it above the input box. The agent carries on meanwhile; the result lands here once you decide."},"tool.parked.past":{zh:"当时挂起等你批准,结局见后面的审批结果。",en:"This call was parked for your approval; see the approval result further down."},"tool.waitingYou":{zh:"等你回复",en:"Waiting for your reply"},"tool.verb.readComputerHistory":{zh:"读取电脑历史",en:"Read computer history"},"tool.computerHistory.notSaved":{zh:"电脑历史摘录已交给模型,不会保存在对话记录里。",en:"The computer history excerpt was passed to the model and isn’t saved in the conversation."}});const xa="read_computer_history";function gc(t,n){return t.name===xa&&!t.isError?n("tool.computerHistory.notSaved"):t.result||n("tool.empty")}const vc=new Set(["ask_user","exit_plan_mode"]);function ut(t){if(!t)return 0;const n=t.split(`
|
|
33
|
-
`).length;return t.endsWith(`
|
|
34
|
-
`)?n-1:n}function xc(t){let n=0,s=0;for(const a of t.split(`
|
|
35
|
-
`))/^\+(?!\+\+)/.test(a)?n++:/^-(?!--)/.test(a)&&s++;return{adds:n,dels:s}}const We=t=>t.split(/[/\\]/).filter(Boolean).pop()||t;function wa(t){let n={};try{n=t.arguments?JSON.parse(t.arguments):{}}catch{}const s=typeof n.path=="string"?n.path:"";switch(t.name){case"write_file":return{kind:"write",verbKey:"tool.verb.wrote",target:We(s),adds:ut(String(n.content??"")),dels:0,isFile:!0};case"edit_file":return{kind:"edit",verbKey:"tool.verb.edited",target:We(s),adds:ut(String(n.new_string??"")),dels:ut(String(n.old_string??"")),isFile:!0};case"multi_edit":{let a=0,o=0;if(Array.isArray(n.edits))for(const i of n.edits)a+=ut(String(i?.new_string??"")),o+=ut(String(i?.old_string??""));return{kind:"edit",verbKey:"tool.verb.edited",target:We(s),adds:a,dels:o,isFile:!0}}case"apply_patch":{const a=String(n.patch??n.input??n.diff??t.arguments??""),{adds:o,dels:i}=xc(a),r=a.match(/(?:\*\*\* (?:Update|Add|Delete) File: |\+\+\+ |--- )([^\n]+)/);return{kind:"edit",verbKey:"tool.verb.edited",target:r?We(r[1].trim()):"patch",adds:o,dels:i,isFile:!0}}case"run_bash":case"run_background":return{kind:"run",verbKey:"tool.verb.ran",target:String(n.command??n.cmd??"").split(`
|
|
36
|
-
`)[0],isFile:!1};case"run_python":return{kind:"run",verbKey:"tool.verb.ran",target:"python: "+String(n.code??"").split(`
|
|
37
|
-
`)[0],isFile:!1};case"read_file":case"read_document":case"read_log":case"view_image":case"display_file":return{kind:"read",verbKey:"tool.verb.read",target:We(s||String(n.name??n.file??"")),isFile:!0};case"sketch":return{kind:"other",verbKey:"tool.verb.sketched",target:String(n.title??"")||"sketch",isFile:!1};case"desk_present":return{kind:"read",verbKey:"tool.verb.presented",target:(Array.isArray(n.views)?n.views:[]).map(i=>We(String(i?.path||""))).filter(Boolean).join(", ")||"Agent Desk",isFile:!0};case"list_dir":case"list_files":return{kind:"read",verbKey:"tool.verb.listed",target:We(s||"."),isFile:!0};case"search_files":case"glob_files":return{kind:"search",verbKey:"tool.verb.searched",target:String(n.query??n.pattern??n.glob??""),isFile:!1};case"web_search":return{kind:"search",verbKey:"tool.verb.searched",target:String(n.query??""),isFile:!1};case"web_fetch":return{kind:"browse",verbKey:"tool.verb.browsed",target:String(n.url??""),isFile:!1};case xa:return{kind:"read",verbKey:"tool.verb.readComputerHistory",target:String(n.query??n.app??""),isFile:!1};default:return t.name.startsWith("browser_")?{kind:"browse",verbKey:"tool.verb.browsed",target:String(n.url??n.text??t.name.replace("browser_","")),isFile:!1}:{kind:"other",verbKey:"",target:typeof n.command=="string"?n.command:typeof n.path=="string"?n.path:typeof n.query=="string"?n.query:(t.arguments||"").slice(0,80),isFile:!1}}}const ts=t=>{try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}},wc=({d:t})=>t.adds||t.dels?e.jsxs("span",{className:"tool-row-stat",children:[t.adds?e.jsxs("span",{className:"add",children:["+",t.adds]}):null,t.dels?e.jsxs("span",{className:"del",children:["-",t.dels]}):null]}):null,yc=({ev:t,desc:n,running:s,waiting:a,asking:o})=>{const{t:i}=V(),[r,u]=c.useState(!1),p=c.useMemo(()=>r?io(t.name,t.arguments):null,[r,t.name,t.arguments]),f=n.verbKey?i(n.verbKey):t.name,m=s&&!t.done&&!o;return e.jsxs("div",{className:"tool-row",children:[e.jsxs("button",{className:"tool-row-head","aria-busy":m,onClick:()=>u(g=>!g),children:[r?e.jsx(it,{size:12}):e.jsx(we,{size:12}),e.jsx("span",{className:"tool-row-copy",children:e.jsxs("span",{className:`tool-row-copy-text${m?" chat-run-shimmer-text":""}`,children:[e.jsx("span",{className:"tool-row-verb",children:f}),e.jsx("span",{className:`tool-row-target${n.isFile?" file":""}`,children:n.target})]})}),e.jsx(wc,{d:n}),e.jsx("span",{className:"tool-row-status",children:o?e.jsx(rn,{size:11,style:{color:"var(--accent-ink)"},"data-waiting-you":"1","aria-label":i("tool.waitingYou"),children:e.jsx("title",{children:i("tool.waitingYou")})}):t.parked?e.jsx(rn,{size:11,style:{color:a?"var(--accent-ink)":"var(--text-faint)"}}):t.done&&t.isError?e.jsx(Ft,{size:11,style:{color:"var(--danger)"}}):null})]}),e.jsx($e,{open:r,children:e.jsxs("div",{className:"tool-card-body",children:[p?e.jsxs(e.Fragment,{children:[e.jsx(yn,{text:p,side:!1}),t.arguments&&e.jsxs("details",{className:"tool-raw-args",children:[e.jsx("summary",{children:i("tool.argsLabel")}),ts(t.arguments)]})]}):t.arguments?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"label",children:i("tool.argsLabel")}),ts(t.arguments)]}):null,t.parked?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"label",children:i("tool.resultLabel")}),i(a?"tool.parked.waiting":"tool.parked.past")]}):t.result!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"label",children:i("tool.resultLabel")}),gc(t,i)]})]})})]})},ns=({events:t,running:n,approvals:s,awaitingAnswer:a})=>{const{t:o}=V(),[i,r]=c.useState(!1);if(!t.length)return null;const u=n?t.filter(S=>(S.name==="generate_image"||S.name==="edit_image")&&!S.done):[],p=u.length?t.filter(S=>!u.includes(S)):t,f=p.map(wa),m={write:0,edit:0,run:0,read:0,search:0,browse:0,other:0};f.forEach(S=>{m[S.kind]++});const g={write:"tool.sum.wrote",edit:"tool.sum.edited",run:"tool.sum.ran",read:"tool.sum.read",search:"tool.sum.searched",browse:"tool.sum.browsed",other:"tool.sum.other"},x=["write","edit","run","read","search","browse","other"].filter(S=>m[S]>0).map(S=>o(g[S],{n:m[S]})).join(" · "),z=S=>!!a&&!!n&&!S.done&&vc.has(S.name),k=p.every(S=>S.done),y=p.some(S=>S.isError),N=new Set((s||[]).filter(S=>S.status==="pending"&&S.toolCallId).map(S=>S.toolCallId)),d=p.some(S=>S.parked),_=n?p.findIndex(S=>!S.done):-1,b=_>=0&&z(p[_]),C=!!n&&p.length>0&&!k&&!b,j=_>=0?f[_]:null,h=j?j.verbKey?o(j.verbKey):p[_].name:"";return e.jsxs(e.Fragment,{children:[!!p.length&&e.jsxs("div",{className:"tool-group",children:[e.jsxs("button",{className:"tool-group-head","aria-busy":C,onClick:()=>r(S=>!S),children:[i?e.jsx(it,{size:13}):e.jsx(we,{size:13}),e.jsx(Rr,{size:12,className:"tool-group-ic"}),!i&&b?e.jsx("span",{className:"tool-group-cur","data-waiting-you":"1",children:e.jsx("span",{className:"tool-group-cur-copy",children:o("tool.waitingYou")})}):!i&&j?e.jsx("span",{className:"tool-group-cur",children:e.jsxs("span",{className:"tool-group-cur-copy chat-run-shimmer-text",children:[h," ",e.jsx("span",{className:j.isFile?"file":void 0,children:j.target}),"…"]})}):e.jsx("span",{className:`tool-group-sum${C?" chat-run-shimmer-text":""}`,children:x}),e.jsx("span",{className:"tool-group-status",children:d?e.jsx(rn,{size:13,style:{color:p.some(S=>S.parked&&N.has(S.id))?"var(--accent-ink)":"var(--text-faint)"}}):k?y?e.jsx(Ft,{size:13,style:{color:"var(--danger)"}}):e.jsx(vn,{size:13,style:{color:"var(--green)"}}):null})]}),e.jsx($e,{open:i,children:e.jsx("div",{className:"tool-group-list",children:p.map((S,B)=>e.jsx(yc,{ev:S,desc:f[B],running:!!n,waiting:N.has(S.id),asking:z(S)},S.id))})})]}),!!u.length&&e.jsx("div",{className:"image-generation-jobs","aria-busy":"true",children:u.map(S=>e.jsx(fc,{},S.id))})]})};function jc(t){const[n,s]=c.useState({id:"",at:0,count:1/0}),a=t.revealAt||0,o=!!a&&Date.now()-a<2e3&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches,i=n.id===t.id&&n.at===a?n.count:o?0:1/0;if(c.useLayoutEffect(()=>{if(!o||!t.content)return;const u=Array.from(t.content),p=Math.min(900,Math.max(180,u.length*3)),f=performance.now();let m=0;const g=()=>{const w=Math.min(1,(performance.now()-f)/p);s({id:t.id,at:a,count:w===1?1/0:Math.ceil(u.length*w)}),w<1&&(m=requestAnimationFrame(g))};return m=requestAnimationFrame(g),()=>cancelAnimationFrame(m)},[t.id,a,t.content]),!Number.isFinite(i))return t;const r=Array.from(t.content).slice(0,i).join("");return{...t,content:r,segments:r?[{t:"text",text:r}]:[],teamDone:!1}}te({"plan.approveGo":{zh:"批准并开始执行",en:"Approve & start"},"plan.approveEditedGo":{zh:"按我改的批准并执行",en:"Approve my edits & start"},"plan.approveManual":{zh:"批准,手动开始",en:"Approve, start manually"},"plan.edit":{zh:"编辑计划",en:"Edit plan"},"plan.sendBack":{zh:"打回",en:"Request changes"},"plan.reject":{zh:"拒绝",en:"Reject"},"plan.feedbackPlaceholder":{zh:"要改哪里?(反馈会发给 Agent 重做计划)",en:"What should change? (sent to the agent to revise the plan)"},"plan.sendFeedback":{zh:"发送反馈",en:"Send feedback"},"plan.doneApproved":{zh:"已批准",en:"Approved"},"plan.doneRevised":{zh:"已批准(按你修订的版本)",en:"Approved (your revised version)"},"plan.doneRejected":{zh:"已打回:{answer}",en:"Sent back: {answer}"},"plan.pointer":{zh:"等你拍板 · 在输入框上方",en:"Waiting for your decision · above the input box"},"plan.decisionTitle":{zh:"计划等你拍板(正文见对话里的计划卡)",en:"The plan needs your decision (full text in the plan card above)"}});const ya=({req:t,onAnswer:n})=>{const{t:s}=V(),[a,o]=c.useState(""),i=t.status==="pending";return e.jsxs("div",{className:`inquiry-card${i?"":" resolved"}`,children:[e.jsxs("div",{className:"inquiry-q",children:[e.jsx(kn,{size:14}),t.question]}),i?e.jsxs(e.Fragment,{children:[t.options.length>0&&e.jsx("div",{className:"inquiry-opts",children:t.options.map((r,u)=>e.jsxs("button",{className:"btn ghost sm",style:{justifyContent:"flex-start"},onClick:()=>n(r),children:[u+1,". ",r]},u))}),e.jsxs("div",{className:"inquiry-input",children:[e.jsx("input",{type:"text",className:"inline-input",value:a,placeholder:t.options.length?s("inquiry.placeholderOrFree"):s("inquiry.placeholderAnswer"),onChange:r=>o(r.target.value),onKeyDown:r=>{r.key==="Enter"&&a.trim()&&!r.nativeEvent.isComposing&&(r.preventDefault(),n(a.trim()))}}),e.jsxs("button",{className:"btn primary sm",disabled:!a.trim(),onClick:()=>a.trim()&&n(a.trim()),children:[e.jsx(Ms,{size:12})," ",s("inquiry.answer")]})]})]}):e.jsx("div",{className:"inquiry-resolved",children:t.status==="answered"?s("inquiry.answered",{answer:t.answer??""}):s("inquiry.expired")})]})},ja="批准,自动开始执行",ba="批准,退出计划模式(手动开始)",bc="拒绝,保持计划模式",mn=`
|
|
38
|
-
<<<REVISED_PLAN>>>
|
|
39
|
-
`,kc=/^(批准|同意|approve|approved|ok|yes|y)[!!。.]?$/i;function Sc(t){const n=t.trim();return n===ja||n===ba||kc.test(n)}function Nc(t){const n=t.indexOf(mn);return n<0?{head:t.trim()}:{head:t.slice(0,n).trim(),revised:t.slice(n+mn.length).trim()}}const zc=({plan:t,req:n})=>{const{t:s}=V(),a=n?.status==="answered"?Nc(n.answer||""):null,o=a?.revised||t;return e.jsxs("div",{className:"plan-card",children:[e.jsxs("div",{className:"tg-card-title",children:["📋 ",s("inquiry.planProposal"),a&&e.jsx("span",{className:"plan-verdict",children:Sc(a.head)?a.revised?s("plan.doneRevised"):s("plan.doneApproved"):s("plan.doneRejected",{answer:a.head.slice(0,60)})}),n?.status==="expired"&&e.jsx("span",{className:"plan-verdict",children:s("inquiry.expired")})]}),e.jsx("div",{className:"plan-body",children:e.jsx(qe,{content:o})}),n?.status==="pending"&&e.jsxs("div",{className:"t2-dim t2-apv-pointer","data-plan-pointer":n.inquiryId,children:[e.jsx(It,{size:12})," ",s("plan.pointer")]})]})},Cc=({plan:t,req:n,busy:s,onAnswer:a})=>{const{t:o}=V(),[i,r]=c.useState(t),[u,p]=c.useState(!1),[f,m]=c.useState(""),[g,w]=c.useState(!1),x=n.status==="pending"&&!s,z=y=>{x&&a(y)},k=y=>{if(!x)return;const N=y?ja:ba,d=u&&i.trim()&&i!==t?i.trim():"";z(d?`${N}${mn}${d}`:N)};return e.jsxs("div",{className:"plan-decision","data-plan-decision":n.inquiryId,children:[e.jsxs("div",{className:"plan-decision-title",children:[e.jsx(It,{size:15})," ",o("plan.decisionTitle")]}),u&&e.jsx("textarea",{className:"approval-edit plan-edit",value:i,onChange:y=>r(y.target.value),spellCheck:!1,autoFocus:!0}),e.jsxs("div",{className:"approval-actions",children:[e.jsxs("button",{className:"btn primary sm",disabled:!x,onClick:()=>k(!0),children:[e.jsx(As,{size:13})," ",o(u&&i!==t?"plan.approveEditedGo":"plan.approveGo")]}),e.jsx("button",{className:"btn ghost sm",disabled:!x,onClick:()=>k(!1),children:o("plan.approveManual")}),e.jsxs("button",{className:"btn ghost sm",disabled:!x,onClick:()=>{p(y=>!y),r(t)},children:[e.jsx(at,{size:13})," ",o(u?"common.cancel":"plan.edit")]}),e.jsxs("button",{className:"btn ghost sm",disabled:!x,onClick:()=>w(y=>!y),children:[e.jsx(bn,{size:13})," ",o("plan.sendBack")]}),e.jsx("button",{className:"btn danger sm",disabled:!x,onClick:()=>z(bc),children:o("plan.reject")})]}),g&&e.jsxs("div",{className:"inquiry-input",children:[e.jsx("input",{type:"text",className:"inline-input",value:f,placeholder:o("plan.feedbackPlaceholder"),onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"&&f.trim()&&x&&!y.nativeEvent.isComposing&&(y.preventDefault(),z(f.trim()))}}),e.jsxs("button",{className:"btn primary sm",disabled:!f.trim()||!x,onClick:()=>f.trim()&&z(f.trim()),children:[e.jsx(Ms,{size:12})," ",o("plan.sendFeedback")]})]})]})},Ec=({todos:t})=>{const{t:n}=V(),s=t.filter(a=>a.status==="completed").length;return e.jsxs("div",{className:"todo-card",children:[e.jsxs("div",{className:"tg-card-title",children:["✓ ",n("inquiry.todoList")," ",e.jsxs("span",{className:"tg-count",children:["(",s,"/",t.length,")"]})]}),e.jsx("div",{className:"todo-rows",children:t.map((a,o)=>e.jsxs("div",{className:`todo-row ${a.status}`,children:[e.jsx("span",{className:`todo-mark ${a.status}`,children:a.status==="completed"?e.jsx(ll,{size:14}):a.status==="in_progress"?e.jsx(Oe,{size:14,className:"spin"}):e.jsx(Rs,{size:14})}),e.jsx("span",{className:"todo-text",children:a.content})]},o))})]})};function Tc(t,n,s){const a=x=>x.replace(/\\/g,"/"),o=a(t||"").replace(/\/+$/,""),i=a((n||"").trim());if(!o||!i)return null;const r=/^[a-zA-Z]:/.exec(o)?.[0]??"",p=/^([a-zA-Z]:)?\//.test(i)?i:`${o}/${i}`,f=/^[a-zA-Z]:/.exec(p)?.[0]??"",m=[];for(const x of p.slice(f.length).split("/"))if(!(!x||x===".")){if(x===".."){if(!m.length)return null;m.pop();continue}m.push(x)}const g=`${f}/${m.join("/")}`,w=x=>r?x.toLowerCase():x;return w(g)===w(o)?s?g:null:w(g).startsWith(`${w(o)}/`)?g:null}te({"creation.card.createTitle":{zh:"做成作品:{name}",en:"Make it a creation: {name}"},"creation.card.createBody":{zh:"在「造物」里给它建一个文件夹,把这条对话的工作目录切过去,接着在里面做。之后它会出现在造物里,有稳定的预览、桌面快捷方式和版本历史。",en:"Creates a folder for it in Creations, moves this conversation into that folder and keeps building there. It then shows up in Creations with a stable preview, a desktop shortcut and version history."},"creation.card.addTitle":{zh:"加入造物:{name}",en:"Add to Creations: {name}"},"creation.card.addBody":{zh:"把「{path}」原地加入造物,不复制也不移动。这条对话之后在它里面继续,它会出现在造物里,有稳定的预览和桌面快捷方式。",en:"Adds “{path}” to Creations where it is, without copying or moving it. This conversation continues in it, and it shows up in Creations with a stable preview and a desktop shortcut."},"creation.card.create":{zh:"做成作品",en:"Make it a creation"},"creation.card.add":{zh:"加入造物",en:"Add to Creations"},"creation.card.done":{zh:"已在造物里:{name}",en:"In Creations: {name}"},"creation.card.doneNewChat":{zh:"已在造物里建好「{name}」。这条对话没有挪过去,已切到在它里面新建对话。",en:"Created “{name}” in Creations. This conversation was not moved there, so a new conversation in it is ready."},"creation.card.openStudio":{zh:"在编码工作室中打开",en:"Open in Coding Studio"},"creation.card.openCreations":{zh:"在造物中查看",en:"View in Creations"},"creation.continuePrompt":{zh:"作品文件夹「{name}」已经建好,这条对话的工作目录已经切过去了。请在这里接着做。",en:"The creation folder “{name}” is ready and this conversation now works in it. Please continue building here."},"creation.err.running":{zh:"这条对话还在运行,等这一轮结束再点。",en:"This conversation is still running. Try again when this turn has finished."},"creation.err.outside":{zh:"卡片里的文件夹不在这条对话的工作目录里,不能从这里加入。",en:"The folder in this card is outside this conversation’s working folder, so it cannot be added from here."},"creation.err.invalid_source":{zh:"找不到要加入的文件夹。",en:"The folder to add was not found."},"creation.err.forbidden_source":{zh:"这个文件夹不能加入造物(比如家目录、造物自己的文件夹这类位置)。",en:"This folder cannot be added to Creations (for example your home folder or the Creations folder itself)."},"creation.err.nested":{zh:"这个文件夹在另一个造物里面,或者里面已经有造物了,不能再单独加入。",en:"This folder is inside another creation, or already contains one, so it cannot be added on its own."}});async function Rc(t,n,s){const a=await window.tangu.productsRegister(t,n,s);if(!a.ok)throw new Error(Ne(`creation.err.${a.code}`));return{dir:a.dir,name:a.name}}function Mc({cards:t,sessionId:n}){return!t.length||!window.tangu?.productsCreate||!window.tangu?.productsRegister?null:e.jsx("div",{className:"t2-tasks",children:t.map((s,a)=>e.jsx(Ac,{card:s,sessionId:n},`${a}:${s.name}:${s.path||""}`))})}function Ac({card:t,sessionId:n}){const{t:s}=V(),a=P(C=>n?C.sessions.find(j=>j.id===n):void 0),o=P(C=>n?C.configBySession[n]?.cwd:void 0),i=P(C=>C.defaultWsDir),r=o||a?.project_path||"",[u,p]=c.useState(!1);c.useEffect(()=>{let C=!0;return p(!1),r&&window.tangu?.productsIsCreation?.(r).then(j=>{C&&p(!!j)}).catch(()=>{}),()=>{C=!1}},[r]);const[f,m]=c.useState(!1),[g,w]=c.useState(""),[x,z]=c.useState(null),k=!!t.path,y=!!r&&xt(r)!==xt(i||""),N=k?Tc(r,t.path,y):null,d=x??(u?{dir:r,name:a?.project_name||t.name,moved:!0}:null),_=async()=>{const C=window.tangu;if(!C?.productsCreate||!C.productsRegister||f)return;if(m(!0),w(""),n&&(P.getState().runningBySession[n]||!Yo(n))){w(s("creation.err.running")),m(!1);return}let j=!1,h="";try{let S,B;if(k){if(!N)throw new Error(s("creation.err.outside"));({dir:S,name:B}=await Rc(N,r,!y))}else{const K=await C.productsCreate(t.name);S=K.dir,B=K.name}const J=P.getState();j=!!r&&xt(S)===xt(r)||(n?await J.moveSessionToProject(n,S,B)==="moved":!1),j||(J.setNewChatWs({key:S,name:B,kind:"local",path:S}),J.setActiveId(null)),z({dir:S,name:B,moved:j}),h=B}catch(S){w(String(S?.message||S))}finally{n&&Jo(n),m(!1)}j&&!k&&n&&P.getState().send(s("creation.continuePrompt",{name:h}),[],void 0,void 0,void 0,n)},b=()=>{d&&(en("coding"),requestAnimationFrame(()=>{on.getState().openProject(d.dir,d.name)}))};return e.jsxs("div",{className:`t2-taskcard t2-creationcard${d?" done":""}${f?" busy":""}`,"data-creation-card":k?"add":"create",children:[e.jsxs("div",{className:"t2-taskcard-head",children:[k?e.jsx(Vn,{size:13}):e.jsx(Ke,{size:13})," ",e.jsx("b",{children:s(k?"creation.card.addTitle":"creation.card.createTitle",{name:t.name})})]}),e.jsx("div",{className:"t2-taskcard-tldr",children:s(k?"creation.card.addBody":"creation.card.createBody",{path:t.path||""})}),d?e.jsxs("div",{className:"t2-taskcard-done","data-creation-done":!0,children:[s(d.moved?"creation.card.done":"creation.card.doneNewChat",{name:d.name}),e.jsxs("div",{className:"t2-taskcard-actions",children:[e.jsxs("button",{onClick:b,children:[e.jsx(Ct,{size:12})," ",s("creation.card.openStudio")]}),e.jsxs("button",{onClick:()=>en("artificial"),children:[e.jsx(Go,{size:12})," ",s("creation.card.openCreations")]})]})]}):k&&!N?e.jsx("div",{className:"t2-taskcard-done",role:"alert",children:s("creation.err.outside")}):e.jsx("div",{className:"t2-taskcard-actions",children:e.jsxs("button",{className:"primary",disabled:f,onClick:()=>{_()},"data-creation-accept":!0,children:[f?e.jsx(Oe,{size:12,className:"spin"}):k?e.jsx(Vn,{size:12}):e.jsx(Ke,{size:12})," ",s(k?"creation.card.add":"creation.card.create")]})}),g&&e.jsx("div",{className:"t2-taskcard-done",role:"alert","data-creation-error":!0,children:g})]})}const Qt=new Map,Xt=new Set;function Pc(t){let n=5381;for(let s=0;s<t.length;s++)n=(n<<5)+n+t.charCodeAt(s)|0;return(n>>>0).toString(36)}function Ic(t,n,s){return`${t}:${n}:${Pc(`${s.title}|${s.prompt}`)}`}function Dc({tasks:t,ownerId:n,onTask:s,noHere:a=!1,todoStatus:o,onTodoRetry:i}){const{t:r}=V(),[u,p]=c.useState({}),[f,m]=c.useState(null),[g,w]=c.useState({});return t.length?e.jsx("div",{className:"t2-tasks",children:t.map((x,z)=>{const k=Ic(n,z,x),y=u[k]??Qt.get(k),N=!y&&x.todo&&o?o[x.todo]??"checking":"pending",d=N!=="pending",_=f===k,b=!!g[k],C=!!window.tangu?.backendStatus,j=async D=>{if(_||y||d||Xt.has(k)||Qt.has(k))return;Xt.add(k),m(k);let q=!1;try{q=await s?.(x,D)!==!1}catch{q=!1}Xt.delete(k),m(E=>E===k?null:E),q&&(Qt.set(k,D),p(E=>({...E,[k]:D})))},h=(D,q,E,F=!1)=>e.jsxs("button",{className:F?"primary":"",disabled:_,onClick:()=>{j(D)},children:[q," ",E]},D),S=!!(x.track||x.todo)&&C,B=a?null:h("here",e.jsx(Ts,{size:12}),r("chat.task.here"),!S),J=h("new",e.jsx(Qs,{size:12}),r("chat.task.new"),a&&!S),L=C?h("muse",e.jsx(Ke,{size:12}),r(x.todo?"chat.task.museDo":"chat.task.muse"),S):null,K=y==="here"?"chat.task.doneHere":y==="new"?"chat.task.doneNew":y==="muse"?x.todo?"chat.task.doneMuseDo":"chat.task.doneMuse":"chat.task.doneIgnore";return e.jsxs("div",{className:`t2-taskcard${y||d?" done":""}${_?" busy":""}`,children:[e.jsxs("div",{className:"t2-taskcard-head",children:[e.jsx(It,{size:13})," ",e.jsx("b",{children:x.title}),x.track&&e.jsx("span",{className:"t2-taskcard-tag",children:r("chat.task.trackTag")})]}),x.tldr&&e.jsx("div",{className:"t2-taskcard-tldr",children:x.tldr}),e.jsxs("button",{className:"t2-taskcard-toggle",onClick:()=>w(D=>({...D,[k]:!b})),"aria-expanded":b,children:[b?e.jsx(it,{size:12}):e.jsx(we,{size:12})," ",r(b?"chat.task.hidePrompt":"chat.task.showPrompt")]}),b&&e.jsx("pre",{className:"t2-taskcard-prompt",children:x.prompt}),y?e.jsx("div",{className:"t2-taskcard-done",children:r(K)}):d?e.jsxs("div",{className:"t2-taskcard-done",children:[r(N==="checking"?"chat.task.todoChecking":N==="error"?"chat.task.todoCheckFail":N==="missing"?"chat.task.todoMissing":"chat.task.doneTodo"),N==="error"&&i&&e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{className:"t2-taskcard-toggle",onClick:i,children:r("inbox.approval.retry")})]})]}):e.jsxs("div",{className:"t2-taskcard-actions",children:[S?[L,B,J]:[B,J,L],h("ignore",e.jsx(Ye,{size:12}),r("chat.task.ignore"))]})]},k)})}):null}function ka(t){if(!t.planProposal)return;const n=(t.inquiries||[]).filter(s=>s.kind==="plan");return n.find(s=>s.status==="pending")||n[n.length-1]}function _c(t){const n=[];for(const s of t||[]){const a=s.work&&s.agentName?{agentName:s.agentName}:{};for(const i of s.approvals||[])i.status==="pending"&&n.push({kind:"approval",id:i.approvalId,messageId:s.id,req:i,...a});const o=ka(s);for(const i of s.inquiries||[])i.status==="pending"&&(i===o&&s.planProposal?n.push({kind:"plan",id:i.inquiryId,messageId:s.id,req:i,plan:s.planProposal,...a}):n.push({kind:"inquiry",id:i.inquiryId,messageId:s.id,req:i,...a}))}return n}const Sa="<approval_update>";function Fc(t){return[...t.matchAll(/^\[(approved|rejected|failed)\] (\S+) \(call ([^)]*)\) — (.*)$/gm)].map(n=>({status:n[1],name:n[2],callId:n[3],preview:n[4]}))}function $c(t,n){if(!n)return;let s;for(const a of t||[])for(const o of a.approvals||[])o.toolCallId===n&&(s=o);return s}te({"chat.team.working":{zh:"工作中 · {activity}",en:"Working · {activity}"},"chat.team.workingIdle":{zh:"工作中",en:"Working"},"chat.team.waiting":{zh:"等待你的审批",en:"Waiting for your approval"},"chat.team.waitingAnswer":{zh:"等你回答 · 在输入框上方",en:"Waiting for your answer · above the input box"},"chat.team.done":{zh:"已完成",en:"Done"},"chat.approval.pointer":{zh:"{name} 等你批准 · 在输入框上方",en:"{name} is waiting for your approval · above the input box"},"chat.approval.pointerN":{zh:"{n} 项操作等你批准 · 在输入框上方",en:"{n} actions are waiting for your approval · above the input box"},"chat.inquiry.pointer":{zh:"有问题等你回答 · 在输入框上方",en:"A question is waiting for your answer · above the input box"},"chat.inquiry.pointerN":{zh:"{n} 个问题等你回答 · 在输入框上方",en:"{n} questions are waiting for your answer · above the input box"},"chat.approval.update.approved":{zh:"已批准并执行 {name}",en:"Approved and ran {name}"},"chat.approval.update.failed":{zh:"已批准,{name} 执行出错",en:"Approved; {name} ran with an error"},"chat.approval.update.rejected":{zh:"已拒绝 {name}(没有执行)",en:"Rejected {name} (not run)"},"chat.approval.update.byApproved":{zh:"{where}批准",en:"Approved {where}"},"chat.approval.update.byRejected":{zh:"{where}拒绝",en:"Rejected {where}"}});const Lc={approved:"chat.approval.update.approved",failed:"chat.approval.update.failed",rejected:"chat.approval.update.rejected"};function qc(t,n){const s=new Map((n||[]).map(r=>[r.callId,r])),a=[];let o=[];const i=()=>{o.length&&a.push({t:"tools",events:o}),o=[]};for(const r of t){o.push(r);const u=s.get(r.id);u&&(i(),a.push({t:"sketch",item:u}))}return i(),a}function ss(t){const n=(t||"").trim();return n?Array.from(n)[0].toUpperCase():"?"}const Na=/provided authentication token is expired|try signing in again/i,Oc=[[Na,"chat.err.subExpired"],[/token_quota_exceeded/i,"chat.err.quota"],[/engine_unavailable_remote/i,"chat.err.engineRemote"],[/run_cost_exceeded/i,"chat.err.runCost"],[/input_too_large/i,"chat.err.inputTooLarge"],[/group_needs_2_agents/i,"chat.err.groupAgents"],[/^orphaned$|stale: process restarted/i,"chat.err.orphaned"],[/fetch failed|ECONNREFUSED|ENOTFOUND|EAI_AGAIN/i,"chat.err.network"],[/terminated|ECONNRESET|socket hang up|premature close/i,"chat.err.dropped"],[/ETIMEDOUT|timed? ?out/i,"chat.err.timeout"],[/(^|\D)(401|403)(\D|$)|unauthorized|invalid[ _-]?api[ _-]?key/i,"chat.err.auth"],[/(^|\D)429(\D|$)|rate[ _-]?limit|insufficient[ _-]?quota/i,"chat.err.rate"],[/(^|\D)5\d\d(\D|$)|bad gateway|overloaded/i,"chat.err.server"]];function za(t,n){if(!t)return n("chat.error");const s=Oc.find(([a])=>a.test(t));return s?`${n(s[1])}(${t})`:t}te({"chat.err.subExpired":{zh:"直连账号的登录已过期,需要重新登录",en:"Your direct-connection sign-in has expired — please sign in again"},"chat.err.relogin":{zh:"重新登录 {provider}",en:"Sign in to {provider} again"},"rewind.title":{zh:"回退到这条消息",en:"Rewind to this message"},"rewind.counting":{zh:"正在统计改动…",en:"Counting changes…"},"rewind.codeOnly":{zh:"仅回退代码({n} 个文件)",en:"Code only ({n} file(s))"},"rewind.convOnly":{zh:"仅回退对话(原文回输入框)",en:"Conversation only (prompt back in the box)"},"rewind.both":{zh:"代码 + 对话都回退",en:"Both code and conversation"},"rewind.scopeNote":{zh:"只覆盖 Agent 经内置写文件工具(write/edit/multi_edit/apply_patch)改过的文件;终端命令与插件/MCP 工具改的不在内。",en:"Covers only files changed through the built-in file-writing tools (write/edit/multi_edit/apply_patch); changes made by shell commands or plugin/MCP tools are not included."},"rewind.skippedNote":{zh:"另有 {n} 个文件当时太大未存快照,恢复不了。",en:"{n} file(s) were too large to snapshot and cannot be restored."},"rewind.keepNote":{zh:"Agent 新建、之后又被改动过的文件会原样保留,不会被删。",en:"Files the agent created that changed afterwards are kept as-is, never deleted."}});function Bc(t,n){if(!t||!Na.test(t))return null;const s=(n||"").split("/")[0];return s&&s in Ps?s:null}function Ca({error:t,modelId:n}){const{t:s}=V(),a=Bc(t,n);return!a||!window.tangu?.providerLogin?null:e.jsxs("button",{className:"t2-relogin",onClick:()=>P.getState().openSettings("model/m-providers"),children:[e.jsx(oi,{size:12})," ",s("chat.err.relogin",{provider:Ps[a]})]})}function Hc({reasoning:t}){const{t:n}=V(),[s,a]=c.useState(!1);return e.jsxs("div",{className:"t2-think",children:[e.jsxs("button",{className:"t2-think-head",onClick:()=>a(o=>!o),children:[s?e.jsx(it,{size:13}):e.jsx(we,{size:13})," ✦ ",n("thinking.process")," ",e.jsxs("span",{className:"t2-dim",children:["· ",n("thinking.charCount",{count:t.length})]})]}),e.jsx($e,{open:s,children:e.jsx("div",{className:"t2-think-body",children:t})})]})}function Ea(t,n){return!n?.sessionId||!t?Promise.resolve({files:0,skipped:0}):ii(de(n.sessionId),n.sessionId).then(s=>{const a=new Set,o=new Set;for(const i of s)i.at<t||(i.files.forEach(r=>a.add(r)),i.skipped.forEach(r=>o.add(r)));return o.forEach(i=>a.delete(i)),{files:a.size,skipped:o.size}}).catch(()=>({files:0,skipped:0}))}function Wc(t,n,s){const a=t?.files??0;return[{id:"code",label:t?n("rewind.codeOnly",{n:a}):n("rewind.counting"),icon:e.jsx(Wr,{size:14}),disabled:!a,run:()=>s("code")},{id:"conversation",label:n("rewind.convOnly"),icon:e.jsx(ri,{size:14}),run:()=>s("conversation")},{id:"both",label:n("rewind.both"),icon:e.jsx(zt,{size:14}),disabled:!a,run:()=>s("both")}]}function Vc(t,n,s,a,o,i,r=Ea){return!1}const Uc=({at:t,ctx:n,onPick:s})=>{const{t:a}=V(),[o,i]=c.useState(null),[r,u]=c.useState(!1),p=c.useRef(null),f=ai(!0,{boundary:".t2-chat-view"});return c.useEffect(()=>{let m=!0;return Ea(t,n).then(g=>{m&&i(g)}),()=>{m=!1}},[t,n?.sessionId,n?.cfg]),c.useLayoutEffect(()=>{const m=p.current;if(!m)return;const g=document.querySelector(".composer-anchor")?.getBoundingClientRect().top??window.innerHeight;m.getBoundingClientRect().bottom>g-4&&u(!0)},[o]),e.jsxs("div",{ref:m=>{p.current=m,f.ref.current=m},className:`composer-menu rewind-menu left${r?" up":""}`,style:f.style,children:[e.jsx("div",{className:"menu-section",children:a("rewind.title")}),Wc(o,a,s).map(m=>e.jsxs("button",{className:"menu-item",disabled:m.disabled,onClick:m.run,children:[m.icon,e.jsx("span",{className:"grow",children:m.label})]},m.id)),e.jsxs("div",{className:"menu-section rewind-note",children:[a("rewind.scopeNote")," ",a("rewind.keepNote"),!!o?.skipped&&e.jsxs(e.Fragment,{children:[" ",a("rewind.skippedNote",{n:o.skipped})]})]})]})};function Kc({sessionId:t,callId:n,status:s}){const{t:a}=V(),o=P(u=>t?$c(u.messagesBySession[t],n):void 0),i=ei(t);if(!o?.answeredBy)return null;const r=ti(o.answeredBy,{remotePage:uo(t),answeredHere:co(o.approvalId),hostName:i},a);return r?e.jsx("div",{className:"t2-apv-update-by","data-answered-by":!0,children:a(s==="rejected"?"chat.approval.update.byRejected":"chat.approval.update.byApproved",{where:r})}):null}function as({onInsert:t}){const{t:n}=V(),s=Jl();if(s==="hidden")return null;const a=s==="ready";return e.jsx("button",{className:"t2-iconbtn","data-act":"insert-note","aria-disabled":a?void 0:!0,title:n(a?"chat.action.insertNote":"chat.insertNote.none"),"aria-label":n("chat.action.insertNote"),onClick:t,children:e.jsx(Tr,{size:14})})}function Gc({msg:t,avatarUrl:n,agentNameFallback:s,userName:a,userAvatar:o,handlers:i,fileCtx:r,rootRef:u,speakState:p,voice:f,modelId:m,showWaitDetails:g=!1,footer:w}){const x=r?.sessionId,z=c.useMemo(()=>x?{cwd:P.getState().configBySession[x]?.cwd||P.getState().sessions.find(I=>I.id===x)?.project_path||void 0,onRun:I=>{P.getState().send(Qo(I),[],void 0,void 0,void 0,x)}}:void 0,[x]),k=r?.execMode,y=c.useMemo(()=>x&&tn!=="mobile"&&window.tangu?.readHostFile?{execMode:k}:void 0,[x,k]),{t:N}=V();t=jc(t);const[d,_]=c.useState(!1),[b,C]=c.useState(!1),[j,h]=c.useState(!1),S=c.useRef(null);if(c.useEffect(()=>()=>{S.current?.abort(),S.current=null},[t.id,x]),c.useEffect(()=>{if(!b)return;const I=Y=>{Y.target?.closest?.("[data-cmenu]")||C(!1)},O=Y=>{Y.key==="Escape"&&C(!1)};return document.addEventListener("mousedown",I),document.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("keydown",O)}},[b]),t.role==="system"){if(t.groupVote){const I=t.groupVote;return e.jsxs("div",{ref:u,className:"t2-sys",children:[e.jsx("span",{className:"t2-dim",children:N("group.vote.round",{round:I.round})})," ",e.jsx("b",{children:N("group.vote.tally",{end:I.endCount,total:I.total})})]})}return t.content?e.jsx("div",{ref:u,className:"t2-sys",children:t.content}):null}if(t.role==="user"){if(t.content.startsWith("<turn_interrupted>"))return e.jsxs("div",{ref:u,className:"t2-sys t2-interrupted",children:["⏹ ",N("msg.interrupted")]});if(t.content.startsWith(Sa)){const G=Fc(t.content);return e.jsx("div",{ref:u,className:"t2-sys t2-apv-update","data-approval-update":G.length,children:G.map(A=>e.jsxs(c.Fragment,{children:[e.jsxs("div",{className:"t2-apv-update-row","data-status":A.status,children:[A.status==="approved"?e.jsx(vn,{size:12}):e.jsx(Ft,{size:12}),e.jsx("span",{className:"t2-apv-update-what",children:N(Lc[A.status],{name:A.name})}),e.jsx("span",{className:"t2-apv-update-preview",title:A.preview,children:A.preview})]}),e.jsx(Kc,{sessionId:x,callId:A.callId,status:A.status})]},A.callId))})}const I=a||N("chat.you"),O=ro(t.content),Y=O?O.body.trim()||O.refs.map(G=>G.name).join(" "):t.content,ee=()=>{if(!b){S.current?.abort();const G=new AbortController;if(S.current=G,Vc(t.timestamp,r,N,A=>i?.onRewind?.(A),()=>C(!0),G.signal))return;S.current=null}C(G=>!G)},ce=G=>{[...i?.onCopy?[{label:N("chat.action.copy"),icon:e.jsx(ht,{size:14}),run:()=>i.onCopy?.(t.content)}]:[],...i?.onEdit?[{label:N("chat.action.edit"),icon:e.jsx(at,{size:14}),run:()=>i.onEdit?.()}]:[],...i?.onRewind?[{label:N("rewind.title"),icon:e.jsx(zt,{size:14}),run:ee}]:[]]};return e.jsxs("div",{ref:u,className:`t2-userwrap${j?" t2-userwrap--inline":""}`,id:`tocmsg-${t.id}`,"data-toc-msg-role":"user","data-toc-title":Y,children:[e.jsxs("div",{className:"t2-user-col",children:[e.jsx("div",{className:"t2-username",children:I}),e.jsxs("div",{className:"t2-user",onContextMenu:ce,children:[!!t.attachments?.length&&e.jsx("div",{className:"msg-attach-grid",children:t.attachments.map((G,A)=>G.mimeType?.startsWith("image/")&&G.data?e.jsx("img",{className:"msg-attach-img",src:`data:${G.mimeType};base64,${G.data}`,alt:G.name,title:G.name},`${G.name}-${A}`):e.jsxs("span",{className:"msg-attach-file",title:G.name,children:["📎 ",G.name]},`${G.name}-${A}`))}),O&&e.jsx("div",{className:"t2-user-refs",children:O.refs.map((G,A)=>e.jsx(lo,{chip:G,children:G.wiki?e.jsx(Xo,{inner:G.wiki}):void 0},`${G.token}-${A}`))}),O?O.body&&e.jsx(_n,{text:O.body}):e.jsx(_n,{text:t.content})]}),e.jsxs("div",{className:"t2-actions",children:[e.jsx(os,{at:t.timestamp}),e.jsx("button",{className:"t2-iconbtn",title:N("chat.action.copy"),onClick:()=>i?.onCopy?.(t.content),children:e.jsx(ht,{size:14})}),e.jsx("button",{className:"t2-iconbtn",title:N("chat.action.edit"),onClick:()=>i?.onEdit?.(),children:e.jsx(at,{size:14})}),i?.onRewind&&e.jsxs("span",{style:{position:"relative",display:"inline-flex"},"data-cmenu":!0,children:[e.jsx("button",{className:"t2-iconbtn","data-act":"rewind",title:N("rewind.title"),onClick:ee,children:e.jsx(zt,{size:14})}),b&&e.jsx(Uc,{at:t.timestamp,ctx:r,onPick:G=>{C(!1),i.onRewind?.(G)}})]})]})]}),e.jsx("div",{className:"t2-avatar t2-user-avatar",style:o?void 0:{background:"color-mix(in srgb, var(--text-muted) 22%, transparent)"},children:o?e.jsx("img",{src:o,alt:""}):ss(I)})]})}const B=t.status==="streaming",J=window.tangu?.productsRegister?["suggest","task","creation"]:["suggest","task"],{text:L,items:K,tasks:D,creations:q}=Fn(t.content,{streaming:B,kinds:J}),E=i?.onInsertNote?I=>e.jsx(as,{onInsert:()=>i.onInsertNote?.(Er(I.html))}):void 0,F=ka(t),W=(t.approvals||[]).filter(I=>I.status==="pending"),X=(t.inquiries||[]).filter(I=>I!==F&&I.status==="pending"),ae=X.length>0||F?.status==="pending",Q=!!f?.on&&(t.status==="done"||t.status==="stopped"),H=new Set((t.sketches||[]).map(I=>I.callId)),le=new Set;if(!Q){for(const I of t.segments||[])if(I.t==="tools")for(const O of I.ids)H.has(O)&&le.add(O)}const ne=(t.sketches||[]).filter(I=>!le.has(I.callId));return e.jsxs("div",{ref:u,className:"t2-asst",id:`tocmsg-${t.id}`,children:[e.jsx("div",{className:"t2-avatar",style:!n&&t.agentColor?{background:t.agentColor,color:"#fff"}:void 0,children:n?e.jsx("img",{src:n,alt:""}):ss(t.agentName||s||"Tangu")}),e.jsxs("div",{className:"t2-asst-col",children:[e.jsxs("div",{className:"t2-name",style:t.agentColor?{color:t.agentColor}:void 0,children:[t.agentName||s||"Tangu",t.status==="streaming"&&e.jsx("span",{className:"t2-dot"})]}),t.systemPrompt&&e.jsx(lc,{content:t.systemPrompt}),t.reasoning&&e.jsx(Hc,{reasoning:t.reasoning}),(()=>{if(t.segments?.length&&!Q){let I;const O=t.segments.reduce((Y,ee,ce)=>ee.t==="text"?ce:Y,-1);return t.segments.map((Y,ee)=>{if(Y.t==="text"){const A=Fn(Y.text,{streaming:B||ee!==O,state:I,kinds:J});I=A.state;const fe=A.text;return fe?e.jsx("div",{className:"t2-content",children:e.jsx(qe,{content:fe,anchorPrefix:`toc-${t.id}`,run:z,embeds:y})},ee):null}const ce=Y.ids.map(A=>t.toolEvents?.find(fe=>fe.id===A)).filter(Boolean),G=qc(ce,t.sketches);return G.length?e.jsx(c.Fragment,{children:G.map((A,fe)=>A.t==="tools"?e.jsx(ns,{events:A.events,running:t.status==="streaming",approvals:t.approvals,awaitingAnswer:ae},`tools-${A.events.map(he=>he.id).join("-")}-${fe}`):e.jsx(Wn,{items:[A.item],actions:E,stateScope:x?`${x}:${t.id}`:void 0},`sketch-${A.item.callId}`))},ee):null})}return e.jsxs(e.Fragment,{children:[!!t.toolEvents?.length&&e.jsx(ns,{events:t.toolEvents,running:t.status==="streaming",approvals:t.approvals,awaitingAnswer:ae}),L&&(Q?e.jsx(rc,{text:L,stored:f.stored,anchorPrefix:`toc-${t.id}`}):e.jsx("div",{className:"t2-content",children:e.jsx(qe,{content:L,anchorPrefix:`toc-${t.id}`,run:z,embeds:y})}))]})})(),!!K.length&&t.status==="done"&&e.jsx("div",{className:"t2-suggest",children:K.map((I,O)=>e.jsxs("button",{className:"t2-suggest-chip",disabled:d,onClick:()=>{_(!0),i?.onSuggest?.(I)},children:[e.jsx(Zo,{size:13})," ",I]},O))}),!!D.length&&t.status==="done"&&e.jsx(Dc,{tasks:D,ownerId:t.id,onTask:i?.onTask}),!!q.length&&t.status==="done"&&e.jsx(Mc,{cards:q,sessionId:x}),r&&e.jsx(tc,{changes:ec(t.toolEvents),cfg:r.cfg,sessionId:r.sessionId}),r&&e.jsx(ic,{changes:ac(t.toolEvents),sessionId:r.sessionId}),t.planProposal&&e.jsx(zc,{plan:t.planProposal,req:F},F?.inquiryId||"plan"),!!t.todos?.length&&e.jsx(Ec,{todos:t.todos}),g&&t.status==="streaming"&&t.live&&e.jsx(Jc,{live:t.live}),t.status==="streaming"&&t.work&&e.jsx("div",{className:"t2-dim chat-thinking-live",role:"status","aria-live":"polite","data-team-work":t.work.waiting?"waiting":"working",children:e.jsx("span",{className:t.work.waiting?void 0:"chat-run-shimmer-text",children:t.work.waiting?N(!W.length&&ae?"chat.team.waitingAnswer":"chat.team.waiting"):t.work.activity?N("chat.team.working",{activity:t.work.activity}):N("chat.team.workingIdle")})}),!L&&t.status==="streaming"&&!t.work&&!t.toolEvents?.length&&!t.reasoning&&(!t.live||!g)&&e.jsx("div",{className:"t2-dim chat-thinking-live chat-run-shimmer-text",role:"status","aria-live":"polite",children:N("chat.thinking")}),t.teamDone&&t.status!=="streaming"&&e.jsxs("div",{className:"t2-dim t2-team-done","data-team-done":"1",children:["✓ ",N("chat.team.done")]}),!!t.displayFiles?.length&&r&&e.jsx(kr,{files:t.displayFiles,cfg:r.cfg,sessionId:r.sessionId,execMode:r.execMode,onOpenPreview:r.onOpenPreview}),!!ne.length&&e.jsx(Wn,{items:ne,actions:E,stateScope:x?`${x}:${t.id}`:void 0}),!t.work&&W.length>0&&e.jsxs("div",{className:"t2-dim t2-apv-pointer","data-approval-pointer":W.length,children:[e.jsx(js,{size:12}),W.length===1?N("chat.approval.pointer",{name:W[0].name}):N("chat.approval.pointerN",{n:W.length})]}),!t.work&&X.length>0&&e.jsxs("div",{className:"t2-dim t2-apv-pointer","data-inquiry-pointer":X.length,children:[e.jsx(kn,{size:12}),X.length===1?N("chat.inquiry.pointer"):N("chat.inquiry.pointerN",{n:X.length})]}),t.inquiries?.filter(I=>I!==F&&I.status!=="pending").map(I=>e.jsx(ya,{req:I,onAnswer:()=>{}},I.inquiryId)),t.status==="error"&&e.jsxs("div",{className:"t2-tool err",children:[e.jsxs("span",{className:"t2-status-err",children:["✕ ",za(t.error,N)]}),e.jsx(Ca,{error:t.error,modelId:m})]}),t.status==="stopped"&&e.jsxs("div",{className:"t2-dim",children:["⏹ ",N("chat.aborted")]}),w,(t.status==="done"||t.status==="stopped")&&e.jsxs("div",{className:"t2-actions",children:[e.jsx("button",{className:"t2-iconbtn",title:N("chat.action.copy"),onClick:()=>i?.onCopy?.(L),children:e.jsx(ht,{size:14})}),i?.onSpeak&&!!L&&e.jsx("button",{className:"t2-iconbtn",title:N(p?"chat.action.stopSpeak":"chat.action.speak"),onClick:()=>i.onSpeak?.(L),children:p==="loading"?e.jsx(Oe,{size:14,className:"spin"}):p==="playing"?e.jsx(Rs,{size:14}):e.jsx(fl,{size:14})}),i?.onInsertNote&&!!L&&e.jsx(as,{onInsert:()=>i.onInsertNote?.(L)}),e.jsx("button",{className:"t2-iconbtn",title:N("chat.action.regenerate"),onClick:()=>i?.onRegenerate?.(),children:e.jsx($t,{size:14})}),e.jsx("button",{className:"t2-iconbtn",title:N("chat.action.branch"),onClick:()=>i?.onBranch?.(),children:e.jsx(Jr,{size:14})}),e.jsx(os,{at:t.timestamp})]})]})]})}function os({at:t}){return t>0?e.jsx("span",{className:"t2-msgtime",title:si(t,{year:"always"}),children:ni(t)}):null}function Yc(t){const[n,s]=c.useState(Date.now());return c.useEffect(()=>{s(Date.now());const a=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(a)},[t]),Math.max(0,Math.floor((n-t)/1e3))}function Jc({live:t}){const{t:n}=V(),s=Yc(t.since),a=Math.max(1,Math.round((t.bytes||0)/1024)),o=t.phase==="sending"&&t.bytes?n("chat.wait.sending",{kb:a}):n("chat.wait.firstToken");return e.jsxs("div",{className:"t2-dim chat-thinking-live",role:"status","aria-live":"polite",children:[e.jsx("span",{className:"chat-run-shimmer-text",children:o}),s>=2&&e.jsxs("span",{className:"chat-wait-elapsed",children:[" · ",n("chat.wait.elapsed",{s})]})]})}te({"approval.tray.title":{zh:"等你批准 · {n}",en:"Waiting for your approval · {n}"},"approval.tray.titleAny":{zh:"等你处理 · {n}",en:"Waiting for you · {n}"},"approval.tray.label":{zh:"等你处理的事项",en:"Items waiting for you"},"approval.tray.planRow":{zh:"计划等你拍板",en:"Plan waiting for your decision"}});const Qc=350;function Xc({items:t,onDecide:n,onAnswer:s,sessionId:a}){const{t:o}=V(),[i,r]=c.useState(null),[u,p]=c.useState(!1),f=t.find(d=>d.id===i)??t[0],m=f?.id;c.useEffect(()=>{m&&m!==i&&r(m)},[m,i]);const[g,w]=c.useState(void 0);c.useEffect(()=>{const d=setTimeout(()=>w(m),Qc);return()=>clearTimeout(d)},[m]);const x=c.useRef(new Set),[,z]=c.useState(0);c.useEffect(()=>{for(const d of x.current)t.some(_=>_.id===d)||x.current.delete(d)},[t]);const k=(d,_)=>{if(g!==d||x.current.has(d))return;x.current.add(d),z(C=>C+1);const b=()=>{x.current.delete(d),z(C=>C+1)};Promise.resolve().then(_).then(C=>{C===!1&&b()},b)};if(!f)return null;const y=x.current.has(f.id),N=t.every(d=>d.kind==="approval")?"approval.tray.title":"approval.tray.titleAny";return e.jsxs("div",{className:"t2c-apv",role:"region","aria-label":o("approval.tray.label"),"data-approval-tray":t.length,children:[e.jsxs("button",{type:"button",className:"t2c-apv-head","aria-expanded":!u,onClick:()=>p(d=>!d),children:[e.jsx(js,{size:13,className:"t2c-apv-ic"}),e.jsx("span",{className:"t2c-apv-title",children:o(N,{n:t.length})}),e.jsx(it,{size:13,className:`t2c-apv-chev${u?" is-collapsed":""}`})]}),!u&&t.length>1&&e.jsx("div",{className:"t2c-apv-rest",children:t.filter(d=>d!==f).map(d=>e.jsxs("button",{type:"button",className:"t2c-apv-row","data-tray-kind":d.kind,"data-tray-msg":d.messageId,title:is(d,o),onClick:()=>r(d.id),children:[d.agentName&&e.jsx("span",{className:"t2c-apv-row-from",children:d.agentName}),d.kind==="approval"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"t2c-apv-row-name",children:d.req.name}),e.jsx("span",{className:"t2c-apv-row-preview",children:d.req.preview})]}):e.jsxs(e.Fragment,{children:[d.kind==="plan"?e.jsx(It,{size:12,className:"t2c-apv-row-ic"}):e.jsx(kn,{size:12,className:"t2c-apv-row-ic"}),e.jsx("span",{className:"t2c-apv-row-text",children:is(d,o)})]})]},d.id))}),!u&&e.jsxs("div",{className:`t2c-apv-body${g===m?"":" is-arming"}${y?" is-sent":""}`,"data-tray-kind":f.kind,"data-tray-msg":f.messageId,children:[f.agentName&&e.jsx("div",{className:"t2c-apv-from",children:f.agentName}),f.kind==="approval"?e.jsx(ho,{req:f.req,sessionId:a,onDecide:(d,_)=>k(f.id,()=>n(f.messageId,f.id,d,_))},f.id):f.kind==="plan"?e.jsx(Cc,{plan:f.plan,req:f.req,busy:y,onAnswer:d=>k(f.id,()=>s(f.messageId,f.id,d))},f.id):e.jsx(ya,{req:f.req,onAnswer:d=>k(f.id,()=>s(f.messageId,f.id,d))},f.id)]})]})}function is(t,n){return t.kind==="approval"?t.req.preview:t.kind==="plan"?n("approval.tray.planRow"):t.req.question}te({"chat.runStats.tokens":{zh:"{n} tokens",en:"{n} tokens"},"chat.runStats.thinking":{zh:"思考中 {t}",en:"Thinking {t}"},"chat.runStats.thought":{zh:"思考 {t}",en:"Thought for {t}"}});const rs=t=>{const n=Math.max(0,Math.floor(t/1e3));return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m ${n%60}s`:`${Math.floor(n/3600)}h ${String(Math.floor(n/60)%60).padStart(2,"0")}m`};function ls({stats:t}){const{t:n}=V(),s=t.finishedAt==null,[a,o]=c.useState(Date.now);c.useEffect(()=>{if(!s)return;o(Date.now());const p=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(p)},[s]);const i=t.finishedAt??a,r=t.thinkMs+(t.thinkSince!=null?Math.max(0,i-t.thinkSince):0),u=[rs(i-t.startedAt)];return t.tokens>0&&u.push(n("chat.runStats.tokens",{n:po(t.tokens)})),t.thinkTracked&&r>=1e3&&u.push(n(t.thinkSince!=null?"chat.runStats.thinking":"chat.runStats.thought",{t:rs(r)})),e.jsx("div",{className:"t2-dim t2-runstats","data-run-stats":s?"live":"done",children:u.join(" · ")})}function Zc({title:t,subtitle:n,compact:s=!1}){const{t:a}=V(),o=c.useRef(null);return c.useLayoutEffect(()=>{const i=o.current,r=i?.parentElement;if(!i||!r?.classList.contains("t2-chat-col"))return;const u=r.querySelector(":scope > .composer-anchor");if(!u)return;const p=()=>{i.style.bottom="auto";const m=Math.max(0,r.clientHeight-u.offsetHeight-40),g=m<100?["minimal"]:m<200?["compact","minimal"]:["full","compact","minimal"];let w=0;for(const x of g)if(i.dataset.density=x,w=i.offsetHeight,w<=m)break;i.style.visibility=w>m?"hidden":"",i.style.top=`${Math.max(16,Math.min((r.clientHeight-w)/2,16+m-w))}px`};p();const f=new ResizeObserver(p);return f.observe(r),f.observe(u),f.observe(i),()=>f.disconnect()},[]),e.jsx("div",{className:"t2-empty",ref:o,children:s?t:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"t2-empty-mark",children:e.jsx(li,{size:64})}),e.jsx("div",{className:"t2-empty-title",children:t||a("chat.emptyTitle")}),e.jsx("div",{className:"t2-empty-sub",children:n||a("chat.emptyHint")})]})})}te({"ftoc.label":{zh:"目录",en:"Table of contents"}});const ed=t=>{if(t.dataset.tocMsgRole==="user"){const s=(t.dataset.tocTitle||t.textContent||"").trim();return s?{text:s,level:0,primary:!0}:null}const n=(t.textContent||"").trim();return!n||!t.dataset.tocLevel?null:{text:n,level:Number(t.dataset.tocLevel)||1}};function td({scrollContainerRef:t,scanTrigger:n}){const{t:s}=V();return e.jsx(Ar,{scrollContainer:t,selector:"[data-toc-msg-role='user'], [data-toc-level]",itemFromElement:ed,label:s("ftoc.label"),scanTrigger:n})}const nd={read_file:"file",read_document:"file",read_log:"file",view_image:"file",list_dir:"dir",list_files:"dir",search_files:"search",glob_files:"search",web_search:"search",web_fetch:"web"},sd=new Set(["write_file","edit_file","multi_edit"]),ad=/^\*\*\* (?:Add|Update) File: (.+)$/gm,od=/^([/~]|[A-Za-z]:[\\/])/,Ta=t=>t.split(/[/\\]/).filter(Boolean).pop()||t,id=t=>{try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}},fn=(t,n)=>!n||od.test(t)?t:n.replace(/[/\\]+$/,"")+"/"+t,Ra=t=>!!t.done&&!t.isError;function Ma(t){try{return t.arguments?JSON.parse(t.arguments):{}}catch{return null}}function rd(t,n){if(!Ra(t))return null;const s=nd[t.name]||(t.name.startsWith("browser_")?"web":null);if(!s)return null;const a=Ma(t);if(!a)return null;const o=s==="web"?a.url:s==="search"?a.query??a.pattern??a.glob:a.path;let i=typeof o=="string"?o.trim():"";return i?((s==="file"||s==="dir")&&(i=fn(i,n)),{kind:s,id:i,label:s==="web"?id(i):s==="search"?i:Ta(i),hits:1}):null}function ld(t,n){if(!Ra(t))return[];const s=Ma(t);if(!s)return[];if(sd.has(t.name)){const o=typeof s.path=="string"?s.path.trim():"";return o?[fn(o,n)]:[]}return t.name!=="apply_patch"?[]:[...(typeof s.patch=="string"?s.patch:typeof s.input=="string"?s.input:"").matchAll(ad)].map(o=>fn(o[1].trim(),n)).filter(Boolean)}function cd(t,n,s){const a=[],o=new Map,i=new Map;let r=[],u=null,p=null,f=null,m=!1;for(const g of t){g.role==="user"&&(p=g.timestamp,u=null);for(const w of g.approvals||[])w.status==="pending"&&a.push({kind:"approval",text:w.name});for(const w of g.inquiries||[])w.status==="pending"&&a.push({kind:"inquiry",text:w.question});g.todos&&(r=g.todos);for(const w of g.displayFiles||[]){const x=w.path||w.name;i.delete(x),i.set(x,w)}for(const w of g.toolEvents||[]){w.done||(u=w);for(const y of ld(w,s)){const N=i.get(y);i.delete(y),i.set(y,N||{name:Ta(y),path:y})}const x=rd(w,s);if(!x)continue;const z=`${x.kind}:${x.id}`,k=o.get(z);k&&(k.hits++,o.delete(z)),o.set(z,k||x)}g.role==="assistant"&&(f=g.status==="error"?g.error||"":null,m=g.status==="stopped")}return{state:a.length?"attention":n?"running":f!==null?"error":m?"stopped":t.length?"done":"idle",attention:a,todos:r,action:n?u:null,sources:[...o.values()].reverse(),outputs:[...i.values()].reverse(),startedAt:p,error:f}}const cs=t=>t.state!=="idle";te({"tsum.title":{zh:"任务概览",en:"Task overview"},"tsum.state.running":{zh:"正在运行",en:"Running"},"tsum.state.attention":{zh:"等待你处理",en:"Waiting for you"},"tsum.state.error":{zh:"已失败",en:"Failed"},"tsum.state.stopped":{zh:"已停止",en:"Stopped"},"tsum.state.done":{zh:"已完成",en:"Done"},"tsum.elapsed":{zh:"已运行 {t}",en:"Running {t}"},"tsum.attention.approval":{zh:"需要批准:{name}",en:"Approval needed: {name}"},"tsum.attention.inquiry":{zh:"需要你回答",en:"Needs your answer"},"tsum.plan":{zh:"计划",en:"Plan"},"tsum.scope":{zh:"工作范围",en:"Scope"},"tsum.scope.default":{zh:"默认目录",en:"Default folder"},"tsum.scope.add":{zh:"添加工作文件夹",en:"Add working folder"},"tsum.scope.remove":{zh:"移出工作范围",en:"Remove from scope"},"tsum.scope.hint":{zh:"加进来的文件夹 Agent 可直接读写、不再逐次弹审批;相对路径仍只相对默认目录解析。",en:"Added folders are readable/writable without per-call approval; relative paths still resolve against the default folder."},"tsum.sources":{zh:"来源",en:"Sources"},"tsum.outputs":{zh:"产物",en:"Outputs"},"tsum.openFile":{zh:"打开",en:"Open"},"tsum.openWeb":{zh:"在浏览器中打开",en:"Open in browser"},"tsum.editing":{zh:"正在编辑",en:"Editing"},"tsum.editingTip":{zh:"在 Agent Desk 中查看",en:"Show in Agent Desk"},"tsum.viewAll":{zh:"显示全部 {n} 项",en:"View all {n}"}});const dd={file:gn,dir:st,web:hi,search:ui},ds=3;function yt({title:t,count:n,action:s,items:a,children:o}){const{t:i}=V(),[r,u]=c.useState(!0),[p,f]=c.useState(!1);return e.jsxs("details",{className:"t2-tsum-sec",open:r,onToggle:m=>{const g=m.currentTarget.open;u(g),g||f(!1)},children:[e.jsxs("summary",{className:"t2-tsum-sectitle",children:[e.jsx("span",{children:t}),n!==void 0&&e.jsx("span",{className:"t2-tsum-count",children:n}),s&&e.jsx("button",{type:"button",className:"t2-tsum-secact",title:s.label,"aria-label":s.label,onClick:m=>{m.preventDefault(),m.stopPropagation(),s.run()},children:s.icon}),e.jsx(we,{size:12,className:"t2-tsum-chev"})]}),a?e.jsxs("div",{className:"t2-tsum-scroll",children:[p?a:a.slice(0,ds),!p&&a.length>ds&&e.jsx("button",{type:"button",className:"t2-tsum-more",onClick:()=>f(!0),children:i("tsum.viewAll",{n:a.length})})]}):o]})}const ud=t=>{const n=Math.floor(t/1e3);return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`},jt=t=>t.split(/[/\\]/).filter(Boolean).pop()||t;function hd({messages:t,running:n,cwd:s,hostCwd:a,onJumpToAttention:o,onShowEditing:i,onOpenFile:r,extraRoots:u=[],lockedRoots:p=[],onAddRoot:f,onRemoveRoot:m,modelId:g,teamStatus:w}){const{t:x}=V(),z=c.useMemo(()=>cd(t,n,a),[t,n,a]),k=c.useMemo(()=>n&&i?ci(t,s):null,[t,n,s,i]),[y,N]=c.useState(()=>Date.now());c.useEffect(()=>{if(!n)return;N(Date.now());const j=window.setInterval(()=>N(Date.now()),1e3);return()=>window.clearInterval(j)},[n]);const d=n&&z.startedAt?y-z.startedAt:0,_=z.todos.filter(j=>j.status==="completed").length,b=z.action?wa(z.action):null,C=z.state==="attention"?sa:z.state==="error"?Ft:z.state==="stopped"?Br:z.state==="running"?null:vn;return e.jsx("aside",{className:`t2-tsum${cs(z)||w?" show":""}`,"aria-hidden":!cs(z)&&!w,"aria-busy":z.state==="running","aria-label":x("tsum.title"),children:e.jsxs("div",{className:"t2-tsum-in",children:[!((z.state==="idle"||z.state==="done")&&!t.some(j=>j.role==="assistant"))&&e.jsxs("div",{className:`t2-tsum-state ${z.state}`,role:"status","aria-live":"polite",children:[C&&e.jsx(C,{size:14}),e.jsx("span",{className:`t2-tsum-state-tx${z.state==="running"?" chat-run-shimmer-text":""}`,children:x(`tsum.state.${z.state==="idle"?"done":z.state}`)}),z.todos.length>0&&e.jsxs("span",{className:"t2-tsum-count",children:[_,"/",z.todos.length]})]}),w,d>=3e4&&e.jsx("div",{className:"t2-tsum-sub",children:x("tsum.elapsed",{t:ud(d)})}),b&&e.jsxs("div",{className:"t2-tsum-sub",title:b.target,children:[b.verbKey?x(b.verbKey):z.action.name," ",b.target]}),k&&i&&e.jsxs("button",{className:"t2-tsum-edit",title:`${x("tsum.editingTip")}:${k.path}`,onClick:()=>i(k.path),children:[e.jsx(at,{size:11}),e.jsxs("span",{className:"t2-tsum-edit-tx",children:[x("tsum.editing")," ",k.name]})]}),z.state==="error"&&z.error&&e.jsx("div",{className:"t2-tsum-sub err",title:z.error,children:za(z.error,x)}),z.state==="error"&&e.jsx(Ca,{error:z.error??void 0,modelId:g}),z.attention.length>0&&e.jsxs("button",{className:"t2-tsum-attn",onClick:o,children:[z.attention[0].kind==="approval"?x("tsum.attention.approval",{name:z.attention[0].text}):x("tsum.attention.inquiry"),z.attention.length>1&&e.jsxs("span",{className:"t2-tsum-count",children:["+",z.attention.length-1]})]}),z.todos.length>0&&e.jsx(yt,{title:x("tsum.plan"),items:z.todos.map((j,h)=>e.jsxs("div",{className:`t2-tsum-todo ${j.status}`,children:[e.jsx("span",{className:"t2-tsum-todo-mark",children:j.status==="completed"?"✓":j.status==="in_progress"?"●":"○"}),e.jsx("span",{className:"t2-tsum-todo-tx",children:j.content})]},h))}),s&&e.jsx(yt,{title:x("tsum.scope"),action:f?{icon:e.jsx(di,{size:13}),label:`${x("tsum.scope.add")} — ${x("tsum.scope.hint")}`,run:f}:void 0,items:[e.jsxs("div",{className:"t2-tsum-row",title:`${x("tsum.scope.default")}:${s}`,children:[e.jsx(st,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:jt(s)}),e.jsx("span",{className:"t2-tsum-hits",children:x("tsum.scope.default")})]},"__cwd"),...u.map(j=>e.jsxs("div",{className:"t2-tsum-row t2-tsum-root",title:j,children:[e.jsx(st,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:jt(j)}),m&&!p.includes(j)&&e.jsx("button",{type:"button",className:"t2-tsum-x",title:x("tsum.scope.remove"),"aria-label":`${x("tsum.scope.remove")}:${jt(j)}`,onClick:()=>m(j),children:e.jsx(Ye,{size:12})})]},j))]}),z.sources.length>0&&e.jsx(yt,{title:x("tsum.sources"),count:z.sources.length,items:z.sources.map(j=>{const h=dd[j.kind],S=`${j.kind}:${j.id}`,B=e.jsxs(e.Fragment,{children:[e.jsx(h,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:j.label}),j.hits>1&&e.jsxs("span",{className:"t2-tsum-hits",children:["×",j.hits]})]});return j.kind==="web"?e.jsx(pi,{className:"t2-tsum-row act",href:j.id,quote:"",title:`${x("tsum.openWeb")}:${j.id}`,children:B},S):j.kind!=="file"||!r?e.jsx("div",{className:"t2-tsum-row",title:j.id,children:B},S):e.jsx("button",{type:"button",className:"t2-tsum-row act",title:j.id,"aria-label":`${x("tsum.openFile")}:${j.label}`,onClick:()=>r({name:j.label,path:j.id}),children:B},S)})}),z.outputs.length>0&&e.jsx(yt,{title:x("tsum.outputs"),count:z.outputs.length,items:z.outputs.map(j=>{const h=jt(j.name||j.path||""),S=e.jsxs(e.Fragment,{children:[e.jsx(gn,{size:14}),e.jsx("span",{className:"t2-tsum-row-tx",children:h})]});return r?e.jsx("button",{type:"button",className:"t2-tsum-row act",title:j.path||j.name,"aria-label":`${x("tsum.openFile")}:${h}`,onClick:()=>r(j),children:S},j.path||j.name):e.jsx("div",{className:"t2-tsum-row",title:j.path||j.name,children:S},j.path||j.name)})})]})})}te({"panel.files.showAllWs":{zh:"显示全部项目",en:"Show all projects"},"panel.files.sessionFiles":{zh:"本会话的文件",en:"Session files"},"panel.files.sessionEmpty":{zh:"还没有附件或产物",en:"No attachments or outputs yet"}});const Aa=t=>[...t].sort((n,s)=>n.isDir===s.isDir?n.name.localeCompare(s.name):n.isDir?-1:1),Ue=t=>t.slice(0,Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"))),pd=t=>!!t&&t.length<256&&!/[\\/]/.test(t)&&!t.includes("\0")&&t!=="."&&t!=="..",Me=()=>!!window.tangu?.mkdirHost,us=()=>!!window.tangu?.revealHostPath,gt=new EventTarget,Te=t=>{gt.dispatchEvent(new CustomEvent("fs-bump",{detail:t}))};function Tt({initial:t,depth:n,onCommit:s,onCancel:a}){const[o,i]=c.useState(t),r=c.useRef(!1),u=()=>{r.current||(r.current=!0,s(o.trim()))};return e.jsx("input",{className:"t2sf-input",style:{marginLeft:_t(n+1)},value:o,autoFocus:!0,spellCheck:!1,onFocus:p=>p.currentTarget.select(),onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Enter"?u():p.key==="Escape"&&(r.current=!0,a())},onBlur:u})}function Pa({entry:t,depth:n,ctx:s}){const a=Rt(Mt(t.path)||"",t.path);return s.renaming===t.path?e.jsx(Tt,{initial:t.name,depth:n,onCommit:o=>s.commitRename(t,o),onCancel:s.cancelEdit}):e.jsxs("div",{className:`t2sf-row t2sf-file${s.isSel(t.path)?" sel":""}`,"data-sel-id":t.path,style:{paddingLeft:jn(n+1)},...Us(()=>Ks(t.path,t.name)),draggable:Me(),onDragStart:o=>s.rowDragStart(o,t),onDragEnd:s.dragEnd,onDragOver:o=>s.dragOverDir(o,Ue(t.path)),onDragLeave:()=>s.dragLeaveDir(Ue(t.path)),onDrop:o=>s.dropOnDir(o,Ue(t.path)),onClick:o=>s.rowClick(o,t),onDoubleClick:()=>s.openFile(t),onContextMenu:o=>s.onMenu(o,t),children:[e.jsx("span",{className:"t2s-lead",children:e.jsx(a,{className:"t2s-lead-icon t2sf-fic"})}),e.jsx("span",{className:"t2sf-name",children:t.name}),t.size>0&&e.jsx("span",{className:"t2sf-size",children:At(t.size)})]})}function Ia({entry:t,depth:n,ctx:s,forceOpen:a}){const o=!!a&&(a===t.path||a.startsWith(t.path+"/")||a.startsWith(t.path+"\\")),[i,r]=c.useState(o),[u,p]=c.useState(null);c.useEffect(()=>{o&&r(!0)},[o,a]),c.useEffect(()=>{const m=g=>{const w=g.detail;(w==="*"||w===t.path)&&p(null)};return gt.addEventListener("fs-bump",m),()=>gt.removeEventListener("fs-bump",m)},[t.path]);const f=s.creating?.dir===t.path;return c.useEffect(()=>{f&&r(!0)},[f]),c.useEffect(()=>{if(!i||u)return;let m=!0;return window.tangu?.listDir?.(t.path).then(g=>{m&&p(Aa(g))}).catch(()=>{m&&p([])}),()=>{m=!1}},[i,u,t.path]),e.jsxs(e.Fragment,{children:[s.renaming===t.path?e.jsx(Tt,{initial:t.name,depth:n,onCommit:m=>s.commitRename(t,m),onCancel:s.cancelEdit}):e.jsxs("div",{className:`t2sf-row${s.isSel(t.path)?" sel":""}${s.dropDir===t.path?" drop":""}`,"data-sel-id":t.path,style:{paddingLeft:jn(n+1)},...Us(()=>Ks(t.path,t.name)),draggable:Me(),onDragStart:m=>s.rowDragStart(m,t),onDragEnd:s.dragEnd,onDragOver:m=>s.dragOverDir(m,t.path),onDragLeave:()=>s.dragLeaveDir(t.path),onDrop:m=>s.dropOnDir(m,t.path),onClick:m=>{s.rowClick(m,t).open!=="none"&&m.detail===1&&r(w=>!w)},onContextMenu:m=>s.onMenu(m,t),children:[e.jsxs("span",{className:"t2s-lead",children:[i?e.jsx(st,{className:"t2s-lead-icon t2sf-fic"}):e.jsx(Lt,{className:"t2s-lead-icon t2sf-fic"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${i?" open":""}`,children:e.jsx(we,{size:12})})]}),e.jsx("span",{className:"t2sf-name",children:t.name})]}),e.jsxs($e,{open:i,children:[f&&s.creating&&e.jsx(Tt,{initial:"",depth:n+1,onCommit:m=>s.commitCreate(t.path,s.creating.kind,m),onCancel:s.cancelEdit}),u===null?e.jsx("div",{className:"t2sf-loading",style:{paddingLeft:_t(n+2)},children:"…"}):e.jsx(e.Fragment,{children:u.map(m=>m.isDir?e.jsx(Ia,{entry:m,depth:n+1,ctx:s,forceOpen:o?a:null},m.path):e.jsx(Pa,{entry:m,depth:n+1,ctx:s},m.path))})]})]})}function hs({label:t,title:n,scope:s,kind:a,open:o,onToggle:i,onOpenPreview:r,sel:u,rowDownload:p=!1,emptyText:f}){const{t:m}=V(),g=P(D=>D.cfg),{sessionId:w,project:x}=s,z=P(D=>x?Object.keys(D.runningBySession).length>0:!!D.runningBySession[w]),[k,y]=c.useState(null),[N,d]=c.useState(null),_=mi(Is(w)).workspaceDelete,b=`${w}
|
|
40
|
-
${x??""}`,C=c.useRef(b);C.current=b,c.useEffect(()=>{y(null)},[b]);const j=c.useCallback(()=>{const D=b;fi(de(w),w,x).then(q=>{C.current===D&&y([...q].sort((E,F)=>E.path.localeCompare(F.path)))}).catch(()=>{C.current===D&&y([])})},[g,w,x,b]);c.useEffect(()=>{o&&k===null&&j()},[o,k,j]);const h=c.useRef(z);c.useEffect(()=>{h.current&&!z&&o&&j(),h.current=z},[z,o,j]);const S=D=>{gi(de(w),w,D.path,x).catch(q=>P.getState().toast(q?.message||String(q),!0))},B=(D,q)=>{r({name:D.path,load:async()=>{const E=await vi(de(w),w,D.path,x);return{mimeType:E.mimeType,bytes:xi(E.content),size:E.size}},download:()=>S(D)},q?{newTab:!0}:void 0)},J=async D=>{if(window.confirm(m("panel.confirm.delete",{name:D.path})))try{await Ln(de(w),w,D.path,x),j()}catch(q){P.getState().toast(q?.message||String(q),!0)}},L=async D=>{if(!(!D.length||!window.confirm(m("panel.confirm.deleteN",{n:String(D.length)})))){try{for(const q of D)await Ln(de(w),w,q.path,x)}catch(q){P.getState().toast(q?.message||String(q),!0)}u.clear(),j()}},K=(D,q)=>{D.preventDefault(),D.stopPropagation();const E=u.batch(q.path);if(E.length===1&&u.only(q.path),E.length>1){if(!_)return;const W=(k??[]).filter(ae=>E.includes(ae.path)),X=[{label:m("panel.action.deleteN",{n:String(W.length)}),icon:e.jsx(ft,{size:13}),danger:!0,run:()=>{L(W)}}];d({...pt(D,X.length),items:X});return}const F=[{label:m("panel.action.preview"),icon:e.jsx(Pt,{size:13}),run:()=>B(q)},{label:m("panel.action.download"),icon:e.jsx(Ie,{size:13}),run:()=>S(q)},..._?[{label:m("panel.action.delete"),icon:e.jsx(ft,{size:13}),danger:!0,run:()=>{J(q)}}]:[]];d({...pt(D,F.length),items:F})};return e.jsxs("div",{"data-ws-scope":a,children:[e.jsxs("div",{className:"t2s-group",style:{paddingLeft:Vs(0)},children:[e.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:i,title:n,children:[e.jsxs("span",{className:"t2s-lead",children:[o?e.jsx(st,{className:"t2s-lead-icon"}):e.jsx(Lt,{className:"t2s-lead-icon"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${o?" open":""}`,children:e.jsx(we,{size:12})})]}),e.jsx("span",{className:"t2s-group-label",children:t})]}),e.jsx("button",{className:"t2s-group-add",title:m("panel.files.refresh"),onClick:j,children:e.jsx(nt,{size:13})})]}),e.jsx($e,{open:o,children:e.jsx("div",{className:"t2sf-tree",children:k==null?e.jsx("div",{className:"t2sf-loading",style:{paddingLeft:_t(1)},children:"…"}):k.length===0?e.jsx("div",{className:"t2sf-empty",children:f||m("panel.files.empty")}):k.map(D=>{const q=Rt(Mt(D.path)||"",D.path);return e.jsxs("div",{className:`t2sf-row t2sf-file${u.has(D.path)?" sel":""}`,"data-sel-id":D.path,"data-ws-file":D.path,style:{paddingLeft:jn(1)},onClick:E=>{const F=u.click(D.path,E);F.open!=="none"&&B(D,F.open==="new")},onDoubleClick:()=>B(D),onContextMenu:E=>K(E,D),children:[e.jsx("span",{className:"t2s-lead",children:e.jsx(q,{className:"t2s-lead-icon t2sf-fic"})}),e.jsx("span",{className:"t2sf-name",children:D.path.replace(/^\//,"")}),D.size>0&&e.jsx("span",{className:"t2sf-size",children:At(D.size)}),p&&e.jsx("button",{className:"t2sf-row-act","data-download":!0,"aria-label":m("panel.action.download"),title:m("panel.action.download"),onClick:E=>{E.stopPropagation(),S(D)},onDoubleClick:E=>E.stopPropagation(),children:e.jsx(Ie,{size:14})})]},D.path)})})}),N&&e.jsx(Xs,{menu:N,onClose:()=>d(null)})]})}function Du({workspaces:t,onOpenPreview:n,activeWorkspaceKey:s,onEnterWorkspace:a,expandToPath:o,pinnedWorkspaceKey:i}){const{t:r}=V(),u=P(v=>Object.keys(v.runningBySession).length>0),p=P(v=>v.openWorkspaceKeys),f=P(v=>v.toggleOpenWorkspace),m=t.filter(v=>v.kind==="local"&&!!v.path),g=t.filter(v=>v.kind==="cloud"&&!!v.project),w=P(v=>v.activeId),x=Dt(w).kind==="unit"?w:null,[z,k]=c.useState(!0),[y,N]=c.useState({}),d=c.useRef(null),_=yr(d),[b,C]=c.useState(null),[j,h]=c.useState(null),[S,B]=c.useState(null),[J,L]=c.useState(null),[K,D]=c.useState(!1),q=c.useRef(null),E=(v,R)=>P.getState().toast(v,R),F=(v,R)=>{v.isDir||n(Ds(v.path,v.name),R?{newTab:!0}:void 0)},W=(v,R)=>{const T=_.click(R.path,v);return T.open!=="none"&&!R.isDir&&F(R,T.open==="new"),T},X=c.useCallback((v,R)=>{N(T=>({...T,[v]:T[v]??null})),window.tangu?.listDir?.(R).then(T=>N($=>({...$,[v]:Aa(T)}))).catch(()=>N(T=>({...T,[v]:[]})))},[]),ae=m.map(v=>`${v.key}
|
|
41
|
-
${v.path}`).join("\0");c.useEffect(()=>{const v=ae?ae.split("\0").map(T=>T.split(`
|
|
42
|
-
`)):[],R=T=>{const $=T.detail;for(const[ie,ye]of v)ye&&($==="*"||$===ye)&&X(ie,ye)};return gt.addEventListener("fs-bump",R),()=>gt.removeEventListener("fs-bump",R)},[ae,X]);const Q=c.useRef(u);c.useEffect(()=>{Q.current&&!u&&Te("*"),Q.current=u},[u]);const H=async(v,R)=>{if(C(null),!(!R||R===v.name||!window.tangu?.renameHostPath)){try{await window.tangu.renameHostPath(v.path,R)}catch(T){E(r("panel.toast.renameFail",{err:T?.message||T}),!0)}Te(Ue(v.path))}},le=async(v,R,T)=>{if(h(null),!!T){if(!pd(T)){E(r("panel.toast.invalidName",{name:T}),!0);return}try{R==="folder"?await window.tangu?.mkdirHost?.(v,T):await window.tangu?.writeHostFile?.(`${v}/${T}`,"",void 0,!0)}catch($){E(r("panel.toast.mkdirFail",{err:$?.message||$}),!0)}Te(v)}},ne=async v=>{if(!(!v.length||!window.tangu?.trashHostPath||!window.confirm(v.length===1?r("panel.confirm.trash",{name:v[0].split(/[/\\]/).pop()||""}):r("panel.confirm.trashN",{n:String(v.length)})))){try{for(const T of v)await window.tangu.trashHostPath(T)}catch(T){E(r("panel.toast.deleteFail",{err:T?.message||T}),!0)}_.clear();for(const T of v)Te(Ue(T))}},I=async(v,R)=>{if(!window.tangu?.moveHostPath)return;const T=R.filter($=>$!==v&&!v.startsWith($+"/")&&!v.startsWith($+"\\"));try{for(const $ of T)await window.tangu.moveHostPath($,v),Te(Ue($))}catch($){E(r("panel.toast.moveFail",{err:$?.message||$}),!0)}T.length&&Te(v)},O=async(v,R)=>{if(!(!window.tangu?.copyHostFiles||!v.length)){try{const T=await window.tangu.copyHostFiles(v,R);E(r("panel.toast.copied",{n:String(T.copied)}))}catch(T){E(r("panel.toast.copyFail",{err:T?.message||T}),!0)}Te(R)}},Y=async(v,R)=>{const T=window.tangu?.copyNoteBundles;if(!T)return O(v,R);const $=new Set(v),ie=se=>se.replace(/\.md$/i,".fd"),ye=v.filter(se=>/\.md$/i.test(se)).map(se=>({md:se,fd:$.has(ie(se))?ie(se):void 0})),be=new Set(ye.flatMap(se=>se.fd?[se.md,se.fd]:[se.md])),vt=v.filter(se=>!be.has(se)&&!ye.some(Je=>Je.fd&&se.startsWith(`${Je.fd}/`)));try{let se=0;ye.length&&(se+=(await T(ye,R)).copied),vt.length&&window.tangu?.copyHostFiles&&(se+=(await window.tangu.copyHostFiles(vt,R)).copied),E(r("panel.toast.copied",{n:String(se)}))}catch(se){E(r("panel.toast.copyFail",{err:se?.message||se}),!0)}Te(R)},ee=async(v,R)=>{window.tangu?.getPathForFile&&await O(Array.from(v).map(T=>{try{return window.tangu.getPathForFile(T)}catch{return""}}).filter(Boolean),R)},ce=(v,R)=>{v.preventDefault(),v.stopPropagation();const T=_.batch(R.path);if(T.length===1&&_.only(R.path),T.length>1){const ie=[{label:r("panel.action.copyPath"),icon:e.jsx(ht,{size:13}),run:()=>{navigator.clipboard.writeText(T.join(`
|
|
43
|
-
`))}}];Me()&&ie.push({label:r("panel.action.deleteN",{n:String(T.length)}),icon:e.jsx(ft,{size:13}),danger:!0,run:()=>{ne(T)}}),B({...pt(v,ie.length),items:ie});return}const $=[];R.isDir?Me()&&($.push({label:r("panel.action.newFile"),icon:e.jsx(Gt,{size:13}),run:()=>h({dir:R.path,kind:"file"})}),$.push({label:r("panel.action.newFolder"),icon:e.jsx(Ut,{size:13}),run:()=>h({dir:R.path,kind:"folder"})})):($.push({label:r("panel.action.open"),icon:e.jsx(Pt,{size:13}),run:()=>F(R)}),window.tangu?.openHostPath&&$.push({label:r("preview.openWithDefault"),icon:e.jsx(bt,{size:13}),run:()=>{window.tangu?.openHostPath?.(R.path).then(ie=>{ie&&!ie.ok&&E(ie.error||"open failed",!0)})}})),Me()&&$.push({label:r("panel.action.rename"),icon:e.jsx(at,{size:13}),run:()=>C(R.path)}),$.push({label:r("panel.action.copyPath"),icon:e.jsx(ht,{size:13}),run:()=>{navigator.clipboard.writeText(R.path)}}),us()&&$.push({label:r("panel.action.revealInFileManager"),icon:e.jsx(ln,{size:13}),run:()=>{window.tangu?.revealHostPath?.(R.path)}}),Me()&&$.push({label:r("panel.action.moveToTrash"),icon:e.jsx(ft,{size:13}),danger:!0,run:()=>{ne([R.path])}}),B({...pt(v,$.length),items:$})},G=(v,R)=>{if(!R.path)return;v.preventDefault(),v.stopPropagation();const T=R.path,$=[];Me()&&($.push({label:r("panel.action.newFile"),icon:e.jsx(Gt,{size:13}),run:()=>{a?.(R.key),h({dir:T,kind:"file"})}}),$.push({label:r("panel.action.newFolder"),icon:e.jsx(Ut,{size:13}),run:()=>{a?.(R.key),h({dir:T,kind:"folder"})}})),us()&&$.push({label:r("panel.action.revealInFileManager"),icon:e.jsx(ln,{size:13}),run:()=>{window.tangu?.revealHostPath?.(T)}}),$.push({label:r("panel.files.refresh"),icon:e.jsx(nt,{size:13}),run:()=>Te(T)}),B({...pt(v,$.length),items:$})},A=(v,R)=>{if(v.altKey&&window.tangu?.startHostDrag){v.preventDefault(),window.tangu.startHostDrag(R.path);return}const T=_.batch(R.path);q.current=T,v.dataTransfer.setData(Wt,JSON.stringify(T)),v.dataTransfer.effectAllowed="copyMove"},fe=()=>{q.current=null,L(null)},he=(v,R)=>{const T=Me()&&v.dataTransfer.types.includes("Files");!(q.current||v.dataTransfer.types.includes(Wt))&&!T||q.current?.includes(R)||!T&&q.current?.every(ie=>Ue(ie)===R)||(v.preventDefault(),v.stopPropagation(),v.dataTransfer.dropEffect=T||v.dataTransfer.types.includes($n)?"copy":"move",L(R))},Ce=v=>{L(R=>R===v?null:R)},Pe=(v,R)=>{v.preventDefault(),v.stopPropagation();const T=v.dataTransfer.files;let $=q.current;if(!$)try{$=JSON.parse(v.dataTransfer.getData(Wt)||"null")}catch{$=null}const ie=v.dataTransfer.types.includes($n);L(null),q.current=null,T?.length?ee(T,R):$?.length&&(ie?Y($,R):I(R,$))},ve={isSel:_.has,rowClick:W,openFile:F,onMenu:ce,renaming:b,commitRename:H,creating:j,commitCreate:le,cancelEdit:()=>{C(null),h(null)},dropDir:J,rowDragStart:A,dragEnd:fe,dragOverDir:he,dragLeaveDir:Ce,dropOnDir:Pe},_e=v=>{const R=!p.includes(v.key);f(v.key,R),R&&a?.(v.key)};c.useEffect(()=>{s&&(f(s,!0),s!==i&&D(!0))},[s,i,f]),c.useEffect(()=>{for(const v of p){const R=m.find(T=>T.key===v);R?.path&&y[v]===void 0&&X(v,R.path)}},[p,m,y,X]);const pe=x?e.jsx(hs,{label:r("panel.files.sessionFiles"),scope:{sessionId:x},kind:"session",open:z,onToggle:()=>k(v=>!v),onOpenPreview:n,sel:_,rowDownload:!0,emptyText:r("panel.files.sessionEmpty")},`session:${x}`):null;if(!m.length&&!g.length)return pe?e.jsx("aside",{className:"t2s-side",children:e.jsx("div",{ref:d,className:"t2s-scroll",children:pe})}):e.jsx("div",{className:"t2s-hint",style:{padding:"18px 12px"},children:r("panel.files.noLocalWs")});const Fe=v=>{if(v.kind==="cloud")return e.jsx(hs,{label:v.name,title:v.project,scope:{sessionId:"__project__",project:v.project},kind:"project",open:p.includes(v.key),onToggle:()=>_e(v),onOpenPreview:n,sel:_},v.key);const R=p.includes(v.key),T=y[v.key];return e.jsxs("div",{children:[e.jsxs("div",{className:`t2s-group${J===v.path?" drop":""}`,style:{paddingLeft:Vs(0)},onContextMenu:$=>G($,v),onDragOver:$=>{v.path&&R&&he($,v.path)},onDragLeave:()=>{v.path&&Ce(v.path)},onDrop:$=>{v.path&&Pe($,v.path)},children:[e.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>_e(v),title:v.path||void 0,children:[e.jsxs("span",{className:"t2s-lead",children:[R?e.jsx(st,{className:"t2s-lead-icon"}):e.jsx(Lt,{className:"t2s-lead-icon"}),e.jsx("span",{className:`t2s-chev t2s-lead-chev${R?" open":""}`,children:e.jsx(we,{size:12})})]}),e.jsx("span",{className:"t2s-group-label",children:v.name})]}),R&&Me()&&e.jsx("button",{className:"t2s-group-add",title:r("panel.action.newFile"),onClick:()=>{v.path&&h({dir:v.path,kind:"file"})},children:e.jsx(Gt,{size:13})}),R&&Me()&&e.jsx("button",{className:"t2s-group-add",title:r("panel.action.newFolder"),onClick:()=>{v.path&&h({dir:v.path,kind:"folder"})},children:e.jsx(Ut,{size:13})}),e.jsx("button",{className:"t2s-group-add",title:r("panel.files.refresh"),onClick:()=>{v.path&&X(v.key,v.path)},children:e.jsx(nt,{size:13})})]}),e.jsx($e,{open:R,children:e.jsxs("div",{className:"t2sf-tree",children:[j&&v.path&&j.dir===v.path&&e.jsx(Tt,{initial:"",depth:1,onCommit:$=>le(v.path,j.kind,$),onCancel:()=>h(null)}),T==null?e.jsx("div",{className:"t2sf-loading",style:{paddingLeft:_t(1)},children:"…"}):T.length===0?e.jsx("div",{className:"t2sf-empty",children:r("panel.files.empty")}):T.map($=>$.isDir?e.jsx(Ia,{entry:$,depth:1,ctx:ve,forceOpen:R?o:null},$.path):e.jsx(Pa,{entry:$,depth:1,ctx:ve},$.path))]})})]},v.key)},Z=[...g,...m],re=[i,s,Z[0]?.key].find(v=>v&&Z.some(R=>R.key===v))??null,Be=Z.filter(v=>v.key!==re);return e.jsxs("aside",{className:"t2s-side",children:[e.jsxs("div",{ref:d,className:"t2s-scroll",onClick:v=>{v.target===v.currentTarget&&_.clear()},children:[pe,Z.filter(v=>v.key===re).map(Fe),Be.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"t2sf-showall",onClick:()=>D(v=>!v),children:[e.jsx("span",{className:`t2s-chev${K?" open":""}`,children:e.jsx(we,{size:12})}),r("panel.files.showAllWs"),e.jsx("span",{className:"t2sf-showall-n",children:Be.length})]}),e.jsx($e,{open:K,children:Be.map(Fe)})]})]}),S&&e.jsx(Xs,{menu:S,onClose:()=>B(null)})]})}async function md(t,n){const s=P.getState().toast,a=t.replace(/(\.[^./\\]+)?$/,`.本地未保存-${Date.now()}$1`);try{await window.tangu?.writeHostFile?.(a,n,void 0,!0),Te(a.slice(0,Math.max(a.lastIndexOf("/"),a.lastIndexOf("\\")))),s(P.getState().tr("preview.mdSalvaged",{file:a.split(/[/\\]/).pop()||a}),!0)}catch{s(P.getState().tr("preview.mdSaveFail",{err:t}),!0)}}const ps=({src:t,kind:n,seek:s})=>{const a=c.useRef(null);c.useEffect(()=>{const i=a.current;if(!i||!s)return;const r=()=>{try{i.currentTime=s.t}catch{}};if(i.readyState>=1){r();return}return i.addEventListener("loadedmetadata",r,{once:!0}),()=>i.removeEventListener("loadedmetadata",r)},[t,s?.t,s?.nonce]),c.useEffect(()=>{const i=a.current,r=s?.to;if(!i||!r)return;const u=()=>{i.currentTime>=r&&i.pause()};return i.addEventListener("timeupdate",u),()=>i.removeEventListener("timeupdate",u)},[s?.to]);const o={ref:i=>{a.current=i},src:t,controls:!0,preload:"metadata"};return n==="video"?e.jsx("video",{...o}):e.jsx("audio",{...o})},fd=({path:t,text:n,mtimeMs:s,view:a,onReload:o,focusLine:i})=>{const{t:r}=V(),u=yi(b=>b.mode),p=c.useMemo(()=>ji(n).fm,[n]),f=c.useRef(n.slice(p.length)),m=c.useRef(s),g=c.useRef(!1),w=c.useRef(null),[x,z]=c.useState(!1),[k,y]=c.useState(null),N=async b=>{if(!g.current||!window.tangu?.writeHostFile)return{};const C=f.current,j=window.tangu.writeHostFile(t,p+C,b?void 0:m.current);qn.set(t,j.catch(()=>{}));try{const h=await j;return h.conflict?(z(!0),{conflict:!0}):(m.current=h.mtimeMs,g.current=f.current!==C,z(!1),y(null),{})}catch(h){return y(h?.message||String(h)),{failed:!0}}finally{qn.delete(t)}},d=c.useRef(N);d.current=N;const _=b=>{f.current=b,g.current=!0,w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{d.current()},800)};return c.useEffect(()=>()=>{w.current&&clearTimeout(w.current);const b=p+f.current,C=g.current;d.current().then(j=>{C&&(j.conflict||j.failed)&&md(t,b)})},[]),e.jsxs("div",{className:"wsmd-edit",children:[x&&e.jsxs("div",{className:"wsmd-banner",children:[e.jsx(jr,{size:13}),e.jsx("span",{children:r("preview.mdConflict")}),e.jsx("button",{className:"btn ghost sm",onClick:o,children:r("preview.mdReload")}),e.jsx("button",{className:"btn ghost sm",onClick:()=>{N(!0)},children:r("preview.mdOverwrite")})]}),k&&e.jsxs("div",{className:"wsmd-banner danger",children:[e.jsx(De,{size:13}),e.jsx("span",{children:r("preview.mdSaveFail",{err:k})})]}),a==="source"?xe({value:p+f.current,fileName:t,wrap:!1,focusLine:i}):e.jsx("div",{className:"am-app tangu-lovable wsmd-scope","data-mode":u,children:e.jsx(Pr,{initial:f.current,onChange:_})})]})};function gd({leaf:t}){const{t:n}=V(),s=typeof t.params.path=="string"?t.params.path:null,a=typeof t.params.tkey=="string"?t.params.tkey:null,o=typeof t.params.name=="string"&&t.params.name?t.params.name:s?s.split(/[/\\]/).pop()||s:"",i=typeof t.params.line=="number"&&t.params.line>=1?Math.trunc(t.params.line):null,r=typeof t.params.endLine=="number"&&t.params.endLine>=1?Math.trunc(t.params.endLine):void 0,[u,p]=c.useState(i?{line:i,end:r,nonce:0}:null),f=typeof t.params.t=="number"&&t.params.t>=0?t.params.t:null,m=typeof t.params.tTo=="number"&&t.params.tTo>(f??0)?t.params.tTo:void 0,[g,w]=c.useState(f!=null?{t:f,to:m,nonce:0}:null),x=c.useMemo(()=>s?Ds(s,o):a?wi(a)??null:null,[s,a,o]);c.useEffect(()=>{o&&t.setTitle(o)},[o]);const[z,k]=c.useState(!0),[y,N]=c.useState(null),[d,_]=c.useState(null),[b,C]=c.useState(null),[j,h]=c.useState(null),[S,B]=c.useState(i?"source":"preview"),[J,L]=c.useState(i?"source":"edit");c.useEffect(()=>{if(!s)return;const v=R=>{const T=R.detail;if(!(!T||T.path!==s)){if(T.clear){p(null),w(null),t.setParams({line:void 0,endLine:void 0,t:void 0,tTo:void 0});return}if(typeof T.t=="number"&&T.t>=0){w($=>({t:T.t,to:typeof T.tTo=="number"&&T.tTo>T.t?T.tTo:void 0,nonce:($?.nonce??0)+1}));return}typeof T.line!="number"||T.line<1||(p($=>({line:Math.trunc(T.line),end:typeof T.endLine=="number"&&T.endLine>=1?Math.trunc(T.endLine):void 0,nonce:($?.nonce??0)+1})),L("source"),B("source"))}};return window.addEventListener("amadeus:wsfile-goto",v),()=>window.removeEventListener("amadeus:wsfile-goto",v)},[s]);const[K,D]=c.useState(0),[q,E]=c.useState(!1),[F,W]=c.useState(!0),[X,ae]=c.useState({s:1,x:0,y:0}),Q=Ss(o),H=d?Nt(d.mimeType,o):"binary",le=Rt(d?.mimeType||"",o);c.useEffect(()=>{if(!x){k(!1);return}let v=!1,R=null;return k(!0),N(null),_(null),C(null),h(null),ae({s:1,x:0,y:0}),(async()=>{try{const T=await x.load();if(v)return;if(!T){N("not-found"),k(!1);return}if("tooLarge"in T){C(T.size),k(!1);return}if(la.has(Nt(T.mimeType,o))){const $=Mt(o)||T.mimeType||"application/octet-stream";R=URL.createObjectURL(new Blob([T.bytes],{type:$})),h(R)}_(T),k(!1)}catch(T){v||(N(T?.message||"error"),k(!1))}})(),()=>{v=!0,R&&URL.revokeObjectURL(R)}},[x,K]);const ne=c.useMemo(()=>d&&ra.has(H)?new TextDecoder("utf-8",{fatal:!1}).decode(d.bytes):"",[d,H]),[I,O]=c.useState(null),[Y,ee]=c.useState(!1),[ce,G]=c.useState(0);c.useEffect(()=>{if(!d||H!=="xlsx"&&H!=="pptx"){O(null),ee(!1);return}let v=!1;return O(null),ee(!1),G(0),ha(d.bytes,H).then(R=>{v||O(R)}).catch(()=>{v||ee(!0)}),()=>{v=!0}},[d,H]);const A=()=>{s&&window.tangu?.openHostPath?.(s).then(v=>{v&&!v.ok&&P.getState().toast(v.error||"open failed",!0)})},fe=()=>{s&&window.tangu?.revealHostPath?.(s)},he=s&&window.tangu?.openHostPath?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"btn ghost sm",onClick:A,children:[e.jsx(bt,{size:13})," ",n("preview.openWithDefault")]}),e.jsxs("button",{className:"btn ghost sm",onClick:fe,children:[e.jsx(ln,{size:13})," ",n("panel.action.revealInFileManager")]})]}):x?.download?e.jsxs("button",{className:"btn ghost sm",onClick:x.download,children:[e.jsx(Ie,{size:13})," ",n("preview.download")]}):null,Ce=xn(v=>v.fileTypes),Pe=!!s&&(/\.(excalidraw|mindmap)\.md$/i.test(s)||!!wn(Ce,s)),ve=H==="markdown"&&!!s&&!!window.tangu?.writeHostFile&&!Pe,_e=ot(v=>v.vaultRoot),pe=c.useMemo(()=>{if(!s||!_e)return null;const v=$=>$.replace(/\\/g,"/").replace(/\/+$/,""),R=v(_e),T=v(s);return T.startsWith(R+"/")?T.slice(R.length+1):null},[s,_e]),Fe=pe&&/\.md$/i.test(pe)?()=>{bi(pe)}:void 0;let Z;if(!x)Z=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:n("preview.expired")})]});else if(z)Z=e.jsx(Ge,{});else if(b!==null)Z=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:n("preview.tooLarge",{size:At(b)})}),e.jsx("div",{className:"wsfile-ask-actions",children:he})]});else if(y||!d)Z=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:n(y==="not-found"?"preview.notFound":"preview.loadFailed")}),he&&e.jsx("div",{className:"wsfile-ask-actions",children:he})]});else if(H==="image")Z=j?e.jsx(ca,{src:j,alt:o,view:X,setView:ae}):null;else if(H==="pdf")Z=e.jsx(ua,{bytes:d.bytes,download:x.download});else if(H==="video")Z=e.jsx("div",{className:"wsfile-media",children:j&&e.jsx(ps,{src:j,kind:"video",seek:g})});else if(H==="audio")Z=e.jsx("div",{className:"wsfile-media wsfile-audio",children:j&&e.jsx(ps,{src:j,kind:"audio",seek:g})});else if(H==="markdown")ve?Z=e.jsx(fd,{path:s,text:ne,mtimeMs:d.mtimeMs,view:J,onReload:()=>D(v=>v+1),focusLine:u},`${s}:${d.mtimeMs??0}:${K}`):Pe||S==="source"?Z=xe({value:ne,fileName:o,wrap:q,focusLine:u}):Z=e.jsx("div",{className:"wsfile-doc msg-content",children:e.jsx(qe,{content:ne})});else if(H==="json"){let v=ne;if(!u)try{v=JSON.stringify(JSON.parse(ne),null,2)}catch{}Z=xe({value:v,fileName:"x.json",language:"json",wrap:q,focusLine:u})}else if(H==="code")Z=xe({value:ne,fileName:o,wrap:q,focusLine:u});else if(H==="text")Z=xe({value:ne,fileName:o,wrap:q,focusLine:u});else if(H==="diff")Z=u?xe({value:ne,fileName:o,wrap:q,focusLine:u}):e.jsx(yn,{text:ne,side:F});else if(H==="csv"&&u)Z=xe({value:ne,fileName:o,wrap:q,focusLine:u});else if(H==="csv"){const v=Ns(ne,Q==="tsv"?" ":","),R=v.slice(0,et),T=R[0]??[];Z=e.jsxs("div",{className:"wsfile-doc",children:[e.jsxs("table",{className:"wsfile-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:T.map(($,ie)=>e.jsx("th",{children:$},ie))})}),e.jsx("tbody",{children:R.slice(1).map(($,ie)=>e.jsx("tr",{children:T.map((ye,be)=>e.jsx("td",{children:$[be]??""},be))},ie))})]}),v.length>et&&e.jsx("div",{className:"panel-note",children:n("preview.csvTruncated",{shown:String(et),total:String(v.length)})})]})}else H==="html"?Z=S==="preview"?e.jsx(ia,{path:s??x.path,text:ne,title:o,nonce:K}):xe({value:ne,language:"html",wrap:q,focusLine:u}):H==="docx"?Z=e.jsx(da,{bytes:d.bytes,download:x.download}):H==="xlsx"||H==="pptx"?Z=Y?e.jsx(qt,{t:n,download:x.download}):I?I.kind==="xlsx"?e.jsxs("div",{className:"wsfile-sheetwrap",children:[I.sheets.length>1&&e.jsx("div",{className:"wsfile-seg wsfile-sheet-tabs",children:I.sheets.map((v,R)=>e.jsx("button",{className:R===ce?"active":"",onClick:()=>G(R),children:v.name},R))}),e.jsx("div",{className:"wsfile-doc wsfile-sheet",dangerouslySetInnerHTML:{__html:I.sheets[ce]?.html??I.sheets[0]?.html??""}})]}):e.jsx("div",{className:"wsfile-doc wsfile-pptx",children:I.slides.map((v,R)=>{const T=v.split(`
|
|
44
|
-
`);return e.jsxs("div",{className:"wsfile-slide",children:[e.jsx("div",{className:"wsfile-slide-no",children:n("preview.slide",{n:String(R+1)})}),T[0]&&e.jsx("div",{className:"wsfile-slide-title",children:T[0]}),e.jsx("pre",{children:T.slice(1).join(`
|
|
45
|
-
`)||(T[0]?"":"—")})]},R)})}):e.jsx(Ge,{}):Z=e.jsxs("div",{className:"wsfile-center wsfile-fallback",children:[e.jsx(De,{size:26}),e.jsx("div",{children:n(s?"preview.unsupportedAsk":"preview.notAvailable")}),e.jsx("div",{className:"wsfile-ask-actions",children:he})]});const re=!z&&!y&&b===null&&!!d,Be=re&&(H==="code"||H==="json"||H==="text"||H==="html"&&S==="source"||H==="markdown"&&!ve&&(S==="source"||Pe));return e.jsxs("div",{className:"wsfile-tab",children:[e.jsxs("div",{className:"wsfile-head",children:[e.jsx(le,{size:14,className:"wsfile-head-icon"}),e.jsxs("div",{className:"wsfile-title",title:s??o,children:[e.jsx("span",{className:"wsfile-name",children:s??o}),Q&&e.jsx("span",{className:"wsfile-ext",children:Q})]}),re&&ve&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:J==="edit"?"active":"",title:n("preview.mdEdit"),onClick:()=>L("edit"),children:e.jsx(at,{size:13})}),e.jsx("button",{className:J==="source"?"active":"",title:n("preview.htmlCode"),onClick:()=>L("source"),children:e.jsx(Ct,{size:13})})]}),re&&!ve&&!Pe&&(H==="markdown"||H==="html")&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:S==="preview"?"active":"",title:n("preview.htmlPreview"),onClick:()=>B("preview"),children:e.jsx(Pt,{size:13})}),e.jsx("button",{className:S==="source"?"active":"",title:n("preview.htmlCode"),onClick:()=>B("source"),children:e.jsx(Ct,{size:13})}),H==="html"&&S==="preview"&&e.jsx("button",{title:n("preview.reload"),onClick:()=>D(v=>v+1),children:e.jsx(nt,{size:12})}),H==="html"&&S==="preview"&&!!(s??x?.path)&&!!window.tangu?.codePreviewServePath&&!!window.tangu?.openExternal&&e.jsx("button",{title:n("preview.openInBrowser"),onClick:()=>{window.tangu.codePreviewServePath(s??x.path).then(v=>window.tangu.openExternal(v.url)).catch(()=>{})},children:e.jsx(bt,{size:12})})]}),re&&H==="diff"&&e.jsxs("div",{className:"wsfile-seg",children:[e.jsx("button",{className:F?"active":"",title:n("preview.diffSideBySide"),onClick:()=>W(!0),children:e.jsx(zs,{size:13})}),e.jsx("button",{className:F?"":"active",title:n("preview.diffLineByLine"),onClick:()=>W(!1),children:e.jsx(ta,{size:13})})]}),Be&&e.jsx("button",{className:`icon-btn${q?" active":""}`,title:n("preview.wrap"),onClick:()=>E(v=>!v),children:e.jsx(na,{size:14})}),re&&H==="image"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"icon-btn",title:n("preview.zoomOut"),onClick:()=>ae(v=>({...v,s:Math.min(8,Math.max(.1,v.s*.8))})),children:e.jsx(Gs,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("preview.zoomIn"),onClick:()=>ae(v=>({...v,s:Math.min(8,Math.max(.1,v.s*1.25))})),children:e.jsx(Ys,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("preview.fit"),onClick:()=>ae({s:1,x:0,y:0}),children:e.jsx(Zs,{size:14})})]}),Fe&&e.jsx("button",{className:"icon-btn",title:n("preview.openInAmadeus"),onClick:Fe,children:e.jsx(ys,{size:14})}),s&&e.jsx("button",{className:"icon-btn",title:n("preview.openWithDefault"),onClick:A,children:e.jsx(bt,{size:14})}),x?.download&&e.jsx("button",{className:"icon-btn",title:n(s?"panel.action.revealInFileManager":"preview.download"),onClick:x.download,children:e.jsx(Ie,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("preview.reload"),onClick:()=>D(v=>v+1),children:e.jsx(nt,{size:14})})]}),e.jsx("div",{className:"wsfile-body",children:Z})]})}const ms=t=>_s()?.agentStatus?.(t)??ki(t);function Da({entry:t,surface:n,sessionId:s}){const a=c.useRef(null),o=c.useRef(s);o.current=s;const i=c.useRef(new Set),r=p=>{for(const f of[...i.current])try{f(p)}catch(m){console.error("[desk-companion] onStatus callback failed",t.key,m)}};c.useEffect(()=>{const p=a.current;if(!p)return;const f=i.current,m={surface:n,sessionId:()=>o.current,status:()=>ms(o.current),onStatus:w=>(f.add(w),()=>{f.delete(w)})};let g;try{g=t.mount(p,m)}catch(w){console.error("[desk-companion] mount failed",t.key,w)}return()=>{try{typeof g=="function"&&g()}catch(w){console.error("[desk-companion] dispose failed",t.key,w)}f.clear(),p.replaceChildren()}},[t.key,t.mount,n]);const u=c.useRef(s);return c.useEffect(()=>{const p=_s()?.subscribeAgentStatus?.(r,s);return u.current!==s&&(u.current=s,r(ms(s))),()=>{try{p?.()}catch(f){console.error("[desk-companion] unsubscribe failed",f)}}},[s]),e.jsx("div",{ref:a,className:"agent-desk-companion-slot","data-companion":t.key,"data-surface":n,style:{position:"relative",flex:"1 1 0",minHeight:0,minWidth:0,overflow:"hidden"}})}te({"desk.writing":{zh:"正在编辑 {name}",en:"Editing {name}"},"desk.drafting":{zh:"正在起草…",en:"Drafting…"},"desk.expand":{zh:"展开",en:"Expand"},"desk.collapse":{zh:"收起为卡片",en:"Collapse to card"},"desk.empty":{zh:"Agent 会在这里展示成果",en:"Agent will present work here"},"desk.clear":{zh:"清空 Desk",en:"Clear Desk"}});const _a=t=>P.getState().patchDesk(t,{items:[],mode:void 0,note:void 0}),Fa=(t,n,s)=>({id:t,type:n,loc:"main",params:s,setTitle:()=>{},setParams:()=>{},close:()=>{}});function St({item:t}){const n=c.useMemo(()=>Fa(`desk:${t.key}`,"wsfile",{path:t.path,name:t.name}),[t.key,t.path,t.name]);return e.jsx(gd,{leaf:n,params:n.params})}function tt({type:t,params:n,k:s}){const[,a]=c.useReducer(r=>r+1,0);c.useEffect(()=>Ci(a),[]);const o=t==="chat"?void 0:Ei(t),i=c.useMemo(()=>Fa(s,t,n),[s,t]);return o?e.jsx("div",{className:"desk-note-wrap",children:o.factory({leaf:i,params:i.params})}):e.jsxs("div",{className:"agent-desk-card-empty",children:[e.jsx(Ke,{size:18}),e.jsx("span",{children:t})]})}function $a(t,n){if(!n||!t)return null;const s=i=>i.replace(/\\/g,"/").replace(/\/+$/,""),a=s(n),o=s(t);return o.startsWith(a+"/")?o.slice(a.length+1):null}const La=(t,n)=>ws(t)||wn(n,t)?null:/\.md$/i.test(t)?"note":null;function vd(t){const[n,s]=c.useState(!1);return c.useEffect(()=>{let a=!0;const o=()=>ot.getState(),i=u=>u.replace(/\\/g,"/"),r=()=>o().files.some(u=>i(u)===t)||o().pages.some(u=>i(u)===t);return(async()=>{if(o().activePage!==t){if(!r()){if(await o().refreshStructure(),!a)return;if(!r()){s(!0);return}}s(!1),o().loadPage(t)}})(),()=>{a=!1}},[t]),n}function xd({item:t,rel:n}){return vd(n)?e.jsx(St,{item:t}):e.jsx(tt,{type:"amadeus-editor",params:{notePath:n},k:`desk-note:${n}`})}function qa({item:t,allowNative:n}){const s=ot(r=>r.vaultRoot),a=xn(r=>r.fileTypes),o=$a(t.path,s);return o?La(o,a)?n?e.jsx(xd,{item:t,rel:o}):e.jsx(St,{item:t}):ws(o)?e.jsx(tt,{type:"amadeus-drawing",params:{drawingPath:o},k:`desk-draw:${o}`}):wn(a,o)?e.jsx(tt,{type:"amadeus-plugin-file",params:{filePath:o},k:`desk-ft:${o}`}):/\.db$/i.test(o)?e.jsx(tt,{type:"amadeus-db",params:{dbPath:o},k:`desk-db:${o}`}):e.jsx(St,{item:t}):e.jsx(St,{item:t})}function Oa(t){c.useEffect(()=>{Si()},[]);const n=ot(a=>a.vaultRoot),s=xn(a=>a.fileTypes);return t.find(a=>{if(a.live||a.view)return!1;const o=$a(a.path,n);return!!o&&La(o,s)!==null})?.key}function Ba({sessionId:t,item:n}){const{t:s}=V(),a=n.live,o=P(u=>u.messagesBySession[t]?.find(f=>f.id===a.msgId)?.toolEvents?.find(f=>f.id===a.toolId)?.arguments||""),i=c.useMemo(()=>zi(o,a.tool),[o,a.tool]),r=c.useRef(null);return c.useEffect(()=>{const u=r.current;u&&(u.scrollTop=u.scrollHeight)},[i]),e.jsxs("div",{className:"agent-desk-livepane",children:[e.jsxs("div",{className:"agent-desk-livehead",children:[e.jsx(Oe,{size:12,className:"spin"}),e.jsx("span",{className:"agent-desk-livehead-tx",title:n.path||void 0,children:n.path?s("desk.writing",{name:n.name}):s("desk.drafting")})]}),e.jsx("pre",{ref:r,className:"agent-desk-livebody",children:i})]})}function Ha(t,n){return c.useCallback(s=>{const a=n.current?.parentElement;if(!a)return;s.preventDefault();const o=s.currentTarget;o.setPointerCapture(s.pointerId),n.current?.classList.add("no-anim");const i=a.getBoundingClientRect(),r=p=>{const f=Math.min(.72,Math.max(.25,(i.right-p.clientX)/i.width));P.getState().patchDesk(t,{fraction:f,userResized:!0})},u=()=>{n.current?.classList.remove("no-anim"),o.removeEventListener("pointermove",r),o.removeEventListener("pointerup",u),o.removeEventListener("pointercancel",u),o.removeEventListener("lostpointercapture",u)};o.addEventListener("pointermove",r),o.addEventListener("pointerup",u),o.addEventListener("pointercancel",u),o.addEventListener("lostpointercapture",u)},[t,n])}function wd({sessionId:t}){const{t:n}=V(),s=P(w=>w.deskBySession[t]),a=Oa(s?.items?.slice(0,2)??[]),o=c.useRef(null),i=Ha(t,o),r=Fs(),u=r?.mode==="always";if(!s?.items.length&&!u)return null;const p=s?.mode==="open",f=s?.fraction??(s?.size==="wide"?.62:.46),m=s?.items.slice(0,2)??[],g=r?.mode==="idle"&&m.length>0;return e.jsx("div",{ref:o,"data-desk-session":t,className:`agent-desk${p?" open":""}`,style:{"--desk-w":`${(f*100).toFixed(2)}%`},children:p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"agent-desk-grip",onPointerDown:i}),e.jsxs("div",{className:"agent-desk-inner",children:[e.jsxs("div",{className:"agent-desk-head",children:[e.jsx(Ke,{size:13,className:"agent-desk-spark"}),e.jsx("span",{className:"agent-desk-title",children:n("desk.title")}),!u&&s?.note?e.jsx("span",{className:"agent-desk-note",title:s.note,children:s.note}):e.jsx("span",{className:"agent-desk-note"}),g&&e.jsx("button",{className:"icon-btn",title:n("desk.clear"),onClick:()=>_a(t),children:e.jsx($s,{size:14})}),e.jsx("button",{className:"icon-btn",title:n("desk.collapse"),onClick:()=>P.getState().patchDesk(t,{mode:void 0}),children:e.jsx(ea,{size:14})})]}),e.jsx("div",{className:"agent-desk-body",children:u&&r?e.jsx("div",{className:"agent-desk-pane agent-desk-companion",children:e.jsx(Da,{entry:r,surface:"desk-panel",sessionId:t},r.key)}):m.map(w=>e.jsx("div",{className:"agent-desk-pane",children:w.live?e.jsx(Ba,{sessionId:t,item:w}):w.view?e.jsx(tt,{type:w.view.type,params:w.view.params??{},k:`desk-view:${w.key}`}):e.jsx(qa,{item:w,allowNative:w.key===a})},w.key))})]})]})})}const yd=(t,n)=>t==="open"&&n;function jd(t){const n=t.companion==="always",s=yd(t.mode,n?!t.draft:t.itemCount>0);return{gone:s,showCompanion:n||t.companion==="idle"&&t.itemCount===0,expandable:!s&&!t.draft&&(n||t.itemCount>0),clearable:t.companion==="idle"&&t.itemCount>0}}function bd({sessionId:t}){const{t:n}=V(),s=P(g=>g.deskBySession[t]),a=Fs(),o=s?.items?.slice(0,2)??[],i=Oa(o),r=t===Ni,u=jd({mode:s?.mode,itemCount:o.length,companion:a?.mode??null,draft:r}),p=u.gone,f=u.expandable?()=>P.getState().patchDesk(t,{mode:"open"}):void 0,m=u.showCompanion?a:null;return e.jsxs("div",{"data-desk-session":t,className:`agent-desk-card${f?" act":""}${p?" gone":""}`,onClick:f,title:f?n("desk.expand"):void 0,children:[e.jsxs("div",{className:"agent-desk-card-head",children:[e.jsx(Ke,{size:12,className:"agent-desk-spark"}),e.jsx("span",{className:"agent-desk-card-title",children:m?n("desk.title"):o[0]?.name||n("desk.title")}),u.clearable&&e.jsx("button",{className:"icon-btn",title:n("desk.clear"),onClick:g=>{g.stopPropagation(),_a(t)},children:e.jsx($s,{size:13})}),f&&e.jsx("button",{className:"icon-btn",title:n("desk.expand"),onClick:g=>{g.stopPropagation(),f()},children:e.jsx(Cs,{size:13})})]}),e.jsx("div",{className:`agent-desk-card-body${m?" companion":""}`,children:p?null:m?e.jsx("div",{className:"agent-desk-pane agent-desk-companion",children:e.jsx(Da,{entry:m,surface:"desk-card",sessionId:r?null:t},m.key)}):o.length?o.map(g=>e.jsx("div",{className:"agent-desk-pane",children:g.live?e.jsx(Ba,{sessionId:t,item:g}):g.view?e.jsx(tt,{type:g.view.type,params:g.view.params??{},k:`desk-view:${g.key}`}):e.jsx(qa,{item:g,allowNative:g.key===i})},g.key)):e.jsxs("div",{className:"agent-desk-card-empty",children:[e.jsx(Ke,{size:18}),e.jsx("span",{children:n("desk.empty")})]})})]})}te({"historian.status.ready":{zh:"待命",en:"Ready"},"historian.status.working":{zh:"整理会话中",en:"Reviewing conversation"},"historian.status.empty":{zh:"本会话还没有 Historian 工作记录",en:"No Historian activity in this conversation yet"},"historian.status.unavailable":{zh:"状态暂不可用",en:"Status unavailable"},"historian.status.viewTranscript":{zh:"查看完整记录",en:"View full transcript"}});const kd=3e3;function Sd(t){try{const n=JSON.parse(t.replace(/^```(?:json)?\s*|\s*```$/g,""));return[n.summary,n.title,n.log,...Array.isArray(n.memory_candidates)?n.memory_candidates.map(s=>typeof s=="string"?s:s.text||s.content||""):[]].filter(s=>typeof s=="string"&&s.trim()).join(`
|
|
46
|
-
|
|
47
|
-
`)}catch{return t}}function Nd(t,n){const s=P.getState(),a=s.configBySession[t]?.agentSlug||s.defaultAgentSlug,o=s.sessions.find(i=>i.id===t)?.title||a;ue({event:"harness.candidates",level:"info",sticky:!0,dedupeKey:`harness.candidates:${n}`,text:s.tr("ntf.harnessCandidates",{name:o}),action:{label:s.tr("ntf.actionRefine"),run:()=>{const i=P.getState(),r=i.configBySession[t];!(r?.execMode==="host"&&!r?.planMode)||i.runningBySession[t]?Sn(a,"evolution"):i.send("/refine",[],void 0,void 0,void 0,t)}}})}function zd(t,n,s){const a=P.getState(),o=a.configBySession[t]?.agentSlug||a.defaultAgentSlug,i=a.agentDefs.find(r=>r.slug===o)?.name||o;ue({event:"harness.candidates",level:"info",sticky:!0,dedupeKey:`harness.adopted:${n}`,text:a.tr("ntf.harnessAdopted",{name:i,titles:s.split(" | ").join(ao()==="zh"?"、":", ")}),action:{label:a.tr("ntf.actionView"),run:()=>Sn(o,"evolution")}})}function Cd(t,n){const s=P.getState(),a=s.configBySession[t]?.agentSlug||s.defaultAgentSlug;ue({event:"harness.candidates",level:"info",sticky:!0,dedupeKey:`harness.confirm:${n}`,text:s.tr("ntf.harnessConfirm",{name:s.agentDefs.find(o=>o.slug===a)?.name||a}),action:{label:s.tr("ntf.actionView"),run:()=>Sn(a,"evolution")}})}function Ed(t,n){const s=P.getState(),a=s.sessions.find(o=>o.id===t)?.project_path||"";ue({event:"memory.projectCandidates",level:"info",sticky:!0,dedupeKey:`memory.projectCandidates:${n}`,text:s.tr("ntf.projectCandidates",{name:a.split(/[\\/]/).filter(Boolean).pop()||""}),...a?{action:{label:s.tr("ntf.actionView"),run:()=>Ot({kind:"project",path:a})}}:{}})}function Td(t,n){const s=P.getState(),a=s.sessions.find(o=>o.id===t)?.project_path||"";ue({event:"memory.projectCompacted",level:"info",dedupeKey:`memory.projectCompacted:${n}`,text:s.tr("ntf.projectCompacted",{name:a.split(/[\\/]/).filter(Boolean).pop()||""}),...a?{action:{label:s.tr("ntf.actionView"),run:()=>Ot({kind:"project",path:a})}}:{}})}function Rd({sessionId:t}){const{t:n}=V(),s=P(y=>y.cfg),a=P(y=>y.connState==="ok"),[o,i]=c.useState(!1),[r,u]=c.useState(null),[p,f]=c.useState(!1),m=c.useRef(null),g=c.useRef(null),[w,x]=c.useState(null);c.useEffect(()=>{i(!1),u(null),f(!1),x(null),m.current=null,g.current=null},[t]),c.useEffect(()=>{if(!o||!a||w)return;let y=!1,N;const d=()=>{Ls(de(t),t,"historian").then(_=>_.find(b=>b.kind==="historian")?.sessionId??null,()=>null).then(_=>{y||(_?x(_):N=setTimeout(d,kd))})};return d(),()=>{y=!0,clearTimeout(N)}},[s,t,o,a,w]),c.useEffect(()=>{if(!a)return;let y=!1,N;const d=async()=>{try{const _=await Ti(de(t),t,o);if(!y){u(_),f(!1);const{fresh:b,seen:C}=Rl(_.activity||[],m.current);m.current=C;for(const h of b)h.action==="harness_adopted"?zd(t,h.id,h.detail||""):h.action==="harness_confirm"?Cd(t,h.id):h.action==="project_memory_candidates"?Ed(t,h.id):h.action==="project_memory_compacted"?Td(t,h.id):Nd(t,h.id);const j=_.activity?.find(h=>h.action==="icon_updated");j&&j.id!==g.current&&(g.current=j.id,nn(de(t),t).then(h=>{y||h.id!==t||P.setState(S=>({sessions:S.sessions.map(B=>B.id===t?{...B,emoji:h.emoji}:B),archivedSessions:S.archivedSessions.map(B=>B.id===t?{...B,emoji:h.emoji}:B)}))}).catch(()=>{y||(g.current=null)}))}}catch{y||f(!0)}y||(N=setTimeout(d,2500))};return d(),()=>{y=!0,clearTimeout(N)}},[s,t,o,a]);const z=r?.running?"working":"idle",k=(r?.records||[]).map(y=>({...y,content:Sd(y.content)})).filter(y=>y.content);return e.jsxs("div",{className:"t2o-team-status","data-historian-status":p?"unavailable":z,children:[e.jsxs("button",{type:"button",className:"t2o-desk-row","aria-expanded":o,onClick:()=>i(!o),children:[e.jsx(zt,{size:18,className:r?.running?"historian-working":void 0}),e.jsx("span",{className:"t2o-desk-name",children:"Historian"}),e.jsx("span",{className:"t2o-desk-dot","data-status":z}),e.jsx("span",{className:"t2o-desk-activity",children:n(p?"historian.status.unavailable":r?.running?"historian.status.working":"historian.status.ready")}),e.jsx(we,{size:12,style:{transform:o?"rotate(90deg)":void 0}})]}),o&&e.jsxs("div",{className:"t2o-desk-work","data-historian-work":!0,children:[k.map(y=>e.jsx(qe,{content:y.content},y.id)),(r?.activity||[]).map(y=>e.jsx("div",{className:"t2o-historian-event",children:y.detail},y.id)),!k.length&&!r?.activity.length&&e.jsx("div",{className:"panel-note",children:n("historian.status.empty")}),w&&e.jsx("button",{type:"button",className:"t2-tsum-more","data-historian-transcript":!0,onClick:()=>Ae.getState().open(t,{id:w,title:"Historian",sessionId:w}),children:n("historian.status.viewTranscript")})]})]})}te({"teamdesk.title":{zh:"团队工作台",en:"Team Desk"},"teamdesk.summary":{zh:"{n} 人 · {k} 工作中",en:"{n} members · {k} working"},"teamdesk.status.idle":{zh:"空闲",en:"Idle"},"teamdesk.status.working":{zh:"工作中",en:"Working"},"teamdesk.status.waiting":{zh:"等待审批",en:"Waiting for approval"},"teamdesk.status.done":{zh:"已完成",en:"Done"},"teamdesk.status.failed":{zh:"失败",en:"Failed"},"teamdesk.thinking":{zh:"思考中",en:"Thinking"},"teamdesk.noWork":{zh:"还没有工作记录",en:"No work yet"},"teamdesk.task":{zh:"任务:{task}",en:"Task: {task}"},"teamdesk.live":{zh:"直播中",en:"Live"},"teamdesk.connecting":{zh:"连接中",en:"Connecting"},"teamdesk.expand":{zh:"展开团队工作台",en:"Expand Team Desk"},"teamdesk.collapse":{zh:"收起",en:"Collapse"}});function Md(t){const n=P(qs(s=>({cfg:s.configBySession[t],work:s.teamWorkBySession[t],agentDefs:s.agentDefs,running:s.runningBySession[t],childRuns:s.runningBySession})));return c.useMemo(()=>(Array.isArray(n.cfg?.groupAgents)?n.cfg.groupAgents.map(String):[]).map(a=>{const o=n.work?.[a],i=n.agentDefs.find(p=>p.slug===a)?.name||o?.name||a,u=o?.sessionId&&n.childRuns[o.sessionId]?o?.status==="waiting"?"waiting":"working":o?!n.running&&(o.status==="working"||o.status==="waiting")?"idle":o.status:"idle";return{...o||{since:0},slug:a,name:i,status:u}}),[n.cfg,n.work,n.agentDefs,n.running,n.childRuns])}function Ad({slug:t,name:n,status:s}){const a=P(i=>i.agentAvatars[t]),o=`t2o-bar-avatar${s==="working"?" is-working":s==="waiting"?" is-waiting":""}`;return a?e.jsx("img",{src:a,width:18,height:18,alt:"",className:o}):e.jsx("span",{className:`${o} t2o-bar-avatar-text`,children:[...n][0]||"?"})}function Pd(t,n){return t.status==="working"?t.activity||(t.task?t.task:n("teamdesk.thinking")):t.status==="waiting"?n("teamdesk.status.waiting"):t.status==="failed"?n("teamdesk.status.failed"):t.status==="done"?t.task||n("teamdesk.status.done"):n("teamdesk.status.idle")}function Id({sessionId:t}){const{t:n}=V(),s=Md(t),a=P(i=>i.hydrateTeamWork),o=Ae(i=>i.selected[t]?.id);return c.useEffect(()=>{a(t)},[t,a]),e.jsx("div",{className:"t2o-team-status","data-team-desk":"status",children:s.map(i=>e.jsx("div",{children:e.jsxs("button",{type:"button",className:"t2o-desk-row","data-slug":i.slug,"data-status":i.status,"aria-pressed":o===i.slug,onClick:()=>Ae.getState().open(t,{id:i.slug,title:i.name,slug:i.slug,sessionId:i.sessionId,runId:i.runId,task:i.task}),children:[e.jsx(Ad,{slug:i.slug,name:i.name,status:i.status}),e.jsx("span",{className:"t2o-desk-name",children:i.name}),e.jsx("span",{className:"t2o-desk-dot","data-status":i.status,title:n(`teamdesk.status.${i.status}`)}),e.jsx("span",{className:"t2o-desk-activity",children:Pd(i,n)}),e.jsx(we,{size:12})]})},i.slug))})}function Dd(t,n,s){const a=t.filter(i=>s&&i.kind==="historian"),o=t.filter(i=>i.kind!=="teamwork"&&!a.includes(i)).map(i=>({id:i.sessionId,title:i.title||i.kind,sessionId:i.sessionId,runId:i.runId||void 0,streaming:i.runStatus==="running"||i.runStatus==="queued"}));for(const i of n||[])a.some(r=>r.sessionId===i.sessionId||!!r.runId&&r.runId===i.runId)||s&&i.bgKind==="historian"||o.some(r=>r.sessionId===i.sessionId||r.runId&&r.runId===i.runId)||o.push({id:i.id,title:i.title,sessionId:i.sessionId,runId:i.runId,streaming:i.streaming});return o}te({"childchat.title":{zh:"子会话",en:"Child conversation"},"childchat.hint":{zh:"消息仅发送给这个子会话,保留与主会话的关联。",en:"Messages stay in this child conversation, linked to the main conversation."},"childchat.notStarted":{zh:"正在打开成员子会话…",en:"Opening the member’s conversation…"},"childchat.legacy":{zh:"这条旧子任务没有保存独立会话。新任务会保留完整记录。",en:"This older task has no saved child conversation. New tasks retain their full history."},"childchat.retry":{zh:"重新载入",en:"Reload"}});function _d({sessionId:t}){const{t:n}=V(),s=P(p=>p.cfg),a=P(p=>p.subChatsBySession[t]),o=P(p=>!!p.specialEnabled.historian),[i,r]=c.useState([]);c.useEffect(()=>{let p=!1;r([]);const f=()=>{Ls(de(t),t).then(g=>{const w=Di(g,t);p||r(w)}).catch(()=>{})};f();const m=setInterval(f,Is(t).kind==="unit"?12e3:4e3);return()=>{p=!0,clearInterval(m)}},[s,t]);const u=Dd(i,a,o);return u.length?e.jsx("div",{className:"t2o-team-status","data-subchat-status":!0,children:u.map(p=>e.jsxs("button",{type:"button",className:"t2o-desk-row",onClick:()=>Ae.getState().open(t,p),children:[e.jsx(Os,{size:16}),e.jsx("span",{className:"t2o-desk-name",children:p.title}),e.jsx("span",{className:"t2o-desk-activity",children:n(p.streaming?"teamdesk.status.working":"teamdesk.status.done")}),e.jsx(we,{size:12})]},p.id))}):null}function Fd({parentId:t}){const n=Ae(b=>b.selected[t]),s=P(b=>n?.slug?b.teamWorkBySession[t]?.[n.slug]:void 0),a=s?.sessionId||n?.sessionId,o=s?.runId||n?.runId,i=P(b=>(b.subChatsBySession[t]||[]).some(C=>C.sessionId===a&&C.streaming)&&!!b.runningBySession[t]),r=P(b=>b.cfg),u=P(b=>b.deskBySession[t]?.fraction??.52),p=c.useRef(null),f=Ha(t,p),{t:m}=V(),[g,w]=c.useState(""),[x,z]=c.useState(""),[k,y]=c.useState(0),[N,d]=c.useState(!1);c.useEffect(()=>{if(!n?.slug||a)return;let b=!1;return z(""),Ri(de(t),t,n.slug).then(C=>{if(Mi(C.id,t)==="conflict")throw new Error(m("app.cannotCreateSession"));b||(Ae.getState().open(t,{...n,sessionId:C.id}),P.getState().hydrateTeamWork(t))}).catch(C=>{b||z(String(C.message||C))}),()=>{b=!0}},[r,t,n?.slug,a,k]),c.useEffect(()=>{if(w(""),z(""),d(!1),!a)return;let b=!1;return nn(de(a),a).then(async C=>{b||(d(!!C.delegate_running),Ae.getState().remember(C),P.setState(j=>({configBySession:{...j.configBySession,[a]:{...C.agent_config,...j.configBySession[a]}}})),await P.getState().loadSessionHistory(a),b||w(a))}).catch(C=>{b||z(String(C.message||C))}),()=>{b=!0}},[r,a,k]),c.useEffect(()=>{if(!a||!N)return;let b=!1;const C=setInterval(()=>{nn(de(a),a).then(j=>{!b&&!j.delegate_running&&Ai(de(a),a).then(h=>{b||(P.setState(S=>{const B=h.map(L=>Pi(L,void 0,K=>S.agentDefs.find(D=>D.slug===K)?.name)),J=new Set(B.map(L=>L.id));return{messagesBySession:{...S.messagesBySession,[a]:[...B,...(S.messagesBySession[a]||[]).filter(L=>!J.has(L.id))].sort((L,K)=>L.timestamp-K.timestamp)}}}),d(!1))}).catch(()=>{})}).catch(()=>{})},1500);return()=>{b=!0,clearInterval(C)}},[r,a,N]),c.useEffect(()=>{if(!a||!o||g!==a)return;let b=!1;return Ii(de(a),a).then(C=>{if(b)return;const j=C.find(S=>S.id===o&&(S.status==="running"||S.status==="queued"));if(!j?.assistant_message_id)return;const h=j.assistant_message_id;P.setState(S=>{const B=S.messagesBySession[a]||[];return B.some(J=>J.id===h)?{}:{messagesBySession:{...S.messagesBySession,[a]:[...B,{id:h,role:"assistant",content:"",status:"streaming",timestamp:Date.now()}]}}}),P.getState().subscribeRun(a,o,h)}).catch(()=>{}),()=>{b=!0}},[r,a,o,g]);const _=c.useMemo(()=>({id:`child-chat:${t}:${a}`,type:"child-chat",loc:"right",params:{},setTitle:()=>{},setParams:()=>{},close:()=>Ae.getState().close(t)}),[t,a]);return n?e.jsxs("div",{ref:p,className:"agent-desk open child-chat-panel","data-team-desk":"panel",style:{"--desk-w":`${u*100}%`},children:[e.jsx("div",{className:"agent-desk-grip",onPointerDown:f}),e.jsxs("div",{className:"agent-desk-inner",children:[e.jsxs("div",{className:"agent-desk-head",children:[e.jsx(Os,{size:15}),e.jsx("strong",{className:"agent-desk-title",children:n.title}),e.jsx("span",{className:"agent-desk-note",children:m("childchat.title")}),e.jsx("button",{className:"icon-btn","aria-label":m("teamdesk.collapse"),onClick:_.close,children:e.jsx(Ye,{size:16})})]}),e.jsx("div",{className:"child-chat-hint",children:m("childchat.hint")}),x?e.jsxs("div",{className:"child-chat-placeholder",role:"alert",children:[x,e.jsx("button",{onClick:()=>y(b=>b+1),children:m("childchat.retry")})]}):a?g!==a?e.jsx("div",{className:"child-chat-placeholder",children:e.jsx(Oe,{className:"spin",size:18})}):e.jsx(Ua,{leaf:_,params:{followActive:!1,sessionId:a,childSurface:!0,readOnly:i||N,teamSessionId:n.slug?t:void 0}},a):e.jsx("div",{className:"child-chat-placeholder",children:m(n.slug?"childchat.notStarted":"childchat.legacy")})]})]}):null}te({"team.summary":{zh:"Historian · 团队总结",en:"Historian · Team summary"}});function $d({message:t}){const{t:n}=V();return e.jsxs("details",{className:"t2-team-summary","data-team-summary":!0,children:[e.jsx("summary",{children:n("team.summary")}),e.jsx(qe,{content:t.content})]})}te({"studio.openTool":{zh:"编码工作室 · 打开项目工具",en:"Coding Studio · Open project tool"},"studio.projectTools":{zh:"项目工具",en:"Project tools"},"studio.panelPosition":{zh:"面板位置",en:"Panel position"},"studio.move.left":{zh:"移至左侧面板",en:"Move to left panel"},"studio.move.right":{zh:"移至右侧面板",en:"Move to right panel"},"studio.move.bottom":{zh:"移至底部面板",en:"Move to bottom panel"},"studio.inspectShort":{zh:"点选修改",en:"Select to edit"},"studio.filesShort":{zh:"文件",en:"Files"},"studio.chatTitle":{zh:"一起把想法做出来",en:"Build your idea together"},"studio.chatHint":{zh:"描述目标,或在预览中点选要修改的地方。",en:"Describe your goal, or select something in the preview to change."},"studio.chooseProject":{zh:"先在工作台创建或打开一个项目。",en:"Create or open a project in the studio first."},"studio.split":{zh:"并排",en:"Split"},"studio.desktop":{zh:"自适应",en:"Responsive"},"studio.tablet":{zh:"平板 · 768",en:"Tablet · 768"},"studio.phone":{zh:"手机 · 390",en:"Phone · 390"},"studio.inspect":{zh:"选择页面元素",en:"Select an element"},"studio.inspectHint":{zh:"点击预览中的元素,再描述你想怎样修改。Esc 取消。",en:"Click an element in the preview, then describe your change. Esc cancels."},"studio.selection":{zh:"定向修改",en:"Focused edit"},"studio.changePlaceholder":{zh:"例如:放大标题,保留现有配色",en:"For example: enlarge the heading and keep the colors"},"studio.addToChat":{zh:"加入对话",en:"Add to chat"},"studio.close":{zh:"关闭",en:"Close"},"studio.loading":{zh:"正在加载预览…",en:"Loading preview…"},"studio.previewFailed":{zh:"预览未能加载",en:"Preview could not load"},"studio.previewReady":{zh:"预览已加载",en:"Preview loaded"},"studio.previewIdle":{zh:"等待首个可运行页面",en:"Waiting for a runnable page"},"studio.sandbox.statusIdle":{zh:"插件项目 · 在 Sandbox 里加载试用",en:"Plugin project · load it from the Sandbox to try it"},"studio.building":{zh:"正在构建",en:"Building"},"studio.waiting":{zh:"等待你的回复",en:"Waiting for your input"},"studio.stopped":{zh:"停止生成",en:"Stop generation"},"studio.filesChanged":{zh:"{count} 个文件有改动",en:"{count} files changed"},"studio.autoRefresh":{zh:"实时刷新",en:"Live updates"},"studio.pendingChanges":{zh:"有新改动,点击刷新",en:"Changes ready. Reload to view."},"studio.files":{zh:"项目文件",en:"Project files"},"studio.terminal":{zh:"打开项目终端",en:"Open project terminal"},"studio.reveal":{zh:"在文件管理器中显示",en:"Show project folder"},"studio.project":{zh:"项目简报",en:"Project brief"},"studio.history":{zh:"版本",en:"Versions"},"studio.issues":{zh:"问题",en:"Issues"},"studio.checks":{zh:"验收",en:"Checks"},"studio.setup":{zh:"预览设置",en:"Preview settings"},"studio.sandbox":{zh:"Sandbox",en:"Sandbox"},"studio.pluginPreview":{zh:"插件没有页面预览",en:"A plugin has no page preview"},"studio.pluginPreviewHint":{zh:"插件不是网页,它加载进 Forsion 本身运行。打开 Sandbox,把这个项目加载进来试用。",en:"A plugin is not a web page: it is loaded into Forsion itself. Open the Sandbox to load this project and try it."},"studio.openSandbox":{zh:"打开 Sandbox",en:"Open Sandbox"},"studio.sandbox.notPlugin":{zh:"这个项目不是 Forsion 插件。项目根有 manifest.json(含 id、apiVersion 与 main)时,才能从这里加载。",en:"This project is not a Forsion plugin. It can be loaded here once the project root has a manifest.json with id, apiVersion and main."},"studio.sandbox.unavailable":{zh:"当前版本的应用还不支持从项目文件夹加载插件。",en:"This app version cannot load a plugin from a project folder yet."},"studio.sandbox.stateUnloaded":{zh:"未加载",en:"Not loaded"},"studio.sandbox.stateActive":{zh:"已加载,正在运行",en:"Loaded and running"},"studio.sandbox.stateBlocked":{zh:"不能从这里加载",en:"Cannot be loaded from here"},"studio.sandbox.stateFailed":{zh:"启动失败",en:"Failed to start"},"studio.sandbox.unloadedHint":{zh:"这个插件还没有加载进 Forsion。",en:"This plugin is not loaded into Forsion yet."},"studio.sandbox.activeHint":{zh:"项目开在编码工作室期间,保存即重载;关掉这个项目就不再重载。",en:"While this project is open in Coding Studio, saving reloads the plugin. Closing the project stops that."},"studio.sandbox.failedHint":{zh:"插件的 setup(ctx) 抛了错,这一次没能起来。改完保存会自动重试。",en:"The plugin threw from setup(ctx) and did not start. Saving a fix reloads it automatically."},"studio.sandbox.blockedFileext":{zh:"这个插件声明了自定义文件类型。宿主的防线只覆盖已安装目录,所以这类插件必须先安装再测。",en:"This plugin declares custom file types. The host safeguards only cover installed plugins, so install it to test custom file types."},"studio.sandbox.blockedApi":{zh:"宿主拒绝加载:manifest.json 的 apiVersion 不是这个版本的 Forsion 支持的值(目前为 1)。",en:"The host refused to load it: the apiVersion in manifest.json is not supported by this version of Forsion (currently 1)."},"studio.sandbox.blockedMinApp":{zh:"宿主拒绝加载:manifest.json 的 minAppVersion 高于当前 Forsion 的版本。",en:"The host refused to load it: the minAppVersion in manifest.json is newer than this version of Forsion."},"studio.sandbox.blockedOther":{zh:"宿主拒绝加载:{reason}",en:"The host refused to load it: {reason}"},"studio.sandbox.trust":{zh:"这不是隔离沙箱:开发副本就跑在这个真应用、你的真智库上,与已安装插件同权。试验期间别写、挪、删你的数据;定时器与监听必须在 disposer 里清掉——每次保存都会重跑一遍 setup,漏清一次就叠一层。",en:"This is not an isolated sandbox: the dev copy runs in this real app, on your real notes, with the same privileges as an installed plugin. Do not write, move or delete your data while experimenting, and release every timer and listener in the disposer, because each save runs setup again and anything left behind stacks up."},"studio.sandbox.staleGrant":{zh:"之前的加载授权已失效(项目文件夹被重建或移动过,或是旧版本 Forsion 记下的授权)。确认这是你的项目后,再点一次「加载」。",en:"The earlier permission to load this project no longer applies (the folder was recreated or moved, or the permission was saved by an older Forsion version). If this is your project, choose Load again."},"studio.sandbox.shadow":{zh:"这个插件已安装的副本在开发副本加载期间被顶替;期间它的「卸载」不可用。",en:"The installed copy of this plugin is replaced while the dev copy is loaded, and Uninstall is unavailable meanwhile."},"studio.sandbox.load":{zh:"在 Forsion 中加载",en:"Load into Forsion"},"studio.sandbox.loading":{zh:"正在加载…",en:"Loading…"},"studio.sandbox.unload":{zh:"卸载开发副本",en:"Unload"},"studio.sandbox.unloading":{zh:"正在卸载…",en:"Unloading…"},"studio.sandbox.reload":{zh:"立即重载",en:"Reload now"},"studio.sandbox.reloading":{zh:"正在重载…",en:"Reloading…"},"studio.sandbox.retry":{zh:"重试重载",en:"Retry reload"},"studio.sandbox.halfDone":{zh:"这个项目已标记为开发插件源,但这次重载没成功。重试重载即可。",en:"This project is marked as a dev plugin source, but the reload did not finish. Try the reload again."},"studio.sandbox.setupError":{zh:"setup(ctx) 抛出的错误",en:"Error thrown by setup(ctx)"},"studio.sandbox.mountErrors":{zh:"视图加载错误",en:"View mount errors"},"studio.sandbox.console":{zh:"这个插件的控制台输出",en:"Console output from this plugin"},"studio.sandbox.noEvidence":{zh:"还没有任何输出。在应用里操作这个插件,报错和 console 输出会出现在这里。",en:"Nothing captured yet. Use the plugin in the app and its errors and console output appear here."},"studio.sandbox.clear":{zh:"清空输出",en:"Clear output"},"studio.sandbox.note":{zh:"发生了什么?(可选)",en:"What happened? (optional)"},"studio.sandbox.send":{zh:"带上证据发回对话",en:"Send evidence to chat"},"studio.noIssues":{zh:"暂未捕获运行错误。仍需实际操作,确认流程和视觉效果。",en:"No runtime errors captured. Try the flows and check the visual result."},"studio.issueDescription":{zh:"发生了什么?你期待怎样的结果?",en:"What happened, and what did you expect?"},"studio.diagnose":{zh:"带上证据修复",en:"Fix with evidence"},"studio.clearIssues":{zh:"清空记录",en:"Clear captured issues"},"studio.errorCount":{zh:"{count} 条运行问题",en:"{count} runtime issues"},"studio.noBrief":{zh:"为已有项目补一份简报,后续修改都能沿用。",en:"Add a brief to keep future changes aligned with this project."},"studio.idea":{zh:"项目目标",en:"Project goal"},"studio.audience":{zh:"给谁使用",en:"Audience"},"studio.constraints":{zh:"必须保留的要求",en:"Requirements to preserve"},"studio.briefSaved":{zh:"简报已保存到项目文件。",en:"Brief saved to the project file."},"studio.saveBrief":{zh:"保存简报",en:"Save brief"},"studio.plan":{zh:"先做计划",en:"Plan first"},"studio.build":{zh:"开始构建",en:"Start building"},"studio.promptReady":{zh:"已加入左侧草稿,可继续编辑后发送。",en:"Added to the chat draft. Edit it before sending."},"studio.firstPage":{zh:"把想法变成第一个可运行版本",en:"Turn your idea into a working first version"},"studio.firstPageHint":{zh:"从项目简报开始,或在左侧描述需求。代码写好后,预览会自动出现在这里。",en:"Start with your brief, or describe what you need in chat. Your app will appear here as files are created."},"studio.staticPreview":{zh:"即时预览",en:"Instant preview"},"studio.devServer":{zh:"本地开发服务",en:"Local dev server"},"studio.devHint":{zh:"已有 Vite、Next.js 等项目:先在项目终端启动,再填入本机地址。发布功能适用于即时预览的静态项目。",en:"For Vite, Next.js or an existing app, start its server in the project terminal and enter the local URL. Publishing supports static projects using instant preview."},"studio.devUrl":{zh:"本机预览地址",en:"Local preview URL"},"studio.invalidUrl":{zh:"请输入 localhost、127.0.0.1 或 [::1] 的 HTTP(S) 地址。",en:"Use an HTTP(S) URL on localhost, 127.0.0.1 or [::1]."},"studio.apply":{zh:"应用",en:"Apply"},"studio.useStatic":{zh:"使用即时预览",en:"Use instant preview"},"studio.entry":{zh:"入口页面",en:"Entry page"},"studio.loadError":{zh:"无法读取项目:{error}",en:"Could not read project: {error}"},"studio.retry":{zh:"重新加载",en:"Try again"},"studio.versionName":{zh:"例如:首页布局定稿",en:"For example: approved home layout"},"studio.saveVersion":{zh:"保存版本",en:"Save version"},"studio.noVersions":{zh:"还没有版本。满意当前效果时,保存一个版本再继续尝试。",en:"No versions yet. Save a version you like before trying something new."},"studio.restore":{zh:"恢复源码",en:"Restore source"},"studio.confirmRestore":{zh:"确认恢复此版本?当前源码会先自动备份。",en:"Restore this version? Current source will be backed up first."},"studio.cancel":{zh:"取消",en:"Cancel"},"studio.versionSaved":{zh:"源码版本已保存。",en:"Source version saved."},"studio.restored":{zh:"已恢复 {restored} 个文件,移除 {deleted} 个新增文件;当前版本已备份。",en:"Restored {restored} files and removed {deleted} added files. Previous source was backed up."},"studio.restoreConflicts":{zh:"{count} 个文件在恢复期间被修改,已保留,请检查。",en:"{count} files changed during restore and were preserved. Please review them."},"studio.saveFirst":{zh:"请先处理未保存的修改,并等待生成结束。",en:"Resolve unsaved edits and wait for generation to finish first."},"studio.manualChecks":{zh:"亲自验证后再勾选。预览能打开不等于功能已通过;项目有新改动时勾选会重置。",en:"Check these only after testing. A loaded preview is not a verified app. New project changes reset these checks."},"studio.checkMain":{zh:"主要流程可完整操作",en:"The main user flow works end to end"},"studio.checkPhone":{zh:"手机宽度下可读、可点",en:"Readable and usable at phone width"},"studio.checkFailure":{zh:"空数据、加载和失败都有提示",en:"Empty, loading and failure states are clear"},"studio.checkData":{zh:"刷新后的数据行为符合预期",en:"Data behaves as expected after reload"},"studio.checkAccess":{zh:"键盘操作与颜色对比可用",en:"Keyboard access and text contrast are usable"},"studio.askVerify":{zh:"让 AI 帮我检查",en:"Ask AI to check"},"studio.publishStaticOnly":{zh:"当前使用开发服务,请先构建可发布的静态页面。",en:"This project uses a dev server. Build a static page before publishing."},"studio.publishImported":{zh:"发布前请将项目复制到 Forsion 的 Project 文件夹。",en:"Copy this project into the Forsion Project folder before publishing."},"studio.streaming":{zh:"正在写入 · {file}",en:"Writing · {file}"},"studio.watchError":{zh:"文件监听不可用,可手动刷新。{error}",en:"File watching is unavailable. Reload manually. {error}"},"studio.history.showInstall":{zh:"查看安装方式",en:"Show how to install"},"studio.history.gitWhy":{zh:"编码工作室用 Git 记录项目版本:装好之后,每轮 AI 改动都会自动存一版,你也可以随时保存命名版本。编码工作室的其他功能都不需要它。",en:"Coding Studio uses git to keep project versions: once it is installed, every agent run is saved automatically and you can save named versions yourself. Nothing else in Coding Studio needs it."},"studio.history.firstVersionNote":{zh:"保存第一个版本会在项目文件夹里创建 Git 仓库(.git)。",en:"Saving the first version creates a git repository (.git) in the project folder."},"studio.history.enableNote":{zh:"这个文件夹还没有版本历史。保存第一个版本会在里面创建 Git 仓库(.git),之后每轮 AI 改动都会自动存一版。",en:"This folder has no version history yet. Saving the first version creates a git repository (.git) in it; after that, every AI turn is saved as a version automatically."},"studio.history.readonlyForeign":{zh:"这个项目用的是它自己的 Git 仓库;Forsion 只展示历史,不做任何改动。",en:"This project uses its own git repository; Forsion shows its history but does not change it."},"studio.history.readonlyNested":{zh:"这个项目位于另一个 Git 仓库内部。",en:"This project lives inside another git repository."},"studio.history.readonlyOutside":{zh:"只有加入造物的项目,版本才由 Forsion 管理。",en:"Version history is only managed for projects in Creations."},"studio.history.readonlyBridge":{zh:"当前版本的应用只能查看版本历史;保存与恢复需要更新到新版本。",en:"This app version can only show version history; saving and restoring need a newer version."},"studio.history.untitled":{zh:"未命名版本",en:"Untitled version"},"studio.history.backupName":{zh:"恢复前的备份",en:"Backup before restore"},"studio.history.restorePrefix":{zh:"恢复到:",en:"Restore:"},"studio.history.noChanges":{zh:"与上一个版本相比没有改动。",en:"No changes since the last version."},"studio.history.files":{zh:"{count} 个文件",en:"{count} files"},"studio.history.auto":{zh:"自动",en:"Auto"},"studio.history.autoFallback":{zh:"AI 改动",en:"Agent changes"},"studio.history.autoFooter":{zh:"这个项目在编码工作室里打开时,每轮 AI 改动结束后都会自动存一个版本。",en:"Automatic versions are created after each agent run while this project is open in Coding Studio."},"studio.history.confirmRestore":{zh:"恢复到这个版本?当前状态会先存成一个备份版本,所以这次恢复本身也能撤销。",en:"Restore this version? The current state is saved as a backup version first, so restoring is itself undoable."},"studio.history.restored":{zh:"已恢复到该版本;恢复前的状态已存为备份版本。",en:"Restored. The previous state was saved as a backup version."},"studio.history.restoredClean":{zh:"已恢复到该版本。",en:"Restored to this version."},"studio.history.empty":{zh:"这个仓库还没有提交。",en:"This repository has no commits yet."},"studio.history.legacy":{zh:"更早的快照(只读)",en:"Earlier snapshots (read-only)"},"studio.history.legacyHint":{zh:"这些是启用 Git 之前保存的快照,可以恢复,但不再新增。",en:"These snapshots were saved before git was used here. They can be restored, but no new ones are created."}});function Ld(t){return t.filter(n=>(n.modelType||"llm")==="llm")}te({"reset.ceremony.eyebrow":{zh:"FORSION · 额度重置卡",en:"FORSION · Quota reset card"},"reset.ceremony.title":{zh:"额度已焕新",en:"Quota restored"},"reset.ceremony.both":{zh:"今日与本周额度已恢复",en:"Today's and this week's quota has been restored"},"reset.ceremony.dailyLabel":{zh:"今日",en:"Today"},"reset.ceremony.weeklyLabel":{zh:"本周",en:"This week"},"reset.ceremony.remaining":{zh:"额度重置卡剩余 {n} 张",en:"{n} quota reset cards remaining"},"reset.ceremony.continue":{zh:"继续使用",en:"Continue"},"reset.ceremony.close":{zh:"关闭",en:"Close"}});const fs=(t,n)=>Fi(t[`${n}Limit`],t[`${n}Remaining`],t[`${n}Percent`]);function Wa({result:t,onClose:n,returnFocusSelector:s}){const{t:a}=V(),o=c.useRef(null),i=c.useRef(null),r=c.useRef(n);r.current=n;const u=c.useMemo(()=>["daily","weekly"].map(p=>({period:p,before:fs(t.before,p),after:fs(t.after,p)})).filter(p=>p.after!==null),[t]);return c.useEffect(()=>{const p=document.activeElement instanceof HTMLElement?document.activeElement:null;o.current?.focus();const f=m=>{if(m.key==="Escape"){m.preventDefault(),r.current();return}if(m.key!=="Tab")return;const g=o.current,w=i.current;if(!(!g||!w)){if(getComputedStyle(w).visibility==="hidden"){m.preventDefault(),g.focus();return}m.shiftKey&&document.activeElement===g?(m.preventDefault(),w.focus()):!m.shiftKey&&document.activeElement===w&&(m.preventDefault(),g.focus())}};return window.addEventListener("keydown",f),()=>{window.removeEventListener("keydown",f),p?.isConnected?p.focus():document.querySelector(s)?.focus()}},[s]),_i.createPortal(e.jsx("div",{className:"reset-ceremony-backdrop",children:e.jsxs("section",{className:"reset-ceremony",role:"dialog","aria-modal":"true","aria-labelledby":"reset-ceremony-title","aria-describedby":"reset-ceremony-description",children:[e.jsx("button",{ref:o,className:"reset-ceremony-close","aria-label":a("reset.ceremony.close"),onClick:n,children:e.jsx(Ye,{size:16,"aria-hidden":"true"})}),e.jsxs("div",{className:"reset-ceremony-scene","aria-hidden":"true",children:[e.jsx("span",{className:"reset-ceremony-halo"}),e.jsxs("div",{className:"reset-ceremony-card",children:[e.jsxs("div",{className:"reset-ceremony-card-top",children:[e.jsx("span",{children:"FORSION"}),e.jsx($t,{size:19,strokeWidth:1.5})]}),e.jsx("span",{className:"reset-ceremony-card-mark",children:"F"}),e.jsx("span",{className:"reset-ceremony-card-bottom",children:"QUOTA RESET"}),e.jsx("span",{className:"reset-ceremony-card-sheen"})]}),e.jsx("span",{className:"reset-ceremony-seal",children:e.jsx(As,{size:21,strokeWidth:2.2})})]}),e.jsx("div",{className:"reset-ceremony-eyebrow",children:a("reset.ceremony.eyebrow")}),e.jsx("h2",{id:"reset-ceremony-title",children:a("reset.ceremony.title")}),e.jsx("p",{id:"reset-ceremony-description",children:a("reset.ceremony.both")}),u.length>0&&e.jsx("div",{className:"reset-ceremony-quotas",children:u.map(({period:p,before:f,after:m})=>e.jsxs("div",{className:"reset-ceremony-quota",children:[e.jsxs("div",{className:"reset-ceremony-quota-copy",children:[e.jsx("span",{children:a(`reset.ceremony.${p}Label`)}),e.jsxs("span",{className:"reset-ceremony-values",children:[e.jsx("span",{children:f==null?"—":sn(f,"—")}),e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx("strong",{children:sn(m,"—")})]})]}),e.jsx("div",{className:"reset-ceremony-track","aria-hidden":"true",children:e.jsx("span",{style:{"--reset-before":`${f??0}%`,"--reset-after":`${m}%`}})})]},p))}),e.jsxs("div",{className:"reset-ceremony-footer",children:[t.remainingCards!=null&&e.jsx("span",{children:a("reset.ceremony.remaining",{n:String(t.remainingCards)})}),e.jsx("button",{ref:i,className:"reset-ceremony-continue",onClick:n,children:a("reset.ceremony.continue")})]})]})}),document.body)}function _u(t,n=".ribbon-account, .account-card"){const s=document.createElement("div");document.body.appendChild(s);const a=Nr.createRoot(s);let o=!1;const i=()=>{o||(o=!0,queueMicrotask(()=>{a.unmount(),s.remove()}))};a.render(e.jsx(oo,{children:e.jsx(Wa,{result:t,onClose:i,returnFocusSelector:n})}))}const Zt=10;te({"quota.banner.period.daily":{zh:"今日 AI 额度",en:"Today's AI quota"},"quota.banner.period.weekly":{zh:"本周 AI 额度",en:"This week's AI quota"},"quota.banner.low":{zh:"{period}剩余 {percent}",en:"{period} has {percent} remaining"},"quota.banner.near":{zh:"{period}即将用尽,仅剩 {percent}",en:"{period} is almost used up, with {percent} remaining"},"quota.banner.critical":{zh:"{period}严重不足,仅剩 {percent}",en:"{period} is critically low, with {percent} remaining"},"quota.banner.exhausted":{zh:"{period}已用尽",en:"{period} is exhausted"},"quota.banner.upgrade":{zh:"升级会员",en:"Upgrade membership"},"quota.banner.useReset":{zh:"使用额度重置卡({n})",en:"Use a quota reset card ({n})"},"quota.banner.noReset":{zh:"暂无额度重置卡",en:"No quota reset card"},"quota.banner.confirmReset":{zh:"再次点击确认",en:"Click again to confirm"},"quota.banner.resetFail":{zh:"重置额度失败",en:"Failed to reset quota"},"quota.banner.close":{zh:"关闭额度提示",en:"Dismiss quota notice"},"quota.banner.bg.period.daily":{zh:"今日后台额度",en:"Today's background quota"},"quota.banner.bg.period.weekly":{zh:"本周后台额度",en:"This week's background quota"},"quota.banner.bg.exhausted":{zh:"{period}已用尽,Muse 与自动化已暂停",en:"{period} is exhausted; Muse and automations are paused"},"quota.banner.bg.autoMain":{zh:"{period}已用尽,正在用 AI 额度继续",en:"{period} is exhausted; continuing on your AI quota"},"quota.banner.bg.convert":{zh:"从 AI 额度转入 {percent}%",en:"Move {percent}% from AI quota"},"quota.banner.bg.convertDone":{zh:"已从 AI 额度转入 {percent}%,本周期有效",en:"Moved {percent}% from your AI quota for this period"},"quota.banner.bg.convertFail":{zh:"转入失败",en:"Failed to move quota"},"quota.banner.bg.noMain":{zh:"AI 额度已用完,没有可转入的额度",en:"Your AI quota is used up; there is nothing to move"},"quota.banner.bg.settings":{zh:"后台额度设置",en:"Background quota settings"}});function qd({loggedIn:t,onToast:n}){const{t:s}=V(),[a,o]=c.useState(null),[i,r]=c.useState(null),[u,p]=c.useState(!1),[f,m]=c.useState(!1),[g,w]=c.useState(null),[x,z]=c.useState(!1),[k,y]=c.useState(!1),N=c.useRef(0),d=c.useRef(0),_=c.useCallback(()=>{if(!t||!window.tangu?.accountQuota){o(null);return}const E=++N.current;window.tangu.accountQuota().then(F=>{if(E!==N.current)return;const W=F?.status===200&&F.json?F.json:null;o(W),W&&Vt(W)}).catch(()=>{E===N.current&&o(null)})},[t]);c.useEffect(()=>{if(!t){++N.current,++d.current,o(null),m(!1),p(!1),y(!1),z(!1),w(null);return}_();const E=()=>_();return window.addEventListener("focus",E),()=>{++N.current,++d.current,window.removeEventListener("focus",E)}},[t,_]),c.useEffect(()=>$i(E=>{t&&o(E)}),[t]);const b=c.useMemo(()=>Li(Bi(a),qi()?Oi(a):null),[a]),C=b?.advisory??null,j=b?.bucket==="background",h=b?`${b.bucket}:${b.advisory.period}:${b.advisory.threshold}`:null;c.useEffect(()=>{p(!1),z(!1),h||r(null)},[h]);const S=g&&e.jsx(Wa,{result:g,onClose:()=>w(null),returnFocusSelector:".t2c-ta"});if(!t||!a||!C||i===h)return S;const B=s(j?`quota.banner.bg.period.${C.period}`:`quota.banner.period.${C.period}`),J=sn(C.remainingPercent,""),L=C.exhausted?j?a.background?.autoMain?"quota.banner.bg.autoMain":"quota.banner.bg.exhausted":"quota.banner.exhausted":C.threshold===5?"quota.banner.critical":C.threshold===10?"quota.banner.near":"quota.banner.low",K=Math.max(0,Number(a.resetCards)||0),D=async()=>{if(!K||f||!window.tangu?.accountUseResetCard)return;if(!u){p(!0);return}m(!0);const E=++d.current;try{const F=await window.tangu.accountUseResetCard("both");if(E!==d.current)return;if(F?.status===200&&F.json?.success){const W={...F.json.quota||{},resetCards:F.json.resetCards};o(W),Vt(W),w({scope:"both",before:a,after:W,remainingCards:F.json.resetCards})}else n?.(String(F?.json?.detail||s("quota.banner.resetFail")),!0)}catch(F){E===d.current&&n?.(String(F?.message||F||s("quota.banner.resetFail")),!0)}finally{E===d.current&&(m(!1),p(!1))}},q=async()=>{if(k||!window.tangu?.accountBgConvert)return;if(!x){z(!0);return}y(!0);const E=++d.current;try{const F=await window.tangu.accountBgConvert(Zt);if(E!==d.current)return;if(F?.status===200&&F.json?.success){const W={...F.json.quota||{},resetCards:a.resetCards};o(W),Vt(W),n?.(s("quota.banner.bg.convertDone",{percent:String(Zt)}))}else n?.(F?.json?.error==="insufficient_main_quota"?s("quota.banner.bg.noMain"):String(F?.json?.detail||s("quota.banner.bg.convertFail")),!0)}catch(F){E===d.current&&n?.(String(F?.message||F||s("quota.banner.bg.convertFail")),!0)}finally{E===d.current&&(y(!1),z(!1))}};return e.jsxs(e.Fragment,{children:[S,e.jsxs("div",{className:"t2-quota-advisory","data-level":C.critical?"critical":C.threshold===10?"near":"low","data-bucket":j?"background":"main",role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"t2-quota-advisory-copy",children:[e.jsx(sa,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:s(L,{period:B,percent:J})})]}),j?e.jsxs("span",{className:"t2-quota-advisory-actions",children:[!!window.tangu?.accountBgConvert&&e.jsxs("button",{className:"t2-quota-action convert",disabled:k,onClick:()=>{q()},children:[e.jsx(Fr,{size:12,className:k?"spin":void 0,"aria-hidden":"true"}),x?s("quota.banner.confirmReset"):s("quota.banner.bg.convert",{percent:String(Zt)})]}),e.jsxs("button",{className:"t2-quota-action settings",onClick:()=>P.getState().openSettings("forsion/fx:forsion-extend:quota"),children:[e.jsx(Hi,{size:12,"aria-hidden":"true"})," ",s("quota.banner.bg.settings")]})]}):e.jsxs("span",{className:"t2-quota-advisory-actions",children:[!!window.tangu?.openPayCenter&&e.jsxs("button",{className:"t2-quota-action upgrade",onClick:()=>{window.tangu?.openPayCenter?.()},children:[s("quota.banner.upgrade")," ",e.jsx(Ir,{size:12,"aria-hidden":"true"})]}),!!window.tangu?.accountUseResetCard&&e.jsxs("button",{className:"t2-quota-action reset",disabled:!K||f,title:K?void 0:s("quota.banner.noReset"),onClick:()=>{D()},children:[e.jsx($t,{size:12,className:f?"spin":void 0,"aria-hidden":"true"}),u?s("quota.banner.confirmReset"):K?s("quota.banner.useReset",{n:String(K)}):s("quota.banner.noReset")]})]}),e.jsx("button",{className:"t2-quota-dismiss",title:s("quota.banner.close"),"aria-label":s("quota.banner.close"),onClick:()=>r(h),children:e.jsx(Ye,{size:13,"aria-hidden":"true"})})]})]})}te({"engine.target.retry":{zh:"重试",en:"Retry"}});const Od={offline:cn,"engine-unavailable":al,"engine-auth":Ui,"caller-unavailable":On,refused:On,"rate-limited":hl,gone:Lr,connecting:Oe,failed:cn},gs={offline:"engine.target.offline","engine-unavailable":"engine.target.engineUnavailable","engine-auth":"engine.target.engineAuth","caller-unavailable":"engine.target.callerUnavailable",refused:"engine.target.refused","rate-limited":"engine.target.rateLimited",gone:"engine.target.gone"},Bd=new Set(["offline","engine-unavailable","rate-limited","failed","caller-unavailable","engine-auth","refused"]);function Va(t){const n=Dt(t),s=P(a=>a.connState);return Hs(a=>n.kind==="unit"?a.byKey[Ws(n)]:void 0),Wi({connState:s},t)}function Hd(t){const{t:n}=V(),s=Dt(t),a=Va(t);if(an(o=>o.name),!(s.kind!=="unit"||a))return n("engine.target.composerWaiting",{name:Bs(s)||n("engine.target.defaultName")})}function Wd({fallback:t,sessionId:n}){const{t:s}=V(),a=Dt(n),o=an(y=>y.ref);an(y=>y.name);const i=Vi(a,o),r=Bs(a),u=a.kind==="unit"?Ws(a):null,p=Hs(y=>u?y.byKey[u]:void 0),f=P(y=>y.connState),m=P(y=>y.connMessage);if(!u)return e.jsx(e.Fragment,{children:t});const g=r||s("engine.target.defaultName");let w=null,x="";if(p&&gs[p.state]){w=p.state;const y="code"in p?p.code:void 0,N="refusal"in p?p.refusal:void 0;x=Dr(y,N)||s(gs[p.state],{name:g})}else i&&f==="idle"?(w="connecting",x=s("engine.target.connecting",{name:g})):i&&f==="err"&&(w="failed",x=m||s("engine.target.offline",{name:g}));if(!w)return e.jsx(e.Fragment,{children:t});const z=Od[w]??cn,k=()=>{if(i){Ki().catch(()=>{});return}const y=Gi(a);y&&Yi(y).catch(()=>{})};return e.jsxs("div",{className:"t2-quota-advisory t2-target-health","data-target-health":w,role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"t2-quota-advisory-copy",children:[e.jsx(z,{size:14,"aria-hidden":"true",className:w==="connecting"?"spin":void 0}),e.jsx("span",{children:x})]}),Bd.has(w)&&e.jsx("span",{className:"t2-quota-advisory-actions",children:e.jsxs("button",{className:"t2-quota-action reset",onClick:k,children:[e.jsx($t,{size:12,"aria-hidden":"true"})," ",s("engine.target.retry")]})})]})}const Vd=[],Ud={},Kd={ctx:0,base:0,live:0},Gd=[],Yd=[],vs=t=>!!t.teamSummary||!!t.work&&!t.content&&!t.error&&!t.approvals?.length&&!t.inquiries?.length;function Ua({leaf:t,params:n}){const{t:s}=V(),a=yl(),o=Ae(l=>l.selected),[i,r]=c.useState(!1),u=c.useRef(null),p=c.useRef(null),f=c.useRef(null),m=c.useRef(!0),g=c.useRef(0),w=P(l=>l.activeId),x=n.followActive!==!1,z=Ji(l=>l.activeSpaceId==="coding"),k=x&&(!!n.studio||z),y=on(l=>l.activeProject),N=typeof n.sessionId=="string"?n.sessionId:null,d=x?w:N,_=Hd(d),b=Va(d),C=mo(),j=P(l=>!!(d&&l.historyLoading[d])),h=P(qs(l=>({activeSession:l.sessions.find(M=>M.id===d)||l.archivedSessions.find(M=>M.id===d)||null,activeMessages:d&&l.messagesBySession[d]||Vd,running:!!(d&&l.runningBySession[d]),runStats:d&&l.runStatsBySession[d]||null,historianEnabled:l.specialEnabled.historian,execConfig:d&&l.configBySession[d]||Ud,activeUsage:d&&l.usageBySession[d]||Kd,activeCtxInfo:d&&l.ctxInfoBySession[d]||null,isGroupVoting:!!(d&&l.groupVoting[d]),llmRetry:d&&l.llmRetryBySession[d]||null,compacting:d?l.compactingBySession[d]:void 0,cfg:l.cfg,authInfo:l.authInfo,desktopConfig:l.desktopConfig,modelsResp:l.modelsResp,newChatWs:l.newChatWs,newChatCfg:l.newChatCfg,newChatModel:l.newChatModel,sessionMode:l.sessionMode,setSessionMode:l.setSessionMode,pendingDraft:l.pendingDraft,setPendingDraft:l.setPendingDraft,pendingShare:l.pendingShare,takePendingShare:l.takePendingShare,pendingChatQuote:l.pendingChatQuote,clearPendingChatQuote:l.clearPendingChatQuote,draftRefs:l.draftRefs,appendRefs:l.appendRefs,clearDraftRefs:l.clearDraftRefs,steerPending:d&&l.steerPendingBySession[d]||Gd,steerSent:d&&l.steerSentBySession[d]||Yd,steerRestore:d&&l.steerRestoreBySession[d]||null,jumpTarget:l.jumpTarget,clearJumpTarget:l.clearJumpTarget,withdrawSteer:l.withdrawSteer,steerNow:l.steerNow,clearSteerRestore:l.clearSteerRestore,engines:l.engines,engineCaps:l.engineCaps,agentDefs:l.agentDefs,agentAvatars:l.agentAvatars,defaultAgentSlug:l.defaultAgentSlug,skillsList:l.skillsList,connState:l.connState,connMessage:l.connMessage,filePreview:l.filePreview,openFeedback:l.openFeedback,toast:l.toast,editUserMessage:l.editUserMessage,regenerate:l.regenerate,branchFromMessage:l.branchFromMessage,rewindTo:l.rewindTo,decideApproval:l.decideApproval,answerInquiry:l.answerInquiry,setFilePreview:l.setFilePreview,setSessionEngine:l.setSessionEngine,setNewChatCfg:l.setNewChatCfg,selectSessionAgent:l.selectSessionAgent,selectNewChatAgent:l.selectNewChatAgent,workspaces:l.workspaces,setNewChatWs:l.setNewChatWs,addLocalWorkspace:l.addLocalWorkspace,addCloudProject:l.addCloudProject,setSessionModel:l.setSessionModel,setNewChatModel:l.setNewChatModel,setSessionEngineModel:l.setSessionEngineModel,setSessionThinking:l.setSessionThinking,setDefaultModel:l.setDefaultModel,setModelContextWindow:l.setModelContextWindow,setSessionMaxIterations:l.setSessionMaxIterations,setSessionPlanMode:l.setSessionPlanMode,voiceOnByAgent:l.voiceOnByAgent,setVoiceMode:l.setVoiceMode,setSessionGroup:l.setSessionGroup,newSession:l.newSession,openSettings:l.openSettings,setExecConfig:l.setExecConfig,send:l.send,stop:l.stop,compact:l.compact}))),[S,B]=c.useState(null),[J,L]=c.useState(""),[K,D]=c.useState(!1),[q,E]=c.useState(null),[F,W]=c.useState(""),[X,ae]=c.useState(!1),Q=Ae(l=>d?l.sessions[d]:void 0),H=h.activeSession||Q,le=(h.modelsResp?.models||[]).find(l=>l.id===(H?.model_id||h.cfg.modelId||h.modelsResp?.defaultModelId||""))||null,ne=h.activeCtxInfo&&(!h.activeCtxInfo.modelId||!le||h.activeCtxInfo.modelId===le.id)?h.activeCtxInfo:null,I=h.activeUsage,O=h.activeMessages,Y=c.useMemo(()=>_c(O),[O]),ee=h.running,ce=h.execConfig,G=ot(l=>l.vaultRoot);c.useEffect(()=>{const l=h.pendingChatQuote;!l||l.targetType!==t.type||(W(l.text),h.clearPendingChatQuote(l.seq))},[t.type,h.pendingChatQuote,h.clearPendingChatQuote]);const A=Qi(d?ce.execMode?ce:{execMode:H?.project_path?"host":"sandbox",approvalMode:"auto-edit",cwd:H?.project_path||void 0,...ce}:(()=>{const l=Xi(h.sessionMode,h.newChatWs,Zi()),M=l==="chat"||h.newChatWs?.kind==="cloud"||h.newChatWs?.kind==="rootless";return er(tr({execMode:M?"sandbox":"host",...nr(h.desktopConfig,!M,l),cwd:M?void 0:h.newChatWs?.path||void 0,...h.newChatCfg},l))})(),G),fe=typeof n.teamSessionId=="string"&&n.teamSessionId===A.teamMember?.teamSessionId?n.teamSessionId:void 0,he=P(l=>fe?l.configBySession[fe]:void 0),Ce=sr({...h,activeId:d}),Pe=h.modelsResp?.models?Ld(h.modelsResp.models):null,ve=d?ce.engineId:h.newChatCfg.engineId,_e=c.useMemo(()=>O.find(l=>l.status==="streaming")?.id??null,[O]),pe=h.runStats,Fe=c.useMemo(()=>{if(!pe)return null;for(let l=O.length-1;l>=0;l--){const M=O[l];if(M.role==="assistant"&&!vs(M))return ar(pe,M.timestamp)?M.id:null}return null},[O,pe]),Z=c.useMemo(()=>{const l=O.filter(U=>U.role==="user"&&!U.content.startsWith("<turn_interrupted>")&&!U.content.startsWith(Sa)).map(U=>U.content),M=new Set(l);return[...l,...h.steerSent.filter(U=>!M.has(U))]},[O,h.steerSent]),re=A.agentSlug||h.defaultAgentSlug,Be=re?h.agentAvatars[re]:void 0,v=ve?h.engines.find(l=>l.id===ve)?.name:re?h.agentDefs.find(l=>l.slug===re)?.name:void 0,R=h.authInfo?.nickname||h.authInfo?.username||void 0,T=h.authInfo?.avatar||void 0,$=re?!!h.voiceOnByAgent[re]:!1;c.useEffect(()=>{P.getState().ensureEngineCaps(ve||void 0)},[ve]),c.useEffect(()=>{re&&P.getState().refreshVoiceMode(re)},[re]);const ie=c.useCallback(l=>{u.current=l,Le.getState().registerChatSurface(t.id,l)},[t.id]),ye=c.useRef(null);c.useEffect(()=>{const l=ye.current;if(!l||typeof ResizeObserver>"u")return;const M=l.parentElement,U=()=>M?.style.setProperty("--t2-composer-h",`${l.offsetHeight}px`);U();const me=new ResizeObserver(U);return me.observe(l),()=>me.disconnect()},[]),c.useEffect(()=>{d&&P.getState().loadSessionHistory(d)},[d]),c.useEffect(()=>{t.setTitle(H?.title?fo(H.title,s):d?"Tangu Agent":s("sidebar.newChat"))},[d,H?.title,t,s]),c.useEffect(()=>{const l=h.jumpTarget;if(!l||l.sessionId!==d||j)return;const M=document.getElementById(`tocmsg-${l.messageId}`);if(!M){O.length&&(h.toast(s("search.jumpOutOfWindow"),!0),h.clearJumpTarget());return}const U=u.current;if(U){const ke=M.getBoundingClientRect().top-U.getBoundingClientRect().top+U.scrollTop;U.scrollTo({top:Math.max(0,ke-24),behavior:"smooth"}),m.current=!1}M.classList.add("t2-jump-flash");const me=window.setTimeout(()=>M.classList.remove("t2-jump-flash"),1600);return h.clearJumpTarget(),()=>window.clearTimeout(me)},[h.jumpTarget?.seq,d,j,O.length]);const be=c.useCallback((l=!1)=>{const M=u.current;M&&(M.scrollTo({top:M.scrollHeight,behavior:l?"smooth":"auto"}),m.current=!0,D(!1))},[]);c.useLayoutEffect(()=>{m.current=!h.jumpTarget,g.current=0},[d]),c.useEffect(()=>{const l=u.current,M=l?.querySelector(".t2-stream-inner");if(!l||!M)return;let U=0,me=l.scrollTop,ke=!1;const Se=()=>{const je=l.scrollHeight-l.scrollTop-l.clientHeight<40;je?m.current=!0:ke&&l.scrollTop<me&&(m.current=!1),me=l.scrollTop,D(!je&&!m.current)},Xe=()=>{m.current=!1,D(!0)},rt=je=>{je.deltaY<0&&Xe()};let lt=0;const ct=je=>{lt=je.touches[0]?.clientY||0},dt=je=>{(je.touches[0]?.clientY||0)>lt&&Xe()},Mn=()=>{ke=!0},An=()=>{ke=!1},Pn=je=>{["ArrowUp","PageUp","Home"].includes(je.key)&&!(je.target instanceof HTMLTextAreaElement||je.target instanceof HTMLInputElement)&&Xe()},In=()=>{m.current&&(l.scrollTop=l.scrollHeight,me=l.scrollTop,D(!1))},Ht=new ResizeObserver(()=>{cancelAnimationFrame(U),U=requestAnimationFrame(In)});return Ht.observe(M),Ht.observe(l),In(),l.addEventListener("scroll",Se,{passive:!0}),l.addEventListener("wheel",rt,{passive:!0}),l.addEventListener("touchstart",ct,{passive:!0}),l.addEventListener("touchmove",dt,{passive:!0}),l.addEventListener("pointerdown",Mn),l.addEventListener("keydown",Pn),window.addEventListener("pointerup",An),()=>{Ht.disconnect(),cancelAnimationFrame(U),l.removeEventListener("scroll",Se),l.removeEventListener("wheel",rt),l.removeEventListener("touchstart",ct),l.removeEventListener("touchmove",dt),l.removeEventListener("pointerdown",Mn),l.removeEventListener("keydown",Pn),window.removeEventListener("pointerup",An)}},[d]);const vt=h.compacting!==void 0;c.useLayoutEffect(()=>{m.current&&!h.jumpTarget&&be()},[O,j,be,vt]),c.useEffect(()=>{let l=0;for(const M of O)l+=M.planProposal&&M.inquiries?.filter(U=>U.status==="pending"&&U.kind==="plan").length||0;l>g.current&&be(!0),g.current=l},[O,be]),c.useEffect(()=>{const l=u.current,M=p.current;if(!l||!M)return;const U=()=>{const Se=window.getSelection();if(!Se||Se.isCollapsed||!Se.rangeCount){E(null);return}const Xe=Se.toString().trim(),rt=Se.getRangeAt(0);if(!Xe||!l.contains(rt.commonAncestorContainer)){E(null);return}const lt=rt.getBoundingClientRect(),ct=M.getBoundingClientRect(),dt=mr(M);E({x:(lt.right-ct.left)/dt,y:(lt.bottom-ct.top)/dt+6,text:Xe})},me=()=>{window.getSelection()?.isCollapsed&&E(null)},ke=()=>E(null);return l.addEventListener("mouseup",U),document.addEventListener("selectionchange",me),l.addEventListener("scroll",ke,{passive:!0}),()=>{l.removeEventListener("mouseup",U),document.removeEventListener("selectionchange",me),l.removeEventListener("scroll",ke)}},[d,O.length]);const se=l=>{try{navigator.clipboard.writeText(l)}catch{}},[Je,Ka]=c.useState(or());c.useEffect(()=>ir(Ka),[]);const En=!!h.desktopConfig?.ttsModelId?.trim(),Ga=(l,M)=>{if(Je?.msgId===l){gr();return}vr(ze(),h.desktopConfig,l,M).catch(U=>{h.toast(U?.message==="EMPTY"?s("tts.noText"):s("tts.failed",{e:U?.message||U}),!0)})},Ya=(l,M)=>{B(l),L(M)},Tn=()=>{S&&J.trim()&&h.editUserMessage(S,J.trim(),d),B(null)},Qe=O.length>0,Bt=!!d&&Qe&&!n.childSurface&&!k&&tn!=="mobile"&&!!h.desktopConfig?.agentDeskEnabled,Rn=rr(Bt),Ja=!n.childSurface&&!k&&tn!=="mobile"&&!!A.groupChat&&(A.groupAgents?.length||0)>=2,Qa=l=>{Hn(l.dataTransfer)&&(l.preventDefault(),l.dataTransfer.dropEffect="copy",X||ae(!0))},Xa=l=>{if(ae(!1),!Hn(l.dataTransfer))return;l.preventDefault(),l.stopPropagation();const M=fr(l.dataTransfer);M.length&&h.appendRefs(M)};return e.jsxs("div",{className:`t2-chat-view${X?" refdrop":""}`,"data-chat-surface":t.type,"data-session-id":d||void 0,style:{flex:1,minHeight:0,display:"flex",flexDirection:"row",minWidth:0},onDragOver:Qa,onDragLeave:l=>{l.currentTarget.contains(l.relatedTarget)||ae(!1)},onDrop:Xa,children:[i&&A.soloAgentSlug&&d&&e.jsx(_l,{agents:h.agentDefs.filter(l=>l.createdBy!=="system"&&!!l.libraryDir),team:null,initialMembers:[A.soloAgentSlug],onClose:()=>r(!1),onSaved:l=>{r(!1);const M=d;P.getState().ensureTeamSession(l.slug).then(U=>{U&&(P.getState().setSeedOnce(U.id,M),lr(U.id,{newTab:!0}))})}}),e.jsxs("div",{className:"t2-chat-col",children:[e.jsx(vl,{children:e.jsxs("div",{className:"t2-chat-body",ref:p,children:[Qe&&e.jsx(td,{scrollContainerRef:u,scanTrigger:O.length}),e.jsx("div",{className:"t2-stream",ref:ie,children:e.jsxs("div",{className:"t2-stream-inner",children:[Qe?O.map(l=>vs(l)?null:l.role==="user"&&l.id===S?e.jsx("div",{className:"t2-userwrap",children:e.jsxs("div",{className:"t2-edit",children:[e.jsx("textarea",{className:"t2-edit-ta",value:J,autoFocus:!0,onChange:M=>L(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.metaKey||M.ctrlKey)&&Tn(),M.key==="Escape"&&B(null)}}),e.jsxs("div",{className:"t2-btnrow",children:[e.jsx("button",{className:"t2-btn primary",onClick:Tn,children:s("chat.edit.saveResend")}),e.jsx("button",{className:"t2-btn ghost",onClick:()=>B(null),children:s("common.cancel")})]})]})},l.id):e.jsx(Gc,{msg:l,showWaitDetails:a,rootRef:l.id===_e?f:void 0,footer:l.id===Fe&&pe?e.jsx(ls,{stats:pe}):void 0,avatarUrl:l.role!=="assistant"?void 0:(()=>{const M=l.agentId||(l.agentName?h.agentDefs.find(U=>U.name===l.agentName)?.slug:void 0);if(M)return h.agentAvatars[M];if(!l.agentName)return ve?void 0:Be})(),agentNameFallback:v,userName:R,userAvatar:T,fileCtx:{cfg:h.cfg,sessionId:d||"",execMode:A.execMode,onOpenPreview:h.setFilePreview},modelId:Ce,speakState:Je?.msgId===l.id?Je.phase:void 0,voice:En?{on:$,cfg:h.cfg,stored:h.desktopConfig}:void 0,handlers:{onCopy:se,onRegenerate:n.readOnly?void 0:()=>h.regenerate(l.id,d),onBranch:n.childSurface?void 0:()=>{h.branchFromMessage(l.id,d)},onEdit:n.readOnly?void 0:()=>Ya(l.id,l.content),onRewind:n.readOnly?void 0:M=>{h.rewindTo(l.id,M,d)},onSuggest:n.readOnly?void 0:M=>{h.send(M,[],void 0,void 0,void 0,d)},onTask:(M,U)=>Ol(M,U,d),onInsertNote:dr()?M=>{Gl(M,Vl(O,l.id))}:void 0,...En?{onSpeak:M=>Ga(l.id,M)}:{}}},l.id)):j?e.jsx(cr,{variant:"chat"}):null,ee&&pe&&!Fe&&pe.finishedAt==null&&e.jsx("div",{className:"t2-runstats-solo",children:e.jsx(ls,{stats:pe})}),O.filter(l=>l.teamSummary).slice(-1).map(l=>e.jsx($d,{message:l},l.id)),ee&&d&&h.isGroupVoting&&e.jsxs("div",{className:"t2-sys",children:[e.jsx("span",{className:"t2-dot"})," ",s("group.voting.inProgress")]}),ee&&d&&h.llmRetry&&e.jsxs("div",{className:"t2-sys t2-retry",title:h.llmRetry.error,children:["⟳ ",s("chat.llmRetrying",{s:(h.llmRetry.waitMs/1e3).toFixed(1),n:h.llmRetry.attempt,max:h.llmRetry.max||"?"}),h.llmRetry.error?e.jsx("span",{className:"t2-retry-err",children:h.llmRetry.error}):null]}),h.compacting!==void 0&&e.jsxs("div",{className:"t2-compact",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"t2-compact-head",children:[e.jsx("span",{children:s("input.compacting")}),e.jsxs("span",{className:"t2-compact-pct",children:[h.compacting,"%"]})]}),e.jsx("div",{className:"t2-compact-track",children:e.jsx("div",{className:"t2-compact-fill",style:{width:`${h.compacting}%`}})})]})]})}),K&&e.jsx("button",{className:"jump-bottom t2-jump",title:s("chat.jumpToBottom"),onClick:()=>be(!0),children:e.jsx(ur,{size:16})}),q&&e.jsxs("div",{className:"quote-float t2-quote-menu",role:"toolbar","aria-label":s("chat.selection.actions"),onMouseDown:l=>l.preventDefault(),style:{left:q.x,top:q.y,"--quote-x":`${q.x}px`},children:[e.jsxs("button",{className:"t2-quote-action","data-testid":"selection-quote",onClick:()=>{W(q.text),E(null),window.getSelection()?.removeAllRanges()},children:[e.jsx(il,{size:13})," ",s("chat.action.quote")]}),t.type!=="chat-panel"&&e.jsxs("button",{className:"t2-quote-action","data-testid":"selection-ask-in-panel",onClick:()=>{Bl(q.text),E(null),window.getSelection()?.removeAllRanges()},children:[e.jsx(Qs,{size:13})," ",s("chat.action.askInPanel")]}),d&&e.jsxs("button",{className:"t2-quote-action","data-testid":"selection-btw",onClick:()=>{Gn({sessionId:d,title:H?.title,quote:q.text,modelId:Ce||void 0}),E(null),window.getSelection()?.removeAllRanges()},children:[e.jsx(tl,{size:13})," ",s("btw.selectionAction")]})]})]})},d||"none"),!Qe&&!j&&e.jsx(Zc,{compact:!!n.miniSurface,title:n.miniSurface?s("mini.chatHint"):k?s("studio.chatTitle"):void 0,subtitle:k?s(y?"studio.chatHint":"studio.chooseProject"):void 0}),e.jsxs("div",{className:"composer-anchor",ref:ye,children:[!n.miniSurface&&!n.childSurface&&!Qe&&A.preset!=="chat"&&!A.soloAgentSlug&&!A.soloEngineId&&!A.teamSlug&&e.jsx("div",{className:"newchat-pickers",children:e.jsx(go,{sessionId:d,cfg:A})}),!d&&(!k||y)&&(A.preset!=="chat"||C&&!k)&&e.jsx("div",{className:"newchat-projectbar",children:e.jsxs("div",{className:"newchat-projectbar-inner",children:[C&&!k&&e.jsx(vo,{}),A.preset!=="chat"&&(k&&y?e.jsxs("div",{className:"project-pill",title:y,"data-studio-project":y,children:[e.jsx(Lt,{size:13}),e.jsx("span",{className:"project-pill-name",children:Mr(y)})]}):e.jsx(xo,{workspaces:h.workspaces(),value:h.newChatWs?.key??null,onChange:l=>h.setNewChatWs(l),onAddProject:window.tangu?.pickDirectory?()=>{h.addLocalWorkspace()}:void 0,onAddCloudProject:l=>{h.addCloudProject(l)}}))]})}),e.jsx(br,{children:h.filePreview&&e.jsx(Dl,{target:h.filePreview,onClose:()=>h.setFilePreview(null)},h.filePreview.name)}),e.jsx(wo,{sessionId:d,approvalTray:Y.length?e.jsx(Xc,{sessionId:d??void 0,items:Y,onDecide:(l,M,U,me)=>h.decideApproval(l,M,U,me,d),onAnswer:(l,M,U)=>h.answerInquiry(l,M,U,d)},d??""):void 0,advisory:n.childSurface?void 0:e.jsx(Wd,{sessionId:d,fallback:e.jsx(qd,{loggedIn:!!h.authInfo?.loggedIn&&h.authInfo.tokenValid!==!1,onToast:h.toast})}),liveOwner:x&&t.loc==="main",liveSessionKey:d,disabled:!!n.readOnly||!b||k&&!y,disabledPlaceholder:k&&!y?s("studio.chooseProject"):_,running:ee,execConfig:he?{...A,approvalMode:he.approvalMode||A.approvalMode}:A,teamApproval:!!he,models:Pe,modelsResponse:h.modelsResp,modelId:Ce,onModelChange:l=>h.setSessionModel(l,d,!n.childSurface),engines:h.engines,engineId:A.engineId,engineModels:A.engineId?h.engineCaps[A.engineId]?.models??[]:void 0,engineModelId:A.engineModelId,onEngineModelChange:d?l=>h.setSessionEngineModel(l,d):l=>h.setNewChatCfg(M=>({...M,engineModelId:l||void 0})),engineCommands:A.engineId?h.engineCaps[A.engineId]?.commands??[]:void 0,thinkingLevel:A.thinkingLevel,ultra:A.ultra,onThinkingChange:(l,M)=>h.setSessionThinking(l,d,!n.childSurface,M),defaultModelIds:{backgroundModelId:h.desktopConfig?.backgroundModelId||"",imageModelId:h.cfg.imageModelId||"",visionModelId:h.cfg.visionModelId||""},onDefaultModelChange:h.setDefaultModel,onContextWindowChange:(l,M)=>{h.setModelContextWindow(l,M)},maxIterations:A.maxIterations,onMaxIterationsChange:d?l=>h.setSessionMaxIterations(l,d):l=>h.setNewChatCfg(M=>({...M,maxIterations:l})),verifyCommand:A.verifyCommand,onVerifyCommandChange:d?l=>h.setExecConfig({verifyCommand:l||void 0},d):l=>h.setNewChatCfg(M=>({...M,verifyCommand:l||void 0})),planMode:A.planMode,onPlanModeChange:he?void 0:d?l=>h.setSessionPlanMode(l,d):l=>h.setNewChatCfg(M=>({...M,planMode:l})),preset:A.preset,onPresetChange:d?void 0:l=>h.setSessionMode(l),voiceMode:$,onVoiceModeChange:re?l=>{h.setVoiceMode(re,l)}:void 0,groupChat:A.groupChat,groupAgents:A.groupAgents,groupTempAgents:A.groupTempAgents,onGroupChange:n.childSurface||A.soloAgentSlug||A.soloEngineId?void 0:d?l=>h.setSessionGroup(l,d):l=>h.setNewChatCfg(M=>({...M,...l})),onAddAgent:A.soloAgentSlug?()=>r(!0):void 0,onNormalWork:he?void 0:()=>{const l={planMode:!1,groupChat:!1,approvalMode:"auto-edit"};A.teamSlug&&!A.agentSlug&&(l.agentSlug=A.groupAgents?.[0]||h.defaultAgentSlug),d?h.setExecConfig(l,d):(h.setSessionMode("work"),h.setNewChatCfg(M=>({...M,...l})))},skills:h.skillsList,agents:h.agentDefs,onAgentSwitch:!n.childSurface&&d&&Qe&&!A.groupChat&&!A.soloAgentSlug&&!A.soloEngineId&&!A.teamSlug&&!A.engineId?l=>h.selectSessionAgent(l,d):void 0,currentAgentSlug:A.agentSlug||h.defaultAgentSlug,mentionProjects:A.soloAgentSlug?h.workspaces().filter(l=>l.kind==="local"&&!!l.path).map(l=>({name:l.name,path:l.path})):void 0,onNewSession:n.childSurface?void 0:()=>{A.soloAgentSlug?ee||Bn("agent",A.soloAgentSlug):A.soloEngineId?ee||Bn("engine",A.soloEngineId):h.newSession()},onBranch:!n.childSurface&&d?()=>{h.branchFromMessage(void 0,d)}:void 0,onOpenSettings:()=>h.openSettings("skills"),onExecConfigChange:fe&&he?l=>{l.approvalMode&&h.setExecConfig({approvalMode:l.approvalMode},fe)}:l=>h.setExecConfig(l,d),onSend:async(l,M,U,me,ke)=>{if(k){const Se=on.getState().prepareRun();return Se?P.getState().send(l,M,U,me,ke,Se.sessionId):!1}return h.send(l,M,U,me,ke,d)},onStop:()=>h.stop(d),quotedText:F,onClearQuote:()=>W(""),onBtw:d?(l,M)=>Gn({sessionId:d,title:H?.title,question:l,quote:M,modelId:Ce||void 0}):void 0,contextWindow:ne?.ctxWindow||le?.contextWindow||0,ctxInfo:ne,ctxTokens:I.ctx,sessionTokens:I.base+I.live,runCost:I.runCost,costLimit:I.costLimit,onCompact:l=>{h.compact(d,l)},seedText:h.steerRestore??(n.childSurface?null:h.pendingDraft),seedShare:n.childSurface||t.type==="chat-panel"?null:h.pendingShare,takeSeedShare:h.takePendingShare,appendRefs:n.childSurface?null:h.draftRefs,onAppendRefsConsumed:h.clearDraftRefs,autoRefFromMain:!n.childSurface&&(t.loc!=="main"||n.autoRefFromMain===!0),onSeedConsumed:()=>{h.steerRestore&&d?h.clearSteerRestore(d):n.childSurface||h.setPendingDraft(null)},sentHistory:Z,pendingSteer:h.steerPending,onCancelSteer:d?l=>{h.withdrawSteer(d,l)}:void 0,onWithdrawSteer:d?l=>h.withdrawSteer(d,l):void 0,onSteerNow:d?()=>{h.steerNow(d)}:void 0})]}),!n.childSurface&&e.jsxs("div",{className:"t2-rail",children:[e.jsx(hd,{teamStatus:d?e.jsxs(e.Fragment,{children:[Ja&&e.jsx(Id,{sessionId:d}),e.jsx(_d,{sessionId:d}),h.historianEnabled&&e.jsx(Rd,{sessionId:d},d)]}):void 0,messages:O,running:ee,cwd:A.cwd,modelId:Ce,hostCwd:A.execMode==="host"?A.cwd:void 0,extraRoots:A.extraRoots,lockedRoots:A.execMode==="host"&&G?[G]:[],onAddRoot:A.execMode==="host"&&d?()=>{window.tangu?.pickDirectory?.().then(l=>{if(!l)return;const M=P.getState().configBySession[d]?.extraRoots||[];l===A.cwd||M.includes(l)||P.getState().setExecConfig({extraRoots:[...M,l]},d)})}:void 0,onRemoveRoot:A.execMode==="host"&&d?l=>{if(l===G)return;const M=P.getState().configBySession[d]?.extraRoots||[];P.getState().setExecConfig({extraRoots:M.filter(U=>U!==l)},d)}:void 0,onJumpToAttention:()=>be(!0),onShowEditing:Rn&&d?l=>P.getState().deskShowFile(d,l):void 0,onOpenFile:l=>{const M=l.path?hr(l.path,A.cwd):null;if(Rn&&d&&M&&h.desktopConfig?.summaryOpenIn==="desk"){P.getState().deskShowFile(d,M);return}pr(Sr(l,h.cfg,d||"",A.execMode))}}),Bt&&d?e.jsx(bd,{sessionId:d}):null]})]}),Bt&&d&&!o[d]?e.jsx(wd,{sessionId:d}):null,!n.childSurface&&d?e.jsx(Fd,{parentId:d},d):null]})}const Fu=Object.freeze(Object.defineProperty({__proto__:null,ChatView:Ua},Symbol.toStringTag,{value:"Module"}));export{Xc as A,_u as B,Ua as C,Dc as D,vl as E,Vn as F,Jr as G,wt as H,Xr as I,Ol as J,De as K,na as L,Gn as M,Fu as N,il as Q,ll as S,sa as T,fl as V,gd as W,Zc as a,Tu as b,Gc as c,Ru as d,yl as e,jl as f,zu as g,Eu as h,Au as i,Pu as j,Xl as k,Et as l,Wr as m,Iu as n,Sn as o,_c as p,Mu as q,Zl as r,Cu as s,Rc as t,kl as u,pn as v,Ot as w,_l as x,Du as y,Bl as z};
|