@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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import{d as u,t as Ie,r as xe,j as t,u as ze,T as Yn,R as nn,N as Yr,O as Gr,P as Xr,v as Es}from"./index-B5UW6SaE.js";import{G as He,u as $,ma as Jr,t as pt,mb as Zr,mc as Qr,md as ec,N as vo,me as tc,i8 as yo,aN as sn,cP as ko,bI as nc,bq as fa,fp as xo,U as Gs,aF as mt,aK as ft,bK as Gn,ar as ts,ln as sc,mf as ac,mg as ic,mh as oc,lo as rc,lv as cc,lw as lc,mi as uc,mj as dc,mk as mc,fD as an,q as Xn,b as Nn,ej as ns,ap as zi,aC as Ts,bg as hc,Y as pc,Z as fc,at as Rn,aQ as en,c6 as _t,T as wo,ah as bo,ml as jo,iG as gc,_ as ga,I as Rs,mm as vc,aJ as cs,b1 as yc,mn as kc,cM as xc,iv as wc,ir as Mi,cq as bc,mo as Ai,mp as Nt,mq as jc,mr as Sc,lu as Nc,ms as Cc,mt as Is,h as zc,bG as Mc,e0 as Ac,ea as Ec,er as Tc,lh as Ei,eo as Rc,mu as $s,cO as Ic,a3 as $c,mv as Lc,mw as Pc,mx as Dc,lX as _c,cQ as Fc,my as So,mz as Oc,mA as Wc,mB as Uc,mC as Bc,cj as Ti,mD as qc,kQ as Hc,ci as Vc,as as ss,mE as Kc,aT as Yc,mF as Gc,hA as Xc,mG as Jc,V as No,hK as Ri,cs as tn,cr as Zc,H as Qc,mH as el,hD as Ft,mI as tl,mJ as nl,mK as on,l$ as In,bC as sl,mL as Ii,n as Ls,mM as $n,lZ as An,mN as Co,mO as va,kX as al,a6 as as,ab as zo,bD as Mo,ig as il,id as ol,mP as rl,mQ as cl,h0 as ya,o as ll,f as ul,mR as Ao,c as dl,g as ml,lH as Eo,mS as hl,iC as pl,dm as $i,l as fl,h1 as Ps,ai as Xs,ce as gl,e4 as vl,mT as yl,mU as kl,hH as xl,a5 as wl,am as bl,f6 as To,eb as Ro,lU as Li,lV as jl}from"./appStore-CidPWYa0.js";import{u as Pi,n as Di}from"./codeStudioStore-DXMQwRzG.js";import{a as Sl,u as _i,C as Nl,j as Cl}from"./RightPanel-BgSeCLnw.js";import{c as ls,n as Bn}from"./nativeDownload-B3JGkABw.js";import"./client-CPUljePZ.js";import{h as zl,o as ka,C as Ml,k as Al,t as Io,u as El,A as Tl,m as Rl,l as Il,i as $l,a as Js,p as Ll,S as Pl,q as Dl,w as _l,s as Fl,v as Ol,P as qn,f as Wl,g as $o,d as Zs,e as Lo,x as Ul}from"./phoneList-DrxIwJxQ.js";import{t as Qs,c as Bl,g as ql,a as Hl}from"./ModelPill-DveHcLqq.js";import{P as zn}from"./pencil-CJsJD7M_.js";import{c as Vl,D as Kl}from"./create-C19zqt5N.js";import{S as Yl,W as Gl}from"./approvalText-Cy2UAUAQ.js";import{M as Xl}from"./message-square-plus-3wFslIMY.js";import{F as is}from"./folder-CoOsfQ64.js";import{H as Jl}from"./hand-fuehbnkI.js";import{F as Po}from"./folder-plus-d5MwIMlf.js";import{i as Zl}from"./ipc-CNlIRMtU.js";import{a as Ql,S as Do,I as eu}from"./pageChrome-DFi9zs6F.js";const tu=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],Fi=He("archive-restore",tu);const nu=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Jn=He("archive",nu);const su=[["path",{d:"M2 10v3",key:"1fnikh"}],["path",{d:"M6 6v11",key:"11sgs0"}],["path",{d:"M10 3v18",key:"yhl04a"}],["path",{d:"M14 8v7",key:"3a1oy3"}],["path",{d:"M18 5v13",key:"123xd1"}],["path",{d:"M22 10v3",key:"154ddg"}]],au=He("audio-lines",su);const iu=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]],Oi=He("folder-x",iu);const ou=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],ru=He("notebook-pen",ou);const cu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],Zn=He("panels-top-left",cu);const lu=[["circle",{cx:"11",cy:"4",r:"2",key:"vol9p0"}],["circle",{cx:"18",cy:"8",r:"2",key:"17gozi"}],["circle",{cx:"20",cy:"16",r:"2",key:"1v9bxh"}],["path",{d:"M9 10a5 5 0 0 1 5 5v3.5a3.5 3.5 0 0 1-6.84 1.045Q6.52 17.48 4.46 16.84A3.5 3.5 0 0 1 5.5 10Z",key:"1ydw1z"}]],uu=He("paw-print",lu);const du=[["line",{x1:"9",x2:"9",y1:"4",y2:"20",key:"ovs5a5"}],["path",{d:"M4 7c0-1.7 1.3-3 3-3h13",key:"10pag4"}],["path",{d:"M18 20c-1.7 0-3-1.3-3-3V4",key:"1gaosr"}]],mu=He("pi",du);const hu=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],Wi=He("pin-off",hu);const pu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]],fu=He("shield-question-mark",pu);const gu=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],_o=He("user-plus",gu);const vu=[["path",{d:"M2 12q2.5 2 5 0t5 0 5 0 5 0",key:"8ddzzs"}],["path",{d:"M2 19q2.5 2 5 0t5 0 5 0 5 0",key:"1wj4st"}],["path",{d:"M2 5q2.5 2 5 0t5 0 5 0 5 0",key:"69x50u"}]],yu=He("waves-horizontal",vu);let wn=null,Ds=null;function ku(e){const n=$.getState().tr;return n(`channel.name.${e}`)}function xu(e){const n=e.filter(i=>i.enabled&&i.workspace).map(i=>({key:i.workspace,name:ku(i.kind),kind:"channel",channel:i.kind,path:i.workspace,system:!0})),a=$.getState().channelWorkspaces;a.length===n.length&&a.every((i,c)=>i.key===n[c].key&&i.name===n[c].name&&i.channel===n[c].channel)||$.setState({channelWorkspaces:n})}const wu=ls((e,n)=>({channels:[],available:!1,loaded:!1,refresh:async()=>{if(window.tangu?.backendStatus)try{const a=await ec(pt()),o=Array.isArray(a.channels)?a.channels:[];e({channels:o,available:!!a.available,loaded:!0}),xu(o)}catch{}},save:async(a,o)=>{await Qr(pt(),a,o),await n().refresh()},connect:async a=>{const o=await Zr(pt(),a);return await n().refresh(),$.getState().refreshSessions($.getState().cfg),o},disconnect:async(a,o)=>{await Jr(pt(),a,o),await n().refresh()},startPolling:()=>{if(wn!=null)return;const a=()=>{$.getState().connState==="ok"&&n().refresh()};wn=window.setInterval(a,15e3);let o=$.getState().connState;Ds=$.subscribe(i=>{i.connState==="ok"&&o!=="ok"&&n().refresh(),o=i.connState}),a()},stopPolling:()=>{wn!=null&&(window.clearInterval(wn),wn=null),Ds?.(),Ds=null}}));xe({"voiceinput.silent":{zh:"没采集到声音(输入电平≈0):检查系统输入设备是否选对、麦克风没被静音",en:"No audio captured (input level ≈ 0): check that the right input device is selected and that the microphone is not muted"},"voiceinput.unsupported":{zh:"此环境不支持语音输入",en:"Voice input is not supported in this environment"},"voiceinput.denied":{zh:"麦克风权限被拒绝(打开 系统设置 › 隐私与安全 › 麦克风,允许本 App)",en:"Microphone access was denied (open System Settings › Privacy & Security › Microphone and allow this app)"},"voiceinput.silentPhone":{zh:"没录到声音,再试一次",en:"No sound was recorded — try again"},"voiceinput.deniedPhone":{zh:"麦克风权限被拒绝(到系统设置 › 应用 › 权限里允许麦克风)",en:"Microphone access was denied (allow it in system Settings › Apps › Permissions)"},"voiceinput.noDevice":{zh:"没检测到麦克风设备",en:"No microphone found"},"voiceinput.openFailed":{zh:"麦克风打不开:{e}",en:"Could not open the microphone: {e}"},"voiceinput.unclear":{zh:"没听清,再试一次",en:"Didn't catch that — try again"}});async function bu(e){const n=await e.arrayBuffer(),a=new AudioContext,o=await a.decodeAudioData(n);await a.close();const i=Math.max(1,Math.round(o.duration*16e3)),c=new OfflineAudioContext(1,i,16e3),r=c.createBufferSource();r.buffer=o,r.connect(c.destination),r.start();const l=(await c.startRendering()).getChannelData(0);let m=0,p=0;for(let f=0;f<l.length;f++){const x=Math.abs(l[f]);x>m&&(m=x),p+=l[f]*l[f]}if(console.warn(`[voice] captured ${l.length} samples @16k, ${(l.length/16e3).toFixed(2)}s, peak=${m.toFixed(4)} rms=${Math.sqrt(p/(l.length||1)).toFixed(4)}`),m<.005)throw new Error(window.tangu?.mobile?Ie("voiceinput.silentPhone"):Ie("voiceinput.silent"));return ju(l,16e3)}function ju(e,n){const a=e.length,o=new ArrayBuffer(44+a*2),i=new DataView(o),c=(p,f)=>{for(let x=0;x<f.length;x++)i.setUint8(p+x,f.charCodeAt(x))};c(0,"RIFF"),i.setUint32(4,36+a*2,!0),c(8,"WAVE"),c(12,"fmt "),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,n,!0),i.setUint32(28,n*2,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),c(36,"data"),i.setUint32(40,a*2,!0);for(let p=0;p<a;p++){const f=Math.max(-1,Math.min(1,e[p]));i.setInt16(44+p*2,f<0?f*32768:f*32767,!0)}const r=new Uint8Array(o);let l="";const m=32768;for(let p=0;p<r.length;p+=m)l+=String.fromCharCode(...r.subarray(p,p+m));return btoa(l)}function Su(e,n){const[a,o]=u.useState(!1),[i,c]=u.useState(!1),[r,l]=u.useState(null),m=u.useRef(null),p=u.useRef([]),f=u.useRef(!1),[x,b]=u.useState(null),A=u.useRef(null),T=u.useCallback(()=>{b(null),A.current?.close().catch(()=>{}),A.current=null},[]);u.useEffect(()=>T,[T]);const z=typeof navigator<"u"&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u"&&!!window.tangu?.transcribeAudio,M=u.useCallback(B=>{f.current=B,m.current?.stop()},[]),U=u.useCallback(async()=>{if(l(null),!z){l(Ie("voiceinput.unsupported"));return}let B;try{B=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(E){console.warn("[voice] getUserMedia failed:",E?.name,E?.message||E),l(E?.name==="NotAllowedError"?window.tangu?.mobile?Ie("voiceinput.deniedPhone"):Ie("voiceinput.denied"):E?.name==="NotFoundError"?Ie("voiceinput.noDevice"):Ie("voiceinput.openFailed",{e:E?.name||E?.message||E}));return}try{const E=new AudioContext,g=E.createAnalyser();g.fftSize=128,g.smoothingTimeConstant=.7,E.createMediaStreamSource(B).connect(g),A.current=E,b(g)}catch{}const J=new MediaRecorder(B);m.current=J,p.current=[],f.current=!1,J.ondataavailable=E=>{E.data.size&&p.current.push(E.data)},J.onstop=async()=>{if(B.getTracks().forEach(g=>g.stop()),T(),o(!1),m.current=null,f.current||!p.current.length)return;const E=new Blob(p.current,{type:J.mimeType||"audio/webm"});c(!0);try{const g=await window.tangu.transcribeAudio({audioBase64:await bu(E),mime:"audio/wav",modelId:n});g?e(g):l(Ie("voiceinput.unclear"))}catch(g){console.warn("[voice] transcribe failed:",g?.message||g),l(g?.message||String(g))}finally{c(!1)}},J.start(),o(!0)},[z,n,e,T]),_=u.useCallback(()=>{i||(a?M(!1):U())},[i,a,U,M]),L=u.useCallback(()=>{a&&M(!0)},[a,M]);return{recording:a,busy:i,error:r,toggle:_,cancel:L,supported:z,analyser:x}}const Nu=({size:e})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M10.931 3.34a.112.112 0 0 0-.069-.104l-.038-.007c-1.537.05-2.45.318-3.714 1.002v6.683c.48-.248.936-.44 1.414-.58.695-.203 1.417-.292 2.303-.305l.038-.008a.113.113 0 0 0 .066-.104V3.341ZM2.363 9.919c0 .064.051.11.105.111l.33.008c1.162.046 2.042.243 2.975.662-.403-.585-1.008-1.075-1.654-1.292a.991.991 0 0 1-.674-.941v-5.14a6.36 6.36 0 0 0-.59-.076l-.37-.02a.115.115 0 0 0-.122.111v6.577Zm9.455-.001a.998.998 0 0 1-.877.992l-.101.007c-.832.012-1.47.095-2.066.27-.599.174-1.176.448-1.883.863a.444.444 0 0 1-.449 0c-1.299-.763-2.229-1.07-3.689-1.125l-.299-.008a.997.997 0 0 1-.977-.998V3.342c0-.573.478-1.017 1.038-.999l.417.023c.188.015.35.037.513.062v-.754c0-.708.749-1.244 1.429-.903.984.492 1.836 1.449 2.15 2.505 1.216-.617 2.222-.884 3.771-.934l.105.003a.998.998 0 0 1 .918.996v6.576ZM4.332 8.466c0 .049.03.087.07.1l.24.091a4.319 4.319 0 0 1 1.581 1.176V3.721c-.164-.803-.799-1.617-1.584-2.07l-.162-.088c-.025-.012-.054-.013-.088.009a.12.12 0 0 0-.057.102v6.792Z"})}),Cu=({size:e})=>t.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"})}),Ui=({engineId:e,size:n=16})=>{const a=e.toLowerCase();return a.includes("claude")?t.jsx(Cu,{size:n}):a.includes("codex")||a.includes("openai")?t.jsx(Nu,{size:n}):a.includes("claw")?t.jsx(uu,{size:n}):a==="pi"||a.startsWith("pi-")?t.jsx(mu,{size:n}):a.includes("dsh")||a.includes("deepseek")?t.jsx(yu,{size:n}):t.jsx(vo,{size:n})},zu=e=>/(^|\/)qwen-audio-/i.test(e);function Mu(e,n){return n&&e===n.id?n.apiModelId||n.id:e}const Au=(e,n)=>zu(Mu(e,n)),Eu=(e,n)=>Au(e,n)?"longanqian":"Tina";function Tu(e,n){const a=e.realtimeModelId?.trim()||"";return a||!e.realtimeModelUnset?a:n.signedIn&&n.model?.id?n.model.id:""}function Ru(e,n){const a=Tu(e,n),o=e.realtimeVoice?.trim()||"";return{model:a,voice:o||(a&&n.model&&a===n.model.id?Eu(a,n.model):"")}}const ea="forsion_voice_call_voice",Iu=50,$u=1e3,Lu=300,Pu=2500;function Bi(e){try{e?localStorage.setItem(ea,JSON.stringify({...e,t:Date.now()})):localStorage.removeItem(ea)}catch{}}let rt=null,Fo=0,qi,Hi=!1;const ta=new Set;function Oo(e){clearTimeout(qi);let n=null;try{n=e?JSON.parse(e):null}catch{n=null}const a=rt;if(n&&typeof n.sessionId=="string"&&typeof n.phase=="string"){const o=a?.sessionId===n.sessionId&&a.phase===n.phase;rt={sessionId:n.sessionId,phase:n.phase,level:Math.min(1,Math.max(0,Number(n.level)||0)),since:o?a.since:Date.now()},Fo=Date.now(),qi=setTimeout(()=>Oo(null),Pu)}else rt=null;(a?.sessionId!==rt?.sessionId||a?.phase!==rt?.phase)&&ta.forEach(o=>o())}function Wo(){Hi||typeof window>"u"||typeof window.addEventListener!="function"||(Hi=!0,window.addEventListener("storage",e=>{(e.key===ea||e.key===null)&&Oo(e.key?e.newValue:null)}))}function eh(){return Wo(),rt&&rt.level>0&&Date.now()-Fo>Lu&&(rt={...rt,level:0}),rt}function th(e){return Wo(),ta.add(e),()=>{ta.delete(e)}}const Du="forsion_realtime_cfg_rev";let Cn={realtimeModelId:"",realtimeModelUnset:!1,realtimeVoice:""},Vi=!1;const na=new Set;function _s(){window.tangu?.getConfig?.().then(e=>{const n={realtimeModelId:e.realtimeModelId?.trim()||"",realtimeModelUnset:!!e.realtimeModelUnset,realtimeVoice:e.realtimeVoice?.trim()||""};n.realtimeModelId===Cn.realtimeModelId&&n.realtimeModelUnset===Cn.realtimeModelUnset&&n.realtimeVoice===Cn.realtimeVoice||(Cn=n,na.forEach(a=>a()))}).catch(()=>{})}function _u(){return u.useSyncExternalStore(e=>(Vi||(Vi=!0,_s(),window.addEventListener("storage",n=>{n.key===Du&&_s()}),window.addEventListener("focus",_s)),na.add(e),()=>{na.delete(e)}),()=>Cn)}const Uo="forsion_voice_call_evt",sa=new Set;function Fu(e){try{localStorage.setItem(Uo,JSON.stringify({...e,n:`${Date.now()}-${Math.random()}`}))}catch{}sa.forEach(n=>{try{n(e)}catch{}})}let Bo=null,Ki=0;const aa=new Set;function Ou(e){e&&!ke&&Ki++,Bo=e?{...e,dial:Ki}:null,aa.forEach(n=>n())}const nh=()=>Bo;function sh(e){return aa.add(e),()=>{aa.delete(e)}}const os="forsion_voice_call_active",Qn=new Set;let Yi=!1;function Wu(e){try{e?localStorage.setItem(os,e):localStorage.removeItem(os)}catch{}Qn.forEach(n=>n())}function qo(){try{return localStorage.getItem(os)}catch{return null}}function Uu(e){return Yi||(Yi=!0,window.addEventListener("storage",n=>{(n.key===os||n.key===null)&&Qn.forEach(a=>a())})),Qn.add(e),()=>{Qn.delete(e)}}const Bu=4e3,ah=1500;function qu(e,n,a=2e3){const o=`${Date.now()}-${Math.random()}`;return new Promise(i=>{const c=Ho(l=>{l.kind==="text-ack"&&l.id===o&&(c(),clearTimeout(r),i(!0))}),r=setTimeout(()=>{c(),qo()===e&&Wu(null),i(!1)},a);Fu({kind:"text",sessionId:e,text:n,id:o,at:Date.now()})})}function Ho(e){const n=a=>{if(!(a.key!==Uo||!a.newValue))try{e(JSON.parse(a.newValue))}catch{}};return window.addEventListener("storage",n),sa.add(e),()=>{window.removeEventListener("storage",n),sa.delete(e)}}const Hu=.04,Vu="backgrounded",Gi=24e3;let ke=null,ia=null;const oa=new Set;let es=null,rn=null;const ra=()=>oa.forEach(e=>e()),Vo=e=>{ke&&(ke={...ke,...e},ra())};function ih(e){return oa.add(e),()=>{oa.delete(e)}}const oh=()=>ke,rh=()=>ia;function Ku(e){es?.(e)}function ch(){ke&&Vo({muted:!ke.muted})}const lh=e=>rn?.mic(e)??Promise.resolve(),uh=e=>rn?.speaker(e)??Promise.resolve(),dh=e=>rn?.run(e),mh=e=>rn?.text(e)??!1;async function hh(e){ke&&Ku(),ia=null,ke={sessionId:e.sessionId,phase:"connecting",muted:!1,working:null,analyser:null,connectedAt:null},ra();let n=null,a=null;const o=new AudioContext({sampleRate:16e3}),i=new AudioContext({sampleRate:Gi}),c=o.createAnalyser(),r=i.createAnalyser();r.connect(i.destination);const l=new Set;let m=0,p=!1,f=null,x=null;const b=C=>({echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,channelCount:1,...C?{deviceId:C}:{}}),A=()=>{f=o.createMediaStreamSource(n),f.connect(c),x&&f.connect(x)},T=C=>(i.setSinkId?.(C)??Promise.resolve()).catch(P=>console.warn("[realtime] setSinkId failed:",P)),z=C=>{p||Vo(C)},M=(C=500)=>{e.onActivity&&window.setTimeout(e.onActivity,C)},U=()=>{l.forEach(C=>{try{C.stop()}catch{}}),l.clear(),m=0},_=C=>{const P=new Int16Array(C,0,C.byteLength>>1);if(!P.length)return;const H=i.createBuffer(1,P.length,Gi),Z=H.getChannelData(0);for(let v=0;v<P.length;v++)Z[v]=P[v]/32768;const R=i.createBufferSource();R.buffer=H,R.connect(r);const Q=Math.max(i.currentTime+.05,m);R.start(Q),m=Q+H.duration,l.add(R),R.onended=()=>{l.delete(R),!l.size&&ke?.phase==="speaking"&&z({phase:"listening",analyser:c})},ke?.phase!=="speaking"&&z({phase:"speaking",analyser:r})},L=new Uint8Array(r.fftSize);let B="",J=0;const E=window.setInterval(()=>{if(p||!ke)return;const C=l.size>0,P=C?"speaking":ke.phase,H=Date.now();if(!C&&P===B&&H-J<$u)return;let Z=0;if(C){r.getByteTimeDomainData(L);const R=L.length>>1;let Q=0;for(let v=R;v<L.length;v++){const F=(L[v]-128)/128;Q+=F*F}Z=Math.min(1,Math.sqrt(Q/(L.length-R))*4)}B=P,J=H,Bi({sessionId:e.sessionId,phase:P,level:Z})},Iu),g=()=>Bi(null);window.addEventListener("pagehide",g);const O=!!window.tangu?.mobile,X=()=>{document.hidden&&Y(Vu)};let ee=null;O&&(document.addEventListener("visibilitychange",X),navigator.wakeLock?.request("screen").then(C=>{p?C.release().catch(()=>{}):ee=C}).catch(()=>{}));const Y=C=>{if(p)return;p=!0;const P=es===Y;P&&(es=null),window.clearInterval(E),window.removeEventListener("pagehide",g),document.removeEventListener("visibilitychange",X),ee?.release().catch(()=>{}),P&&g(),U();try{a?.close()}catch{}n?.getTracks().forEach(H=>H.stop()),o.close().catch(()=>{}),i.close().catch(()=>{}),P&&(rn=null,ia=C||null,ke=null,ra()),M(300)};es=Y,rn={mic:async C=>{const P=await navigator.mediaDevices.getUserMedia({audio:b(C)});if(p){P.getTracks().forEach(H=>H.stop());return}f?.disconnect(),n?.getTracks().forEach(H=>H.stop()),n=P,f&&A()},speaker:T,run:C=>{e.run=C,a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify({type:"run",run:C}))},text:C=>p||!ke?.connectedAt||ke.phase==="reconnecting"||a?.readyState!==WebSocket.OPEN?!1:(U(),z({phase:"thinking",analyser:c}),a.send(JSON.stringify({type:"text",text:C})),M(),!0)};try{if(n=await navigator.mediaDevices.getUserMedia({audio:b(e.micId)}),p){n.getTracks().forEach(P=>P.stop());return}e.speakerId&&await T(e.speakerId);const C=await tc(e.target);if(p)return;a=C.protocols?new WebSocket(C.url,C.protocols):new WebSocket(C.url),a.binaryType="arraybuffer"}catch(C){Y(C?.message||String(C));return}const W=a;W.onopen=()=>W.send(JSON.stringify({type:"start",session_id:e.sessionId,model:e.model,voice:e.voice||void 0,title:e.title,run:{...e.run,app_id:yo}})),W.onclose=C=>Y(C.reason||(C.code===1e3?void 0:`connection closed (${C.code})`)),W.onmessage=C=>{if(p)return;if(C.data instanceof ArrayBuffer){_(C.data);return}let P;try{P=JSON.parse(String(C.data))}catch{return}switch(P.type){case"ready":{if(x){z(l.size?{phase:"speaking",analyser:r}:{phase:"listening",analyser:c});break}x=o.createScriptProcessor(1024,1,1),x.connect(o.destination),x.onaudioprocess=H=>{if(p||!ke||ke.muted||W.readyState!==WebSocket.OPEN)return;const Z=H.inputBuffer.getChannelData(0);let R=0;for(let F=0;F<Z.length;F++)R+=Z[F]*Z[F];const Q=l.size>0&&Math.sqrt(R/Z.length)<Hu,v=new Int16Array(Z.length);if(!Q)for(let F=0;F<Z.length;F++)v[F]=Math.max(-32768,Math.min(32767,Math.round(Z[F]*32767)));W.send(v.buffer)},A(),z({phase:"listening",analyser:c,connectedAt:Date.now()});break}case"input_audio_buffer.speech_started":U(),z({phase:"hearing",analyser:c});break;case"input_audio_buffer.speech_stopped":z({phase:"thinking"});break;case"conversation.item.input_audio_transcription.completed":case"response.audio_transcript.done":M();break;case"response.done":!l.size&&ke?.phase==="thinking"&&P.response?.status!=="completed"&&z({phase:"listening",analyser:c});break;case"transcript.corrected":typeof P.message_id=="string"&&typeof P.text=="string"&&e.onTranscriptFix?.(P.message_id,P.text);break;case"tangu.run":z({working:P.status==="started"?String(P.task||""):null}),M(P.status==="started"?300:800);break;case"error":console.warn("[realtime] upstream error:",P.error?.message||P.error);break;case"reconnecting":P.replay&&U(),z({phase:"reconnecting"});break;case"end":Y(P.reason&&P.reason!=="client closed"?String(P.reason):void 0);break}}}const ca=e=>Array.from((e||"").trim());function Yu(e,n){const a=e.map(r=>r.toLowerCase()),o=a.join("");let i=0;for(const r of n){if(!r.length||r.join("")===o||r[0]!==a[0])continue;let l=0;for(;l<a.length&&l<r.length&&a[l]===r[l];)l++;i=Math.max(i,l)}const c=[];for(let r=i;i&&r<e.length;r++)e[r].trim()&&c.push(e[r]);return{first:e[0],picks:c,collides:i>0}}function Gu(e){const n=e.map(l=>ca(l)),a=n.map(l=>l.map(m=>m.toLowerCase())),o=n.map(()=>"?"),i=new Set,c=[];n.forEach((l,m)=>{if(!l.length)return;const{first:p,picks:f,collides:x}=Yu(l,a);if(!x||!f.length){o[m]=p.toUpperCase(),i.add(p.toLowerCase());return}c.push({index:m,key:a[m].join(""),picks:f,first:p})}),c.sort((l,m)=>l.key<m.key?-1:l.key>m.key?1:l.index-m.index);const r=new Map;for(const l of c){const m=r.get(l.key);if(m){o[l.index]=m;continue}const f=(l.picks.find(x=>!i.has(x.toLowerCase()))??l.first).toUpperCase();i.add(f.toLowerCase()),r.set(l.key,f),o[l.index]=f}return o}function Xu(e,n=[]){const a=ca(e);if(!a.length)return"?";const o=a.join("").toLowerCase();let i=n.findIndex(r=>ca(r).join("").toLowerCase()===o);const c=i>=0?n:[e,...n];return i<0&&(i=0),Gu(c)[i]}const Xi=(...e)=>e.filter(Boolean).join(" ")||void 0;function Ju({name:e,url:n,siblings:a,className:o,imgClassName:i,initialClassName:c,size:r,fill:l,title:m,style:p,...f}){return n?t.jsx("img",{...f,className:Xi(o,i),src:n,alt:"",title:m,draggable:!1,width:r,height:r,style:p}):t.jsx("span",{...f,className:Xi("agent-avatar-initial",l&&"agent-avatar-fill",o,c),title:m,"aria-hidden":"true",style:p,children:t.jsx("span",{className:"agent-avatar-glyph",children:Xu(e,a)})})}const Ji=ls((e,n)=>({pending:[],queue:(a,o)=>e(i=>({pending:[...i.pending,{sessionId:a,text:o}]})),take:a=>{const o=n().pending.filter(i=>i.sessionId===a);return o.length&&e(i=>({pending:i.pending.filter(c=>c.sessionId!==a)})),o.map(i=>i.text)}})),Zi=40,Qi=.1,Zu=3.2;function Qu({analyser:e,recording:n,busy:a,onStop:o,onSend:i,status:c,stopTitle:r,t:l}){const m=u.useRef(null),[p,f]=u.useState(0),x=u.useRef(0);u.useEffect(()=>{if(!n)return;x.current=Date.now(),f(0);const A=window.setInterval(()=>f(Math.floor((Date.now()-x.current)/1e3)),250);return()=>window.clearInterval(A)},[n]),u.useEffect(()=>{const A=m.current;if(!e||!n||!A)return;const T=A.getContext("2d");if(!T)return;const z=window.devicePixelRatio||1;A.width=Math.max(1,A.clientWidth)*z,A.height=Math.max(1,A.clientHeight)*z,T.setTransform(z,0,0,z,0,0);const M=getComputedStyle(document.documentElement),U=(M.getPropertyValue("--accent-ink")||M.getPropertyValue("--accent")||"#7c3aed").trim(),_=(M.getPropertyValue("--border")||"rgba(127,127,127,0.4)").trim(),L=new Uint8Array(e.fftSize),B=[];let J=Date.now(),E=0;const g=()=>{E=requestAnimationFrame(g);const O=Date.now();e.getByteTimeDomainData(L);let X=0;for(let P=0;P<L.length;P++){const H=(L[P]-128)/128;X+=H*H}const ee=Math.min(1,Math.sqrt(X/L.length)*Zu);for(;O-J>=Zi;)B.push({t:J,level:ee}),J+=Zi;const Y=A.clientWidth,W=A.clientHeight,C=W/2;for(T.clearRect(0,0,Y,W),T.strokeStyle=_,T.lineWidth=1,T.setLineDash([2,3]),T.beginPath(),T.moveTo(0,C),T.lineTo(Y,C),T.stroke(),T.setLineDash([]);B.length&&Y-(O-B[0].t)*Qi<-4;)B.shift();T.fillStyle=U;for(const P of B){const H=Y-(O-P.t)*Qi;if(H<-4||H>Y)continue;const Z=Math.max(2,P.level*(W-4));T.globalAlpha=H<Y*.15?Math.max(0,H/(Y*.15)):1,T.beginPath(),T.roundRect(H-1.1,C-Z/2,2.2,Z,1.1),T.fill()}T.globalAlpha=1};return g(),()=>cancelAnimationFrame(E)},[e,n]);const b=`${Math.floor(p/60)}:${String(p%60).padStart(2,"0")}`;return a?t.jsxs("div",{className:"t2c-voicebar",children:[t.jsx(sn,{size:14,className:"spin"}),t.jsx("span",{className:"t2c-voicelabel",children:l("input.micBusy")}),t.jsx("span",{className:"t2c-grow"})]}):t.jsxs("div",{className:"t2c-voicebar",children:[t.jsx("canvas",{ref:m,className:"t2c-voicewave"}),t.jsx("span",{className:"t2c-voicetime",children:c??b}),t.jsx("button",{className:"t2c-voicestop",title:r??l("input.micStop"),onClick:o,children:t.jsx(ko,{size:12})}),i&&t.jsx("button",{className:"t2c-send",title:l("input.send"),onClick:i,children:t.jsx(nc,{size:16})})]})}xe({"ultraConfirm.title":{zh:"开启 Ultra?",en:"Turn on Ultra?"},"ultraConfirm.msg":{zh:"Ultra 会把思考拉满、上下文用到模型支持的上限,并主动把能并行的活拆给多个子代理同时做。一次任务的 token 消耗可能是平时的数倍,适合大任务。",en:"Ultra maxes out thinking, uses the model's full context window, and proactively splits parallelizable work across several subagents. One task can use several times the usual tokens, so it suits big jobs."},"ultraConfirm.recommend":{zh:"推荐配合「完全放行」使用:多个子代理并行时,每个需要确认的操作都会停下来等你批准。",en:"Full access is recommended: with several subagents running in parallel, every action that needs approval stops and waits for you."},"ultraConfirm.fullAccess":{zh:"同时把本会话切到「完全放行」",en:"Also switch this session to Full access"},"ultraConfirm.skip":{zh:"以后不再显示",en:"Don't show this again"},"ultraConfirm.confirm":{zh:"开启 Ultra",en:"Turn on Ultra"}});const Ko="forsion_ultra_confirm_off";function ed(){try{return localStorage.getItem(Ko)==="1"}catch{return!1}}function td({offerFullAccess:e,onConfirm:n,onClose:a}){const{t:o}=ze(),[i,c]=u.useState(!1),[r,l]=u.useState(!1),m=u.useRef(typeof document<"u"?document.activeElement:null);u.useEffect(()=>()=>{const f=m.current;f?.isConnected&&typeof f.focus=="function"&&f.focus({preventScroll:!0})},[]);const p=f=>{if(f.key!=="Tab")return;const x=f.currentTarget.querySelector(".dialog"),b=x?[...x.querySelectorAll('button, input, [tabindex]:not([tabindex="-1"])')].filter(z=>!z.disabled):[];if(!b.length)return;const A=b[0],T=b[b.length-1];f.shiftKey&&document.activeElement===A?(f.preventDefault(),T.focus()):!f.shiftKey&&document.activeElement===T&&(f.preventDefault(),A.focus())};return fa.createPortal(t.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},"data-ultra-confirm":!0,"data-keep-menus":!0,onKeyDown:p,children:t.jsxs(xo,{title:o("ultraConfirm.title"),message:o("ultraConfirm.msg"),confirmLabel:o("ultraConfirm.confirm"),danger:!1,onConfirm:()=>{if(r)try{localStorage.setItem(Ko,"1")}catch{}n({fullAccess:e&&i})},onClose:a,children:[e&&t.jsx("div",{className:"dialog-msg",children:o("ultraConfirm.recommend")}),e&&t.jsxs("label",{className:"dialog-check","data-ultra-full-access":!0,children:[t.jsx("input",{type:"checkbox",checked:i,onChange:f=>c(f.target.checked)}),t.jsx("span",{children:o("ultraConfirm.fullAccess")})]}),t.jsxs("label",{className:"dialog-check","data-ultra-skip":!0,children:[t.jsx("input",{type:"checkbox",checked:r,onChange:f=>l(f.target.checked)}),t.jsx("span",{children:o("ultraConfirm.skip")})]})]})}),document.body)}xe({"session.untitled":{zh:"新会话",en:"New session"},"session.rootlessGroup":{zh:"无项目会话",en:"No project"}});const nd="New Chat";function ht(e,n){const a=(e||"").trim();return!a||a===nd?n("session.untitled"):e}function bn(e,n){return e.kind==="rootless"?n("session.rootlessGroup"):e.name}xe({"group.setup.selfPacedHint":{zh:"发消息后成员同时开工,可相互 @ 交接;每位成员自己决定何时收尾,全员完成即结束,没有轮数上限。",en:"After you send, members work in parallel and can @-mention each other; each decides when they are done, and the team stops once everyone is — no round limit."}});const sd=()=>({name:"",description:"",model:"",systemPrompt:"",thinkingLevel:"",maxIterations:"",approvalMode:""}),ad=()=>`temp-${Date.now().toString(36)}-${Math.floor(Math.random()*46656).toString(36)}`,id=({agents:e,models:n,initialAgents:a,initialTempAgents:o,active:i,hideDisable:c,onConfirm:r,onDisable:l,onClose:m})=>{const{t:p}=ze(),f=u.useMemo(()=>new Set(e.map(g=>g.slug)),[e]),[x,b]=u.useState(()=>a.filter(g=>f.has(g))),[A,T]=u.useState(o||[]),[z,M]=u.useState(null),U=u.useMemo(()=>(n||[]).map(g=>({id:g.id,label:g.name||g.id})),[n]),L=x.length+A.length>=2,B=g=>b(O=>O.includes(g)?O.filter(X=>X!==g):[...O,g]),J=()=>{if(!z||!z.name.trim()||!z.systemPrompt.trim())return;const g=z.slug||ad(),O={slug:g,name:z.name.trim(),description:z.description.trim(),model:z.model,tools:[],thinkingLevel:z.thinkingLevel,maxIterations:z.maxIterations?Number(z.maxIterations):null,approvalMode:z.approvalMode,createdBy:"user",createdAt:"",systemPrompt:z.systemPrompt.trim()};T(X=>{const ee=X.findIndex(Y=>Y.slug===g);if(ee>=0){const Y=X.slice();return Y[ee]=O,Y}return[...X,O]}),M(null)},E=()=>{L&&r({groupAgents:[...x,...A.map(g=>g.slug)],groupTempAgents:A})};return t.jsx("div",{onClick:m,style:{position:"fixed",inset:0,background:"var(--overlay-scrim)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:t.jsxs("div",{"data-team-setup":!0,onClick:g=>g.stopPropagation(),style:{width:480,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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.jsx(Gs,{size:18}),t.jsx("strong",{style:{fontSize:"var(--ui-font-heading, 14px)",flex:1},children:p("group.setup.title")}),t.jsx("button",{className:"icon-btn",onClick:m,title:p("group.setup.close"),children:t.jsx(mt,{size:16})})]}),z?t.jsxs("div",{className:"field",children:[t.jsx("div",{className:"hint",style:{marginBottom:8},children:p("group.setup.tempFormHint")}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:p("settings.agents.name")}),t.jsx("input",{type:"text",value:z.name,placeholder:p("settings.agents.namePlaceholder"),onChange:g=>M({...z,name:g.target.value})})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:p("settings.agents.desc")}),t.jsx("input",{type:"text",value:z.description,onChange:g=>M({...z,description:g.target.value})})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:p("settings.agents.model")}),t.jsxs("select",{value:z.model,onChange:g=>M({...z,model:g.target.value}),children:[t.jsx("option",{value:"",children:p("settings.agents.modelDefault")}),U.map(g=>t.jsx("option",{value:g.id,children:g.label},g.id))]})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:p("settings.agents.systemPrompt")}),t.jsx("textarea",{rows:6,value:z.systemPrompt,placeholder:p("settings.agents.systemPromptPlaceholder"),onChange:g=>M({...z,systemPrompt:g.target.value})})]}),t.jsxs("div",{className:"field-row",children:[t.jsxs("div",{className:"field",children:[t.jsx("label",{children:p("settings.agents.thinking")}),t.jsxs("select",{value:z.thinkingLevel,onChange:g=>M({...z,thinkingLevel:g.target.value}),children:[t.jsx("option",{value:"",children:p("settings.agents.inherit")}),Yn.map(g=>t.jsx("option",{value:g,children:Qs(g,p)},g))]})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:p("settings.agents.maxIter")}),t.jsx("input",{type:"number",min:10,max:200,value:z.maxIterations,onChange:g=>M({...z,maxIterations:g.target.value})})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:p("settings.agents.approval")}),t.jsxs("select",{value:z.approvalMode,onChange:g=>M({...z,approvalMode:g.target.value}),children:[t.jsx("option",{value:"",children:p("settings.agents.inherit")}),t.jsx("option",{value:"readonly",children:"readonly"}),t.jsx("option",{value:"auto-edit",children:"auto-edit"}),t.jsx("option",{value:"full-auto",children:"full-auto"}),t.jsx("option",{value:"custom",children:"custom"})]})]})]}),t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsxs("button",{className:"btn primary sm",disabled:!z.name.trim()||!z.systemPrompt.trim(),onClick:J,children:[t.jsx(ft,{size:13})," ",p("group.setup.tempSave")]}),t.jsx("button",{className:"btn ghost sm",onClick:()=>M(null),children:p("group.setup.close")})]})]}):t.jsxs(t.Fragment,{children:[e.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",fontWeight:600,margin:"8px 0 6px",color:"var(--text-dim)"},children:p("group.setup.savedAgents")}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:12},children:e.map(g=>{const O=x.includes(g.slug);return t.jsxs("button",{onClick:()=>B(g.slug),style:{display:"flex",alignItems:"center",gap:10,textAlign:"left",padding:"8px 10px",borderRadius:"var(--radius-sm, 6px)",border:`1px solid ${O?"var(--accent-ink)":"var(--border)"}`,background:O?"var(--accent-soft)":"transparent",color:"inherit",cursor:"pointer"},children:[t.jsx("span",{style:{width:16,height:16,borderRadius:4,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",border:`1px solid ${O?"var(--accent-ink)":"var(--border)"}`,background:O?"var(--accent-ink)":"transparent"},children:O&&t.jsx(ft,{size:12,color:"var(--on-accent-ink, var(--on-accent))"})}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"var(--ui-font-body, 13px)",fontWeight:600},children:g.name}),g.description&&t.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.description})]})]},g.slug)})})]}),t.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",fontWeight:600,margin:"8px 0 6px",color:"var(--text-dim)"},children:p("group.setup.tempAgents")}),A.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,marginBottom:8},children:A.map(g=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:"var(--radius-sm, 6px)",border:"1px solid var(--accent-ink)",background:"var(--accent-soft)"},children:[t.jsx(_o,{size:14,style:{flexShrink:0,opacity:.8}}),t.jsxs("span",{style:{flex:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:"var(--ui-font-body, 13px)",fontWeight:600},children:g.name}),t.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-dim)",marginLeft:6},children:p("group.setup.tempBadge")})]}),t.jsx("button",{className:"icon-btn",title:p("common.edit"),onClick:()=>M({slug:g.slug,name:g.name,description:g.description,model:g.model,systemPrompt:g.systemPrompt,thinkingLevel:g.thinkingLevel,maxIterations:g.maxIterations!=null?String(g.maxIterations):"",approvalMode:g.approvalMode}),children:t.jsx(zn,{size:13})}),t.jsx("button",{className:"icon-btn",title:p("common.delete"),onClick:()=>T(O=>O.filter(X=>X.slug!==g.slug)),children:t.jsx(Gn,{size:13})})]},g.slug))}),t.jsxs("button",{className:"btn ghost sm",style:{marginBottom:14},onClick:()=>M(sd()),children:[t.jsx(ts,{size:13})," ",p("group.setup.addTemp")]}),t.jsx("div",{style:{fontSize:"var(--ui-font-meta, 12px)",color:"var(--text-dim)",margin:"6px 0 14px"},children:p("group.setup.selfPacedHint")}),t.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[i&&!c&&t.jsx("button",{className:"btn sm",onClick:()=>{l(),m()},children:p("group.setup.disable")}),t.jsx("button",{className:"btn primary sm",onClick:E,disabled:!L,children:p(i?"group.setup.update":"group.setup.start")})]}),!L&&t.jsx("div",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--danger)",textAlign:"right",marginTop:6},children:p("group.setup.needTwo")})]})]})})},Hn=2e5,Fs=(e,n,a)=>Vl(e,e,n,a,void 0,void 0,{context:3});function od(e){if(!/^\*\*\* (Begin Patch|(Add|Update|Delete) File:)/m.test(e))return null;const n=e.replace(/\r\n/g,`
|
|
2
|
+
`).split(`
|
|
3
|
+
`),a=/^\*\*\* (Add|Update|Delete) File: (.+)$/,o=r=>a.test(r)||/^\*\*\* (Begin|End) Patch$/.test(r.trim()),i=[];let c=0;for(;c<n.length;){const r=a.exec(n[c]);if(!r){c++;continue}const l=r[1],m=r[2].trim();c++;let p="";const f=l==="Update"?/^\*\*\* Move to: (.+)$/.exec(n[c]??""):null;f&&(p=f[1].trim(),c++);const x=[];for(;c<n.length&&!o(n[c]);)x.push(n[c]),c++;if(l==="Delete"){i.push(`--- ${m}`,"+++ /dev/null","@@ -1,1 +0,0 @@","-(deleted)");continue}if(l==="Add"){const M=x.filter(U=>U.startsWith("+")).map(U=>U.slice(1));if(!M.length)continue;i.push("--- /dev/null",`+++ ${m}`,`@@ -0,0 +1,${M.length} @@`,...M.map(U=>"+"+U));continue}const b=[`--- ${m}`,`+++ ${p||m}`];let A=[],T="";const z=()=>{if(!A.length)return;const M=A.filter(_=>_[0]!=="+").length,U=A.filter(_=>_[0]!=="-").length;b.push(`@@ -1,${M} +1,${U} @@${T?" "+T:""}`,...A),A=[]};for(const M of x){const U=/^@@ ?(.*)$/.exec(M);if(U){z(),T=U[1]||"";continue}M.startsWith("+")||M.startsWith("-")||M.startsWith(" ")?A.push(M):A.push(" "+M)}z(),b.length>2&&i.push(...b)}return i.length?i.join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`:null}function rd(e,n){if(!n)return null;let a;try{a=JSON.parse(n)}catch{return null}if(!a||typeof a!="object")return null;const o=typeof a.path=="string"&&a.path?a.path:"file";try{switch(e){case"edit_file":{const i=String(a.old_string??""),c=String(a.new_string??"");return!i&&!c||i.length+c.length>Hn?null:Fs(o,i,c)}case"multi_edit":{if(!Array.isArray(a.edits)||!a.edits.length)return null;let i=0;const c=[];for(let r=0;r<a.edits.length;r++){const l=a.edits[r],m=String(l?.old_string??""),p=String(l?.new_string??"");if(i+=m.length+p.length,i>Hn)return null;c.push(Fs(a.edits.length>1?`${o} · #${r+1}`:o,m,p))}return c.join(`
|
|
6
|
+
`)}case"write_file":{const i=String(a.content??"");return!i||i.length>Hn?null:Fs(o,"",i)}case"apply_patch":{const i=String(a.patch??a.input??a.diff??"");return i.length>Hn?null:/^@@[ -]/m.test(i)&&/^(--- |\+\+\+ )/m.test(i)?i:od(i)}default:return null}}catch{return null}}xe({"approval.remoteReadOnly":{zh:"远程连接下只能原样批准或拒绝,要改命令请在那台设备本机上操作",en:"Over a remote connection you can only approve or reject as is. To change the command, use that device itself"},"approval.remote.caller":{zh:"来自远程会话 · {name}",en:"From a remote session · {name}"},"approval.remote.device":{zh:"来自远程会话 · 已登记设备",en:"From a remote session · a registered device"},"approval.remote.account":{zh:"来自远程会话 · 账号下未识别的客户端",en:"From a remote session · an unidentified client on your account"},"approval.remote.lan":{zh:"来自远程会话 · 局域网配对设备",en:"From a remote session · a LAN-paired device"},"approval.remote.p2p":{zh:"来自远程会话 · 点对点直连",en:"From a remote session · a peer-to-peer connection"},"approval.remote.unknown":{zh:"来自远程会话",en:"From a remote session"},"approval.localOnly":{zh:"这项操作涉及受保护的配置,只能在执行它的电脑上批准",en:"This touches protected configuration and can only be approved on the computer running it"},"approval.byHost":{zh:"在执行的电脑上",en:"on the host computer"},"approval.byHostNamed":{zh:"在执行的电脑上({device})",en:"on the host computer ({device})"},"approval.byDevice":{zh:"在 {device} 上",en:"on {device}"},"approval.byRegisteredDevice":{zh:"在已登记设备上",en:"on a registered device"},"approval.byOther":{zh:"在另一台设备上",en:"on another device"},"approval.byChannel":{zh:"经消息通道",en:"via a messaging channel"}});const la=new Set,ph=e=>la.has(e),cd=e=>cc(lc(e)).remoteApprover,eo=480,fh=({req:e,onDecide:n,sessionId:a})=>{const{t:o}=ze(),i=cd(a),c=sc(a),r=e.name==="run_bash",l=(()=>{if(!r||!e.arguments)return"";try{return String(JSON.parse(e.arguments).command??"")}catch{return""}})(),[m,p]=u.useState(l),f=u.useRef(null),[x,b]=u.useState(!1);u.useLayoutEffect(()=>{const g=f.current;if(!g)return;g.style.height="auto";const O=g.scrollHeight;g.style.height=`${Math.min(O,eo)}px`,b(O>eo)},[m]);const A=Yl.test(m),T=Gl.test(m),z=e.status!=="pending",M=u.useMemo(()=>r?null:rd(e.name,e.arguments),[r,e.name,e.arguments]),U=ac(e.reason)&&!i,_=ic(e.reason,o),L=oc(e.remote,o),B=!(e.localOnly&&i),J=z?rc(e.answeredBy,{remotePage:i,answeredHere:la.has(e.approvalId),hostName:c},o):"",E=g=>{if(z||g!=="reject"&&!B)return;la.add(e.approvalId);const O=r&&!i&&m.trim()&&m!==l?{command:m}:void 0;n(g,g==="reject"?void 0:O)};return t.jsxs("div",{className:`approval-card${z?" resolved":""}`,children:[t.jsxs("div",{className:"approval-title",children:[t.jsx(fu,{size:15,style:{color:"var(--accent-ink)"}}),o("approval.requestExec",{name:e.name}),z&&t.jsxs("span",{style:{fontWeight:400,fontSize:"var(--ui-font-meta, 12px)",color:"var(--text-faint)"},children:[e.status==="approved"?o("approval.statusApproved"):e.status==="rejected"?o("approval.statusRejected"):o("approval.statusExpired"),J&&t.jsxs("span",{"data-answered-by":!0,children:[" · ",J]})]})]}),L&&t.jsx("div",{className:"approval-why","data-approval-remote":!0,children:L}),_&&t.jsx("div",{className:"approval-why",children:_}),r&&!z&&!i?t.jsx("textarea",{className:"approval-edit",value:m,onChange:g=>p(g.target.value),ref:f,rows:1,spellCheck:!1}):null,r&&!z&&(x||A||T)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"approval-why",children:[x&&t.jsx("div",{children:o("approval.cmdOverflow")}),A&&t.jsx("div",{children:o("approval.cmdHiddenChars")}),T&&t.jsx("div",{children:o("approval.cmdWideBlank")})]}),(A||T)&&t.jsx("div",{className:"approval-preview",children:e.preview})]}),r&&!z&&!i?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"approval-preview",children:e.preview}),M&&t.jsx("div",{className:"approval-diff",children:t.jsx(Kl,{text:M,side:!1})}),i&&!z&&B&&t.jsx("div",{className:"approval-why","data-remote-readonly":!0,children:o("approval.remoteReadOnly")}),!z&&!B&&t.jsx("div",{className:"approval-why","data-local-only":!0,children:o("approval.localOnly")})]}),!z&&t.jsxs("div",{className:"approval-actions",children:[B&&t.jsxs("button",{className:"btn primary sm",onClick:()=>E("approve"),children:[t.jsx(ft,{size:13})," ",o("approval.approve")]}),U&&B&&t.jsxs("button",{className:"btn ghost sm",onClick:()=>E("approve_always"),children:[t.jsx(Sl,{size:13})," ",o("approval.approveAlways")]}),t.jsxs("button",{className:"btn danger sm",onClick:()=>E("reject"),children:[t.jsx(mt,{size:13})," ",o("approval.reject")]})]})]})},ld=["readonly","auto-edit","full-auto"],ud={base:"auto-edit"},Os=e=>e.join(`
|
|
7
|
+
`),Ws=e=>e.split(`
|
|
8
|
+
`).map(n=>n.trim()).filter(Boolean),dd=({cfg:e,onClose:n})=>{const{t:a}=ze(),[o,i]=u.useState(ud.base),[c,r]=u.useState({deny:"",ask:"",allow:""}),[l,m]=u.useState(!0),[p,f]=u.useState(!1),[x,b]=u.useState(!1),[A,T]=u.useState(""),z=nn.useRef(e);z.current=e;const M=nn.useCallback(()=>{m(!0),T(""),uc(pt()).then(L=>{i(L.base),r({deny:Os(L.deny),ask:Os(L.ask),allow:Os(L.allow)}),f(!0),m(!1)}).catch(L=>{T(String(L?.message||L)),f(!1),m(!1)})},[]);u.useEffect(()=>{M()},[M]);const U=async()=>{if(p){b(!0),T("");try{await mc(pt(),{base:o,deny:Ws(c.deny),ask:Ws(c.ask),allow:Ws(c.allow)}),n()}catch(L){T(String(L?.message||L)),b(!1)}}},_=L=>t.jsxs("div",{className:"field",children:[t.jsx("label",{children:t.jsx("b",{children:a(`approvalRules.${L}`)})}),t.jsx("div",{className:"hint",children:a(`approvalRules.${L}Hint`)}),t.jsx("textarea",{value:c[L],onChange:B=>r(J=>({...J,[L]:B.target.value})),rows:3,spellCheck:!1,placeholder:a(`approvalRules.${L}Ph`),style:{width:"100%",fontFamily:"var(--font-mono)",fontSize:"var(--ui-font-meta, 12px)"}})]},L);return t.jsx("div",{className:"apvr-modal",onClick:n,style:{position:"fixed",inset:0,background:"var(--overlay-scrim)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:t.jsxs("div",{onClick:L=>L.stopPropagation(),style:{background:"var(--bg-card)",border:"var(--border-width) solid var(--border)",borderRadius:"var(--radius-lg, 12px)",padding:18,width:"min(620px, 92vw)",maxHeight:"86vh",overflow:"auto",boxShadow:"var(--card-shadow)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:10},children:[t.jsx("b",{children:a("approvalRules.title")}),t.jsx("button",{className:"icon-btn",onClick:n,children:t.jsx(mt,{size:15})})]}),l?t.jsx("div",{className:"field",children:t.jsxs("div",{className:"hint",children:[t.jsx(sn,{size:14,className:"spin"})," ",a("common.loading")]})}):p?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"field",children:[t.jsx("div",{className:"hint",children:a("approvalRules.scopeNote")}),t.jsx("div",{className:"hint",style:{marginTop:4},children:a("approvalRules.syntax")})]}),t.jsxs("div",{className:"field",children:[t.jsx("label",{children:t.jsx("b",{children:a("approvalRules.base")})}),t.jsx("div",{className:"hint",children:a("approvalRules.baseHint")}),t.jsx("div",{style:{display:"flex",gap:6,marginTop:6},children:ld.map(L=>t.jsx("button",{className:`btn sm${o===L?" primary":" ghost"}`,onClick:()=>i(L),children:a(dc[L])},L))})]}),["deny","ask","allow"].map(_),A&&t.jsx("div",{className:"field",children:t.jsx("div",{className:"hint",style:{color:"var(--danger)"},children:A})})]}):t.jsxs("div",{className:"field",children:[t.jsx("div",{className:"hint",style:{color:"var(--danger)"},children:a("approvalRules.loadFailed")}),t.jsx("div",{className:"hint",children:A}),t.jsx("div",{style:{marginTop:8},children:t.jsx("button",{className:"btn sm ghost",onClick:M,children:a("common.retry")})})]}),t.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end",marginTop:14},children:[t.jsx("button",{className:"btn ghost sm",onClick:n,children:a("common.cancel")}),t.jsxs("button",{className:"btn primary sm",disabled:!p||x,onClick:()=>{U()},children:[x?t.jsx(sn,{size:13,className:"spin"}):null," ",a("common.save")]})]})]})})},md=[{name:"/help",key:"help",zh:"显示帮助与命令列表",en:"Show help and the command list",surfaces:["tui","desktop","channel"]},{name:"/feedback",key:"feedback",zh:"提交问题或建议,可在命令后填写反馈内容",en:"Report an issue or suggestion; optionally add your feedback after the command",surfaces:["desktop"]},{name:"/new",key:"new",zh:"开始新会话",en:"Start a new session",surfaces:["tui","desktop","channel"]},{name:"/clear",key:"clear",zh:"清屏(保留会话历史)",en:"Clear the screen (history is kept)",surfaces:["tui"]},{name:"/sessions",key:"sessions",aliases:["/list"],zh:"列出最近会话",en:"List recent sessions",surfaces:["tui","desktop","channel"]},{name:"/resume",key:"resume",aliases:["/switch"],zh:"恢复会话并续聊",en:"Resume a session and continue",arg:"<id|序号>",surfaces:["tui","channel"]},{name:"/rename",key:"rename",arg:"<标题>",zh:"重命名本会话",en:"Rename this session",surfaces:["tui"]},{name:"/branch",key:"branch",arg:"[序号]",aliases:["/fork"],zh:"从某条回复后分支新会话(继承历史),缺省最近",en:"Branch a new session from a reply (inherits history); defaults to the latest",surfaces:["tui","desktop"]},{name:"/btw",key:"btw",arg:"[问题]",aliases:["/side"],zh:"顺便问一句:带着本会话上下文旁聊,不进主对话、不打断正在跑的任务",en:"Ask a side question with this session as context; not added to the conversation and never interrupts a running task",surfaces:["desktop"]},{name:"/compact",key:"compact",arg:"[关注点]",zh:"压缩上下文:总结后精简续接(同会话;可附本次摘要的关注点)",en:"Compact context: summarize, then continue compactly (optional focus for this summary)",surfaces:["tui","desktop","channel"]},{name:"/status",key:"status",zh:"本会话概况:模型 / 思考档 / 审批档 / 工作目录 / 用量",en:"Session overview: model, thinking level, approval mode, cwd, usage",surfaces:["tui","desktop","channel"]},{name:"/export",key:"export",zh:"导出本会话为 Markdown",en:"Export this session as Markdown",surfaces:["tui","desktop"]},{name:"/cost",key:"cost",zh:"本会话 token 用量与费用",en:"Token usage and cost for this session",surfaces:["tui","desktop","channel"]},{name:"/diff",key:"diff",zh:"查看工作目录的 git 改动(含未跟踪文件)",en:"Show git changes in the working directory (including untracked files)",surfaces:["tui"]},{name:"/copy",key:"copy",zh:"复制上一条回复到剪贴板",en:"Copy the last reply to the clipboard",surfaces:["tui","desktop"]},{name:"/retry",key:"retry",zh:"重跑上一条用户消息",en:"Re-run the last user message",surfaces:["tui","desktop"]},{name:"/edit",key:"edit",zh:"编辑最近一条消息并重跑($EDITOR)",en:"Edit the last message and re-run ($EDITOR)",surfaces:["tui"]},{name:"/delete",key:"delete",zh:"删除最近一轮对话",en:"Delete the last turn",surfaces:["tui"]},{name:"/queue",key:"queue",arg:"[clear]",zh:"查看排队项:运行中发的消息与 /compact 等命令排到本轮结束后依次执行(/queue clear 清空)",en:"Show queued items: messages and commands like /compact sent while running run in order after this turn (/queue clear to empty)",surfaces:["tui"]},{name:"/stop",key:"stop",zh:"停止当前运行",en:"Stop the current run",surfaces:["desktop","channel"]},{name:"/model",key:"model",arg:"[名称|序号]",zh:"切换模型(不带参数列出可选模型)",en:"Switch model (no argument lists the available models)",surfaces:["tui","desktop","channel"]},{name:"/think",key:"think",arg:"<档位>",aliases:["/effort"],zh:"思考强度:off|minimal|low|medium|high|xhigh|max(模型不支持的档自动降档)",en:"Thinking level: off|minimal|low|medium|high|xhigh|max (auto-clamped to what the model supports)",surfaces:["tui","desktop","channel"]},{name:"/approval",key:"approval",arg:"<档位>",aliases:["/permissions"],zh:"查看或切换审批档:readonly|auto-edit|full-auto|custom",en:"Show or switch the approval mode: readonly|auto-edit|full-auto|custom",surfaces:["tui","desktop","channel"]},{name:"/loop",key:"loop",arg:"<1-200>",zh:"最大循环轮数(默认 90;耗尽会提示)",en:"Max loop iterations (default 90; you get a prompt when exhausted)",surfaces:["tui","desktop","channel"]},{name:"/verify",key:"verify",arg:"<命令|off>",zh:"本会话验证命令:收尾前自动跑,不绿不许收(off 关闭)",en:"Session verify command — runs before the turn may end; must pass (off to clear)",surfaces:["desktop"]},{name:"/plan",key:"plan",zh:"切换计划模式:只读调研 → 提交计划求批准",en:"Toggle plan mode: read-only research, then submit a plan for approval",surfaces:["tui","desktop"]},{name:"/chat",key:"chat",zh:"切到 Chat 模式(轻量:答完即停、临时工作区、不写笔记;侧栏只列聊天会话,新会话按此模式创建,已创建的会话不可切换)",en:"Switch to Chat mode (light: answers and stops, temporary workspace, never writes your notes; the sidebar lists chat sessions only, new sessions use it, existing sessions are fixed)",surfaces:["desktop"]},{name:"/work",key:"work",zh:"切到 Work 模式(完整工具面:文件、命令、技能、子代理;侧栏列出全部项目)",en:"Switch to Work mode (full toolset: files, commands, skills, subagents; the sidebar lists all projects)",surfaces:["desktop"]},{name:"/voice",key:"voice",zh:"切到语音消息(该 Agent 回复变语音)",en:"Switch to voice messages (this agent replies as voice)",surfaces:["desktop","channel"]},{name:"/text",key:"text",zh:"切回文字消息",en:"Switch back to text messages",surfaces:["channel"]},{name:"/cwd",key:"cwd",arg:"[path]",zh:"查看或切换工作目录",en:"Show or change the working directory",surfaces:["tui"]},{name:"/config",key:"config",zh:"查看当前设置",en:"Show current settings",surfaces:["tui","desktop"]},{name:"/login",key:"login",zh:"重新登录 Forsion",en:"Sign in to Forsion again",surfaces:["tui","desktop"]},{name:"/hotkeys",key:"hotkeys",zh:"查看快捷键",en:"Show keyboard shortcuts",surfaces:["tui"]},{name:"/exit",key:"exit",zh:"退出 Tangu",en:"Quit Tangu",surfaces:["tui"]},{name:"/tools",key:"tools",zh:"列出当前模式可用工具",en:"List tools available in the current mode",surfaces:["tui","desktop"]},{name:"/skills",key:"skills",zh:"列出可用技能(✓=本会话启用)",en:"List available skills (✓ = enabled for this session)",surfaces:["tui","desktop"]},{name:"/skill",key:"skill",arg:"<id>",zh:"启用/停用技能",en:"Enable or disable a skill",surfaces:["tui"]},{name:"/agents",key:"agents",zh:"列出本地 Normal Agent(自定义人格)",en:"List local normal agents (custom personas)",surfaces:["tui","desktop","channel"]},{name:"/agent",key:"agent",arg:"<slug>",zh:"启用 Agent;管理:/agent new|edit|rm <slug>",en:"Activate an agent; manage with /agent new|edit|rm <slug>",surfaces:["tui","desktop","channel"]},{name:"/groupchat",key:"groupchat",arg:"<slug…>",zh:"团队模式(/groupchat off 退出)",en:"Team mode (/groupchat off to leave)",surfaces:["tui","desktop"]},{name:"/historian",key:"historian",zh:"Historian 状态/活动;/historian on|off 开关",en:"Historian status/activity; /historian on|off to toggle",surfaces:["tui","desktop"]},{name:"/muse",key:"muse",zh:"Muse 状态/TODO;/muse on|off 开关",en:"Muse status/TODOs; /muse on|off to toggle",surfaces:["tui","desktop"]},{name:"/memory",key:"memory",arg:"[edit]",zh:"查看/编辑长期记忆",en:"View or edit long-term memory",surfaces:["tui","desktop"]},{name:"/refine",key:"refine",arg:"[focus]",zh:"复盘本会话,沉淀 Agent 的进化记录(可回滚)",en:"Reflect on this conversation and refine the agent's evolution record (reversible)",surfaces:["tui","desktop"]},{name:"/log",key:"log",arg:"[YYYY-MM-DD]",zh:"查看每日日志",en:"View the daily log",surfaces:["tui"]},{name:"/mcp",key:"mcp",zh:"列出 MCP server 状态",en:"List MCP server status",surfaces:["tui","desktop"]},{name:"/plugins",key:"plugins",zh:"列出已发现插件",en:"List discovered plugins",surfaces:["tui","desktop"]}];function to(e){return md.filter(n=>n.surfaces.includes(e))}xe({"addMenu.label":{zh:"添加",en:"Add"},"addMenu.newChat":{zh:"新会话",en:"New session"},"addMenu.agent":{zh:"添加 Agent",en:"Add agent"},"addMenu.files":{zh:"添加文件或文件夹",en:"Add files or folders"},"addMenu.camera":{zh:"拍照",en:"Take photo"},"addMenu.photos":{zh:"相册",en:"Photos"},"addMenu.file":{zh:"文件",en:"Files"},"addMenu.conversation":{zh:"添加会话",en:"Add session"},"addMenu.view":{zh:"添加正在使用的 View",en:"Add an active View"},"addMenu.searchChats":{zh:"搜索全部会话",en:"Search all sessions"},"addMenu.searchViews":{zh:"搜索全部 View",en:"Search all Views"},"addMenu.recent":{zh:"最近使用",en:"Recent"},"addMenu.allChats":{zh:"全部会话",en:"All sessions"},"addMenu.inUse":{zh:"正在使用",en:"In use"},"addMenu.allViews":{zh:"全部 View",en:"All Views"},"addMenu.noMatches":{zh:"没有匹配项",en:"No matches"}});const Us=new Set(["chat","chat-panel","home","launcher","sidebar-empty"]),hd=300;function pd(e,n,a=hd){const o=new Set(e.map(c=>c.id)),i=n.filter(c=>!o.has(c.id));return i.length>a?null:{recent:[...e],rest:i}}function Vn(e){const n=new Set;return e.filter(a=>n.has(a.key)?!1:(n.add(a.key),!0))}const fd=({open:e,disabled:n,activeSessionId:a,canUsePathPicker:o,onOpenChange:i,onNewSession:c,onAddAgent:r,onPickPaths:l,onPickFiles:m,onAddReference:p})=>{const{t:f}=ze(),[x,b]=u.useState(null),[A,T]=u.useState(""),[z,M]=u.useState("right"),[U,_]=u.useState(0),L=u.useRef(null),B=u.useRef(null),J=u.useRef(null),E=u.useRef(null),g=an(e,{boundary:".t2-chat-view"}),O=an(x?`${x}:${z}`:"",{boundary:".t2-chat-view"}),X=$(j=>j.sessions),ee=$(j=>j.archivedSessions),Y=zl(j=>j.items),W=Xn(j=>j.mainTabs),C=Xn(j=>j.leftTabs),P=Xn(j=>j.rightTabs),H=Nn(j=>j.vaultRoot);u.useEffect(()=>{e||(b(null),T(""))},[e]),u.useEffect(()=>{T(""),x&&requestAnimationFrame(()=>J.current?.focus())},[x]),u.useLayoutEffect(()=>{const j=L.current,K=B.current;if(!x||!j||!K)return;const q=()=>{const Ge=j.getBoundingClientRect(),zt=(j.closest(".t2c-card")||j.closest(".t2-chat-view"))?.getBoundingClientRect(),tt=bo(K),Xe=zt?jo(Ge.left,Ge.right,K.offsetWidth,zt.left,zt.right,tt):"right";M(Le=>Le===Xe?Le:Xe),_(Le=>Le===j.offsetHeight+6?Le:j.offsetHeight+6)};q(),window.addEventListener("resize",q),window.addEventListener(ns,q);const ae=new ResizeObserver(q);ae.observe(j),ae.observe(K);const Ne=j.closest(".t2c-card")||j.closest(".t2-chat-view");return Ne&&ae.observe(Ne),()=>{window.removeEventListener("resize",q),window.removeEventListener(ns,q),ae.disconnect()}},[x]);const Z=u.useMemo(()=>{const j=new Set;return[...X,...ee].filter(K=>K.id===a||j.has(K.id)?!1:(j.add(K.id),!0))},[X,ee,a]),R=u.useMemo(()=>{const j=new Map(Z.map(q=>[q.id,q])),K=Y.filter(q=>q.kind==="chat").map(q=>j.get(q.id)).filter(Boolean);return(K.length?K:Z).slice(0,6)},[Z,Y]),Q=u.useMemo(()=>{const j=A.trim().toLocaleLowerCase();return j?Z.filter(K=>`${K.title||""}
|
|
9
|
+
${K.summary||""}`.toLocaleLowerCase().includes(j)).slice(0,12):R},[A,R,Z]),v=u.useMemo(()=>{const j=W.flatMap(q=>{if(Us.has(q.type))return[];const ae=q.title||zi(Ts(q.type)?.displayName||q.type);if(q.filePath){const Ne=q.type==="amadeus-editor"&&!!H;return[{key:`${Ne?"note":"file"}:${q.filePath}`,type:q.type,title:ae,ref:Ne?{kind:"note",path:q.filePath}:{kind:"file",path:q.filePath},meta:q.filePath}]}return[{key:`view:${q.type}`,type:q.type,title:ae,ref:{kind:"view",type:q.type,title:ae}}]}),K=[...C,...P].flatMap(q=>Us.has(q.type)?[]:[{key:`view:${q.type}`,type:q.type,title:q.title,ref:{kind:"view",type:q.type,title:q.title}}]);return Vn([...j,...K]).slice(0,8)},[W,C,P,H]),F=u.useMemo(()=>Vn(Y.flatMap(j=>j.kind==="chat"?[]:j.kind==="note"?[{key:j.key,type:"amadeus-editor",title:j.title,ref:{kind:"note",path:j.id},meta:j.id}]:j.kind==="file"&&j.viewType?[{key:j.key,type:j.viewType,title:j.title,ref:{kind:"file",path:j.id},meta:j.id}]:j.kind==="view"&&j.viewType&&Ts(j.viewType)?[{key:j.key,type:j.viewType,title:j.title,ref:{kind:"view",type:j.viewType,title:j.title}}]:[])).slice(0,6),[Y]),ne=hc().filter(j=>!Us.has(j.type)).map(j=>{const K=zi(j.displayName);return{key:`view:${j.type}`,type:j.type,title:K,ref:{kind:"view",type:j.type,title:K}}}),we=(()=>{const j=A.trim().toLocaleLowerCase();return j?Vn([...v,...F,...ne]).filter(K=>`${K.title}
|
|
10
|
+
${K.type}
|
|
11
|
+
${K.meta||""}`.toLocaleLowerCase().includes(j)).slice(0,12):[]})(),be=j=>{p(j),i(!1)},je=async j=>{i(!1);const K=await j();if(!K.length)return;const q=new DataTransfer;K.forEach(ae=>q.items.add(ae)),await m(q.files)},Pe=async()=>{if(o&&window.tangu?.pickPaths){i(!1);const j=await window.tangu.pickPaths();j.length&&await l(j);return}if(window.tangu?.pickFiles)return je(()=>window.tangu.pickFiles());E.current?.click()},Te=j=>Ts(j)?.icon||Zn,Me=j=>{const K=j.ref.kind==="file"||j.ref.kind==="note"?ga:Te(j.type);return{id:`ref:${j.key}`,label:j.title,detail:j.meta,icon:t.jsx(K,{size:14}),run:()=>be(j.ref)}},Ve=j=>({id:`session:${j.id}`,label:j.title||"Chat",detail:j.summary||void 0,icon:t.jsx(en,{size:14}),run:()=>be({kind:"session",id:j.id,title:j.title||"Chat"})}),$e={id:"new-chat",label:f("addMenu.newChat"),icon:t.jsx(Xl,{size:14}),run:()=>{c?.(),i(!1)}},De=r?{id:"add-agent",act:"add-agent",label:f("addMenu.agent"),icon:t.jsx(_o,{size:14}),run:()=>{r(),i(!1)}}:null,Ke={id:"files",label:f("addMenu.files"),icon:t.jsx(gc,{size:14}),run:()=>{Pe()}},_e=window.tangu,Ye=_e?.takePhoto&&_e.pickPhotos&&_e.pickFiles?[{id:"camera",label:f("addMenu.camera"),icon:t.jsx(pc,{size:14}),run:()=>{je(()=>_e.takePhoto())}},{id:"photos",label:f("addMenu.photos"),icon:t.jsx(fc,{size:14}),run:()=>{je(()=>_e.pickPhotos())}},{...Ke,label:f("addMenu.file")}]:[Ke],vt=()=>{const j=pd(R,Z),K=Vn([...v,...F]),q=new Set(K.map(Ne=>Ne.key)),ae=f("addMenu.noMatches");return{title:f("addMenu.label"),back:f("common.back"),sections:[{items:[$e,...De?[De]:[],...Ye,j?{id:"conversation",label:f("addMenu.conversation"),icon:t.jsx(en,{size:14}),search:{placeholder:f("addMenu.searchChats"),empty:ae},children:[{title:f("addMenu.recent"),items:j.recent.map(Ve)},{title:f("addMenu.allChats"),items:j.rest.map(Ve)}]}:{id:"conversation",label:f("addMenu.conversation"),icon:t.jsx(en,{size:14}),run:()=>{i(!0),b("conversation")}},{id:"view",label:f("addMenu.view"),icon:t.jsx(Zn,{size:14}),search:{placeholder:f("addMenu.searchViews"),empty:ae},children:[{title:f("addMenu.inUse"),items:v.map(Me)},{title:f("addMenu.recent"),items:F.filter(Ne=>!v.some(Ge=>Ge.key===Ne.key)).map(Me)},{title:f("addMenu.allViews"),items:ne.filter(Ne=>!q.has(Ne.key)).map(Me)}]}]}]}},Ct=j=>j.map(K=>{const q=Me(K);return t.jsxs("button",{className:"menu-item add-menu-result",title:K.meta||K.title,onClick:q.run,children:[q.icon,t.jsxs("span",{className:"grow add-menu-result-main",children:[t.jsx("span",{className:"add-menu-result-title",children:q.label}),q.detail&&t.jsx("span",{className:"add-menu-result-meta",children:q.detail})]})]},K.key)});return t.jsxs("span",{className:`add-pill-wrap t2c-capsule-peer${e?" is-open":""}`,"data-cmenu":!0,children:[t.jsxs("button",{className:`t2c-pill add-pill-btn${e?" is-open":""}`,title:f("input.addContent"),"aria-expanded":e,disabled:n,onClick:()=>{!e&&ka(vt,{})||i(!e)},children:[t.jsx(ts,{size:16,className:"add-pill-plus"}),t.jsx("span",{className:"add-pill-label",children:f("addMenu.label")}),t.jsx(Rn,{size:10,className:"add-pill-chevron"})]}),e&&t.jsxs("div",{ref:j=>{L.current=j,g.ref.current=j},className:"composer-menu composer-menu--add",style:g.style,children:[t.jsxs("button",{className:"menu-item",onClick:$e.run,children:[$e.icon,t.jsx("span",{className:"grow",children:$e.label})]}),De&&t.jsxs("button",{className:"menu-item","data-add-agent":!0,onClick:De.run,children:[De.icon,t.jsx("span",{className:"grow",children:De.label})]}),t.jsxs("button",{className:"menu-item",onClick:Ke.run,children:[Ke.icon,t.jsx("span",{className:"grow",children:Ke.label})]}),t.jsxs("button",{className:`menu-item add-menu-parent${x==="conversation"?" active":""}`,"aria-expanded":x==="conversation",onPointerEnter:()=>b("conversation"),onFocus:()=>b("conversation"),onClick:()=>b("conversation"),children:[t.jsx(en,{size:14}),t.jsx("span",{className:"grow",children:f("addMenu.conversation")}),t.jsx(_t,{size:13})]}),t.jsxs("button",{className:`menu-item add-menu-parent${x==="view"?" active":""}`,"aria-expanded":x==="view",onPointerEnter:()=>b("view"),onFocus:()=>b("view"),onClick:()=>b("view"),children:[t.jsx(Zn,{size:14}),t.jsx("span",{className:"grow",children:f("addMenu.view")}),t.jsx(_t,{size:13})]})]}),e&&x&&t.jsxs("div",{ref:j=>{B.current=j,O.ref.current=j},className:`composer-menu add-menu-sub ${z}`,"data-pane":x,style:{...O.style,bottom:z==="stacked"?`calc(100% + ${U}px)`:void 0},children:[t.jsxs("label",{className:"add-menu-search",children:[t.jsx(wo,{size:13}),t.jsx("input",{ref:J,value:A,onChange:j=>T(j.currentTarget.value),placeholder:f(x==="conversation"?"addMenu.searchChats":"addMenu.searchViews")})]}),t.jsx("div",{className:"add-menu-sub-scroll",children:x==="conversation"?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:f(A.trim()?"addMenu.allChats":"addMenu.recent")}),Q.map(j=>{const K=Ve(j);return t.jsxs("button",{className:"menu-item add-menu-result",title:j.summary||j.title||"",onClick:K.run,children:[K.icon,t.jsxs("span",{className:"grow add-menu-result-main",children:[t.jsx("span",{className:"add-menu-result-title",children:K.label}),K.detail&&t.jsx("span",{className:"add-menu-result-meta",children:K.detail})]})]},j.id)}),!Q.length&&t.jsx("div",{className:"add-menu-empty",children:f("addMenu.noMatches")})]}):A.trim()?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:f("addMenu.allViews")}),Ct(we),!we.length&&t.jsx("div",{className:"add-menu-empty",children:f("addMenu.noMatches")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:f("addMenu.inUse")}),Ct(v),!v.length&&t.jsx("div",{className:"add-menu-empty",children:f("addMenu.noMatches")}),!!F.length&&t.jsx("div",{className:"menu-section add-menu-section-gap",children:f("addMenu.recent")}),Ct(F)]})})]}),t.jsx("input",{ref:E,type:"file",multiple:!0,hidden:!0,onChange:j=>{m(j.currentTarget.files),j.currentTarget.value="",i(!1)}})]})};function Yo(e,n){const a=e.agents.filter(l=>l.createdBy!=="system"),o=e.agents.find(l=>l.slug===e.currentAgentSlug),i={id:"normal-work",label:n("input.normalWork"),icon:t.jsx(Rs,{size:14}),checked:e.active,disabled:e.disabled,run:()=>{e.onNormalWork(),e.onClose()}},c=e.onAgentSwitch?a.map(l=>({id:`agent:${l.slug}`,label:l.name,icon:t.jsx(Rs,{size:14}),checked:e.currentAgentSlug===l.slug,run:()=>{e.onAgentSwitch(l.slug),e.onClose()}})):[],r=c.length?{id:"agent-switch",label:n("input.agentSwitch.section"),detail:o?.name,icon:t.jsx(Rs,{size:14}),children:[{items:c}]}:null;return{normal:i,agentSwitch:r,agents:c}}function gd(e){const{currentAgentSlug:n,agents:a}=e,{t:o}=ze(),[i,c]=u.useState(!1),[r,l]=u.useState("right"),[m,p]=u.useState(0),f=u.useRef(null),x=u.useRef(null),b=an(i?r:"",{boundary:".t2-chat-view"}),A=Yo(e,o),T=A.agentSwitch?()=>c(!0):void 0,z=a.find(M=>M.slug===n);return u.useLayoutEffect(()=>{const M=f.current,U=x.current,_=M?.closest(".composer-menu");if(!i||!M||!U||!_)return;const L=()=>{const E=_.getBoundingClientRect(),g=(_.closest(".t2c-card")||_.closest(".t2-chat-view"))?.getBoundingClientRect(),O=_.closest(".t2-chat-view")?.getBoundingClientRect(),X=bo(U),ee=g?jo(E.left,E.right,U.offsetWidth,g.left,g.right,X):"right";l(W=>W===ee?W:ee);const Y=vc(M.getBoundingClientRect().top,U.offsetHeight,E.top,E.bottom,O?.top??0,O?.bottom??window.innerHeight,X);p(W=>Math.abs(W-Y)<.5?W:Y)};L(),window.addEventListener("resize",L),window.addEventListener(ns,L);const B=new ResizeObserver(L);B.observe(_),B.observe(U);const J=_.closest(".t2c-card")||_.closest(".t2-chat-view");return J&&B.observe(J),()=>{window.removeEventListener("resize",L),window.removeEventListener(ns,L),B.disconnect()}},[i]),u.useEffect(()=>{const M=f.current?.closest(".composer-menu");if(!i||!M)return;const U=_=>{const L=_.target?.closest?.(".menu-item");L&&!f.current?.contains(L)&&c(!1)};return M.addEventListener("pointerover",U),M.addEventListener("focusin",U),()=>{M.removeEventListener("pointerover",U),M.removeEventListener("focusin",U)}},[i]),t.jsxs("div",{ref:f,className:"mode-normal-row",onPointerEnter:T,children:[t.jsxs("button",{className:`menu-item${A.normal.checked?" active":""}`,"data-normal-work":!0,disabled:A.normal.disabled,onClick:A.normal.run,children:[A.normal.icon,t.jsx("span",{className:"grow",children:A.normal.label}),A.normal.checked&&t.jsx(ft,{size:13})]}),T&&t.jsxs("button",{className:"menu-item mode-agent-trigger","data-agent-switch":!0,"aria-haspopup":"menu","aria-expanded":i,title:o("input.agentSwitch.section"),onFocus:T,onClick:T,children:[z&&t.jsx("span",{className:"mode-agent-name",children:z.name}),t.jsx(_t,{size:13})]}),i&&T&&t.jsxs("div",{ref:M=>{x.current=M,b.ref.current=M},className:`cm-sub ${r}`,"data-pane":"agents",role:"menu",style:{...b.style,"--cm-sub-top":`${m}px`},children:[t.jsx("div",{className:"menu-section",children:o("input.agentSwitch.section")}),A.agents.map(M=>t.jsxs("button",{role:"menuitemradio","aria-checked":!!M.checked,className:`menu-item${M.checked?" active":""}`,onClick:M.run,children:[M.icon,t.jsx("span",{className:"grow",children:M.label}),M.checked&&t.jsx(ft,{size:13})]},M.id))]})]})}function vd(e){const n=e.find(o=>o.active),a=(n?.filePath?n:void 0)??e.find(o=>o.front&&o.filePath)??e.find(o=>o.type==="amadeus-editor"&&o.filePath)??e.find(o=>o.filePath);return a?a.type==="amadeus-editor"?a.filePath?`note:${a.filePath}`:"note":a.filePath?`file:${a.filePath}`:"":""}const jn={color:"var(--accent-ink)",flexShrink:0};function yd({chip:e,onRemove:n,removeTitle:a,children:o}){return t.jsxs("span",{className:"attach-chip",title:e.token,"data-ref-kind":e.kind,children:[e.kind==="session"?t.jsx(cs,{size:13,style:jn}):e.kind==="folder"?t.jsx(is,{size:13,style:jn}):e.kind==="view"?t.jsx(Zn,{size:13,style:jn}):e.kind==="app"?t.jsx(yc,{size:13,style:jn}):t.jsx(ga,{size:13,style:jn}),t.jsx("span",{children:o??e.name}),n&&t.jsx("button",{type:"button",title:a,"aria-label":a,onClick:n,children:t.jsx(mt,{size:12})})]})}const Bs=e=>e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||e,no=e=>e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");function kd(e){if(/[\s"<>[\]]/.test(e)||e.includes("://"))return!1;const n=/^(~?\/|[A-Za-z]:[\\/])/.test(e),a=e.split(/[\\/]/).filter(Boolean);return n?a.length>=(/^[A-Za-z]:/.test(e)?3:2):a.length>=2&&/\.[A-Za-z0-9]{1,10}$/.test(a[a.length-1])}const xd=/^\[\[([^[\]\n]+)\]\]/,wd=/^"([^"\n]+)"/,bd=/^<forsion-view type="([^"\n]*)" title="([^"\n]*)" \/>/,jd=/^<forsion-app app="([^"\n]*)"[^>\n]* \/>/,Sd=/^[^\s]+/;function Nd(e,n){const a=e.slice(n);let o=xd.exec(a);if(o){const i=o[1],c=i.indexOf("|"),r=(c===-1?i:i.slice(0,c)).trim(),l=(c===-1?"":i.slice(c+1)).trim();return r?{ref:kc(r)?{token:o[0],name:l||"Chat",kind:"session",wiki:i}:{token:o[0],name:l||Bs(r).replace(/\.md$/i,""),kind:"note",wiki:i},end:n+o[0].length,strong:!0}:null}if(o=bd.exec(a),o)return{ref:{token:o[0],name:no(o[2]),kind:"view"},end:n+o[0].length,strong:!0};if(o=jd.exec(a),o)return{ref:{token:o[0],name:no(o[1]),kind:"app"},end:n+o[0].length,strong:!0};if(o=wd.exec(a),o){const i=o[1];return!/\s/.test(i)||!/[\\/]/.test(i)?null:{ref:{token:o[0],name:Bs(i),kind:"file"},end:n+o[0].length,strong:!0}}return o=Sd.exec(a),o&&kd(o[0])?{ref:{token:o[0],name:Bs(o[0]),kind:"file"},end:n+o[0].length,strong:!1}:null}function gh(e){if(!e)return null;const n=e.indexOf(`
|
|
12
|
+
`),a=n===-1?e:e.slice(0,n),o=[];let i=!0,c=0;for(;c<a.length;){const r=Nd(a,c);if(!r)return null;if(o.push(r.ref),i=i&&r.strong,c=r.end,c===a.length)break;if(a[c]!==" "||(c+=1,c===a.length))return null}return!o.length||n===-1&&!i?null:{refs:o,body:n===-1?"":e.slice(n+1)}}const Cd=({tier:e})=>{const n=(e||"free").toLowerCase();if(n==="free"||!n)return null;const a=n==="pro"?{background:"linear-gradient(135deg, #8B5CF6, #A855F7)",color:"#fff",border:"none"}:{background:"linear-gradient(135deg, #F59E0B, #F97316)",color:"#fff",border:"none"};return t.jsx("span",{className:"tier-badge",style:a,children:n})};xe({"ctx.pop.title":{zh:"上下文窗口",en:"Context window"},"ctx.pop.compact":{zh:"立即压缩",en:"Compact now"},"ctx.grp.tools":{zh:"工具与本轮",en:"Tools & this run"},"ctx.grp.system":{zh:"系统提示",en:"System prompt"},"ctx.sec.human":{zh:"协作说明",en:"Collaboration handbook"},"ctx.grp.memory":{zh:"记忆",en:"Memory"},"ctx.grp.project":{zh:"项目与资料",en:"Project & files"},"ctx.grp.skills":{zh:"技能",en:"Skills"},"ctx.grp.used":{zh:"已用",en:"Used"},"ctx.grp.buffer":{zh:"自动压缩预留",en:"Auto-compact buffer"},"ctx.grp.free":{zh:"剩余可用",en:"Free space"},"ctx.untilCompact":{zh:"还剩 {left} 触发自动压缩({n},{pct}%)",en:"{left} until auto-compact ({n}, {pct}%)"},"ctx.limit.title":{zh:"Forsion 额度",en:"Forsion usage limits"},"ctx.limit.resetsIn":{zh:"{h} 小时 {m} 分钟后重置",en:"Resets in {h} hr {m} min"},"ctx.limit.resetsAt":{zh:"{when} 重置",en:"Resets {when}"},"ctx.limit.used":{zh:"已用 {pct}%",en:"{pct}% used"}});const Qe=e=>e>=1e6?`${Math.floor(e/1e5)/10}M`:e>=1e3?`${Math.floor(e/100)/10}k`:String(e),so=new Set(["persona","harness","human","guidance","profile","project","agentFolder","memory","skills","environment","hooks","plan"]),ao="var(--model-tag-blue)",zd=[{id:"system",keys:["persona","guidance","environment","hooks","plan"],color:"var(--warning)"},{id:"memory",keys:["memory","profile","harness","human"],color:"var(--green)"},{id:"project",keys:["project","agentFolder"],color:"color-mix(in srgb, var(--accent-ink) 55%, transparent)"},{id:"skills",keys:["skills"],color:"color-mix(in srgb, var(--model-tag-blue) 45%, var(--green))"}];function Md(e,n,a){if(!n)return e>0?[{id:"used",label:a("ctx.grp.used"),tokens:e,color:ao}]:[];let o=Math.max(0,e);const i=m=>{const p=Math.min(o,Math.max(0,m));return o-=p,p},c=zd.map(m=>{const p=n.sections.filter(b=>m.keys.includes(b.k)||m.id==="system"&&!so.has(b.k)),f=p.reduce((b,A)=>b+A.tokens,0),x=i(f);return{id:m.id,label:a(`ctx.grp.${m.id}`),color:m.color,tokens:x,parts:x===f?p.map(b=>({label:so.has(b.k)?a(`ctx.sec.${b.k}`):b.k,tokens:b.tokens})):void 0}}),r={id:"messages",label:a("ctx.sec.history",{n:n.historyCount}),tokens:i(n.historyTokens),color:ao},l={id:"tools",label:a("ctx.grp.tools"),tokens:o,color:"var(--model-tag-purple)"};return[r,l,...c].filter(m=>m.tokens>0)}const Go=8*36e5,Ad=e=>864e5-(e+Go)%864e5;function Ed(e){const n=/^(\d{4})-(\d{2})-(\d{2})/.exec(e||"");return n?new Date(Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]))-Go):null}function Td({open:e,contextWindow:n,ctxTokens:a,sessionTokens:o,runCost:i,costLimit:c,ctxInfo:r,onCompact:l}){const{t:m}=ze(),[p,f]=u.useState(!1),x=a||0,b=_=>_/n*100,A=_=>`${Math.round(b(_)*10)/10}%`,T=Md(Math.min(x,n),r??null,m),z=r?.compactAt&&r.compactAt<n?r.compactAt:0,M=z?Math.max(0,n-Math.max(z,x)):0,U=Math.max(0,n-x-M);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:"t2c-cu-head","aria-expanded":p,onClick:()=>f(_=>!_),children:[t.jsx("span",{className:"t2c-cu-title",children:m("ctx.pop.title")}),t.jsxs("span",{className:"t2c-cu-num",children:[Qe(x)," / ",Qe(n)," tokens (",Math.min(100,Math.round(b(x))),"%)"]}),t.jsx(_t,{size:13,className:"t2c-cu-chev","aria-hidden":"true"})]}),t.jsxs("span",{className:"t2c-cu-bar","aria-hidden":"true",children:[T.map(_=>t.jsx("span",{style:{width:`${b(_.tokens)}%`,background:_.color}},_.id)),M>0&&t.jsx("span",{className:"t2c-cu-buffer",style:{width:`${b(M)}%`}})]}),r&&r.ctxWindowSource!=="override"&&(r.ctxWindowMax??0)>r.ctxWindow&&t.jsx("span",{className:"t2c-ctxinfo-src",children:m("ctx.windowCapped",{max:Qe(r.ctxWindowMax),n:Qe(r.ctxWindow)})}),p&&t.jsxs("span",{className:"t2c-cu-detail",children:[t.jsxs("span",{className:"t2c-cu-legend",children:[T.map(_=>t.jsxs(u.Fragment,{children:[t.jsxs("span",{className:"t2c-cu-row",children:[t.jsx("i",{style:{background:_.color}}),t.jsx("span",{children:_.label}),t.jsx("span",{children:Qe(_.tokens)}),t.jsx("span",{children:A(_.tokens)})]}),_.parts&&_.parts.length>1&&_.parts.map(L=>t.jsxs("span",{className:"t2c-cu-row is-sub",children:[t.jsx("i",{}),t.jsx("span",{children:L.label}),t.jsxs("span",{children:["~",Qe(L.tokens)]}),t.jsx("span",{})]},L.label))]},_.id)),M>0&&t.jsxs("span",{className:"t2c-cu-row",children:[t.jsx("i",{className:"t2c-cu-buffer"}),t.jsx("span",{children:m("ctx.grp.buffer")}),t.jsx("span",{children:Qe(M)}),t.jsx("span",{children:A(M)})]}),t.jsxs("span",{className:"t2c-cu-row",children:[t.jsx("i",{className:"is-free"}),t.jsx("span",{children:m("ctx.grp.free")}),t.jsx("span",{children:Qe(U)}),t.jsx("span",{children:A(U)})]})]}),r&&t.jsx("span",{className:"t2c-ctxinfo-src",children:m(`ctx.windowSource.${["override","model","learned","family","default"].includes(r.ctxWindowSource)?r.ctxWindowSource:"default"}`)}),!!o&&o>0&&t.jsx("span",{className:"t2c-ctxinfo-src",children:m("input.sessionTokens",{n:Qe(o)})}),r&&t.jsxs("span",{className:"t2c-ctxinfo-files",children:[t.jsxs("span",{className:"t2c-ctxinfo-label",children:[m("ctx.files.label"),r.filesTruncated?` ${m("ctx.files.truncated")}`:""]}),r.files.length>0?r.files.map(_=>t.jsx("span",{className:"t2c-ctxinfo-file",title:_,children:_.split(/[/\\]/).slice(-2).join("/")},_)):t.jsx("span",{className:"t2c-ctxinfo-file dim",children:m("ctx.files.none")})]})]}),t.jsxs("span",{className:"t2c-cu-foot",children:[z>0&&t.jsx("span",{children:m("ctx.untilCompact",{left:Qe(Math.max(0,z-x)),n:Qe(z),pct:Math.round(b(z))})}),l&&t.jsx("button",{type:"button",className:"t2c-ctxring-compact",onClick:l,title:m("input.slash.compact"),children:m("ctx.pop.compact")})]}),i!=null&&c!=null&&c>0&&t.jsx("span",{className:"t2c-ctxinfo-src","data-warn":i>=c*.8||void 0,children:m("input.runCost",{used:Math.round(i).toLocaleString(),limit:c.toLocaleString()})}),t.jsx(Rd,{open:e})]})}function Rd({open:e}){const{t:n,locale:a}=ze(),o=$(b=>b.authInfo?.loggedIn&&b.authInfo.tokenValid!==!1?`${b.authInfo.accountId??""}:${b.authInfo.username??""}`:null),i=o!==null&&!!window.tangu?.accountQuota,c=$(b=>b.authInfo?.membershipTier),[r,l]=u.useState(null),m=u.useRef(0);if(u.useEffect(()=>xc(b=>{m.current++,l(b)}),[]),u.useEffect(()=>{l(null)},[o]),u.useEffect(()=>{if(!i||!e)return;let b=!0;const A=++m.current;return window.tangu.accountQuota().then(T=>{!b||A!==m.current||T?.status!==200||!T.json||(l(T.json),wc(T.json))}).catch(()=>{}),()=>{b=!1}},[e,o,i]),!i||!r)return null;const p=Ad(Date.now()),f=Ed(r.weeklyResetAt),x=[{key:"daily",label:n("sidebar.account.menu.daily"),limit:Number(r.dailyLimit),rem:Mi(r.dailyLimit,r.dailyRemaining,r.dailyPercent),reset:n("ctx.limit.resetsIn",{h:Math.floor(p/36e5),m:Math.floor(p%36e5/6e4)})},{key:"weekly",label:n("sidebar.account.menu.weekly"),limit:Number(r.weeklyLimit),rem:Mi(r.weeklyLimit,r.weeklyRemaining,r.weeklyPercent),reset:f?n("ctx.limit.resetsAt",{when:bc(f,{locale:a})}):""}].filter(b=>b.limit<0||b.rem!==null);return x.length?t.jsxs("span",{className:"t2c-cu-limits",children:[t.jsxs("span",{className:"t2c-cu-limits-title",children:[n("ctx.limit.title"),t.jsx(Cd,{tier:c})]}),x.map(b=>t.jsxs("span",{className:"t2c-cu-limit","data-limit":b.key,children:[t.jsxs("span",{className:"t2c-cu-limit-line",children:[t.jsx("span",{className:"t2c-cu-limit-name",children:b.label}),b.rem!==null&&t.jsx("span",{className:"t2c-cu-limit-reset",children:b.reset}),t.jsx("span",{children:b.rem===null?n("sidebar.account.menu.unlimited"):n("ctx.limit.used",{pct:Math.round(100-b.rem)})})]}),b.rem!==null&&t.jsx("span",{className:"t2c-cu-bar","data-warn":b.rem<=15||void 0,"aria-hidden":"true",children:t.jsx("span",{style:{width:`${100-b.rem}%`}})})]},b.key))]}):null}xe({"livecall.start":{zh:"语音通话",en:"Voice call"},"livecall.return":{zh:"回到通话",en:"Back to the call"},"livecall.localOnly":{zh:"语音通话只能在本机的会话里用",en:"Voice calls only work in sessions on this computer"},"livecall.cloudOnly":{zh:"这个会话在你的电脑上,语音通话暂时只能在云端的会话里用",en:"This session lives on your computer. For now, voice calls only work in cloud sessions"},"livecall.typeHint":{zh:"通话中:打的字会直接送进电话",en:"In a call: typed messages go straight into the call"},"livecall.textFallback":{zh:"通话没接上,这条改发给 Tangu 了",en:"The call did not pick this up, so it was sent to Tangu instead"}});xe({"input.modeSheetTitle":{zh:"模式",en:"Mode"},"input.hubSheetTitle":{zh:"模型与模式",en:"Model and mode"},"input.agentSwitch.section":{zh:"切换 Agent",en:"Switch agent"},"input.mention.projectNote":{zh:"派往项目 · 在该项目新建会话开工",en:"Dispatch to project · starts a new session there"},"input.normalWork":{zh:"普通模式",en:"Normal mode"},"input.presetChat":{zh:"Chat",en:"Chat"},"input.presetWork":{zh:"Work",en:"Work"},"input.presetLocked":{zh:"模式在创建会话时确定;换模式请新建会话",en:"Mode is fixed when the session is created; start a new session to change it"},"input.approvalSection.team":{zh:"团队审批档 · 改动对全队生效",en:"Approval mode for the whole team"},"input.planModeTeamOff":{zh:"团队模式下不可用",en:"Not available in team mode"},"composer2.exportRoleUser":{zh:"我",en:"Me"},"composer2.listSep":{zh:"、",en:", "}});const Id=8e3,xa="input.tip.steer",io=[xa,"input.tip.switchChat","input.tip.quote","input.tip.dropFiles","input.tip.wikiRef","input.tip.dragSession","input.tip.branch","input.tip.newTab","input.tip.palette","input.tip.quickFind","input.tip.findInChat","input.tip.toc"],$d=[xa,"input.tip.wikiRef"];xe({"input.tip":{zh:"小贴士:{tip}",en:"Tip: {tip}"},"input.runningPlaceholder":{zh:"运行中,可继续输入…",en:"Working… You can keep typing"},"input.steer.queuedHint":{zh:"排队项在本轮结束后依次执行 · ↑ 取回编辑",en:"Queued items run in order after this turn · ↑ to recall"},"input.tip.steer":{zh:"运行中也能继续发消息,会在下一步交给 Agent",en:"You can send while it runs: the agent reads it at the next step"},"input.tip.switchChat":{zh:"可以先切去别的会话,运行不会中断,侧栏圆点标出运行中",en:"Switch chats meanwhile; this run keeps going, marked by a sidebar dot"},"input.tip.quote":{zh:"划选回复里的文字,点「引用」即可带进下一条消息",en:"Select text in a reply and click Quote to cite it in your next message"},"input.tip.dropFiles":{zh:"文件可拖到聊天区任意位置,截图可直接粘贴进输入框",en:"Drop files anywhere in the chat, or paste a screenshot into the box"},"input.tip.wikiRef":{zh:"输入 [[ 可引用历史会话,本机项目里还能引用笔记和文件",en:"Type [[ to reference past chats, or notes and files in local projects"},"input.tip.dragSession":{zh:"把侧栏的会话拖进对话区,即可挂为引用随消息发送",en:"Drag a chat from the sidebar into the conversation to cite it"},"input.tip.branch":{zh:"悬停已完成的回复,点分支图标即可从此处开出新会话",en:"Hover a finished reply and click the branch icon to fork a new chat"},"input.tip.newTab":{zh:"⌘/Ctrl 点击侧栏里的会话,会在新标签页打开",en:"⌘/Ctrl-click a session in the sidebar to open it in a new tab"},"input.tip.palette":{zh:"按 ⌘/Ctrl+K 打开命令面板,搜索并执行命令",en:"Press ⌘/Ctrl+K to open the command palette and run commands"},"input.tip.quickFind":{zh:"⌘/Ctrl+P 快速查找,按名称跳到会话",en:"⌘/Ctrl+P opens quick find: jump to a session by name"},"input.tip.findInChat":{zh:"⌘/Ctrl+F 在当前对话里查找文字",en:"Press ⌘/Ctrl+F to find text in the current conversation"},"input.tip.toc":{zh:"悬停对话左侧的短横线展开目录,点击即可跳回任意一轮提问",en:"Hover the bars on the chat's left edge, then click to jump to a turn"}});const qs=5*1024*1024,oo=15e4,Hs=25*1024*1024,Vs=[{id:"readonly",Icon:Jl,key:"input.approval.readonly",desc:"input.approval.readonlyDesc"},{id:"auto-edit",Icon:Ac,key:"input.approval.autoEdit",desc:"input.approval.autoEditDesc"},{id:"full-auto",Icon:Ec,key:"input.approval.fullAuto",desc:"input.approval.fullAutoDesc",danger:!0},{id:"custom",Icon:Tc,key:"input.approval.custom",desc:"input.approval.customDesc"}],En=e=>e.split(/[\\/]/).pop()||e,Ld=".t2-chat-view";function Pd(e,n,a){const o=e.closest(Ld)??e,i=p=>Array.from(p.dataTransfer?.types??[]).includes("Files"),c=p=>{o===e?a(p):o.toggleAttribute("data-filedrop",p)},r=p=>{i(p)&&(p.preventDefault(),p.dataTransfer&&(p.dataTransfer.dropEffect="copy"),c(!0))},l=p=>{o.contains(p.relatedTarget)||c(!1)},m=p=>{i(p)&&(p.preventDefault(),c(!1),p.dataTransfer?.files?.length&&n(p.dataTransfer.files))};return o.addEventListener("dragover",r),o.addEventListener("dragleave",l),o.addEventListener("drop",m),()=>{o.removeEventListener("dragover",r),o.removeEventListener("dragleave",l),o.removeEventListener("drop",m),c(!1)}}const Dt=e=>({token:/\s/.test(e)?`"${e}"`:e,name:En(e),kind:"file"}),Dd=e=>({token:/\s/.test(e)?`"${e}"`:e,name:En(e),kind:"folder"}),_d=(e,n)=>{const a=o=>String(o).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");return{token:`<forsion-view type="${a(e)}" title="${a(n)}" />`,name:n,kind:"view"}},Fd=e=>{const n=a=>String(a).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\n/g," ");return{token:`<forsion-app app="${n(e.app)}" bundleId="${n(e.bundleId||"")}" pid="${e.pid}" windowId="${e.windowId}" title="${n(e.title)}" />`,name:e.app,kind:"app"}};function Ks(e,n){const a=So(e,n).trim();return e.kind==="session"?{token:a,name:e.title||"Chat",kind:"session"}:e.kind==="note"?{token:a,name:En(e.path),kind:"note"}:Dt(e.path)}function Od(e,n,a,o){if(a){if(n>=e.length)return null;const c=n+1;return{pos:c,val:e[e.length-c]}}if(n===0)return null;const i=n-1;return{pos:i,val:i===0?o:e[e.length-i]}}function Wd(e,n,a){return/^\/refine(\s|$)/i.test(a)&&(a="/refine"+a.slice(7)),/^\/refine(\s|$)/.test(a)&&(e||n)?`${a}
|
|
13
|
+
|
|
14
|
+
${e}${n}`.trimEnd():e+n+a}function Ud(e,n=200){return e>0?`${Math.min(e,n)}px`:"auto"}function Bd(e,n){const a=/(?:^|\s)(\/\S*)$/.exec(e.slice(0,n));return a?{start:n-a[1].length,token:a[1]}:null}const vh=({sessionId:e,advisory:n,approvalTray:a,autoFocus:o,disabled:i,disabledPlaceholder:c,running:r,execConfig:l,teamApproval:m,models:p,modelsResponse:f,modelId:x,onModelChange:b,engines:A,engineId:T,engineModels:z,engineModelId:M,onEngineModelChange:U,engineCommands:_,thinkingLevel:L,onThinkingChange:B,ultra:J,defaultModelIds:E,onDefaultModelChange:g,onContextWindowChange:O,maxIterations:X,onMaxIterationsChange:ee,verifyCommand:Y,onVerifyCommandChange:W,preset:C,onPresetChange:P,planMode:H,onPlanModeChange:Z,voiceMode:R,onVoiceModeChange:Q,liveOwner:v,liveSessionKey:F,prepareLiveSession:ne,skills:we,groupChat:be,groupAgents:je,groupTempAgents:Pe,onGroupChange:Te,onAddAgent:Me,onNormalWork:Ve,agents:$e,onAgentSwitch:De,currentAgentSlug:Ke,mentionProjects:_e,onNewSession:Ye,onBranch:vt,onOpenSettings:Ct,onExecConfigChange:j,onSend:K,onStop:q,quotedText:ae,onClearQuote:Ne,onBtw:Ge,contextWindow:zt,ctxTokens:tt,sessionTokens:Xe,runCost:Le,costLimit:Fe,ctxInfo:pe,onCompact:Je,seedText:Ot,onSeedConsumed:h,seedShare:D,takeSeedShare:k,appendRefs:V,onAppendRefsConsumed:oe,autoRefFromMain:se,appRef:Re,sentHistory:ct,pendingSteer:We,onCancelSteer:us,onWithdrawSteer:ce,onSteerNow:yt})=>{const{t:N,locale:ds}=ze(),mr=$(s=>s.activeId),fe=e===void 0?mr:e,hr=u.useId(),Oe=e===void 0?`preview:${hr}`:e??Ai,ja=u.useRef(Oe);ja.current=Oe;const[ue,he]=Nt(Oe,"text"),[Sa,Na]=u.useState(0),[ms]=u.useState(()=>!!window.tangu?.mobile||!!window.matchMedia?.("(hover: none)").matches),Ca=(ms?$d:io).filter(s=>!T||s!==xa),[pr,hs]=u.useState(!1),[Mt,fr]=u.useState(!1),[ps,za]=u.useState(!1);u.useEffect(()=>{if(!r||Mt)return;Na(Math.floor(Math.random()*io.length));let s=0;const d=window.setInterval(()=>{hs(!0),s=window.setTimeout(()=>{Na(y=>y+1),hs(!1)},300)},Id);return()=>{window.clearInterval(d),window.clearTimeout(s),hs(!1),za(!1)}},[r,Mt]);const[fs,gr]=u.useState([]),[Wt,Ln]=Nt(Oe,"attachments"),[Ut,gs]=Nt(Oe,"wsFiles"),[cn,Ma]=Nt(Oe,"refChips"),[vs,vr]=u.useState(null),Bt=s=>Ma(d=>{const y=new Set(d.map(S=>S.token)),w=[];for(const S of s)y.has(S.token)||(y.add(S.token),w.push(S));return w.length?[...d,...w]:d}),[qt,Aa]=Nt(Oe,"pinnedSkills"),[Ea,Ae]=u.useState(null),[Ta,Ue]=u.useState(0),[ln,un]=u.useState(null),[Ra,Ia]=u.useState(!1),$a=u.useRef(null),[Ee,Ze]=u.useState(null),[yr,dn]=u.useState(!1),[Be,lt]=u.useState(0),[La,Pn]=u.useState(0),[Pa,Da]=u.useState(!1),[kr,_a]=Nt(Oe,"mentionedSlug"),[Fa,Oa]=Nt(Oe,"mentionAgents"),[Wa,Dn]=u.useState(0),[Ua,Ba]=u.useState(!1),[qa,Ha]=u.useState(null),ys=u.useRef(""),[xr,wr]=u.useState(!1),[At,Ht]=u.useState(0),ks=u.useRef(""),Va=u.useRef(At);Va.current=At,u.useLayoutEffect(()=>(Ht(0),lt(0),un(null),()=>{Va.current>0&&jc(Oe,"text",ks.current)}),[Oe]);const ve=u.useRef(null),Et=u.useRef(null);u.useLayoutEffect(()=>{const s=Et.current;if(!s)return;const d=new ResizeObserver(([y])=>fr(y.contentRect.width<=360));return d.observe(s),()=>d.disconnect()},[]);const mn=u.useMemo(()=>{const s=new Map(to("desktop").map(d=>[d.name,d]));return d=>{const y=s.get(d);return y?ds==="en"?y.en:y.zh:d}},[ds]);u.useEffect(()=>{let s=!0;return Sc(pt()).then(d=>{s&&gr(d)}),()=>{s=!1}},[]);const br=async()=>{const s=$.getState(),d=fe,S=([...d?s.messagesBySession[d]||[]:[]].reverse().find(I=>I.role==="assistant")?.content||"").trim();if(!S){s.toast(N("input.slash.nothingToCopy"),!0);return}try{await navigator.clipboard.writeText(S),s.toast(N("input.slash.copied"))}catch{s.toast(N("input.slash.nothingToCopy"),!0)}},jr=async()=>{const s=$.getState(),d=fe;if(![...d?s.messagesBySession[d]||[]:[]].reverse().find(S=>S.role==="user")){s.toast(N("input.slash.nothingToRetry"),!0);return}await s.retry(d)},Sr=async()=>{const s=$.getState(),d=fe;if(!d){s.toast(N("input.slash.nothingToExport"),!0);return}const y=s.sessions.find(ge=>ge.id===d);let w=[];try{w=(await Vc(Ti(d),d)).messages}catch{}if(w.length||(w=s.messagesBySession[d]||[]),!w.length){s.toast(N("input.slash.nothingToExport"),!0);return}const S=y?.title||"Tangu Session",I=["---",`id: ${d}`,`title: ${JSON.stringify(S)}`,...y?.summary?[`summary: ${JSON.stringify(y.summary)}`]:[],...y?.model_id?[`model: ${y.model_id}`]:[],`exported_at: ${new Date().toISOString()}`,"---","",`# ${S}`,""];for(const ge of w){const Ce=ge.role==="model"?"assistant":ge.role;if(Ce!=="user"&&Ce!=="assistant")continue;const kn=(ge.content||"").trim(),xn=Array.isArray(ge.tool_calls)?ge.tool_calls:[];if(!kn&&!xn.length)continue;I.push(Ce==="user"?`## ${N("composer2.exportRoleUser")}`:"## Tangu",""),kn&&I.push(kn,"");for(const Pt of xn){const Xt=Pt?.function?.name||Pt?.name||"tool";let qe="";try{qe=String(typeof Pt?.function?.arguments=="string"?Pt.function.arguments:JSON.stringify(Pt?.function?.arguments??""))}catch{qe=""}qe=qe.replace(/\s+/g," ").trim(),I.push(`> 🔧 \`${Xt}\`${qe&&qe!=="{}"?` ${qe.length>200?qe.slice(0,200)+"…":qe}`:""}`)}xn.length&&I.push("");const Lt=Array.isArray(ge.attachments)?ge.attachments:[];Lt.length&&I.push(`> 📎 ${Lt.length} attachment(s)`,"")}const G=new Blob([I.join(`
|
|
15
|
+
`)],{type:"text/markdown"}),re=document.createElement("a");re.href=URL.createObjectURL(G),re.download=`tangu-${String(d).slice(0,8)}.md`,re.click(),setTimeout(()=>URL.revokeObjectURL(re.href),1e3)},de=Su(s=>{he(d=>d?d.replace(/\s+$/,"")+" "+s:s),Ht(0),requestAnimationFrame(ie)}),Ka=de.recording||de.busy,xs=u.useRef(!1),Nr=()=>{xs.current=!0,de.toggle()};u.useEffect(()=>{!xs.current||de.recording||de.busy||(xs.current=!1,ue.trim()&&On())},[de.recording,de.busy]);const Cr=Nc(fe),_n=v??e===null,Ya=_u(),Ga=$(s=>s.modelsResp?.realtimeModel??null),Xa=$(s=>!!s.authInfo?.loggedIn&&s.authInfo.tokenValid!==!1)&&!!window.tangu?.forsionLogin,{model:Ja,voice:zr}=u.useMemo(()=>Ru(Ya,{model:Ga,signedIn:Xa}),[Ya,Ga,Xa]),[ws,Za]=u.useState(!1),[Qa,ei]=u.useState(""),ti=!!window.tangu?.mobile,Mr=u.useSyncExternalStore(Uu,qo),hn=!!fe&&Mr===fe,bs=Cc(s=>(e?s.bySession[e]:void 0)||""),js=!!bs&&!ue&&!r&&!i&&!hn&&!ms;u.useEffect(()=>{r&&e&&Is(e)},[r,e]),u.useEffect(()=>{if(_n)return Ho(s=>{if(s.kind==="activity"){$.getState().pollSession(s.sessionId);return}if(s.kind==="transcript"){const d=()=>{const S=$.getState().messagesBySession[s.sessionId]?.find(I=>I.id===s.messageId);return S?(S.content!==s.text&&$.setState(I=>({messagesBySession:{...I.messagesBySession,[s.sessionId]:(I.messagesBySession[s.sessionId]||[]).map(G=>G.id===s.messageId?{...G,content:s.text}:G)}})),!0):!1};if(d())return;const y=$.subscribe(()=>{d()&&(y(),clearTimeout(w))}),w=setTimeout(y,3e4);return}s.kind==="effort"&&$.setState(d=>d.configBySession[s.sessionId]?{configBySession:{...d.configBySession,[s.sessionId]:{...d.configBySession[s.sessionId],thinkingLevel:s.level,...s.level!=="max"?{ultra:void 0}:{}}}}:{})})},[_n]);const Ar=async()=>{if(!ws){Za(!0),ei("");try{let s=F!==void 0?F:fe;if(!s){const I=$.getState().activeId;s=ne?await ne():await $.getState().newSession().then(()=>$.getState().activeId),s===I&&(s=null)}if(!s)return;if(Ti(s).key!=="home"){ei(N(ti?"livecall.cloudOnly":"livecall.localOnly"));return}const{modelId:y,agentConfig:w}=$.getState().voiceRunParams(s),S={type:"voice-call",params:{sessionId:s,model:Ja,voice:zr,title:N("livecall.title"),agentSlug:w.agentSlug,run:{model_id:y,agent_config:w}}};window.tangu?.openMini?window.tangu.openMini({view:S,mainView:{type:"chat",params:{sessionId:s}},title:N("livecall.title")}):Ou(S.params)}finally{Za(!1)}}},me=l.execMode==="host",ye=C==="chat",pn=T?void 0:$e?.find(s=>s.slug===Ke),fn=l.approvalMode||pn?.approvalMode||"auto-edit",Tt=L||(be?void 0:pn?.thinkingLevel)||void 0,kt=me&&!ye&&!T&&!be,Vt=kt&&!!J&&Tt==="max",{window:Rt,stale:Er}=Bl({ctxInfo:pe,contextWindow:zt,running:r,ultra:Vt,model:f?.models.find(s=>s.id===x),engineUncapped:f?.ultraUncapped}),Ss=Er&&pe?{...pe,ctxWindow:Rt||pe.ctxWindow,compactAt:void 0}:pe,[Tr,ni]=u.useState(!1),gn=(s,d)=>B?d===!0&&!Vt&&!ed()?(ni(!0),!1):(B(s,d),!0):!1,si=an(Ee==="mode",{boundary:".t2-chat-view"}),ai=an(Ee==="ctx",{boundary:".t2-chat-view"});u.useEffect(()=>{if(!Ee)return;const s=y=>{y.target?.closest?.("[data-cmenu], [data-keep-menus]")||Ze(null)},d=y=>{y.key==="Escape"&&!document.querySelector("[data-keep-menus]")&&Ze(null)};return document.addEventListener("mousedown",s),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",s),document.removeEventListener("keydown",d)}},[Ee]);const ie=()=>{const s=ve.current;if(s){if(!s.value){s.style.height="";return}s.style.height="auto",s.style.height=Ud(s.scrollHeight)}};u.useEffect(()=>{const s=ve.current;if(!s||typeof ResizeObserver>"u")return;let d=s.clientWidth;const y=new ResizeObserver(()=>{s.clientWidth!==d&&(d=s.clientWidth,ie())});return y.observe(s),()=>y.disconnect()},[]),u.useLayoutEffect(ie,[ue]),u.useLayoutEffect(()=>{const s=ve.current;r&&!Mt&&!ps&&s&&!s.value&&s.scrollHeight>s.clientHeight+2&&za(!0)},[r,Sa,ds,ps,ue,Mt]);const ii=s=>{s&&At===0&&(ks.current=ue);const d=Od(ct||[],At,s,ks.current);d&&(Ht(d.pos),he(d.val),requestAnimationFrame(()=>{const y=ve.current;y&&(y.focus(),y.selectionStart=y.selectionEnd=d.val.length,lt(d.val.length)),ie()}))};u.useEffect(()=>{Ot&&(he(Ot),h?.(),requestAnimationFrame(()=>{ve.current?.focus(),ie()}))},[Ot]),u.useEffect(()=>{ae&&requestAnimationFrame(()=>ve.current?.focus())},[ae]),u.useEffect(()=>{V?.refs.length&&(Bt(V.refs.map(s=>Ks(s,jt||""))),oe?.(),requestAnimationFrame(()=>{ve.current?.focus(),ie()}))},[V?.seq]);const nt=s=>{const d=$a.current,y=d?.start??0,w=d?.end??1/0;he(I=>I.slice(0,y)+s+I.slice(w));const S=y+s.length;return requestAnimationFrame(()=>{const I=ve.current;I&&(!$.getState().feedbackOpen&&!document.querySelector("[data-keep-menus]")&&I.focus(),I.selectionStart=I.selectionEnd=S,lt(S)),ie()}),y},oi=u.useMemo(()=>{const s=()=>{nt(""),un(null)},d=$.getState,y={"/stop":r?()=>{q(),s()}:void 0,"/new":Ye?()=>{Ye(),s()}:void 0,"/branch":vt?()=>{vt(),s()}:void 0,"/compact":Je?()=>{Je(),s()}:void 0,"/plan":Z&&!ye?()=>{Z(!H),s()}:void 0,"/chat":P?()=>{P("chat"),s()}:()=>{d().toast(N("input.presetLocked")),s()},"/work":P?()=>{P("work"),s()}:()=>{d().toast(N("input.presetLocked")),s()},"/voice":Q?()=>{Q(!R),s()}:void 0,"/model":b&&p?.length?()=>{un({start:nt("/model ")}),Ue(0)}:void 0,"/loop":ee?()=>{nt("/loop "),Ue(0)}:void 0,"/verify":me&&W?()=>{nt("/verify "),Ue(0)}:void 0,"/think":B?()=>{nt("/think"),Ue(0)}:void 0,"/refine":me?()=>{nt("/refine "),Ue(0)}:void 0,"/approval":()=>{Ze("mode"),s()},"/help":()=>{d().openSettings("about"),s()},"/feedback":window.tangu?.submitFeedback?()=>{d().openFeedback()&&s()}:void 0,"/btw":Ge?()=>{nt("/btw "),Ue(0)}:void 0,"/skills":()=>{d().openSettings("skills"),s()},"/tools":()=>{d().openSettings("agents"),s()},"/agents":()=>{d().openSettings("agents"),s()},"/agent":()=>{d().openSettings("agents"),s()},"/mcp":()=>{d().openSettings("mcp"),s()},"/plugins":()=>{d().openSettings("plugins"),s()},"/memory":()=>{d().openSettings("forsion/f-sync"),s()},"/config":()=>{d().openSettings("general"),s()},"/login":window.tangu?.forsionLogin?()=>{d().openSettings("forsion"),s()}:void 0,"/historian":()=>{d().setActiveSpecial("agents"),s()},"/muse":()=>{d().setActiveSpecial("agents"),s()},"/groupchat":Te&&!ye?()=>{dn(!0),s()}:void 0,"/sessions":()=>{d().setActiveId(null),s()},"/cost":()=>{d().pushNotice(`${(Xe??0).toLocaleString()} tokens · ${N("input.ctxLabel")} ${(tt??0).toLocaleString()}/${(Rt??0).toLocaleString()}`+(Le!=null&&Fe!=null&&Fe>0?` · ${N("input.runCost",{used:Math.round(Le).toLocaleString(),limit:Fe.toLocaleString()})}`:"")),s()},"/status":()=>{d().pushNotice([`${N("input.slash.status")}`,`model=${x||"-"}`,`think=${Tt||"medium"}${pe?.thinkingRequested===(Tt||"medium")&&pe.thinkingEffective&&pe.thinkingEffective!==pe.thinkingRequested?`→${pe.thinkingEffective}`:""}`,`approval=${l.approvalMode||pn?.approvalMode||(l.execMode==="host"?"auto-edit":"full-auto")} (${l.approvalMode?"session":pn?.approvalMode?"agent":"default"})`,`cwd=${l.cwd||"-"}`,`loop=${X||pe?.maxIterations||90} (${X?"session":pe?.maxIterationsSource||"default"})`,`verify=${Y||"-"}`,`tokens=${(Xe??0).toLocaleString()}`,`cost=${Le!=null?Math.round(Le).toLocaleString():"-"}${Fe!=null&&Fe>0?`/${Fe.toLocaleString()}`:""}`].join(`
|
|
16
|
+
`)),s()},"/copy":()=>{br(),s()},"/retry":()=>{jr(),s()},"/export":()=>{Sr(),s()}},w=[];if(r){const S=y["/stop"];S&&w.push({cmd:"/stop",desc:mn("/stop"),run:S})}if(T){Ye&&w.push({cmd:"/new",desc:mn("/new"),run:()=>{Ye(),s()}}),y["/feedback"]&&w.push({cmd:"/feedback",desc:mn("/feedback"),run:y["/feedback"]});for(const S of _||[])S.name.replace(/^\//,"").toLowerCase()==="feedback"&&y["/feedback"]||w.push({cmd:`/${S.name}`,desc:S.hint?`${S.description} · ${S.hint}`:S.description,run:()=>{nt(`/${S.name} `),Ue(0)}});return w}if(B){const S=T?void 0:p?.find(I=>I.id===x)?.thinkingLevels;for(const I of Yn){const G=!!S&&!S.includes(I);w.push({cmd:`/think ${I}`,desc:`${N("input.slash.thinkDesc",{level:Qs(I,N)})}${G?` ${N("pill.thinkUnsupported")}`:""}${!Vt&&Tt===I?N("input.slash.current"):""}`,run:()=>{gn(I,kt?!1:void 0),s()}})}kt&&w.push({cmd:"/think ultra",desc:`${N("pill.ultraTitle")}${Vt?N("input.slash.current"):""}`,run:()=>{gn("max",!0),s()}})}for(const S of to("desktop")){if(S.name==="/stop")continue;const I=y[S.name];I&&w.push({cmd:S.arg?`${S.name} ${S.arg}`:S.name,desc:mn(S.name),run:I})}for(const S of fs)w.push({cmd:S.argHint?`/${S.name} ${S.argHint}`:`/${S.name}`,desc:S.description,run:()=>{nt(`/${S.name} `),Ue(0)}});if(we?.length)for(const S of we)w.push({cmd:`/skill:${S.id}`,desc:N("input.slash.skillUse",{name:S.name}),run:()=>{Aa(I=>I.some(G=>G.id===S.id)?I:[...I,S]),s()}});return w},[r,q,H,R,Q,Tt,X,ee,Y,W,p,x,we,Z,B,b,Ye,vt,Je,Te,ye,P,T,_,fs,mn,l,pn,Xe,tt,Rt,Le,Fe,pe,!!Ge,kt,Vt]),st=u.useMemo(()=>{if(i||Ra)return null;const s=ue.slice(0,Be);if(ln&&s.startsWith("/model ",ln.start))return{start:ln.start,token:s.slice(ln.start),sub:"model"};const d=Bd(ue,Be);return d?{...d,sub:null}:null},[ue,Be,i,Ra,ln]);$a.current=st?{start:st.start,end:Be}:null;const xt=u.useMemo(()=>{if(!st)return[];if(st.sub==="model"){const y=st.token.slice(7).toLowerCase();return(p||[]).filter(w=>!y||w.id.toLowerCase().includes(y)||w.name.toLowerCase().includes(y)).slice(0,12).map(w=>({cmd:w.id===x?`● ${w.name}`:w.name,desc:`${w.source==="direct"?N("input.directPrefix"):""}${w.provider} · ${w.id}`,run:()=>{b?.(w.id),nt(""),un(null)}}))}const s=st.token.toLowerCase(),d=s.startsWith("/th");return oi.filter(y=>(d||!y.cmd.startsWith("/think "))&&(y.cmd.toLowerCase().startsWith(s)||s.length>1&&y.desc.toLowerCase().includes(s.slice(1)))).slice(0,10)},[st,oi,p,x]),Kt=!!st&&xt.length>0;u.useEffect(()=>{Ue(0)},[st?.start,st?.token]);const vn=!!be&&(je?.length||0)>=2,[Rr,Ir]=Nt(Oe,"mentionedProjects"),yn=!!_e?.length,ri=u.useMemo(()=>{if(yn)return(_e||[]).map(y=>({slug:y.path,name:y.name,description:y.path}));if(!vn)return $e||[];const s=($e||[]).filter(y=>je.includes(y.slug)),d=new Set(s.map(y=>y.slug));return[...s,...(Pe||[]).filter(y=>!d.has(y.slug))]},[vn,$e,je,Pe,yn,_e]),wt=u.useMemo(()=>{if(i||Kt||Pa)return null;const s=/(?:^|\s)@([^\s@]*)$/.exec(ue.slice(0,Be));return s?{query:s[1],start:Be-s[1].length-1}:null},[ue,Be,i,Kt,Pa]),bt=u.useMemo(()=>{if(!wt)return[];const s=wt.query.toLowerCase();return ri.filter(d=>!s||d.name.toLowerCase().includes(s)||d.slug.toLowerCase().includes(s)).slice(0,10)},[wt,ri]),ci=!!wt&&bt.length>0;u.useEffect(()=>{Pn(0)},[wt?.start,wt?.query]);const li=s=>{if(!wt)return;const d=ue.slice(0,wt.start),y=`@${s.name} `,w=d+y+ue.slice(Be);he(w),yn?Ir(I=>I.some(G=>G.path===s.slug)?I:[...I,{name:s.name,path:s.slug}]):vn?_a(s.slug):Oa(I=>I.includes(s.slug)?I:[...I,s.slug]);const S=d.length+y.length;requestAnimationFrame(()=>{const I=ve.current;I&&(I.focus(),I.selectionStart=I.selectionEnd=S,lt(S)),ie()})},at=u.useMemo(()=>{if(i||Kt||Ua)return null;const s=/\[\[([^\]\n]*)$/.exec(ue.slice(0,Be));return s?{query:s[1],start:Be-s[1].length-2}:null},[ue,Be,i,Kt,Ua]);u.useEffect(()=>{if(!at||!me)return;window.amadeus&&zc();const s=l.cwd;if(!s||ys.current===s)return;ys.current=s,Ha(null);const d=new Set(["node_modules","dist","build","out","target",".git",".venv","venv","__pycache__"]);(async()=>{const w=[],S=[{dir:s,rel:"",depth:0}];for(;S.length&&w.length<2e3;){const{dir:I,rel:G,depth:re}=S.shift();let ge=[];try{ge=await window.tangu?.listDir?.(I)||[]}catch{continue}for(const Ce of ge)if(!Ce.name.startsWith(".")){if(Ce.isDir)re<8&&!d.has(Ce.name)&&S.push({dir:Ce.path,rel:G?`${G}/${Ce.name}`:Ce.name,depth:re+1});else if(w.push(G?`${G}/${Ce.name}`:Ce.name),w.length>=2e3)break}}return w})().then(w=>{ys.current===s&&Ha(w)}).catch(()=>{})},[at,l.cwd,me]);const ui=Nn(s=>s.pages),jt=Nn(s=>s.vaultRoot),di=Nn(s=>s.icons),mi=$(s=>s.sessions),Yt=Pi(s=>s.pendingPrompt),It=_i(s=>s.pending);u.useEffect(()=>{!It||It.sessionId!==fe||!Et.current?.closest("[data-image-studio-chat]")||!Et.current.getClientRects().length||_i.getState().consume(It.seq)&&(he(s=>s.trim()?`${s}
|
|
17
|
+
|
|
18
|
+
${It.text}`:It.text),Ln(s=>[...s,...It.attachments]),requestAnimationFrame(()=>{ve.current?.focus(),ie()}))},[It,fe]);const hi=Ji(s=>s.pending);u.useEffect(()=>{if(!fe||!hi.some(d=>d.sessionId===fe)||!Et.current?.closest("[data-plugin-chat]"))return;const s=Ji.getState().take(fe);s.length&&(he(d=>[...d.trim()?[d]:[],...s].join(`
|
|
19
|
+
|
|
20
|
+
`)),requestAnimationFrame(()=>{ve.current?.focus(),ie()}))},[hi,fe]),u.useEffect(()=>{if(!Yt||!Et.current?.getClientRects().length)return;const s=$.getState(),d=fe?s.sessions.find(y=>y.id===fe)?.project_path:s.newChatWs?.path;Di(d||"")!==Di(Yt.project)||!Pi.getState().consumePrompt(Yt.seq)||(he(y=>y.trim()?`${y}
|
|
21
|
+
|
|
22
|
+
${Yt.text}`:Yt.text),requestAnimationFrame(()=>{ve.current?.focus(),ie()}))},[Yt,fe]);const St=u.useMemo(()=>{if(!at)return[];const s=at.query.toLowerCase(),d=[...me?ui.map(S=>({p:S,note:!0})):[],...me?(qa??[]).map(S=>({p:S})):[],...mi.filter(S=>S.id!==fe).slice(0,300).map(S=>({p:ht(S.title,N),session:{id:S.id,title:ht(S.title,N),summary:S.summary}}))],y=s?d.filter(S=>S.p.toLowerCase().includes(s)):d,w=S=>{const I=(S.note?S.p.replace(/\.md$/i,""):S.p).split("/").pop().toLowerCase();return(I.startsWith(s)?0:I.includes(s)?1:2)*1e4+S.p.length};return[...y].sort((S,I)=>w(S)-w(I)).slice(0,10)},[at,qa,ui,mi,fe,me,N]),Ns=!!at&&St.length>0;u.useEffect(()=>{Dn(0)},[at?.start,at?.query]);const pi=s=>{if(!at)return;const d=(s.session?So({kind:"session",id:s.session.id,title:s.session.title},jt||""):s.note&&jt?qc(jt,s.p):/\s/.test(s.p)?`"${s.p}"`:s.p).trim();Bt([{token:d,name:s.session?s.session.title:En(s.p),kind:s.session?"session":s.note?"note":"file"}]);const y=ue.slice(0,at.start);he(y+ue.slice(Be)),requestAnimationFrame(()=>{const w=ve.current;w&&(w.focus(),w.selectionStart=w.selectionEnd=y.length,lt(y.length)),ie()})},fi=Nn(s=>s.activePage??s.activeNotePath),Gt=Xn(s=>vd(s.mainTabs)),Fn=u.useMemo(()=>{if(Re){const y=Fd(Re);return vs===y.token||cn.some(w=>w.token===y.token)?null:y}if(!me||!se||!Gt)return null;const s=Gt==="note"?fi:Gt.startsWith("note:")?Gt.slice(5):"",d=s?jt?Ks({kind:"note",path:s},jt):null:Dt(Gt.slice(5));return!d||vs===d.token||cn.some(y=>y.token===d.token)?null:d},[Re,me,se,Gt,fi,jt,vs,cn]),ut=Fn?[Fn,...cn]:cn,gi=s=>{const d=(s??ue).trim(),y=s==null?d:"",w=/^\/feedback(?:\s+([\s\S]*))?$/i.exec(y);if(w&&window.tangu?.submitFeedback){$.getState().openFeedback(w[1]?.trim())&&(he(""),requestAnimationFrame(ie));return}const S=/^\/(?:btw|side)(?:\s+([\s\S]*))?$/i.exec(y);if(S&&Ge){Ge(S[1]?.trim()||void 0,ae||void 0),ae&&Ne?.(),he(""),requestAnimationFrame(ie);return}if(!d&&!ut.length)return;const I=/^\/compact(?:\s+([\s\S]+))?$/i.exec(y);if(I&&Je){Je((I[1]||"").trim()||void 0),he(""),requestAnimationFrame(ie);return}const G=/^\/loop(?:\s+(\d+))?$/i.exec(y);if(G&&ee){if(G[1]){const te=Math.min(Math.max(1,parseInt(G[1],10)),200);ee(te),Ae(N("input.slash.loopSet",{n:te}))}else Ae(N("input.slash.loop",{current:X||pe?.maxIterations||90}));he(""),requestAnimationFrame(ie);return}const re=/^\/verify(?:\s+([\s\S]+))?$/i.exec(y);if(re&&me&&W){const te=(re[1]||"").trim();te?/^(off|clear|关闭)$/i.test(te)?(W(""),Ae(N("input.slash.verifyCleared"))):(W(te),Ae(N("input.slash.verifySet",{cmd:te}))):Ae(N("input.slash.verifyUsage",{current:Y||N("input.slash.verifyNone")})),he(""),requestAnimationFrame(ie);return}if(Q&&/^\/(voice|text)$/i.test(y)){const te=/^\/voice$/i.test(d);Q(te),Ae(N(te?"input.slash.voiceOnHint":"input.slash.voiceOffHint")),he(""),requestAnimationFrame(ie);return}const ge=/^\/(?:think|effort)(?:\s+(\S+))?$/i.exec(y);if(ge&&B){const te=(ge[1]||"").toLowerCase();kt&&te==="ultra"?gn("max",!0)&&Ae(N("input.slash.thinkSet",{level:N("pill.ultra")})):Yn.includes(te)?(gn(te,kt?!1:void 0),Ae(N("input.slash.thinkSet",{level:Qs(te,N)}))):Ae(N("input.slash.thinkUsage",{levels:[...Yn,...kt?["ultra"]:[]].join("|")})),he(""),requestAnimationFrame(ie);return}const Ce=/^\/([a-z0-9][a-z0-9-]*)(?:\s+([\s\S]*))?$/i.exec(y);if(Ce&&fs.some(te=>te.name===Ce[1].toLowerCase())){const te=Ce[1].toLowerCase(),it=Ce[2]||"";he(""),requestAnimationFrame(ie),Oc(pt(),te,it).then(Jt=>K(Jt,[],[],void 0,void 0)).catch(Jt=>Ae(String(Jt?.message||Jt)));return}if(i)return;if(hn&&!s&&d&&d.length<=Bu&&!Wt.length&&!Ut.length&&!ut.length&&!ae&&!qt.length)return he(""),Ht(0),Ae(null),requestAnimationFrame(ie),qu(fe,d).then(async te=>{if(te)return!0;const it=await Promise.resolve(gi(d)).catch(()=>!1)??!1;return it?Ae(N("livecall.textFallback")):he(Jt=>Jt||d),it});const kn=ae?`${ae.split(`
|
|
23
|
+
`).map(te=>`> ${te}`).join(`
|
|
24
|
+
`)}
|
|
25
|
+
|
|
26
|
+
`:"",xn=ut.length?ut.map(te=>te.token).join(" ")+`
|
|
27
|
+
`:"",Lt=Wd(xn,kn,d);if(Lt.length>oo){Ae(N("input.tooLong",{len:Lt.length.toLocaleString(),max:oo.toLocaleString()}));return}Ae(null);const Pt=yn?{mentionProjects:(()=>{const te=Rr.filter(it=>Lt.includes(`@${it.name}`));return te.length?te:void 0})()}:vn?{priorityAgent:kr||void 0}:{mentionAgents:Fa.length?Fa:void 0},Xt=Oe,qe=Xt===Ai?new Set($.getState().sessions.map(te=>te.id)):null;return K(Lt,Wt,Ut,qt.map(te=>te.id),Pt).then(te=>{if(!te){const it=ja.current;return qe&&it!==Xt&&!qe.has(it)&&Wc(Xt,it),!1}return Uc(Xt,!!s),s||(Ht(0),Bc("tick")),Ne?.(),requestAnimationFrame(ie),!0})},On=()=>{gi()},vi=async s=>{if(!s)return;const d=[],y=[];for(const w of Array.from(s)){if(!w.type.startsWith("image/")){y.push(N("input.skip.notImage",{name:w.name}));continue}if(w.size>qs){y.push(N("input.skip.tooBig",{name:w.name,mb:String(Math.round(qs/1024/1024))}));continue}const S=await w.arrayBuffer();let I="";const G=new Uint8Array(S);for(let re=0;re<G.length;re+=32768)I+=String.fromCharCode(...G.subarray(re,re+32768));d.push({name:w.name,mimeType:w.type,data:btoa(I),size:w.size})}Ae(y.length?N("input.skip.imageHint",{items:y.join(N("composer2.listSep"))}):null),Ln(w=>[...w,...d])},Cs=async s=>{if(!s)return;const d=[],y=[];for(const w of Array.from(s)){if(w.size>Hs){y.push(N("input.skip.tooBig",{name:w.name,mb:String(Math.round(Hs/1024/1024))}));continue}const S=await w.arrayBuffer();let I="";const G=new Uint8Array(S);for(let re=0;re<G.length;re+=32768)I+=String.fromCharCode(...G.subarray(re,re+32768));d.push({name:w.name,mimeType:w.type||"application/octet-stream",data:btoa(I),size:w.size})}Ae(y.length?N("input.skip.simple",{items:y.join(N("composer2.listSep"))}):null),gs(w=>[...w,...d])},yi=s=>{if(s.length){if(me&&window.tangu?.getPathForFile){const d=Array.from(s).map(y=>{try{return window.tangu.getPathForFile(y)}catch{return""}}).filter(Boolean);if(d.length){Bt(d.map(Dt)),requestAnimationFrame(()=>{ve.current?.focus(),ie()});return}}Cs(s)}},ki=u.useRef(yi);ki.current=yi,u.useEffect(()=>{const s=Et.current;return s?Pd(s,d=>ki.current(d),wr):void 0},[]);const xi=async s=>{if(!s?.length)return;const d=Array.from(s).filter(w=>w.type.startsWith("image/")),y=Array.from(s).filter(w=>!w.type.startsWith("image/"));if(d.length){const w=new DataTransfer;d.forEach(S=>w.items.add(S)),await vi(w.files)}if(y.length){const w=new DataTransfer;y.forEach(S=>w.items.add(S)),await Cs(w.files)}};u.useEffect(()=>{if(!D)return;const s=k?.();if(s&&(s.text&&(he(d=>d.trim()?`${d.replace(/\s+$/,"")}
|
|
28
|
+
|
|
29
|
+
${s.text}`:s.text),requestAnimationFrame(()=>ie())),s.files.length)){const d=new DataTransfer;s.files.forEach(y=>d.items.add(y)),xi(d.files)}},[D]);const $r=async s=>{const d=[],y=[],w=[];for(const S of s){if(S.isDirectory){w.push(Dd(S.path));continue}try{const I=await window.tangu?.readHostFile?.(S.path);if(!I||I.tooLarge){w.push(Dt(S.path));continue}const G={name:En(S.path),mimeType:I.mimeType,data:I.content,size:I.size};I.mimeType.startsWith("image/")&&I.size<=qs?d.push(G):I.size<=Hs?y.push(G):w.push(Dt(S.path))}catch{w.push(Dt(S.path))}}d.length&&Ln(S=>[...S,...d]),y.length&&gs(S=>[...S,...y]),w.length&&Bt(w)},Lr=s=>{Bt([s.kind==="view"?_d(s.type,s.title):Ks(s,jt||"")]),requestAnimationFrame(()=>ve.current?.focus())},[Pr,wi]=u.useState(!1),Dr=$(s=>s.cfg),_r=s=>{j({execMode:"host",approvalMode:s,cwd:l.cwd}),Ze(null)},bi=Mc(),Fr=u.useMemo(()=>ql(p||[],bi),[p,bi]),dt=!!be&&(je?.length||0)>=2,Or=!!Ja&&_n&&(!!window.tangu?.openMini||ti)&&!(H&&!ye)&&!dt&&!ye&&!T,zs=Vs.find(s=>s.id===fn)||Vs[1],Wr=dt?N("group.modeLabel",{n:je.length}):N(H&&!ye?"input.planMode":ye?"input.presetChat":me?zs.key:"input.normal"),Ur=dt?Gs:H&&!ye?Ei:me?zs.Icon:cs,ji=!dt&&!(H&&!ye)&&!ye&&me&&zs.id==="full-auto",Br=!ye&&(!!Z||me||!!Te||!!De),qr=(A||[]).find(s=>s.id===T)?.name||N("input.engineDefault"),Se=!!T,Hr=Se?[{label:qr,options:z||[]}]:Fr.map(s=>({key:s.key,label:s.provider,source:s.source,options:s.models.map(d=>({...d,description:`${d.provider} · ${d.id}`}))})),Vr=Se||!!b||!!B,Wn=Rc(),[Lm,Pm]=u.useState(!1),Un=()=>Ze(null),Si={active:!H&&!dt&&fn==="auto-edit",disabled:r,agents:$e||[],currentAgentSlug:Ke,onNormalWork:Ve||(()=>{}),onAgentSwitch:!Se&&!dt?De:void 0,onClose:Un},Ms=Z&&!ye?{title:N("input.planMode"),items:[{id:"plan-mode",icon:t.jsx(Ei,{size:14}),label:N(be?"input.planModeTeamOff":H?"input.planModeOn":"input.planModeEnable"),checked:!!H&&!be,disabled:!!be,run:()=>{Z(!H),Un()}}]}:null,As=Te&&!Se&&!ye?{title:N("group.menu.section"),items:[{id:"group-chat",label:dt?N("group.menu.configured",{n:je.length}):N("group.menu.enable"),icon:t.jsx(Gs,{size:14}),checked:dt,run:()=>{dn(!0),Un()}}]}:null,Ni=me?Vs.map(({id:s,Icon:d,key:y,desc:w,...S})=>({id:`approval:${s}`,approvalId:s,label:N(y),detail:N(w),icon:t.jsx(d,{size:15,className:"approval-ic"}),checked:fn===s,danger:"danger"in S,run:()=>_r(s)})):[],$t=me&&fn==="custom"?{id:"approval-rules",label:N("input.approval.editRules"),detail:N("input.approval.editRulesDesc"),icon:t.jsx(Hc,{size:15,className:"approval-ic"}),run:()=>{wi(!0),Un()}}:null,Kr=()=>{const s=Ve&&!ye?Yo(Si,N):null;return{title:N("input.modeSheetTitle"),back:N("common.back"),sections:[{items:s?[s.normal,...s.agentSwitch?[s.agentSwitch]:[]]:[]},...Ms?[Ms]:[],...As?[As]:[],...me?[{title:N(m?"input.approvalSection.team":"input.approvalSection"),items:[...Ni,...$t?[$t]:[]]}]:[]]}},Ci=r?t.jsxs(t.Fragment,{children:[(!!ue.trim()||ut.length>0)&&t.jsx($s,{onClick:On,disabled:i,title:N("input.send"),"aria-label":N("input.send")}),t.jsxs("button",{className:"t2c-stop",onClick:q,title:N("input.stop"),"aria-label":N("input.stop"),children:[t.jsx(ko,{size:10}),t.jsx("span",{className:"t2c-stop-label",children:N("input.stop")})]})]}):Or&&!ue.trim()&&!ut.length&&!Wt.length&&!Ut.length&&!ae&&!qt.length?t.jsx($s,{className:"t2c-live-control",onClick:()=>{Ar()},disabled:!!i||ws,title:N(hn?"livecall.return":"livecall.start"),"aria-label":N(hn?"livecall.return":"livecall.start"),children:ws?t.jsx(sn,{size:16,className:"spin"}):t.jsx(au,{size:16})}):t.jsx($s,{onClick:On,disabled:i||!ue.trim()&&!ut.length,title:N("input.send"),"aria-label":N("input.send")});return t.jsxs("div",{className:"t2c",children:[yr&&t.jsx(id,{agents:$e||[],models:p,initialAgents:je||[],initialTempAgents:Pe,active:dt,hideDisable:!0,onConfirm:s=>{Te?.({groupChat:!0,...s}),dn(!1),Ic("chat.group")},onDisable:()=>Te?.({groupChat:!1}),onClose:()=>dn(!1)}),t.jsxs("div",{className:"t2c-inner",children:[!!We?.length&&t.jsxs("div",{className:"t2c-steer",role:"status","aria-label":N("input.steer.waiting"),children:[We.map(s=>t.jsxs("div",{className:"t2c-steer-item",children:[t.jsx(Ml,{size:12,className:"t2c-steer-ic"}),t.jsx("span",{className:"t2c-steer-text",title:s.text,children:s.text}),t.jsx("button",{className:"t2c-steer-x",title:N("input.steer.remove"),onClick:()=>us?.(s.id),children:t.jsx(mt,{size:12})})]},s.id)),t.jsxs("div",{className:"t2c-steer-foot",children:[t.jsx("span",{className:"t2c-steer-hint",children:N(We.some(s=>s.localOnly)?"input.steer.queuedHint":"input.steer.hint")}),yt&&We.some(s=>!s.localOnly)&&t.jsxs("button",{className:"t2c-steer-now",onClick:yt,children:[t.jsx($c,{size:11})," ",N("input.steer.now")]})]})]}),a,t.jsxs(Lc,{ref:Et,className:`${Wn?"t2c-card--phone":""}${xr?" dragover":""}`,children:[n,Ea&&t.jsx("div",{className:"t2c-hint",children:Ea}),ae&&t.jsxs("div",{className:"t2c-quote",children:[t.jsx("span",{className:"t2c-quote-text",children:ae.length>280?`${ae.slice(0,280)}…`:ae}),t.jsx("button",{title:N("input.remove"),onClick:()=>Ne?.(),className:"t2c-quote-x",children:t.jsx(mt,{size:12})})]}),ut.length>0&&t.jsxs("div",{className:"t2c-chiprow t2c-refrow",role:"group","aria-label":N("input.ref.selected"),children:[t.jsx("span",{className:"t2c-reflabel",children:N("input.ref.selected")}),ut.map(s=>t.jsx(yd,{chip:s,removeTitle:N("input.remove"),onRemove:()=>{Fn&&s.token===Fn.token?vr(s.token):Ma(d=>d.filter(y=>y.token!==s.token))}},s.token))]}),Wt.length>0&&t.jsx("div",{className:"t2c-chiprow",children:Wt.map((s,d)=>t.jsxs("span",{className:"attach-chip",children:[s.mimeType.startsWith("image/")&&t.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:s.name}),t.jsx("span",{children:s.name}),t.jsx("button",{title:N("input.remove"),onClick:()=>Ln(Wt.filter((y,w)=>w!==d)),children:t.jsx(mt,{size:12})})]},`${s.name}-${d}`))}),Ut.length>0&&t.jsx("div",{className:"t2c-chiprow",children:Ut.map((s,d)=>t.jsxs("span",{className:"attach-chip",title:N("input.wsUploadTitle",{name:s.name}),children:[s.mimeType.startsWith("image/")?t.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:s.name}):t.jsx(ga,{size:14,style:{color:"var(--accent-ink)",flexShrink:0}}),t.jsx("span",{children:s.name}),t.jsx("span",{style:{fontSize:"var(--ui-font-caption, 11px)",color:"var(--text-faint)",flexShrink:0},children:N("input.toWorkspace")}),t.jsx("button",{title:N("input.remove"),onClick:()=>gs(Ut.filter((y,w)=>w!==d)),children:t.jsx(mt,{size:12})})]},`ws-${s.name}-${d}`))}),qt.length>0&&t.jsx("div",{className:"t2c-chiprow",children:qt.map(s=>t.jsxs("span",{className:"attach-chip",title:N("input.skillChipTitle"),children:[t.jsx(vo,{size:13,style:{color:"var(--accent-ink)",flexShrink:0}}),t.jsx("span",{children:s.name}),t.jsx("button",{title:N("input.remove"),onClick:()=>Aa(qt.filter(d=>d.id!==s.id)),children:t.jsx(mt,{size:12})})]},`skill-${s.id}`))}),(s=>Wn?t.jsxs("div",{className:"t2c-field",children:[s,!Ka&&Ci]}):s)(t.jsx(Pc,{autoSize:!1,ref:ve,className:"t2c-ta",rows:1,autoFocus:o,value:ue,placeholder:js?bs:i?c||N("input.placeholderDisabled"):hn?N("livecall.typeHint"):r?Mt?N("input.runningPlaceholder"):N("input.tip",{tip:N(Ca[Sa%Ca.length])}):N(ms?"input.placeholderTouch":"input.placeholder"),"data-suggestion":js||void 0,"data-tip-fade":r&&!Mt&&pr||void 0,"data-tip-tall":r&&!Mt&&ps||void 0,disabled:i,onChange:s=>{he(s.target.value),lt(s.target.selectionStart||0),Ia(!1),Da(!1),Ba(!1),At&&Ht(0),e&&s.target.value&&Is(e),s.target.value.includes("@")||(_a(""),Oa([])),ie()},onSelect:s=>lt(s.target.selectionStart||0),onPaste:s=>{const d=s.clipboardData?.files;if(!d?.length)return;s.preventDefault();const y=Array.from(d),w=y.filter(G=>G.type.startsWith("image/")),S=y.filter(G=>!G.type.startsWith("image/")),I=[];if(S.length){const G=[];for(const re of S){let ge="";if(me)try{ge=window.tangu?.getPathForFile?.(re)||""}catch{ge=""}ge?G.push(ge):I.push(re)}G.length&&(Bt(G.map(Dt)),requestAnimationFrame(()=>{ve.current?.focus(),ie()}))}if(w.length){const G=new DataTransfer;w.forEach(re=>G.items.add(re)),vi(G.files)}if(I.length){const G=new DataTransfer;I.forEach(re=>G.items.add(re)),Cs(G.files)}},onKeyDown:s=>{if(Ns){if(s.key==="ArrowDown"){s.preventDefault(),Dn(d=>(d+1)%St.length);return}if(s.key==="ArrowUp"){s.preventDefault(),Dn(d=>(d-1+St.length)%St.length);return}if((s.key==="Enter"||s.key==="Tab")&&!s.nativeEvent.isComposing){s.preventDefault(),pi(St[Math.min(Wa,St.length-1)]);return}if(s.key==="Escape"){s.preventDefault(),Ba(!0);return}}if(ci){if(s.key==="ArrowDown"){s.preventDefault(),Pn(d=>(d+1)%bt.length);return}if(s.key==="ArrowUp"){s.preventDefault(),Pn(d=>(d-1+bt.length)%bt.length);return}if((s.key==="Enter"||s.key==="Tab")&&!s.nativeEvent.isComposing){s.preventDefault(),li(bt[Math.min(La,bt.length-1)]);return}if(s.key==="Escape"){s.preventDefault(),Da(!0);return}}if(Kt){if(s.key==="ArrowDown"){s.preventDefault(),Ue(d=>(d+1)%xt.length);return}if(s.key==="ArrowUp"){s.preventDefault(),Ue(d=>(d-1+xt.length)%xt.length);return}if((s.key==="Enter"||s.key==="Tab")&&!s.nativeEvent.isComposing){s.preventDefault(),xt[Math.min(Ta,xt.length-1)]?.run();return}if(s.key==="Escape"){s.preventDefault(),Ia(!0),un(null);return}}if(s.key==="Tab"&&!s.shiftKey&&js&&!Ee&&!s.nativeEvent.isComposing){s.preventDefault();const d=bs;he(d),e&&Is(e),requestAnimationFrame(()=>{const y=ve.current;y&&(y.selectionStart=y.selectionEnd=d.length,lt(d.length)),ie()});return}if(s.key==="ArrowUp"&&We?.length&&ce&&At===0&&s.currentTarget.selectionStart===s.currentTarget.selectionEnd&&ue.slice(0,s.currentTarget.selectionStart).indexOf(`
|
|
30
|
+
`)===-1){s.preventDefault();const d=We[We.length-1];ce(d.id).then(y=>{y&&(he(w=>w.trim()?`${y}
|
|
31
|
+
|
|
32
|
+
${w}`:y),requestAnimationFrame(()=>{const w=ve.current;w&&(w.focus(),w.selectionStart=w.selectionEnd=y.length,lt(y.length)),ie()}))});return}if(s.key==="ArrowUp"&&s.currentTarget.selectionStart===s.currentTarget.selectionEnd&&ue.slice(0,s.currentTarget.selectionStart).indexOf(`
|
|
33
|
+
`)===-1&&ct?.length){s.preventDefault(),ii(!0);return}if(s.key==="ArrowDown"&&At>0&&s.currentTarget.selectionStart===s.currentTarget.selectionEnd&&ue.slice(s.currentTarget.selectionStart).indexOf(`
|
|
34
|
+
`)===-1){s.preventDefault(),ii(!1);return}s.key==="Enter"&&!s.shiftKey&&!s.nativeEvent.isComposing&&(s.preventDefault(),On())}})),Kt&&t.jsx("div",{className:"t2c-menu",children:xt.map((s,d)=>t.jsxs("button",{className:"t2c-menu-item","data-active":d===Math.min(Ta,xt.length-1)||void 0,onMouseEnter:()=>Ue(d),onClick:()=>s.run(),children:[t.jsx("span",{className:"t2c-menu-cmd",children:s.cmd}),t.jsx("span",{className:"t2c-menu-desc",children:s.desc})]},`${s.cmd}-${d}`))}),ci&&!Ns&&t.jsxs("div",{className:"t2c-menu",children:[t.jsx("div",{className:"t2c-menu-sec",children:N(yn?"input.mention.projectNote":vn?"input.mention.groupNote":"input.mention.delegateNote")}),bt.map((s,d)=>t.jsxs("button",{className:"t2c-menu-item","data-active":d===Math.min(La,bt.length-1)||void 0,onMouseEnter:()=>Pn(d),onClick:()=>li(s),children:[t.jsxs("span",{className:"t2c-menu-cmd",children:["@",s.name]}),t.jsx("span",{className:"t2c-menu-desc",children:s.description||s.slug})]},s.slug))]}),Ns&&t.jsxs("div",{className:"t2c-menu",children:[t.jsx("div",{className:"t2c-menu-sec",children:N("input.fileref.note")}),St.map((s,d)=>t.jsxs("button",{className:"t2c-menu-item","data-active":d===Math.min(Wa,St.length-1)||void 0,onMouseEnter:()=>Dn(d),onClick:()=>pi(s),children:[t.jsx("span",{className:"t2c-menu-cmd",children:s.session?`💬 ${s.session.title}`:s.note?`${di[s.p]?`${di[s.p]} `:""}${s.p.split("/").pop().replace(/\.md$/i,"")}`:s.p.split("/").pop()}),t.jsx("span",{className:"t2c-menu-desc",children:s.session?s.session.summary||N("input.fileref.session"):s.p})]},s.session?`s:${s.session.id}`:(s.note?"n:":"f:")+s.p))]}),t.jsxs(Dc,{children:[t.jsx(fd,{open:Ee==="add",disabled:i,activeSessionId:fe,canUsePathPicker:me,onOpenChange:s=>Ze(s?"add":null),onNewSession:Ye,onAddAgent:!r&&!ye&&!Se?Me||(Te?()=>dn(!0):void 0):void 0,onPickPaths:$r,onPickFiles:xi,onAddReference:Lr}),Ka?t.jsx(Qu,{analyser:de.analyser,recording:de.recording,busy:de.busy,onStop:de.toggle,onSend:Nr,t:N}):t.jsxs(t.Fragment,{children:[Br&&!0&&t.jsxs("span",{className:`mode-pill-wrap t2c-capsule-peer${Ee==="mode"?" is-open":""}`,"data-cmenu":!0,children:[t.jsxs("button",{className:`t2c-pill mode-pill-btn${Ee==="mode"?" is-open":""}${H&&!ye?" active":""}`,"data-danger":ji||void 0,title:N(ji?"input.approval.fullAutoDesc":"input.modeChipTitle"),"aria-expanded":Ee==="mode",onClick:()=>{if(Ee!=="mode"&&ka(Kr,{})){Ze(null);return}Ze(s=>s==="mode"?null:"mode")},children:[t.jsx(Ur,{size:13}),t.jsx("span",{className:"t2c-pill-label",children:Wr}),t.jsx(Rn,{size:10})]}),Ee==="mode"&&t.jsxs("div",{ref:si.ref,className:"composer-menu composer-menu--mode",style:si.style,children:[Ve&&!ye&&t.jsx(gd,{...Si}),[Ms,As].map(s=>s&&t.jsxs(nn.Fragment,{children:[t.jsx("div",{className:"menu-section",children:s.title}),s.items.map(d=>t.jsxs("button",{className:`menu-item${d.checked?" active":""}`,disabled:d.disabled,onClick:d.run,children:[d.icon,t.jsx("span",{className:"grow",children:d.label}),d.checked&&t.jsx(ft,{size:13})]},d.id))]},s.items[0].id)),me&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"menu-section",children:N(m?"input.approvalSection.team":"input.approvalSection")}),Ni.map(s=>t.jsxs("button",{className:`menu-item approval-item${s.checked?" active":""}${s.danger?" danger":""}`,"aria-describedby":`approval-mode-desc-${s.approvalId}`,onClick:s.run,children:[s.icon,t.jsx("span",{className:"grow approval-title",children:s.label}),s.checked&&t.jsx(ft,{size:13,className:"approval-ck"}),t.jsx("span",{id:`approval-mode-desc-${s.approvalId}`,role:"tooltip",className:"approval-hover-desc",children:s.detail})]},s.approvalId)),$t&&t.jsxs("button",{className:"menu-item approval-item","aria-describedby":"approval-edit-rules-desc",onClick:$t.run,children:[$t.icon,t.jsx("span",{className:"grow approval-title",children:$t.label}),t.jsx("span",{id:"approval-edit-rules-desc",role:"tooltip",className:"approval-hover-desc",children:$t.detail})]})]})]})]}),t.jsx("span",{className:"t2c-grow"}),!ye&&!!Rt&&Rt>0&&(()=>{const s=Math.min(100,Math.round((tt||0)/Rt*100)),d=Ss?.compactAt?(tt||0)>=Ss.compactAt*.8:s>=80,y=9,w=2*Math.PI*y;return t.jsxs("span",{className:`t2c-ctxring t2c-collapse-on-capsule-open${Ee==="ctx"?" is-open":""}`,"data-warn":d||void 0,"data-cmenu":!0,children:[t.jsx("button",{type:"button",className:"t2c-ctxring-btn","aria-expanded":Ee==="ctx","aria-label":`${N("input.ctxLabel")} ${s}%`,...Io(()=>Ee==="ctx"?null:[`${N("input.ctxLabel")} ${s}%`]),onClick:()=>{Al(),Ze(S=>S==="ctx"?null:"ctx")},children:t.jsxs("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":"true",children:[t.jsx("circle",{className:"t2c-ctxring-track",cx:"12",cy:"12",r:y}),t.jsx("circle",{className:"t2c-ctxring-fill",cx:"12",cy:"12",r:y,style:{strokeDasharray:w,strokeDashoffset:w*(1-s/100)}})]})}),t.jsx("span",{ref:ai.ref,className:"t2c-ctxring-pop",style:ai.style,children:t.jsx(Td,{open:Ee==="ctx",contextWindow:Rt,ctxTokens:tt,sessionTokens:Xe,runCost:Le,costLimit:Fe,ctxInfo:Ss,onCompact:Je?()=>{Je(),Ze(null)}:void 0})})]})})(),Vr&&t.jsx(Hl,{scopeKey:`${fe??"draft"}:${_c(Cr)}:${Se?"engine":"tangu"}`,className:"t2c-capsule-peer",icon:Wn?null:void 0,hub:void 0,open:Ee==="model",onOpenChange:s=>Ze(s?"model":null),disabled:i,modelId:Se?M:x,groups:Hr,onSelect:Se?s=>U?.(s):s=>b?.(s),thinkingLevel:Se?void 0:Tt,onThinkingChange:Se||!B?void 0:(s,d)=>{gn(s,d)},allowUltra:kt,ultra:Vt,running:r,supportedThinking:Se?void 0:p?.find(s=>s.id===x)?.thinkingLevels,effectiveThinking:Se?void 0:pe?.thinkingRequested===(Tt||"medium")?pe?.thinkingEffective:void 0,modelsResponse:Se?void 0:f,defaultModelIds:Se?void 0:E,onDefaultModelChange:Se?void 0:g,onContextWindowChange:Se?void 0:O,emptyLabel:Se?N("input.engineModelDefault"):void 0,footnote:!Se&&!me&&!p?.some(s=>s.source==="direct")?N("input.cloudModelHint"):void 0}),t.jsx("button",{className:`t2c-iconbtn t2c-mic-control t2c-collapse-on-capsule-open${de.recording?" recording":""}`,title:de.busy?N("input.micBusy"):de.recording?N("input.micStop"):de.error||N("input.micStart"),disabled:i||de.busy||!de.supported,onClick:de.toggle,children:de.busy?t.jsx(sn,{size:14,className:"spin"}):t.jsx(Fc,{size:14})}),!Wn&&Ci]})]}),de.error&&!de.recording&&!de.busy&&t.jsx("div",{className:"t2c-hint",style:{marginTop:6,marginBottom:0},children:de.error}),Qa&&_n&&!de.error&&t.jsx("div",{className:"t2c-hint",style:{marginTop:6,marginBottom:0},children:Qa})]})]}),Pr&&t.jsx(dd,{cfg:Dr,onClose:()=>wi(!1)}),Tr&&t.jsx(td,{offerFullAccess:me&&!m&&fn!=="full-auto",onConfirm:({fullAccess:s})=>{s&&j({execMode:"host",approvalMode:"full-auto",cwd:l.cwd}),B?.("max",!0)},onClose:()=>ni(!1)})]})};function qd(e,n){const a=Math.max(0,e.content-e.width);if(e.left>=a-1)return 0;const o=e.left+e.width,i=n.find(r=>r.end>o+1),c=i?Math.min(i.start,a):a;return c>e.left+1?c:Math.min(o,a)}function Hd(e,n){return e-n>1}xe({"chatPicker.engine":{zh:"引擎",en:"Engine"},"chatPicker.agent":{zh:"Agent",en:"Agent"}});function Vd({label:e,value:n,icon:a,options:o,onChange:i,busy:c=!1}){const r=o.find(l=>l.value===n);return t.jsxs("label",{className:"compact-chat-picker","aria-busy":c||void 0,title:r?.name,children:[t.jsx("span",{className:"compact-chat-picker-kind",children:e}),t.jsx("span",{className:"compact-chat-picker-icon",children:a}),t.jsx("span",{className:"compact-chat-picker-name",children:r?.name||e}),t.jsx(Rn,{size:13}),t.jsxs("select",{"aria-label":e,value:r?n:"",onChange:l=>i(l.target.value),children:[!r&&t.jsx("option",{value:"",disabled:!0,children:e}),o.map(l=>t.jsx("option",{value:l.value,disabled:l.disabled,children:l.description?`${l.name} — ${l.description}`:l.name},l.value))]})]})}const Kd=({label:e,children:n,role:a="radiogroup"})=>{const{t:o}=ze(),i=u.useRef(null),[c,r]=u.useState(!1);u.useLayoutEffect(()=>{const m=i.current;if(!m)return;const p=()=>{const x=m.parentElement,b=x&&getComputedStyle(x),A=x&&b?x.clientWidth-parseFloat(b.paddingLeft)-parseFloat(b.paddingRight):m.clientWidth;r(Hd(m.scrollWidth,A))};p();const f=new ResizeObserver(p);f.observe(m);for(const x of Array.from(m.children))f.observe(x);return()=>f.disconnect()},[n]),u.useEffect(()=>{const m=i.current,p=m?.querySelector('[aria-checked="true"],[aria-pressed="true"]');if(!m||!p)return;const f=m.getBoundingClientRect(),x=p.getBoundingClientRect();x.right>f.right?m.scrollLeft+=x.right-f.right+6:x.left<f.left&&(m.scrollLeft-=f.left-x.left+6)},[]);const l=u.useCallback(()=>{const m=i.current;if(!m)return;const p=m.getBoundingClientRect(),f=Array.from(m.children).map(x=>{const b=x.getBoundingClientRect();return{start:b.left-p.left+m.scrollLeft,end:b.right-p.left+m.scrollLeft}});m.scrollTo({left:qd({left:m.scrollLeft,width:m.clientWidth,content:m.scrollWidth},f),behavior:"smooth"})},[]);return t.jsxs("div",{className:"engine-picker-bar","data-more":c||void 0,children:[t.jsx("div",{className:"engine-picker-scroll",ref:i,role:a,"aria-label":e,children:n}),c&&t.jsx("button",{type:"button",className:"engine-picker-more",onClick:l,title:o("pill.more"),"aria-label":o("pill.more"),children:t.jsx(ss,{size:16})})]})};function Yd(e,n,a){const o=Kc(e,n),i=o.groupAgents??[];return o.groupChat&&i.length>=2?{kind:"team",count:i.length}:{kind:"agent",slug:o.agentSlug||a||null}}xe({"agentSelect.title":{zh:"选择 Agent",en:"Pick agents"},"agentSelect.hintDefault":{zh:"由默认 Agent {name} 处理",en:"Handled by the default agent, {name}"},"agentSelect.hintDefaultAnon":{zh:"由默认 Agent 处理",en:"Handled by the default agent"},"agentSelect.hintOne":{zh:"{name} 将处理这条消息",en:"{name} will handle this message"},"agentSelect.removeHint":{zh:"再次点击移除",en:"Click again to remove"},"agentSelect.team":{zh:"团队模式 · {n} 人",en:"Team mode · {n} people"},"agentSelect.picked":{zh:"已选",en:"Picked"},"agentSelect.default":{zh:"默认 Agent",en:"Default agent"},"agentSelect.defaultTag":{zh:"默认",en:"Default"},"agentSelect.direct":{zh:"私聊",en:"Direct chat"}});const Zt=2,Qt=e=>`agent:${e}`,Sn=e=>`engine:${e}`,Gd=(e,n)=>e.length===n.length&&e.every((a,o)=>a===n[o]);function Xd(e){if(e.engineId)return[];const n=e.groupAgents??[];return e.groupChat&&n.length>=2?[...n]:e.agentSlug?[e.agentSlug]:[]}function yh({sessionId:e,cfg:n}){const{t:a}=ze(),[o,i]=u.useState(null),c=$(Yc(v=>({agentDefs:v.agentDefs,agentAvatars:v.agentAvatars,defaultAgentSlug:v.defaultAgentSlug,engines:v.engines,engineCaps:v.engineCaps,teams:v.teams}))),r=$(v=>e?null:Gc(v,Xc())),l=$(v=>r?v.projectSettingsByPath[r]??null:null),m=$(v=>!r||r in v.projectSettingsByPath);u.useEffect(()=>{r&&!m&&$.getState().ensureProjectSettings(r).catch(()=>null)},[r,m]);const p=n.engineId||"",f=Xd(n),x=p?[Sn(p)]:f.map(Qt),b=p&&!c.engineCaps[p]?p:"",A=u.useMemo(()=>{const v=c.agentDefs.map(F=>({id:Qt(F.slug),kind:"agent",slug:F.slug,name:F.name,description:F.description,system:F.createdBy==="system"}));for(const F of n.groupAgents??[]){if(v.some(we=>we.id===Qt(F)))continue;const ne=n.groupTempAgents?.find(we=>we.slug===F);v.push({id:Qt(F),kind:"agent",slug:F,name:ne?.name||F,description:ne?.description})}if(n.agentSlug&&!v.some(F=>F.id===Qt(n.agentSlug))&&v.push({id:Qt(n.agentSlug),kind:"agent",slug:n.agentSlug,name:n.agentSlug}),n.execMode==="host")for(const F of c.engines)F.available&&v.push({id:Sn(F.id),kind:"engine",engineId:F.id,name:F.name});return p&&!v.some(F=>F.id===Sn(p))&&v.push({id:Sn(p),kind:"engine",engineId:p,name:c.engines.find(F=>F.id===p)?.name||p}),v},[c.agentDefs,c.engines,p,n.execMode,n.groupAgents,n.groupTempAgents,n.agentSlug]),T=u.useMemo(()=>new Map(A.map(v=>[v.id,v])),[A]),z=u.useMemo(()=>A.filter(v=>v.kind==="agent").map(v=>v.name),[A]),M=x.map(v=>T.get(v)).filter(v=>!!v),U=A.filter(v=>!x.includes(v.id)),_=n.groupChat?f.length:0,L=v=>{const F=!!n.groupChat&&f.length<Zt;if(!p&&!F&&Gd(f,v))return;const ne=$.getState(),we=!!p,be=(n.groupTempAgents||[]).filter(Me=>v.includes(Me.slug)),je=we?{engineId:void 0,engineModelId:void 0}:{};if(v.length>=Zt){const Me={groupChat:!0,groupAgents:v,groupTempAgents:be.length?be:void 0,...je};e?ne.patchSessionConfig(Me,e):ne.setNewChatCfg(Ve=>({...Ve,...Me}));return}const Pe=v[0]||"",Te={groupChat:!1,groupAgents:void 0,groupTempAgents:void 0,...je};e?ne.selectSessionAgent(Pe,e,Te):(ne.setNewChatCfg(Me=>({...Me,...Te})),ne.selectNewChatAgent(Pe))},B=v=>{const F=$.getState();e?F.setSessionEngine(v,e):F.setNewChatCfg(ne=>({...ne,engineId:v||void 0,engineModelId:void 0,...v?{groupChat:!1,groupAgents:void 0,agentSlug:void 0}:{}}))},J=u.useRef(null),E=u.useRef(null);u.useEffect(()=>{const v=J.current;if(!v)return;J.current=null,E.current?.querySelector(`[data-pill-id="${CSS.escape(v)}"]`)?.focus()});const g=v=>{if(J.current=v.id,v.kind==="engine"){B(v.engineId===p?"":v.engineId);return}const F=f.includes(v.slug)?f.filter(ne=>ne!==v.slug):[...f,v.slug];L(F)},O=()=>{p?B(""):L([])},X=v=>{v.kind==="agent"?Ri("agent",v.slug):Ri("engine",v.engineId)},ee=v=>v.kind==="engine"?b===v.engineId?t.jsx(sn,{size:16,className:"spin"}):t.jsx(Ui,{engineId:v.engineId,size:16}):t.jsx(Ju,{name:v.name,url:c.agentAvatars[v.slug],siblings:z,imgClassName:"agent-pill-avatar",initialClassName:"agent-pill-initial"}),Y=(v,F)=>{const ne=v.kind==="agent"&&v.description?`${v.name} — ${v.description}`:v.name;return F?`${ne} · ${a("agentSelect.removeHint")}`:v.kind==="agent"&&v.slug===c.defaultAgentSlug?`${ne} · ${a("agentSelect.defaultTag")}`:ne},W=(v,F)=>{const ne=F!==null,we=v.kind==="engine"&&b===v.engineId;return t.jsxs("button",{type:"button","aria-pressed":ne,"data-pill-id":v.id,className:`engine-pill agent-pill${ne?" selected":""}`,"data-agent-slug":v.kind==="agent"?v.slug:void 0,"data-engine-id":v.kind==="engine"?v.engineId:void 0,title:Y(v,ne),disabled:!!b&&!we,onClick:()=>{(!b||we)&&g(v)},onContextMenu:be=>{be.preventDefault(),i({...Cl(be),items:[{label:a("agentSelect.direct"),icon:t.jsx(No,{size:13}),run:()=>X(v)}]})},children:[ne&&M.length>=Zt&&t.jsx("span",{className:"agent-pill-index",children:F+1}),t.jsx("span",{className:"engine-pill-icon",children:ee(v)}),t.jsx("span",{className:"engine-pill-label",children:v.name}),v.kind==="agent"&&v.system&&t.jsx("span",{className:"agent-badge-system",children:a("agent.badge.system")})]},v.id)};if(n.preset==="chat"||!A.length)return null;const C=Yd(n,e?{}:Jc(l,Array.isArray(c.teams)?c.teams:[]).config,c.defaultAgentSlug),P=C.kind==="agent"&&C.slug?c.agentDefs.find(v=>v.slug===C.slug)?.name:void 0,H=_>=Zt?a("agentSelect.team",{n:_}):M.length===1?a("agentSelect.hintOne",{name:M[0].name}):C.kind==="team"?a("agentSelect.team",{n:C.count}):P?a("agentSelect.hintDefault",{name:P}):a("agentSelect.hintDefaultAnon"),Z=_<Zt&&M.length!==1&&C.kind!=="team",R=x[0]||"",Q=M[0]?ee(M[0]):t.jsx(Ui,{engineId:"",size:16});return t.jsxs("div",{ref:E,className:"engine-picker agent-picker agent-select-strip",role:"group","aria-label":a("agentSelect.title"),children:[t.jsx(Vd,{label:a("chatPicker.agent"),value:R,icon:Q,options:[{value:"",name:a("agentSelect.default")},...A.map(v=>({value:v.id,name:v.name,description:x.includes(v.id)?a("agentSelect.picked"):v.kind==="agent"?v.description:void 0,disabled:!!b&&v.id!==Sn(b)}))],onChange:v=>{if(!v){O();return}const F=T.get(v);F&&g(F)},busy:!!b}),t.jsx(Kd,{label:a("agentSelect.title"),role:"group",children:[...M.map((v,F)=>W(v,F)),...M.length>0?[t.jsx("span",{className:"agent-select-sep","aria-hidden":"true"},"sep")]:[],...U.map(v=>W(v,null))]}),t.jsx("div",{className:`engine-picker-hint${_>=Zt?" agent-select-team":""}${Z?" is-default":""}`,children:H}),o&&t.jsx(Nl,{menu:o,onClose:()=>i(null)})]})}const Jd=e=>`${e.name} ${e.path||""} ${e.project||""}`,Zd=e=>[e.path,e.project].filter(n=>!!n&&n!==e.name).join(" · ")||void 0,kh=({workspaces:e,value:n,onChange:a,onAddProject:o,onAddCloudProject:i})=>{const{t:c}=ze(),[r,l]=u.useState(!1),[m,p]=u.useState(""),[f,x]=u.useState(!1),[b,A]=u.useState(""),T=u.useRef(null),z=u.useRef(null),M=an(r);u.useEffect(()=>{if(!r)return;const R=v=>{T.current&&!T.current.contains(v.target)&&(l(!1),p(""),x(!1),A(""))},Q=v=>{v.key==="Escape"&&(l(!1),p(""),x(!1),A(""),T.current?.querySelector(".project-pill")?.focus())};return window.addEventListener("mousedown",R),window.addEventListener("keydown",Q),()=>{window.removeEventListener("mousedown",R),window.removeEventListener("keydown",Q)}},[r]);const U=e.filter(R=>R.kind!=="channel"),_=U.find(R=>R.key===n||!!n&&R.sessionKeys?.includes(n))||U.find(R=>R.kind==="local"&&R.system)||U[0]||null,L=U.find(R=>R.kind==="rootless")||null,B=U.filter(R=>R.kind!=="rootless"),J=m.trim().toLowerCase(),E=B.filter(R=>!J||Jd(R).toLowerCase().includes(J)),g=B.length>=6,O=_?.kind==="cloud"?tn:_?.kind==="rootless"?Oi:is,X=()=>{l(!1),p(""),x(!1),A("")},ee=R=>{a(R),X()},Y=R=>({id:`ws:${R.key}`,label:R.name,detail:Zd(R),icon:R.kind==="cloud"?t.jsx(tn,{size:14}):t.jsx(is,{size:14}),checked:R.key===_?.key,run:()=>ee(R)}),W=L?{id:`ws:${L.key}`,label:c("input.project.dontWork"),icon:t.jsx(Oi,{size:14}),checked:L.key===_?.key,run:()=>ee(L)}:null,C=i?{id:"add-cloud",label:c("input.project.addCloud"),icon:t.jsx(tn,{size:14}),run:()=>{{x(!0);return}}}:null,P=o?{id:"add-local",label:c("input.project.add"),icon:t.jsx(Po,{size:14}),run:()=>{o(),X()}}:null,H=()=>({title:c("input.project.label"),back:c("common.back"),...g?{search:{placeholder:c("input.project.search"),empty:c("input.project.noMatches")}}:{},sections:[{items:B.map(Y)},{items:W?[W]:[]},{items:[C,P].filter(R=>!!R)}]});u.useEffect(()=>{if(!r||Zc())return;const R=requestAnimationFrame(()=>{(g?z.current?.querySelector(".project-menu-search input"):z.current?.querySelector(".project-menu-item.active"))?.focus()});return()=>cancelAnimationFrame(R)},[r,g]);const Z=R=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(R.key))return;const Q=[...z.current?.querySelectorAll(".project-menu-item:not(:disabled)")||[]];if(!Q.length)return;R.preventDefault();const v=Q.indexOf(document.activeElement),F=R.key==="Home"?0:R.key==="End"?Q.length-1:v<0?R.key==="ArrowDown"?0:Q.length-1:R.key==="ArrowDown"?(v+1)%Q.length:(v-1+Q.length)%Q.length;Q[F]?.focus()};return t.jsxs("div",{className:`project-selector${r?" is-open":""}`,ref:T,children:[t.jsxs("button",{className:`composer-chip project-pill${r?" is-open":""}`,onClick:()=>{if(r){X();return}ka(H,{})||l(!0)},title:c("input.project.label"),"aria-haspopup":"menu","aria-expanded":r,children:[t.jsx(O,{size:13}),t.jsx("span",{className:"project-pill-name",children:_?.name||c("input.project.none")}),t.jsx(Rn,{size:12})]}),r&&t.jsxs("div",{ref:R=>{z.current=R,M.ref.current=R},className:"composer-menu project-menu",style:M.style,role:"menu","aria-label":c("input.project.label"),onKeyDown:Z,children:[g&&t.jsxs("label",{className:"project-menu-search",children:[t.jsx(wo,{size:13}),t.jsx("input",{value:m,onChange:R=>p(R.target.value),placeholder:c("input.project.search")})]}),t.jsxs("div",{className:"project-menu-list",children:[E.map(Y).map(R=>t.jsxs("button",{className:`menu-item project-menu-item${R.checked?" active":""}`,role:"menuitemradio","aria-checked":!!R.checked,onClick:R.run,children:[R.icon,t.jsx("span",{className:"grow project-menu-name",children:R.label}),t.jsx("span",{className:"project-menu-check",children:R.checked?t.jsx(ft,{size:13}):null})]},R.id)),!E.length&&t.jsx("div",{className:"project-menu-empty",children:c("input.project.noMatches")})]}),W&&t.jsx("div",{className:"project-menu-section project-menu-projectless-section",role:"group",children:t.jsxs("button",{className:`menu-item project-menu-item project-menu-projectless${W.checked?" active":""}`,role:"menuitemradio","aria-checked":W.checked,onClick:W.run,children:[W.icon,t.jsx("span",{className:"grow project-menu-name",children:W.label}),t.jsx("span",{className:"project-menu-check",children:W.checked?t.jsx(ft,{size:13}):null})]})}),(C||P)&&t.jsxs("div",{className:"project-menu-section project-menu-actions",role:"group",children:[i&&C&&(f?t.jsxs("label",{className:"project-menu-search project-menu-naming",children:[t.jsx(tn,{size:13}),t.jsx("input",{autoFocus:!0,value:b,onChange:R=>A(R.target.value),placeholder:c("input.project.cloudName"),onKeyDown:R=>{R.key==="Enter"&&b.trim()&&(i(b.trim()),X()),R.key==="Escape"&&(R.stopPropagation(),A(""),x(!1))}})]}):t.jsxs("button",{className:"menu-item project-menu-item project-menu-add",role:"menuitem",onClick:C.run,children:[C.icon,t.jsx("span",{className:"grow",children:C.label})]})),P&&t.jsxs("button",{className:"menu-item project-menu-item project-menu-add",role:"menuitem",onClick:P.run,children:[P.icon,t.jsx("span",{className:"grow",children:P.label})]})]})]})]})},ua=Qc,ro=/^[0-9a-zA-Z-]{8,64}$/;function Xo(e){return e.kind==="unit"?`unit:${e.unitId.toLowerCase()}`:""}function Qd(e){if(typeof e=="string"){const a=/^unit:(.+)$/.exec(e);return a&&ro.test(a[1])?Object.freeze({kind:"unit",unitId:a[1].toLowerCase()}):ua}const n=e;return n&&typeof n=="object"&&n.kind==="unit"&&typeof n.unitId=="string"&&ro.test(n.unitId)?Object.freeze({kind:"unit",unitId:n.unitId.toLowerCase()}):ua}const em=5*6e4,co=new Set(["remoteOff","awaitingConfirm","denied","callerBlocked"]);function da(e){if(e==null)return null;const n=typeof e=="object"?e:{},a=typeof n.code=="string"?n.code:"",o=typeof n.status=="number"?n.status:NaN;switch(a){case"ENGINE_NOT_READY":return"starting";case"UNIT_OFFLINE":case"UNIT_DISCONNECTED":return"offline";case"UNIT_TIMEOUT":return"unreachable";case"REMOTE_SESSIONS_OFF":return"remoteOff";case"REMOTE_CALLER_UNCONFIRMED":return Zl(n.reason)?"callerBlocked":n.state==="denied"?"denied":"awaitingConfirm";case"CALLER_UNAVAILABLE":case"CALLER_UNSUPPORTED":case"UNIT_CALLER_INVALID":case"UNIT_CALLER_EXPIRED":return"unreachable"}return a?o>=500?"unreachable":null:n.name==="TypeError"||n.name==="AbortError"||o===0||o>=500?"unreachable":null}const lo=e=>e.state||e.reason?{...e.state?{state:e.state}:{},...e.reason?{reason:e.reason}:{}}:void 0;function tm(e,n,a,o=Date.now()){if(!e.online)return{status:"offline"};if(e.capsLive&&e.caps){const i=e.caps.engine;if(i==="external")return{status:"noEngine"};if(i==="stopped")return{status:"engineStopped"};if(i==="starting")return{status:"starting"}}if(n&&!n.ok){const i=da(n)??"unreachable",c=co.has(i)?lo(n):void 0;return c?{status:i,refusal:c}:{status:i}}if(a&&o-a.at>=0&&o-a.at<em){const i=da({status:403,code:a.code,state:a.state,reason:a.reason});if(i&&co.has(i)){const c=lo(a);return c?{status:i,refusal:c}:{status:i}}}return n?.ok?{status:"ready"}:{status:"checking"}}function nm(e){return!!(e.online&&e.capsLive&&e.caps?.engine==="ready")}const sm=1e4,am=8e3,im=50,om={sessions:[],fetchedAt:null,loading:!1};async function rm(){if(typeof window.tangu?.unitSelf=="function")try{const e=await window.tangu.unitSelf();return{id:e?.unitId?e.unitId.toLowerCase():null,registered:!!e?.registered}}catch{}try{const e=await window.tangu?.unitHostStatus?.();if(e?.unitId)return{id:e.unitId.toLowerCase(),registered:null}}catch{}return{id:null,registered:null}}function cm(e,n){return e.filter(a=>!!a&&typeof a.id=="string"&&va(a.id)&&(a.kind??"desktop")==="desktop"&&a.id.toLowerCase()!==n)}function lm(e){const n=e?.sessions;if(!Array.isArray(n))return[];const a=[];for(const o of n){if(!o||typeof o!="object")continue;const i=o;if(typeof i.id!="string"||!i.id||i.id.length>200||i.archived)continue;const{location:c,...r}=i;a.push({...r,title:typeof r.title=="string"?r.title:""})}return a}function gt(e){return{kind:"unit",unitId:e.toLowerCase()}}const le=ls((e,n)=>({gen:0,units:null,byUnit:{},refreshedAt:0,selfRegistered:null,refreshRoster:async()=>{if(!tl()||!window.tangu?.unitsList)return null;const a=n().gen;let o=null;try{const r=await window.tangu.unitsList();r?.status===200&&Array.isArray(r.json?.units)&&(o=r.json.units)}catch{}if(a!==n().gen)return null;if(!o)return n().units;const i=await rm(),c=cm(o,i.id);if(a!==n().gen)return null;for(const r of c)nl(gt(r.id),r.name);return e({units:c,selfRegistered:i.registered}),c},refresh:async(a={})=>{if(!Ft())return;const o=n().gen,i=await n().refreshRoster();if(!i||o!==n().gen||(await Promise.all(i.map(l=>um(l,o,!!a.force,!!a.periodic))),o!==n().gen))return;const c=new Set(i.map(l=>l.id.toLowerCase())),r=Object.fromEntries(Object.entries(n().byUnit).filter(([l])=>c.has(l)));e({byUnit:r,refreshedAt:Date.now()}),mm()},reset:()=>{e(a=>({gen:a.gen+1,units:null,byUnit:{},refreshedAt:0,selfRegistered:null})),el()}}));function ot(e,n){const a=e.toLowerCase();le.setState(o=>({byUnit:{...o.byUnit,[a]:{...o.byUnit[a]??om,...n}}}))}async function um(e,n,a,o=!1){const i=e.id.toLowerCase(),c=le.getState().byUnit[i];if(o&&dm(on.getState().probes[i]))return;if(!e.online){ot(i,{sessions:[],loading:!1});return}if(le.getState().selfRegistered===!1){ot(i,{sessions:[],loading:!1});return}if(e.capsLive&&e.caps?.engine&&e.caps.engine!=="ready"){ot(i,{sessions:[],loading:!1});return}if(!a&&c?.fetchedAt&&Date.now()-c.fetchedAt<sm)return;const r=In(gt(i));if(r){ot(i,{loading:!0});try{const l=await sl(r,`/agent/sessions?archived=false&limit=${im}&app_id=${encodeURIComponent(yo)}`,{},{timeoutMs:am});let m=null;try{m=await l.json()}catch{}if(n!==le.getState().gen)return;if(!l.ok){const x=m??{},b=Ii({status:l.status,code:x.code,state:x.state,reason:x.reason});Ls(i,b),ot(i,{sessions:uo(i,b),fetchedAt:Date.now(),loading:!1});return}const p=gt(i),f=lm(m).filter(x=>$n(x.id,p)?(console.warn(`[device-sessions] dropped session ${x.id} listed by ${i}: that id already belongs to another location`),!1):!0);Ls(i,{ok:!0}),ot(i,{sessions:f,fetchedAt:Date.now(),loading:!1})}catch(l){if(n!==le.getState().gen)return;const m=Ii(l);Ls(i,m),ot(i,{sessions:uo(i,m),fetchedAt:Date.now(),loading:!1})}}}function dm(e){if(!e||e.ok)return!1;const n=al(e.status,{code:e.code});return n==="caller-unavailable"||n==="gone"||n==="account-auth?"}function uo(e,n){return da(n)==="unreachable"?le.getState().byUnit[e]?.sessions??[]:[]}function mm(){const e=le.getState().byUnit,n=new Map;for(const[c,r]of Object.entries(e))for(const l of r.sessions)An(Co(l.id),gt(c))&&n.set(l.id,l);if(!n.size)return;const a=$.getState();let o=!1;const i=a.sessions.map(c=>{const r=c.location?.kind==="unit"?n.get(c.id):void 0;return!r||r.title===c.title&&r.updated_at===c.updated_at&&r.summary===c.summary?c:(o=!0,{...c,title:r.title,updated_at:r.updated_at,summary:r.summary})});o&&$.setState({sessions:i})}function wa(e,n=Date.now()){const a=on.getState(),o=e.id.toLowerCase(),i=tm(e,a.probes[o]??null,a.sticky[o]??null,n);return i.status==="checking"&&le.getState().selfRegistered===!1&&nm(e)?{status:"ready"}:i}function Jo(e){const n=e.toLowerCase();return le.getState().units?.find(a=>a.id.toLowerCase()===n)??null}function ma(e,n){if(!e?.id||!va(n.unitId))return!1;const a=gt(n.unitId);if(ol(e.id,a)==="conflict")return console.warn(`[device-sessions] refused to open ${e.id} on ${a.unitId}: that id already belongs to another location`),!1;const{location:o,...i}=e,c=rl(i);return $.setState(r=>({sessions:[c,...r.sessions.filter(l=>l.id!==e.id)],configBySession:r.configBySession[e.id]||!e.agent_config?r.configBySession:{...r.configBySession,[e.id]:e.agent_config}})),(as.getState().activeSpaceId==="home"||as.getState().activeSpaceId==="inbox")&&zo("tangu"),Mo(e.id),!0}async function xh(e,n){if(!Ft()||!va(e)||!n)return!1;const a=gt(e);if($n(n,a))return!1;const o=$.getState();if((o.sessions.find(l=>l.id===n)??o.archivedSessions.find(l=>l.id===n))&&An(Co(n),a))return(as.getState().activeSpaceId==="home"||as.getState().activeSpaceId==="inbox")&&zo("tangu"),Mo(n),!0;const c=le.getState().byUnit[a.unitId]?.sessions.find(l=>l.id===n);if(c)return ma(c,a);const r=In(a);if(!r)return!1;try{const l=await il(r,n);return!l||l.id!==n?!1:ma(l,a)}catch{return!1}}async function hm(e,n,a){const o=gt(e),i=In(o);if(!i||$n(n,o))return;const c=l=>l.id===n?{...l,title:a}:l,r=le.getState().byUnit[o.unitId];r&&ot(o.unitId,{sessions:r.sessions.map(c)}),$.setState(l=>({sessions:l.sessions.map(m=>m.location?.kind==="unit"?c(m):m)}));try{await ya(i,n,{title:a})}catch(l){$.getState().toast($.getState().tr("app.renameFail",{e:l?.message||l}),!0)}}async function pm(e,n,a){const o=gt(e),i=In(o);if(!i||$n(n,o))return!1;const c=cl(a);if(a!==null&&!c)return $.getState().toast($.getState().tr("session.icon.invalid"),!0),!1;try{const r=await ya(i,n,{emoji:c}),l=p=>p.id===n?{...p,emoji:r.emoji}:p,m=le.getState().byUnit[o.unitId];return m&&ot(o.unitId,{sessions:m.sessions.map(l)}),$.setState(p=>({sessions:p.sessions.map(f=>f.location&&An(f.location,o)?l(f):f),archivedSessions:p.archivedSessions.map(f=>f.location&&An(f.location,o)?l(f):f)})),!0}catch(r){return $.getState().toast($.getState().tr("session.icon.saveFail",{e:r?.message||r}),!0),!1}}async function fm(e,n){const a=gt(e),o=In(a);if(!o||$n(n,a))return;try{await ya(o,n,{archived:!0})}catch(c){$.getState().toast(c?.message||String(c),!0);return}const i=le.getState().byUnit[a.unitId];i&&ot(a.unitId,{sessions:i.sessions.filter(c=>c.id!==n)}),$.setState(c=>({sessions:c.sessions.filter(r=>!(r.id===n&&r.location?.kind==="unit"))})),$.getState().activeId===n&&$.getState().setActiveId(null)}let mo=$.getState().cfg?.token??"";$.subscribe(e=>{const n=e.cfg?.token??"";n!==mo&&(mo=n,le.getState().reset())});const et=ls(()=>({draftSeq:0,explicitSeq:null,reconciledSeq:null,explicitPending:!1,chooser:null}));function wh(e){return et.setState({chooser:e}),()=>{et.getState().chooser===e&&et.setState({chooser:null})}}const gm="forsion_run_location:";function Zo(){const e=Yr(dl(),$.getState().cfg?.token||"");return e?`${gm}${e}`:null}function vm(){const e=Zo();if(!e)return null;try{const n=localStorage.getItem(e);return n===null?null:Qd(n)}catch{return null}}function Qo(e){const n=Zo();if(n)try{localStorage.setItem(n,Xo(e))}catch{}}async function bh(e,n){Qo(e),et.setState({explicitPending:!0});try{await Ao(e,{name:n.name??null})}finally{et.setState(a=>({explicitSeq:a.draftSeq,explicitPending:!1}))}}let ho=!1,ha=!1;function er(){if(!Ft())return!1;const e=et.getState();if($.getState().activeId||e.explicitPending||e.explicitSeq===e.draftSeq||e.reconciledSeq===e.draftSeq)return!1;const n=ul();let a=vm();ho||(ho=!0,a===null&&n.kind==="unit"&&(a=n,Qo(n)));let o=ua,i=null;if(a?.kind==="unit"){if(le.getState().units===null)return!1;const c=Jo(a.unitId);if(c){const r=wa(c).status;if(r==="checking")return!1;r==="ready"&&(o=a,i=c.name)}}if(et.setState({reconciledSeq:e.draftSeq}),!An(o,n)){ha=!0;let c;try{c=Ao(o,{name:i})}finally{ha=!1}c.catch(()=>{})}return!0}ll(()=>{if(ha)return;const e=et.getState();et.setState({explicitSeq:$.getState().activeId?e.draftSeq+1:e.draftSeq})});const ym=1e4;let Ys=$.getState().activeId;$.subscribe(e=>{if(e.activeId===Ys)return;const n=Ys;if(Ys=e.activeId,n&&!e.activeId){et.setState(o=>({draftSeq:o.draftSeq+1}));const a=le.getState();Date.now()-a.refreshedAt<ym?er():a.refresh().catch(()=>{})}});le.subscribe((e,n)=>{e.refreshedAt!==n.refreshedAt&&er()});xe({"session.icon.set":{zh:"设置图标",en:"Set icon"},"session.icon.invalid":{zh:"请选择一个 Emoji 作为会话图标",en:"Choose one emoji for the session icon"},"session.icon.saveFail":{zh:"图标未能保存:{e}",en:"Could not save the icon: {e}"}});function ba({emoji:e,fallback:n,size:a=17}){return e?t.jsx("span",{"data-session-emoji":e,"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:a,height:a,flexShrink:0,fontSize:a,lineHeight:1},children:e}):t.jsx(t.Fragment,{children:n??t.jsx(No,{size:a})})}function jh({params:e,size:n}){const a=$(o=>{const i=e.followActive!==!1?o.activeId:e.sessionId;return o.sessions.find(c=>c.id===i)?.emoji??o.archivedSessions.find(c=>c.id===i)?.emoji});return t.jsx(ba,{emoji:a,size:n})}function tr({sessionId:e,current:n,x:a,y:o,onClose:i,onSave:c}){const r=u.useRef(!1),l=async m=>{if(!r.current){r.current=!0;try{await(c?c(m):$.getState().setSessionEmoji(e,m))&&i()}finally{r.current=!1}}};return fa.createPortal(t.jsx(Ql,{x:a,y:o,current:n,onPick:m=>{l(m)},onClose:i}),document.body)}const nr=({open:e,children:n})=>{const a=El();return t.jsx(Tl,{initial:!1,children:e&&t.jsx(Rl.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:a?0:.24,ease:[.2,.8,.3,1]},style:{overflow:"hidden"},children:n})})};function km({path:e,fallback:n,className:a}){const o=$(l=>l.projectSettingsByPath[e]?.icon),i=$(l=>l.projectIconUrls[e]),c=$(l=>l.connState==="ok"),r=Gr(o);return u.useEffect(()=>{c&&$.getState().ensureProjectSettings(e)},[e,c]),u.useEffect(()=>{c&&r&&$.getState().loadProjectIcon(e)},[e,c,r]),r?i?t.jsx("img",{className:a,src:i,alt:"",draggable:!1}):t.jsx(t.Fragment,{children:n}):o?t.jsx("span",{className:a,"aria-hidden":"true",children:o}):t.jsx(t.Fragment,{children:n})}xe({"agentRemove.title":{zh:"删除 Agent「{name}」?",en:'Delete agent "{name}"?'},"agentRemove.msg":{zh:"会从 Agent 名册和侧栏移除,历史私聊保留(只读)。它的记忆与 Library 默认保留在 Tangu 数据目录的 agents/.removed/ 里。",en:"It is removed from the agent roster and the sidebar; past direct chats are kept (read-only). By default its memory and Library are kept in agents/.removed/ in the Tangu data folder."},"agentRemove.msgCloud":{zh:"会从 Agent 名册移除,历史会话保留(只读)。",en:"It is removed from the agent roster; past sessions are kept (read-only)."},"agentRemove.files":{zh:"同时删除相关文件:它的记忆、Library 等,移到废纸篓",en:"Also delete related files: its memory, Library and the rest, moved to the Trash"},"agentRemove.confirm":{zh:"删除",en:"Delete"},"agentRemove.done":{zh:"已删除 Agent「{name}」",en:'Agent "{name}" deleted'}});function sr({title:e,message:n,confirmLabel:a,filesLabel:o,onConfirm:i,onClose:c}){const[r,l]=u.useState(!1);return fa.createPortal(t.jsx("div",{className:"am-app tangu-lovable",style:{display:"contents"},"data-remove-dialog":!0,children:t.jsx(xo,{title:e,message:n,confirmLabel:a,onConfirm:()=>i(!!o&&r),onClose:c,children:o&&t.jsxs("label",{className:"dialog-check",children:[t.jsx("input",{type:"checkbox",checked:r,onChange:m=>l(m.target.checked)}),t.jsx("span",{children:o})]})})}),document.body)}function Sh({agent:e,onDone:n,onClose:a}){const{t:o}=ze(),i=!!e.libraryDir,c=e.name||e.slug;return t.jsx(sr,{title:o("agentRemove.title",{name:c}),message:o(i?"agentRemove.msg":"agentRemove.msgCloud"),confirmLabel:o("agentRemove.confirm"),filesLabel:i&&window.tangu?.trashHostPath?o("agentRemove.files"):void 0,onConfirm:r=>{const l=$.getState();l.removeAgent(e,r).then(()=>{l.toast(o("agentRemove.done",{name:c})),n?.()}).catch(m=>l.toast(String(m?.message||m),!0))},onClose:a})}const ar="forsion_orbits_pinned_entries_v1",Tn=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Kn(e,n){return Tn(e,n)}function ir(e,n){let a=0;for(const o of Object.values(e))Number.isFinite(o)&&(a=Math.max(a,o));return Math.max(n,a+1)}function Nh(e,n,a=Date.now()){if(Tn(e,n)){const o={...e};return delete o[n],o}return{...e,[n]:ir(e,a)}}function Ch(e,n,a=Date.now()){return Tn(e,n)?{...e,[n]:ir(e,a)}:e}function zh(e=typeof localStorage>"u"?null:localStorage){if(!e)return{};try{const n=JSON.parse(e.getItem(ar)||"{}");if(!n||typeof n!="object"||Array.isArray(n))return{};const a={};for(const[o,i]of Object.entries(n))o&&Number.isFinite(i)&&Number(i)>0&&(a[o]=Number(i));return a}catch{return{}}}function Mh(e,n=typeof localStorage>"u"?null:localStorage){try{n?.setItem(ar,JSON.stringify(e))}catch{}}function po(e,n){return e.map((a,o)=>({entry:a,index:o})).sort((a,o)=>{const i=Tn(n,a.entry.key),c=Tn(n,o.entry.key);return i!==c?i?-1:1:i&&c?n[o.entry.key]-n[a.entry.key]||a.index-o.index:o.entry.at-a.entry.at||a.index-o.index}).map(({entry:a})=>a)}xe({"sidebar.attention":{zh:"{n} 项等你处理",en:"{n} waiting for you"},"sidebar.attentionLocalOnly":{zh:"{n} 项等你处理 · 含只能在那台电脑上批准的操作",en:"{n} waiting for you · includes actions that can only be approved on that computer"}});const or=({n:e,localOnly:n})=>{const{t:a}=ze();return t.jsx("span",{className:"t2s-dot attention","data-attention":e,title:a(n?"sidebar.attentionLocalOnly":"sidebar.attention",{n:e})})};xe({"chat.toNote.action":{zh:"整理成笔记",en:"Turn into note"},"chat.toNote.working":{zh:"正在把对话整理成笔记…",en:"Turning the chat into a note…"},"chat.toNote.empty":{zh:"这段对话还没有可整理的内容",en:"This chat has nothing to turn into a note yet"},"chat.toNote.done":{zh:"已整理成笔记「{name}」",en:"Saved as the note “{name}”"},"chat.toNote.failed":{zh:"没能整理成笔记:{reason}",en:"Couldn’t turn the chat into a note: {reason}"},"chat.toNote.workingTail":{zh:"对话较长,只整理最近的部分…",en:"This chat is long; only the most recent part will be turned into a note…"},"chat.toNote.emptyAnswer":{zh:"模型没有返回内容",en:"the model returned nothing"},"chat.toNote.nameTaken":{zh:"同名笔记太多(已试到 -20)",en:"too many notes with that name (tried up to -20)"}});const xm=["The text in <selection> is a chat transcript between a user and an AI assistant.","Turn it into a standalone, well-organized note that someone can reread later without the chat.",'Start with exactly one "# " heading that names the topic.',"Keep the conclusions, decisions, facts, numbers, code and step-by-step instructions; drop greetings, filler, retries and back-and-forth.","Use headings, lists and tables where they help. Do not mention that it came from a chat.","Write in the language the user wrote in."].join(" "),pa=2e4;function rr(e){const n=[];for(const a of e){if(a.role!=="user"&&a.role!=="assistant")continue;const o=(a.role==="assistant"?pl(a.content).text:a.content).trim();o&&n.push(`${a.role==="user"?"User":"Assistant"}:
|
|
35
|
+
${o}`)}return n.join(`
|
|
36
|
+
|
|
37
|
+
`)}function wm(e){const n=rr(e);return n.length>pa?n.slice(-pa):n}function bm(e,n){const a=/^\s*#[ \t]+(.+?)[ \t]*#*[ \t]*(?:\r?\n|$)/.exec(e);return{title:(a?a[1]:n).replace(/[\\/:*?"<>|#^[\]]/g," ").replace(/\s+/g," ").trim().slice(0,80)||n,body:(a?e.slice(a[0].length):e).replace(/^\s*\n/,"")}}function jm(){return ml()&&!!Eo()?.complete}async function Sm(e,n){for(let a=1;a<=20;a++){const o=`${a===1?e:`${e}-${a}`}.md`;if(await $i.readTextFile?.(o)?.catch(()=>null)!=null)continue;const i=await $i.writeTextFile(o,n,{create:!0,base:Xr("")});if(!(i&&i.ok===!1))return o}return null}async function Nm(e){const n=Eo()?.complete;if(!n)return!1;const a=$.getState(),o=[...a.sessions,...a.archivedSessions].find(i=>i.id===e);try{a.messagesBySession[e]?.length||await a.loadSessionHistory(e);const i=$.getState().messagesBySession[e]||[],c=wm(i);if(!c)return Bn({text:Ie("chat.toNote.empty"),level:"info",inAppOnly:!0}),!1;Bn({text:Ie(rr(i).length>pa?"chat.toNote.workingTail":"chat.toNote.working"),level:"info",inAppOnly:!0});const r=await n({action:"custom",instruction:xm,selection:c,title:o?.title||void 0});if(!r.text.trim())throw new Error(Ie("chat.toNote.emptyAnswer"));const{title:l,body:m}=bm(r.text,o?.title?.trim()||Ie("amadeus.default.note")),p=await Sm(l,m.trimEnd()+`
|
|
38
|
+
`);if(!p)throw new Error(Ie("chat.toNote.nameTaken"));return Bn({text:Ie("chat.toNote.done",{name:l}),level:"success",receipt:!0}),hl(p),!0}catch(i){return Bn({text:Ie("chat.toNote.failed",{reason:i instanceof Error?i.message:String(i)}),level:"error",inAppOnly:!0}),!1}}const fo={wechat:vl,telegram:gl,qq:en};xe({"sidebar.openInNewTab":{zh:"在新标签页打开",en:"Open in new tab"},"sidebar.archiveN":{zh:"归档 {n} 项",en:"Archive {n}"},"sidebar.unarchiveN":{zh:"取消归档 {n} 项",en:"Unarchive {n}"},"sidebar.deleteN":{zh:"删除 {n} 项",en:"Delete {n}"},"sidebar.deleteConfirmN":{zh:"删除选中的 {n} 个会话?不可撤销。",en:"Delete {n} selected chats? This cannot be undone."},"sidebar.mode.chat":{zh:"Chat",en:"Chat"},"sidebar.mode.work":{zh:"Work",en:"Work"},"sidebar.mode.tip":{zh:"Chat:轻聊天,只列聊天会话;Work:完整工具面,列出全部项目",en:"Chat: light conversations, chat sessions only. Work: full toolset, all projects"},"sidebar.pin":{zh:"置顶",en:"Pin to top"},"sidebar.unpin":{zh:"取消置顶",en:"Unpin"},"sidebar.ws.details":{zh:"查看详情",en:"View details"},"sidebar.ws.removeTitle":{zh:"移除项目「{name}」?",en:'Remove project "{name}"?'},"sidebar.ws.removeMsg":{zh:"会从侧栏移除它,并删除其中的 {count} 个会话,不可撤销。磁盘上的项目文件夹不会删除。",en:"It is removed from the sidebar and its {count} session(s) are deleted. This cannot be undone. The project folder on disk is not deleted."},"sidebar.ws.removeFiles":{zh:"同时删除相关文件:项目里的 .tangu 文件夹(Tangu 的指令、技能、计划),移到废纸篓",en:"Also delete related files: the project's .tangu folder (Tangu instructions, skills and plans), moved to the Trash"},"sidebar.ws.removeAction":{zh:"移除",en:"Remove"}});const cr="forsion_tangu_collapsed_projects",lr="forsion_tangu_workspace_order";function Cm(){try{return new Set(JSON.parse(localStorage.getItem(cr)||"[]"))}catch{return new Set}}function go(e){try{localStorage.setItem(cr,JSON.stringify([...e]))}catch{}}function zm(){try{const e=JSON.parse(localStorage.getItem(lr)||"[]");return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}catch{return[]}}function Mm(e){try{localStorage.setItem(lr,JSON.stringify(e))}catch{}}function rs(e){const n=String(e||"").trim();if(!n)return 0;const a=Date.parse(n.includes("T")?n:n.replace(" ","T"));return Number.isFinite(a)?a:0}const Am=({icon:e,title:n,active:a,onClick:o,onExpand:i,act:c})=>t.jsxs("button",{className:`t2s-special${a?" active":""}`,"data-act":c,onClick:o,children:[t.jsx("span",{className:"t2s-special-ic",children:e}),t.jsx("span",{className:"t2s-special-title",children:n}),i&&t.jsx("span",{className:"t2s-special-go",onClick:r=>{r.stopPropagation(),i()},children:t.jsx(_t,{size:14})})]}),Ah=e=>{const{t:n}=ze(),a=u.useRef(null),o=u.useRef(null);Il(o,e.timeline?e.onSearch:void 0);const i=e.allSessions??e.sessions,c=e.allArchived??e.archivedSessions,r=$l(a),[l,m]=u.useState(null),[p,f]=u.useState(null),[x,b]=u.useState(null),[A,T]=u.useState(""),[z,M]=u.useState(()=>{try{return Math.max(1,Number(localStorage.getItem("tangu_ws_session_limit"))||5)}catch{return 5}});u.useEffect(()=>{const h=()=>{try{M(Math.max(1,Number(localStorage.getItem("tangu_ws_session_limit"))||5))}catch{}};return window.addEventListener("tangu:wslimit",h),()=>window.removeEventListener("tangu:wslimit",h)},[]);const[U,_]=u.useState(!1),[L,B]=u.useState(Cm),[J,E]=u.useState(zm),[g,O]=u.useState(null),[X,ee]=u.useState(null),Y=u.useRef(null),W=u.useRef(!1),[C,P]=u.useState(null),[H,Z]=u.useState(null),[R,Q]=u.useState(null),[v,F]=u.useState(""),ne=u.useRef(null),we=wu(h=>h.channels),be=u.useMemo(()=>{const h=new Map;for(const D of we)h.set(D.kind,D.runtime.some(k=>k.running));return h},[we]),je=u.useMemo(()=>{const h=new Map;for(const D of e.workspaces)h.set(D.key,[]);for(const D of e.sessions){const k=Es(D,e.workspaces);h.has(k)||h.set(k,[]),h.get(k).push(D)}return h},[e.workspaces,e.sessions]),Pe=u.useMemo(()=>{const h=new Map(e.workspaces.map(V=>[V.key,V])),D=[];for(const V of J){const oe=h.get(V);oe&&(D.push(oe),h.delete(V))}const k=[...h.values()].sort((V,oe)=>(V.kind==="channel"?-1:0)-(oe.kind==="channel"?-1:0));return[...D,...k]},[e.workspaces,J]),Te=g?Pe.findIndex(h=>h.key===g):-1,Me=u.useMemo(()=>{if(e.timeline)return po([...(e.extraRows||[]).map(k=>({key:`row:${k.key}`,at:k.at,node:k.node})),...e.sessions.map(k=>({key:`ses:${k.id}`,at:rs(k.updated_at),session:k}))],e.pinnedEntries||{});const h=Pe.map(k=>({key:`ws:${k.key}`,ws:k,at:(je.get(k.key)||[]).reduce((V,oe)=>Math.max(V,rs(oe.updated_at)),0)}));if(e.orderBy!=="activity")return h;const D=(e.extraRows||[]).map(k=>({key:`row:${k.key}`,at:k.at,node:k.node}));return po([...D,...h],e.pinnedEntries||{})},[Pe,je,e.orderBy,e.extraRows,e.pinnedEntries,e.timeline,e.sessions]),Ve=e.orderBy!=="activity",$e=h=>{const D=g;if(O(null),ee(null),!D||D===h)return;const k=Pe.map(se=>se.key),V=k.indexOf(h);if(V<0||!k.includes(D))return;const oe=bl(k,D,V);E(oe),Mm(oe)},De=h=>{B(D=>{const k=new Set(D);return k.has(h)?k.delete(h):k.add(h),go(k),k})},Ke=h=>{B(D=>{if(!D.has(h))return D;const k=new Set(D);return k.delete(h),go(k),k})},_e=h=>{e.onEnterWorkspace?.(h),Ke(h)};u.useEffect(()=>{if(!W.current){W.current=!0;return}e.activeWorkspaceKey!=null&&Ke(e.activeWorkspaceKey)},[e.activeWorkspaceKey]),u.useEffect(()=>{x&&Y.current?.select()},[x]),u.useEffect(()=>{R&&ne.current?.select()},[R]),u.useEffect(()=>{if(!l&&!C)return;const h=()=>{m(null),P(null)};return window.addEventListener("click",h),window.addEventListener("contextmenu",h),()=>{window.removeEventListener("click",h),window.removeEventListener("contextmenu",h)}},[l,C]);const Ye=(h,D)=>{h.preventDefault(),h.stopPropagation(),P(null);const k=r.batch(D.id);k.length===1&&r.only(D.id),m({id:D.id,ids:k,x:h.clientX,y:h.clientY,archived:!!D.archived})},vt=(h,D)=>{h.preventDefault(),h.stopPropagation(),m(null),P({ws:D,x:h.clientX,y:h.clientY})},Ct=()=>{x&&A.trim()&&e.onRename(x,A.trim()),b(null)},j=h=>{const D=[...i,...c].find(V=>V.id===h),k=()=>{T(D?.title||""),b(h)};{k();return}},K=h=>{const D=()=>{F(h.name),Q(h.key)};{D();return}},q=h=>{const D=[],k=h.ids.length===1,V=k?[...i,...c].find(se=>se.id===h.id):void 0;k&&D.push({id:"open-new-tab",label:n("sidebar.openInNewTab"),icon:t.jsx(ts,{size:13}),run:()=>{e.onSelect(h.id,{newTab:!0}),m(null)}}),k&&D.push({id:"set-icon",label:n("session.icon.set"),icon:t.jsx(Do,{size:13}),run:()=>{f({id:h.id,current:V?.emoji??null,x:h.x,y:h.y}),m(null)}}),k&&D.push({id:"rename",label:n("sidebar.rename"),icon:t.jsx(zn,{size:13}),run:()=>{m(null),j(h.id)}}),k&&jm()&&D.push({id:"to-note",label:n("chat.toNote.action"),icon:t.jsx(ru,{size:13}),run:()=>{Nm(h.id),m(null)}}),D.push({id:h.archived?"unarchive":"archive",label:h.ids.length>1?n(h.archived?"sidebar.unarchiveN":"sidebar.archiveN",{n:String(h.ids.length)}):h.archived?n("sidebar.unarchive"):n("sidebar.archive"),icon:h.archived?t.jsx(Fi,{size:13}):t.jsx(Jn,{size:13}),run:()=>{for(const se of h.ids)e.onArchive(se,!h.archived);r.clear(),m(null)}});const oe=V?.project_path?e.workspaces.find(se=>se.kind==="channel"&&se.key===V.project_path):null;if(V&&oe?.channel){const se=fo[oe.channel];D.push({id:"channel-connect",label:n("sidebar.channel.setAsConnected"),icon:t.jsx(se,{size:13}),run:()=>{m(null),yl(pt(),oe.channel,h.id).then(()=>e.onToast?.(n("sidebar.wechat.setConnectedOk"))).catch(Re=>e.onToast?.(n("sidebar.wechat.setConnectedFail",{e:Re?.message||Re}),!0))}})}return h.ids.every(se=>e.archivedSessions.some(Re=>Re.id===se))&&D.push({id:"delete",danger:!0,icon:t.jsx(Gn,{size:13}),label:h.ids.length>1?n("sidebar.deleteN",{n:String(h.ids.length)}):n("sidebar.delete"),run:()=>{const se=h.ids;if(m(null),!!(se.length>1?window.confirm(n("sidebar.deleteConfirmN",{n:String(se.length)})):window.confirm(n("sidebar.deleteConfirm",{name:ht(V?.title,n)})))){for(const ct of se)e.onDelete(ct);r.clear()}}}),D},ae=h=>{const D=[];if(e.onTogglePinned){const k=`ws:${h.ws.key}`,V=Kn(e.pinnedEntries||{},k);D.push({id:V?"unpin":"pin",label:n(V?"sidebar.unpin":"sidebar.pin"),icon:V?t.jsx(Wi,{size:13}):t.jsx(qn,{size:13}),run:()=>{P(null),e.onTogglePinned?.(k)}})}return e.onShowWorkspaceDetails&&Ps(h.ws)&&[...i,...c].some(k=>k.project_path===h.ws.path&&!k.projectless)&&D.push({id:"ws-details",act:"ws-details",label:n("sidebar.ws.details"),icon:t.jsx(eu,{size:13}),run:()=>{const k=h.ws;P(null),e.onShowWorkspaceDetails?.(k)}}),h.ws.system||(D.push({id:"ws-rename",label:n("sidebar.ws.rename"),icon:t.jsx(zn,{size:13}),run:()=>{const k=h.ws;P(null),K(k)}}),D.push({id:"ws-remove",act:"ws-remove",danger:!0,label:n("sidebar.ws.remove"),icon:t.jsx(Gn,{size:13}),run:()=>{Z(h.ws),P(null)}})),D},Ne=h=>{if(h.ids.length!==1)return;const D=[...i,...c].find(k=>k.id===h.id);return ht(D?.title,n)},Ge=Js(l,()=>l&&{title:Ne(l),sections:[{items:q(l)}]},()=>m(null)),zt=Js(C,()=>C&&{title:bn(C.ws,n),sections:[{items:ae(C)}]},()=>P(null)),tt=()=>{if(R&&v.trim()){const h=e.workspaces.find(D=>D.key===R);h&&e.onRenameWorkspace(h,v.trim())}Q(null)},Xe=(h,D)=>{const k=h.kind==="channel"?fo[h.channel||"wechat"]:h.kind==="cloud"?tn:h.kind==="rootless"?en:D?is:wl;return t.jsxs("span",{className:"t2s-lead",children:[Ps(h)?t.jsx(km,{path:h.path,className:"amx-page-emoji t2s-project-icon",fallback:t.jsx(k,{className:"t2s-lead-icon"})}):t.jsx(k,{className:"t2s-lead-icon"}),t.jsx("span",{className:`t2s-chev t2s-lead-chev${D?"":" open"}`,onClick:V=>{V.stopPropagation(),De(h.key)},children:t.jsx(_t,{size:12})})]})},Le=h=>{const D=[];if(!h.archived&&e.onTogglePinned){const V=Kn(e.pinnedEntries||{},`ses:${h.id}`);D.push({id:V?"unpin":"pin",label:n(V?"sidebar.unpin":"sidebar.pin"),icon:V?t.jsx(Wi,{}):t.jsx(qn,{}),run:()=>e.onTogglePinned?.(`ses:${h.id}`)})}h.archived||D.push({id:"rename",label:n("sidebar.rename"),icon:t.jsx(zn,{}),run:()=>j(h.id)}),D.push({id:h.archived?"unarchive":"archive",label:n(h.archived?"sidebar.unarchive":"sidebar.archive"),icon:h.archived?t.jsx(Fi,{}):t.jsx(Jn,{}),tone:"accent",run:()=>e.onArchive(h.id,!h.archived)});const k=h.archived?q({id:h.id,ids:[h.id],x:0,y:0,archived:!0}).find(V=>V.id==="delete"):void 0;return k&&D.push({id:"delete",label:n("sidebar.delete"),icon:t.jsx(Gn,{}),tone:"danger",run:()=>k.run?.()}),D},Fe=h=>{const D=Es(h,e.workspaces),k=e.workspaces.find(V=>V.key===D);return k&&k.kind!=="rootless"&&!k.system?bn(k,n):""},pe=h=>{const D=t.jsx(Lo,{as:"button",className:`${h.id===e.activeId?"active":""}${r.has(h.id)?" sel":""}`.trim()||void 0,selId:h.id,title:h.summary||h.title||void 0,depth:e.flat?0:1,style:e.timeline?{paddingLeft:void 0}:void 0,lead:t.jsxs(t.Fragment,{children:[t.jsx(ba,{emoji:h.emoji,fallback:e.rowIcon?.(h)??t.jsx(cs,{className:"t2s-lead-icon t2s-dim"})}),e.attentionIds?.get(h.id)?t.jsx(or,{n:e.attentionIds.get(h.id).n,localOnly:e.attentionIds.get(h.id).localOnly}):e.runningIds.has(h.id)?t.jsx("span",{className:"t2s-dot running",title:n("sidebar.running")}):e.unreadIds.has(h.id)?t.jsx("span",{className:"t2s-dot unread",title:n("sidebar.unread")}):null]}),trailing:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"t2s-srow-time",children:xl(h.updated_at)}),t.jsx("span",{className:"t2s-srow-menu",onClick:k=>Ye(k,h),children:t.jsx(ss,{size:14})})]}),onClick:k=>{const V=r.click(h.id,k);if(V.open==="none")return;e.onSelect(h.id,V.open==="new"?{newTab:!0}:void 0);const oe=e.sessionWorkspaceKeyOf?e.sessionWorkspaceKeyOf(h):Es(h,e.workspaces);oe&&(e.onActivateEntry?.(`ws:${oe}`),_e(oe))},onContextMenu:k=>Ye(k,h),draggable:!e.timeline&&x!==h.id,onDragStart:k=>{const V=k.currentTarget.getBoundingClientRect();k.dataTransfer.setDragImage(k.currentTarget,k.clientX-V.left,k.clientY-V.top),k.dataTransfer.effectAllowed="copy";const oe=[...i,...c],se=r.batch(h.id).map(Re=>{const ct=oe.find(We=>We.id===Re);return{kind:"session",id:Re,title:ht(ct?.title,n)}});kl(k.dataTransfer,se)},children:x===h.id?t.jsx("input",{ref:Y,className:"t2s-rename",value:A,onChange:k=>T(k.target.value),onBlur:Ct,onKeyDown:k=>{k.key==="Enter"&&Ct(),k.key==="Escape"&&b(null)},onClick:k=>k.stopPropagation()}):e.timeline?t.jsxs("span",{className:"t2s-srow-text",children:[t.jsx("span",{className:"t2s-srow-title",children:ht(h.title,n)}),(Fe(h)||h.summary)&&t.jsxs("span",{className:"t2s-srow-sub",children:[Fe(h)&&t.jsx("span",{className:"t2s-srow-tag",children:Fe(h)}),Fe(h)&&h.summary?" · ":"",h.summary]})]}):t.jsx("span",{className:"t2s-srow-title",children:ht(h.title,n)})},h.id);return e.timeline?t.jsx(Ul,{actions:Le(h),children:D},h.id):D},Je=fl(),Ot=(window.tangu?.pickDirectory&&!e.flat||e.archivedSessions.length>0)&&t.jsxs("div",{className:"t2s-foot",children:[window.tangu?.pickDirectory&&!e.flat&&t.jsxs("button",{className:"t2s-add-ws",onClick:e.onAddWorkspace,children:[t.jsx(Po,{size:14})," ",n("sidebar.addLocalWorkspace")]}),e.archivedSessions.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"t2s-srow t2s-archived-toggle",onClick:()=>_(!U),children:[t.jsx("span",{className:"t2s-chev",children:t.jsx(Jn,{size:13})}),t.jsx("span",{className:"t2s-srow-title t2s-faint",children:n("sidebar.archived")}),t.jsx("span",{className:"t2s-count",children:e.archivedSessions.length})]}),U&&e.archivedSessions.map(pe)]})]});return t.jsxs("aside",{className:"t2s-side",ref:a,"data-timeline":e.timeline?"":void 0,children:[t.jsxs("div",{className:"t2s-scroll",ref:o,"data-under-dock":Je?"":void 0,onTouchStart:e.timeline?Ll:void 0,onDragOver:h=>{g&&(h.preventDefault(),h.dataTransfer.dropEffect="move")},onDrop:h=>{g&&X&&(h.preventDefault(),$e(X))},children:[e.showSpecial&&t.jsx("div",{className:"t2s-special-group",children:t.jsxs("div",{className:"t2s-special-row",children:[t.jsx(Am,{icon:t.jsx(Pl,{}),title:n("sidebar.newChat"),active:!1,onClick:e.onNewChat,act:"new-chat"}),e.mode&&e.onModeChange&&t.jsxs("div",{className:"t2s-vaultseg t2s-mode",role:"tablist","aria-label":n("sidebar.mode.tip"),title:n("sidebar.mode.tip"),children:[t.jsx("div",{className:"t2s-vaultseg-thumb","data-side":e.mode}),["chat","work"].map(h=>t.jsx("button",{type:"button",role:"tab","aria-selected":e.mode===h,"data-mode":h,className:e.mode===h?"on":void 0,onClick:()=>e.onModeChange(h),children:n(h==="chat"?"sidebar.mode.chat":"sidebar.mode.work")},h))]})]})}),e.timeline&&e.onSearch&&t.jsx(Dl,{}),e.timeline&&e.timelineHead,e.timeline&&_l(Me,h=>Kn(e.pinnedEntries||{},h.key)?"pinned":Fl(h.at)).map(h=>"section"in h?t.jsx(Ol,{bucket:h.section},`sec:${h.section}`):h.item.session?pe(h.item.session):t.jsx(nn.Fragment,{children:h.item.node},h.item.key)),!e.timeline&&Me.map((h,D)=>{if(h.node)return t.jsx(nn.Fragment,{children:h.node},h.key);const k=h.ws,V=Kn(e.pinnedEntries||{},h.key),oe=je.get(k.key)||[];if(e.flat)return t.jsx("div",{className:"t2s-group-sessions t2s-flat",children:oe.map(pe)},k.key);const se=L.has(k.key),Re={onDragOver:ce=>{if(!g)return;ce.preventDefault(),ce.dataTransfer.dropEffect="move";const yt=g===k.key?null:k.key;X!==yt&&ee(yt)},onDrop:ce=>{g&&(ce.preventDefault(),ce.stopPropagation(),$e(k.key))}},ct=!!g&&X===k.key&&g!==k.key,We=ct&&Te>=0&&Te<D,us=We?se?" drag-over below":"":ct?" drag-over":"";return t.jsxs(nn.Fragment,{children:[t.jsxs("div",{className:`t2s-group${us}${g===k.key?" dragging":""}`,"data-workspace-key":k.key,"data-pinned":V?"true":void 0,"data-active":e.activeWorkspaceKey===k.key?"true":void 0,style:{paddingLeft:$o(0)},...Io(()=>[k.path||"",Wl("tip.sessions",{count:oe.length})].filter(Boolean)),draggable:Ve&&R!==k.key,onContextMenu:ce=>vt(ce,k),onDragStart:ce=>{const yt=ce.currentTarget.getBoundingClientRect();ce.dataTransfer.setDragImage(ce.currentTarget,ce.clientX-yt.left,ce.clientY-yt.top),ce.dataTransfer.effectAllowed="move",O(k.key)},...Re,onDragEnd:()=>{O(null),ee(null)},children:[R===k.key?t.jsxs("div",{className:"t2s-group-toggle t2s-folder-row",style:{cursor:"default"},children:[Xe(k,se),t.jsx("input",{ref:ne,className:"t2s-rename",value:v,onChange:ce=>F(ce.target.value),onBlur:tt,onKeyDown:ce=>{ce.key==="Enter"&&tt(),ce.key==="Escape"&&Q(null)},onClick:ce=>ce.stopPropagation()})]}):k.kind==="channel"?t.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>{e.onActivateEntry?.(h.key),se?_e(k.key):De(k.key)},children:[Xe(k,se),t.jsx("span",{className:"t2s-group-label",children:bn(k,n)}),V&&t.jsx(qn,{className:"t2o-pin-mark","aria-hidden":"true"}),t.jsx("span",{className:`t2s-mini-dot${be.get(k.channel||"wechat")?" ok":""}`})]}):t.jsxs("button",{className:"t2s-group-toggle t2s-folder-row",onClick:()=>{e.onActivateEntry?.(h.key),se?_e(k.key):De(k.key)},children:[Xe(k,se),t.jsx("span",{className:"t2s-group-label",children:bn(k,n)}),V&&t.jsx(qn,{className:"t2o-pin-mark","aria-hidden":"true"})]}),(!k.system||e.onTogglePinned||e.onShowWorkspaceDetails&&Ps(k))&&t.jsx("button",{type:"button",className:"t2s-group-add",title:n("sidebar.ws.menu"),onClick:ce=>vt(ce,k),children:t.jsx(ss,{size:14})}),t.jsx("button",{type:"button",className:"t2s-group-add",title:n("sidebar.newChatIn",{name:bn(k,n)}),onClick:()=>e.onNewInWorkspace(k),children:t.jsx(ts,{size:14})})]}),t.jsx(nr,{open:!se,children:t.jsxs("div",{className:`t2s-group-sessions${We&&!se?" drag-over-end":""}`,...Re,children:[oe.slice(0,z).map(pe),oe.length>z&&t.jsxs("button",{className:"t2s-viewmore",onClick:()=>e.onOpenWorkspace(k.key),children:[n("sidebar.viewMore")," · ",oe.length-z]})]})})]},k.key)}),e.deviceSections,Je&&Ot]}),!Je&&Ot,l&&Ge&&t.jsx(Xs,{className:"ctx-menu",x:l.x,y:l.y,onClick:h=>h.stopPropagation(),children:t.jsx(Zs,{items:q(l)})}),p&&t.jsx(tr,{sessionId:p.id,current:p.current,x:p.x,y:p.y,onClose:()=>f(null)}),C&&zt&&t.jsx(Xs,{className:"ctx-menu",x:C.x,y:C.y,onClick:h=>h.stopPropagation(),children:t.jsx(Zs,{items:ae(C)})}),H&&t.jsx(sr,{title:n("sidebar.ws.removeTitle",{name:H.name}),message:n("sidebar.ws.removeMsg",{count:[...i,...c].filter(h=>h.project_path===H.key).length}),confirmLabel:n("sidebar.ws.removeAction"),filesLabel:H.kind==="local"&&window.tangu?.trashHostPath?n("sidebar.ws.removeFiles"):void 0,onConfirm:h=>e.onRemoveWorkspace(H,{deleteFiles:h}),onClose:()=>Z(null)})]})};xe({"devstatus.checking":{zh:"正在连接…",en:"Connecting…"},"devstatus.ready":{zh:"在线",en:"Online"},"devstatus.starting":{zh:"引擎正在启动",en:"Engine is starting"},"devstatus.engineStopped":{zh:"引擎没有运行",en:"Engine isn't running"},"devstatus.noEngine":{zh:"没有 Agent 引擎",en:"No agent engine"},"devstatus.offline":{zh:"离线",en:"Offline"},"devstatus.unreachable":{zh:"暂时连不上",en:"Can't reach it"},"devstatus.remoteOff":{zh:"未开启远程会话",en:"Remote sessions off"},"devstatus.awaitingConfirm":{zh:"等待那台电脑允许",en:"Waiting for approval there"},"devstatus.denied":{zh:"拒绝了这台手机",en:"Declined this phone"},"devstatus.callerBlocked":{zh:"不允许这台手机运行",en:"Doesn't allow this phone"},"devstatus.long.checking":{zh:"正在连接这台电脑…",en:"Connecting to this computer…"},"devstatus.long.ready":{zh:"在线,可以在上面运行会话",en:"Online. Sessions can run here"},"devstatus.long.starting":{zh:"这台电脑在线,Agent 引擎正在启动",en:"This computer is online and its agent engine is starting"},"devstatus.long.engineStopped":{zh:"Forsion 已打开,但 Agent 引擎没有运行",en:"Forsion is open, but its agent engine isn't running"},"devstatus.long.noEngine":{zh:"这台设备上的 Forsion 没有 Agent 引擎",en:"Forsion on this device has no agent engine"},"devstatus.long.offline":{zh:"离线,重新上线后这里会显示它的会话",en:"Offline. Its sessions show up here when it's back"},"devstatus.long.unreachable":{zh:"暂时连不上,稍后重试",en:"Can't reach it right now. Try again shortly"},"devstatus.long.remoteOff":{zh:"这台电脑没有开启「允许远程会话」",en:"Remote sessions are turned off on this computer"},"devstatus.long.awaitingConfirm":{zh:"请在那台电脑上允许这台手机",en:"Allow this phone on that computer to continue"},"devstatus.long.denied":{zh:"那台电脑拒绝了这台手机",en:"That computer declined this phone"},"devstatus.long.callerBlocked":{zh:"那台电脑不允许这台手机运行会话,请在它的「设置 › 远程会话」中调整",en:"That computer doesn't let this phone run sessions. Change it in Settings › Remote sessions there"},"sidebar.device.label":{zh:"{name} 上的会话",en:"Sessions on {name}"},"sidebar.device.empty":{zh:"还没有会话",en:"No sessions yet"},"sidebar.device.pickFirst":{zh:"在「在哪运行」里选过这台电脑后,这里会显示它的会话",en:"Pick this computer under Run on to see its sessions here"},"sidebar.device.menu":{zh:"更多操作",en:"More actions"}});function Mn(e,n){const a=typeof e=="string"?e.trim():"";return a.length>n?`${a.slice(0,n-1)}…`:a}const ur="forsion_device_sections_collapsed";function Em(){try{const e=JSON.parse(localStorage.getItem(ur)||"[]");return new Set(Array.isArray(e)?e.filter(n=>typeof n=="string").slice(0,200):[])}catch{return new Set}}function Tm(e){try{localStorage.setItem(ur,JSON.stringify([...e]))}catch{}}function Rm({u:e}){return e.icon?t.jsx("span",{className:"t2d-emoji","aria-hidden":!0,children:Mn(e.icon,4)}):e.platform==="win32"||e.platform==="linux"?t.jsx(To,{className:"t2s-lead-icon"}):t.jsx(Ro,{className:"t2s-lead-icon"})}function Eh(e,n){const a=e?.get(n);return a?t.jsx(or,{n:a.n,localOnly:a.localOnly}):null}function dr(){const e=$(n=>n.connState);u.useEffect(()=>{if(!Ft())return;const n=()=>{le.getState().refresh()},a=()=>{le.getState().refresh({periodic:!0})};n();let o=null;const i=()=>{o&&(clearInterval(o),o=null),(typeof document>"u"||document.visibilityState==="visible")&&(o=setInterval(a,3e4))},c=()=>{document.visibilityState==="visible"&&n(),i()};return i(),document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c),o&&clearInterval(o)}},[]),u.useEffect(()=>{e==="ok"&&Ft()&&le.getState().refresh()},[e])}function Th(e){const{t:n}=ze();dr();const a=le(E=>E.units),o=le(E=>E.byUnit);on(E=>E.probes),on(E=>E.sticky);const i=$(E=>E.sessions),c=le(E=>E.selfRegistered),[r,l]=u.useState(Em),[m,p]=u.useState(null),[f,x]=u.useState(null),[b,A]=u.useState(null),[T,z]=u.useState(""),M=u.useRef(null);u.useEffect(()=>{b&&M.current?.select()},[b]),u.useEffect(()=>{if(!m)return;const E=()=>p(null),g=O=>{O.key==="Escape"&&p(null)};return window.addEventListener("click",E),window.addEventListener("contextmenu",E),window.addEventListener("keydown",g),()=>{window.removeEventListener("click",E),window.removeEventListener("contextmenu",E),window.removeEventListener("keydown",g)}},[m]);const U=u.useMemo(()=>{const E={};for(const g of a||[]){const O=g.id.toLowerCase();if(!g.online){E[O]=[];continue}const X=o[O]?.sessions??[],ee=new Set(X.map(C=>C.id)),W=[...i.filter(C=>C.location?.kind==="unit"&&C.location.unitId===O&&!ee.has(C.id)&&!C.archived),...X].sort((C,P)=>rs(P.updated_at)-rs(C.updated_at));E[O]=e.filter?e.filter(W):W}return E},[a,o,i,e.filter]),_=E=>{const g=U[E.unitId]?.find(O=>O.id===E.id);return[{id:"set-icon",label:n("session.icon.set"),icon:t.jsx(Do,{size:13}),run:()=>{x({...E,current:g?.emoji??null}),p(null)}},{id:"rename",label:n("sidebar.rename"),icon:t.jsx(zn,{size:13}),run:()=>{p(null);const O=()=>{z(g?.title||""),A({unitId:E.unitId,id:E.id})};{O();return}}},{id:"archive",label:n("sidebar.archive"),icon:t.jsx(Jn,{size:13}),run:()=>{p(null),fm(E.unitId,E.id)}}]},L=Js(m,()=>m&&{title:ht(Mn(U[m.unitId]?.find(E=>E.id===m.id)?.title,200),n),sections:[{items:_(m)}]},()=>p(null));if(!Ft()||!a?.length)return null;const B=E=>{l(g=>{const O=new Set(g);return O.has(E)?O.delete(E):O.add(E),Tm(O),O})},J=()=>{b&&T.trim()&&hm(b.unitId,b.id,T.trim()),A(null)};return t.jsxs("div",{className:"t2d-sections","data-device-sections":!0,children:[a.map(E=>{const g=E.id.toLowerCase(),O=wa(E).status,X=U[g]??[],ee=r.has(g),Y=Mn(E.name,60)||n("engine.target.defaultName");return t.jsxs("div",{className:"t2d-section","data-device-section":g,"data-device-status":O,children:[t.jsx("div",{className:"t2s-group t2d-head",style:{paddingLeft:$o(0)},title:n(`devstatus.long.${O}`),children:t.jsxs("button",{type:"button",className:"t2s-group-toggle t2s-folder-row t2d-toggle","aria-expanded":!ee,"aria-label":n("sidebar.device.label",{name:Y}),onClick:()=>B(g),children:[t.jsxs("span",{className:"t2s-lead",children:[t.jsx(Rm,{u:E}),t.jsx("span",{className:`t2s-chev t2s-lead-chev${ee?"":" open"}`,children:t.jsx(_t,{size:12})})]}),t.jsx("span",{className:"t2s-group-label t2d-name",children:Y}),t.jsx("span",{className:"t2d-status","data-tone":O==="ready"?"ok":O==="checking"?"wait":"warn",role:"status",children:n(`devstatus.${O}`)})]})}),t.jsx(nr,{open:!ee,children:t.jsxs("div",{className:"t2s-group-sessions",children:[X.map(W=>t.jsx(Lo,{as:b?.id===W.id?"div":"button",className:W.id===e.activeId?"active":void 0,depth:1,title:W.summary||W.title||void 0,lead:t.jsxs(t.Fragment,{children:[t.jsx(ba,{emoji:W.emoji,fallback:t.jsx(cs,{className:"t2s-lead-icon t2s-dim"})}),e.rowBadge?.(W)??(e.runningIds.has(W.id)?t.jsx("span",{className:"t2s-dot running"}):e.unreadIds.has(W.id)?t.jsx("span",{className:"t2s-dot unread"}):null)]}),trailing:b?.id===W.id?void 0:t.jsx("span",{className:"t2s-srow-menu",role:"button","aria-label":n("sidebar.device.menu"),onClick:C=>{C.stopPropagation(),p({unitId:g,id:W.id,x:C.clientX,y:C.clientY})},children:t.jsx(ss,{size:14})}),onClick:()=>{b?.id!==W.id&&ma(W,{unitId:g})},onContextMenu:C=>{C.preventDefault(),C.stopPropagation(),p({unitId:g,id:W.id,x:C.clientX,y:C.clientY})},children:b?.id===W.id?t.jsx("input",{ref:M,className:"t2s-rename",value:T,onChange:C=>z(C.target.value),onBlur:J,onKeyDown:C=>{C.key==="Enter"&&J(),C.key==="Escape"&&A(null)},onClick:C=>C.stopPropagation()}):t.jsx("span",{className:"t2s-srow-title","data-remote-session":W.id,children:ht(Mn(W.title,200),n)})},W.id)),O==="ready"&&!X.length&&t.jsx("div",{className:"t2d-empty",children:n(c===!1?"sidebar.device.pickFirst":"sidebar.device.empty")})]})})]},g)}),m&&L&&t.jsx(Xs,{className:"ctx-menu",x:m.x,y:m.y,onClick:E=>E.stopPropagation(),children:t.jsx(Zs,{items:_(m)})}),f&&t.jsx(tr,{sessionId:f.id,current:f.current,x:f.x,y:f.y,onSave:E=>pm(f.unitId,f.id,E),onClose:()=>x(null)})]})}xe({"runloc.label":{zh:"运行位置",en:"Run on"},"runloc.cloud":{zh:"云端",en:"Cloud"},"runloc.thisDevice":{zh:"这台电脑",en:"This computer"},"runloc.pillTitle":{zh:"新会话在哪运行:{where}",en:"New sessions run on: {where}"}});function Im(){const e=le(n=>n.units);return Ft()&&!!e?.length}function Rh(){const{t:e}=ze();dr();const n=Im(),a=Li(m=>m.ref);Li(m=>m.name),le(m=>m.units),on(m=>m.probes),on(m=>m.sticky);const o=et(m=>m.chooser);if(!n)return null;const i=a.kind==="unit"?Jo(a.unitId):null,c=i?wa(i).status:null,r=a.kind==="unit"?Mn(jl(a)||i?.name,60)||e("engine.target.defaultName"):e("runloc.cloud"),l=a.kind==="home"?tn:i?.platform==="win32"||i?.platform==="linux"?To:Ro;return t.jsx("div",{className:"project-selector runloc","data-run-location-picker":!0,"data-run-location":Xo(a)||"home","data-device-status":c??void 0,children:t.jsxs("button",{type:"button",className:"composer-chip project-pill runloc-pill",title:e("runloc.pillTitle",{where:r}),"aria-label":e("runloc.pillTitle",{where:r}),"aria-haspopup":"dialog",disabled:!o,onClick:()=>o?.(),children:[t.jsx(l,{size:13}),t.jsx("span",{className:"project-pill-name",children:r}),c&&c!=="ready"&&t.jsx("span",{className:"runloc-status","data-tone":c==="checking"?"wait":"warn",children:e(`devstatus.${c}`)}),o&&t.jsx(Rn,{size:12})]})})}export{Ji as $,Ju as A,uh as B,vh as C,bn as D,Ui as E,Jn as F,Fi as G,ht as H,tr as I,ba as J,Xu as K,Sh as L,jh as M,ru as N,Th as O,km as P,Eh as Q,Du as R,Ah as S,zh as T,rs as U,Kn as V,_o as W,Wi as X,Mh as Y,Nh as Z,Ch as _,sh as a,th as a0,eh as a1,Cd as a2,xh as a3,yh as a4,Rh as a5,kh as a6,nr as a7,rd as a8,gh as a9,yd as aa,fu as ab,ph as ac,cd as ad,fh as ae,Qe as af,Im as ag,Au as b,Eu as c,tm as d,Tu as e,ih as f,nh as g,oh as h,wh as i,rh as j,hh as k,Ku as l,dh as m,Wu as n,Ou as o,Ho as p,ah as q,mh as r,bh as s,Fu as t,wu as u,ch as v,ju as w,qo as x,Vu as y,lh as z};
|