agent-tower 0.7.1-beta.4 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime/__tests__/codex-runtime-resolution.test.js +0 -2
- package/dist/runtime/__tests__/codex-runtime-resolution.test.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-B__0_CPX.js → AgentDemoPage-Gr8q6VxC.js} +1 -1
- package/dist/web/assets/{AgentEnvironmentSettingsPage-uSnG5iV3.js → AgentEnvironmentSettingsPage-b0XzUzna.js} +1 -1
- package/dist/web/assets/{AgentLogo-CoAT8dNB.js → AgentLogo-q8Chady2.js} +1 -1
- package/dist/web/assets/{ConversationPage-BOfzGTyj.js → ConversationPage-DQRA8WuD.js} +1 -1
- package/dist/web/assets/CreateTaskInput-Dr6Lvllw.js +1 -0
- package/dist/web/assets/{DemoPage-CuDLCuUQ.js → DemoPage-DaDC_MIJ.js} +1 -1
- package/dist/web/assets/{ExecutionPermissionSelector-Cu7Z72Yk.js → ExecutionPermissionSelector-DglILGVC.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-CmG_TW4-.js → GeneralSettingsPage-BKRf-usO.js} +1 -1
- package/dist/web/assets/{Icons-B6q-ul89.js → Icons-7lThaqQv.js} +1 -1
- package/dist/web/assets/{LoadingPreviewPage-Db5WcYw_.js → LoadingPreviewPage-BHAQCQDA.js} +1 -1
- package/dist/web/assets/{McpSettingsPage-CQV1RaHW.js → McpSettingsPage-CVOEPwCv.js} +1 -1
- package/dist/web/assets/{MemberAvatar-BQA5sE4L.js → MemberAvatar-DUXHTIXf.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-BGKJ6wO0.js → NotificationSettingsPage-DBe1YCNN.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-dTvp-LFa.js → ProfileSettingsPage-DwziCseV.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-Dcz8KXWU.js +86 -0
- package/dist/web/assets/{ProjectSettingsPage-CwLXTwwe.js → ProjectSettingsPage-hzSrj79M.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-Ced1VN2f.js → ProviderSettingsPage-CC3zkdf6.js} +1 -1
- package/dist/web/assets/{SettingsMasterDetail-CEZsOwjq.js → SettingsMasterDetail-D5lNH2f6.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-lErIz31n.js → TeamSettingsPage-Cdbvh2ne.js} +1 -1
- package/dist/web/assets/{arc-CgQPLQJF.js → arc-d2D24uRQ.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-BRns2_cB.js → architectureDiagram-3BPJPVTR-C_p9_AH2.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-DUIPlzPN.js → blockDiagram-GPEHLZMM-CKsR1Tax.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-BfWsGU4R.js → c4Diagram-AAUBKEIU-BBUKt2FW.js} +1 -1
- package/dist/web/assets/channel-D0hF47LU.js +1 -0
- package/dist/web/assets/check-BqhuHtHP.js +1 -0
- package/dist/web/assets/{chevron-down-Dz61D9cJ.js → chevron-down-Bw_76CB_.js} +1 -1
- package/dist/web/assets/{chevron-right-q_hHAFb1.js → chevron-right-DbcFf_Dw.js} +1 -1
- package/dist/web/assets/{chevron-up-ChWM4fJS.js → chevron-up-x1n3MhC-.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-DOverrRX.js → chunk-2J33WTMH-BcGNhDoU.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-BakE7rwb.js → chunk-4BX2VUAB-9dL7TVjW.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-BJY_hqWJ.js → chunk-55IACEB6-CzJzh0tH.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-Bz_y_ixN.js → chunk-727SXJPM-Bp5EOgoG.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-DPrP1E5u.js → chunk-AQP2D5EJ-BaLnh9ac.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4--yjwIi92.js → chunk-FMBD7UC4-BcbzC8r4.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-BlN7Zpnx.js → chunk-ND2GUHAM-DkT5Stbd.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-b97Y7iON.js → chunk-QZHKN3VN-DszScpAV.js} +1 -1
- package/dist/web/assets/{circle-alert-B3BU6yxp.js → circle-alert-ChWS5BPS.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-ulXJsBKw.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ulXJsBKw.js +1 -0
- package/dist/web/assets/{code-block-OCS4YCEC-pXxp6Ipb.js → code-block-OCS4YCEC-G8tEtSdL.js} +1 -1
- package/dist/web/assets/{confirm-dialog-CeNfH2ZR.js → confirm-dialog-0vHzUzvI.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-BE-ASlGZ.js → cose-bilkent-S5V4N54A-DueZsNr5.js} +1 -1
- package/dist/web/assets/{cssMode-B8d06lCF.js → cssMode-Dqx3XDOC.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-lAvNJn8H.js → dagre-BM42HDAG-BkQGrA8s.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-DBgI60j-.js → diagram-2AECGRRQ-D4qtEjjj.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-BqFMhpcI.js → diagram-5GNKFQAL-ZuFk-7GO.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-8dtMJ7XC.js → diagram-KO2AKTUF-kwBr5lw0.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-CEbAGy_U.js → diagram-LMA3HP47-m88-mNyr.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-BTy4Wqho.js → diagram-OG6HWLK6-B9gV1dxA.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-Fe0pjB7H.js → erDiagram-TEJ5UH35-De_DsoOX.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-Cn5xoMyS.js → flowDiagram-I6XJVG4X-9VwLS0b3.js} +1 -1
- package/dist/web/assets/{folder-picker-DlJ9hExj.js → folder-picker-B0khMt7A.js} +1 -1
- package/dist/web/assets/{freemarker2-WBCTYbCf.js → freemarker2-CLp1Yffb.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-Bwf7sOJW.js → ganttDiagram-6RSMTGT7-DoOyYr5i.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DEqHf_N3.js → gitGraphDiagram-PVQCEYII-CMGuTxMz.js} +1 -1
- package/dist/web/assets/{handlebars-aoMw8XNP.js → handlebars-CmLfR6Uy.js} +1 -1
- package/dist/web/assets/{html-mP4L-gn5.js → html-D34UDOLc.js} +1 -1
- package/dist/web/assets/{htmlMode-BRkGssBX.js → htmlMode-qjrvkZFJ.js} +1 -1
- package/dist/web/assets/{index-DxE1UagD.js → index-DI7lHrAR.js} +4 -4
- package/dist/web/assets/{index-_mroLJ3-.js → index-DrzmyANC.js} +8 -8
- package/dist/web/assets/index-MMCbS8_L.css +1 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-BzITBBR6.js → infoDiagram-5YYISTIA-gUCDmQX7.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-Bd9MT4ne.js → ishikawaDiagram-YF4QCWOH-CmfFhhIz.js} +1 -1
- package/dist/web/assets/javascript-D5tp0LcO.js +1 -0
- package/dist/web/assets/{journeyDiagram-JHISSGLW-CR2x5gV0.js → journeyDiagram-JHISSGLW-BvV5GoR_.js} +1 -1
- package/dist/web/assets/{jsonMode-BixD4b0P.js → jsonMode-BbjYNQ7Q.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-DZx-6dHw.js → kanban-definition-UN3LZRKU-BpTm0MC-.js} +1 -1
- package/dist/web/assets/{layers-DOM1D0GC.js → layers-DslPQJ3T.js} +1 -1
- package/dist/web/assets/{linear-BBLqccsD.js → linear-BJ_g8wqu.js} +1 -1
- package/dist/web/assets/{liquid-DGETTZ3q.js → liquid-DBu3_6XS.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-DLBGi3go.js → lspLanguageFeatures-PSX0tqnR.js} +1 -1
- package/dist/web/assets/{mdx-Co95_1jL.js → mdx-Bb4nrA8s.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-K1Nm51AP.js → mermaid-NOHMQCX5-B44shuzc.js} +4 -4
- package/dist/web/assets/{message-square-eTP8tZLX.js → message-square-C-22K3oa.js} +1 -1
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-BuB-92St.js → mindmap-definition-RKZ34NQL-DS5GLydx.js} +1 -1
- package/dist/web/assets/{modal-CSnK65Cb.js → modal-CFVLBZ5p.js} +1 -1
- package/dist/web/assets/{monaco-C17UmdbS.js → monaco-CkaUvvB4.js} +3 -3
- package/dist/web/assets/{pencil-l1-UifOH.js → pencil-DB3VPszm.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5--40xP_i_.js → pieDiagram-4H26LBE5-C1PJJGsh.js} +1 -1
- package/dist/web/assets/{python-CQw9WtC1.js → python-BfodDYt4.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-BxiOfFTG.js → quadrantDiagram-W4KKPZXB-CzDfs-TQ.js} +1 -1
- package/dist/web/assets/{razor-Du_XbZEg.js → razor-DdED1MBH.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-GR0Dtr4T.js → requirementDiagram-4Y6WPE33-qHbU7oZa.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-tWpKambG.js → sankeyDiagram-5OEKKPKP-BfRgrEeN.js} +1 -1
- package/dist/web/assets/{select-DB6L9-KB.js → select-CL78HCY0.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-ByVTWC_r.js → sequenceDiagram-3UESZ5HK-CGTNzKk3.js} +1 -1
- package/dist/web/assets/{server-CrODl9NC.js → server-Cd7APx6v.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-Bd8b6zV5.js → stateDiagram-AJRCARHV-BY1LJ4b7.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BV_JKRZC.js +1 -0
- package/dist/web/assets/{switch-DvXJc47w.js → switch-DmQ0Brgd.js} +1 -1
- package/dist/web/assets/{textarea-CSKljQWP.js → textarea-DOte4pMQ.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-BZhaE4Q8.js → timeline-definition-PNZ67QCA-BBhCKsly.js} +1 -1
- package/dist/web/assets/{trash-2-DdOhDOCv.js → trash-2-BSAHXKfW.js} +1 -1
- package/dist/web/assets/{tsMode-D9Lc5Ctp.js → tsMode-B6rHoWny.js} +1 -1
- package/dist/web/assets/{typescript-jsG0idOk.js → typescript-C2A3q8UY.js} +1 -1
- package/dist/web/assets/{upload-9nN5Lg83.js → upload-e87qV_RH.js} +1 -1
- package/dist/web/assets/{use-profiles-8YJrKR2I.js → use-profiles-Cv2zBJOC.js} +1 -1
- package/dist/web/assets/{use-projects-BdSJ4zPv.js → use-projects-C8WDJXdj.js} +1 -1
- package/dist/web/assets/{use-providers-BlqWIGOP.js → use-providers-CnpIgITQ.js} +1 -1
- package/dist/web/assets/{useNormalizedLogs-B_LoDoiT.js → useNormalizedLogs-AbIXa8s-.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-COnwMBZG.js → vennDiagram-CIIHVFJN-DrDrt_Jg.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-DnIbpfhs.js → wardley-L42UT6IY-CMYQm14y.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-QNFL1GWo.js → wardleyDiagram-YWT4CUSO-COLA9A80.js} +1 -1
- package/dist/web/assets/{xml-C_Zqe3tk.js → xml-D4xDxfjR.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-CW7FVlM3.js → xychartDiagram-2RQKCTM6-BDegkKoT.js} +1 -1
- package/dist/web/assets/{yaml-CETOqGaS.js → yaml-yJExA7tq.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/CreateTaskInput-DwQsAlWX.js +0 -1
- package/dist/web/assets/ProjectKanbanPage-CHZc9WB7.js +0 -92
- package/dist/web/assets/channel-CYUMBIeW.js +0 -1
- package/dist/web/assets/check-C_RQ5zOf.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-KLi01tMF.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-KLi01tMF.js +0 -1
- package/dist/web/assets/index-BoQh7Rhc.css +0 -1
- package/dist/web/assets/javascript-CzeLwCQy.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-A6YN_ZNd.js +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-C17UmdbS.js","assets/index-_mroLJ3-.js","assets/index-BoQh7Rhc.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{aj as bd,ak as mo,al as _d,am as yd,an as Sd,k as Ve,r as b,ao as ue,D as Cs,m as jt,ap as Rs,n as Ht,p as ye,o as vt,q as ce,u as de,j as t,aa as _t,Z as Ia,_ as wd,l as se,a0 as qs,B as Ae,aq as Oa,ar as Ba,as as Fa,ah as js,X as Yt,at as Cn,au as Cd,P as Sr,av as kd,E as Ed,aw as jd,ax as Nd,ay as Rd,T as As,t as ot,V as cs,W as dt,Y as Ws,Q as Be,az as Ts,U as ur,aA as Ad,aB as ui,ai as Td,ad as za,s as Ks,ag as Md,aC as Wa,aD as kn,a6 as Dd,aE as Ha,aF as $a,aG as Ua,aH as qa,aI as Pd,aJ as Ld,a3 as Id,aK as Od,aL as Bd,aM as Fd,$ as po,a9 as go}from"./index-_mroLJ3-.js";import{S as ut,m as on,u as En,A as jn,o as zd,F as Ka,p as Wd,q as Hd,r as $d,Q as Nn,t as Ud,v as Pt,W as bt,w as Va,C as gr,x as zr,y as qd,z as Kd,B as Vd,T as Xd,c as Rt,b as Yr,D as Xa,G as Vt}from"./mermaid-NOHMQCX5-K1Nm51AP.js";import{C as Rn}from"./confirm-dialog-CeNfH2ZR.js";import{c as Ya,a as Ga,b as Qa,I as Za,d as Ja,A as vo,G as el}from"./Icons-B6q-ul89.js";import{e as xo,f as Yd,d as An,S as Gd,u as Tn,A as vr,c as Mn,G as tl,Z as Qd,g as Dn,T as Pn,h as Zd,i as Ln,j as bo,k as Jd,b as sl,l as rl,a as il,m as nl,n as ol,R as al,P as ll,o as Gr,p as eu,C as _o,B as yo}from"./CreateTaskInput-DwQsAlWX.js";import{C as wt}from"./chevron-down-Dz61D9cJ.js";import{C as Tt}from"./chevron-right-q_hHAFb1.js";import{a as tu,F as su,b as ru}from"./folder-picker-DlJ9hExj.js";import{M as hi}from"./message-square-eTP8tZLX.js";import{L as Vs}from"./layers-DOM1D0GC.js";import{P as In,C as iu,u as cl,a as dl,L as Qr,T as Zr}from"./useNormalizedLogs-B_LoDoiT.js";import{a as ts,l as nu,g as ul}from"./ExecutionPermissionSelector-Cu7Z72Yk.js";import{u as Gs}from"./use-providers-BlqWIGOP.js";import{A as fi}from"./AgentLogo-CoAT8dNB.js";import{M as Xt}from"./MemberAvatar-BQA5sE4L.js";import{C as hl}from"./chevron-up-ChWM4fJS.js";import{C as Gt}from"./check-C_RQ5zOf.js";import{M as gs}from"./modal-CSnK65Cb.js";import{S as ds}from"./select-DB6L9-KB.js";import{P as us,T as On}from"./trash-2-DdOhDOCv.js";import{T as ou}from"./textarea-CSKljQWP.js";import{S as an,C as So}from"./server-CrODl9NC.js";import{F as Bn,e as au,d as lu,f as cu,u as du}from"./use-projects-BdSJ4zPv.js";import{U as Jr}from"./upload-9nN5Lg83.js";import{P as uu}from"./pencil-l1-UifOH.js";var hu=class extends bd{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:mo()})}getOptimisticResult(e){return e.behavior=mo(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:x,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,a=x&&n==="forward",h=p&&n==="forward",c=x&&n==="backward",g=p&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:yd(s,r.data),hasPreviousPage:_d(s,r.data),isFetchNextPageError:a,isFetchingNextPage:h,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!a&&!c,isRefetching:m&&!h&&!g}}};function Fn(e,s){return Sd(e,hu)}const fu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],fl=Ve("arrow-right",fu);const mu=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ml=Ve("ban",mu);const pu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gu=Ve("chevron-left",pu);const vu=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],xu=Ve("clipboard-paste",vu);const bu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],hs=Ve("clock-3",bu);const _u=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],mi=Ve("code-xml",_u);const yu=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],wo=Ve("copy-plus",yu);const Su=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],wu=Ve("earth",Su);const Cu=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],pl=Ve("ellipsis-vertical",Cu);const ku=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],Eu=Ve("file-braces-corner",ku);const ju=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],ei=Ve("file-code-corner",ju);const Nu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ru=Ve("file-exclamation-point",Nu);const Au=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],pi=Ve("folder-open",Au);const Tu=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Qs=Ve("git-graph",Tu);const Mu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Xs=Ve("history",Mu);const Du=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],Pu=Ve("maximize",Du);const Lu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Iu=Ve("panel-left-close",Lu);const Ou=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Bu=Ve("panel-left-open",Ou);const Fu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],zu=Ve("panel-right-close",Fu);const Wu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],ln=Ve("panel-right-open",Wu);const Hu=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],$u=Ve("pen-line",Hu);const Uu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ks=Ve("play",Uu);const qu=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],gl=Ve("settings-2",qu);const Ku=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Co=Ve("smartphone",Ku);const Vu=[["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"}]],Wr=Ve("user-plus",Vu);const Xu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Yu=Ve("zoom-in",Xu);const Gu=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Qu=Ve("zoom-out",Gu),gi=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Zs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function zn(e){return"nodeType"in e}function Ct(e){var s,r;return e?Zs(e)?e:zn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Wn(e){const{Document:s}=Ct(e);return e instanceof s}function wr(e){return Zs(e)?!1:e instanceof Ct(e).HTMLElement}function vl(e){return e instanceof Ct(e).SVGElement}function Js(e){return e?Zs(e)?e.document:zn(e)?Wn(e)?e:wr(e)||vl(e)?e.ownerDocument:document:document:document}const ss=gi?b.useLayoutEffect:b.useEffect;function vi(e){const s=b.useRef(e);return ss(()=>{s.current=e}),b.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function Zu(){const e=b.useRef(null),s=b.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function xr(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return ss(()=>{r.current!==e&&(r.current=e)},s),r}function Cr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function ti(e){const s=vi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function si(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Ii={};function xi(e,s){return b.useMemo(()=>{if(s)return s;const r=Ii[e]==null?0:Ii[e]+1;return Ii[e]=r,e+"-"+r},[e,s])}function xl(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,x)=>{const i=Object.entries(x);for(const[n,a]of i){const h=m[n];h!=null&&(m[n]=h+e*a)}return m},{...s})}}const Us=xl(1),ri=xl(-1);function Ju(e){return"clientX"in e&&"clientY"in e}function Hn(e){if(!e)return!1;const{KeyboardEvent:s}=Ct(e.target);return s&&e instanceof s}function eh(e){if(!e)return!1;const{TouchEvent:s}=Ct(e.target);return s&&e instanceof s}function ii(e){if(eh(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return Ju(e)?{x:e.clientX,y:e.clientY}:null}const br=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[br.Translate.toString(e),br.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),ko="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function th(e){return e.matches(ko)?e:e.querySelector(ko)}const sh={display:"none"};function rh(e){let{id:s,value:r}=e;return ue.createElement("div",{id:s,style:sh},r)}function ih(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ue.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function nh(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const bl=b.createContext(null);function oh(e){const s=b.useContext(bl);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function ah(){const[e]=b.useState(()=>new Set),s=b.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[b.useCallback(o=>{let{type:p,event:m}=o;e.forEach(x=>{var i;return(i=x[p])==null?void 0:i.call(x,m)})},[e]),s]}const lh={draggable:`
|
|
3
|
-
To pick up a draggable item, press the space bar.
|
|
4
|
-
While dragging, use the arrow keys to move the item.
|
|
5
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
6
|
-
`},ch={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function dh(e){let{announcements:s=ch,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=lh}=e;const{announce:m,announcement:x}=nh(),i=xi("DndLiveRegion"),[n,a]=b.useState(!1);if(b.useEffect(()=>{a(!0)},[]),oh(b.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:v}=c;s.onDragMove&&m(s.onDragMove({active:g,over:v}))},onDragOver(c){let{active:g,over:v}=c;m(s.onDragOver({active:g,over:v}))},onDragEnd(c){let{active:g,over:v}=c;m(s.onDragEnd({active:g,over:v}))},onDragCancel(c){let{active:g,over:v}=c;m(s.onDragCancel({active:g,over:v}))}}),[m,s])),!n)return null;const h=ue.createElement(ue.Fragment,null,ue.createElement(rh,{id:o,value:p.draggable}),ue.createElement(ih,{id:i,announcement:x}));return r?Cs.createPortal(h,r):h}var ct;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ct||(ct={}));function ni(){}function uh(e,s){return b.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function hh(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return b.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Wt=Object.freeze({x:0,y:0});function fh(e,s){const r=ii(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function mh(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function ph(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function gh(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),x=p-o,i=m-r;if(o<p&&r<m){const n=s.width*s.height,a=e.width*e.height,h=x*i,c=h/(n+a-h);return Number(c.toFixed(4))}return 0}const vh=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:x}=m,i=r.get(x);if(i){const n=gh(i,s);n>0&&p.push({id:x,data:{droppableContainer:m,value:n}})}}return p.sort(mh)};function xh(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function _l(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Wt}function bh(e){return function(r){for(var o=arguments.length,p=new Array(o>1?o-1:0),m=1;m<o;m++)p[m-1]=arguments[m];return p.reduce((x,i)=>({...x,top:x.top+e*i.y,bottom:x.bottom+e*i.y,left:x.left+e*i.x,right:x.right+e*i.x}),{...r})}}const _h=bh(1);function yl(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function yh(e,s,r){const o=yl(s);if(!o)return e;const{scaleX:p,scaleY:m,x,y:i}=o,n=e.left-x-(1-p)*parseFloat(r),a=e.top-i-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),h=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:h,height:c,top:a,right:n+h,bottom:a+c,left:n}}const Sh={ignoreTransform:!1};function kr(e,s){s===void 0&&(s=Sh);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:a,transformOrigin:h}=Ct(e).getComputedStyle(e);a&&(r=yh(r,a,h))}const{top:o,left:p,width:m,height:x,bottom:i,right:n}=r;return{top:o,left:p,width:m,height:x,bottom:i,right:n}}function Eo(e){return kr(e,{ignoreTransform:!0})}function wh(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Ch(e,s){return s===void 0&&(s=Ct(e).getComputedStyle(e)),s.position==="fixed"}function kh(e,s){s===void 0&&(s=Ct(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function $n(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Wn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!wr(p)||vl(p)||r.includes(p))return r;const m=Ct(e).getComputedStyle(p);return p!==e&&kh(p,m)&&r.push(p),Ch(p,m)?r:o(p.parentNode)}return e?o(e):r}function Sl(e){const[s]=$n(e,1);return s??null}function Oi(e){return!gi||!e?null:Zs(e)?e:zn(e)?Wn(e)||e===Js(e).scrollingElement?window:wr(e)?e:null:null}function wl(e){return Zs(e)?e.scrollX:e.scrollLeft}function Cl(e){return Zs(e)?e.scrollY:e.scrollTop}function cn(e){return{x:wl(e),y:Cl(e)}}var ht;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ht||(ht={}));function kl(e){return!gi||!e?!1:e===document.scrollingElement}function El(e){const s={x:0,y:0},r=kl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,x=e.scrollTop>=o.y,i=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:x,isRight:i,maxScroll:o,minScroll:s}}const Eh={x:.2,y:.2};function jh(e,s,r,o,p){let{top:m,left:x,right:i,bottom:n}=r;o===void 0&&(o=10),p===void 0&&(p=Eh);const{isTop:a,isBottom:h,isLeft:c,isRight:g}=El(e),v={x:0,y:0},_={x:0,y:0},w={height:s.height*p.y,width:s.width*p.x};return!a&&m<=s.top+w.height?(v.y=ht.Backward,_.y=o*Math.abs((s.top+w.height-m)/w.height)):!h&&n>=s.bottom-w.height&&(v.y=ht.Forward,_.y=o*Math.abs((s.bottom-w.height-n)/w.height)),!g&&i>=s.right-w.width?(v.x=ht.Forward,_.x=o*Math.abs((s.right-w.width-i)/w.width)):!c&&x<=s.left+w.width&&(v.x=ht.Backward,_.x=o*Math.abs((s.left+w.width-x)/w.width)),{direction:v,speed:_}}function Nh(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:x}=window;return{top:0,left:0,right:m,bottom:x,width:m,height:x}}const{top:s,left:r,right:o,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:p,width:e.clientWidth,height:e.clientHeight}}function jl(e){return e.reduce((s,r)=>Us(s,cn(r)),Wt)}function Rh(e){return e.reduce((s,r)=>s+wl(r),0)}function Ah(e){return e.reduce((s,r)=>s+Cl(r),0)}function Nl(e,s){if(s===void 0&&(s=kr),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);Sl(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Th=[["x",["left","right"],Rh],["y",["top","bottom"],Ah]];class Un{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=$n(r),p=jl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,x,i]of Th)for(const n of x)Object.defineProperty(this,n,{get:()=>{const a=i(o),h=p[m]-a;return this.rect[n]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class hr{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var p;(p=this.target)==null||p.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Mh(e){const{EventTarget:s}=Ct(e);return e instanceof s?e:Js(e)}function Bi(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Dt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Dt||(Dt={}));function jo(e){e.preventDefault()}function Dh(e){e.stopPropagation()}var Ke;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ke||(Ke={}));const Rl={start:[Ke.Space,Ke.Enter],cancel:[Ke.Esc],end:[Ke.Space,Ke.Enter,Ke.Tab]},Ph=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ke.Right:return{...r,x:r.x+25};case Ke.Left:return{...r,x:r.x-25};case Ke.Down:return{...r,y:r.y+25};case Ke.Up:return{...r,y:r.y-25}}};class Al{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new hr(Js(r)),this.windowListeners=new hr(Ct(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Dt.Resize,this.handleCancel),this.windowListeners.add(Dt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Dt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Nl(o),r(Wt)}handleKeyDown(s){if(Hn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=Rl,coordinateGetter:x=Ph,scrollBehavior:i="smooth"}=p,{code:n}=s;if(m.end.includes(n)){this.handleEnd(s);return}if(m.cancel.includes(n)){this.handleCancel(s);return}const{collisionRect:a}=o.current,h=a?{x:a.left,y:a.top}:Wt;this.referenceCoordinates||(this.referenceCoordinates=h);const c=x(s,{active:r,context:o.current,currentCoordinates:h});if(c){const g=ri(c,h),v={x:0,y:0},{scrollableAncestors:_}=o.current;for(const w of _){const l=s.code,{isTop:u,isRight:d,isLeft:f,isBottom:S,maxScroll:C,minScroll:k}=El(w),E=Nh(w),y={x:Math.min(l===Ke.Right?E.right-E.width/2:E.right,Math.max(l===Ke.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(l===Ke.Down?E.bottom-E.height/2:E.bottom,Math.max(l===Ke.Down?E.top:E.top+E.height/2,c.y))},j=l===Ke.Right&&!d||l===Ke.Left&&!f,R=l===Ke.Down&&!S||l===Ke.Up&&!u;if(j&&y.x!==c.x){const P=w.scrollLeft+g.x,M=l===Ke.Right&&P<=C.x||l===Ke.Left&&P>=k.x;if(M&&!g.y){w.scrollTo({left:P,behavior:i});return}M?v.x=w.scrollLeft-P:v.x=l===Ke.Right?w.scrollLeft-C.x:w.scrollLeft-k.x,v.x&&w.scrollBy({left:-v.x,behavior:i});break}else if(R&&y.y!==c.y){const P=w.scrollTop+g.y,M=l===Ke.Down&&P<=C.y||l===Ke.Up&&P>=k.y;if(M&&!g.x){w.scrollTo({top:P,behavior:i});return}M?v.y=w.scrollTop-P:v.y=l===Ke.Down?w.scrollTop-C.y:w.scrollTop-k.y,v.y&&w.scrollBy({top:-v.y,behavior:i});break}}this.handleMove(s,Us(ri(c,this.referenceCoordinates),v))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Al.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Rl,onActivation:p}=s,{active:m}=r;const{code:x}=e.nativeEvent;if(o.start.includes(x)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function No(e){return!!(e&&"distance"in e)}function Ro(e){return!!(e&&"delay"in e)}class qn{constructor(s,r,o){var p;o===void 0&&(o=Mh(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:x}=m;this.props=s,this.events=r,this.document=Js(x),this.documentListeners=new hr(this.document),this.listeners=new hr(o),this.windowListeners=new hr(Ct(x)),this.initialCoordinates=(p=ii(m))!=null?p:Wt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Dt.Resize,this.handleCancel),this.windowListeners.add(Dt.DragStart,jo),this.windowListeners.add(Dt.VisibilityChange,this.handleCancel),this.windowListeners.add(Dt.ContextMenu,jo),this.documentListeners.add(Dt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ro(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(No(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:p}=this.props;p(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Dt.Click,Dh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Dt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:x,options:{activationConstraint:i}}=m;if(!p)return;const n=(r=ii(s))!=null?r:Wt,a=ri(p,n);if(!o&&i){if(No(i)){if(i.tolerance!=null&&Bi(a,i.tolerance))return this.handleCancel();if(Bi(a,i.distance))return this.handleStart()}if(Ro(i)&&Bi(a,i.tolerance))return this.handleCancel();this.handlePending(i,a);return}s.cancelable&&s.preventDefault(),x(n)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===Ke.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const Lh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Kn extends qn{constructor(s){const{event:r}=s,o=Js(r.target);super(s,Lh,o)}}Kn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const Ih={move:{name:"mousemove"},end:{name:"mouseup"}};var dn;(function(e){e[e.RightClick=2]="RightClick"})(dn||(dn={}));class Oh extends qn{constructor(s){super(s,Ih,Js(s.event.target))}}Oh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===dn.RightClick?!1:(o?.({event:r}),!0)}}];const Fi={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Bh extends qn{constructor(s){super(s,Fi)}static setup(){return window.addEventListener(Fi.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Fi.move.name,s)};function s(){}}}Bh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:p}=r;return p.length>1?!1:(o?.({event:r}),!0)}}];var fr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(fr||(fr={}));var oi;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(oi||(oi={}));function Fh(e){let{acceleration:s,activator:r=fr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:x=5,order:i=oi.TreeOrder,pointerCoordinates:n,scrollableAncestors:a,scrollableAncestorRects:h,delta:c,threshold:g}=e;const v=Wh({delta:c,disabled:!m}),[_,w]=Zu(),l=b.useRef({x:0,y:0}),u=b.useRef({x:0,y:0}),d=b.useMemo(()=>{switch(r){case fr.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case fr.DraggableRect:return p}},[r,p,n]),f=b.useRef(null),S=b.useCallback(()=>{const k=f.current;if(!k)return;const E=l.current.x*u.current.x,y=l.current.y*u.current.y;k.scrollBy(E,y)},[]),C=b.useMemo(()=>i===oi.TreeOrder?[...a].reverse():a,[i,a]);b.useEffect(()=>{if(!m||!a.length||!d){w();return}for(const k of C){if(o?.(k)===!1)continue;const E=a.indexOf(k),y=h[E];if(!y)continue;const{direction:j,speed:R}=jh(k,y,d,s,g);for(const P of["x","y"])v[P][j[P]]||(R[P]=0,j[P]=0);if(R.x>0||R.y>0){w(),f.current=k,_(S,x),l.current=R,u.current=j;return}}l.current={x:0,y:0},u.current={x:0,y:0},w()},[s,S,o,w,m,x,JSON.stringify(d),JSON.stringify(v),_,a,C,h,JSON.stringify(g)])}const zh={x:{[ht.Backward]:!1,[ht.Forward]:!1},y:{[ht.Backward]:!1,[ht.Forward]:!1}};function Wh(e){let{delta:s,disabled:r}=e;const o=si(s);return Cr(p=>{if(r||!o||!p)return zh;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[ht.Backward]:p.x[ht.Backward]||m.x===-1,[ht.Forward]:p.x[ht.Forward]||m.x===1},y:{[ht.Backward]:p.y[ht.Backward]||m.y===-1,[ht.Forward]:p.y[ht.Forward]||m.y===1}}},[r,s,o])}function Hh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return Cr(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function $h(e,s){return b.useMemo(()=>e.reduce((r,o)=>{const{sensor:p}=o,m=p.activators.map(x=>({eventName:x.eventName,handler:s(x.handler,o)}));return[...r,...m]},[]),[e,s])}var _r;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(_r||(_r={}));var un;(function(e){e.Optimized="optimized"})(un||(un={}));const Ao=new Map;function Uh(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,x]=b.useState(null),{frequency:i,measure:n,strategy:a}=p,h=b.useRef(e),c=l(),g=xr(c),v=b.useCallback(function(u){u===void 0&&(u=[]),!g.current&&x(d=>d===null?u:d.concat(u.filter(f=>!d.includes(f))))},[g]),_=b.useRef(null),w=Cr(u=>{if(c&&!r)return Ao;if(!u||u===Ao||h.current!==e||m!=null){const d=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const S=f.node.current,C=S?new Un(n(S),S):null;f.rect.current=C,C&&d.set(f.id,C)}return d}return u},[e,m,r,c,n]);return b.useEffect(()=>{h.current=e},[e]),b.useEffect(()=>{c||v()},[r,c]),b.useEffect(()=>{m&&m.length>0&&x(null)},[JSON.stringify(m)]),b.useEffect(()=>{c||typeof i!="number"||_.current!==null||(_.current=setTimeout(()=>{v(),_.current=null},i))},[i,c,v,...o]),{droppableRects:w,measureDroppableContainers:v,measuringScheduled:m!=null};function l(){switch(a){case _r.Always:return!1;case _r.BeforeDragging:return r;default:return!r}}}function Vn(e,s){return Cr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function qh(e,s){return Vn(e,s)}function Kh(e){let{callback:s,disabled:r}=e;const o=vi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function bi(e){let{callback:s,disabled:r}=e;const o=vi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function Vh(e){return new Un(kr(e),e)}function To(e,s,r){s===void 0&&(s=Vh);const[o,p]=b.useState(null);function m(){p(n=>{if(!e)return null;if(e.isConnected===!1){var a;return(a=n??r)!=null?a:null}const h=s(e);return JSON.stringify(n)===JSON.stringify(h)?n:h})}const x=Kh({callback(n){if(e)for(const a of n){const{type:h,target:c}=a;if(h==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),i=bi({callback:m});return ss(()=>{m(),e?(i?.observe(e),x?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),x?.disconnect())},[e]),o}function Xh(e){const s=Vn(e);return _l(e,s)}const Mo=[];function Yh(e){const s=b.useRef(e),r=Cr(o=>e?o&&o!==Mo&&e&&s.current&&e.parentNode===s.current.parentNode?o:$n(e):Mo,[e]);return b.useEffect(()=>{s.current=e},[e]),r}function Gh(e){const[s,r]=b.useState(null),o=b.useRef(e),p=b.useCallback(m=>{const x=Oi(m.target);x&&r(i=>i?(i.set(x,cn(x)),new Map(i)):null)},[]);return b.useEffect(()=>{const m=o.current;if(e!==m){x(m);const i=e.map(n=>{const a=Oi(n);return a?(a.addEventListener("scroll",p,{passive:!0}),[a,cn(a)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),o.current=e}return()=>{x(e),x(m)};function x(i){i.forEach(n=>{const a=Oi(n);a?.removeEventListener("scroll",p)})}},[p,e]),b.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,x)=>Us(m,x),Wt):jl(e):Wt,[e,s])}function Do(e,s){s===void 0&&(s=[]);const r=b.useRef(null);return b.useEffect(()=>{r.current=null},s),b.useEffect(()=>{const o=e!==Wt;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?ri(e,r.current):Wt}function Qh(e){b.useEffect(()=>{if(!gi)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function Zh(e,s){return b.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=x=>{m(x,s)},r},{}),[e,s])}function Tl(e){return b.useMemo(()=>e?wh(e):null,[e])}const Po=[];function Jh(e,s){s===void 0&&(s=kr);const[r]=e,o=Tl(r?Ct(r):null),[p,m]=b.useState(Po);function x(){m(()=>e.length?e.map(n=>kl(n)?o:new Un(s(n),n)):Po)}const i=bi({callback:x});return ss(()=>{i?.disconnect(),x(),e.forEach(n=>i?.observe(n))},[e]),p}function Ml(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return wr(s)?s:e}function ef(e){let{measure:s}=e;const[r,o]=b.useState(null),p=b.useCallback(a=>{for(const{target:h}of a)if(wr(h)){o(c=>{const g=s(h);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=bi({callback:p}),x=b.useCallback(a=>{const h=Ml(a);m?.disconnect(),h&&m?.observe(h),o(h?s(h):null)},[s,m]),[i,n]=ti(x);return b.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const tf=[{sensor:Kn,options:{}},{sensor:Al,options:{}}],sf={current:{}},Vr={draggable:{measure:Eo},droppable:{measure:Eo,strategy:_r.WhileDragging,frequency:un.Optimized},dragOverlay:{measure:kr}};class mr extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const rf={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new mr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ni},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Vr,measureDroppableContainers:ni,windowRect:null,measuringScheduled:!1},Dl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ni,draggableNodes:new Map,over:null,measureDroppableContainers:ni},Er=b.createContext(Dl),Pl=b.createContext(rf);function nf(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new mr}}}function of(e,s){switch(s.type){case ct.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ct.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ct.DragEnd:case ct.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ct.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new mr(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ct.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const x=new mr(e.droppable.containers);return x.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:x}}}case ct.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new mr(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function af(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=b.useContext(Er),m=si(o),x=si(r?.id);return b.useEffect(()=>{if(!s&&!o&&m&&x!=null){if(!Hn(m)||document.activeElement===m.target)return;const i=p.get(x);if(!i)return;const{activatorNode:n,node:a}=i;if(!n.current&&!a.current)return;requestAnimationFrame(()=>{for(const h of[n.current,a.current]){if(!h)continue;const c=th(h);if(c){c.focus();break}}})}},[o,s,p,x,m]),null}function Ll(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function lf(e){return b.useMemo(()=>({draggable:{...Vr.draggable,...e?.draggable},droppable:{...Vr.droppable,...e?.droppable},dragOverlay:{...Vr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function cf(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=b.useRef(!1),{x,y:i}=typeof p=="boolean"?{x:p,y:p}:p;ss(()=>{if(!x&&!i||!s){m.current=!1;return}if(m.current||!o)return;const a=s?.node.current;if(!a||a.isConnected===!1)return;const h=r(a),c=_l(h,o);if(x||(c.x=0),i||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=Sl(a);g&&g.scrollBy({top:c.y,left:c.x})}},[s,x,i,o,r])}const _i=b.createContext({...Wt,scaleX:1,scaleY:1});var ls;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ls||(ls={}));const df=b.memo(function(s){var r,o,p,m;let{id:x,accessibility:i,autoScroll:n=!0,children:a,sensors:h=tf,collisionDetection:c=vh,measuring:g,modifiers:v,..._}=s;const w=b.useReducer(of,void 0,nf),[l,u]=w,[d,f]=ah(),[S,C]=b.useState(ls.Uninitialized),k=S===ls.Initialized,{draggable:{active:E,nodes:y,translate:j},droppable:{containers:R}}=l,P=E!=null?y.get(E):null,M=b.useRef({initial:null,translated:null}),T=b.useMemo(()=>{var ee;return E!=null?{id:E,data:(ee=P?.data)!=null?ee:sf,rect:M}:null},[E,P]),B=b.useRef(null),[I,H]=b.useState(null),[q,A]=b.useState(null),O=xr(_,Object.values(_)),D=xi("DndDescribedBy",x),L=b.useMemo(()=>R.getEnabled(),[R]),K=lf(g),{droppableRects:U,measureDroppableContainers:z,measuringScheduled:W}=Uh(L,{dragging:k,dependencies:[j.x,j.y],config:K.droppable}),$=Hh(y,E),N=b.useMemo(()=>q?ii(q):null,[q]),F=Y(),V=qh($,K.draggable.measure);cf({activeNode:E!=null?y.get(E):null,config:F.layoutShiftCompensation,initialRect:V,measure:K.draggable.measure});const X=To($,K.draggable.measure,V),te=To($?$.parentElement:null),G=b.useRef({activatorEvent:null,active:null,activeNode:$,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),pe=R.getNodeFor((r=G.current.over)==null?void 0:r.id),he=ef({measure:K.dragOverlay.measure}),re=(o=he.nodeRef.current)!=null?o:$,ne=k?(p=he.rect)!=null?p:X:null,le=!!(he.nodeRef.current&&he.rect),Se=Xh(le?null:X),We=Tl(re?Ct(re):null),Ee=Yh(k?pe??$:null),He=Jh(Ee),at=Ll(v,{transform:{x:j.x-Se.x,y:j.y-Se.y,scaleX:1,scaleY:1},activatorEvent:q,active:T,activeNodeRect:X,containerNodeRect:te,draggingNodeRect:ne,over:G.current.over,overlayNodeRect:he.rect,scrollableAncestors:Ee,scrollableAncestorRects:He,windowRect:We}),Me=N?Us(N,j):null,Ne=Gh(Ee),Oe=Do(Ne),Ue=Do(Ne,[X]),qe=Us(at,Oe),De=ne?_h(ne,at):null,Ge=T&&De?c({active:T,collisionRect:De,droppableRects:U,droppableContainers:L,pointerCoordinates:Me}):null,Qe=ph(Ge,"id"),[Te,ge]=b.useState(null),et=le?at:Us(at,Ue),Ye=xh(et,(m=Te?.rect)!=null?m:null,X),$e=b.useRef(null),ft=b.useCallback((ee,ie)=>{let{sensor:ae,options:Ce}=ie;if(B.current==null)return;const ke=y.get(B.current);if(!ke)return;const Pe=ee.nativeEvent,Je=new ae({active:B.current,activeNode:ke,event:Pe,options:Ce,context:G,onAbort(xe){if(!y.get(xe))return;const{onDragAbort:Fe}=O.current,st={id:xe};Fe?.(st),d({type:"onDragAbort",event:st})},onPending(xe,me,Fe,st){if(!y.get(xe))return;const{onDragPending:Nt}=O.current,kt={id:xe,constraint:me,initialCoordinates:Fe,offset:st};Nt?.(kt),d({type:"onDragPending",event:kt})},onStart(xe){const me=B.current;if(me==null)return;const Fe=y.get(me);if(!Fe)return;const{onDragStart:st}=O.current,lt={activatorEvent:Pe,active:{id:me,data:Fe.data,rect:M}};Cs.unstable_batchedUpdates(()=>{st?.(lt),C(ls.Initializing),u({type:ct.DragStart,initialCoordinates:xe,active:me}),d({type:"onDragStart",event:lt}),H($e.current),A(Pe)})},onMove(xe){u({type:ct.DragMove,coordinates:xe})},onEnd:be(ct.DragEnd),onCancel:be(ct.DragCancel)});$e.current=Je;function be(xe){return async function(){const{active:Fe,collisions:st,over:lt,scrollAdjustedTranslate:Nt}=G.current;let kt=null;if(Fe&&Nt){const{cancelDrop:xt}=O.current;kt={activatorEvent:Pe,active:Fe,collisions:st,delta:Nt,over:lt},xe===ct.DragEnd&&typeof xt=="function"&&await Promise.resolve(xt(kt))&&(xe=ct.DragCancel)}B.current=null,Cs.unstable_batchedUpdates(()=>{u({type:xe}),C(ls.Uninitialized),ge(null),H(null),A(null),$e.current=null;const xt=xe===ct.DragEnd?"onDragEnd":"onDragCancel";if(kt){const It=O.current[xt];It?.(kt),d({type:xt,event:kt})}})}}},[y]),tt=b.useCallback((ee,ie)=>(ae,Ce)=>{const ke=ae.nativeEvent,Pe=y.get(Ce);if(B.current!==null||!Pe||ke.dndKit||ke.defaultPrevented)return;const Je={active:Pe};ee(ae,ie.options,Je)===!0&&(ke.dndKit={capturedBy:ie.sensor},B.current=Ce,ft(ae,ie))},[y,ft]),J=$h(h,tt);Qh(h),ss(()=>{X&&S===ls.Initializing&&C(ls.Initialized)},[X,S]),b.useEffect(()=>{const{onDragMove:ee}=O.current,{active:ie,activatorEvent:ae,collisions:Ce,over:ke}=G.current;if(!ie||!ae)return;const Pe={active:ie,activatorEvent:ae,collisions:Ce,delta:{x:qe.x,y:qe.y},over:ke};Cs.unstable_batchedUpdates(()=>{ee?.(Pe),d({type:"onDragMove",event:Pe})})},[qe.x,qe.y]),b.useEffect(()=>{const{active:ee,activatorEvent:ie,collisions:ae,droppableContainers:Ce,scrollAdjustedTranslate:ke}=G.current;if(!ee||B.current==null||!ie||!ke)return;const{onDragOver:Pe}=O.current,Je=Ce.get(Qe),be=Je&&Je.rect.current?{id:Je.id,rect:Je.rect.current,data:Je.data,disabled:Je.disabled}:null,xe={active:ee,activatorEvent:ie,collisions:ae,delta:{x:ke.x,y:ke.y},over:be};Cs.unstable_batchedUpdates(()=>{ge(be),Pe?.(xe),d({type:"onDragOver",event:xe})})},[Qe]),ss(()=>{G.current={activatorEvent:q,active:T,activeNode:$,collisionRect:De,collisions:Ge,droppableRects:U,draggableNodes:y,draggingNode:re,draggingNodeRect:ne,droppableContainers:R,over:Te,scrollableAncestors:Ee,scrollAdjustedTranslate:qe},M.current={initial:ne,translated:De}},[T,$,Ge,De,y,re,ne,U,R,Te,Ee,qe]),Fh({...F,delta:j,draggingRect:De,pointerCoordinates:Me,scrollableAncestors:Ee,scrollableAncestorRects:He});const fe=b.useMemo(()=>({active:T,activeNode:$,activeNodeRect:X,activatorEvent:q,collisions:Ge,containerNodeRect:te,dragOverlay:he,draggableNodes:y,droppableContainers:R,droppableRects:U,over:Te,measureDroppableContainers:z,scrollableAncestors:Ee,scrollableAncestorRects:He,measuringConfiguration:K,measuringScheduled:W,windowRect:We}),[T,$,X,q,Ge,te,he,y,R,U,Te,z,Ee,He,K,W,We]),we=b.useMemo(()=>({activatorEvent:q,activators:J,active:T,activeNodeRect:X,ariaDescribedById:{draggable:D},dispatch:u,draggableNodes:y,over:Te,measureDroppableContainers:z}),[q,J,T,X,u,D,y,Te,z]);return ue.createElement(bl.Provider,{value:f},ue.createElement(Er.Provider,{value:we},ue.createElement(Pl.Provider,{value:fe},ue.createElement(_i.Provider,{value:Ye},a)),ue.createElement(af,{disabled:i?.restoreFocus===!1})),ue.createElement(dh,{...i,hiddenTextDescribedById:D}));function Y(){const ee=I?.autoScrollEnabled===!1,ie=typeof n=="object"?n.enabled===!1:n===!1,ae=k&&!ee&&!ie;return typeof n=="object"?{...n,enabled:ae}:{enabled:ae}}}),uf=b.createContext(null),Lo="button",hf="Draggable";function ff(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=xi(hf),{activators:x,activatorEvent:i,active:n,activeNodeRect:a,ariaDescribedById:h,draggableNodes:c,over:g}=b.useContext(Er),{role:v=Lo,roleDescription:_="draggable",tabIndex:w=0}=p??{},l=n?.id===s,u=b.useContext(l?_i:uf),[d,f]=ti(),[S,C]=ti(),k=Zh(x,s),E=xr(r);ss(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:S,data:E}),()=>{const j=c.get(s);j&&j.key===m&&c.delete(s)}),[c,s]);const y=b.useMemo(()=>({role:v,tabIndex:w,"aria-disabled":o,"aria-pressed":l&&v===Lo?!0:void 0,"aria-roledescription":_,"aria-describedby":h.draggable}),[o,v,w,l,_,h.draggable]);return{active:n,activatorEvent:i,activeNodeRect:a,attributes:y,isDragging:l,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:C,transform:u}}function mf(){return b.useContext(Pl)}const pf="Droppable",gf={timeout:25};function vf(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=xi(pf),{active:x,dispatch:i,over:n,measureDroppableContainers:a}=b.useContext(Er),h=b.useRef({disabled:r}),c=b.useRef(!1),g=b.useRef(null),v=b.useRef(null),{disabled:_,updateMeasurementsFor:w,timeout:l}={...gf,...p},u=xr(w??o),d=b.useCallback(()=>{if(!c.current){c.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{a(Array.isArray(u.current)?u.current:[u.current]),v.current=null},l)},[l]),f=bi({callback:d,disabled:_||!x}),S=b.useCallback((y,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),y&&f.observe(y))},[f]),[C,k]=ti(S),E=xr(s);return b.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),b.useEffect(()=>(i({type:ct.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:E}}),()=>i({type:ct.UnregisterDroppable,key:m,id:o})),[o]),b.useEffect(()=>{r!==h.current.disabled&&(i({type:ct.SetDroppableDisabled,id:o,key:m,disabled:r}),h.current.disabled=r)},[o,m,r,i]),{active:x,rect:g,isOver:n?.id===o,node:C,over:n,setNodeRef:k}}function xf(e){let{animation:s,children:r}=e;const[o,p]=b.useState(null),[m,x]=b.useState(null),i=si(r);return!r&&!o&&i&&p(i),ss(()=>{if(!m)return;const n=o?.key,a=o?.props.id;if(n==null||a==null){p(null);return}Promise.resolve(s(a,m)).then(()=>{p(null)})},[s,o,m]),ue.createElement(ue.Fragment,null,r,o?b.cloneElement(o,{ref:x}):null)}const bf={x:0,y:0,scaleX:1,scaleY:1};function _f(e){let{children:s}=e;return ue.createElement(Er.Provider,{value:Dl},ue.createElement(_i.Provider,{value:bf},s))}const yf={position:"fixed",touchAction:"none"},Sf=e=>Hn(e)?"transform 250ms ease":void 0,wf=b.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:x,rect:i,style:n,transform:a,transition:h=Sf}=e;if(!i)return null;const c=p?a:{...a,scaleX:1,scaleY:1},g={...yf,width:i.width,height:i.height,top:i.top,left:i.left,transform:br.Transform.toString(c),transformOrigin:p&&o?fh(o,i):void 0,transition:typeof h=="function"?h(o):h,...n};return ue.createElement(r,{className:x,style:g,ref:s},m)}),Cf=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:x}=e;if(m!=null&&m.active)for(const[i,n]of Object.entries(m.active))n!==void 0&&(p[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(m!=null&&m.dragOverlay)for(const[i,n]of Object.entries(m.dragOverlay))n!==void 0&&o.node.style.setProperty(i,n);return x!=null&&x.active&&r.node.classList.add(x.active),x!=null&&x.dragOverlay&&o.node.classList.add(x.dragOverlay),function(){for(const[n,a]of Object.entries(p))r.node.style.setProperty(n,a);x!=null&&x.active&&r.node.classList.remove(x.active)}},kf=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:br.Transform.toString(s)},{transform:br.Transform.toString(r)}]},Ef={duration:250,easing:"ease",keyframes:kf,sideEffects:Cf({styles:{active:{opacity:"0"}}})};function jf(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return vi((m,x)=>{if(s===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const a=Ml(x);if(!a)return;const{transform:h}=Ct(x).getComputedStyle(x),c=yl(h);if(!c)return;const g=typeof s=="function"?s:Nf(s);return Nl(n,p.draggable.measure),g({active:{id:m,data:i.data,node:n,rect:p.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:x,rect:p.dragOverlay.measure(a)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function Nf(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...Ef,...e};return m=>{let{active:x,dragOverlay:i,transform:n,...a}=m;if(!s)return;const h={x:i.rect.left-x.rect.left,y:i.rect.top-x.rect.top},c={scaleX:n.scaleX!==1?x.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?x.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-h.x,y:n.y-h.y,...c},v=p({...a,active:x,dragOverlay:i,transform:{initial:n,final:g}}),[_]=v,w=v[v.length-1];if(JSON.stringify(_)===JSON.stringify(w))return;const l=o?.({active:x,dragOverlay:i,...a}),u=i.node.animate(v,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{u.onfinish=()=>{l?.(),d()}})}}let Io=0;function Rf(e){return b.useMemo(()=>{if(e!=null)return Io++,Io},[e])}const Af=ue.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:x,wrapperElement:i="div",className:n,zIndex:a=999}=e;const{activatorEvent:h,active:c,activeNodeRect:g,containerNodeRect:v,draggableNodes:_,droppableContainers:w,dragOverlay:l,over:u,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:S,windowRect:C}=mf(),k=b.useContext(_i),E=Rf(c?.id),y=Ll(x,{activatorEvent:h,active:c,activeNodeRect:g,containerNodeRect:v,draggingNodeRect:l.rect,over:u,overlayNodeRect:l.rect,scrollableAncestors:f,scrollableAncestorRects:S,transform:k,windowRect:C}),j=Vn(g),R=jf({config:o,draggableNodes:_,droppableContainers:w,measuringConfiguration:d}),P=j?l.setRef:void 0;return ue.createElement(_f,null,ue.createElement(xf,{animation:R},c&&E?ue.createElement(wf,{key:E,id:c.id,ref:P,as:i,activatorEvent:h,adjustScale:s,className:n,transition:m,rect:j,style:{zIndex:a,...p},transform:y},r):null))}),Il=768;function Tf(e){const s=window.matchMedia(`(max-width: ${Il-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Mf(){return window.innerWidth<Il}function Df(){return!1}function Ol(){return b.useSyncExternalStore(Tf,Mf,Df)}const Pf=1500,Lf=2e3,If=5e3;function Bl(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?Pf:!1}function Of(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?Lf:!1}function Bf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?If:!1}function Xn(e){return jt({queryKey:ce.workspaces.list(e),queryFn:()=>ye.get(`/tasks/${e}/workspaces`),enabled:!!e})}function Fl(e){const s=vt();return Ht({mutationFn:r=>ye.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ce.workspaces.list(e)}),s.invalidateQueries({queryKey:ce.tasks.all})}})}function zl(){const e=vt();return Ht({mutationFn:({id:s,commitMessage:r,stopActiveServices:o})=>ye.post(`/workspaces/${s}/merge`,{commitMessage:r,stopActiveServices:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all}),e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})},onError:()=>{e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})}})}function Ff(){const e=vt();return Ht({mutationFn:s=>ye.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function Yn(){return Ht({mutationFn:({workspaceId:e,editorType:s})=>ye.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function Gn(e,s={}){const r=Rs(p=>p.visibleContext),o=Of(e,r);return jt({queryKey:ce.workspaces.gitStatus(e),queryFn:()=>ye.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Wl(){const e=vt();return Ht({mutationFn:s=>ye.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function Qn(){const e=vt();return Ht({mutationFn:s=>ye.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function zf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(x=>x.status===ut.RUNNING||x.status===ut.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function Zn({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:x}){const{t:i}=de(),{data:n,isLoading:a}=Xn(m===void 0&&e?o:""),h=m??n,c=m===void 0&&e&&a,g=b.useMemo(()=>zf(h,i),[h,i]);return t.jsx(Rn,{isOpen:e,onClose:s,onConfirm:r,title:i("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((v,_)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:v})]},_))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:x||c})}const _e={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},hn={[_e.Review]:{label:"Review",icon:Ja,iconClass:"text-warning",accentClass:"text-warning"},[_e.Running]:{label:"Running",icon:Za,iconClass:"text-info",accentClass:"text-info"},[_e.Pending]:{label:"Pending",icon:Qa,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[_e.Done]:{label:"Done",icon:Ga,iconClass:"text-success/80",accentClass:"text-success"},[_e.Cancelled]:{label:"Cancelled",icon:Ya,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},Wf=[_e.Review,_e.Running,_e.Pending,_e.Done,_e.Cancelled],Hl=b.createContext(null),Hf=3e4;function $f(e=Hf){const[,s]=b.useState(0);b.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}function Uf(e){const s=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return s<60?_t("{count}s ago",{count:s}):s<3600?_t("{count}m ago",{count:Math.floor(s/60)}):s<86400?_t("{count}h ago",{count:Math.floor(s/3600)}):_t("{count}d ago",{count:Math.floor(s/86400)})}function qf({task:e,status:s,isSelected:r,project:o,onSelectTask:p,onTaskStatusChange:m,onDeleteTask:x,onTaskPriorityChange:i,disableDrag:n}){const{t:a}=de(),h=b.useContext(Hl),c=b.useRef(null),g=!!e.projectArchivedAt,v=g||!!n,{attributes:_,listeners:w,setNodeRef:l,isDragging:u}=ff({id:e.id,data:{task:e,fromStatus:s},disabled:v}),d=b.useCallback(T=>{c.current=T,l(T),h&&(T?h.registry.set(e.id,T):h.registry.delete(e.id))},[l,h,e.id]);b.useEffect(()=>()=>{h?.registry.delete(e.id)},[e.id,h]);const[f,S]=b.useState(null),[C,k]=b.useState(!1),E=b.useRef(null),y=b.useRef(null),j=b.useCallback(T=>{g||!m&&!x&&!i||(T.preventDefault(),S({x:T.clientX,y:T.clientY}))},[g,m,x,i]),R=b.useCallback(()=>{y.current&&(clearTimeout(y.current),y.current=null)},[]),P=b.useCallback(T=>{if(!n||g||!m&&!x)return;const B=T.touches[0];if(!B)return;const{clientX:I,clientY:H}=B;y.current=setTimeout(()=>{y.current=null,S({x:I,y:H})},500)},[n,g,m,x]);b.useEffect(()=>{if(!f)return;const T=B=>{E.current&&!E.current.contains(B.target)&&S(null)};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T)}},[f]);const M=o?o.name:void 0;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d,onClick:()=>p(e.id),onContextMenu:j,onTouchStart:P,onTouchEnd:R,onTouchMove:R,title:M,"aria-label":M?`${e.title} — ${M}`:e.title,className:`flex items-center gap-2.5 ml-4 mr-2 px-2 py-2 rounded-md text-sm text-left transition-colors group animate-task-enter
|
|
7
|
-
${u?"opacity-30":""}
|
|
8
|
-
${r?"bg-accent":"hover:bg-accent/50"}`,...v?{}:w,...v?{}:_,children:[t.jsx("span",{className:"shrink-0 flex items-center",children:(()=>{const{icon:T,iconClass:B}=hn[s];return t.jsx(T,{className:`${B} ${s===_e.Running?"animate-pulse":""}`})})()}),t.jsx("span",{className:`min-w-0 flex-1 truncate ${r?"text-foreground font-medium":"text-foreground/90"}`,children:e.title}),e.priority!==void 0&&e.priority!==on.NORMAL&&t.jsx(xo,{priority:e.priority}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:e.projectRepoDeletedAt?a("源码已删除"):a("已删除")}),e.updatedAt&&t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground/50 tabular-nums",children:Uf(e.updatedAt)}),o&&t.jsx("span",{className:`shrink-0 w-1.5 h-1.5 rounded-full ${o.color.replace("text-","bg-")}`})]}),f&&t.jsxs("div",{ref:E,className:"fixed z-[100] w-44 bg-popover rounded-lg border border-border shadow-lg py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:f.x,top:f.y},children:[m&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:a("Move to")}),Wf.filter(T=>T!==s).map(T=>{const{icon:B,label:I,accentClass:H}=hn[T];return t.jsxs("button",{onClick:()=>{m(e.id,T),S(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(B,{className:`w-3.5 h-3.5 ${H}`}),t.jsx("span",{className:"text-foreground/80",children:a(I)})]},T)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted-foreground/70 uppercase tracking-wider",children:a("Priority")}),Yd.map(T=>t.jsxs("button",{onClick:()=>{i(e.id,T.value),S(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent/50 transition-colors",children:[t.jsx(xo,{priority:T.value}),t.jsxs("span",{className:"text-foreground/80",children:[T.code," · ",a(T.label)]}),e.priority===T.value&&t.jsx("span",{className:"ml-auto text-foreground",children:"✓"})]},T.value))]}),x&&t.jsxs(t.Fragment,{children:[m&&t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{k(!0),S(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),t.jsx("span",{children:a("Delete Task")})]})]})]}),t.jsx(Zn,{isOpen:C,onClose:()=>k(!1),onConfirm:()=>{x?.(e.id),k(!1)},taskId:e.id,taskTitle:e.title})]})}const Kf=b.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:x,projects:i,isDragging:n,dragFromStatus:a,onTaskStatusChange:h,onDeleteTask:c,onTaskPriorityChange:g,disableDrag:v}){const{t:_}=de(),[w,l]=b.useState(p);$f();const u=r.length===0,d=n&&a===o,f=n&&a!==o,{setNodeRef:S,isOver:C}=vf({id:`group-${o}`,data:{status:o}}),k=o===_e.Review,E=_(s),y=n?d&&(w||!0):w;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsxs("button",{onClick:()=>!n&&l(j=>!j),className:"flex items-center gap-1.5 w-full px-4 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors group/header",children:[t.jsx("span",{className:"flex-1 text-left",children:E}),k&&!u?t.jsx("span",{className:"px-1.5 py-0.5 bg-warning/15 text-warning text-[11px] font-semibold rounded-full animate-hop",children:r.length}):t.jsx("span",{className:"text-[11px] text-muted-foreground/50 font-normal tabular-nums",children:r.length}),t.jsx("span",{className:"text-muted-foreground/50",children:y?t.jsx(wt,{size:12}):t.jsx(Tt,{size:12})})]}),f&&t.jsx("div",{ref:S,className:`mx-2 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
|
|
9
|
-
${C?"border-info bg-info/10 text-info":"border-border bg-muted/30 text-muted-foreground/70"}`,children:t.jsx("span",{className:"text-xs font-medium",children:C?_("Drop into {title}",{title:E}):_("Drop here")})}),y&&!f&&t.jsx("div",{ref:d?void 0:S,className:`flex flex-col mt-0.5 min-h-[40px] rounded-md transition-colors
|
|
10
|
-
${C&&!d?"bg-info/10 ring-1 ring-info/30":""}
|
|
11
|
-
${u&&n?"border border-dashed border-border mx-2":""}`,children:u?t.jsx("span",{className:"text-xs text-muted-foreground/50 py-2 px-4",children:_("No tasks")}):r.map(j=>{const R=m===j.id,P=j.projectId?i.find(M=>M.id===j.projectId):void 0;return t.jsx(qf,{task:j,status:o,isSelected:R,project:P,onSelectTask:x,onTaskStatusChange:j.projectArchivedAt?void 0:h,onDeleteTask:j.projectArchivedAt?void 0:c,onTaskPriorityChange:j.projectArchivedAt?void 0:g,disableDrag:v},j.id)})})]})}),Vf=12,Xf=50;function Yf({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=de(),[x,i]=b.useState(""),[n,a]=b.useState(0),h=b.useRef(null);b.useEffect(()=>{e&&(i(""),a(0))},[e]);const c=b.useMemo(()=>{const _=x.trim().toLowerCase();return _?r.filter(w=>w.title.toLowerCase().includes(_)).slice(0,Xf):r.slice(0,Vf)},[r,x]);b.useEffect(()=>{a(0)},[x]),b.useEffect(()=>{h.current?.children[n]?.scrollIntoView({block:"nearest"})},[n]);const g=b.useCallback(_=>{p(_),s()},[p,s]),v=b.useCallback(_=>{if(_.key==="Escape")_.preventDefault(),s();else if(_.key==="ArrowDown")_.preventDefault(),a(w=>Math.min(w+1,c.length-1));else if(_.key==="ArrowUp")_.preventDefault(),a(w=>Math.max(w-1,0));else if(_.key==="Enter"&&!_.nativeEvent.isComposing){_.preventDefault();const w=c[n];w&&g(w.id)}},[s,c,n,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(An,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:x,onChange:_=>i(_.target.value),onKeyDown:v,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!x.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:h,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((_,w)=>{const l=o.find(f=>f.id===_.projectId),{icon:u,iconClass:d}=hn[_.status];return t.jsxs("button",{onClick:()=>g(_.id),onMouseEnter:()=>a(w),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
|
|
12
|
-
${w===n?"bg-accent":""}`,children:[t.jsx(u,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:_.title,children:_.title}),l&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:l.name})]},_.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const Gf=260,Qf=220;function Zf(e){const s={[_e.Review]:[],[_e.Running]:[],[_e.Pending]:[],[_e.Done]:[],[_e.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s[_e.Review].sort((r,o)=>(o.priority??on.NORMAL)-(r.priority??on.NORMAL)),s}const Jf=[{status:_e.Review,title:"Review",defaultOpen:!0},{status:_e.Running,title:"Running",defaultOpen:!0},{status:_e.Pending,title:"Pending",defaultOpen:!1},{status:_e.Done,title:"Done",defaultOpen:!1},{status:_e.Cancelled,title:"Cancelled",defaultOpen:!1}];function Oo({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:x=320,onCreateTask:i,onCreateProject:n,isCreateActive:a,onTaskStatusChange:h,onDeleteTask:c,onTaskPriorityChange:g}){const{t:v}=de(),{preserveDesktopSearch:_}=Ia(),w=Ol(),[l,u]=b.useState(null),[d,f]=b.useState(null),[S,C]=b.useState(!1),k=b.useRef(new Map),E=b.useRef(new Set),y=b.useRef(new Map),j=b.useMemo(()=>({registry:k.current}),[]),R=b.useCallback(L=>{L.remove(),E.current.delete(L)},[]),P=p?e.filter(L=>L.projectId===p):e,M=b.useCallback((L,K)=>{const U=document.querySelector(`[data-task-group-status="${L}"]`);if(!U)return null;const W=(U.querySelector("button")??U).getBoundingClientRect();return W.width===0||W.height===0?null:new DOMRect(W.left+8,W.bottom+4,K.width,K.height)},[]),T=b.useCallback((L,K,U,z=!1)=>{const W=document.createElement("div");W.setAttribute("aria-hidden","true"),W.innerHTML=U;const $=W.firstElementChild;$&&($.style.cssText="",$.className=$.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),$.style.pointerEvents="none",$.style.width=`${L.width}px`,$.style.height=`${L.height}px`,$.style.margin="0",$.style.backgroundColor="var(--sidebar-accent)",$.style.borderRadius="0.375rem",$.style.boxShadow="0 6px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.08)",$.style.opacity="0.96",$.style.transition="none",$.setAttribute("tabindex","-1")),Object.assign(W.style,{position:"fixed",left:`${L.left}px`,top:`${L.top}px`,width:`${L.width}px`,height:`${L.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(W),E.current.add(W);const N=K.left-L.left,F=K.top-L.top;W.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${N}px, ${F}px)`,opacity:z?.12:.96,offset:1}],{duration:z?Qf:Gf,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>R(W),()=>R(W))},[R]);b.useLayoutEffect(()=>{const L=window.matchMedia("(prefers-reduced-motion: reduce)").matches,K=new Map;for(const U of P){const z=k.current.get(U.id);if(!z)continue;const W={status:U.status,rect:z.getBoundingClientRect(),html:z.outerHTML};if(K.set(U.id,W),L)continue;const $=y.current.get(U.id);if(!$||$.status===U.status)continue;const N=W.rect.left-$.rect.left,F=W.rect.top-$.rect.top;Math.abs(N)<1&&Math.abs(F)<1||T($.rect,W.rect,$.html)}if(!L)for(const[U,z]of y.current){if(K.has(U))continue;const W=P.find(N=>N.id===U);if(!W||W.status===z.status)continue;const $=M(W.status,z.rect);$&&T(z.rect,$,z.html,!0)}y.current=K},[P,T,M]),b.useEffect(()=>()=>{for(const L of E.current)L.remove();E.current.clear()},[]);const B=hh(uh(Kn,{activationConstraint:{distance:8}})),I=b.useCallback(L=>{const K=L.active.data.current?.task,U=L.active.data.current?.fromStatus;K&&u(K),U&&f(U)},[]),H=b.useCallback(L=>{u(null),f(null);const{active:K,over:U}=L;if(!U)return;const z=K.data.current?.task,W=K.data.current?.fromStatus,$=U.data.current?.status;!z||!W||!$||z.projectArchivedAt||W!==$&&h?.(z.id,$)},[h]),O=!!!(p?s.find(L=>L.id===p)??null:null)?.archivedAt,D=Zf(P);return t.jsxs("div",{className:"h-full flex flex-col flex-shrink-0",style:{width:x},children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex-shrink-0",children:[n&&t.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:v("New Project"),children:[t.jsx(tu,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:v("New Project")})]}),t.jsxs("button",{onClick:i,disabled:!O,className:`w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm transition-colors disabled:opacity-30 disabled:cursor-not-allowed
|
|
13
|
-
${a?"bg-accent text-foreground":"text-foreground/80 hover:bg-accent/50"}`,title:v(O?"New Task":"Deleted projects are read-only"),children:[t.jsx(Gd,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:v("New Task")})]}),t.jsxs("button",{onClick:()=>C(!0),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:v("Search"),children:[t.jsx(An,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:v("Search")})]}),t.jsxs(wd,{to:_("/conversations"),className:"w-full flex items-center gap-2.5 px-2 py-2 rounded-md text-sm text-foreground/80 hover:bg-accent/50 transition-colors",title:v("对话"),children:[t.jsx(hi,{size:16,className:"text-muted-foreground"}),t.jsx("span",{children:v("对话")})]})]}),P.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 text-center select-none",children:[t.jsx(Vs,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:v("No tasks")}),O&&i?t.jsx("button",{onClick:i,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors",children:v("New Task")}):null]}):t.jsx(Hl.Provider,{value:j,children:t.jsxs(df,{sensors:B,onDragStart:I,onDragEnd:H,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:Jf.map(({status:L,title:K,defaultOpen:U})=>t.jsx(Kf,{title:K,tasks:D[L],status:L,defaultOpen:U,selectedTaskId:r,onSelectTask:o,projects:s,isDragging:l!==null,dragFromStatus:d,onTaskStatusChange:h,onDeleteTask:c,onTaskPriorityChange:g,disableDrag:w},L))}),t.jsx(Af,{dropAnimation:null,children:l?t.jsx("div",{className:"bg-popover shadow-lg rounded-md border border-border px-4 py-2 text-sm max-w-[280px] opacity-90",children:t.jsx("span",{className:"block truncate font-medium text-foreground/80",title:l.title,children:l.title})}):null})]})}),P.length>0?t.jsxs("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:[t.jsx("span",{children:v("{count} tasks",{count:P.length})}),p?t.jsx("button",{onClick:()=>m(null),className:"hover:text-foreground underline decoration-border underline-offset-2",children:v("Clear filter")}):null]}):t.jsx("div",{className:"px-4 py-3 border-t border-border/60 text-xs text-muted-foreground/70 flex items-center justify-between",children:t.jsx("span",{children:v("{count} tasks",{count:0})})}),t.jsx(Yf,{isOpen:S,onClose:()=>C(!1),tasks:P,projects:s,onSelectTask:o})]})}const em=10,tm=24,$l=em*tm,sm=8;function rm(e,s=$l){return e>s+sm}function im(e,s){return e.includes(s)?e:[...e,s]}function nm(e,s){return e.filter(r=>r!==s)}function om(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const yi=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function Bo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function am(e,s=[],r=[]){const o=new Set(r.filter(m=>yi.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!o.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,x)=>{const i=Bo(m.sortTime)-Bo(x.sortTime);return i!==0?i:m.order!==x.order?m.order-x.order:m.key.localeCompare(x.key)})}function lm(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function cm(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function dm(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const x=r[p];return x?`${x} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function um(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function hm({status:e}){const{t:s}=de();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:s(lm(e))})}function fm({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:x,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:a}=de(),[h,c]=b.useState(um),g=b.useMemo(()=>e.filter(_=>yi.has(_.status)).sort((_,w)=>Date.parse(w.updatedAt??w.createdAt??"")-Date.parse(_.updatedAt??_.createdAt??"")),[e]);if(g.length===0)return null;const v=dm(g,a);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(_=>!_),"aria-expanded":h,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:a("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:v})]}),h?t.jsx(wt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(hl,{size:15,className:"shrink-0 text-neutral-400"})]}),h&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(_=>{const w=s.get(_.memberId),l=r.get(_.workRequestId),u=!!(_.sessionId&&o),d=!!w,f=i===_.id,S=m&&x===_.memberId,C=l?.instruction??_.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:se("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",u?"cursor-pointer hover:bg-white":"cursor-default"),role:u?"button":void 0,tabIndex:u?0:void 0,onClick:()=>_.sessionId&&o?.(_.sessionId),onKeyDown:k=>{!u||!_.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(_.sessionId))},children:[t.jsx(Xt,{name:w?.name??a("Agent"),avatar:w?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:w?.name??a("Agent")}),t.jsx("span",{className:se("shrink-0",cm(_.status)),children:t.jsx(hm,{status:_.status})})]}),u&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),_.sessionId&&o?.(_.sessionId)},onKeyDown:k=>k.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:a("View log"),"aria-label":`${a("View log")} ${w?.name??a("Agent")}`,children:t.jsx(ln,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(_.id)},onKeyDown:k=>k.stopPropagation(),disabled:S,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:a("Stop"),"aria-label":`${a("Stop")} ${w?.name??a("Agent")}`,children:t.jsx(qs,{size:12})})]}),d&&f&&w&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:a("Stop running work?")}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:()=>p(w.id,!1),children:[t.jsx(qs,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop only")})]}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:S,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(w.id,!0),children:[t.jsx(ml,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop + clear queue")})]})]})]},_.id)})})]})}const fn=Sr(),mm=240;let Fo=0;function pm(e,s){return Fo+=1,{id:`pending-room-message-${Date.now()}-${Fo}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Ul(e){return"pendingStatus"in e}function gm(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function vm(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function mn(e,s){if(s.length===0)return e;const r=new Set(s.map(vm));return e.split(`
|
|
14
|
-
`).map(o=>{const p=o.match(/^\s*/)?.[0]??"",m=o.trimStart();for(const x of r){if(m===x)return null;if(m.startsWith(`${x} `)||m.startsWith(`${x} `))return`${p}${m.slice(x.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
|
|
15
|
-
`).replace(/\n{3,}/g,`
|
|
16
|
-
|
|
17
|
-
`).trim()}function xm(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function pn(e,s){return e instanceof Error?e.message:s}function bm(e,s=mm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function _m(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function ym(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function zo(e){return e.membershipStatus!=="REMOVED"}function Sm(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function wm(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Cm(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(x=>Sm(x,s)).filter(x=>x&&!o.includes(`@${x}`));if(p.length===0)return o;const m=p.map(x=>`@${x}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${m}`:m}function km(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function Em({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:x}){const i=b.useMemo(()=>m||x?Wd(e):e,[e,x,m]),n=Hd(i),a=b.useMemo(()=>$d({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:x}),[x,p,m,o,r]);return t.jsx("div",{className:se("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",s?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(Nn,{components:a,plugins:n,controls:n?Ud:void 0,children:i})})}function jm({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(x=>x.mimeType.startsWith("image/")),m=new Map(p.map((x,i)=>[x.id,i]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(x=>{const i=`${fn}${x.url}`;if(x.mimeType.startsWith("image/")){const a=m.get(x.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,a),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:x.originalName,children:[t.jsx("img",{src:i,alt:x.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:x.originalName})]},x.id)}return t.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:x.originalName,children:[t.jsx(Ka,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:x.originalName}),t.jsx("span",{className:"text-neutral-400",children:gm(x.sizeBytes)})]}),t.jsx(Cn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},x.id)})})}function Nm({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m,workingDir:x,onOpenWorkspaceFile:i,onOpenPreviewUrl:n,onOpenVisualization:a,downloadSessionId:h}){const c=b.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:g=[],isLoading:v}=zd(c),_=g.length>0?mn(s,g):s;return t.jsxs(t.Fragment,{children:[_.trim()&&t.jsx(Tm,{message:e,content:_,attachments:g,isUser:o,tone:p,workingDir:x,onOpenWorkspaceFile:i,onOpenPreviewUrl:n,onOpenVisualization:a,downloadSessionId:h}),t.jsx(jm,{hasAttachmentIds:c.length>0,attachments:g,isLoading:v,onOpenImage:m})]})}function Rm({images:e,index:s,onClose:r,onSelect:o}){const p=e[s];if(!p)return null;const m=s>0,x=s<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Yt,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>o(s-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(gu,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${fn}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),t.jsxs("a",{href:`${fn}${p.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(Cn,{size:13,"aria-hidden":!0}),"Open"]})]})]}),x&&t.jsx("button",{type:"button",onClick:()=>o(s+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Tt,{size:24,"aria-hidden":!0})})]})}function Am({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const m=[e.trim(),s].filter(Boolean).join(`
|
|
18
|
-
|
|
19
|
-
`);return m?{content:m,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Tm({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent",workingDir:m,onOpenWorkspaceFile:x,onOpenPreviewUrl:i,onOpenVisualization:n,downloadSessionId:a}){const{t:h}=de(),c=b.useId(),g=b.useRef(null),[v,_]=b.useState(null),[w,l]=b.useState(!1),[u,d]=b.useState(null),f=kd(e.teamRunId,e.id,!1),S=f.data?.content,C=S?mn(S,r):void 0,E=!!(C&&C!==s)?C:s,y=!!(e.isTruncated&&!Ul(e)),j=v?.messageId===e.id&&v.content===E&&v.expanded,R=b.useCallback(()=>{const I=g.current;I&&l(rm(I.scrollHeight))},[]);b.useLayoutEffect(()=>{R();const I=g.current;if(!I)return;const H=window.requestAnimationFrame(R),q=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return q?.observe(I),window.addEventListener("resize",R),()=>{window.cancelAnimationFrame(H),q?.disconnect(),window.removeEventListener("resize",R)}},[E,R]);const P=b.useCallback(async()=>{if(d(null),j){_({messageId:e.id,content:E,expanded:!1});return}if(y&&!S){const I=await f.refetch();if(I.error){d(pn(I.error,h("Failed to load full message")));return}const H=I.data?.content?mn(I.data.content,r):E;_({messageId:e.id,content:H,expanded:!0});return}_({messageId:e.id,content:E,expanded:!0})},[r,y,S,f,j,e.id,E,h]),M=(w||y)&&!j,T=w||y,B=f.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:c,ref:g,onLoadCapture:R,className:se("relative transition-[max-height] duration-200 ease-out",M?"overflow-hidden":""),style:M?{maxHeight:$l}:void 0,children:[t.jsx(Em,{content:E,isUser:o,workingDir:m,onOpenWorkspaceFile:x,onOpenPreviewUrl:i,onOpenVisualization:n,downloadSessionId:a}),M&&t.jsx("div",{className:se("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),T&&t.jsxs("button",{type:"button","aria-expanded":j,"aria-controls":c,"aria-label":h(j?"Collapse message":"Expand full message"),disabled:B,onClick:()=>{P()},className:se("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",B?"cursor-wait opacity-70":""),children:[j?t.jsx(hl,{size:13}):t.jsx(wt,{size:13}),t.jsx("span",{children:h(B?"Loading":j?"Collapse message":"Expand full message")})]}),u&&t.jsx("div",{className:se("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:u})]})}function ql({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:x,bubbleClassName:i,isPending:n}){return p?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:m})}):t.jsxs("div",{className:se("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Xt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:se("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:se("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(hs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:xm(r)}),x]}),t.jsx("div",{className:se("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",i,n?"opacity-70":""),children:m})]}),o&&t.jsx(Xt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Mm({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(fi,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Dm({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:x,workingDir:i,onOpenWorkspaceFile:n,onOpenPreviewUrl:a,onOpenVisualization:h,previewWorkspaceId:c,previewSessionId:g}){const{t:v}=de(),_=e.senderType==="user",w=e.senderType==="system",l=Ul(e)?e.pendingStatus:null,u=e.mentions??[],d=e.workRequestIds?.length??0,f=e.visibility==="PRIVATE",S=b.useCallback(y=>{a?.(y,c)},[a,c]),C=b.useCallback(y=>{g&&h?.(g,y,c)},[h,g,c]),k=f?wm(e,p):[],E=t.jsxs(t.Fragment,{children:[!_&&!w&&o&&t.jsx(Mm,{provider:o}),f&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:k.join(", "),children:[t.jsx(Cd,{size:10}),t.jsxs("span",{className:"truncate",children:[v("Private"),k.length>0?`: ${k.join(", ")}`:""]})]}),!w&&d>0&&u.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[v("Work requests"),": ",d]}),l==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:v("发送中...")}),l==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:v("发送失败")})]});return t.jsx(ql,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:_,isSystem:w,headerAddon:E,bubbleClassName:_&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(Nm,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:_&&l!=="failed",tone:w?"system":void 0,onOpenImage:x,workingDir:i,onOpenWorkspaceFile:n,onOpenPreviewUrl:a?S:void 0,onOpenVisualization:h&&g?C:void 0,downloadSessionId:g})})}function Pm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:x}){const{t:i}=de();return t.jsx(ql,{senderName:s?.name??i("Agent"),avatar:s?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(hs,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??bm(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Gt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(Yt,{size:12}),t.jsx("span",{children:i(x?"Rejecting":"Reject")})]})]})]})})}function Kl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:x,compactComposer:i,centered:n,workingDir:a,onOpenWorkspaceFile:h,onOpenPreviewUrl:c,onOpenVisualization:g}){const{t:v}=de(),_=Oa(e.id),w=Ba(e.id),l=Fa(e.id),[u,d]=b.useState(""),[f,S]=b.useState(!1),[C,k]=b.useState(null),[E,y]=b.useState(0),[j,R]=b.useState([]),[P,M]=b.useState(!1),[T,B]=b.useState(null),[I,H]=b.useState([]),[q,A]=b.useState(null),O=b.useRef(null),D=b.useRef(null),{files:L,addFiles:K,removeFile:U,clear:z,restoreFiles:W,buildMarkdownLinks:$,getDoneAttachments:N,isUploading:F}=En(),V=L.some(Y=>Y.status==="done"&&Y.attachment),[X,te]=b.useState(null),{scrollRef:G,contentRef:pe,isAtBottom:he,scrollToBottom:re}=Tn({resize:"smooth",initial:"instant"}),ne=b.useRef(!1),le=b.useRef(null);b.useEffect(()=>{const Y=G.current;if(!Y)return;const ee=ie=>{if(ie.deltaY<0){ne.current=!0;return}ie.deltaY>0&&Y.scrollHeight-Y.scrollTop-Y.clientHeight<=70&&(ne.current=!1)};return Y.addEventListener("wheel",ee,{passive:!0}),()=>Y.removeEventListener("wheel",ee)},[G]);const{data:Se}=Gs(),We=b.useMemo(()=>{const Y=new Map;for(const ee of Se??[])Y.set(ee.provider.id,ee.provider);return Y},[Se]),Ee=b.useMemo(()=>new Map((e.members??[]).map(Y=>[Y.id,Y])),[e.members]),He=b.useMemo(()=>(e.members??[]).filter(zo),[e.members]),at=b.useMemo(()=>new Map((e.invocations??[]).map(Y=>[Y.id,Y])),[e.invocations]),Me=b.useMemo(()=>{const Y=new Set(s.map(ie=>ie.id)),ee=I.filter(ie=>!Y.has(ie.id));return[...s,...ee].sort((ie,ae)=>{const Ce=Date.parse(ie.createdAt??""),ke=Date.parse(ae.createdAt??"");return(Number.isNaN(Ce)?0:Ce)-(Number.isNaN(ke)?0:ke)})},[s,I]),Ne=b.useMemo(()=>new Map((e.workRequests??[]).map(Y=>[Y.id,Y])),[e.workRequests]),Oe=b.useMemo(()=>am(Me,e.workRequests??[],e.invocations??[]),[Me,e.invocations,e.workRequests]);b.useEffect(()=>{const Y=Oe.at(-1)?.key??null,ee=le.current;le.current=Y,!(ee==null||Y==null||Y===ee||ne.current)&&requestAnimationFrame(()=>{re({animation:"smooth",ignoreEscapes:!0})})},[re,Oe]);const Ue=b.useMemo(()=>(e.invocations??[]).filter(Y=>yi.has(Y.status)),[e.invocations]),qe=b.useMemo(()=>j.map(Y=>Ee.get(Y)).filter(Y=>!!Y).filter(zo),[Ee,j]),De=b.useMemo(()=>{const Y=C?.query??"";return He.filter(ee=>ym(ee,Y)).sort((ee,ie)=>{const ae=j.includes(ee.id),Ce=j.includes(ie.id);return ae!==Ce?ae?1:-1:ee.name.localeCompare(ie.name)})},[He,C?.query,j]),Ge=!r&&(f||!!C)&&De.length>0,Qe=b.useCallback((Y,ee)=>{if(ee==null){k(null);return}k(_m(Y,ee)),y(0)},[]),Te=b.useCallback(Y=>{R(ke=>im(ke,Y.id));const ee=`@${Y.name} `;if(C){const ke=`${u.slice(0,C.start)}${ee}${u.slice(C.end)}`,Pe=C.start+ee.length;d(ke),k(null),S(!1),requestAnimationFrame(()=>{O.current?.focus(),O.current?.setSelectionRange(Pe,Pe)});return}const ie=u.length===0||/\s$/.test(u)?"":" ",ae=`${u}${ie}${ee}`,Ce=ae.length;d(ae),S(!1),requestAnimationFrame(()=>{O.current?.focus(),O.current?.setSelectionRange(Ce,Ce)})},[u,C]),ge=b.useCallback(Y=>{R(ee=>nm(ee,Y))},[]),et=b.useCallback(Y=>{const ee=Y.target.value;d(ee),B(null);const ie=Y.target;ie.style.height="auto",ie.style.height=`${Math.max(i?40:72,Math.min(ie.scrollHeight,i?140:240))}px`,S(!1),Qe(ee,ie.selectionStart)},[i,Qe]),Ye=b.useCallback(Y=>{const ee=Y.target.files;ee&&ee.length>0&&(K(Array.from(ee)),B(null)),Y.target.value=""},[K]),$e=b.useCallback(Y=>{const ee=[];for(const ie of Y.clipboardData.items)if(ie.kind==="file"){const ae=ie.getAsFile();ae&&ee.push(ae)}ee.length>0&&(Y.preventDefault(),K(ee),B(null))},[K]),ft=b.useCallback(async()=>{if(r||P||F)return;const Y=$(),ee=N().map(be=>be.id),ie=om(j,He),ae=Am({draft:u,attachmentMarkdown:Y,attachmentIds:ee,mentions:ie});if(!ae||!u.trim()&&!V)return;const Ce=pm(e.id,ae),ke=u,Pe=j,Je=L;H(be=>[...be,Ce]),d(""),R([]),S(!1),k(null),z(),O.current&&(O.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>re()),M(!0),B(null);try{const be=await p(ae);H(xe=>xe.filter(me=>me.id!==Ce.id)),be&&typeof be=="object"&&"id"in be&&requestAnimationFrame(()=>re())}catch(be){const xe=be instanceof Error?be.message:"Failed to send room message";H(me=>me.map(Fe=>Fe.id===Ce.id?{...Fe,pendingStatus:"failed",error:xe}:Fe)),d(me=>me.length===0?ke:me),R(me=>me.length===0?Pe:me),W(Je),B(xe),requestAnimationFrame(()=>re())}finally{M(!1)}},[He,L,$,z,i,u,N,V,P,F,p,r,W,re,j,e.id]),tt=b.useCallback(Y=>{const ee=Y.nativeEvent.isComposing||Y.nativeEvent.keyCode===229;if(Ge){if(Y.key==="ArrowDown"){Y.preventDefault(),y(ie=>(ie+1)%De.length);return}if(Y.key==="ArrowUp"){Y.preventDefault(),y(ie=>(ie-1+De.length)%De.length);return}if(Y.key==="Enter"&&!ee||Y.key==="Tab"){Y.preventDefault();const ie=De[E]??De[0];ie&&Te(ie);return}if(Y.key==="Escape"){Y.preventDefault(),k(null),S(!1);return}}Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!ee&&(Y.preventDefault(),ft())},[Te,ft,E,De,Ge]);b.useEffect(()=>{d(""),R([]),S(!1),k(null),B(null),H([]),z(),ne.current=!1,le.current=null,A(null),O.current&&(O.current.style.height=i?"40px":"72px")},[z,i,e.id]);const J=_.isError?_.error:w.isError?w.error:null,fe=_.isPending||w.isPending,we=b.useCallback((Y,ee)=>{l.mutate({memberId:Y,cancelQueued:ee},{onSuccess:()=>A(null)})},[l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[X&&t.jsx(Rm,{images:X.images,index:X.index,onClose:()=>te(null),onSelect:Y=>te(ee=>ee&&{...ee,index:Y})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:G,className:se("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:pe,className:se(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[Oe.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(js,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:v("No room messages yet")})]}):Oe.map(Y=>{if(Y.kind==="pendingApproval"){const xe=Y.request,me=Ee.get(xe.targetMemberId),Fe=_.isPending&&_.variables===xe.id,st=w.isPending&&w.variables===xe.id;return t.jsx(Pm,{request:xe,member:me,onApprove:()=>_.mutate(xe.id),onReject:()=>w.mutate(xe.id),isActionPending:fe,isApprovePending:Fe,isRejectPending:st},Y.key)}const ee=Y.message,ie=km(ee,Ee,at),ae=ee.senderType==="user"?v("你"):ee.senderType==="system"?v("System"):ie?.name??v("Agent"),Ce=Cm(ee,Ee),ke=ie?.providerId?We.get(ie.providerId)??null:null,Pe=ee.senderInvocationId?at.get(ee.senderInvocationId):void 0,Je=Pe?.workspaceId??void 0,be=Pe?.sessionId??void 0;return t.jsx(Dm,{message:ee,senderName:ae,senderMember:ie,senderProvider:ke,memberById:Ee,displayContent:Ce,onOpenImage:(xe,me)=>te({images:xe,index:me}),workingDir:a,onOpenWorkspaceFile:h,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:Je,previewSessionId:be},Y.key)}),J&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:pn(J,v("Failed to update work request"))}),l.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:pn(l.error,v("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>re(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(vr,{size:14}),t.jsx("span",{children:v("Back to bottom")})]})]}),t.jsx("div",{className:se("shrink-0 border-t border-transparent bg-white",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:se(n&&"max-w-4xl mx-auto"),children:[t.jsx(fm,{invocations:Ue,memberById:Ee,workRequestById:Ne,onViewInvocationSession:m,onStopMember:we,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:q,onToggleStopConfirm:Y=>A(ee=>ee===Y?null:Y)}),!r&&x,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??v("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[Ge&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:v(C?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:De.map((Y,ee)=>{const ie=j.includes(Y.id),ae=ee===E;return t.jsxs("button",{type:"button",onMouseEnter:()=>y(ee),onMouseDown:Ce=>{Ce.preventDefault(),Te(Y)},className:se("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ae?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Xt,{name:Y.name,avatar:Y.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:Y.name}),ie&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:v("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[Y.providerId,Y.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(vo,{size:15,className:"text-neutral-400"})]},Y.id)})})]}),qe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:qe.map(Y=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",Y.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Y.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>ge(Y.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:v("Remove mention"),"aria-label":`${v("Remove mention")} ${Y.name}`,children:t.jsx(Yt,{size:12})})]},Y.id))}),t.jsx(jn,{files:L,onRemove:U}),t.jsx("textarea",{ref:O,value:u,rows:i?1:void 0,onChange:et,onKeyDown:tt,onPaste:$e,onClick:Y=>Qe(u,Y.currentTarget.selectionStart),onSelect:Y=>Qe(u,Y.currentTarget.selectionStart),placeholder:v("Message the team room..."),className:se("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",i?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:i?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:se("flex items-center justify-between",i?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:D,type:"file",multiple:!0,className:"hidden",onChange:Ye}),t.jsx("button",{type:"button",onClick:()=>D.current?.click(),title:v("Upload file"),"aria-label":v("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(In,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{S(Y=>!Y),k(null),requestAnimationFrame(()=>O.current?.focus())},disabled:qe.length===0&&He.length===0,title:v("Mention members"),"aria-label":v("Mention members"),className:se("rounded-lg transition-colors",i?"p-1.5":"p-2",f?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",qe.length===0&&He.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(vo,{size:i?15:18})}),qe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[qe.length," ",v("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{ft()},disabled:r||P||F||!u.trim()&&!V,title:v(F?"Uploading...":P?"发送中...":"发送"),"aria-label":v(F?"Uploading...":P?"发送中...":"发送"),className:se("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(u.trim()||V)&&!r&&!P&&!F?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",P||F?"opacity-70":""),children:t.jsx(Mn,{size:i?15:18})})]}),T&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:T})]})]})})]})}function Lm(e){return e?e.slice(0,8):""}function Wo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function Jn(e){return e?.workspaceKind===bt.MAIN_DIRECTORY}function Ys(e){return e?Jn(e)?"Project directory":e.branchName:"—"}function fs(e){return e?.workingDir||e?.worktreePath||void 0}function eo(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),o=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const x=m.parentWorkspaceId?o.get(m.parentWorkspaceId):void 0,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,n=!!(p&&m.id===p),a=n?"main":m.parentWorkspaceId?"child":"root",h=i?.name??(m.ownerMemberId?`Member ${Lm(m.ownerMemberId)}`:void 0),c=Jn(m)?"Project directory":n?"Main workspace":a==="child"?h?`${h} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:a,roleLabel:n?"Main":a==="child"?"Child":"Root",displayName:c,ownerName:h,parentBranchName:x?Ys(x):void 0,isMain:n}}).sort((m,x)=>{const i=a=>a.kind==="main"?0:a.kind==="child"?1:2,n=i(m)-i(x);return n!==0?n:Wo(m.workspace.createdAt)-Wo(x.workspace.createdAt)})}function Vl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===Pt.ACTIVE)?.id??e[0]?.id}function Xl(e,s){return!e||e.status!==Pt.ACTIVE||Jn(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Yl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const to={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Im=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],Gl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Om=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Ql=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Bm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function ar(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...to},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Bs(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...to,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function zi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...to,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Fm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function zm(e){return{name:e.name.trim(),aliases:Fm(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function Ho(e,s){return e instanceof Error?e.message:s}function $o(e){return e.membershipStatus!=="REMOVED"}function gn(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Uo(e){return gn(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function qo(e){return Gl.find(s=>s.value===e)?.label??e}function Wm(e){return Ql.find(s=>s.value===e)?.label??e}function Kt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Ko({icon:e,title:s,description:r,action:o}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function Hm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=de(),{data:p=[]}=Ed(),{data:m=[]}=Gs(),x=jd(r.id),i=Nd(r.id),n=Rd(r.id),a=b.useRef(!1),[h,c]=b.useState("edit"),[g,v]=b.useState(null),[_,w]=b.useState(""),[l,u]=b.useState(ar()),[d,f]=b.useState(null),[S,C]=b.useState(null),k=r.members??[],E=b.useMemo(()=>k.filter($o),[k]),y=b.useMemo(()=>S&&$o(S)&&!E.some($=>$.id===S.id)?[...E,S]:E,[S,E]),j=g?E.find($=>$.id===g)??null:null,R=S?.id===g?S:j,P=_?p.find($=>$.id===_)??null:null,M=x.isPending||i.isPending||n.isPending,T=y.filter(gn).length,B=b.useMemo(()=>{const $=m.map(({provider:N,availability:F})=>({value:N.id,label:N.name+(F.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(fi,{agentType:N.agentType,className:"size-4"}),disabled:F.type==="NOT_FOUND"}));return l.providerId&&!$.some(N=>N.value===l.providerId)&&$.unshift({value:l.providerId,label:`${l.providerId}${o(" (不可用)")}`,disabled:!0}),$},[l.providerId,m,o]);b.useEffect(()=>{if(!e){a.current=!1,C(null);return}if(a.current)return;a.current=!0;const $=y[0]??null;c($?"edit":"add-preset"),v($?.id??null),w(""),u($?Bs($):ar()),f(null)},[y,e]),b.useEffect(()=>{S&&E.some($=>$.id===S.id)&&C(null)},[S,E]),b.useEffect(()=>{h==="add-preset"&&P&&u(zi(P))},[h,P]);const I=($,N)=>{u(F=>({...F,[$]:N}))},H=($,N)=>{u(F=>({...F,capabilities:{...F.capabilities,[$]:N}}))},q=$=>{c("edit"),v($.id),w(""),u(Bs($))},A=()=>{c("add-preset"),v(null);const $=P??p[0]??null;w($?.id??""),u($?zi($):ar())},O=()=>{c("add-custom"),v(null),w(""),u(ar())},D=!!(l.name.trim()&&l.providerId.trim()&&l.rolePrompt.trim()),L=h==="add-preset"?!!_:h==="edit"?!!(R&&D):D,K=async()=>{try{if(h==="add-preset"){if(!_)return;const N=await x.mutateAsync({memberPresetId:_});ot.success(o("Member added")),C(N),c("edit"),v(N.id),w(""),u(Bs(N));return}const $=zm(l);if(!$.name||!$.providerId||!$.rolePrompt){ot.error(o("Name, provider, and role prompt are required"));return}if(h==="add-custom"){const N=await x.mutateAsync({member:$});ot.success(o("Member added")),C(N),c("edit"),v(N.id),u(Bs(N));return}if(R){const N=await i.mutateAsync({memberId:R.id,data:$});ot.success(o("Member updated")),C(F=>F?.id===N.id?N:F),v(N.id),u(Bs(N))}}catch($){ot.error(Ho($,o("Failed to save member")))}},U=async()=>{if(d)try{if(await n.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const $=y.find(N=>N.id!==d.id)??null;v($?.id??null),c($?"edit":"add-preset"),u($?Bs($):ar())}C($=>$?.id===d.id?null:$),f(null),ot.success(o("Member removed"))}catch($){ot.error(Ho($,o("Failed to remove member")))}},z=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(Wr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:M,children:[t.jsx(wo,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(Ko,{icon:t.jsx(Wr,{size:18}),title:o("No member presets"),description:o("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:O,disabled:M,children:[t.jsx(us,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map($=>{const N=_===$.id;return t.jsxs("button",{type:"button",onClick:()=>{w($.id),u(zi($))},className:se("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Xt,{name:$.name,avatar:$.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:$.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:$.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(qo($.workspacePolicy))," · ",o(Wm($.sessionPolicy))]})]}),N?t.jsx(Gt,{size:16,className:"shrink-0 text-neutral-900"}):null]},$.id)})})})]}),W=()=>{const $=h==="edit";return $&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Ko,{icon:t.jsx(js,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(us,{size:13}),o("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[$?t.jsx(gl,{size:15,className:"text-neutral-500"}):t.jsx(us,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o($?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o($?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),$&&R?t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:()=>f(R),disabled:M,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(On,{size:13}),o("Remove")]}):t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(Wr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[$&&R?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Xt,{name:R.name,avatar:R.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:se("h-2 w-2 shrink-0 rounded-full",Uo(R))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:R.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[R.providerId," · ",o(qo(R.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Name")}),t.jsx("input",{value:l.name,onChange:N=>I("name",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Aliases")}),t.jsx("input",{value:l.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Provider")}),t.jsx(ds,{value:l.providerId,onChange:N=>I("providerId",N),options:B})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Avatar")}),t.jsx("input",{value:l.avatar,onChange:N=>I("avatar",N.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Workspace policy")}),t.jsx(ds,{value:l.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:Gl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Trigger policy")}),t.jsx(ds,{value:l.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:Om.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Session policy")}),t.jsx(ds,{value:l.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:Ql.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Queue policy")}),t.jsx(ds,{value:l.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:Bm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Kt,{children:o("Role prompt")}),t.jsx("textarea",{value:l.rolePrompt,onChange:N=>I("rolePrompt",N.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Kt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Im.map(N=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!l.capabilities[N.key],onChange:F=>H(N.key,F.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(gs,{isOpen:e,onClose:M?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{type:"button",variant:"outline",onClick:s,disabled:M,children:o("Close")}),t.jsx(Ae,{type:"button",onClick:K,disabled:M||!L,children:o(M?"Processing...":h==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(js,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[y.length," ",o("active")," · ",T," ",o("working")]})]}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:M,title:o("Add member"),children:t.jsx(us,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:y.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:o("No active members")}):t.jsx("div",{className:"space-y-1",children:y.map($=>{const N=h==="edit"&&g===$.id;return t.jsxs("button",{type:"button",onClick:()=>q($),className:se("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Xt,{name:$.name,avatar:$.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",Uo($))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:$.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:$.providerId})]}),t.jsx($u,{size:13,className:se("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},$.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:A,disabled:M,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",h==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Wr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:O,disabled:M,className:se("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",h==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(wo,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:h==="add-preset"?z():W()})]})}),t.jsx(Rn,{isOpen:!!d,onClose:()=>f(null),onConfirm:U,title:o("Remove member"),variant:"danger",isLoading:n.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?o("Remove this member from future TeamRun work?"):""}),d&&gn(d)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(As,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const $m=[],Um=[],qm=[],Km=240;function Vm(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const Vo={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Wi(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Xo(e,s){return e instanceof Error?e.message:s}function Xm(e,s=Km){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Hr(e){return e?e.instructionPreview??Xm(e.instruction):""}function Ym(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function Gm(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Qm(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function Zm(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Jm(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function ep(e){switch(e){case Pt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Pt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Pt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Pt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function tp(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function sp(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function rp(e,s){return s.find(r=>r.memberId===e.id&&yi.has(r.status))}function Zl({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=de(),x=Oa(e.id),i=Ba(e.id),n=Fa(e.id),[a,h]=b.useState(null),[c,g]=b.useState(null),[v,_]=b.useState(!1),[w,l]=b.useState(!1),u=e.members??$m,d=b.useMemo(()=>u.filter(I=>I.membershipStatus!=="REMOVED"),[u]),f=e.workRequests??Um,S=e.invocations??qm,C=b.useMemo(()=>eo(s,e),[e,s]),k=b.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),E=b.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),y=b.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,H)=>Date.parse(H.updatedAt??H.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),j=b.useMemo(()=>[...u].map(I=>({member:I,status:Vm(I.status)})).sort((I,H)=>Vo[I.status]-Vo[H.status]),[u]),R=x.isError?x.error:i.isError?i.error:null,P=x.isPending||i.isPending,M=C.find(I=>I.workspace.id===r),T=e.messages??[],B=j.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(Hm,{isOpen:w,onClose:()=>l(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Vs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:m("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Messages"),children:[t.jsx(hi,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:T.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(js,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:B>0?`${B}/${d.length}`:d.length}),B>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),y.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(hs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:y.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(hs,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(hs,{size:13}),t.jsx("span",{children:m("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(I=>{const H=u.find(O=>O.id===I.targetMemberId),q=x.isPending&&x.variables===I.id,A=i.isPending&&i.variables===I.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Xt,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Hr(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(Zm(I.requesterType))}),t.jsx("span",{children:Wi(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>x.mutate(I.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Gt,{size:11}),t.jsx("span",{className:"truncate",children:m(q?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(I.id),disabled:P,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Yt,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"Rejecting":"Reject")})]})]})]},I.id)})}),R&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Xo(R,m("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(js,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>l(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(gl,{size:13})})]}),u.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:j.map(({member:I,status:H})=>{const q=rp(I,S),A=sp(S.filter(W=>W.memberId===I.id)),O=q?k.get(q.workRequestId):void 0,D=c===I.id,L=H==="running"||H==="waiting room reply",K=L&&!!q,U=a===I.id,z=n.isPending&&n.variables?.memberId===I.id;return t.jsxs("div",{className:se("bg-white",D&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Xt,{name:I.name,avatar:I.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:se("h-1.5 w-1.5 shrink-0 rounded-full",Qm(H))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Gm(H)),children:m(Ym(H))})]}),L&&O?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Hr(O)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[K&&t.jsx("button",{type:"button",onClick:()=>h(U?null:I.id),disabled:n.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:m("Stop"),"aria-label":m("Stop"),children:t.jsx(qs,{size:12})}),q?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p(q.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(ln,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(D?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":D,children:D?t.jsx(wt,{size:13}):t.jsx(Tt,{size:13})})]})]}),K&&U&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>h(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(qs,{size:10}),t.jsx("span",{children:z&&n.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>h(null)})},disabled:n.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(ml,{size:10}),t.jsx("span",{children:z&&n.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]}),D&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?m("Resume last session"):m("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(W=>{const $=k.get(W.workRequestId),N=!!(W.sessionId&&p);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:se("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Jm(W.status)),children:W.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Wi(W.updatedAt??W.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Hr($)||W.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>W.sessionId&&p?.(W.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:m("View log"),"aria-label":m("View log"),children:[t.jsx(ln,{size:10}),t.jsx("span",{children:m("Log")})]})]})},W.id)})})]}),j[j.length-1]?.member.id!==I.id&&!D&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),n.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Xo(n.error,m("Failed to stop member work"))})]}),y.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(hs,{size:13}),t.jsx("span",{children:m("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:y.length})]}),t.jsx("div",{className:"space-y-1",children:y.map(I=>{const H=u.find(q=>q.id===I.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Xt,{name:H?.name??"Agent",avatar:H?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:H?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Hr(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Wi(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>_(I=>!I),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":v,"aria-label":m("Workspaces"),children:[t.jsx(Vs,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[M&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:Ys(M.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),v?t.jsx(wt,{size:13,className:"text-neutral-400"}):t.jsx(Tt,{size:13,className:"text-neutral-400"})]})]}),v&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const H=r===I.workspace.id;return t.jsx("div",{className:se("rounded-md border bg-white px-3 py-2",H?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(I.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",tp(I.roleLabel)),children:m(I.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ep(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Ys(I.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[I.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||H,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View workspace"),children:[H?t.jsx(Gt,{size:11}):t.jsx(tl,{size:11}),t.jsx("span",{children:m(H?"Selected":"Select")})]})]})},I.workspace.id)})})]}),E.length===0&&y.length===0&&j.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Hi={exports:{}},Yo;function ip(){return Yo||(Yo=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(x,i,n){var a=this&&this.__decorate||function(f,S,C,k){var E,y=arguments.length,j=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var R=f.length-1;R>=0;R--)(E=f[R])&&(j=(y<3?E(j):y>3?E(S,C,j):E(S,C))||j);return y>3&&j&&Object.defineProperty(S,C,j),j},h=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const c=n(9042),g=n(6114),v=n(9924),_=n(844),w=n(5596),l=n(4725),u=n(3656);let d=i.AccessibilityManager=class extends _.Disposable{constructor(f,S){super(),this._terminal=f,this._renderService=S,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new v.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
20
|
-
`)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new w.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,u.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,_.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let S=0;S<f;S++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
|
|
21
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),g.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,g.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,S){this._liveRegionDebouncer.refresh(f,S,this._terminal.rows)}_renderRows(f,S){const C=this._terminal.buffer,k=C.lines.length.toString();for(let E=f;E<=S;E++){const y=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),R=this._rowElements[E];R&&(y.length===0?R.innerText=" ":R.textContent=y,R.setAttribute("aria-posinset",j),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,S){const C=f.target,k=this._rowElements[S===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(S===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let E,y;if(S===0?(E=C,y=this._rowElements.pop(),this._rowContainer.removeChild(y)):(E=this._rowElements.shift(),y=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),y.removeEventListener("focus",this._bottomBoundaryFocusListener),S===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(S===0?-1:1),this._rowElements[S===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let S=this._rowContainer.children.length;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=a([h(1,l.IRenderService)],d)},3614:(x,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function a(g,v){return v?"\x1B[200~"+g+"\x1B[201~":g}function h(g,v,_,w){g=a(g=n(g),_.decPrivateModes.bracketedPasteMode&&w.rawOptions.ignoreBracketedPasteMode!==!0),_.triggerDataEvent(g,!0),v.value=""}function c(g,v,_){const w=_.getBoundingClientRect(),l=g.clientX-w.left-10,u=g.clientY-w.top-10;v.style.width="20px",v.style.height="20px",v.style.left=`${l}px`,v.style.top=`${u}px`,v.style.zIndex="1000",v.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=a,i.copyHandler=function(g,v){g.clipboardData&&g.clipboardData.setData("text/plain",v.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,v,_,w){g.stopPropagation(),g.clipboardData&&h(g.clipboardData.getData("text/plain"),v,_,w)},i.paste=h,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,v,_,w,l){c(g,v,_),l&&w.rightClickSelect(g),v.value=w.selectionText,v.select()}},7239:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const a=n(1505);i.ColorContrastCache=class{constructor(){this._color=new a.TwoKeyMap,this._css=new a.TwoKeyMap}setCss(h,c,g){this._css.set(h,c,g)}getCss(h,c){return this._css.get(h,c)}setColor(h,c,g){this._color.set(h,c,g)}getColor(h,c){return this._color.get(h,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,a,h,c){n.addEventListener(a,h,c);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(a,h,c))}}}},6465:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const c=n(3656),g=n(8460),v=n(844),_=n(2585);let w=i.Linkifier2=class extends v.Disposable{get currentLink(){return this._currentLink}constructor(l){super(),this._bufferService=l,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,v.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,v.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(l){return this._linkProviders.push(l),{dispose:()=>{const u=this._linkProviders.indexOf(l);u!==-1&&this._linkProviders.splice(u,1)}}}attachToDom(l,u,d){this._element=l,this._mouseService=u,this._renderService=d,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(l){if(this._lastMouseEvent=l,!this._element||!this._mouseService)return;const u=this._positionFromMouseEvent(l,this._element,this._mouseService);if(!u)return;this._isMouseOut=!1;const d=l.composedPath();for(let f=0;f<d.length;f++){const S=d[f];if(S.classList.contains("xterm"))break;if(S.classList.contains("xterm-hover"))return}this._lastBufferCell&&u.x===this._lastBufferCell.x&&u.y===this._lastBufferCell.y||(this._handleHover(u),this._lastBufferCell=u)}_handleHover(l){if(this._activeLine!==l.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(l,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,l)||(this._clearCurrentLink(),this._askForLink(l,!0))}_askForLink(l,u){var d,f;this._activeProviderReplies&&u||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=l.y);let S=!1;for(const[C,k]of this._linkProviders.entries())u?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(S=this._checkLinkProviderResult(C,l,S)):k.provideLinks(l.y,(E=>{var y,j;if(this._isMouseOut)return;const R=E?.map((P=>({link:P})));(y=this._activeProviderReplies)===null||y===void 0||y.set(C,R),S=this._checkLinkProviderResult(C,l,S),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(l.y,this._activeProviderReplies)}))}_removeIntersectingLinks(l,u){const d=new Set;for(let f=0;f<u.size;f++){const S=u.get(f);if(S)for(let C=0;C<S.length;C++){const k=S[C],E=k.link.range.start.y<l?0:k.link.range.start.x,y=k.link.range.end.y>l?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=y;j++){if(d.has(j)){S.splice(C--,1);break}d.add(j)}}}}_checkLinkProviderResult(l,u,d){var f;if(!this._activeProviderReplies)return d;const S=this._activeProviderReplies.get(l);let C=!1;for(let k=0;k<l;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&S){const k=S.find((E=>this._linkAtPosition(E.link,u)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((y=>this._linkAtPosition(y.link,u)));if(E){d=!0,this._handleNewLink(E);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(l){if(!this._element||!this._mouseService||!this._currentLink)return;const u=this._positionFromMouseEvent(l,this._element,this._mouseService);u&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,u)&&this._currentLink.link.activate(l,this._currentLink.link.text)}_clearCurrentLink(l,u){this._element&&this._currentLink&&this._lastMouseEvent&&(!l||!u||this._currentLink.link.range.start.y>=l&&this._currentLink.link.range.end.y<=u)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,v.disposeArray)(this._linkCacheDisposables))}_handleNewLink(l){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const u=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);u&&this._linkAtPosition(l.link,u)&&(this._currentLink=l,this._currentLink.state={decorations:{underline:l.link.decorations===void 0||l.link.decorations.underline,pointerCursor:l.link.decorations===void 0||l.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,l.link,this._lastMouseEvent),l.link.decorations={},Object.defineProperties(l.link.decorations,{pointerCursor:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:d=>{var f,S;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((S=this._element)===null||S===void 0||S.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.underline},set:d=>{var f,S,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(S=this._currentLink)===null||S===void 0?void 0:S.state)===null||C===void 0?void 0:C.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(l.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const f=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,S=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=S&&(this._clearCurrentLink(f,S),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(l,u,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(u,!0),this._currentLink.state.decorations.pointerCursor&&l.classList.add("xterm-cursor-pointer")),u.hover&&u.hover(d,u.text)}_fireUnderlineEvent(l,u){const d=l.range,f=this._bufferService.buffer.ydisp,S=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-f-1,d.end.x,d.end.y-f-1,void 0);(u?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(S)}_linkLeave(l,u,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(u,!1),this._currentLink.state.decorations.pointerCursor&&l.classList.remove("xterm-cursor-pointer")),u.leave&&u.leave(d,u.text)}_linkAtPosition(l,u){const d=l.range.start.y*this._bufferService.cols+l.range.start.x,f=l.range.end.y*this._bufferService.cols+l.range.end.x,S=u.y*this._bufferService.cols+u.x;return d<=S&&S<=f}_positionFromMouseEvent(l,u,d){const f=d.getCoords(l,u,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(l,u,d,f,S){return{x1:l,y1:u,x2:d,y2:f,cols:this._bufferService.cols,fg:S}}};i.Linkifier2=w=a([h(0,_.IBufferService)],w)},9042:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(x,i,n){var a=this&&this.__decorate||function(w,l,u,d){var f,S=arguments.length,C=S<3?l:d===null?d=Object.getOwnPropertyDescriptor(l,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,l,u,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(l,u,C):f(l,u))||C);return S>3&&C&&Object.defineProperty(l,u,C),C},h=this&&this.__param||function(w,l){return function(u,d){l(u,d,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=n(511),g=n(2585);let v=i.OscLinkProvider=class{constructor(w,l,u){this._bufferService=w,this._optionsService=l,this._oscLinkService=u}provideLinks(w,l){var u;const d=this._bufferService.buffer.lines.get(w-1);if(!d)return void l(void 0);const f=[],S=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=d.getTrimmedLength();let E=-1,y=-1,j=!1;for(let R=0;R<k;R++)if(y!==-1||d.hasContent(R)){if(d.loadCell(R,C),C.hasExtendedAttrs()&&C.extended.urlId){if(y===-1){y=R,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else y!==-1&&(j=!0);if(j||y!==-1&&R===k-1){const P=(u=this._oscLinkService.getLinkData(E))===null||u===void 0?void 0:u.uri;if(P){const M={start:{x:y+1,y:w},end:{x:R+(j||R!==k-1?0:1),y:w}};let T=!1;if(!S?.allowNonHttpProtocols)try{const B=new URL(P);["http:","https:"].includes(B.protocol)||(T=!0)}catch{T=!0}T||f.push({text:P,range:M,activate:(B,I)=>S?S.activate(B,I,M):_(0,I),hover:(B,I)=>{var H;return(H=S?.hover)===null||H===void 0?void 0:H.call(S,B,I,M)},leave:(B,I)=>{var H;return(H=S?.leave)===null||H===void 0?void 0:H.call(S,B,I,M)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(y=R,E=C.extended.urlId):(y=-1,E=-1)}}l(f)}};function _(w,l){if(confirm(`Do you want to navigate to ${l}?
|
|
22
|
-
|
|
23
|
-
WARNING: This link could potentially be dangerous`)){const u=window.open();if(u){try{u.opener=null}catch{}u.location.href=l}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=v=a([h(0,g.IBufferService),h(1,g.IOptionsService),h(2,g.IOscLinkService)],v)},6193:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,a){this._parentWindow=n,this._renderCallback=a,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,a,h){this._rowCount=h,n=n!==void 0?n:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const n=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,a),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const a=n(844);class h extends a.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,a.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}i.ScreenDprMonitor=h},3236:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const a=n(3614),h=n(3656),c=n(6465),g=n(9042),v=n(3730),_=n(1680),w=n(3107),l=n(5744),u=n(2950),d=n(1296),f=n(428),S=n(4269),C=n(5114),k=n(8934),E=n(3230),y=n(9312),j=n(4725),R=n(6731),P=n(8055),M=n(8969),T=n(8460),B=n(844),I=n(6114),H=n(8437),q=n(2584),A=n(7399),O=n(5941),D=n(9074),L=n(2585),K=n(5435),U=n(4567),z=typeof window<"u"?window.document:null;class W extends M.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new B.MutableDisposable),this._onCursorMove=this.register(new T.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new T.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new T.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new T.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new T.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new T.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new T.EventEmitter),this._onBlur=this.register(new T.EventEmitter),this._onA11yCharEmitter=this.register(new T.EventEmitter),this._onA11yTabEmitter=this.register(new T.EventEmitter),this._onWillOpen=this.register(new T.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(v.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(D.DecorationService),this._instantiationService.setService(L.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,V)=>this.refresh(F,V)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),this.register((0,T.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,T.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,T.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,T.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((F=>this._afterResize(F.cols,F.rows)))),this.register((0,B.toDisposable)((()=>{var F,V;this._customKeyEventHandler=void 0,(V=(F=this.element)===null||F===void 0?void 0:F.parentNode)===null||V===void 0||V.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const F of N){let V,X="";switch(F.index){case 256:V="foreground",X="10";break;case 257:V="background",X="11";break;case 258:V="cursor",X="12";break;default:V="ansi",X="4;"+F.index}switch(F.type){case 0:const te=P.color.toColorRGB(V==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[V]);this.coreService.triggerDataEvent(`${q.C0.ESC}]${X};${(0,O.toRgbString)(te)}${q.C1_ESCAPED.ST}`);break;case 1:if(V==="ansi")this._themeService.modifyColors((G=>G.ansi[F.index]=P.rgba.toColor(...F.color)));else{const G=V;this._themeService.modifyColors((pe=>pe[G]=P.rgba.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(q.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const N=this.buffer.ybase+this.buffer.y,F=this.buffer.lines.get(N);if(!F)return;const V=Math.min(this.buffer.x,this.cols-1),X=this._renderService.dimensions.css.cell.height,te=F.getWidth(V),G=this._renderService.dimensions.css.cell.width*te,pe=this.buffer.y*this._renderService.dimensions.css.cell.height,he=V*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=pe+"px",this.textarea.style.width=G+"px",this.textarea.style.height=X+"px",this.textarea.style.lineHeight=X+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,h.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,a.copyHandler)(F,this._selectionService)})));const N=F=>(0,a.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,h.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,h.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,a.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,h.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,a.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,h.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,a.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,h.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,h.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var F;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const V=z.createDocumentFragment();this._viewportElement=z.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),V.appendChild(this._viewportElement),this._viewportScrollArea=z.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=z.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=z.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),V.appendChild(this.screenElement),this.textarea=z.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(C.CoreBrowserService,this.textarea,(F=this._document.defaultView)!==null&&F!==void 0?F:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,h.addDisposableDomListener)(this.textarea,"focus",(X=>this._handleTextAreaFocus(X)))),this.register((0,h.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(S.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((X=>this._onRender.fire(X)))),this.onResize((X=>this._renderService.resize(X.cols,X.rows))),this._compositionView=z.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(u.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(V);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(j.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(_.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((X=>this.scrollLines(X.amount,X.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(y.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((X=>this.scrollLines(X.amount,X.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((X=>this._renderService.handleSelectionChanged(X.start,X.end,X.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((X=>{this.textarea.value=X,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((X=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,h.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(w.BufferDecorationRenderer,this.screenElement)),this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(X=>this._selectionService.handleMouseDown(X)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(U.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(X=>this._handleScreenReaderModeOptionChange(X)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(X=>{!this._overviewRulerRenderer&&X&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,F=this.element;function V(G){const pe=N._mouseService.getMouseReportCoords(G,N.screenElement);if(!pe)return!1;let he,re;switch(G.overrideType||G.type){case"mousemove":re=32,G.buttons===void 0?(he=3,G.button!==void 0&&(he=G.button<3?G.button:3)):he=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":re=0,he=G.button<3?G.button:3;break;case"mousedown":re=1,he=G.button<3?G.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(G)===0)return!1;re=G.deltaY<0?0:1,he=4;break;default:return!1}return!(re===void 0||he===void 0||he>4)&&N.coreMouseService.triggerMouseEvent({col:pe.col,row:pe.row,x:pe.x,y:pe.y,button:he,action:re,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const X={mouseup:null,wheel:null,mousedrag:null,mousemove:null},te={mouseup:G=>(V(G),G.buttons||(this._document.removeEventListener("mouseup",X.mouseup),X.mousedrag&&this._document.removeEventListener("mousemove",X.mousedrag)),this.cancel(G)),wheel:G=>(V(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&V(G)},mousemove:G=>{G.buttons||V(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&G?X.mousemove||(F.addEventListener("mousemove",te.mousemove),X.mousemove=te.mousemove):(F.removeEventListener("mousemove",X.mousemove),X.mousemove=null),16&G?X.wheel||(F.addEventListener("wheel",te.wheel,{passive:!1}),X.wheel=te.wheel):(F.removeEventListener("wheel",X.wheel),X.wheel=null),2&G?X.mouseup||(F.addEventListener("mouseup",te.mouseup),X.mouseup=te.mouseup):(this._document.removeEventListener("mouseup",X.mouseup),F.removeEventListener("mouseup",X.mouseup),X.mouseup=null),4&G?X.mousedrag||(X.mousedrag=te.mousedrag):(this._document.removeEventListener("mousemove",X.mousedrag),X.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,h.addDisposableDomListener)(F,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return V(G),X.mouseup&&this._document.addEventListener("mouseup",X.mouseup),X.mousedrag&&this._document.addEventListener("mousemove",X.mousedrag),this.cancel(G)}))),this.register((0,h.addDisposableDomListener)(F,"wheel",(G=>{if(!X.wheel){if(!this.buffer.hasScrollback){const pe=this.viewport.getLinesScrolled(G);if(pe===0)return;const he=q.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let re="";for(let ne=0;ne<Math.abs(pe);ne++)re+=he;return this.coreService.triggerDataEvent(re,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,h.addDisposableDomListener)(F,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,h.addDisposableDomListener)(F,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(N,F){var V;(V=this._renderService)===null||V===void 0||V.refreshRows(N,F)}updateCursorStyle(N){var F;!((F=this._selectionService)===null||F===void 0)&&F.shouldColumnSelect(N)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(N,F,V=0){var X;V===1?(super.scrollLines(N,F,V),this.refresh(0,this.rows-1)):(X=this.viewport)===null||X===void 0||X.scrollLines(N)}paste(N){(0,a.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const F=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),F}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,F,V){this._selectionService.setSelection(N,F,V)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,F){var V;(V=this._selectionService)===null||V===void 0||V.selectLines(N,F)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!F&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const V=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),V.type===3||V.type===2){const X=this.rows-1;return this.scrollLines(V.type===2?-X:X),this.cancel(N,!0)}return V.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(V.cancel&&this.cancel(N,!0),!V.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(V.key!==q.C0.ETX&&V.key!==q.C0.CR||(this.textarea.value=""),this._onKey.fire({key:V.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(V.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,F){const V=N.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||N.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||N.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?V:V&&(!F.keyCode||F.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)F=N.charCode;else if(N.which===null||N.which===void 0)F=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;F=N.which}return!(!F||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(F,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const F=N.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(N),!0}return!1}resize(N,F){N!==this.cols||F!==this.rows?super.resize(N,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,F){var V,X;(V=this._charSizeService)===null||V===void 0||V.measure(),(X=this.viewport)===null||X===void 0||X.syncScrollArea(!0)}clear(){var N;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(H.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,F;this.options.rows=this.rows,this.options.cols=this.cols;const V=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(F=this.viewport)===null||F===void 0||F.reset(),this._customKeyEventHandler=V,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent(q.C0.ESC+"[I"):this.coreService.triggerDataEvent(q.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case K.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),V=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${q.C0.ESC}[4;${V};${F}t`);break;case K.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const X=this._renderService.dimensions.css.cell.width.toFixed(0),te=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${q.C0.ESC}[6;${te};${X}t`)}}cancel(N,F){if(this.options.cancelEvents||F)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=W},9924:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,a=1e3){this._renderCallback=n,this._debounceThresholdMS=a,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,a,h){this._rowCount=h,n=n!==void 0?n:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,v=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),v)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,a)}}},1680:function(x,i,n){var a=this&&this.__decorate||function(u,d,f,S){var C,k=arguments.length,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,d,f,S);else for(var y=u.length-1;y>=0;y--)(C=u[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},h=this&&this.__param||function(u,d){return function(f,S){d(f,S,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const c=n(3656),g=n(4725),v=n(8460),_=n(844),w=n(2585);let l=i.Viewport=class extends _.Disposable{constructor(u,d,f,S,C,k,E,y){super(),this._viewportElement=u,this._scrollArea=d,this._bufferService=f,this._optionsService=S,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new v.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(y.colors),this.register(y.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(u){this._viewportElement.style.backgroundColor=u.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(u){if(u)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const u=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==u&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=u),this._refreshAnimationFrame=null}syncScrollArea(u=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(u);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(u)}_handleScroll(u){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const u=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(u*(this._smoothScrollState.target-this._smoothScrollState.origin)),u<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(u,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(u.cancelable&&u.preventDefault(),!1)}handleWheel(u){const d=this._getPixelsScrolled(u);return d!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(u,d))}scrollLines(u){if(u!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=u*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:u,suppressScrollEvent:!1})}_getPixelsScrolled(u){if(u.deltaY===0||u.shiftKey)return 0;let d=this._applyScrollModifier(u.deltaY,u);return u.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:u.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(u,d){var f;let S,C="";const k=[],E=d??this._bufferService.buffer.lines.length,y=this._bufferService.buffer.lines;for(let j=u;j<E;j++){const R=y.get(j);if(!R)continue;const P=(f=y.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=R.translateToString(!P),!P||j===y.length-1){const M=document.createElement("div");M.textContent=C,k.push(M),C.length>0&&(S=M),C=""}}return{bufferElements:k,cursorElement:S}}getLinesScrolled(u){if(u.deltaY===0||u.shiftKey)return 0;let d=this._applyScrollModifier(u.deltaY,u);return u.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):u.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(u,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?u*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:u*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(u){this._lastTouchY=u.touches[0].pageY}handleTouchMove(u){const d=this._lastTouchY-u.touches[0].pageY;return this._lastTouchY=u.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(u,d))}};i.Viewport=l=a([h(2,w.IBufferService),h(3,w.IOptionsService),h(4,g.ICharSizeService),h(5,g.IRenderService),h(6,g.ICoreBrowserService),h(7,g.IThemeService)],l)},3107:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const c=n(3656),g=n(4725),v=n(844),_=n(2585);let w=i.BufferDecorationRenderer=class extends v.Disposable{constructor(l,u,d,f){super(),this._screenElement=l,this._bufferService=u,this._decorationService=d,this._renderService=f,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,c.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((S=>this._removeDecoration(S)))),this.register((0,v.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const l of this._decorationService.decorations)this._renderDecoration(l);this._dimensionsChanged=!1}_renderDecoration(l){this._refreshStyle(l),this._dimensionsChanged&&this._refreshXPosition(l)}_createElement(l){var u,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((u=l?.options)===null||u===void 0?void 0:u.layer)==="top"),f.style.width=`${Math.round((l.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(l.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(l.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=(d=l.options.x)!==null&&d!==void 0?d:0;return S&&S>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(l,f),f}_refreshStyle(l){const u=l.marker.line-this._bufferService.buffers.active.ydisp;if(u<0||u>=this._bufferService.rows)l.element&&(l.element.style.display="none",l.onRenderEmitter.fire(l.element));else{let d=this._decorationElements.get(l);d||(d=this._createElement(l),l.element=d,this._decorationElements.set(l,d),this._container.appendChild(d),l.onDispose((()=>{this._decorationElements.delete(l),d.remove()}))),d.style.top=u*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",l.onRenderEmitter.fire(d)}}_refreshXPosition(l,u=l.element){var d;if(!u)return;const f=(d=l.options.x)!==null&&d!==void 0?d:0;(l.options.anchor||"left")==="right"?u.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":u.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(l){var u;(u=this._decorationElements.get(l))===null||u===void 0||u.remove(),this._decorationElements.delete(l),l.dispose()}};i.BufferDecorationRenderer=w=a([h(1,_.IBufferService),h(2,_.IDecorationService),h(3,g.IRenderService)],w)},5871:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(n){if(n.options.overviewRulerOptions){for(const a of this._zones)if(a.color===n.options.overviewRulerOptions.color&&a.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(a,n.marker.line))return;if(this._lineAdjacentToZone(a,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(a,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,a){return a>=n.startBufferLine&&a<=n.endBufferLine}_lineAdjacentToZone(n,a,h){return a>=n.startBufferLine-this._linePadding[h||"full"]&&a<=n.endBufferLine+this._linePadding[h||"full"]}_addLineToZone(n,a){n.startBufferLine=Math.min(n.startBufferLine,a),n.endBufferLine=Math.max(n.endBufferLine,a)}}},5744:function(x,i,n){var a=this&&this.__decorate||function(S,C,k,E){var y,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,E);else for(var P=S.length-1;P>=0;P--)(y=S[P])&&(R=(j<3?y(R):j>3?y(C,k,R):y(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},h=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const c=n(5871),g=n(3656),v=n(4725),_=n(844),w=n(2585),l={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=i.OverviewRulerRenderer=class extends _.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(S,C,k,E,y,j,R){var P;super(),this._viewportElement=S,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=y,this._optionsService=j,this._coreBrowseService=R,this._colorZoneStore=new c.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(P=this._viewportElement.parentElement)===null||P===void 0||P.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,_.toDisposable)((()=>{var T;(T=this._canvas)===null||T===void 0||T.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const S=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);u.full=this._canvas.width,u.left=S,u.center=C,u.right=S,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=u.left,d.right=u.left+u.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowseService.dpr);const S=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(S,12),6)*this._coreBrowseService.dpr);l.left=C,l.center=C,l.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const S=this._colorZoneStore.zones;for(const C of S)C.position!=="full"&&this._renderColorZone(C);for(const C of S)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(S){this._ctx.fillStyle=S.color,this._ctx.fillRect(d[S.position||"full"],Math.round((this._canvas.height-1)*(S.startBufferLine/this._bufferService.buffers.active.lines.length)-l[S.position||"full"]/2),u[S.position||"full"],Math.round((this._canvas.height-1)*((S.endBufferLine-S.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[S.position||"full"]))}_queueRefresh(S,C){this._shouldUpdateDimensions=S||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=f=a([h(2,w.IBufferService),h(3,w.IDecorationService),h(4,v.IRenderService),h(5,w.IOptionsService),h(6,v.ICoreBrowserService)],f)},2950:function(x,i,n){var a=this&&this.__decorate||function(w,l,u,d){var f,S=arguments.length,C=S<3?l:d===null?d=Object.getOwnPropertyDescriptor(l,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,l,u,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(l,u,C):f(l,u))||C);return S>3&&C&&Object.defineProperty(l,u,C),C},h=this&&this.__param||function(w,l){return function(u,d){l(u,d,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=n(4725),g=n(2585),v=n(2584);let _=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(w,l,u,d,f,S){this._textarea=w,this._compositionView=l,this._bufferService=u,this._optionsService=d,this._coreService=f,this._renderService=S,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(w){this._compositionView.textContent=w.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(w){if(this._isComposing||this._isSendingComposition){if(w.keyCode===229||w.keyCode===16||w.keyCode===17||w.keyCode===18)return!1;this._finalizeComposition(!1)}return w.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(w){if(this._compositionView.classList.remove("active"),this._isComposing=!1,w){const l={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let u;this._isSendingComposition=!1,l.start+=this._dataAlreadySent.length,u=this._isComposing?this._textarea.value.substring(l.start,l.end):this._textarea.value.substring(l.start),u.length>0&&this._coreService.triggerDataEvent(u,!0)}}),0)}else{this._isSendingComposition=!1;const l=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(l,!0)}}_handleAnyTextareaChanges(){const w=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const l=this._textarea.value,u=l.replace(w,"");this._dataAlreadySent=u,l.length>w.length?this._coreService.triggerDataEvent(u,!0):l.length<w.length?this._coreService.triggerDataEvent(`${v.C0.DEL}`,!0):l.length===w.length&&l!==w&&this._coreService.triggerDataEvent(l,!0)}}),0)}updateCompositionElements(w){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const l=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),u=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=l*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=u+"px",this._compositionView.style.lineHeight=u+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const S=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(S.width,1)+"px",this._textarea.style.height=Math.max(S.height,1)+"px",this._textarea.style.lineHeight=S.height+"px"}w||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=_=a([h(2,g.IBufferService),h(3,g.IOptionsService),h(4,g.ICoreService),h(5,c.IRenderService)],_)},9806:(x,i)=>{function n(a,h,c){const g=c.getBoundingClientRect(),v=a.getComputedStyle(c),_=parseInt(v.getPropertyValue("padding-left")),w=parseInt(v.getPropertyValue("padding-top"));return[h.clientX-g.left-_,h.clientY-g.top-w]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(a,h,c,g,v,_,w,l,u){if(!_)return;const d=n(a,h,c);return d?(d[0]=Math.ceil((d[0]+(u?w/2:0))/w),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),g+(u?1:0)),d[1]=Math.min(Math.max(d[1],1),v),d):void 0}},9504:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const a=n(2584);function h(l,u,d,f){const S=l-c(l,d),C=u-c(u,d),k=Math.abs(S-C)-(function(E,y,j){let R=0;const P=E-c(E,j),M=y-c(y,j);for(let T=0;T<Math.abs(P-M);T++){const B=g(E,y)==="A"?-1:1,I=j.buffer.lines.get(P+B*T);I?.isWrapped&&R++}return R})(l,u,d);return w(k,_(g(l,u),f))}function c(l,u){let d=0,f=u.buffer.lines.get(l),S=f?.isWrapped;for(;S&&l>=0&&l<u.rows;)d++,f=u.buffer.lines.get(--l),S=f?.isWrapped;return d}function g(l,u){return l>u?"A":"B"}function v(l,u,d,f,S,C){let k=l,E=u,y="";for(;k!==d||E!==f;)k+=S?1:-1,S&&k>C.cols-1?(y+=C.buffer.translateBufferLineToString(E,!1,l,k),k=0,l=0,E++):!S&&k<0&&(y+=C.buffer.translateBufferLineToString(E,!1,0,l+1),k=C.cols-1,l=k,E--);return y+C.buffer.translateBufferLineToString(E,!1,l,k)}function _(l,u){const d=u?"O":"[";return a.C0.ESC+d+l}function w(l,u){l=Math.floor(l);let d="";for(let f=0;f<l;f++)d+=u;return d}i.moveToCellSequence=function(l,u,d,f){const S=d.buffer.x,C=d.buffer.y;if(!d.buffer.hasScrollback)return(function(y,j,R,P,M,T){return h(j,P,M,T).length===0?"":w(v(y,j,y,j-c(j,M),!1,M).length,_("D",T))})(S,C,0,u,d,f)+h(C,u,d,f)+(function(y,j,R,P,M,T){let B;B=h(j,P,M,T).length>0?P-c(P,M):j;const I=P,H=(function(q,A,O,D,L,K){let U;return U=h(O,D,L,K).length>0?D-c(D,L):A,q<O&&U<=D||q>=O&&U<D?"C":"D"})(y,j,R,P,M,T);return w(v(y,B,R,I,H==="C",M).length,_(H,T))})(S,C,l,u,d,f);let k;if(C===u)return k=S>l?"D":"C",w(Math.abs(S-l),_(k,f));k=C>u?"D":"C";const E=Math.abs(C-u);return w((function(y,j){return j.cols-y})(C>u?l:S,d)+(E-1)*d.cols+1+((C>u?S:l)-1),_(k,f))}},1296:function(x,i,n){var a=this&&this.__decorate||function(M,T,B,I){var H,q=arguments.length,A=q<3?T:I===null?I=Object.getOwnPropertyDescriptor(T,B):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(M,T,B,I);else for(var O=M.length-1;O>=0;O--)(H=M[O])&&(A=(q<3?H(A):q>3?H(T,B,A):H(T,B))||A);return q>3&&A&&Object.defineProperty(T,B,A),A},h=this&&this.__param||function(M,T){return function(B,I){T(B,I,M)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=n(3787),g=n(2550),v=n(2223),_=n(6171),w=n(4725),l=n(8055),u=n(8460),d=n(844),f=n(2585),S="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",E="xterm-bg-",y="xterm-focus",j="xterm-selection";let R=1,P=i.DomRenderer=class extends d.Disposable{constructor(M,T,B,I,H,q,A,O,D,L){super(),this._element=M,this._screenElement=T,this._viewportElement=B,this._linkifier2=I,this._charSizeService=q,this._optionsService=A,this._bufferService=O,this._coreBrowserService=D,this._themeService=L,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new u.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((K=>this._injectCss(K)))),this._injectCss(this._themeService.colors),this._rowFactory=H.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(S+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((K=>this._handleLinkHover(K)))),this.register(this._linkifier2.onHideLinkUnderline((K=>this._handleLinkLeave(K)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(S+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const M=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*M,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*M),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/M),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/M),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const B of this._rowElements)B.style.width=`${this.dimensions.css.canvas.width}px`,B.style.height=`${this.dimensions.css.cell.height}px`,B.style.lineHeight=`${this.dimensions.css.cell.height}px`,B.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const T=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=T,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(M){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let T=`${this._terminalSelector} .${C} { color: ${M.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;T+=`${this._terminalSelector} .${C} .xterm-dim { color: ${l.color.multiplyOpacity(M.foreground,.5).css};}`,T+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,T+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",T+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,T+=`${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${M.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${M.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${M.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,T+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[B,I]of M.ansi.entries())T+=`${this._terminalSelector} .${k}${B} { color: ${I.css}; }${this._terminalSelector} .${k}${B}.xterm-dim { color: ${l.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${E}${B} { background-color: ${I.css}; }`;T+=`${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR} { color: ${l.color.opaque(M.background).css}; }${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${l.color.multiplyOpacity(l.color.opaque(M.background),.5).css}; }${this._terminalSelector} .${E}${v.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=T}_setDefaultSpacing(){const M=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${M}px`,this._rowFactory.defaultSpacing=M}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(M,T){for(let B=this._rowElements.length;B<=T;B++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>T;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,T){this._refreshRowElements(M,T),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(M,T,B){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,T,B),this.renderRows(0,this._bufferService.rows-1),!M||!T)return;const I=M[1]-this._bufferService.buffer.ydisp,H=T[1]-this._bufferService.buffer.ydisp,q=Math.max(I,0),A=Math.min(H,this._bufferService.rows-1);if(q>=this._bufferService.rows||A<0)return;const O=document.createDocumentFragment();if(B){const D=M[0]>T[0];O.appendChild(this._createSelectionElement(q,D?T[0]:M[0],D?M[0]:T[0],A-q+1))}else{const D=I===q?M[0]:0,L=q===H?T[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(q,D,L));const K=A-q-1;if(O.appendChild(this._createSelectionElement(q+1,0,this._bufferService.cols,K)),q!==A){const U=H===A?T[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(A,0,U))}}this._selectionContainer.appendChild(O)}_createSelectionElement(M,T,B,I=1){const H=document.createElement("div");return H.style.height=I*this.dimensions.css.cell.height+"px",H.style.top=M*this.dimensions.css.cell.height+"px",H.style.left=T*this.dimensions.css.cell.width+"px",H.style.width=this.dimensions.css.cell.width*(B-T)+"px",H}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const M of this._rowElements)M.replaceChildren()}renderRows(M,T){const B=this._bufferService.buffer,I=B.ybase+B.y,H=Math.min(B.x,this._bufferService.cols-1),q=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let D=M;D<=T;D++){const L=D+B.ydisp,K=this._rowElements[D],U=B.lines.get(L);if(!K||!U)break;K.replaceChildren(...this._rowFactory.createRow(U,L,L===I,A,O,H,q,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${S}${this._terminalClass}`}_handleLinkHover(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!0)}_handleLinkLeave(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!1)}_setCellUnderline(M,T,B,I,H,q){B<0&&(M=0),I<0&&(T=0);const A=this._bufferService.rows-1;B=Math.max(Math.min(B,A),0),I=Math.max(Math.min(I,A),0),H=Math.min(H,this._bufferService.cols);const O=this._bufferService.buffer,D=O.ybase+O.y,L=Math.min(O.x,H-1),K=this._optionsService.rawOptions.cursorBlink,U=this._optionsService.rawOptions.cursorStyle,z=this._optionsService.rawOptions.cursorInactiveStyle;for(let W=B;W<=I;++W){const $=W+O.ydisp,N=this._rowElements[W],F=O.lines.get($);if(!N||!F)break;N.replaceChildren(...this._rowFactory.createRow(F,$,$===D,U,z,L,K,this.dimensions.css.cell.width,this._widthCache,q?W===B?M:0:-1,q?(W===I?T:H)-1:-1))}}};i.DomRenderer=P=a([h(4,f.IInstantiationService),h(5,w.ICharSizeService),h(6,f.IOptionsService),h(7,f.IBufferService),h(8,w.ICoreBrowserService),h(9,w.IThemeService)],P)},3787:function(x,i,n){var a=this&&this.__decorate||function(k,E,y,j){var R,P=arguments.length,M=P<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,y):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(k,E,y,j);else for(var T=k.length-1;T>=0;T--)(R=k[T])&&(M=(P<3?R(M):P>3?R(E,y,M):R(E,y))||M);return P>3&&M&&Object.defineProperty(E,y,M),M},h=this&&this.__param||function(k,E){return function(y,j){E(y,j,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const c=n(2223),g=n(643),v=n(511),_=n(2585),w=n(8055),l=n(4725),u=n(4269),d=n(6171),f=n(3734);let S=i.DomRendererRowFactory=class{constructor(k,E,y,j,R,P,M){this._document=k,this._characterJoinerService=E,this._optionsService=y,this._coreBrowserService=j,this._coreService=R,this._decorationService=P,this._themeService=M,this._workCell=new v.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,y){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=y}createRow(k,E,y,j,R,P,M,T,B,I,H){const q=[],A=this._characterJoinerService.getJoinedCharacters(E),O=this._themeService.colors;let D,L=k.getNoBgTrimmedLength();y&&L<P+1&&(L=P+1);let K=0,U="",z=0,W=0,$=0,N=!1,F=0,V=!1,X=0;const te=[],G=I!==-1&&H!==-1;for(let pe=0;pe<L;pe++){k.loadCell(pe,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let re=!1,ne=pe,le=this._workCell;if(A.length>0&&pe===A[0][0]){re=!0;const ge=A.shift();le=new u.JoinedCellData(this._workCell,k.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),ne=ge[1]-1,he=le.getWidth()}const Se=this._isCellInSelection(pe,E),We=y&&pe===P,Ee=G&&pe>=I&&pe<=H;let He=!1;this._decorationService.forEachDecorationAtCell(pe,E,void 0,(ge=>{He=!0}));let at=le.getChars()||g.WHITESPACE_CELL_CHAR;if(at===" "&&(le.isUnderline()||le.isOverline())&&(at=" "),X=he*T-B.get(at,le.isBold(),le.isItalic()),D){if(K&&(Se&&V||!Se&&!V&&le.bg===z)&&(Se&&V&&O.selectionForeground||le.fg===W)&&le.extended.ext===$&&Ee===N&&X===F&&!We&&!re&&!He){U+=at,K++;continue}K&&(D.textContent=U),D=this._document.createElement("span"),K=0,U=""}else D=this._document.createElement("span");if(z=le.bg,W=le.fg,$=le.extended.ext,N=Ee,F=X,V=Se,re&&P>=pe&&P<=ne&&(P=pe),!this._coreService.isCursorHidden&&We){if(te.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&te.push("xterm-cursor-blink"),te.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":te.push("xterm-cursor-outline");break;case"block":te.push("xterm-cursor-block");break;case"bar":te.push("xterm-cursor-bar");break;case"underline":te.push("xterm-cursor-underline")}}if(le.isBold()&&te.push("xterm-bold"),le.isItalic()&&te.push("xterm-italic"),le.isDim()&&te.push("xterm-dim"),U=le.isInvisible()?g.WHITESPACE_CELL_CHAR:le.getChars()||g.WHITESPACE_CELL_CHAR,le.isUnderline()&&(te.push(`xterm-underline-${le.extended.underlineStyle}`),U===" "&&(U=" "),!le.isUnderlineColorDefault()))if(le.isUnderlineColorRGB())D.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(le.getUnderlineColor()).join(",")})`;else{let ge=le.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&le.isBold()&&ge<8&&(ge+=8),D.style.textDecorationColor=O.ansi[ge].css}le.isOverline()&&(te.push("xterm-overline"),U===" "&&(U=" ")),le.isStrikethrough()&&te.push("xterm-strikethrough"),Ee&&(D.style.textDecoration="underline");let Me=le.getFgColor(),Ne=le.getFgColorMode(),Oe=le.getBgColor(),Ue=le.getBgColorMode();const qe=!!le.isInverse();if(qe){const ge=Me;Me=Oe,Oe=ge;const et=Ne;Ne=Ue,Ue=et}let De,Ge,Qe,Te=!1;switch(this._decorationService.forEachDecorationAtCell(pe,E,void 0,(ge=>{ge.options.layer!=="top"&&Te||(ge.backgroundColorRGB&&(Ue=50331648,Oe=ge.backgroundColorRGB.rgba>>8&16777215,De=ge.backgroundColorRGB),ge.foregroundColorRGB&&(Ne=50331648,Me=ge.foregroundColorRGB.rgba>>8&16777215,Ge=ge.foregroundColorRGB),Te=ge.options.layer==="top")})),!Te&&Se&&(De=this._coreBrowserService.isFocused?O.selectionBackgroundOpaque:O.selectionInactiveBackgroundOpaque,Oe=De.rgba>>8&16777215,Ue=50331648,Te=!0,O.selectionForeground&&(Ne=50331648,Me=O.selectionForeground.rgba>>8&16777215,Ge=O.selectionForeground)),Te&&te.push("xterm-decoration-top"),Ue){case 16777216:case 33554432:Qe=O.ansi[Oe],te.push(`xterm-bg-${Oe}`);break;case 50331648:Qe=w.rgba.toColor(Oe>>16,Oe>>8&255,255&Oe),this._addStyle(D,`background-color:#${C((Oe>>>0).toString(16),"0",6)}`);break;default:qe?(Qe=O.foreground,te.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Qe=O.background}switch(De||le.isDim()&&(De=w.color.multiplyOpacity(Qe,.5)),Ne){case 16777216:case 33554432:le.isBold()&&Me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Me+=8),this._applyMinimumContrast(D,Qe,O.ansi[Me],le,De,void 0)||te.push(`xterm-fg-${Me}`);break;case 50331648:const ge=w.rgba.toColor(Me>>16&255,Me>>8&255,255&Me);this._applyMinimumContrast(D,Qe,ge,le,De,Ge)||this._addStyle(D,`color:#${C(Me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(D,Qe,O.foreground,le,De,void 0)||qe&&te.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}te.length&&(D.className=te.join(" "),te.length=0),We||re||He?D.textContent=U:K++,X!==this.defaultSpacing&&(D.style.letterSpacing=`${X}px`),q.push(D),pe=ne}return D&&K&&(D.textContent=U),q}_applyMinimumContrast(k,E,y,j,R,P){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const M=this._getContrastCache(j);let T;if(R||P||(T=M.getColor(E.rgba,y.rgba)),T===void 0){const B=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);T=w.color.ensureContrastRatio(R||E,P||y,B),M.setColor((R||E).rgba,(P||y).rgba,T??null)}return!!T&&(this._addStyle(k,`color:${T.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const y=this._selectionStart,j=this._selectionEnd;return!(!y||!j)&&(this._columnSelectMode?y[0]<=j[0]?k>=y[0]&&E>=y[1]&&k<j[0]&&E<=j[1]:k<y[0]&&E>=y[1]&&k>=j[0]&&E<=j[1]:E>y[1]&&E<j[1]||y[1]===j[1]&&E===y[1]&&k>=y[0]&&k<j[0]||y[1]<j[1]&&E===j[1]&&k<j[0]||y[1]<j[1]&&E===y[1]&&k>=y[0])}};function C(k,E,y){for(;k.length<y;)k=E+k;return k}i.DomRendererRowFactory=S=a([h(1,l.ICharacterJoinerService),h(2,_.IOptionsService),h(3,l.ICoreBrowserService),h(4,_.ICoreService),h(5,_.IDecorationService),h(6,l.IThemeService)],S)},2550:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const a=n.createElement("span"),h=n.createElement("span");h.style.fontWeight="bold";const c=n.createElement("span");c.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[a,h,c,g],this._container.appendChild(a),this._container.appendChild(h),this._container.appendChild(c),this._container.appendChild(g),n.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(n,a,h,c){n===this._font&&a===this._fontSize&&h===this._weight&&c===this._weightBold||(this._font=n,this._fontSize=a,this._weight=h,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${h}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${h}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(n,a,h){let c=0;if(!a&&!h&&n.length===1&&(c=n.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(n,0);let g=n;a&&(g+="B"),h&&(g+="I");let v=this._holey.get(g);if(v===void 0){let _=0;a&&(_|=1),h&&(_|=2),v=this._measure(n,_),this._holey.set(g,v)}return v}_measure(n,a){const h=this._measureElements[a];return h.textContent=n.repeat(32),h.offsetWidth/32}}},2223:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const a=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=a.isFirefox||a.isLegacyEdge?"bottom":"ideographic"},6171:(x,i)=>{function n(a){return 57508<=a&&a<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(a){if(!a)throw new Error("value must not be falsy");return a},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(a){return 57520<=a&&a<=57527},i.excludeFromContrastRatioDemands=function(a){return n(a)||(function(h){return 9472<=h&&h<=9631})(a)},i.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,a=this.selectionEnd;return!(!n||!a)&&(n[1]>a[1]||n[1]===a[1]&&n[0]>a[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const c=n(2585),g=n(8460),v=n(844);let _=i.CharSizeService=class extends v.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(l,u,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new w(l,u,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const l=this._measureStrategy.measure();l.width===this.width&&l.height===this.height||(this.width=l.width,this.height=l.height,this._onCharSizeChange.fire())}};i.CharSizeService=_=a([h(2,c.IOptionsService)],_);class w{constructor(u,d,f){this._document=u,this._parentElement=d,this._optionsService=f,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const u={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return u.width!==0&&u.height!==0&&(this._result.width=u.width/32,this._result.height=Math.ceil(u.height)),this._result}}},4269:function(x,i,n){var a=this&&this.__decorate||function(u,d,f,S){var C,k=arguments.length,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,d,f,S);else for(var y=u.length-1;y>=0;y--)(C=u[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},h=this&&this.__param||function(u,d){return function(f,S){d(f,S,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const c=n(3734),g=n(643),v=n(511),_=n(2585);class w extends c.AttributeData{constructor(d,f,S){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=S}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=w;let l=i.CharacterJoinerService=class Jl{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new v.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const S=[],C=f.translateToString(!0);let k=0,E=0,y=0,j=f.getFg(0),R=f.getBg(0);for(let P=0;P<f.getTrimmedLength();P++)if(f.loadCell(P,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==R){if(P-k>1){const M=this._getJoinedRanges(C,y,E,f,k);for(let T=0;T<M.length;T++)S.push(M[T])}k=P,y=E,j=this._workCell.fg,R=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const P=this._getJoinedRanges(C,y,E,f,k);for(let M=0;M<P.length;M++)S.push(P[M])}return S}_getJoinedRanges(d,f,S,C,k){const E=d.substring(f,S);let y=[];try{y=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const R=this._characterJoiners[j].handler(E);for(let P=0;P<R.length;P++)Jl._mergeRanges(y,R[P])}catch(R){console.error(R)}return this._stringRangesToCellRanges(y,C,k),y}_stringRangesToCellRanges(d,f,S){let C=0,k=!1,E=0,y=d[C];if(y){for(let j=S;j<this._bufferService.cols;j++){const R=f.getWidth(j),P=f.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&y[0]<=E&&(y[0]=j,k=!0),y[1]<=E){if(y[1]=j,y=d[++C],!y)break;y[0]<=E?(y[0]=j,k=!0):k=!1}E+=P}}y&&(y[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let S=!1;for(let C=0;C<d.length;C++){const k=d[C];if(S){if(f[1]<=k[0])return d[C-1][1]=f[1],d;if(f[1]<=k[1])return d[C-1][1]=Math.max(f[1],k[1]),d.splice(C,1),d;d.splice(C,1),C--}else{if(f[1]<=k[0])return d.splice(C,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),S=!0)}}return S?d[d.length-1][1]=f[1]:d.push(f),d}};i.CharacterJoinerService=l=a([h(0,_.IBufferService)],l)},5114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,a){this._textarea=n,this.window=a,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(x,i,n){var a=this&&this.__decorate||function(_,w,l,u){var d,f=arguments.length,S=f<3?w:u===null?u=Object.getOwnPropertyDescriptor(w,l):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,w,l,u);else for(var C=_.length-1;C>=0;C--)(d=_[C])&&(S=(f<3?d(S):f>3?d(w,l,S):d(w,l))||S);return f>3&&S&&Object.defineProperty(w,l,S),S},h=this&&this.__param||function(_,w){return function(l,u){w(l,u,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=n(4725),g=n(9806);let v=i.MouseService=class{constructor(_,w){this._renderService=_,this._charSizeService=w}getCoords(_,w,l,u,d){return(0,g.getCoords)(window,_,w,l,u,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(_,w){const l=(0,g.getCoordsRelativeToElement)(window,_,w);if(this._charSizeService.hasValidSize)return l[0]=Math.min(Math.max(l[0],0),this._renderService.dimensions.css.canvas.width-1),l[1]=Math.min(Math.max(l[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(l[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(l[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(l[0]),y:Math.floor(l[1])}}};i.MouseService=v=a([h(0,c.IRenderService),h(1,c.ICharSizeService)],v)},3230:function(x,i,n){var a=this&&this.__decorate||function(S,C,k,E){var y,j=arguments.length,R=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,E);else for(var P=S.length-1;P>=0;P--)(y=S[P])&&(R=(j<3?y(R):j>3?y(C,k,R):y(C,k))||R);return j>3&&R&&Object.defineProperty(C,k,R),R},h=this&&this.__param||function(S,C){return function(k,E){C(k,E,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const c=n(3656),g=n(6193),v=n(5596),_=n(4725),w=n(8460),l=n(844),u=n(7226),d=n(2585);let f=i.RenderService=class extends l.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(S,C,k,E,y,j,R,P){if(super(),this._rowCount=S,this._charSizeService=E,this._renderer=this.register(new l.MutableDisposable),this._pausedResizeTask=new u.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new w.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new w.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new w.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new w.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((M,T)=>this._renderRows(M,T))),this.register(this._renderDebouncer),this._screenDprMonitor=new v.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)===null||M===void 0?void 0:M.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(y.onDecorationRegistered((()=>this._fullRefresh()))),this.register(y.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(P.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const M=new R.window.IntersectionObserver((T=>this._handleIntersectionChange(T[T.length-1])),{threshold:0});M.observe(C),this.register({dispose:()=>M.disconnect()})}}_handleIntersectionChange(S){this._isPaused=S.isIntersecting===void 0?S.intersectionRatio===0:!S.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(S,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(S,C,this._rowCount))}_renderRows(S,C){this._renderer.value&&(S=Math.min(S,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(S,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:S,end:C}),this._onRender.fire({start:S,end:C}),this._isNextRenderRedrawOnly=!0)}resize(S,C){this._rowCount=C,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(S){this._renderer.value=S,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(S){return this._renderDebouncer.addRefreshCallback(S)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var S,C;this._renderer.value&&((C=(S=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(S),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(S,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(S,C))):this._renderer.value.handleResize(S,C),this._fullRefresh())}handleCharSizeChanged(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCharSizeChanged()}handleBlur(){var S;(S=this._renderer.value)===null||S===void 0||S.handleBlur()}handleFocus(){var S;(S=this._renderer.value)===null||S===void 0||S.handleFocus()}handleSelectionChanged(S,C,k){var E;this._selectionState.start=S,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(S,C,k)}handleCursorMove(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCursorMove()}clear(){var S;(S=this._renderer.value)===null||S===void 0||S.clear()}};i.RenderService=f=a([h(2,d.IOptionsService),h(3,_.ICharSizeService),h(4,d.IDecorationService),h(5,d.IBufferService),h(6,_.ICoreBrowserService),h(7,_.IThemeService)],f)},9312:function(x,i,n){var a=this&&this.__decorate||function(y,j,R,P){var M,T=arguments.length,B=T<3?j:P===null?P=Object.getOwnPropertyDescriptor(j,R):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")B=Reflect.decorate(y,j,R,P);else for(var I=y.length-1;I>=0;I--)(M=y[I])&&(B=(T<3?M(B):T>3?M(j,R,B):M(j,R))||B);return T>3&&B&&Object.defineProperty(j,R,B),B},h=this&&this.__param||function(y,j){return function(R,P){j(R,P,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const c=n(9806),g=n(9504),v=n(456),_=n(4725),w=n(8460),l=n(844),u=n(6114),d=n(4841),f=n(511),S=n(2585),C=" ",k=new RegExp(C,"g");let E=i.SelectionService=class extends l.Disposable{constructor(y,j,R,P,M,T,B,I,H){super(),this._element=y,this._screenElement=j,this._linkifier=R,this._bufferService=P,this._coreService=M,this._mouseService=T,this._optionsService=B,this._renderService=I,this._coreBrowserService=H,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new w.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new w.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new w.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new w.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=q=>this._handleMouseMove(q),this._mouseUpListener=q=>this._handleMouseUp(q),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((q=>this._handleTrim(q))),this.register(this._bufferService.buffers.onBufferActivate((q=>this._handleBufferActivate(q)))),this.enable(),this._model=new v.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,l.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!y||!j||y[0]===j[0]&&y[1]===j[1])}get selectionText(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!y||!j)return"";const R=this._bufferService.buffer,P=[];if(this._activeSelectionMode===3){if(y[0]===j[0])return"";const M=y[0]<j[0]?y[0]:j[0],T=y[0]<j[0]?j[0]:y[0];for(let B=y[1];B<=j[1];B++){const I=R.translateBufferLineToString(B,!0,M,T);P.push(I)}}else{const M=y[1]===j[1]?j[0]:void 0;P.push(R.translateBufferLineToString(y[1],!0,y[0],M));for(let T=y[1]+1;T<=j[1]-1;T++){const B=R.lines.get(T),I=R.translateBufferLineToString(T,!0);B?.isWrapped?P[P.length-1]+=I:P.push(I)}if(y[1]!==j[1]){const T=R.lines.get(j[1]),B=R.translateBufferLineToString(j[1],!0,0,j[0]);T&&T.isWrapped?P[P.length-1]+=B:P.push(B)}}return P.map((M=>M.replace(k," "))).join(u.isWindows?`\r
|
|
24
|
-
`:`
|
|
25
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(y){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),u.isLinux&&y&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(y){const j=this._getMouseBufferCoords(y),R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!!(R&&P&&j)&&this._areCoordsInSelection(j,R,P)}isCellInSelection(y,j){const R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!(!R||!P)&&this._areCoordsInSelection([y,j],R,P)}_areCoordsInSelection(y,j,R){return y[1]>j[1]&&y[1]<R[1]||j[1]===R[1]&&y[1]===j[1]&&y[0]>=j[0]&&y[0]<R[0]||j[1]<R[1]&&y[1]===R[1]&&y[0]<R[0]||j[1]<R[1]&&y[1]===j[1]&&y[0]>=j[0]}_selectWordAtCursor(y,j){var R,P;const M=(P=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||P===void 0?void 0:P.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const T=this._getMouseBufferCoords(y);return!!T&&(this._selectWordAt(T,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(y,j){this._model.clearSelection(),y=Math.max(y,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,y],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(y){this._model.handleTrim(y)&&this.refresh()}_getMouseBufferCoords(y){const j=this._mouseService.getCoords(y,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(y){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,y,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=R?0:(j>R&&(j-=R),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(y){return u.isMac?y.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:y.shiftKey}handleMouseDown(y){if(this._mouseDownTimeStamp=y.timeStamp,(y.button!==2||!this.hasSelection)&&y.button===0){if(!this._enabled){if(!this.shouldForceSelection(y))return;y.stopPropagation()}y.preventDefault(),this._dragScrollAmount=0,this._enabled&&y.shiftKey?this._handleIncrementalClick(y):y.detail===1?this._handleSingleClick(y):y.detail===2?this._handleDoubleClick(y):y.detail===3&&this._handleTripleClick(y),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(y){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(y))}_handleSingleClick(y){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(y)?3:0,this._model.selectionStart=this._getMouseBufferCoords(y),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(y){this._selectWordAtCursor(y,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(y){const j=this._getMouseBufferCoords(y);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(y){return y.altKey&&!(u.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(y){if(y.stopImmediatePropagation(),!this._model.selectionStart)return;const j=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(y),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(y),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const P=R.lines.get(this._model.selectionEnd[1]);P&&P.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const y=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(y.ydisp+this._bufferService.rows,y.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=y.ydisp),this.refresh()}}_handleMouseUp(y){const j=y.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&y.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(y,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const P=(0,g.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(P,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,R=!(!y||!j||y[0]===j[0]&&y[1]===j[1]);R?y&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&y[0]===this._oldSelectionStart[0]&&y[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(y,j,R)):this._oldHasSelection&&this._fireOnSelectionChange(y,j,R)}_fireOnSelectionChange(y,j,R){this._oldSelectionStart=y,this._oldSelectionEnd=j,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(y){this.clearSelection(),this._trimListener.dispose(),this._trimListener=y.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(y,j){let R=j;for(let P=0;j>=P;P++){const M=y.loadCell(P,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:M>1&&j!==P&&(R+=M-1)}return R}setSelection(y,j,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[y,j],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(y){this._isClickInSelection(y)||(this._selectWordAtCursor(y,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(y,j,R=!0,P=!0){if(y[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,T=M.lines.get(y[1]);if(!T)return;const B=M.translateBufferLineToString(y[1],!1);let I=this._convertViewportColToCharacterIndex(T,y[0]),H=I;const q=y[0]-I;let A=0,O=0,D=0,L=0;if(B.charAt(I)===" "){for(;I>0&&B.charAt(I-1)===" ";)I--;for(;H<B.length&&B.charAt(H+1)===" ";)H++}else{let z=y[0],W=y[0];T.getWidth(z)===0&&(A++,z--),T.getWidth(W)===2&&(O++,W++);const $=T.getString(W).length;for($>1&&(L+=$-1,H+=$-1);z>0&&I>0&&!this._isCharWordSeparator(T.loadCell(z-1,this._workCell));){T.loadCell(z-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,z--):N>1&&(D+=N-1,I-=N-1),I--,z--}for(;W<T.length&&H+1<B.length&&!this._isCharWordSeparator(T.loadCell(W+1,this._workCell));){T.loadCell(W+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(O++,W++):N>1&&(L+=N-1,H+=N-1),H++,W++}}H++;let K=I+q-A+D,U=Math.min(this._bufferService.cols,H-I+A+O-D-L);if(j||B.slice(I,H).trim()!==""){if(R&&K===0&&T.getCodePoint(0)!==32){const z=M.lines.get(y[1]-1);if(z&&T.isWrapped&&z.getCodePoint(this._bufferService.cols-1)!==32){const W=this._getWordAt([this._bufferService.cols-1,y[1]-1],!1,!0,!1);if(W){const $=this._bufferService.cols-W.start;K-=$,U+=$}}}if(P&&K+U===this._bufferService.cols&&T.getCodePoint(this._bufferService.cols-1)!==32){const z=M.lines.get(y[1]+1);if(z?.isWrapped&&z.getCodePoint(0)!==32){const W=this._getWordAt([0,y[1]+1],!1,!1,!0);W&&(U+=W.length)}}return{start:K,length:U}}}_selectWordAt(y,j){const R=this._getWordAt(y,j);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,y[1]--;this._model.selectionStart=[R.start,y[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(y){const j=this._getWordAt(y,!0);if(j){let R=y[1];for(;j.start<0;)j.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,R]}}_isCharWordSeparator(y){return y.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(y.getChars())>=0}_selectLineAt(y){const j=this._bufferService.buffer.getWrappedRangeForLine(y),R={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(R,this._bufferService.cols)}};i.SelectionService=E=a([h(3,S.IBufferService),h(4,S.ICoreService),h(5,_.IMouseService),h(6,S.IOptionsService),h(7,_.IRenderService),h(8,_.ICoreBrowserService)],E)},4725:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const a=n(8343);i.ICharSizeService=(0,a.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,a.createDecorator)("CoreBrowserService"),i.IMouseService=(0,a.createDecorator)("MouseService"),i.IRenderService=(0,a.createDecorator)("RenderService"),i.ISelectionService=(0,a.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,a.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,a.createDecorator)("ThemeService")},6731:function(x,i,n){var a=this&&this.__decorate||function(E,y,j,R){var P,M=arguments.length,T=M<3?y:R===null?R=Object.getOwnPropertyDescriptor(y,j):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(E,y,j,R);else for(var B=E.length-1;B>=0;B--)(P=E[B])&&(T=(M<3?P(T):M>3?P(y,j,T):P(y,j))||T);return M>3&&T&&Object.defineProperty(y,j,T),T},h=this&&this.__param||function(E,y){return function(j,R){y(j,R,E)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const c=n(7239),g=n(8055),v=n(8460),_=n(844),w=n(2585),l=g.css.toColor("#ffffff"),u=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),S={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const E=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],y=[0,95,135,175,215,255];for(let j=0;j<216;j++){const R=y[j/36%6|0],P=y[j/6%6|0],M=y[j%6];E.push({css:g.channels.toCss(R,P,M),rgba:g.channels.toRgba(R,P,M)})}for(let j=0;j<24;j++){const R=8+10*j;E.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return E})());let C=i.ThemeService=class extends _.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new v.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:l,background:u,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:S,selectionBackgroundOpaque:g.color.blend(u,S),selectionInactiveBackgroundTransparent:S,selectionInactiveBackgroundOpaque:g.color.blend(u,S),ansi:i.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(E={}){const y=this._colors;if(y.foreground=k(E.foreground,l),y.background=k(E.background,u),y.cursor=k(E.cursor,d),y.cursorAccent=k(E.cursorAccent,f),y.selectionBackgroundTransparent=k(E.selectionBackground,S),y.selectionBackgroundOpaque=g.color.blend(y.background,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundOpaque=g.color.blend(y.background,y.selectionInactiveBackgroundTransparent),y.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,y.selectionForeground===g.NULL_COLOR&&(y.selectionForeground=void 0),g.color.isOpaque(y.selectionBackgroundTransparent)&&(y.selectionBackgroundTransparent=g.color.opacity(y.selectionBackgroundTransparent,.3)),g.color.isOpaque(y.selectionInactiveBackgroundTransparent)&&(y.selectionInactiveBackgroundTransparent=g.color.opacity(y.selectionInactiveBackgroundTransparent,.3)),y.ansi=i.DEFAULT_ANSI_COLORS.slice(),y.ansi[0]=k(E.black,i.DEFAULT_ANSI_COLORS[0]),y.ansi[1]=k(E.red,i.DEFAULT_ANSI_COLORS[1]),y.ansi[2]=k(E.green,i.DEFAULT_ANSI_COLORS[2]),y.ansi[3]=k(E.yellow,i.DEFAULT_ANSI_COLORS[3]),y.ansi[4]=k(E.blue,i.DEFAULT_ANSI_COLORS[4]),y.ansi[5]=k(E.magenta,i.DEFAULT_ANSI_COLORS[5]),y.ansi[6]=k(E.cyan,i.DEFAULT_ANSI_COLORS[6]),y.ansi[7]=k(E.white,i.DEFAULT_ANSI_COLORS[7]),y.ansi[8]=k(E.brightBlack,i.DEFAULT_ANSI_COLORS[8]),y.ansi[9]=k(E.brightRed,i.DEFAULT_ANSI_COLORS[9]),y.ansi[10]=k(E.brightGreen,i.DEFAULT_ANSI_COLORS[10]),y.ansi[11]=k(E.brightYellow,i.DEFAULT_ANSI_COLORS[11]),y.ansi[12]=k(E.brightBlue,i.DEFAULT_ANSI_COLORS[12]),y.ansi[13]=k(E.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),y.ansi[14]=k(E.brightCyan,i.DEFAULT_ANSI_COLORS[14]),y.ansi[15]=k(E.brightWhite,i.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(y.ansi.length-16,E.extendedAnsi.length);for(let R=0;R<j;R++)y.ansi[R+16]=k(E.extendedAnsi[R],i.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[E]=this._restoreColors.ansi[E]}else for(let y=0;y<this._restoreColors.ansi.length;++y)this._colors.ansi[y]=this._restoreColors.ansi[y]}modifyColors(E){E(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function k(E,y){if(E!==void 0)try{return g.css.toColor(E)}catch{}return y}i.ThemeService=C=a([h(0,w.IOptionsService)],C)},6349:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const a=n(8460),h=n(844);class c extends h.Disposable{constructor(v){super(),this._maxLength=v,this.onDeleteEmitter=this.register(new a.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new a.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new a.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(v){if(this._maxLength===v)return;const _=new Array(v);for(let w=0;w<Math.min(v,this.length);w++)_[w]=this._array[this._getCyclicIndex(w)];this._array=_,this._maxLength=v,this._startIndex=0}get length(){return this._length}set length(v){if(v>this._length)for(let _=this._length;_<v;_++)this._array[_]=void 0;this._length=v}get(v){return this._array[this._getCyclicIndex(v)]}set(v,_){this._array[this._getCyclicIndex(v)]=_}push(v){this._array[this._getCyclicIndex(this._length)]=v,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(v,_,...w){if(_){for(let l=v;l<this._length-_;l++)this._array[this._getCyclicIndex(l)]=this._array[this._getCyclicIndex(l+_)];this._length-=_,this.onDeleteEmitter.fire({index:v,amount:_})}for(let l=this._length-1;l>=v;l--)this._array[this._getCyclicIndex(l+w.length)]=this._array[this._getCyclicIndex(l)];for(let l=0;l<w.length;l++)this._array[this._getCyclicIndex(v+l)]=w[l];if(w.length&&this.onInsertEmitter.fire({index:v,amount:w.length}),this._length+w.length>this._maxLength){const l=this._length+w.length-this._maxLength;this._startIndex+=l,this._length=this._maxLength,this.onTrimEmitter.fire(l)}else this._length+=w.length}trimStart(v){v>this._length&&(v=this._length),this._startIndex+=v,this._length-=v,this.onTrimEmitter.fire(v)}shiftElements(v,_,w){if(!(_<=0)){if(v<0||v>=this._length)throw new Error("start argument out of range");if(v+w<0)throw new Error("Cannot shift elements in list beyond index 0");if(w>0){for(let u=_-1;u>=0;u--)this.set(v+u+w,this.get(v+u));const l=v+_+w-this._length;if(l>0)for(this._length+=l;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let l=0;l<_;l++)this.set(v+l+w,this.get(v+l))}}_getCyclicIndex(v){return(this._startIndex+v)%this._maxLength}}i.CircularList=c},1439:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(a,h=5){if(typeof a!="object")return a;const c=Array.isArray(a)?[]:{};for(const g in a)c[g]=h<=1?a[g]:a[g]&&n(a[g],h-1);return c}},8055:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const a=n(6114);let h=0,c=0,g=0,v=0;var _,w,l,u,d;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function S(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,E,y,j){return j!==void 0?`#${f(k)}${f(E)}${f(y)}${f(j)}`:`#${f(k)}${f(E)}${f(y)}`},C.toRgba=function(k,E,y,j=255){return(k<<24|E<<16|y<<8|j)>>>0}})(_||(i.channels=_={})),(function(C){function k(E,y){return v=Math.round(255*y),[h,c,g]=d.toChannels(E.rgba),{css:_.toCss(h,c,g,v),rgba:_.toRgba(h,c,g,v)}}C.blend=function(E,y){if(v=(255&y.rgba)/255,v===1)return{css:y.css,rgba:y.rgba};const j=y.rgba>>24&255,R=y.rgba>>16&255,P=y.rgba>>8&255,M=E.rgba>>24&255,T=E.rgba>>16&255,B=E.rgba>>8&255;return h=M+Math.round((j-M)*v),c=T+Math.round((R-T)*v),g=B+Math.round((P-B)*v),{css:_.toCss(h,c,g),rgba:_.toRgba(h,c,g)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,y,j){const R=d.ensureContrastRatio(E.rgba,y.rgba,j);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},C.opaque=function(E){const y=(255|E.rgba)>>>0;return[h,c,g]=d.toChannels(y),{css:_.toCss(h,c,g),rgba:y}},C.opacity=k,C.multiplyOpacity=function(E,y){return v=255&E.rgba,k(E,v*y/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(w||(i.color=w={})),(function(C){let k,E;if(!a.isNode){const y=document.createElement("canvas");y.width=1,y.height=1;const j=y.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}C.toColor=function(y){if(y.match(/#[\da-f]{3,8}/i))switch(y.length){case 4:return h=parseInt(y.slice(1,2).repeat(2),16),c=parseInt(y.slice(2,3).repeat(2),16),g=parseInt(y.slice(3,4).repeat(2),16),d.toColor(h,c,g);case 5:return h=parseInt(y.slice(1,2).repeat(2),16),c=parseInt(y.slice(2,3).repeat(2),16),g=parseInt(y.slice(3,4).repeat(2),16),v=parseInt(y.slice(4,5).repeat(2),16),d.toColor(h,c,g,v);case 7:return{css:y,rgba:(parseInt(y.slice(1),16)<<8|255)>>>0};case 9:return{css:y,rgba:parseInt(y.slice(1),16)>>>0}}const j=y.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(j)return h=parseInt(j[1]),c=parseInt(j[2]),g=parseInt(j[3]),v=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(h,c,g,v);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=y,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[h,c,g,v]=k.getImageData(0,0,1,1).data,v!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_.toRgba(h,c,g,v),css:y}}})(l||(i.css=l={})),(function(C){function k(E,y,j){const R=E/255,P=y/255,M=j/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(u||(i.rgb=u={})),(function(C){function k(y,j,R){const P=y>>24&255,M=y>>16&255,T=y>>8&255;let B=j>>24&255,I=j>>16&255,H=j>>8&255,q=S(u.relativeLuminance2(B,I,H),u.relativeLuminance2(P,M,T));for(;q<R&&(B>0||I>0||H>0);)B-=Math.max(0,Math.ceil(.1*B)),I-=Math.max(0,Math.ceil(.1*I)),H-=Math.max(0,Math.ceil(.1*H)),q=S(u.relativeLuminance2(B,I,H),u.relativeLuminance2(P,M,T));return(B<<24|I<<16|H<<8|255)>>>0}function E(y,j,R){const P=y>>24&255,M=y>>16&255,T=y>>8&255;let B=j>>24&255,I=j>>16&255,H=j>>8&255,q=S(u.relativeLuminance2(B,I,H),u.relativeLuminance2(P,M,T));for(;q<R&&(B<255||I<255||H<255);)B=Math.min(255,B+Math.ceil(.1*(255-B))),I=Math.min(255,I+Math.ceil(.1*(255-I))),H=Math.min(255,H+Math.ceil(.1*(255-H))),q=S(u.relativeLuminance2(B,I,H),u.relativeLuminance2(P,M,T));return(B<<24|I<<16|H<<8|255)>>>0}C.ensureContrastRatio=function(y,j,R){const P=u.relativeLuminance(y>>8),M=u.relativeLuminance(j>>8);if(S(P,M)<R){if(M<P){const I=k(y,j,R),H=S(P,u.relativeLuminance(I>>8));if(H<R){const q=E(y,j,R);return H>S(P,u.relativeLuminance(q>>8))?I:q}return I}const T=E(y,j,R),B=S(P,u.relativeLuminance(T>>8));if(B<R){const I=k(y,j,R);return B>S(P,u.relativeLuminance(I>>8))?T:I}return T}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(y){return[y>>24&255,y>>16&255,y>>8&255,255&y]},C.toColor=function(y,j,R,P){return{css:_.toCss(y,j,R,P),rgba:_.toRgba(y,j,R,P)}}})(d||(i.rgba=d={})),i.toPaddedHex=f,i.contrastRatio=S},8969:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const a=n(844),h=n(2585),c=n(4348),g=n(7866),v=n(744),_=n(7302),w=n(6975),l=n(8460),u=n(1753),d=n(1480),f=n(7994),S=n(9282),C=n(5435),k=n(5981),E=n(2660);let y=!1;class j extends a.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new l.EventEmitter),this._onScroll.event((P=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(P.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(P){for(const M in P)this.optionsService.options[M]=P[M]}constructor(P){super(),this._windowsWrappingHeuristics=this.register(new a.MutableDisposable),this._onBinary=this.register(new l.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new l.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new l.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new l.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new _.OptionsService(P)),this._instantiationService.setService(h.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(v.BufferService)),this._instantiationService.setService(h.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(h.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(w.CoreService)),this._instantiationService.setService(h.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(u.CoreMouseService)),this._instantiationService.setService(h.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(h.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(h.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(h.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,l.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,l.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,l.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,l.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((M=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new k.WriteBuffer(((M,T)=>this._inputHandler.parse(M,T)))),this.register((0,l.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(P,M){this._writeBuffer.write(P,M)}writeSync(P,M){this._logService.logLevel<=h.LogLevelEnum.WARN&&!y&&(this._logService.warn("writeSync is unreliable and will be removed soon."),y=!0),this._writeBuffer.writeSync(P,M)}resize(P,M){isNaN(P)||isNaN(M)||(P=Math.max(P,v.MINIMUM_COLS),M=Math.max(M,v.MINIMUM_ROWS),this._bufferService.resize(P,M))}scroll(P,M=!1){this._bufferService.scroll(P,M)}scrollLines(P,M,T){this._bufferService.scrollLines(P,M,T)}scrollPages(P){this.scrollLines(P*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(P){const M=P-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(P,M){return this._inputHandler.registerEscHandler(P,M)}registerDcsHandler(P,M){return this._inputHandler.registerDcsHandler(P,M)}registerCsiHandler(P,M){return this._inputHandler.registerCsiHandler(P,M)}registerOscHandler(P,M){return this._inputHandler.registerOscHandler(P,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let P=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?P=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(P=!0),P?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const P=[];P.push(this.onLineFeed(S.updateWindowsModeWrappedState.bind(null,this._bufferService))),P.push(this.registerCsiHandler({final:"H"},(()=>((0,S.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,a.toDisposable)((()=>{for(const M of P)M.dispose()}))}}}i.CoreTerminal=j},8460:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let a=0;a<this._listeners.length;a++)if(this._listeners[a]===n)return void this._listeners.splice(a,1)}}})),this._event}fire(n,a){const h=[];for(let c=0;c<this._listeners.length;c++)h.push(this._listeners[c]);for(let c=0;c<h.length;c++)h[c].call(void 0,n,a)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,a){return n((h=>a.fire(h)))}},5435:function(x,i,n){var a=this&&this.__decorate||function(q,A,O,D){var L,K=arguments.length,U=K<3?A:D===null?D=Object.getOwnPropertyDescriptor(A,O):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(q,A,O,D);else for(var z=q.length-1;z>=0;z--)(L=q[z])&&(U=(K<3?L(U):K>3?L(A,O,U):L(A,O))||U);return K>3&&U&&Object.defineProperty(A,O,U),U},h=this&&this.__param||function(q,A){return function(O,D){A(O,D,q)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=n(2584),g=n(7116),v=n(2015),_=n(844),w=n(482),l=n(8437),u=n(8460),d=n(643),f=n(511),S=n(3734),C=n(2585),k=n(6242),E=n(6351),y=n(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function P(q,A){if(q>24)return A.setWinLines||!1;switch(q){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var M;(function(q){q[q.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",q[q.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(i.WindowsOptionsReportType=M={}));let T=0;class B extends _.Disposable{getAttrData(){return this._curAttrData}constructor(A,O,D,L,K,U,z,W,$=new v.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=O,this._coreService=D,this._logService=L,this._optionsService=K,this._oscLinkService=U,this._coreMouseService=z,this._unicodeService=W,this._parser=$,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new w.StringToUtf32,this._utf8Decoder=new w.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new u.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new u.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new u.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new u.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new u.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new u.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new u.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new u.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new u.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new u.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new u.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new u.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new u.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:F.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,F,V)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:F,data:V})})),this._parser.setDcsHandlerFallback(((N,F,V)=>{F==="HOOK"&&(V=V.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:F,payload:V})})),this._parser.setPrintHandler(((N,F,V)=>this.print(N,F,V))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const N in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((N,F)=>this.requestStatusString(N,F))))}_preserveStack(A,O,D,L){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=D,this._parseStack.position=L}_logSlowResolvingAsync(A){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([A,new Promise(((O,D)=>setTimeout((()=>D("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,O){let D,L=this._activeBuffer.x,K=this._activeBuffer.y,U=0;const z=this._parseStack.paused;if(z){if(D=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(D),D;L=this._parseStack.cursorStartX,K=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(U=this._parseStack.position+R)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(W=>String.fromCharCode(W))).join("")}"`),typeof A=="string"?A.split("").map((W=>W.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),z||this._dirtyRowTracker.clearRange(),A.length>R)for(let W=U;W<A.length;W+=R){const $=W+R<A.length?W+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(W,$),this._parseBuffer):this._utf8Decoder.decode(A.subarray(W,$),this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,N))return this._preserveStack(L,K,N,W),this._logSlowResolvingAsync(D),D}else if(!z){const W=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,W))return this._preserveStack(L,K,W,0),this._logSlowResolvingAsync(D),D}this._activeBuffer.x===L&&this._activeBuffer.y===K||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,O,D){let L,K;const U=this._charsetService.charset,z=this._optionsService.rawOptions.screenReaderMode,W=this._bufferService.cols,$=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,F=this._curAttrData;let V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&D-O>0&&V.getWidth(this._activeBuffer.x-1)===2&&V.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let X=O;X<D;++X){if(L=A[X],K=this._unicodeService.wcwidth(L),L<127&&U){const te=U[String.fromCharCode(L)];te&&(L=te.charCodeAt(0))}if(z&&this._onA11yChar.fire((0,w.stringFromCodePoint)(L)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),K||!this._activeBuffer.x){if(this._activeBuffer.x+K-1>=W){if($){for(;this._activeBuffer.x<W;)V.setCellFromCodePoint(this._activeBuffer.x++,0,1,F.fg,F.bg,F.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),V=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=W-1,K===2)continue}if(N&&(V.insertCells(this._activeBuffer.x,K,this._activeBuffer.getNullCell(F),F),V.getWidth(W-1)===2&&V.setCellFromCodePoint(W-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),V.setCellFromCodePoint(this._activeBuffer.x++,L,K,F.fg,F.bg,F.extended),K>0)for(;--K;)V.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else V.getWidth(this._activeBuffer.x-1)?V.addCodepointToCell(this._activeBuffer.x-1,L):V.addCodepointToCell(this._activeBuffer.x-2,L)}D-O>0&&(V.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<W&&D-O>0&&V.getWidth(this._activeBuffer.x)===0&&!V.hasContent(this._activeBuffer.x)&&V.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,O){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,O):this._parser.registerCsiHandler(A,(D=>!P(D.params[0],this._optionsService.rawOptions.windowOptions)||O(D)))}registerDcsHandler(A,O){return this._parser.registerDcsHandler(A,new E.DcsHandler(O))}registerEscHandler(A,O){return this._parser.registerEscHandler(A,O)}registerOscHandler(A,O){return this._parser.registerOscHandler(A,new k.OscHandler(O))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=A,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+O)}cursorUp(A){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const O=A.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=A.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const O=A.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,O,D,L=!1,K=!1){const U=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);U.replaceCells(O,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),K),L&&(U.isWrapped=!1)}_resetBufferLine(A,O=!1){const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);D&&(D.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),D.isWrapped=!1)}eraseInDisplay(A,O=!1){let D;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);D<this._bufferService.rows;D++)this._resetBufferLine(D,O);this._dirtyRowTracker.markDirty(D);break;case 1:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(D+1).isWrapped=!1);D--;)this._resetBufferLine(D,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(D=this._bufferService.rows,this._dirtyRowTracker.markDirty(D-1);D--;)this._resetBufferLine(D,O);this._dirtyRowTracker.markDirty(0);break;case 3:const L=this._activeBuffer.lines.length-this._bufferService.rows;L>0&&(this._activeBuffer.lines.trimStart(L),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-L,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-L,0),this._onScroll.fire(0))}return!0}eraseInLine(A,O=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let O=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y,L=this._bufferService.rows-1-this._activeBuffer.scrollBottom,K=this._bufferService.rows-1+this._activeBuffer.ybase-L+1;for(;O--;)this._activeBuffer.lines.splice(K-1,1),this._activeBuffer.lines.splice(D,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let O=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y;let L;for(L=this._bufferService.rows-1-this._activeBuffer.scrollBottom,L=this._bufferService.rows-1+this._activeBuffer.ybase-L;O--;)this._activeBuffer.lines.splice(D,1),this._activeBuffer.lines.splice(L,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let O=A.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let O=A.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(l.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);L.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),L.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);L.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),L.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);L.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),L.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const O=A.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const L=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);L.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),L.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const O=A.params[0]||1,D=new Uint32Array(O);for(let L=0;L<O;++L)D[L]=this._parser.precedingCodepoint;return this.print(D,0,D.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let O=0;O<A.length;O++)switch(A.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[O]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,O){const D=this._coreService.decPrivateModes,{activeProtocol:L,activeEncoding:K}=this._coreMouseService,U=this._coreService,{buffers:z,cols:W}=this._bufferService,{active:$,alt:N}=z,F=this._optionsService.rawOptions,V=pe=>pe?1:2,X=A.params[0];return te=X,G=O?X===2?4:X===4?V(U.modes.insertMode):X===12?3:X===20?V(F.convertEol):0:X===1?V(D.applicationCursorKeys):X===3?F.windowOptions.setWinLines?W===80?2:W===132?1:0:0:X===6?V(D.origin):X===7?V(D.wraparound):X===8?3:X===9?V(L==="X10"):X===12?V(F.cursorBlink):X===25?V(!U.isCursorHidden):X===45?V(D.reverseWraparound):X===66?V(D.applicationKeypad):X===67?4:X===1e3?V(L==="VT200"):X===1002?V(L==="DRAG"):X===1003?V(L==="ANY"):X===1004?V(D.sendFocus):X===1005?4:X===1006?V(K==="SGR"):X===1015?4:X===1016?V(K==="SGR_PIXELS"):X===1048?1:X===47||X===1047||X===1049?V($===N):X===2004?V(D.bracketedPasteMode):0,U.triggerDataEvent(`${c.C0.ESC}[${O?"":"?"}${te};${G}$y`),!0;var te,G}_updateAttrColor(A,O,D,L,K){return O===2?(A|=50331648,A&=-16777216,A|=S.AttributeData.fromColorRGB([D,L,K])):O===5&&(A&=-50331904,A|=33554432|255&D),A}_extractColor(A,O,D){const L=[0,0,-1,0,0,0];let K=0,U=0;do{if(L[U+K]=A.params[O+U],A.hasSubParams(O+U)){const z=A.getSubParams(O+U);let W=0;do L[1]===5&&(K=1),L[U+W+1+K]=z[W];while(++W<z.length&&W+U+1+K<L.length);break}if(L[1]===5&&U+K>=2||L[1]===2&&U+K>=5)break;L[1]&&(K=1)}while(++U+O<A.length&&U+K<L.length);for(let z=2;z<L.length;++z)L[z]===-1&&(L[z]=0);switch(L[0]){case 38:D.fg=this._updateAttrColor(D.fg,L[1],L[3],L[4],L[5]);break;case 48:D.bg=this._updateAttrColor(D.bg,L[1],L[3],L[4],L[5]);break;case 58:D.extended=D.extended.clone(),D.extended.underlineColor=this._updateAttrColor(D.extended.underlineColor,L[1],L[3],L[4],L[5])}return U}_processUnderline(A,O){O.extended=O.extended.clone(),(!~A||A>5)&&(A=1),O.extended.underlineStyle=A,O.fg|=268435456,A===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(A){A.fg=l.DEFAULT_ATTR_DATA.fg,A.bg=l.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const O=A.length;let D;const L=this._curAttrData;for(let K=0;K<O;K++)D=A.params[K],D>=30&&D<=37?(L.fg&=-50331904,L.fg|=16777216|D-30):D>=40&&D<=47?(L.bg&=-50331904,L.bg|=16777216|D-40):D>=90&&D<=97?(L.fg&=-50331904,L.fg|=16777224|D-90):D>=100&&D<=107?(L.bg&=-50331904,L.bg|=16777224|D-100):D===0?this._processSGR0(L):D===1?L.fg|=134217728:D===3?L.bg|=67108864:D===4?(L.fg|=268435456,this._processUnderline(A.hasSubParams(K)?A.getSubParams(K)[0]:1,L)):D===5?L.fg|=536870912:D===7?L.fg|=67108864:D===8?L.fg|=1073741824:D===9?L.fg|=2147483648:D===2?L.bg|=134217728:D===21?this._processUnderline(2,L):D===22?(L.fg&=-134217729,L.bg&=-134217729):D===23?L.bg&=-67108865:D===24?(L.fg&=-268435457,this._processUnderline(0,L)):D===25?L.fg&=-536870913:D===27?L.fg&=-67108865:D===28?L.fg&=-1073741825:D===29?L.fg&=2147483647:D===39?(L.fg&=-67108864,L.fg|=16777215&l.DEFAULT_ATTR_DATA.fg):D===49?(L.bg&=-67108864,L.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):D===38||D===48||D===58?K+=this._extractColor(A,K,L):D===53?L.bg|=1073741824:D===55?L.bg&=-1073741825:D===59?(L.extended=L.extended.clone(),L.extended.underlineColor=-1,L.updateExtended()):D===100?(L.fg&=-67108864,L.fg|=16777215&l.DEFAULT_ATTR_DATA.fg,L.bg&=-67108864,L.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",D);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${O};${D}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const O=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${O};${D}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const O=A.params[0]||1;switch(O){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const D=O%2==1;return this._optionsService.options.cursorBlink=D,!0}setScrollRegion(A){const O=A.params[0]||1;let D;return(A.length<2||(D=A.params[1])>this._bufferService.rows||D===0)&&(D=this._bufferService.rows),D>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=D-1,this._setCursor(0,0)),!0}windowOptions(A){if(!P(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const O=[],D=A.split(";");for(;D.length>1;){const L=D.shift(),K=D.shift();if(/^\d+$/.exec(L)){const U=parseInt(L);if(H(U))if(K==="?")O.push({type:0,index:U});else{const z=(0,y.parseColor)(K);z&&O.push({type:1,index:U,color:z})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(A){const O=A.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(A,O){this._getCurrentLinkId()&&this._finishHyperlink();const D=A.split(":");let L;const K=D.findIndex((U=>U.startsWith("id=")));return K!==-1&&(L=D[K].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:L,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,O){const D=A.split(";");for(let L=0;L<D.length&&!(O>=this._specialColors.length);++L,++O)if(D[L]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const K=(0,y.parseColor)(D[L]);K&&this._onColor.fire([{type:1,index:this._specialColors[O],color:K}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const O=[],D=A.split(";");for(let L=0;L<D.length;++L)if(/^\d+$/.exec(D[L])){const K=parseInt(D[L]);H(K)&&O.push({type:2,index:K})}return O.length&&this._onColor.fire(O),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(j[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const D=this._activeBuffer.ybase+this._activeBuffer.y+O,L=this._activeBuffer.lines.get(D);L&&(L.fill(A),L.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,O){const D=this._bufferService.buffer,L=this._optionsService.rawOptions;return(K=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${K}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${D.scrollTop+1};${D.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[L.cursorStyle]-(L.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,O){this._dirtyRowTracker.markRangeDirty(A,O)}}i.InputHandler=B;let I=class{constructor(q){this._bufferService=q,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(q){q<this.start?this.start=q:q>this.end&&(this.end=q)}markRangeDirty(q,A){q>A&&(T=q,q=A,A=T),q<this.start&&(this.start=q),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function H(q){return 0<=q&&q<256}I=a([h(0,C.IBufferService)],I)},844:(x,i)=>{function n(a){for(const h of a)h.dispose();a.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const a of this._disposables)a.dispose();this._disposables.length=0}register(a){return this._disposables.push(a),a}unregister(a){const h=this._disposables.indexOf(a);h!==-1&&this._disposables.splice(h,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(a){var h;this._isDisposed||a===this._value||((h=this._value)===null||h===void 0||h.dispose(),this._value=a)}clear(){this.value=void 0}dispose(){var a;this._isDisposed=!0,(a=this._value)===null||a===void 0||a.dispose(),this._value=void 0}},i.toDisposable=function(a){return{dispose:a}},i.disposeArray=n,i.getDisposeArrayDisposable=function(a){return{dispose:()=>n(a)}}},1505:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(h,c,g){this._data[h]||(this._data[h]={}),this._data[h][c]=g}get(h,c){return this._data[h]?this._data[h][c]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(a,h,c,g,v){this._data.get(a,h)||this._data.set(a,h,new n),this._data.get(a,h).set(c,g,v)}get(a,h,c,g){var v;return(v=this._data.get(a,h))===null||v===void 0?void 0:v.get(c,g)}clear(){this._data.clear()}}},6114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,a=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const h=n.match(/Version\/(\d+)/);return h===null||h.length<2?0:parseInt(h[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(a),i.isIpad=a==="iPad",i.isIphone=a==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(a),i.isLinux=a.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(a){this._getKey=a,this._array=[]}clear(){this._array.length=0}insert(a){this._array.length!==0?(n=this._search(this._getKey(a)),this._array.splice(n,0,a)):this._array.push(a)}delete(a){if(this._array.length===0)return!1;const h=this._getKey(a);if(h===void 0||(n=this._search(h),n===-1)||this._getKey(this._array[n])!==h)return!1;do if(this._array[n]===a)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===h);return!1}*getKeyIterator(a){if(this._array.length!==0&&(n=this._search(a),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===a))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===a)}forEachByKey(a,h){if(this._array.length!==0&&(n=this._search(a),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===a))do h(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===a)}values(){return[...this._array].values()}_search(a){let h=0,c=this._array.length-1;for(;c>=h;){let g=h+c>>1;const v=this._getKey(this._array[g]);if(v>a)c=g-1;else{if(!(v<a)){for(;g>0&&this._getKey(this._array[g-1])===a;)g--;return g}h=g+1}}return h}}},7226:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const a=n(6114);class h{constructor(){this._tasks=[],this._i=0}enqueue(v){this._tasks.push(v),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(v){this._idleCallback=void 0;let _=0,w=0,l=v.timeRemaining(),u=0;for(;this._i<this._tasks.length;){if(_=Date.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,Date.now()-_),w=Math.max(_,w),u=v.timeRemaining(),1.5*w>u)return l-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(l-_))}ms`),void this._start();l=u}this.clear()}}class c extends h{_requestCallback(v){return setTimeout((()=>v(this._createDeadline(16))))}_cancelCallback(v){clearTimeout(v)}_createDeadline(v){const _=Date.now()+v;return{timeRemaining:()=>Math.max(0,_-Date.now())}}}i.PriorityTaskQueue=c,i.IdleTaskQueue=!a.isNode&&"requestIdleCallback"in window?class extends h{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const a=n(643);i.updateWindowsModeWrappedState=function(h){const c=h.buffer.lines.get(h.buffer.ybase+h.buffer.y-1),g=c?.get(h.cols-1),v=h.buffer.lines.get(h.buffer.ybase+h.buffer.y);v&&g&&(v.isWrapped=g[a.CHAR_DATA_CODE_INDEX]!==a.NULL_CELL_CODE&&g[a.CHAR_DATA_CODE_INDEX]!==a.WHITESPACE_CELL_CODE)}},3734:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new a}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new n;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}i.AttributeData=n;class a{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new a(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=a},9092:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const a=n(6349),h=n(7226),c=n(3734),g=n(8437),v=n(4634),_=n(511),w=n(643),l=n(4863),u=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,f,S){this._hasScrollback=d,this._optionsService=f,this._bufferService=S,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=u.DEFAULT_CHARSET,this.markers=[],this._nullCell=_.CellData.fromCharData([0,w.NULL_CELL_CHAR,w.NULL_CELL_WIDTH,w.NULL_CELL_CODE]),this._whitespaceCell=_.CellData.fromCharData([0,w.WHITESPACE_CELL_CHAR,w.WHITESPACE_CELL_WIDTH,w.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new h.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const f=d+this._optionsService.rawOptions.scrollback;return f>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:f}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let y=0;y<this.lines.length;y++)C+=+this.lines.get(y).resize(d,S);let E=0;if(this._rows<f)for(let y=this._rows;y<f;y++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,S)):this.ybase>0&&this.lines.length<=this.ybase+this.y+E+1?(this.ybase--,E++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,S)));else for(let y=this._rows;y>f;y--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const y=this.lines.length-k;y>0&&(this.lines.trimStart(y),this.ybase=Math.max(this.ybase-y,0),this.ydisp=Math.max(this.ydisp-y,0),this.savedY=Math.max(this.savedY-y,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(d,f),this._cols>d))for(let E=0;E<this.lines.length;E++)C+=+this.lines.get(E).resize(d,S);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,f){this._cols!==d&&(d>this._cols?this._reflowLarger(d,f):this._reflowSmaller(d,f))}_reflowLarger(d,f){const S=(0,v.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(S.length>0){const C=(0,v.reflowLargerCreateNewLayout)(this.lines,S);(0,v.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(d,f,C.countRemoved)}}_reflowLargerAdjustViewport(d,f,S){const C=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=S;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-S,0)}_reflowSmaller(d,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA),C=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let y=this.lines.get(E);if(!y||!y.isWrapped&&y.getTrimmedLength()<=d)continue;const j=[y];for(;y.isWrapped&&E>0;)y=this.lines.get(--E),j.unshift(y);const R=this.ybase+this.y;if(R>=E&&R<E+j.length)continue;const P=j[j.length-1].getTrimmedLength(),M=(0,v.reflowSmallerGetNewLineLengths)(j,this._cols,d),T=M.length-j.length;let B;B=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+T):Math.max(0,this.lines.length-this.lines.maxLength+T);const I=[];for(let L=0;L<T;L++){const K=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);I.push(K)}I.length>0&&(C.push({start:E+j.length+k,newLines:I}),k+=I.length),j.push(...I);let H=M.length-1,q=M[H];q===0&&(H--,q=M[H]);let A=j.length-T-1,O=P;for(;A>=0;){const L=Math.min(O,q);if(j[H]===void 0)break;if(j[H].copyCellsFrom(j[A],O-L,q-L,L,!0),q-=L,q===0&&(H--,q=M[H]),O-=L,O===0){A--;const K=Math.max(A,0);O=(0,v.getWrappedLineTrimmedLength)(j,K,this._cols)}}for(let L=0;L<j.length;L++)M[L]<d&&j[L].setCell(M[L],S);let D=T-B;for(;D-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+T,this.ybase+f-1)}if(C.length>0){const E=[],y=[];for(let H=0;H<this.lines.length;H++)y.push(this.lines.get(H));const j=this.lines.length;let R=j-1,P=0,M=C[P];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let T=0;for(let H=Math.min(this.lines.maxLength-1,j+k-1);H>=0;H--)if(M&&M.start>R+T){for(let q=M.newLines.length-1;q>=0;q--)this.lines.set(H--,M.newLines[q]);H++,E.push({index:R+1,amount:M.newLines.length}),T+=M.newLines.length,M=C[++P]}else this.lines.set(H,y[R--]);let B=0;for(let H=E.length-1;H>=0;H--)E[H].index+=B,this.lines.onInsertEmitter.fire(E[H]),B+=E[H].amount;const I=Math.max(0,j+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(d,f,S=0,C){const k=this.lines.get(d);return k?k.translateToString(f,S,C):""}getWrappedRangeForLine(d){let f=d,S=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;S+1<this.lines.length&&this.lines.get(S+1).isWrapped;)S++;return{first:f,last:S}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===d&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const f=new l.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((S=>{f.line-=S,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((S=>{f.line>=S.index&&(f.line+=S.amount)}))),f.register(this.lines.onDelete((S=>{f.line>=S.index&&f.line<S.index+S.amount&&f.dispose(),f.line>S.index&&(f.line-=S.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const a=n(3734),h=n(511),c=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new a.AttributeData);let v=0;class _{constructor(l,u,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*l);const f=u||h.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let S=0;S<l;++S)this.setCell(S,f);this.length=l}get(l){const u=this._data[3*l+0],d=2097151&u;return[this._data[3*l+1],2097152&u?this._combined[l]:d?(0,g.stringFromCodePoint)(d):"",u>>22,2097152&u?this._combined[l].charCodeAt(this._combined[l].length-1):d]}set(l,u){this._data[3*l+1]=u[c.CHAR_DATA_ATTR_INDEX],u[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[l]=u[1],this._data[3*l+0]=2097152|l|u[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*l+0]=u[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|u[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(l){return this._data[3*l+0]>>22}hasWidth(l){return 12582912&this._data[3*l+0]}getFg(l){return this._data[3*l+1]}getBg(l){return this._data[3*l+2]}hasContent(l){return 4194303&this._data[3*l+0]}getCodePoint(l){const u=this._data[3*l+0];return 2097152&u?this._combined[l].charCodeAt(this._combined[l].length-1):2097151&u}isCombined(l){return 2097152&this._data[3*l+0]}getString(l){const u=this._data[3*l+0];return 2097152&u?this._combined[l]:2097151&u?(0,g.stringFromCodePoint)(2097151&u):""}isProtected(l){return 536870912&this._data[3*l+2]}loadCell(l,u){return v=3*l,u.content=this._data[v+0],u.fg=this._data[v+1],u.bg=this._data[v+2],2097152&u.content&&(u.combinedData=this._combined[l]),268435456&u.bg&&(u.extended=this._extendedAttrs[l]),u}setCell(l,u){2097152&u.content&&(this._combined[l]=u.combinedData),268435456&u.bg&&(this._extendedAttrs[l]=u.extended),this._data[3*l+0]=u.content,this._data[3*l+1]=u.fg,this._data[3*l+2]=u.bg}setCellFromCodePoint(l,u,d,f,S,C){268435456&S&&(this._extendedAttrs[l]=C),this._data[3*l+0]=u|d<<22,this._data[3*l+1]=f,this._data[3*l+2]=S}addCodepointToCell(l,u){let d=this._data[3*l+0];2097152&d?this._combined[l]+=(0,g.stringFromCodePoint)(u):(2097151&d?(this._combined[l]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(u),d&=-2097152,d|=2097152):d=u|4194304,this._data[3*l+0]=d)}insertCells(l,u,d,f){if((l%=this.length)&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),u<this.length-l){const S=new h.CellData;for(let C=this.length-l-u-1;C>=0;--C)this.setCell(l+u+C,this.loadCell(l+C,S));for(let C=0;C<u;++C)this.setCell(l+C,d)}else for(let S=l;S<this.length;++S)this.setCell(S,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}deleteCells(l,u,d,f){if(l%=this.length,u<this.length-l){const S=new h.CellData;for(let C=0;C<this.length-l-u;++C)this.setCell(l+C,this.loadCell(l+u+C,S));for(let C=this.length-u;C<this.length;++C)this.setCell(C,d)}else for(let S=l;S<this.length;++S)this.setCell(S,d);l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),this.getWidth(l)!==0||this.hasContent(l)||this.setCellFromCodePoint(l,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}replaceCells(l,u,d,f,S=!1){if(S)for(l&&this.getWidth(l-1)===2&&!this.isProtected(l-1)&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),u<this.length&&this.getWidth(u-1)===2&&!this.isProtected(u)&&this.setCellFromCodePoint(u,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<u&&l<this.length;)this.isProtected(l)||this.setCell(l,d),l++;else for(l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),u<this.length&&this.getWidth(u-1)===2&&this.setCellFromCodePoint(u,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<u&&l<this.length;)this.setCell(l++,d)}resize(l,u){if(l===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*l;if(l>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const f=new Uint32Array(d);f.set(this._data),this._data=f}for(let f=this.length;f<l;++f)this.setCell(f,u)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=l&&delete this._combined[k]}const S=Object.keys(this._extendedAttrs);for(let C=0;C<S.length;C++){const k=parseInt(S[C],10);k>=l&&delete this._extendedAttrs[k]}}return this.length=l,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const l=new Uint32Array(this._data.length);return l.set(this._data),this._data=l,1}return 0}fill(l,u=!1){if(u)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,l);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,l)}}copyFrom(l){this.length!==l.length?this._data=new Uint32Array(l._data):this._data.set(l._data),this.length=l.length,this._combined={};for(const u in l._combined)this._combined[u]=l._combined[u];this._extendedAttrs={};for(const u in l._extendedAttrs)this._extendedAttrs[u]=l._extendedAttrs[u];this.isWrapped=l.isWrapped}clone(){const l=new _(0);l._data=new Uint32Array(this._data),l.length=this.length;for(const u in this._combined)l._combined[u]=this._combined[u];for(const u in this._extendedAttrs)l._extendedAttrs[u]=this._extendedAttrs[u];return l.isWrapped=this.isWrapped,l}getTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0])return l+(this._data[3*l+0]>>22);return 0}getNoBgTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0]||50331648&this._data[3*l+2])return l+(this._data[3*l+0]>>22);return 0}copyCellsFrom(l,u,d,f,S){const C=l._data;if(S)for(let E=f-1;E>=0;E--){for(let y=0;y<3;y++)this._data[3*(d+E)+y]=C[3*(u+E)+y];268435456&C[3*(u+E)+2]&&(this._extendedAttrs[d+E]=l._extendedAttrs[u+E])}else for(let E=0;E<f;E++){for(let y=0;y<3;y++)this._data[3*(d+E)+y]=C[3*(u+E)+y];268435456&C[3*(u+E)+2]&&(this._extendedAttrs[d+E]=l._extendedAttrs[u+E])}const k=Object.keys(l._combined);for(let E=0;E<k.length;E++){const y=parseInt(k[E],10);y>=u&&(this._combined[y-u+d]=l._combined[y])}}translateToString(l=!1,u=0,d=this.length){l&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;u<d;){const S=this._data[3*u+0],C=2097151&S;f+=2097152&S?this._combined[u]:C?(0,g.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,u+=S>>22||1}return f}}i.BufferLine=_},4841:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,a){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return a*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(x,i)=>{function n(a,h,c){if(h===a.length-1)return a[h].getTrimmedLength();const g=!a[h].hasContent(c-1)&&a[h].getWidth(c-1)===1,v=a[h+1].getWidth(0)===2;return g&&v?c-1:c}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(a,h,c,g,v){const _=[];for(let w=0;w<a.length-1;w++){let l=w,u=a.get(++l);if(!u.isWrapped)continue;const d=[a.get(w)];for(;l<a.length&&u.isWrapped;)d.push(u),u=a.get(++l);if(g>=w&&g<l){w+=d.length-1;continue}let f=0,S=n(d,f,h),C=1,k=0;for(;C<d.length;){const y=n(d,C,h),j=y-k,R=c-S,P=Math.min(j,R);d[f].copyCellsFrom(d[C],k,S,P,!1),S+=P,S===c&&(f++,S=0),k+=P,k===y&&(C++,k=0),S===0&&f!==0&&d[f-1].getWidth(c-1)===2&&(d[f].copyCellsFrom(d[f-1],c-1,S++,1,!1),d[f-1].setCell(c-1,v))}d[f].replaceCells(S,c,v);let E=0;for(let y=d.length-1;y>0&&(y>f||d[y].getTrimmedLength()===0);y--)E++;E>0&&(_.push(w+d.length-E),_.push(E)),w+=d.length-1}return _},i.reflowLargerCreateNewLayout=function(a,h){const c=[];let g=0,v=h[g],_=0;for(let w=0;w<a.length;w++)if(v===w){const l=h[++g];a.onDeleteEmitter.fire({index:w-_,amount:l}),w+=l-1,_+=l,v=h[++g]}else c.push(w);return{layout:c,countRemoved:_}},i.reflowLargerApplyNewLayout=function(a,h){const c=[];for(let g=0;g<h.length;g++)c.push(a.get(h[g]));for(let g=0;g<c.length;g++)a.set(g,c[g]);a.length=h.length},i.reflowSmallerGetNewLineLengths=function(a,h,c){const g=[],v=a.map(((u,d)=>n(a,d,h))).reduce(((u,d)=>u+d));let _=0,w=0,l=0;for(;l<v;){if(v-l<c){g.push(v-l);break}_+=c;const u=n(a,w,h);_>u&&(_-=u,w++);const d=a[w].getWidth(_-1)===2;d&&_--;const f=d?c-1:c;g.push(f),l+=f}return g},i.getWrappedLineTrimmedLength=n},5295:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const a=n(8460),h=n(844),c=n(9092);class g extends h.Disposable{constructor(_,w){super(),this._optionsService=_,this._bufferService=w,this._onBufferActivate=this.register(new a.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(_,w){this._normal.resize(_,w),this._alt.resize(_,w),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}i.BufferSet=g},511:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const a=n(482),h=n(643),c=n(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(_){const w=new g;return w.setFromCharData(_),w}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,a.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(_){this.fg=_[h.CHAR_DATA_ATTR_INDEX],this.bg=0;let w=!1;if(_[h.CHAR_DATA_CHAR_INDEX].length>2)w=!0;else if(_[h.CHAR_DATA_CHAR_INDEX].length===2){const l=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=l&&l<=56319){const u=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=u&&u<=57343?this.content=1024*(l-55296)+u-56320+65536|_[h.CHAR_DATA_WIDTH_INDEX]<<22:w=!0}else w=!0}else this.content=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[h.CHAR_DATA_WIDTH_INDEX]<<22;w&&(this.combinedData=_[h.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[h.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const a=n(8460),h=n(844);class c{get id(){return this._id}constructor(v){this.line=v,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new a.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,h.disposeArray)(this._disposables),this._disposables.length=0)}register(v){return this._disposables.push(v),v}}i.Marker=c,c._nextId=1},7116:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(x,i)=>{var n,a,h;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
|
|
26
|
-
`,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(n||(i.C0=n={})),(function(c){c.PAD="",c.HOP="",c.BPH="",c.NBH="",c.IND="",c.NEL="
",c.SSA="",c.ESA="",c.HTS="",c.HTJ="",c.VTS="",c.PLD="",c.PLU="",c.RI="",c.SS2="",c.SS3="",c.DCS="",c.PU1="",c.PU2="",c.STS="",c.CCH="",c.MW="",c.SPA="",c.EPA="",c.SOS="",c.SGCI="",c.SCI="",c.CSI="",c.ST="",c.OSC="",c.PM="",c.APC=""})(a||(i.C1=a={})),(function(c){c.ST=`${n.ESC}\\`})(h||(i.C1_ESCAPED=h={}))},7399:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const a=n(2584),h={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(c,g,v,_){const w={type:0,cancel:!1,key:void 0},l=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?w.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?w.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?w.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(w.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B");break;case 8:if(c.altKey){w.key=a.C0.ESC+a.C0.DEL;break}w.key=a.C0.DEL;break;case 9:if(c.shiftKey){w.key=a.C0.ESC+"[Z";break}w.key=a.C0.HT,w.cancel=!0;break;case 13:w.key=c.altKey?a.C0.ESC+a.C0.CR:a.C0.CR,w.cancel=!0;break;case 27:w.key=a.C0.ESC,c.altKey&&(w.key=a.C0.ESC+a.C0.ESC),w.cancel=!0;break;case 37:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"D",w.key===a.C0.ESC+"[1;3D"&&(w.key=a.C0.ESC+(v?"b":"[1;5D"))):w.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D";break;case 39:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"C",w.key===a.C0.ESC+"[1;3C"&&(w.key=a.C0.ESC+(v?"f":"[1;5C"))):w.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C";break;case 38:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"A",v||w.key!==a.C0.ESC+"[1;3A"||(w.key=a.C0.ESC+"[1;5A")):w.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A";break;case 40:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"B",v||w.key!==a.C0.ESC+"[1;3B"||(w.key=a.C0.ESC+"[1;5B")):w.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(w.key=a.C0.ESC+"[2~");break;case 46:w.key=l?a.C0.ESC+"[3;"+(l+1)+"~":a.C0.ESC+"[3~";break;case 36:w.key=l?a.C0.ESC+"[1;"+(l+1)+"H":g?a.C0.ESC+"OH":a.C0.ESC+"[H";break;case 35:w.key=l?a.C0.ESC+"[1;"+(l+1)+"F":g?a.C0.ESC+"OF":a.C0.ESC+"[F";break;case 33:c.shiftKey?w.type=2:c.ctrlKey?w.key=a.C0.ESC+"[5;"+(l+1)+"~":w.key=a.C0.ESC+"[5~";break;case 34:c.shiftKey?w.type=3:c.ctrlKey?w.key=a.C0.ESC+"[6;"+(l+1)+"~":w.key=a.C0.ESC+"[6~";break;case 112:w.key=l?a.C0.ESC+"[1;"+(l+1)+"P":a.C0.ESC+"OP";break;case 113:w.key=l?a.C0.ESC+"[1;"+(l+1)+"Q":a.C0.ESC+"OQ";break;case 114:w.key=l?a.C0.ESC+"[1;"+(l+1)+"R":a.C0.ESC+"OR";break;case 115:w.key=l?a.C0.ESC+"[1;"+(l+1)+"S":a.C0.ESC+"OS";break;case 116:w.key=l?a.C0.ESC+"[15;"+(l+1)+"~":a.C0.ESC+"[15~";break;case 117:w.key=l?a.C0.ESC+"[17;"+(l+1)+"~":a.C0.ESC+"[17~";break;case 118:w.key=l?a.C0.ESC+"[18;"+(l+1)+"~":a.C0.ESC+"[18~";break;case 119:w.key=l?a.C0.ESC+"[19;"+(l+1)+"~":a.C0.ESC+"[19~";break;case 120:w.key=l?a.C0.ESC+"[20;"+(l+1)+"~":a.C0.ESC+"[20~";break;case 121:w.key=l?a.C0.ESC+"[21;"+(l+1)+"~":a.C0.ESC+"[21~";break;case 122:w.key=l?a.C0.ESC+"[23;"+(l+1)+"~":a.C0.ESC+"[23~";break;case 123:w.key=l?a.C0.ESC+"[24;"+(l+1)+"~":a.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(v&&!_||!c.altKey||c.metaKey)!v||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?w.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(w.key=a.C0.US),c.key==="@"&&(w.key=a.C0.NUL)):c.keyCode===65&&(w.type=1);else{const u=h[c.keyCode],d=u?.[c.shiftKey?1:0];if(d)w.key=a.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let S=String.fromCharCode(f);c.shiftKey&&(S=S.toUpperCase()),w.key=a.C0.ESC+S}else if(c.keyCode===32)w.key=a.C0.ESC+(c.ctrlKey?a.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),w.key=a.C0.ESC+f,w.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?w.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?w.key=a.C0.NUL:c.keyCode>=51&&c.keyCode<=55?w.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?w.key=a.C0.DEL:c.keyCode===219?w.key=a.C0.ESC:c.keyCode===220?w.key=a.C0.FS:c.keyCode===221&&(w.key=a.C0.GS)}return w}},482:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,a=0,h=n.length){let c="";for(let g=a;g<h;++g){let v=n[g];v>65535?(v-=65536,c+=String.fromCharCode(55296+(v>>10))+String.fromCharCode(v%1024+56320)):c+=String.fromCharCode(v)}return c},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,a){const h=n.length;if(!h)return 0;let c=0,g=0;if(this._interim){const v=n.charCodeAt(g++);56320<=v&&v<=57343?a[c++]=1024*(this._interim-55296)+v-56320+65536:(a[c++]=this._interim,a[c++]=v),this._interim=0}for(let v=g;v<h;++v){const _=n.charCodeAt(v);if(55296<=_&&_<=56319){if(++v>=h)return this._interim=_,c;const w=n.charCodeAt(v);56320<=w&&w<=57343?a[c++]=1024*(_-55296)+w-56320+65536:(a[c++]=_,a[c++]=w)}else _!==65279&&(a[c++]=_)}return c}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,a){const h=n.length;if(!h)return 0;let c,g,v,_,w=0,l=0,u=0;if(this.interim[0]){let S=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const y=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=y-E;for(;u<j;){if(u>=h)return 0;if(k=n[u++],(192&k)!=128){u--,S=!0;break}this.interim[E++]=k,C<<=6,C|=63&k}S||(y===2?C<128?u--:a[w++]=C:y===3?C<2048||C>=55296&&C<=57343||C===65279||(a[w++]=C):C<65536||C>1114111||(a[w++]=C)),this.interim.fill(0)}const d=h-4;let f=u;for(;f<h;){for(;!(!(f<d)||128&(c=n[f])||128&(g=n[f+1])||128&(v=n[f+2])||128&(_=n[f+3]));)a[w++]=c,a[w++]=g,a[w++]=v,a[w++]=_,f+=4;if(c=n[f++],c<128)a[w++]=c;else if((224&c)==192){if(f>=h)return this.interim[0]=c,w;if(g=n[f++],(192&g)!=128){f--;continue}if(l=(31&c)<<6|63&g,l<128){f--;continue}a[w++]=l}else if((240&c)==224){if(f>=h)return this.interim[0]=c,w;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,w;if(v=n[f++],(192&v)!=128){f--;continue}if(l=(15&c)<<12|(63&g)<<6|63&v,l<2048||l>=55296&&l<=57343||l===65279)continue;a[w++]=l}else if((248&c)==240){if(f>=h)return this.interim[0]=c,w;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,w;if(v=n[f++],(192&v)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=v,w;if(_=n[f++],(192&_)!=128){f--;continue}if(l=(7&c)<<18|(63&g)<<12|(63&v)<<6|63&_,l<65536||l>1114111)continue;a[w++]=l}}return w}}},225:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],a=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let h;i.UnicodeV6=class{constructor(){if(this.version="6",!h){h=new Uint8Array(65536),h.fill(1),h[0]=0,h.fill(0,1,32),h.fill(0,127,160),h.fill(2,4352,4448),h[9001]=2,h[9002]=2,h.fill(2,11904,42192),h[12351]=1,h.fill(2,44032,55204),h.fill(2,63744,64256),h.fill(2,65040,65050),h.fill(2,65072,65136),h.fill(2,65280,65377),h.fill(2,65504,65511);for(let c=0;c<n.length;++c)h.fill(0,n[c][0],n[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?h[c]:(function(g,v){let _,w=0,l=v.length-1;if(g<v[0][0]||g>v[l][1])return!1;for(;l>=w;)if(_=w+l>>1,g>v[_][1])w=_+1;else{if(!(g<v[_][0]))return!0;l=_-1}return!1})(c,a)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const a=n(8460),h=n(844);class c extends h.Disposable{constructor(v){super(),this._action=v,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(v,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let w;for(this._isSyncWriting=!0;w=this._writeBuffer.shift();){this._action(w);const l=this._callbacks.shift();l&&l()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(v,_){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(_),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(_)}_innerWrite(v=0,_=!0){const w=v||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const l=this._writeBuffer[this._bufferOffset],u=this._action(l,_);if(u){const f=S=>Date.now()-w>=12?setTimeout((()=>this._innerWrite(0,S))):this._innerWrite(w,S);return void u.catch((S=>(queueMicrotask((()=>{throw S})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=l.length,Date.now()-w>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}i.WriteBuffer=c},5941:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,a=/^[\da-f]+$/;function h(c,g){const v=c.toString(16),_=v.length<2?"0"+v:v;switch(g){case 4:return v[0];case 8:return _;case 12:return(_+_).slice(0,3);default:return _+_}}i.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const v=n.exec(g);if(v){const _=v[1]?15:v[4]?255:v[7]?4095:65535;return[Math.round(parseInt(v[1]||v[4]||v[7]||v[10],16)/_*255),Math.round(parseInt(v[2]||v[5]||v[8]||v[11],16)/_*255),Math.round(parseInt(v[3]||v[6]||v[9]||v[12],16)/_*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),a.exec(g)&&[3,6,9,12].includes(g.length))){const v=g.length/3,_=[0,0,0];for(let w=0;w<3;++w){const l=parseInt(g.slice(v*w,v*w+v),16);_[w]=v===1?l<<4:v===2?l:v===3?l>>4:l>>8}return _}},i.toRgbString=function(c,g=16){const[v,_,w]=c;return`rgb:${h(v,g)}/${h(_,g)}/${h(w,g)}`}},5770:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const a=n(482),h=n(8742),c=n(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(_,w){this._handlers[_]===void 0&&(this._handlers[_]=[]);const l=this._handlers[_];return l.push(w),{dispose:()=>{const u=l.indexOf(w);u!==-1&&l.splice(u,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}reset(){if(this._active.length)for(let _=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;_>=0;--_)this._active[_].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(_,w){if(this.reset(),this._ident=_,this._active=this._handlers[_]||g,this._active.length)for(let l=this._active.length-1;l>=0;l--)this._active[l].hook(w);else this._handlerFb(this._ident,"HOOK",w)}put(_,w,l){if(this._active.length)for(let u=this._active.length-1;u>=0;u--)this._active[u].put(_,w,l);else this._handlerFb(this._ident,"PUT",(0,a.utf32ToString)(_,w,l))}unhook(_,w=!0){if(this._active.length){let l=!1,u=this._active.length-1,d=!1;if(this._stack.paused&&(u=this._stack.loopPosition-1,l=w,d=this._stack.fallThrough,this._stack.paused=!1),!d&&l===!1){for(;u>=0&&(l=this._active[u].unhook(_),l!==!0);u--)if(l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!1,l;u--}for(;u>=0;u--)if(l=this._active[u].unhook(!1),l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!0,l}else this._handlerFb(this._ident,"UNHOOK",_);this._active=g,this._ident=0}};const v=new h.Params;v.addParam(0),i.DcsHandler=class{constructor(_){this._handler=_,this._data="",this._params=v,this._hitLimit=!1}hook(_){this._params=_.length>1||_.params[0]?_.clone():v,this._data="",this._hitLimit=!1}put(_,w,l){this._hitLimit||(this._data+=(0,a.utf32ToString)(_,w,l),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(_){let w=!1;if(this._hitLimit)w=!1;else if(_&&(w=this._handler(this._data,this._params),w instanceof Promise))return w.then((l=>(this._params=v,this._data="",this._hitLimit=!1,l)));return this._params=v,this._data="",this._hitLimit=!1,w}}},2015:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const a=n(844),h=n(8742),c=n(6242),g=n(6351);class v{constructor(u){this.table=new Uint8Array(u)}setDefault(u,d){this.table.fill(u<<4|d)}add(u,d,f,S){this.table[d<<8|u]=f<<4|S}addMany(u,d,f,S){for(let C=0;C<u.length;C++)this.table[d<<8|u[C]]=f<<4|S}}i.TransitionTable=v;const _=160;i.VT500_TRANSITION_TABLE=(function(){const l=new v(4095),u=Array.apply(null,Array(256)).map(((E,y)=>y)),d=(E,y)=>u.slice(E,y),f=d(32,127),S=d(0,24);S.push(25),S.push.apply(S,d(28,32));const C=d(0,14);let k;for(k in l.setDefault(1,0),l.addMany(f,0,2,0),C)l.addMany([24,26,153,154],k,3,0),l.addMany(d(128,144),k,3,0),l.addMany(d(144,152),k,3,0),l.add(156,k,0,0),l.add(27,k,11,1),l.add(157,k,4,8),l.addMany([152,158,159],k,0,7),l.add(155,k,11,3),l.add(144,k,11,9);return l.addMany(S,0,3,0),l.addMany(S,1,3,1),l.add(127,1,0,1),l.addMany(S,8,0,8),l.addMany(S,3,3,3),l.add(127,3,0,3),l.addMany(S,4,3,4),l.add(127,4,0,4),l.addMany(S,6,3,6),l.addMany(S,5,3,5),l.add(127,5,0,5),l.addMany(S,2,3,2),l.add(127,2,0,2),l.add(93,1,4,8),l.addMany(f,8,5,8),l.add(127,8,5,8),l.addMany([156,27,24,26,7],8,6,0),l.addMany(d(28,32),8,0,8),l.addMany([88,94,95],1,0,7),l.addMany(f,7,0,7),l.addMany(S,7,0,7),l.add(156,7,0,0),l.add(127,7,0,7),l.add(91,1,11,3),l.addMany(d(64,127),3,7,0),l.addMany(d(48,60),3,8,4),l.addMany([60,61,62,63],3,9,4),l.addMany(d(48,60),4,8,4),l.addMany(d(64,127),4,7,0),l.addMany([60,61,62,63],4,0,6),l.addMany(d(32,64),6,0,6),l.add(127,6,0,6),l.addMany(d(64,127),6,0,0),l.addMany(d(32,48),3,9,5),l.addMany(d(32,48),5,9,5),l.addMany(d(48,64),5,0,6),l.addMany(d(64,127),5,7,0),l.addMany(d(32,48),4,9,5),l.addMany(d(32,48),1,9,2),l.addMany(d(32,48),2,9,2),l.addMany(d(48,127),2,10,0),l.addMany(d(48,80),1,10,0),l.addMany(d(81,88),1,10,0),l.addMany([89,90,92],1,10,0),l.addMany(d(96,127),1,10,0),l.add(80,1,11,9),l.addMany(S,9,0,9),l.add(127,9,0,9),l.addMany(d(28,32),9,0,9),l.addMany(d(32,48),9,9,12),l.addMany(d(48,60),9,8,10),l.addMany([60,61,62,63],9,9,10),l.addMany(S,11,0,11),l.addMany(d(32,128),11,0,11),l.addMany(d(28,32),11,0,11),l.addMany(S,10,0,10),l.add(127,10,0,10),l.addMany(d(28,32),10,0,10),l.addMany(d(48,60),10,8,10),l.addMany([60,61,62,63],10,0,11),l.addMany(d(32,48),10,9,12),l.addMany(S,12,0,12),l.add(127,12,0,12),l.addMany(d(28,32),12,0,12),l.addMany(d(32,48),12,9,12),l.addMany(d(48,64),12,0,11),l.addMany(d(64,127),12,12,13),l.addMany(d(64,127),10,12,13),l.addMany(d(64,127),9,12,13),l.addMany(S,13,13,13),l.addMany(f,13,13,13),l.add(127,13,0,13),l.addMany([27,156,24,26],13,14,0),l.add(_,0,2,0),l.add(_,8,5,8),l.add(_,6,0,6),l.add(_,11,0,11),l.add(_,13,13,13),l})();class w extends a.Disposable{constructor(u=i.VT500_TRANSITION_TABLE){super(),this._transitions=u,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new h.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,f,S)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,f)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,a.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(u,d=[64,126]){let f=0;if(u.prefix){if(u.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=u.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(u.intermediates){if(u.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<u.intermediates.length;++C){const k=u.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(u.final.length!==1)throw new Error("final must be a single byte");const S=u.final.charCodeAt(0);if(d[0]>S||S>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=S,f}identToString(u){const d=[];for(;u;)d.push(String.fromCharCode(255&u)),u>>=8;return d.reverse().join("")}setPrintHandler(u){this._printHandler=u}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(u,d){const f=this._identifier(u,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const S=this._escHandlers[f];return S.push(d),{dispose:()=>{const C=S.indexOf(d);C!==-1&&S.splice(C,1)}}}clearEscHandler(u){this._escHandlers[this._identifier(u,[48,126])]&&delete this._escHandlers[this._identifier(u,[48,126])]}setEscHandlerFallback(u){this._escHandlerFb=u}setExecuteHandler(u,d){this._executeHandlers[u.charCodeAt(0)]=d}clearExecuteHandler(u){this._executeHandlers[u.charCodeAt(0)]&&delete this._executeHandlers[u.charCodeAt(0)]}setExecuteHandlerFallback(u){this._executeHandlerFb=u}registerCsiHandler(u,d){const f=this._identifier(u);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const S=this._csiHandlers[f];return S.push(d),{dispose:()=>{const C=S.indexOf(d);C!==-1&&S.splice(C,1)}}}clearCsiHandler(u){this._csiHandlers[this._identifier(u)]&&delete this._csiHandlers[this._identifier(u)]}setCsiHandlerFallback(u){this._csiHandlerFb=u}registerDcsHandler(u,d){return this._dcsParser.registerHandler(this._identifier(u),d)}clearDcsHandler(u){this._dcsParser.clearHandler(this._identifier(u))}setDcsHandlerFallback(u){this._dcsParser.setHandlerFallback(u)}registerOscHandler(u,d){return this._oscParser.registerHandler(u,d)}clearOscHandler(u){this._oscParser.clearHandler(u)}setOscHandlerFallback(u){this._oscParser.setHandlerFallback(u)}setErrorHandler(u){this._errorHandler=u}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(u,d,f,S,C){this._parseStack.state=u,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=S,this._parseStack.chunkPos=C}parse(u,d,f){let S,C=0,k=0,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const y=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(S=y[j](this._params),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(S=y[j](),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 6:if(C=u[this._parseStack.chunkPos],S=this._dcsParser.unhook(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=u[this._parseStack.chunkPos],S=this._oscParser.end(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let y=E;y<d;++y){switch(C=u[y],k=this._transitions.table[this.currentState<<8|(C<160?C:_)],k>>4){case 2:for(let T=y+1;;++T){if(T>=d||(C=u[T])<32||C>126&&C<_){this._printHandler(u,y,T),y=T-1;break}if(++T>=d||(C=u[T])<32||C>126&&C<_){this._printHandler(u,y,T),y=T-1;break}if(++T>=d||(C=u[T])<32||C>126&&C<_){this._printHandler(u,y,T),y=T-1;break}if(++T>=d||(C=u[T])<32||C>126&&C<_){this._printHandler(u,y,T),y=T-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:y,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|C];let R=j?j.length-1:-1;for(;R>=0&&(S=j[R](this._params),S!==!0);R--)if(S instanceof Promise)return this._preserveStack(3,j,R,k,y),S;R<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++y<d&&(C=u[y])>47&&C<60);y--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const P=this._escHandlers[this._collect<<8|C];let M=P?P.length-1:-1;for(;M>=0&&(S=P[M](),S!==!0);M--)if(S instanceof Promise)return this._preserveStack(4,P,M,k,y),S;M<0&&this._escHandlerFb(this._collect<<8|C),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|C,this._params);break;case 13:for(let T=y+1;;++T)if(T>=d||(C=u[T])===24||C===26||C===27||C>127&&C<_){this._dcsParser.put(u,y,T),y=T-1;break}break;case 14:if(S=this._dcsParser.unhook(C!==24&&C!==26),S)return this._preserveStack(6,[],0,k,y),S;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let T=y+1;;T++)if(T>=d||(C=u[T])<32||C>127&&C<_){this._oscParser.put(u,y,T),y=T-1;break}break;case 6:if(S=this._oscParser.end(C!==24&&C!==26),S)return this._preserveStack(5,[],0,k,y),S;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=w},6242:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const a=n(5770),h=n(482),c=[];i.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,v){this._handlers[g]===void 0&&(this._handlers[g]=[]);const _=this._handlers[g];return _.push(v),{dispose:()=>{const w=_.indexOf(v);w!==-1&&_.splice(w,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,v,_){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(g,v,_);else this._handlerFb(this._id,"PUT",(0,h.utf32ToString)(g,v,_))}start(){this.reset(),this._state=1}put(g,v,_){if(this._state!==3){if(this._state===1)for(;v<_;){const w=g[v++];if(w===59){this._state=2,this._start();break}if(w<48||57<w)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+w-48}this._state===2&&_-v>0&&this._put(g,v,_)}}end(g,v=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let _=!1,w=this._active.length-1,l=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,_=v,l=this._stack.fallThrough,this._stack.paused=!1),!l&&_===!1){for(;w>=0&&(_=this._active[w].end(g),_!==!0);w--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,_;w--}for(;w>=0;w--)if(_=this._active[w].end(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,_}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,v,_){this._hitLimit||(this._data+=(0,h.utf32ToString)(g,v,_),this._data.length>a.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let v=!1;if(this._hitLimit)v=!1;else if(g&&(v=this._handler(this._data),v instanceof Promise))return v.then((_=>(this._data="",this._hitLimit=!1,_)));return this._data="",this._hitLimit=!1,v}}},8742:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class a{static fromArray(c){const g=new a;if(!c.length)return g;for(let v=Array.isArray(c[0])?1:0;v<c.length;++v){const _=c[v];if(Array.isArray(_))for(let w=0;w<_.length;++w)g.addSubParam(_[w]);else g.addParam(_)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new a(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const v=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-v>0&&c.push(Array.prototype.slice.call(this._subParams,v,_))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>n?n:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>n?n:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,v=255&this._subParamsIdx[c];return v-g>0?this._subParams.subarray(g,v):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const v=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-v>0&&(c[g]=this._subParams.slice(v,_))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const v=this._digitIsSub?this._subParams:this.params,_=v[g-1];v[g-1]=~_?Math.min(10*_+c,n):c}}i.Params=a},5741:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,a){const h={instance:a,dispose:a.dispose,isDisposed:!1};this._addons.push(h),a.dispose=()=>this._wrappedAddonDispose(h),a.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let a=-1;for(let h=0;h<this._addons.length;h++)if(this._addons[h]===n){a=h;break}if(a===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(a,1)}}},8771:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const a=n(3785),h=n(511);i.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(c){const g=this._buffer.lines.get(c);if(g)return new a.BufferLineApiView(g)}getNullCell(){return new h.CellData}}},3785:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const a=n(511);i.BufferLineApiView=class{constructor(h){this._line=h}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(h,c){if(!(h<0||h>=this._line.length))return c?(this._line.loadCell(h,c),c):this._line.loadCell(h,new a.CellData)}translateToString(h,c,g){return this._line.translateToString(h,c,g)}}},8285:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const a=n(8771),h=n(8460),c=n(844);class g extends c.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this.register(new h.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new a.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new a.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}i.BufferNamespaceApi=g},7975:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,a){return this._core.registerCsiHandler(n,(h=>a(h.toArray())))}addCsiHandler(n,a){return this.registerCsiHandler(n,a)}registerDcsHandler(n,a){return this._core.registerDcsHandler(n,((h,c)=>a(h,c.toArray())))}addDcsHandler(n,a){return this.registerDcsHandler(n,a)}registerEscHandler(n,a){return this._core.registerEscHandler(n,a)}addEscHandler(n,a){return this.registerEscHandler(n,a)}registerOscHandler(n,a){return this._core.registerOscHandler(n,a)}addOscHandler(n,a){return this.registerOscHandler(n,a)}}},7090:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const c=n(8460),g=n(844),v=n(5295),_=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let w=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(l){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(l.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(l.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new v.BufferSet(l,this))}resize(l,u){this.cols=l,this.rows=u,this.buffers.resize(l,u),this._onResize.fire({cols:l,rows:u})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(l,u=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===l.fg&&f.getBg(0)===l.bg||(f=d.getBlankLine(l,u),this._cachedBlankLine=f),f.isWrapped=u;const S=d.ybase+d.scrollTop,C=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;C===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=C-S+1;d.lines.shiftElements(S+1,k-1,-1),d.lines.set(C,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(l,u,d){const f=this.buffer;if(l<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else l+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const S=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+l,f.ybase),0),S!==f.ydisp&&(u||this._onScroll.fire(f.ydisp))}};i.BufferService=w=a([h(0,_.IOptionsService)],w)},7994:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,a){this._charsets[n]=a,this.glevel===n&&(this.charset=a)}}},1753:function(x,i,n){var a=this&&this.__decorate||function(f,S,C,k){var E,y=arguments.length,j=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var R=f.length-1;R>=0;R--)(E=f[R])&&(j=(y<3?E(j):y>3?E(S,C,j):E(S,C))||j);return y>3&&j&&Object.defineProperty(S,C,j),j},h=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const c=n(2585),g=n(8460),v=n(844),_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function w(f,S){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||S||(C|=3)),C}const l=String.fromCharCode,u={DEFAULT:f=>{const S=[w(f,!1)+32,f.col+32,f.row+32];return S[0]>255||S[1]>255||S[2]>255?"":`\x1B[M${l(S[0])}${l(S[1])}${l(S[2])}`},SGR:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.col};${f.row}${S}`},SGR_PIXELS:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.x};${f.y}${S}`}};let d=i.CoreMouseService=class extends v.Disposable{constructor(f,S){super(),this._bufferService=f,this._coreService=S,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const C of Object.keys(_))this.addProtocol(C,_[C]);for(const C of Object.keys(u))this.addEncoding(C,u[C]);this.reset()}addProtocol(f,S){this._protocols[f]=S}addEncoding(f,S){this._encodings[f]=S}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const S=this._encodings[this._activeEncoding](f);return S&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(S):this._coreService.triggerDataEvent(S,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,S,C){if(C){if(f.x!==S.x||f.y!==S.y)return!1}else if(f.col!==S.col||f.row!==S.row)return!1;return f.button===S.button&&f.action===S.action&&f.ctrl===S.ctrl&&f.alt===S.alt&&f.shift===S.shift}};i.CoreMouseService=d=a([h(0,c.IBufferService),h(1,c.ICoreService)],d)},6975:function(x,i,n){var a=this&&this.__decorate||function(d,f,S,C){var k,E=arguments.length,y=E<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,S):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(d,f,S,C);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(y=(E<3?k(y):E>3?k(f,S,y):k(f,S))||y);return E>3&&y&&Object.defineProperty(f,S,y),y},h=this&&this.__param||function(d,f){return function(S,C){f(S,C,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const c=n(1439),g=n(8460),v=n(844),_=n(2585),w=Object.freeze({insertMode:!1}),l=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let u=i.CoreService=class extends v.Disposable{constructor(d,f,S){super(),this._bufferService=d,this._logService=f,this._optionsService=S,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(w),this.decPrivateModes=(0,c.clone)(l)}reset(){this.modes=(0,c.clone)(w),this.decPrivateModes=(0,c.clone)(l)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const S=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&S.ybase!==S.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=u=a([h(0,_.IBufferService),h(1,_.ILogService),h(2,_.IOptionsService)],u)},9074:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const a=n(8055),h=n(8460),c=n(844),g=n(6106);let v=0,_=0;class w extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new h.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new h.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const f=new l(d);if(f){const S=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),S.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,f,S){var C,k,E;let y=0,j=0;for(const R of this._decorations.getKeyIterator(f))y=(C=R.options.x)!==null&&C!==void 0?C:0,j=y+((k=R.options.width)!==null&&k!==void 0?k:1),d>=y&&d<j&&(!S||((E=R.options.layer)!==null&&E!==void 0?E:"bottom")===S)&&(yield R)}forEachDecorationAtCell(d,f,S,C){this._decorations.forEachByKey(f,(k=>{var E,y,j;v=(E=k.options.x)!==null&&E!==void 0?E:0,_=v+((y=k.options.width)!==null&&y!==void 0?y:1),d>=v&&d<_&&(!S||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===S)&&C(k)}))}}i.DecorationService=w;class l extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=a.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=a.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new h.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const a=n(2585),h=n(8343);class c{constructor(...v){this._entries=new Map;for(const[_,w]of v)this.set(_,w)}set(v,_){const w=this._entries.get(v);return this._entries.set(v,_),w}forEach(v){for(const[_,w]of this._entries.entries())v(_,w)}has(v){return this._entries.has(v)}get(v){return this._entries.get(v)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(a.IInstantiationService,this)}setService(g,v){this._services.set(g,v)}getService(g){return this._services.get(g)}createInstance(g,...v){const _=(0,h.getServiceDependencies)(g).sort(((u,d)=>u.index-d.index)),w=[];for(const u of _){const d=this._services.get(u.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${u.id}.`);w.push(d)}const l=_.length>0?_[0].index:v.length;if(v.length!==l)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${l+1} conflicts with ${v.length} static arguments`);return new g(...v,...w)}}},7866:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var E=l.length-1;E>=0;E--)(S=l[E])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const c=n(844),g=n(2585),v={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let _,w=i.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(l){super(),this._optionsService=l,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),_=this}_updateLogLevel(){this._logLevel=v[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(l){for(let u=0;u<l.length;u++)typeof l[u]=="function"&&(l[u]=l[u]())}_log(l,u,d){this._evalLazyOptionalParams(d),l.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+u,...d)}trace(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,u)}debug(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,u)}info(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,l,u)}warn(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,l,u)}error(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,l,u)}};i.LogService=w=a([h(0,g.IOptionsService)],w),i.setTraceLogger=function(l){_=l},i.traceCall=function(l,u,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...S){if(_.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,S);_.trace(`GlyphRenderer#${f.name}(${S.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,S);return _.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const a=n(8460),h=n(844),c=n(6114);i.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class v extends h.Disposable{constructor(w){super(),this._onOptionChange=this.register(new a.EventEmitter),this.onOptionChange=this._onOptionChange.event;const l=Object.assign({},i.DEFAULT_OPTIONS);for(const u in w)if(u in l)try{const d=w[u];l[u]=this._sanitizeAndValidateOption(u,d)}catch(d){console.error(d)}this.rawOptions=l,this.options=Object.assign({},l),this._setupOptions()}onSpecificOptionChange(w,l){return this.onOptionChange((u=>{u===w&&l(this.rawOptions[w])}))}onMultipleOptionChange(w,l){return this.onOptionChange((u=>{w.indexOf(u)!==-1&&l()}))}_setupOptions(){const w=u=>{if(!(u in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${u}"`);return this.rawOptions[u]},l=(u,d)=>{if(!(u in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${u}"`);d=this._sanitizeAndValidateOption(u,d),this.rawOptions[u]!==d&&(this.rawOptions[u]=d,this._onOptionChange.fire(u))};for(const u in this.rawOptions){const d={get:w.bind(this,u),set:l.bind(this,u)};Object.defineProperty(this.options,u,d)}}_sanitizeAndValidateOption(w,l){switch(w){case"cursorStyle":if(l||(l=i.DEFAULT_OPTIONS[w]),!(function(u){return u==="block"||u==="underline"||u==="bar"})(l))throw new Error(`"${l}" is not a valid value for ${w}`);break;case"wordSeparator":l||(l=i.DEFAULT_OPTIONS[w]);break;case"fontWeight":case"fontWeightBold":if(typeof l=="number"&&1<=l&&l<=1e3)break;l=g.includes(l)?l:i.DEFAULT_OPTIONS[w];break;case"cursorWidth":l=Math.floor(l);case"lineHeight":case"tabStopWidth":if(l<1)throw new Error(`${w} cannot be less than 1, value: ${l}`);break;case"minimumContrastRatio":l=Math.max(1,Math.min(21,Math.round(10*l)/10));break;case"scrollback":if((l=Math.min(l,4294967295))<0)throw new Error(`${w} cannot be less than 0, value: ${l}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(l<=0)throw new Error(`${w} cannot be less than or equal to 0, value: ${l}`);break;case"rows":case"cols":if(!l&&l!==0)throw new Error(`${w} must be numeric, value: ${l}`);break;case"windowsPty":l=l??{}}return l}}i.OptionsService=v},2660:function(x,i,n){var a=this&&this.__decorate||function(v,_,w,l){var u,d=arguments.length,f=d<3?_:l===null?l=Object.getOwnPropertyDescriptor(_,w):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(v,_,w,l);else for(var S=v.length-1;S>=0;S--)(u=v[S])&&(f=(d<3?u(f):d>3?u(_,w,f):u(_,w))||f);return d>3&&f&&Object.defineProperty(_,w,f),f},h=this&&this.__param||function(v,_){return function(w,l){_(w,l,v)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=n(2585);let g=i.OscLinkService=class{constructor(v){this._bufferService=v,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(v){const _=this._bufferService.buffer;if(v.id===void 0){const S=_.addMarker(_.ybase+_.y),C={data:v,id:this._nextId++,lines:[S]};return S.onDispose((()=>this._removeMarkerFromLink(C,S))),this._dataByLinkId.set(C.id,C),C.id}const w=v,l=this._getEntryIdKey(w),u=this._entriesWithId.get(l);if(u)return this.addLineToLink(u.id,_.ybase+_.y),u.id;const d=_.addMarker(_.ybase+_.y),f={id:this._nextId++,key:this._getEntryIdKey(w),data:w,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(v,_){const w=this._dataByLinkId.get(v);if(w&&w.lines.every((l=>l.line!==_))){const l=this._bufferService.buffer.addMarker(_);w.lines.push(l),l.onDispose((()=>this._removeMarkerFromLink(w,l)))}}getLinkData(v){var _;return(_=this._dataByLinkId.get(v))===null||_===void 0?void 0:_.data}_getEntryIdKey(v){return`${v.id};;${v.uri}`}_removeMarkerFromLink(v,_){const w=v.lines.indexOf(_);w!==-1&&(v.lines.splice(w,1),v.lines.length===0&&(v.data.id!==void 0&&this._entriesWithId.delete(v.key),this._dataByLinkId.delete(v.id)))}};i.OscLinkService=g=a([h(0,c.IBufferService)],g)},8343:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",a="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(h){return h[a]||[]},i.createDecorator=function(h){if(i.serviceRegistry.has(h))return i.serviceRegistry.get(h);const c=function(g,v,_){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(w,l,u){l[n]===l?l[a].push({id:w,index:u}):(l[a]=[{id:w,index:u}],l[n]=l)})(c,g,_)};return c.toString=()=>h,i.serviceRegistry.set(h,c),c}},2585:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const a=n(8343);var h;i.IBufferService=(0,a.createDecorator)("BufferService"),i.ICoreMouseService=(0,a.createDecorator)("CoreMouseService"),i.ICoreService=(0,a.createDecorator)("CoreService"),i.ICharsetService=(0,a.createDecorator)("CharsetService"),i.IInstantiationService=(0,a.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(h||(i.LogLevelEnum=h={})),i.ILogService=(0,a.createDecorator)("LogService"),i.IOptionsService=(0,a.createDecorator)("OptionsService"),i.IOscLinkService=(0,a.createDecorator)("OscLinkService"),i.IUnicodeService=(0,a.createDecorator)("UnicodeService"),i.IDecorationService=(0,a.createDecorator)("DecorationService")},1480:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const a=n(8460),h=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new a.EventEmitter,this.onChange=this._onChange.event;const c=new h.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const v=c.length;for(let _=0;_<v;++_){let w=c.charCodeAt(_);if(55296<=w&&w<=56319){if(++_>=v)return g+this.wcwidth(w);const l=c.charCodeAt(_);56320<=l&&l<=57343?w=1024*(w-55296)+l-56320+65536:g+=this.wcwidth(l)}g+=this.wcwidth(w)}return g}}}},o={};function p(x){var i=o[x];if(i!==void 0)return i.exports;var n=o[x]={exports:{}};return r[x].call(n.exports,n,n.exports,p),n.exports}var m={};return(()=>{var x=m;Object.defineProperty(x,"__esModule",{value:!0}),x.Terminal=void 0;const i=p(9042),n=p(3236),a=p(844),h=p(5741),c=p(8285),g=p(7975),v=p(7090),_=["cols","rows"];class w extends a.Disposable{constructor(u){super(),this._core=this.register(new n.Terminal(u)),this._addonManager=this.register(new h.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=S=>this._core.options[S],f=(S,C)=>{this._checkReadonlyOptions(S),this._core.options[S]=C};for(const S in this._core.options){const C={get:d.bind(this,S),set:f.bind(this,S)};Object.defineProperty(this._publicOptions,S,C)}}_checkReadonlyOptions(u){if(_.includes(u))throw new Error(`Option "${u}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new v.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const u=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:u.applicationCursorKeys,applicationKeypadMode:u.applicationKeypad,bracketedPasteMode:u.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:u.origin,reverseWraparoundMode:u.reverseWraparound,sendFocusMode:u.sendFocus,wraparoundMode:u.wraparound}}get options(){return this._publicOptions}set options(u){for(const d in u)this._publicOptions[d]=u[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(u,d){this._verifyIntegers(u,d),this._core.resize(u,d)}open(u){this._core.open(u)}attachCustomKeyEventHandler(u){this._core.attachCustomKeyEventHandler(u)}registerLinkProvider(u){return this._core.registerLinkProvider(u)}registerCharacterJoiner(u){return this._checkProposedApi(),this._core.registerCharacterJoiner(u)}deregisterCharacterJoiner(u){this._checkProposedApi(),this._core.deregisterCharacterJoiner(u)}registerMarker(u=0){return this._verifyIntegers(u),this._core.registerMarker(u)}registerDecoration(u){var d,f,S;return this._checkProposedApi(),this._verifyPositiveIntegers((d=u.x)!==null&&d!==void 0?d:0,(f=u.width)!==null&&f!==void 0?f:0,(S=u.height)!==null&&S!==void 0?S:0),this._core.registerDecoration(u)}hasSelection(){return this._core.hasSelection()}select(u,d,f){this._verifyIntegers(u,d,f),this._core.select(u,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(u,d){this._verifyIntegers(u,d),this._core.selectLines(u,d)}dispose(){super.dispose()}scrollLines(u){this._verifyIntegers(u),this._core.scrollLines(u)}scrollPages(u){this._verifyIntegers(u),this._core.scrollPages(u)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(u){this._verifyIntegers(u),this._core.scrollToLine(u)}clear(){this._core.clear()}write(u,d){this._core.write(u,d)}writeln(u,d){this._core.write(u),this._core.write(`\r
|
|
27
|
-
`,d)}paste(u){this._core.paste(u)}refresh(u,d){this._verifyIntegers(u,d),this._core.refresh(u,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(u){this._addonManager.loadAddon(this,u)}static get strings(){return i}_verifyIntegers(...u){for(const d of u)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...u){for(const d of u)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}x.Terminal=w})(),m})()))})(Hi)),Hi.exports}var np=ip();var op=2,ap=1,lp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),x={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},i=x.top+x.bottom,n=x.right+x.left,a=o-i,h=p-n-s;return{cols:Math.max(op,Math.floor(h/e.css.cell.width)),rows:Math.max(ap,Math.floor(a/e.css.cell.height))}}};function cp(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[x,i]=b.useState(null),[n,a]=b.useState(()=>cs.isConnected()),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(!1),l=b.useRef({onOutput:p,onExit:m});l.current={onOutput:p,onExit:m};const u=b.useRef(null);u.current=x,b.useEffect(()=>{if(!x)return;const k=cs.getSocket(),E=()=>{a(!0),c(!1),i(null),w(!0)},y=()=>{a(!1),c(!1)},j=T=>{T.terminalId===x&&l.current.onOutput?.(T.data)},R=T=>{T.terminalId===x&&(c(!1),l.current.onExit?.(T.exitCode),i(null))},P=T=>{T.terminalId===x&&c(!0)},M=T=>{T.terminalId===x&&c(!1)};return k.on("connect",E),k.on("disconnect",y),k.on(dt.TERMINAL_STDOUT,j),k.on(dt.TERMINAL_EXIT,R),k.on(dt.TERMINAL_SUBSCRIBED,P),k.on(dt.TERMINAL_UNSUBSCRIBED,M),a(k.connected),k.connected&&k.emit(Ws.SUBSCRIBE,{topic:"terminal",id:x},T=>{T.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",y),k.off(dt.TERMINAL_STDOUT,j),k.off(dt.TERMINAL_EXIT,R),k.off(dt.TERMINAL_SUBSCRIBED,P),k.off(dt.TERMINAL_UNSUBSCRIBED,M),k.emit(Ws.UNSUBSCRIBE,{topic:"terminal",id:x})}},[x]);const d=b.useCallback(async()=>{const k=cs.getSocket();if(!k.connected)return null;v(!0);try{const E=await ye.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return i(E.terminalId),w(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{v(!1)}},[s,r,o]),f=b.useCallback(async()=>{const k=u.current;if(k){try{await ye.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}i(null),c(!1)}},[]),S=b.useCallback(k=>{const E=u.current;if(!E)return;cs.getSocket().emit(Ws.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=b.useCallback((k,E)=>{const y=u.current;if(!y)return;cs.getSocket().emit(Ws.TERMINAL_RESIZE,{terminalId:y,cols:k,rows:E})},[]);return b.useEffect(()=>()=>{const k=u.current;k&&ye.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:x,isConnected:n,isAttached:h,isCreating:g,needsRecreate:_,create:d,destroy:f,sendInput:S,resize:C}}function dp({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:p}){const m=b.useRef(null),x=b.useRef(null),i=b.useRef(0),n=b.useCallback(()=>{m.current!=null&&(window.clearTimeout(m.current),m.current=null),x.current!=null&&(window.cancelAnimationFrame(x.current),x.current=null)},[]),a=b.useCallback(()=>{const g=r.current,v=s.current,_=e.current;if(!g||!v||!_||_.clientWidth<=0||_.clientHeight<=0)return!1;try{return g.fit(),v.cols>0&&v.rows>0&&p(v.cols,v.rows),!0}catch{return!1}},[r,p,e,s]),h=b.useCallback((g=6)=>{n();const v=i.current+1;i.current=v;let _=0;const w=()=>{i.current===v&&(x.current=window.requestAnimationFrame(()=>{if(x.current=null,i.current!==v)return;const l=a(),u=_<2;_<g&&(!l||u)&&(_+=1,m.current=window.setTimeout(w,50))}))};w()},[n,a]),c=b.useCallback(()=>{i.current+=1,n()},[n]);return b.useEffect(()=>c,[c]),b.useEffect(()=>{o&&h(8)},[o,h]),b.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){h(8);return}const v=new ResizeObserver(()=>{h(4)});return v.observe(g),g.parentElement&&v.observe(g.parentElement),h(8),()=>{v.disconnect()}},[h,e]),{fitNow:a,scheduleFit:h}}const up={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},hp=ue.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=b.useRef(null),x=b.useRef(null),i=b.useRef(null),n=b.useRef(!1),{terminalId:a,isAttached:h,needsRecreate:c,create:g,sendInput:v,resize:_}=cp({cwd:s,onOutput:b.useCallback(u=>{x.current?.write(u)},[]),onExit:b.useCallback(u=>{x.current?.writeln(`\r
|
|
28
|
-
\x1B[90m[Process exited with code ${u}]\x1B[0m`),o?.(u)},[o])}),{scheduleFit:w}=dp({terminalRef:m,xtermRef:x,fitAddonRef:i,isVisible:r,onResize:_}),l=b.useCallback(u=>{x.current?.paste(u)},[]);return b.useEffect(()=>{r||x.current?.blur()},[r]),b.useEffect(()=>{if(!c)return;const u=x.current;u&&u.writeln(`\r
|
|
29
|
-
\x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),b.useLayoutEffect(()=>{if(!m.current)return;const u=new np.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:up,scrollback:5e3,convertEol:!0}),d=new lp;return u.loadAddon(d),u.open(m.current),x.current=u,i.current=d,w(8),()=>{u.dispose(),x.current=null,i.current=null}},[w]),b.useEffect(()=>{n.current||(n.current=!0,g())},[g]),b.useEffect(()=>{const u=x.current;if(!u||!h)return;const d=u.onData(f=>{v(f)});return()=>d.dispose()},[v,h]),b.useEffect(()=>{h&&(w(4),p?.({sendInput:v,paste:l}))},[h,p,l,w,v]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!a&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:m,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),fp=ue.memo(function({commands:s,onSelect:r}){const{t:o}=de(),[p,m]=b.useState(!1),x=b.useRef(null),i=b.useRef(null);return b.useEffect(()=>{if(!p)return;const n=a=>{x.current&&!x.current.contains(a.target)&&i.current&&!i.current.contains(a.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[p]),s.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:i,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Qd,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(wt,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:x,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:s.map((n,a)=>t.jsxs("button",{onClick:()=>{r(n.command),m(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(ks,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},a))})})]})]})}),ec="\x1B",mp="\x07",pp="";function gp(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function Go(e,s){let r=s;for(;r<e.length;){if(e[r]===mp||e[r]===pp)return r+1;if(e[r]===ec&&e[r+1]==="\\")return r+2;r+=1}return r}function Qo(e,s){let r=s;for(;r<e.length&&!gp(e[r]);)r+=1;return r<e.length?r+1:r}function vp(e){let s="";for(let r=0;r<e.length;){if(e[r]===""){r=Qo(e,r+1);continue}if(e[r]===""){r=Go(e,r+1);continue}if(e[r]!==ec){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=Qo(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=Go(e,r+2);continue}for(r+=1;r<e.length;){const p=e.charCodeAt(r);if(p<32||p>47)break;r+=1}r<e.length&&(r+=1)}return s}const xp=200,bp=1e3,_p=512*1024;function yp(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>bp||s>_p&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function Sp(e,s){const r=!!e&&e.runtimeInstanceId!==s.runtimeInstanceId,o=r||s.reset,p=o?[]:e?.entries??[],m=new Set(p.map(n=>n.seq)),x=[...p,...s.entries.filter(n=>!m.has(n.seq))].sort((n,a)=>n.seq-a.seq),i=yp(x);return{...s,entries:i.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||i.trimmed}}function so(e,s=!0){return jt({queryKey:ce.workspaceServices.list(e),queryFn:async()=>(await ye.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:s&&!!e,refetchInterval:s&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function wp(e,s,r,o=!0){const p=vt(),m=ce.workspaceServices.logs(e,s);return jt({queryKey:m,queryFn:async()=>{const x=p.getQueryData(m),i=x?Math.max(0,x.nextSeq-1):0,n=x===void 0?r:x.runtimeInstanceId,a=new URLSearchParams({limit:String(xp)});n!==null&&a.set("runtimeInstanceId",n),a.set("afterSeq",String(i));const h=await ye.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${a}`);return Sp(x,h)},enabled:o&&!!e&&!!s,refetchInterval:x=>x.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const Cp=[];function $i(e){return JSON.stringify([e.command,...e.args])}function Zo(e,s,r){if(!e)return r;const o=new Date(e);return Number.isNaN(o.getTime())?r:new Intl.DateTimeFormat(s,{dateStyle:"medium",timeStyle:"medium"}).format(o)}function kp(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-emerald-400"};case"STARTING":return{label:"Starting",dotClassName:"bg-amber-400"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-amber-400"};case"FAILED":return{label:"Failed",dotClassName:"bg-red-400"};case"EXITED":return{label:"Exited",dotClassName:"bg-neutral-400"};default:return{label:"Stopped",dotClassName:"bg-neutral-500"}}}function Jo({state:e}){const{t:s}=de(),r=kp(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] text-neutral-300",children:[t.jsx("span",{className:se("h-1.5 w-1.5 rounded-full",r.dotClassName),"aria-hidden":"true"}),s(r.label)]})}function Ep({message:e,onRetry:s}){const{t:r}=de();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-red-300",role:"alert",children:[t.jsx(As,{size:14,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-[#333] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",title:r("Retry"),"aria-label":r("Retry"),children:t.jsx(Ts,{size:13})})]})}function jp({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=de(),p=so(e,s),m=p.data??Cp,[x,i]=b.useState(null),n=m.find(v=>v.name===x)??m[0]??null,a=wp(e,n?.name??"",n?.runtimeInstanceId??null,s&&!!n),h=b.useMemo(()=>vp(a.data?.entries.map(v=>v.data).join("")??""),[a.data?.entries]),c=b.useRef(null),g=b.useRef(!0);return b.useEffect(()=>{g.current=!0},[n?.id,n?.runtimeInstanceId]),b.useEffect(()=>{const v=c.current;v&&g.current&&(v.scrollTop=v.scrollHeight)},[h]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-[#1e1e1e] text-neutral-200 md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-[#343434] bg-[#252526] md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-[#343434] px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(an,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:o("Background services")})]}),!p.isLoading&&!p.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-neutral-500",children:m.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:p.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(Ep,{message:o("Failed to load background services."),onRetry:()=>{p.refetch()}}):m.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-neutral-500",children:[t.jsx(an,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:o("No background services")})]}):m.map(v=>{const _=v.name===n?.name;return t.jsxs("button",{type:"button",onClick:()=>i(v.name),"aria-pressed":_,className:se("block w-full border-b border-[#343434] px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",_?"bg-[#1e1e1e]":"hover:bg-[#2d2d2d]"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-100",children:v.name}),t.jsx(Jo,{state:v.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:$i(v),children:$i(v)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(Bn,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:v.relativeCwd||"."})]}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(hs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:Zo(v.startedAt,r,o("Not started"))})]})]},v.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-[#1e1e1e]","aria-label":o("Background service logs"),children:n?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-[#343434] bg-[#252526]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-neutral-100",children:n.name}),t.jsx(Jo,{state:n.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",tabIndex:0,"aria-label":`${n.name} ${o("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-[10px] text-neutral-500 sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:$i(n)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:n.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(hs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[o("Started"),":"]}),t.jsx("dd",{className:"truncate text-neutral-400",children:Zo(n.startedAt,r,o("Not started"))})]})]}),n.lastError&&t.jsx("p",{className:"mt-1.5 break-words text-[10px] text-red-300",role:"alert",children:n.lastError})]})]}),(a.data?.truncated||a.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-amber-400/20 bg-amber-400/10 px-3 py-1.5 text-[10px] text-amber-200",children:o("Earlier log output is unavailable.")}),a.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-400/20 bg-red-400/10 px-3 py-1.5 text-[10px] text-red-200",role:"alert",children:[t.jsx("span",{children:o("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{a.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-red-100 transition-colors hover:bg-red-300/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-200",title:o("Retry"),"aria-label":o("Retry"),children:t.jsx(Ts,{size:11})})]}),t.jsx("div",{ref:c,onScroll:v=>{const _=v.currentTarget;g.current=_.scrollHeight-_.scrollTop-_.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:a.isLoading&&!a.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading service logs...")]}):h?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:h}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-500",children:o("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-neutral-500",children:p.isLoading?o("Loading background services..."):o("Select a background service")})})]})}let Ui=0;function ea(){return Ui+=1,{id:`shell-${Ui}`,order:Ui}}const Np=ue.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=de(),[x,i]=b.useState(()=>[ea()]),[n,a]=b.useState(()=>x[0].id),[h,c]=b.useState(()=>new Set),[g,v]=b.useState(!1),[_,w]=b.useState(!1),[l,u]=b.useState(""),[d,f]=b.useState(null),[S,C]=b.useState("terminals"),k=b.useRef(new Map),E=o?S:"terminals",y=b.useCallback(D=>{k.current.delete(D),c(L=>{if(!L.has(D))return L;const K=new Set(L);return K.delete(D),K})},[]),j=b.useCallback(()=>{const D=ea();i(L=>[...L,D]),a(D.id)},[]),R=b.useCallback((D,L)=>{L.stopPropagation(),y(D),i(K=>{const U=K.filter(z=>z.id!==D);return D===n&&U.length>0&&a(U[U.length-1].id),U})},[n,y]),P=b.useCallback(D=>{y(D),i(L=>{const K=L.filter(U=>U.id!==D);return D===n&&K.length>0&&a(K[K.length-1].id),K})},[n,y]),M=b.useCallback((D,L)=>{k.current.set(D,L),c(K=>{if(K.has(D))return K;const U=new Set(K);return U.add(D),U})},[]),T=b.useCallback(D=>{const L=k.current.get(n);L&&L.sendInput(D+"\r")},[n]),B=b.useCallback((D,L="")=>{f(D),u(L),w(!0)},[]),I=b.useCallback((D,L)=>{const K=k.current.get(D);return K?(K.paste(L),ot.success(m("Pasted into terminal")),!0):(ot.error(m("Terminal is not ready")),!1)},[m]),H=b.useCallback(async()=>{if(!k.current.has(n)){ot.error(m("Terminal is not ready"));return}const D=navigator.clipboard;if(!D?.readText){B(n);return}v(!0);try{const L=await D.readText();if(!L||L.includes(`
|
|
30
|
-
`)||L.includes("\r")){B(n,L);return}I(n,L)}catch{B(n)}finally{v(!1)}},[n,B,I,m]),q=b.useCallback(()=>{!l||!d||!I(d,l)||(w(!1),u(""),f(null))},[l,I,d]),A=b.useCallback(()=>{w(!1),u(""),f(null)},[]),O=h.has(n);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[o&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-[#343434] bg-[#202020] px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>C("terminals"),"aria-pressed":E==="terminals",className:se("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(ur,{size:12,"aria-hidden":"true"}),m("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>C("services"),"aria-pressed":E==="services",className:se("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",E==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(an,{size:12,"aria-hidden":"true"}),m("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:se("min-h-0 flex-1 flex-col",E==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:x.map(D=>t.jsxs("button",{onClick:()=>a(D.id),className:se("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",D.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(ur,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:D.order})}),x.length>1&&t.jsx("span",{onClick:L=>R(D.id,L),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Yt,{size:10})})]},D.id))}),x.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:H,disabled:!O||g,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:m("Paste into terminal"),"aria-label":m("Paste into terminal"),children:g?t.jsx(Be,{size:18,className:"animate-spin"}):t.jsx(xu,{size:18})})]}),t.jsx("button",{type:"button",onClick:j,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:m("New Terminal"),"aria-label":m("New Terminal"),children:t.jsx(us,{size:14})}),p.length>0&&t.jsx(fp,{commands:p,onSelect:T})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:x.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(ur,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:j,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:m("New Terminal")})]})}):x.map(D=>t.jsx("div",{"aria-hidden":D.id!==n,className:se("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",D.id===n?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(hp,{cwd:s,isVisible:r&&E==="terminals"&&D.id===n,onExit:()=>P(D.id),onReady:L=>M(D.id,L)})},D.id))})]}),o&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(jp,{workspaceId:o,enabled:r})}),t.jsx(gs,{isOpen:_,onClose:A,title:m("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:A,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:m("Cancel")}),t.jsx("button",{type:"button",onClick:q,disabled:!l,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:m("Paste")})]}),children:t.jsx(ou,{autoFocus:!0,value:l,onChange:D=>u(D.target.value),placeholder:m("Paste terminal input here"),"aria-label":m("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function ta(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function Rp(e){if(Array.isArray(e))return e}function Ap(e,s,r){return(s=Op(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Tp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,x,i=[],n=!0,a=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(n=(o=m.call(r)).done)&&(i.push(o.value),i.length!==s);n=!0);}catch(h){a=!0,p=h}finally{try{if(!n&&r.return!=null&&(x=r.return(),Object(x)!==x))return}finally{if(a)throw p}}return i}}function Mp(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
31
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sa(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function ra(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?sa(Object(r),!0).forEach(function(o){Ap(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sa(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Dp(e,s){if(e==null)return{};var r,o,p=Pp(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(o=0;o<m.length;o++)r=m[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function Pp(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function Lp(e,s){return Rp(e)||Tp(e,s)||Bp(e,s)||Mp()}function Ip(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Op(e){var s=Ip(e,"string");return typeof s=="symbol"?s:s+""}function Bp(e,s){if(e){if(typeof e=="string")return ta(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ta(e,s):void 0}}function Fp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function ia(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function na(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?ia(Object(r),!0).forEach(function(o){Fp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ia(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function zp(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(p,m){return m(p)},o)}}function dr(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function ai(e){return{}.toString.call(e).includes("Object")}function Wp(e){return!Object.keys(e).length}function yr(e){return typeof e=="function"}function Hp(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function $p(e,s){return ai(s)||ms("changeType"),Object.keys(s).some(function(r){return!Hp(e,r)})&&ms("changeField"),s}function Up(e){yr(e)||ms("selectorType")}function qp(e){yr(e)||ai(e)||ms("handlerType"),ai(e)&&Object.values(e).some(function(s){return!yr(s)})&&ms("handlersType")}function Kp(e){e||ms("initialIsRequired"),ai(e)||ms("initialType"),Wp(e)&&ms("initialContent")}function Vp(e,s){throw new Error(e[s]||e.default)}var Xp={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},ms=dr(Vp)(Xp),$r={changes:$p,selector:Up,handler:qp,initial:Kp};function Yp(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};$r.initial(e),$r.handler(s);var r={current:e},o=dr(Zp)(r,s),p=dr(Qp)(r),m=dr($r.changes)(e),x=dr(Gp)(r);function i(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(h){return h};return $r.selector(a),a(r.current)}function n(a){zp(o,p,m,x)(a)}return[i,n]}function Gp(e,s){return yr(s)?s(e.current):s}function Qp(e,s){return e.current=na(na({},e.current),s),s}function Zp(e,s,r){return yr(s)?s(e.current):Object.keys(r).forEach(function(o){var p;return(p=s[o])===null||p===void 0?void 0:p.call(s,e.current[o])}),r}var Jp={create:Yp},eg={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function tg(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function sg(e){return{}.toString.call(e).includes("Object")}function rg(e){return e||oa("configIsRequired"),sg(e)||oa("configType"),e.urls?(ig(),{paths:{vs:e.urls.monacoBase}}):e}function ig(){console.warn(tc.deprecation)}function ng(e,s){throw new Error(e[s]||e.default)}var tc={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
32
|
-
You are using deprecated way of configuration.
|
|
33
|
-
|
|
34
|
-
Instead of using
|
|
35
|
-
monaco.config({ urls: { monacoBase: '...' } })
|
|
36
|
-
use
|
|
37
|
-
monaco.config({ paths: { vs: '...' } })
|
|
38
|
-
|
|
39
|
-
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
40
|
-
`},oa=tg(ng)(tc),og={config:rg},ag=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(p){return r.reduceRight(function(m,x){return x(m)},p)}};function sc(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],sc(e[r],s[r]))}),ra(ra({},e),s)}var lg={type:"cancelation",msg:"operation is manually canceled"};function qi(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(lg):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var cg=["monaco"],dg=Jp.create({config:eg,isInitialized:!1,resolve:null,reject:null,monaco:null}),rc=Lp(dg,2),jr=rc[0],Si=rc[1];function ug(e){var s=og.config(e),r=s.monaco,o=Dp(s,cg);Si(function(p){return{config:sc(p.config,o),monaco:r}})}function hg(){var e=jr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(Si({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),qi(Ki);if(window.monaco&&window.monaco.editor)return ic(window.monaco),e.resolve(window.monaco),qi(Ki);ag(fg,pg)(gg)}return qi(Ki)}function fg(e){return document.body.appendChild(e)}function mg(e){var s=document.createElement("script");return e&&(s.src=e),s}function pg(e){var s=jr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=mg("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function gg(){var e=jr(function(r){var o=r.config,p=r.resolve,m=r.reject;return{config:o,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;ic(o),e.resolve(o)},function(r){e.reject(r)})}function ic(e){jr().monaco||Si({monaco:e})}function vg(){return jr(function(e){var s=e.monaco;return s})}var Ki=new Promise(function(e,s){return Si({resolve:e,reject:s})}),nc={config:ug,init:hg,__getMonacoInstance:vg},xg={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Vi=xg,bg={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},_g=bg;function yg({children:e}){return ue.createElement("div",{style:_g.container},e)}var Sg=yg,wg=Sg;function Cg({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:x}){return ue.createElement("section",{style:{...Vi.wrapper,width:e,height:s},...x},!r&&ue.createElement(wg,null,o),ue.createElement("div",{ref:p,style:{...Vi.fullWidth,...!r&&Vi.hide},className:m}))}var kg=Cg,oc=b.memo(kg);function Eg(e){b.useEffect(e,[])}var ac=Eg;function jg(e,s,r=!0){let o=b.useRef(!0);b.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var At=jg;function pr(){}function Hs(e,s,r,o){return Ng(e,o)||Rg(e,s,r,o)}function Ng(e,s){return e.editor.getModel(lc(e,s))}function Rg(e,s,r,o){return e.editor.createModel(s,r,o?lc(e,o):void 0)}function lc(e,s){return e.Uri.parse(s)}function Ag({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:x,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:a="light",loading:h="Loading...",options:c={},height:g="100%",width:v="100%",className:_,wrapperProps:w={},beforeMount:l=pr,onMount:u=pr}){let[d,f]=b.useState(!1),[S,C]=b.useState(!0),k=b.useRef(null),E=b.useRef(null),y=b.useRef(null),j=b.useRef(u),R=b.useRef(l),P=b.useRef(!1);ac(()=>{let I=nc.init();return I.then(H=>(E.current=H)&&C(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>k.current?B():I.cancel()}),At(()=>{if(k.current&&E.current){let I=k.current.getOriginalEditor(),H=Hs(E.current,e||"",o||r||"text",m||"");H!==I.getModel()&&I.setModel(H)}},[m],d),At(()=>{if(k.current&&E.current){let I=k.current.getModifiedEditor(),H=Hs(E.current,s||"",p||r||"text",x||"");H!==I.getModel()&&I.setModel(H)}},[x],d),At(()=>{let I=k.current.getModifiedEditor();I.getOption(E.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],d),At(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),At(()=>{let{original:I,modified:H}=k.current.getModel();E.current.editor.setModelLanguage(I,o||r||"text"),E.current.editor.setModelLanguage(H,p||r||"text")},[r,o,p],d),At(()=>{E.current?.editor.setTheme(a)},[a],d),At(()=>{k.current?.updateOptions(c)},[c],d);let M=b.useCallback(()=>{if(!E.current)return;R.current(E.current);let I=Hs(E.current,e||"",o||r||"text",m||""),H=Hs(E.current,s||"",p||r||"text",x||"");k.current?.setModel({original:I,modified:H})},[r,s,p,e,o,m,x]),T=b.useCallback(()=>{!P.current&&y.current&&(k.current=E.current.editor.createDiffEditor(y.current,{automaticLayout:!0,...c}),M(),E.current?.editor.setTheme(a),f(!0),P.current=!0)},[c,a,M]);b.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),b.useEffect(()=>{!S&&!d&&T()},[S,d,T]);function B(){let I=k.current?.getModel();i||I?.original?.dispose(),n||I?.modified?.dispose(),k.current?.dispose()}return ue.createElement(oc,{width:v,height:g,isEditorReady:d,loading:h,_ref:y,className:_,wrapperProps:w})}var Tg=Ag;b.memo(Tg);function Mg(e){let s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}var Dg=Mg,Ur=new Map;function Pg({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:x="light",line:i,loading:n="Loading...",options:a={},overrideServices:h={},saveViewState:c=!0,keepCurrentModel:g=!1,width:v="100%",height:_="100%",className:w,wrapperProps:l={},beforeMount:u=pr,onMount:d=pr,onChange:f,onValidate:S=pr}){let[C,k]=b.useState(!1),[E,y]=b.useState(!0),j=b.useRef(null),R=b.useRef(null),P=b.useRef(null),M=b.useRef(d),T=b.useRef(u),B=b.useRef(),I=b.useRef(o),H=Dg(m),q=b.useRef(!1),A=b.useRef(!1);ac(()=>{let L=nc.init();return L.then(K=>(j.current=K)&&y(!1)).catch(K=>K?.type!=="cancelation"&&console.error("Monaco initialization: error:",K)),()=>R.current?D():L.cancel()}),At(()=>{let L=Hs(j.current,e||o||"",s||p||"",m||r||"");L!==R.current?.getModel()&&(c&&Ur.set(H,R.current?.saveViewState()),R.current?.setModel(L),c&&R.current?.restoreViewState(Ur.get(m)))},[m],C),At(()=>{R.current?.updateOptions(a)},[a],C),At(()=>{!R.current||o===void 0||(R.current.getOption(j.current.editor.EditorOption.readOnly)?R.current.setValue(o):o!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[o],C),At(()=>{let L=R.current?.getModel();L&&p&&j.current?.editor.setModelLanguage(L,p)},[p],C),At(()=>{i!==void 0&&R.current?.revealLine(i)},[i],C),At(()=>{j.current?.editor.setTheme(x)},[x],C);let O=b.useCallback(()=>{if(!(!P.current||!j.current)&&!q.current){T.current(j.current);let L=m||r,K=Hs(j.current,o||e||"",s||p||"",L||"");R.current=j.current?.editor.create(P.current,{model:K,automaticLayout:!0,...a},h),c&&R.current.restoreViewState(Ur.get(L)),j.current.editor.setTheme(x),i!==void 0&&R.current.revealLine(i),k(!0),q.current=!0}},[e,s,r,o,p,m,a,h,c,x,i]);b.useEffect(()=>{C&&M.current(R.current,j.current)},[C]),b.useEffect(()=>{!E&&!C&&O()},[E,C,O]),I.current=o,b.useEffect(()=>{C&&f&&(B.current?.dispose(),B.current=R.current?.onDidChangeModelContent(L=>{A.current||f(R.current.getValue(),L)}))},[C,f]),b.useEffect(()=>{if(C){let L=j.current.editor.onDidChangeMarkers(K=>{let U=R.current.getModel()?.uri;if(U&&K.find(z=>z.path===U.path)){let z=j.current.editor.getModelMarkers({resource:U});S?.(z)}});return()=>{L?.dispose()}}return()=>{}},[C,S]);function D(){B.current?.dispose(),g?c&&Ur.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return ue.createElement(oc,{width:v,height:_,isEditorReady:C,loading:n,_ref:P,className:w,wrapperProps:l})}var Lg=Pg,Ig=b.memo(Lg),Og=Ig,Lt=function(e,s){return Number(e.toFixed(s))},Bg=function(e,s){return typeof e=="number"?e:s},Ze=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Fg=function(e){return-Math.cos(e*Math.PI)/2+.5},zg=function(e){return e},Wg=function(e){return e*e},Hg=function(e){return e*(2-e)},$g=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Ug=function(e){return e*e*e},qg=function(e){return--e*e*e+1},Kg=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Vg=function(e){return e*e*e*e},Xg=function(e){return 1- --e*e*e*e},Yg=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Gg=function(e){return e*e*e*e*e},Qg=function(e){return 1+--e*e*e*e*e},Zg=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},cc={easeOut:Fg,linear:zg,easeInQuad:Wg,easeOutQuad:Hg,easeInOutQuad:$g,easeInCubic:Ug,easeOutCubic:qg,easeInOutCubic:Kg,easeInQuart:Vg,easeOutQuart:Xg,easeInOutQuart:Yg,easeInQuint:Gg,easeOutQuint:Qg,easeInOutQuint:Zg},dc=function(e){typeof e=="number"&&cancelAnimationFrame(e)},zt=function(e){e.mounted&&(dc(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function uc(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;zt(e),e.animation=function(){if(!e.mounted)return dc(e.animation);var x=new Date().getTime()-p,i=x/r,n=cc[s],a=n(i);x>=r?(o(m),e.animation=null):e.animation&&(o(a),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Jg(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function xs(e,s,r,o){var p=Jg(s);if(!(!e.mounted||!p)){var m=e.setTransformState,x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY,h=s.scale-i,c=s.positionX-n,g=s.positionY-a;r===0?m(s.scale,s.positionX,s.positionY):uc(e,o,r,function(v){var _=i+h*v,w=n+c*v,l=a+g*v;m(_,w,l)})}}function ev(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,x=s.offsetHeight,i=m*r,n=x*r,a=o-i,h=p-n;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:i,newDiffWidth:a,newContentHeight:n,newDiffHeight:h}}var tv=function(e,s,r,o,p,m,x){var i=e>s?r*(x?1:.5):0,n=o>p?m*(x?1:.5):0,a=e-s-i,h=i,c=o-p-n,g=n;return{minPositionX:a,maxPositionX:h,minPositionY:c,maxPositionY:g}},ro=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var m=ev(r,o,s),x=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,a=m.newDiffWidth,h=m.newContentHeight,c=m.newDiffHeight,g=tv(x,n,a,i,h,c,!!p);return g},vn=function(e,s,r,o){return o?e<s?Lt(s,2):e>r?Lt(r,2):Lt(e,2):Lt(e,2)},Es=function(e,s){var r=ro(e,s);return e.bounds=r,r};function Nr(e,s,r,o,p,m,x){var i=r.minPositionX,n=r.minPositionY,a=r.maxPositionX,h=r.maxPositionY,c=0,g=0;x&&(c=p,g=m);var v=vn(e,i-c,a+c,o),_=vn(s,n-g,h+g,o);return{x:v,y:_}}function wi(e,s,r,o,p,m){var x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY,h=o-i;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:a};var c=n-s*h,g=a-r*h,v=Nr(c,g,p,m,0,0,null);return v}function Rr(e,s,r,o,p){var m=p?o:0,x=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=x?x:e}var aa=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,p=e.wrapperComponent,m=s.target,x="shadowRoot"in m&&"composedPath"in s,i=x?s.composedPath().some(function(h){return h instanceof Element?p?.contains(h):!1}):p?.contains(m),n=o&&m&&i;if(!n)return!1;var a=Ci(m,r);return!a},la=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},sv=function(e,s){var r=e.transformState,o=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,x=s.clientY;e.startCoords={x:m-o,y:x-p}},rv=function(e,s){var r=s.touches,o=e.transformState,p=o.positionX,m=o.positionY;e.isPanning=!0;var x=r.length===1;if(x){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-p,y:n-m}}};function iv(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,x=m.disabled,i=m.limitToBounds,n=m.centerZoomedOut,a=e.wrapperComponent;if(!(x||!a||!e.bounds)){var h=e.bounds,c=h.maxPositionX,g=h.minPositionX,v=h.maxPositionY,_=h.minPositionY,w=r>c||r<g,l=o>v||o<_,u=r>c?a.offsetWidth:e.setup.minPositionX||0,d=o>v?a.offsetHeight:e.setup.minPositionY||0,f=wi(e,u,d,p,e.bounds,i||n),S=f.x,C=f.y;return{scale:p,positionX:w?S:r,positionY:l?C:o}}}function hc(e,s,r,o,p){var m=e.setup.limitToBounds,x=e.wrapperComponent,i=e.bounds,n=e.transformState,a=n.scale,h=n.positionX,c=n.positionY;if(!(x===null||i===null||s===h&&r===c)){var g=Nr(s,r,i,m,o,p,x),v=g.x,_=g.y;e.setTransformState(a,v,_)}}var nv=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,x=m.lockAxisX,i=m.lockAxisY,n=p.positionX,a=p.positionY;if(!o)return{x:n,y:a};var h=s-o.x,c=r-o.y,g=x?n:h,v=i?a:c;return{x:g,y:v}},vs=function(e,s){var r=e.setup,o=e.transformState,p=o.scale,m=r.minScale,x=r.disablePadding;return s>0&&p>=m&&!x?s:0},ov=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,x=p.disabled,i=!x||m>1||!o||s;return!!i},av=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,x=p.velocityAnimation,i=e.transformState.scale,n=x.disabled,a=!n||i>1||!m||s;return!(!a||!r||!o)};function lv(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function ca(e,s,r,o,p,m,x,i,n,a){if(p){if(s>x&&r>x){var h=x+(e-x)*a;return h>n?n:h<x?x:h}if(s<m&&r<m){var h=m+(e-m)*a;return h<i?i:h>m?m:h}}return o?s:vn(e,m,x,p)}function cv(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function dv(e,s){var r=ov(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,x=e.wrapperComponent,i=m.velocityAnimation.equalToMove,n=Date.now();if(o&&p&&x){var a=cv(x,i),h=s.x-o.x,c=s.y-o.y,g=h/a,v=c/a,_=n-p,w=h*h+c*c,l=Math.sqrt(w)/_;e.velocity={velocityX:g,velocityY:v,total:l}}e.lastMousePosition=s,e.velocityTime=n}}function uv(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=av(e);if(!(!m||!s||!r||!p)){var x=s.velocityX,i=s.velocityY,n=s.total,a=r.maxPositionX,h=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,v=o.limitToBounds,_=o.alignmentAnimation,w=o.zoomAnimation,l=o.panning,u=l.lockAxisY,d=l.lockAxisX,f=w.animationType,S=_.sizeX,C=_.sizeY,k=_.velocityAlignmentTime,E=k,y=lv(e,n),j=Math.max(y,E),R=vs(e,S),P=vs(e,C),M=R*p.offsetWidth/100,T=P*p.offsetHeight/100,B=a+M,I=h-M,H=c+T,q=g-T,A=e.transformState,O=new Date().getTime();uc(e,f,j,function(D){var L=e.transformState,K=L.scale,U=L.positionX,z=L.positionY,W=new Date().getTime()-O,$=W/E,N=cc[_.animationType],F=1-N(Math.min(1,$)),V=1-D,X=U+x*V,te=z+i*V,G=ca(X,A.positionX,U,d,v,h,a,I,B,F),pe=ca(te,A.positionY,z,u,v,g,c,q,H,F);(U!==X||z!==te)&&e.setTransformState(K,G,pe)})}}function da(e,s){var r=e.transformState.scale;zt(e),Es(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?rv(e,s):sv(e,s)}function io(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,x=m.disabled,i=m.sizeX,n=m.sizeY,a=m.animationTime,h=m.animationType,c=x||r<p||!i&&!n;if(!c){var g=iv(e);g&&xs(e,g,s??a,h)}}function ua(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,x=m.sizeX,i=m.sizeY;if(o){var n=nv(e,s,r),a=n.x,h=n.y,c=vs(e,x),g=vs(e,i);dv(e,{x:a,y:h}),hc(e,a,h,c,g)}}function hv(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=o?.getBoundingClientRect(),x=p?.getBoundingClientRect(),i=m?.width||0,n=m?.height||0,a=x?.width||0,h=x?.height||0,c=i<a||n<h,g=!s&&r&&r?.total>.1&&c;g?uv(e):io(e)}}function no(e,s,r,o){var p=e.setup,m=p.minScale,x=p.maxScale,i=p.limitToBounds,n=Rr(Lt(s,2),m,x,0,!1),a=Es(e,n),h=wi(e,r,o,n,a,i),c=h.x,g=h.y;return{scale:n,positionX:c,positionY:g}}function fc(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,x=m.minScale,i=m.limitToBounds,n=m.zoomAnimation,a=n.disabled,h=n.animationTime,c=n.animationType,g=a||o>=x;if((o>=1||i)&&io(e),!(g||!p||!e.mounted)){var v=s||p.offsetWidth/2,_=r||p.offsetHeight/2,w=no(e,x,v,_);w&&xs(e,w,h,c)}}var ps=function(){return ps=Object.assign||function(s){for(var r,o=1,p=arguments.length;o<p;o++){r=arguments[o];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},ps.apply(this,arguments)};function ha(e,s,r){for(var o=0,p=s.length,m;o<p;o++)(m||!(o in s))&&(m||(m=Array.prototype.slice.call(s,0,o)),m[o]=s[o]);return e.concat(m||Array.prototype.slice.call(s))}var qr={scale:1,positionX:0,positionY:0},lr={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},xn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},mc=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:qr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:qr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:qr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:qr.positionY}},fa=function(e){var s=ps({},lr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof lr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(lr[r]),x=m==="[object Object]",i=m==="[object Array]";x?s[r]=ps(ps({},lr[r]),e[r]):i?s[r]=ha(ha([],lr[r],!0),e[r]):s[r]=e[r]}}),s},pc=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,x=m.maxScale,i=m.minScale,n=m.zoomAnimation,a=m.smooth,h=n.size;if(!p)throw new Error("Wrapper is not mounted");var c=a?o*Math.exp(s*r):o+s*r,g=Rr(Lt(c,3),i,x,h,!1);return g};function gc(e,s,r,o,p){var m=e.wrapperComponent,x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY;if(!m)return console.error("No WrapperComponent found");var h=m.offsetWidth,c=m.offsetHeight,g=(h/2-n)/i,v=(c/2-a)/i,_=pc(e,s,r),w=no(e,_,g,v);if(!w)return console.error("Error during zoom event. New transformation state was not calculated.");xs(e,w,o,p)}function vc(e,s,r,o){var p=e.setup,m=e.wrapperComponent,x=p.limitToBounds,i=mc(e.props),n=e.transformState,a=n.scale,h=n.positionX,c=n.positionY;if(m){var g=ro(e,i.scale),v=Nr(i.positionX,i.positionY,g,x,0,0,m),_={scale:i.scale,positionX:v.x,positionY:v.y};a===i.scale&&h===i.positionX&&c===i.positionY||(o?.(),xs(e,_,s,r))}}function fv(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),x=r.getBoundingClientRect(),i=m.x*o.scale,n=m.y*o.scale;return{x:(p.x-x.x+i)/o.scale,y:(p.y-x.y+n)/o.scale}}function mv(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,x=e.setup,i=x.limitToBounds,n=x.minScale,a=x.maxScale;if(!o||!p)return m;var h=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=fv(s,o,p,m),v=g.x,_=g.y,w=c.width/m.scale,l=c.height/m.scale,u=o.offsetWidth/w,d=o.offsetHeight/l,f=Rr(r||Math.min(u,d),n,a,0,!1),S=(h.width-w*f)/2,C=(h.height-l*f)/2,k=(h.left-v)*f+S,E=(h.top-_)*f+C,y=ro(e,f),j=Nr(k,E,y,i,0,0,o),R=j.x,P=j.y;return{positionX:R,positionY:P,scale:f}}var pv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),gc(e,1,s,r,o)}},gv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),gc(e,-1,s,r,o)}},vv=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var x=e.transformState,i=x.positionX,n=x.positionY,a=x.scale,h=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!h||!c)){var v={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?a:o};xs(e,v,p,m)}}},xv=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),vc(e,s,r)}},bv=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var p=e.transformState,m=e.wrapperComponent,x=e.contentComponent;if(m&&x){var i=xc(s||p.scale,m,x);xs(e,i,r,o)}}},_v=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),zt(e);var m=e.wrapperComponent,x=typeof s=="string"?document.getElementById(s):s;if(m&&x&&m.contains(x)){var i=mv(e,x,r);xs(e,i,o,p)}}},li=function(e){return{instance:e,zoomIn:pv(e),zoomOut:gv(e),setTransform:vv(e),resetTransform:xv(e),centerView:bv(e),zoomToElement:_v(e)}},bn=function(e){return{instance:e,state:e.transformState}},Xe=function(e){var s={};return Object.assign(s,bn(e)),Object.assign(s,li(e)),s},Xi=!1;function Yi(){try{var e={get passive(){return Xi=!0,!1}};return e}catch{return Xi=!1,Xi}}var Kr=".".concat(xn.wrapperClass),Ci=function(e,s){return s.some(function(r){return e.matches("".concat(Kr," ").concat(r,", ").concat(Kr," .").concat(r,", ").concat(Kr," ").concat(r," *, ").concat(Kr," .").concat(r," *"))})},_n=function(e){e&&clearTimeout(e)},yv=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},xc=function(e,s,r){var o=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-o)/2,x=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:x}};function Sv(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var wv=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,x=r.excluded,i=e.isInitialized,n=e.isPanning,a=s.target,h=i&&!n&&!o&&a;if(!h||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=Ci(a,x);return!c},Cv=function(e){return e?e.deltaY<0?1:-1:0};function kv(e,s){var r=Cv(e),o=Bg(s,r);return o}function bc(e,s,r){var o=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-o.left)/r,m=(e.clientY-o.top)/r;else{var x=e.touches[0];p=(x.clientX-o.left)/r,m=(x.clientY-o.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var Ev=function(e,s,r,o,p){var m=e.transformState.scale,x=e.wrapperComponent,i=e.setup,n=i.maxScale,a=i.minScale,h=i.zoomAnimation,c=i.disablePadding,g=h.size,v=h.disabled;if(!x)throw new Error("Wrapper is not mounted");var _=m+s*r,w=o?!1:!v,l=Rr(Lt(_,3),a,n,g,w&&!c);return l},jv=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,p=e.setup,m=p.maxScale,x=p.minScale;return r?o<m||o>x||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Nv=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,x=s.target,i=m&&!o&&x;if(!i)return!1;var n=Ci(x,p);return!n},Rv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},Av=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Lt(p[0].clientX-o.left,5),x=Lt(p[0].clientY-o.top,5),i=Lt(p[1].clientX-o.left,5),n=Lt(p[1].clientY-o.top,5);return{x:(m+i)/2/s,y:(x+n)/2/s}},_c=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},Tv=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,x=p.minScale,i=p.zoomAnimation,n=p.disablePadding,a=i.size,h=i.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,g=c*r;return Rr(Lt(g,2),x,m,a,!h&&!n)},Mv=160,Dv=100,Pv=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(zt(e),Ze(Xe(e),s,o),Ze(Xe(e),s,p))},Lv=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,x=e.setup,i=e.transformState,n=i.scale,a=x.limitToBounds,h=x.centerZoomedOut,c=x.zoomAnimation,g=x.wheel,v=x.disablePadding,_=x.smooth,w=c.size,l=c.disabled,u=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=kv(s,null),S=_?d*Math.abs(s.deltaY):u,C=Ev(e,f,S,!s.ctrlKey);if(n!==C){var k=Es(e,C),E=bc(s,m,n),y=l||w===0||h||v,j=a&&y,R=wi(e,E.x,E.y,C,k,j),P=R.x,M=R.y;e.previousWheelEvent=s,e.setTransformState(C,P,M),Ze(Xe(e),s,o),Ze(Xe(e),s,p)}},Iv=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;_n(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(fc(e,s.x,s.y),e.wheelAnimationTimer=null)},Dv);var m=jv(e,s);m&&(_n(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ze(Xe(e),s,o),Ze(Xe(e),s,p))},Mv))},yc=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var p=s/2,m=r/2;return{x:p,y:m}},Ov=function(e,s){var r=_c(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=yc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,zt(e)},Bv=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,x=e.setup,i=x.limitToBounds,n=x.centerZoomedOut,a=x.zoomAnimation,h=x.alignmentAnimation,c=a.disabled,g=a.size;if(!(o===null||!r)){var v=Av(s,m,r);if(!(!Number.isFinite(v.x)||!Number.isFinite(v.y))){var _=_c(s),w=Tv(e,_),l=yc(s),u=l.x-(e.pinchLastCenterX||0),d=l.y-(e.pinchLastCenterY||0);if(!(w===m&&u===0&&d===0)){e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y;var f=Es(e,w),S=c||g===0||n,C=i&&S,k=wi(e,v.x,v.y,w,f,C),E=k.x,y=k.y;e.pinchMidpoint=v,e.lastDistance=_;var j=h.sizeX,R=h.sizeY,P=vs(e,j),M=vs(e,R),T=E+u,B=y+d,I=Nr(T,B,f,i,P,M,p),H=I.x,q=I.y;e.setTransformState(w,H,q)}}}},Fv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,fc(e,s?.x,s?.y)},Sc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;_n(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ze(Xe(e),s,r)},o)},zv=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,x=m.animationTime,i=m.animationType;Ze(Xe(e),s,o),vc(e,x,i,function(){return Ze(Xe(e),s,p)}),Sc(e,s)};function Wv(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Hv(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,x=p.scale,i=e.props,n=i.onZoomStart,a=i.onZoom,h=r.doubleClick,c=h.disabled,g=h.mode,v=h.step,_=h.animationTime,w=h.animationType;if(!c&&!o){if(g==="reset")return zv(e,s);if(!m)return console.error("No ContentComponent found");var l=Wv(g,e.transformState.scale),u=pc(e,l,v);if(x!==u){Ze(Xe(e),s,n);var d=bc(s,m,x),f=no(e,u,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ze(Xe(e),s,a),xs(e,f,_,w),Sc(e,s)}}}var $v=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,x=m.disabled,i=m.excluded,n=s.target,a=p?.contains(n),h=r&&n&&a&&!x;if(!h)return!1;var c=Ci(n,i);return!c},Uv=(function(){function e(s){var r=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,Es(r,r.transformState.scale),r.setup=fa(o)},this.initializeWindowEvents=function(){var o,p,m=Yi(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=x?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),i?.addEventListener("mousedown",r.onPanningStart,m),i?.addEventListener("mousemove",r.onPanning,m),i?.addEventListener("mouseup",r.onPanningStop,m),x?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=Yi(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=x?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),x?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),zt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=Yi();o.addEventListener("wheel",r.onWheelZoom,p),o.addEventListener("dblclick",r.onDoubleClick,p),o.addEventListener("touchstart",r.onTouchPanningStart,p),o.addEventListener("touchmove",r.onTouchPanning,p),o.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(o,p){var m=!1,x=r.setup.centerOnInit,i=function(n,a){for(var h=0,c=n;h<c.length;h++){var g=c[h];if(g.target===a)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(Xe(r))}),r.observer=new ResizeObserver(function(n){if(i(n,o)||i(n,p))if(x&&!m){var a=p.offsetWidth,h=p.offsetHeight;(a>0||h>0)&&(m=!0,r.setCenter())}else zt(r),Es(r,r.transformState.scale),io(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=wv(r,o);if(m){var x=r.isPressingKeys(r.setup.wheel.activationKeys);x&&(Pv(r,o),Lv(r,o),Iv(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,x=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!x.wheelDisabled||i.disabled||!i.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var n=r.transformState,a=n.positionX,h=n.positionY,c=a-o.deltaX,g=h-o.deltaY,v=i.lockAxisX?a:c,_=i.lockAxisY?h:g,w=r.setup.alignmentAnimation,l=w.sizeX,u=w.sizeY,d=vs(r,l),f=vs(r,u);v===a&&_===h||hc(r,v,_,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var x=aa(r,o);if(x){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),zt(r),da(r,o),Ze(Xe(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var x=la(r);if(x){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),ua(r,o.clientX,o.clientY),Ze(Xe(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(hv(r),Ze(Xe(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,x=m.onPinchingStart,i=m.onZoomStart;if(!p){var n=Nv(r,o);n&&(Ov(r,o),zt(r),Ze(Xe(r),o,x),Ze(Xe(r),o,i))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,x=m.onPinching,i=m.onZoom;if(!p){var n=Rv(r);n&&(o.preventDefault(),o.stopPropagation(),Bv(r,o),Ze(Xe(r),o,x),Ze(Xe(r),o,i))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,x=p.onZoomStop;r.pinchStartScale&&(Fv(r),Ze(Xe(r),o,m),Ze(Xe(r),o,x))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var x=aa(r,o);if(x){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,zt(r);var n=o.touches,a=n.length===1,h=n.length===2;a&&(zt(r),da(r,o),Ze(Xe(r),o,m)),h&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(p)return;var x=la(r);if(!x)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];ua(r,i.clientX,i.clientY),Ze(Xe(r),o,m)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var p=r.setup.disabled;if(!p){var m=$v(r,o);m&&Hv(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(o,p,m){var x=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(p)&&!Number.isNaN(m)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var i=Xe(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Ze(i,{scale:o,positionX:p,positionY:m},x)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=xc(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,p,m){return r.props.customTransform?r.props.customTransform(o,p,m):yv(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,x=o.positionY,i=r.handleTransformStyles(m,x,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Xe(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,p){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=p,Es(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Xe(r);Ze(m,void 0,r.props.onInit)},this.props=s,this.setup=fa(this.props),this.transformState=mc(this.props)}return e})(),ki=ue.createContext(null),qv=function(e,s){return typeof e=="function"?e(s):e},Kv=ue.forwardRef(function(e,s){var r=b.useRef(new Uv(e)).current,o=qv(e.children,li(r));return b.useImperativeHandle(s,function(){return li(r)},[r]),b.useEffect(function(){r.update(e)},[r,e]),ue.createElement(ki.Provider,{value:r},o)});ue.forwardRef(function(e,s){var r=b.useRef(null),o=b.useContext(ki);return b.useEffect(function(){return o.onChange(function(p){if(r.current){var m=0,x=0;r.current.style.transform=o.handleTransformStyles(m,x,1/p.instance.transformState.scale)}})},[o]),ue.createElement("div",ps({},e,{ref:Sv([r,s])}))});function Vv(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&o.firstChild?o.insertBefore(p,o.firstChild):o.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var Xv=`.transform-component-module_wrapper__SPB86 {
|
|
41
|
-
position: relative;
|
|
42
|
-
width: -moz-fit-content;
|
|
43
|
-
width: fit-content;
|
|
44
|
-
height: -moz-fit-content;
|
|
45
|
-
height: fit-content;
|
|
46
|
-
overflow: hidden;
|
|
47
|
-
-webkit-touch-callout: none; /* iOS Safari */
|
|
48
|
-
-webkit-user-select: none; /* Safari */
|
|
49
|
-
-khtml-user-select: none; /* Konqueror HTML */
|
|
50
|
-
-moz-user-select: none; /* Firefox */
|
|
51
|
-
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
52
|
-
user-select: none;
|
|
53
|
-
margin: 0;
|
|
54
|
-
padding: 0;
|
|
55
|
-
transform: translate3d(0, 0, 0);
|
|
56
|
-
}
|
|
57
|
-
.transform-component-module_content__FBWxo {
|
|
58
|
-
display: flex;
|
|
59
|
-
flex-wrap: wrap;
|
|
60
|
-
width: -moz-fit-content;
|
|
61
|
-
width: fit-content;
|
|
62
|
-
height: -moz-fit-content;
|
|
63
|
-
height: fit-content;
|
|
64
|
-
margin: 0;
|
|
65
|
-
padding: 0;
|
|
66
|
-
transform-origin: 0% 0%;
|
|
67
|
-
}
|
|
68
|
-
.transform-component-module_content__FBWxo img {
|
|
69
|
-
pointer-events: none;
|
|
70
|
-
}
|
|
71
|
-
`,ma={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Vv(Xv);var Yv=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,x=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,a=n===void 0?{}:n,h=e.contentProps,c=h===void 0?{}:h,g=b.useContext(ki),v=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),l=b.useRef(null);return b.useEffect(function(){var u=w.current,d=l.current;return u!==null&&d!==null&&v&&v?.(u,d),function(){_?.()}},[]),ue.createElement("div",ps({},a,{ref:w,className:"".concat(xn.wrapperClass," ").concat(ma.wrapper," ").concat(o),style:x}),ue.createElement("div",ps({},c,{ref:l,className:"".concat(xn.contentClass," ").concat(ma.content," ").concat(m),style:i}),s))},wc=function(){var e=b.useContext(ki);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Gv=function(){var e=wc();return li(e)};function Qv(e){var s=wc(),r=b.useState(e(bn(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,x=s.onChange(function(i){m&&p(e(bn(i.instance)))});return function(){x(),m=!1}},[e,s]),o}function Zv(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Jv(e,s){return jt({queryKey:ce.files.tree(e||"",s),queryFn:()=>ye.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function e0(e,s){return jt({queryKey:ce.files.content(e||"",s||""),queryFn:()=>ye.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function t0(e){const s=vt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function s0(){const e=vt();return Ht({mutationFn:s=>ye.post("/files/write",s),onSuccess:(s,r)=>{const o=ce.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||Zv(r.path)})}})}function r0(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function i0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const n0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function o0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&n0.has(s)?Va:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?ei:s==="json"?Eu:s==="md"||s==="mdx"||s==="txt"?Ka:su}const pa=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:se("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),Cc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})=>{const{t:i}=de(),{data:n,isLoading:a,isError:h}=Jv(e,s),c=b.useMemo(()=>n?.items??[],[n?.items]);return a?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):h?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const u=r0(s,g.name),d=o.has(u);return t.jsxs("div",{children:[t.jsx(pa,{depth:r,onClick:()=>p(u),rightIcon:d?t.jsx(wt,{size:14,className:"text-neutral-400"}):t.jsx(Tt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(pi,{size:14,className:"text-amber-500"}):t.jsx(Bn,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(Cc,{workingDir:e,path:u,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})]},u)}const v=i0(s,g.name),_=o0(g),w=x===v,l=_===Va;return t.jsx(pa,{depth:r,active:w,onClick:()=>m(v),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:l?"text-emerald-600":"text-sky-600"}):null,label:g.name},v)})})},a0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=de(),[x,i]=b.useState(()=>new Set),n=t0(e),a=b.useCallback(h=>{i(c=>{const g=new Set(c);return g.has(h)?g.delete(h):g.add(h),g})},[]);return t.jsxs("div",{className:se("h-full flex flex-col",s),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(Ts,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(Iu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Cc,{workingDir:e,path:"/",depth:0,expanded:x,toggleDir:a,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},l0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function c0(e){const s=e.split(".").pop()?.toLowerCase();return s?l0.has(s):!1}function d0(e,s){const r=Sr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const u0=({filePath:e})=>{const{t:s}=de(),{zoomIn:r,zoomOut:o,centerView:p}=Gv(),m=Qv(i=>i.state.scale),x=Math.round(m*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(Qu,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:s("Reset zoom"),children:[x,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(Yu,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Pu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},h0=({workingDir:e,filePath:s})=>{const{t:r}=de(),[o,p]=b.useState(!1),m=d0(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(Kv,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(u0,{filePath:s}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(Yv,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function f0(e){const s=e.split("/");return s[s.length-1]||e}function m0(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const p0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=de();return t.jsxs("button",{type:"button",onClick:o,className:se("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:se("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(Yt,{size:12})})]})},g0=ue.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=de(),[x,i]=b.useState([]),[n,a]=b.useState(null),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(0),[l,u]=b.useState(null),d=b.useRef(null),f=s0();b.useEffect(()=>{let z=!1;return Ad(async()=>{const{preloadMonaco:W}=await import("./monaco-C17UmdbS.js").then($=>$.m);return{preloadMonaco:W}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:W})=>W()).then(()=>{z||c(!0)}).catch(()=>{z||v(!0)}),()=>{z=!0}},[]);const[S,C]=b.useState(280),[k,E]=b.useState(!1),[y,j]=b.useState(!1),R=b.useRef(280),P=b.useCallback(()=>{E(z=>(z?C(R.current):R.current=S,!z))},[S]),M=b.useCallback(z=>{z.preventDefault(),j(!0);const W=z.clientX,$=S,N=V=>{const X=V.clientX-W,te=Math.min(480,Math.max(160,$+X));C(te)},F=()=>{j(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",F)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",F)},[S]);b.useEffect(()=>{i([]),a(null),u(null)},[s]);const T=b.useMemo(()=>x.find(z=>z.path===n)||null,[x,n]),{data:B,isFetching:I,isError:H,error:q}=e0(s,T?.isImage?null:n);b.useEffect(()=>{!n||!B||i(z=>z.map(W=>W.path!==n||W.isDirty||W.loaded?W:{...W,language:B.language||W.language,content:B.content,savedContent:B.content,isDirty:!1,loaded:!0}))},[n,B]);const A=b.useCallback((z,W,$)=>{i(N=>{if(N.find(X=>X.path===z))return N;const V=c0(z);return[...N,{path:z,name:f0(z),language:m0(z),content:"",savedContent:"",isDirty:!1,loaded:V,isImage:V}]}),a(z),u(W?{path:z,line:W,column:$}:null)},[]);ue.useImperativeHandle(p,()=>({openFile:A}),[A]);const O=b.useCallback(z=>{i(W=>{const $=W.filter(N=>N.path!==z);return a(N=>N!==z?N:$.length?$[$.length-1].path:null),$})},[]),D=b.useCallback(z=>{i(W=>W.map($=>{if($.path!==n)return $;const N=z!==$.savedContent;return{...$,content:z,isDirty:N}}))},[n]),L=b.useCallback(async()=>{o||!s||!T||(await f.mutateAsync({workingDir:s,path:T.path,content:T.content}),i(z=>z.map(W=>W.path===T.path?{...W,savedContent:W.content,isDirty:!1,loaded:!0}:W)))},[T,o,f,s]),K=b.useRef(()=>{});b.useEffect(()=>{K.current=()=>{L().catch(()=>{})}},[L]),b.useEffect(()=>{const z=W=>{o||(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="s"&&(W.preventDefault(),K.current())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[o]);const U=b.useCallback((z,W)=>{d.current=z,w($=>$+1),z.addCommand(W.KeyMod.CtrlCmd|W.KeyCode.KeyS,()=>{K.current()})},[]);return b.useEffect(()=>{if(!l||l.path!==n||!T?.loaded)return;const z=d.current,W=z?.getModel();if(!z||!W)return;const $=Math.min(l.line,W.getLineCount()),N=Math.min(l.column??1,W.getLineMaxColumn($)),F={lineNumber:$,column:N};z.setPosition(F),z.revealPositionInCenter(F),z.focus(),u(null)},[n,T?.loaded,_,l]),t.jsxs("div",{className:se("flex h-full overflow-hidden bg-white",r),style:y?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:k?36:S,transition:y?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:P,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx(Bu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(a0,{workingDir:s,onFileSelect:A,selectedFilePath:T?.path||null,onCollapse:P},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:M,className:se("w-1 shrink-0 cursor-col-resize transition-colors",y?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[x.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):x.map(z=>t.jsx(p0,{active:z.path===n,name:z.name,isDirty:z.isDirty,onClick:()=>a(z.path),onClose:W=>{W.stopPropagation(),O(z.path)}},z.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Saving")]}),T?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?T?T.isImage?t.jsx(h0,{workingDir:s,filePath:T.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):h?t.jsxs(t.Fragment,{children:[t.jsx(Og,{path:T.path,value:T.content,language:T.language,theme:"vs-light",height:"100%",onChange:o?void 0:z=>D(z??""),onMount:U,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!T.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Loading file...")]})}),H&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[m("Failed to load file"),q instanceof Error?`: ${q.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("No workspace selected.")})})]})]})});function Ei(e,s={}){const r=Rs(p=>p.visibleContext),o=Bl(e,r);return jt({queryKey:ce.git.changes(e||""),queryFn:()=>ye.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function kc(e,s,r){const o=Rs(m=>m.visibleContext),p=Bl(e,o);return jt({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>ye.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function oo(e,s){return jt({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>ye.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function ao(e,s,r){return jt({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>ye.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const v0=new Set(["STARTING","RUNNING","STOPPING"]);function Ec(e){return v0.has(e.runtimeState)||e.runtimeInstanceId!==null}function jc(e){return e instanceof ui&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function x0({services:e,isLoading:s,isError:r}){const{t:o}=de();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:o("正在检查后台服务...")})]}):e.length>0?t.jsxs("div",{className:"flex gap-2.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-amber-900",children:[t.jsx(As,{size:16,className:"mt-0.5 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed",children:[t.jsx("p",{className:"font-medium",children:o("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:o("停止后不会自动恢复。")})]})]}):r?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:o("无法检查后台服务状态,提交时会再次确认。")}):null}function Nc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:x,isCheckingServices:i,serviceCheckFailed:n,error:a,onConfirm:h}){const{t:c}=de(),[g,v]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),v(p??""))},[e]),b.useEffect(()=>{_||!e||v(p??"")},[p,_,e]);const l=()=>{m||s()};return t.jsx(gs,{isOpen:e,onClose:l,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:l,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:c("取消")}),t.jsx("button",{onClick:()=>h(g.trim()||void 0,x.length>0),disabled:m||i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:m||i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"}),i?c("正在检查后台服务..."):x.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Jr,{size:14}),x.length>0?c("停止服务并提交"):c("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:r}),t.jsx(fl,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:c("提交消息")}),t.jsx("textarea",{value:g,onChange:u=>{w(!0),v(u.target.value)},placeholder:c("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:c("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!g.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:c("留空将使用默认消息")})]}),t.jsx(x0,{services:x,isLoading:i,isError:n}),a&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:a})]})})}function Fs(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Rc(e){if(!(e instanceof ui)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==gr.REBASE&&s.conflictOp!==gr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Fs(s,"sourceBranch"),targetBranch:Fs(s,"targetBranch"),sourceWorktreePath:Fs(s,"sourceWorktreePath"),targetWorktreePath:Fs(s,"targetWorktreePath"),sourceWorkspaceId:Fs(s,"sourceWorkspaceId"),targetWorkspaceId:Fs(s,"targetWorkspaceId")}}function ga(e,s,r,o){const p=Rc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Ac({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:x,onResolveConflicts:i}){const{t:n}=de(),{data:a,isLoading:h}=Gn(e),c=Wl(),g=zl(),v=Qn(),[_,w]=b.useState(!1),[l,u]=b.useState(null),d=so(e,_),f=(d.data??[]).filter(Ec);if(b.useEffect(()=>{_&&m?.()},[_,m]),h||!a)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("正在检查工作区状态...")})]});const S=a.conflictedFiles.length>0,C=a.operation!=="idle",k=a.hasUncommittedChanges||a.untrackedCount>0,E=a.uncommittedCount+a.untrackedCount,y=!S&&!C&&!k,j=a.operation==="idle"&&a.ahead===0&&a.behind===0&&!k&&!S,R=()=>{u(null),c.mutate(e,{onError:B=>{ga(B,n("更新失败,请稍后重试"),I=>x(I),u)}})},P=()=>{u(null),w(!0)},M=(B,I)=>{u(null),g.mutate({id:e,commitMessage:B,stopActiveServices:I},{onSuccess:()=>w(!1),onError:H=>{if(jc(H)){u(n("后台服务仍在运行,请确认停止服务后再提交。"));return}ga(H,n("提交失败,请稍后重试"),q=>{w(!1),x(q)},u)}})},T=()=>{g.isPending||(w(!1),u(null))};return j?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(Td,{size:13}),t.jsx("span",{className:"text-xs",children:n("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[l&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:l}),k&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(Ru,{size:12,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:E})})]}),S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(As,{size:13,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个文件存在冲突,需要处理后继续",{count:a.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:n("处理冲突")}),t.jsx("button",{onClick:()=>v.mutate(e),disabled:v.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:v.isPending?n("正在撤销..."):n("撤销操作")})]})]}),C&&!S&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:a.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>v.mutate(e),disabled:v.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(za,{size:12}),v.isPending?n("正在撤销..."):n("撤销操作")]})]}),!S&&!C&&(a.behind>0||a.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[a.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("源分支 {branch} 有 {count} 个更新",{branch:r,count:a.behind})}),t.jsxs("button",{onClick:R,disabled:!y||c.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Ts,{size:12}),c.isPending?n("正在同步..."):n("同步更新")]})]}),a.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("{count} 个文件变更,可以安全提交",{count:p??a.ahead})}),a.behind===0&&!k?t.jsxs("button",{onClick:P,disabled:g.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Jr,{size:12}),n("提交变更")]}):t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:n(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Jr,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(Nc,{isOpen:_,onClose:T,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:l,onConfirm:M})]})}const Gi=50,Qi=400,va={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},xa={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Tc(e){const s=e.split("/");return s[s.length-1]||e}function b0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function _0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?_t("{count}s ago",{count:r}):r<3600?_t("{count}m ago",{count:Math.floor(r/60)}):r<86400?_t("{count}h ago",{count:Math.floor(r/3600)}):r<604800?_t("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Xr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const yn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:se("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),y0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},Mc=({diff:e})=>{const{t:s}=de(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
|
|
72
|
-
`),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>Qi,x=m?p.slice(0,Qi):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[x.map((i,n)=>t.jsx(y0,{line:i,lineNum:n+1},n)),m&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-Qi})})]})},S0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=de(),{data:m,isLoading:x,isError:i}=kc(e,o?s:null,r);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Mc,{diff:m?.diff||""})},w0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=de(),{data:m,isLoading:x,isError:i}=ao(e,o?s:null,o?r:null);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Mc,{diff:m?.diff||""})},Zi=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,x]=b.useState(!1),[i,n]=b.useState(!1),a=b.useRef(null),h=Xr(s,e.path);b.useEffect(()=>(p(h,a.current),()=>p(h,null)),[h,p]),b.useEffect(()=>{const v=a.current;if(!v||i)return;const _=new IntersectionObserver(w=>{w.some(l=>l.isIntersecting)&&(n(!0),_.disconnect())},{rootMargin:"300px 0px"});return _.observe(v),()=>_.disconnect()},[i]);const c=va[e.status]||va.M,g=b0(e.path);return t.jsxs("div",{ref:a,"data-card-key":h,className:se("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>x(v=>!v),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(Tt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(wt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Tc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(yn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(S0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(w0,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function C0(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let p=s;for(let m=0;m<o.length-1;m++){const x=o[m];p.dirs.has(x)||p.dirs.set(x,{name:x,path:p.path?`${p.path}/${x}`:x,dirs:new Map,files:[]}),p=p.dirs.get(x)}p.files.push(r)}return Dc(s)}function Dc(e){const s=new Map;for(const r of e.dirs.values()){let o=Dc(r);for(;o.dirs.size===1&&o.files.length===0;){const p=[...o.dirs.values()][0];o={...p,name:`${o.name}/${p.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const k0=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=b.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(x=>!x),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(pi,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Bn,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(Pc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Pc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(k0,{dir:p,depth:s,activeKey:r,onSelect:o},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(p),className:se("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full shrink-0",xa[p.status]||xa.M)}),t.jsx("span",{className:se("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Tc(p.path)})]},p.cardKey)})]}),E0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=de(),{data:p,isLoading:m,fetchNextPage:x,hasNextPage:i,isFetchingNextPage:n}=Fn({queryKey:ce.git.log(e),queryFn:({pageParam:h=0})=>ye.get("/git/log",{params:{workingDir:e,limit:String(Gi),skip:String(h)}}),initialPageParam:0,getNextPageParam:(h,c)=>h.commits.length<Gi?void 0:c.length*Gi}),a=p?.pages.flatMap(h=>h.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Be,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):a.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[a.map(h=>{const c=s===h.hash;return t.jsxs("button",{type:"button",onClick:()=>r(h),className:se("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:h.message,children:[t.jsx("span",{className:se("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:se("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:h.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:h.shortHash})," · ",h.author," · ",_0(h.timestamp)]})]})]},h.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>x(),disabled:n,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},j0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n})=>{const{t:a}=de(),[h,c]=b.useState({kind:"overview"}),[g,v]=b.useState(""),[_,w]=b.useState(null),[l,u]=b.useState(null),{data:d,isLoading:f,isError:S}=Ei(e),C=h.kind==="commit"?h.commit.hash:null,{data:k,isLoading:E}=oo(e,C),y=b.useRef(new Map),j=b.useRef(null),R=b.useRef(null),P=b.useCallback((z,W)=>{W?y.current.set(z,W):y.current.delete(z)},[]),{uncommitted:M,committed:T,commitFiles:B}=b.useMemo(()=>{const z=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(h.kind==="commit"){const N={kind:"commit",hash:h.commit.hash},F=(k?.files||[]).filter(z).map(V=>({...V,cardKey:Xr(N,V.path)}));return{uncommitted:[],committed:[],commitFiles:F}}const W=(d?.uncommitted||[]).filter(z).map(N=>({...N,cardKey:Xr({kind:"working",diffType:"uncommitted"},N.path)})),$=(d?.committed||[]).filter(z).map(N=>({...N,cardKey:Xr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:W,committed:$,commitFiles:[]}},[h,d,k,g]),I=h.kind==="commit"?B:[...M,...T],H=b.useMemo(()=>C0(I),[I]),q=b.useMemo(()=>{let z=0,W=0;for(const $ of I)z+=$.additions??0,W+=$.deletions??0;return{additions:z,deletions:W,files:I.length}},[I]),A=b.useCallback(()=>{const z=j.current;if(!z)return;const W=z.getBoundingClientRect().top;let $=null,N=Number.NEGATIVE_INFINITY;for(const[F,V]of y.current){const X=V.getBoundingClientRect().top-W;X<=48&&X>N&&(N=X,$=F)}if(!$){let F=null,V=Number.POSITIVE_INFINITY;for(const[X,te]of y.current){const G=te.getBoundingClientRect().top-W;G<V&&(V=G,F=X)}$=F}w($)},[]);b.useEffect(()=>{const z=j.current;if(!z)return;let W=0;const $=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(A)};return z.addEventListener("scroll",$,{passive:!0}),()=>{z.removeEventListener("scroll",$),cancelAnimationFrame(W)}},[A]);const O=b.useCallback(z=>{const W=y.current.get(z.cardKey);W&&(W.scrollIntoView({behavior:"smooth",block:"start"}),w(z.cardKey),u(z.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>u(null),1200))},[]),D=b.useCallback(z=>{c(W=>W.kind==="commit"&&W.commit.hash===z.hash?{kind:"overview"}:{kind:"commit",commit:z}),v(""),w(null),j.current?.scrollTo({top:0})},[]),L=b.useCallback(()=>{c({kind:"overview"}),v(""),w(null),j.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:a("未选择工作区")});const K=m&&s&&r&&o,U=h.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[K&&i&&n&&t.jsx(Ac,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:h.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Qs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:a("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:a("{count} 个文件",{count:q.files})}),t.jsx(yn,{additions:q.additions,deletions:q.deletions}),r&&o&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:r}),t.jsx(Ks,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:L,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(Ks,{size:12}),a("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:h.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:h.commit.message}),t.jsx(yn,{className:"ml-auto",additions:q.additions,deletions:q.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:U?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(z=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},z))}):S&&h.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:a("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(ei,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?a("没有匹配筛选条件的文件"):h.kind==="commit"?a("该提交没有文件变更"):a("没有待审查的变更")})]}):h.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:B.map(z=>t.jsx(Zi,{entry:z,source:{kind:"commit",hash:h.commit.hash},workingDir:e,flash:l===z.cardKey,registerNode:P},z.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[M.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(z=>t.jsx(Zi,{entry:z,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:l===z.cardKey,registerNode:P},z.cardKey))})]}),T.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:T.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:T.map(z=>t.jsx(Zi,{entry:z,source:{kind:"working",diffType:"committed"},workingDir:e,flash:l===z.cardKey,registerNode:P},z.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(An,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:z=>v(z.target.value),placeholder:a("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?a("无匹配文件"):a("暂无变更文件")}):t.jsx(Pc,{node:H,depth:0,activeKey:_,onSelect:O})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(Xs,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(E0,{workingDir:e,selectedHash:C,onSelectCommit:D})})]})]})]})]})},Ji=50,ba={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function N0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?_t("{count}s ago",{count:r}):r<3600?_t("{count}m ago",{count:Math.floor(r/60)}):r<86400?_t("{count}h ago",{count:Math.floor(r/3600)}):r<604800?_t("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function R0(e){const s=e.split("/");return s[s.length-1]||e}function A0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const T0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:se("flex",r),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:s}),t.jsx("span",{className:se("pl-2 whitespace-pre",o),children:e})]})},M0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=de(),{data:p,isLoading:m,isError:x}=ao(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const n=i.split(`
|
|
73
|
-
`);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((a,h)=>t.jsx(T0,{line:a,lineNum:h+1},h))})},D0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=de(),{data:m,isLoading:x}=oo(e,s);if(x)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Be,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const a=ba[n.status]||ba.M,h=A0(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:se("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===n.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",a),children:n.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:R0(n.path)}),h&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:h})]},n.path)})})},P0=({workingDir:e})=>{const{t:s}=de(),r=Rs(E=>E.visibleContext),o=Bf(e,r),{data:p,isLoading:m,isError:x,fetchNextPage:i,hasNextPage:n,isFetchingNextPage:a}=Fn({queryKey:ce.git.log(e||""),queryFn:({pageParam:E=0})=>ye.get("/git/log",{params:{workingDir:e||"",limit:String(Ji),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,y)=>E.commits.length<Ji?void 0:y.length*Ji,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),h=p?.pages.flatMap(E=>E.commits)||[],[c,g]=b.useState(null),[v,_]=b.useState(null),[w,l]=b.useState(280),[u,d]=b.useState(!1),f=b.useCallback(E=>{E.preventDefault(),d(!0);const y=E.clientX,j=w,R=M=>{const T=Math.min(480,Math.max(180,j+(M.clientX-y)));l(T)},P=()=>{d(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",P)},[w]),S=E=>{c===E?(g(null),_(null)):(g(E),_(null))},C=b.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:s("No workspace selected.")});if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(h.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(Xs,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=h.find(E=>E.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:u?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:w},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Xs,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:h.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[h.map(E=>{const y=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>S(E.hash),className:se("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",y?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:se("w-2 h-2 rounded-full shrink-0 transition-colors",y?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Tt,{size:12,className:se("shrink-0 text-muted-foreground/70 transition-transform",y&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:N0(E.timestamp)})]})]})]}),y&&t.jsxs(t.Fragment,{children:[E.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:E.body}),t.jsx(D0,{workingDir:e,hash:E.hash,selectedPath:v,onSelectFile:_})]})]},E.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>i(),disabled:a,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:a?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:se("w-1 shrink-0 cursor-col-resize transition-colors",u?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v&&c?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(ei,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:v}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(M0,{workingDir:e,hash:c,filePath:v})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(ei,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},_a=Sr();function L0(e){if(!_a)return e;try{const s=new URL(_a);return new URL(e,s.origin).toString()}catch{return e}}function Lc(e){return{...e,viewUrl:e.viewUrl?L0(e.viewUrl):null}}function I0(e,s=!0){return jt({queryKey:ce.previews.status(e??""),queryFn:async()=>{const r=await ye.get(`/previews/${e}/status`);return Lc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function O0(e){const s=vt();return Ht({mutationFn:async r=>{const o=await ye.put(`/previews/${e}/config`,{target:r});return Lc(o)},onSuccess:r=>{e&&(s.setQueryData(ce.previews.status(e),r),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function B0(){return window.location.protocol==="https:"?"remote":"local"}function F0(e,s,r=!0){const[o,p]=b.useState(null),[m,x]=b.useState(!1),[i,n]=b.useState(null),[a,h]=b.useState(0);return b.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),x(!1),n(null);return}let c=!1,g=null,v=null;p(null);const _=l=>{ye.delete(`/previews/${e}/sessions/${l}`).catch(()=>{})};return(async()=>{x(!0),n(null);try{const l={mode:B0(),localHostname:window.location.hostname},u=await ye.post(`/previews/${e}/sessions`,l);if(c){_(u.id);return}g=u.id,p(u),v=window.setInterval(async()=>{if(g)try{const d=await ye.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),n(null))}catch(d){!c&&d instanceof ui&&d.status===404?h(f=>f+1):c||n(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(l){c||(p(null),n(l instanceof Error?l:new Error("Failed to open preview session")))}finally{c||x(!1)}})(),()=>{c=!0,v!==null&&window.clearInterval(v),g&&_(g)}},[r,a,s?.ready,s?.target,e]),{session:o,isOpening:m,error:i,retry:()=>h(c=>c+1)}}const z0="agent-tower-preview",W0="agent-tower-preview-host";function H0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function $0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function U0(e){return t.jsx(q0,{...e},e.workspaceId??"no-workspace")}function q0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=de(),[m,x]=b.useState(null),n=!(r?.source.kind==="visualization")&&!m,{data:a,isLoading:h,refetch:c,isFetching:g}=I0(e,n),v=O0(e),{session:_,isOpening:w,error:l,retry:u}=F0(e,a,n),d=b.useRef(null),f=b.useRef(null),S=b.useRef(null),C=b.useRef(null),k=b.useRef(null),E=b.useRef(null),[y,j]=b.useState(0),[R,P]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),M=$0(_?.viewUrl),T=a&&R.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:a&&!a.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,B=b.useCallback(U=>{P(z=>({...a&&z.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:z,...U}))},[a]);b.useEffect(()=>{if(!_||_.target!==a?.target)return;const U=k.current!==M;k.current=M,P(z=>{const W=r?.source.kind==="web"&&E.current!==r.id?zr(r.source.url,_.target,_.viewUrl):null;if(!U&&z.iframeSrc&&z.target===_.target&&W?.kind!=="proxy")return z;let $=z.iframeSrc;if(W?.kind==="proxy")$=W.url;else if(!$||z.target!==_.target||U){const F=S.current;if(F)$=qd(_.viewUrl,F);else{const V=zr(z.address||_.target,_.target,_.viewUrl);$=V?.kind==="proxy"?V.url:_.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&$&&N.location.replace($),C.current=null,{target:_.target,address:W?.kind==="proxy"?r?.source.kind==="web"?r.source.url:z.address:z.address||_.target,iframeSrc:$,isFrameLoading:!!$}})},[r,_,M,a?.target]),b.useEffect(()=>()=>{C.current?.close()},[]);const I=b.useCallback(async(U,z=!1)=>{const W=zr(U,a?.target??null,_?.viewUrl??null);if(!W||!e)return;if(x(null),W.kind==="proxy"){if(z){window.open(W.url,"_blank","noopener,noreferrer");return}P({target:a?.target??null,address:U,iframeSrc:W.url,isFrameLoading:!0});return}if(s)return;const $=z?window.open("about:blank","_blank"):null;$&&($.opener=null);try{S.current=W.path,C.current=$;const N=await v.mutateAsync(W.target);P({target:N.target,address:U.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(F=>F+1),ot.success(p("Preview target saved")),N.ready||(C.current?.close(),C.current=null)}catch(N){C.current?.close(),C.current=null,S.current=null;const F=N instanceof Error?N.message:p("Failed to save preview target");ot.error(F)}},[_?.viewUrl,s,a?.target,p,v,e]);b.useEffect(()=>{if(!r||E.current===r.id||r.source.kind==="web"&&h)return;const U=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(x({source:r.source,iframeSrc:Kd(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(z=>z+1)):(x(null),I(r.source.url))},0);return()=>window.clearTimeout(U)},[h,I,r,o]),b.useEffect(()=>{if(m)return;const U=z=>{if(z.source!==d.current?.contentWindow)return;const W=z.data;if(!(!W||W.source!==z0)){if(W.type==="location"&&typeof W.href=="string"){const $=Vd(a?.target??null,_?.viewUrl??null,W.href,window.location.href);$&&document.activeElement!==f.current&&B({target:a?.target??T.target,address:$,isFrameLoading:!1});return}W.type==="navigate-loopback"&&typeof W.href=="string"&&I(W.href,W.newTab===!0)}};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[T.target,I,B,_?.viewUrl,a?.target,m]);const H=U=>{d.current?.contentWindow?.postMessage({source:W0,action:U},"*")},q=U=>{U.preventDefault(),I(T.address)},A=async()=>{if(m){x(z=>z&&{...z,isFrameLoading:!0}),j(z=>z+1);return}const U=await c();if(!U.data?.ready){B({target:U.data?.target??T.target,iframeSrc:null,isFrameLoading:!1});return}if(!_||!T.iframeSrc){u();return}B({isFrameLoading:!0}),H("reload")},O=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!_?.viewUrl)return;const U=zr(T.address||_.target,_.target,_.viewUrl),z=U?.kind==="proxy"?U.url:_.viewUrl;window.open(z,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:p("No active workspace.")});const D=m?.iframeSrc??T.iframeSrc,L=!!m,K=!L&&(h||g||v.isPending||w);return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{L?x(null):H("back")},disabled:!L&&!T.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx(Ks,{})}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>H("forward"),disabled:L||!T.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(fl,{})}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:!L&&T.isFrameLoading?()=>{H("stop"),B({isFrameLoading:!1})}:A,disabled:!L&&!T.isFrameLoading&&g,title:!L&&T.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!L&&T.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!L&&T.isFrameLoading?t.jsx(Yt,{}):g?t.jsx(Be,{className:"animate-spin"}):t.jsx(Ts,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:q,children:[t.jsx(wu,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:f,value:m?.source.file??T.address,onChange:U=>B({address:U.target.value}),onKeyDown:U=>{U.key==="Enter"&&U.nativeEvent.isComposing&&U.preventDefault()},disabled:L||s||v.isPending,placeholder:H0(),"aria-label":p("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:O,disabled:!D,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(Cn,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:L?p("Viewing agent visualization"):K?p("Checking preview target..."):l?l.message:a?.ready?`${p("Proxying")} ${a.target}`:a?.configured?`${p("Preview target is not reachable")}${a.error?`: ${a.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(L?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:D?t.jsx("iframe",{ref:d,src:D,title:p("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:L?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{L?x(U=>U&&{...U,isFrameLoading:!1}):B({isFrameLoading:!1})}},y):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:a?.configured?a.ready&&w?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function K0(e){switch(e){case Pt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Pt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Pt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Pt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function ya(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function V0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Ic({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:x}){const{t:i}=de(),[n,a]=b.useState(!1),h=b.useRef(null),c=b.useMemo(()=>eo(e,s),[e,s]),g=c.find(v=>v.workspace.id===r)??c[0];return b.useEffect(()=>{if(!n)return;const v=_=>{h.current&&!h.current.contains(_.target)&&a(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n]),c.length<=1?null:t.jsxs("div",{ref:h,className:se("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>a(v=>!v),disabled:p,className:se("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",x),title:i("Workspace"),children:[t.jsx(Vs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ya(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:V0(Ys(g.workspace))}),t.jsx(wt,{size:13,className:se("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:c.map(v=>{const _=v.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(v.workspace.id),a(!1)},className:se("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",_&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:_?t.jsx(Gt,{size:13}):t.jsx(tl,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(v.displayName)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ya(v.roleLabel)),children:i(v.roleLabel)}),t.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",K0(v.workspace.status)),children:v.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Ys(v.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[v.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",v.ownerName]}),v.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",v.parentBranchName]}),t.jsx("span",{children:v.workspace.id.slice(0,8)})]})]})]},v.workspace.id)})})]})}const X0=[{key:"review",label:"Changes",icon:t.jsx(Qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(mi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(ur,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(el,{size:14})}],Y0=[{key:"history",label:"History",icon:t.jsx(Xs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(mi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(ur,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(el,{size:14})}],G0=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:se("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[r,t.jsx("span",{children:o})]}),Q0=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:se("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:r}),Oc=ue.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:x,gitAvailable:i=!0,readOnly:n,repoDeleted:a,teamRun:h,teamStatus:c,gitProps:g,workspaces:v,selectedWorkspaceId:_,onSelectWorkspace:w,variant:l="tabs",expanded:u,onExpandedChange:d,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:E}=de(),y=Rs(re=>re.setVisibleContext),j=l==="rail",[R,P]=b.useState(!1),M=j?u??R:!0,T=b.useCallback(re=>{u===void 0&&P(re),d?.(re)},[u,d]),B=b.useMemo(()=>{const re=x?Y0:X0,ne=i?re:re.filter(Se=>Se.key!=="review"&&Se.key!=="history"),le=n?ne.filter(Se=>Se.key!=="terminal"):ne;return h?[{key:"team-status",label:"Team Status",icon:t.jsx(js,{size:14})},...le]:le},[i,x,n,h]),[I,H]=b.useState(()=>C?"preview":i?x?"history":"review":"editor"),q=b.useRef(null),A=b.useRef(0),[O,D]=b.useState(),L=b.useCallback(re=>{H(re),j&&T(!0)},[j,T]);b.useImperativeHandle(S,()=>({setTab:re=>L(re),openFile:(re,ne,le)=>{L("editor"),requestAnimationFrame(()=>q.current?.openFile(re,ne,le))},openPreview:(re,ne)=>{A.current+=1,D({id:A.current,source:re,workspaceId:ne}),L("preview")}}),[L]);const K=C??O,U=K?.workspaceId&&K.workspaceId!==o?void 0:K,z=b.useCallback(re=>{D(ne=>ne?.id===re?void 0:ne),k?.(re)},[k]),{data:W}=au(m??""),$=b.useMemo(()=>{if(!W?.quickCommands)return[];try{return JSON.parse(W.quickCommands)}catch{return[]}},[W?.quickCommands]),[N,F]=b.useState([]),V=b.useRef(void 0);b.useEffect(()=>{p&&p!==V.current&&(V.current=p,F(re=>re.includes(p)?re:[...re,p]))},[p]),b.useEffect(()=>{B.some(re=>re.key===I)||H(B[0]?.key??"editor")},[I,B]),b.useEffect(()=>{if(j&&!M)return;const re=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!re){y(null);return}return y({workspaceId:o,workingDir:p,tab:re}),()=>{y(null)}},[I,M,j,y,p,o]);const X=!!w&&eo(v,h).length>1,te=B.find(re=>re.key===I)??B[0],G=te?E(te.label):"",pe=n?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:E(a?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,he=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[X&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Ic,{workspaces:v,teamRun:h,selectedWorkspaceId:_,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&h&&c,I==="editor"&&t.jsx(g0,{ref:q,workingDir:p,readOnly:n}),N.map(re=>{const ne=I==="terminal"&&p===re;return t.jsx("div",{"aria-hidden":!ne,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:ne?"block":"none"},children:t.jsx(Np,{cwd:re,workspaceId:ne?o:void 0,isVisible:ne,quickCommands:$})},re)}),I==="preview"&&t.jsx(U0,{workspaceId:o,readOnly:n,navigationRequest:U,onNavigationRequestHandled:z}),I==="review"&&t.jsx(j0,{workingDir:p,workspaceId:o,branchName:g?.branchName,targetBranch:g?.targetBranch,commitMessage:g?.commitMessage,canRunGitOperations:g?.canRunGitOperations,onRefreshCommitMessage:g?.onRefreshCommitMessage,onConflict:g?.onConflict,onResolveConflicts:g?.onResolveConflicts}),I==="history"&&t.jsx(P0,{workingDir:p})]})]});return j?t.jsxs("div",{className:se("flex h-full w-full min-w-0 bg-white",s),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:B.map(re=>t.jsx(Q0,{active:M&&I===re.key,onClick:()=>L(re.key),icon:re.icon,label:E(re.label)},re.key))}),M&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[pe,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:te?.icon}),t.jsx("span",{className:"truncate",children:G})]}),t.jsx("button",{type:"button",onClick:()=>T(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(zu,{size:15})})]}),he]})]}):t.jsxs("div",{className:se("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&pe,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:B.map(re=>t.jsx(G0,{active:I===re.key,onClick:()=>L(re.key),icon:re.icon,label:E(re.label)},re.key))}),he]})}),Z0=3e3;function Sa(e,s){const r=new Map(e.map(o=>[o.workspaceId,o]));for(const o of s){const p=r.get(o.workspaceId);(!p||o.updatedAt>=p.updatedAt)&&r.set(o.workspaceId,o)}return[...r.values()]}function Bc(e){const s=vt(),r=b.useRef({version:0,values:new Map}),[o,p]=b.useState(0),{data:m=[]}=jt({queryKey:ce.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:a=>a.state.data?.some(h=>h.status==="running")?3e3:!1,queryFn:async({signal:a})=>{const h=r.current.version,c=await ye.get(`/tasks/${e}/setup-progress`,{signal:a}),g=[...r.current.values.values()].filter(v=>v.version>h&&v.progress.taskId===e).map(v=>v.progress);return Sa(c,g)}});b.useEffect(()=>{if(!e)return;const a=cs.connect(),h=ce.workspaces.setupProgress(e),c=v=>{if(v.taskId!==e)return;const _=r.current.values.get(v.workspaceId);_&&_.progress.updatedAt>v.updatedAt||(r.current.values.set(v.workspaceId,{version:++r.current.version,progress:v}),s.setQueryData(h,w=>Sa(w??[],[v])))},g=()=>{s.invalidateQueries({queryKey:h})};return a.on(dt.WORKSPACE_SETUP_PROGRESS,c),a.on("connect",g),()=>{a.off(dt.WORKSPACE_SETUP_PROGRESS,c),a.off("connect",g)}},[e,s]);const x=[...m].sort((a,h)=>h.updatedAt-a.updatedAt),i=x.find(a=>a.status==="running")??x.find(a=>a.status!=="running"&&a.updatedAt>o),n=i?.status!=="running"?i?.updatedAt??null:null;return b.useEffect(()=>{if(n===null)return;const a=setTimeout(()=>p(n),Z0);return()=>clearTimeout(a)},[n]),i??null}function Fc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:x,taskPrompt:i,projectIsGitRepo:n=!0,projectWorktreeReady:a=!0,projectGitReason:h}){const{t:c}=de(),[g,v]=b.useState(""),[_,w]=b.useState(""),[l,u]=b.useState(bt.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,E]=b.useState(null),y=vt(),j=Fl(o),R=Dn(),P=lu(),{data:M,isLoading:T}=Gs(),B=d?.isGitRepo??n,I=d?.worktreeReady??a,H=d?.reason??h,q=B!==!1&&I!==!1;b.useEffect(()=>{if(!e||!M)return;const te=M.find(G=>!ts(G));v(G=>G&&M.some(pe=>pe.provider.id===G)?G:te?.provider.id??"")},[e,M]),b.useEffect(()=>{if(e){const te=[m];x&&te.push(x),w(i?.trim()||te.join(`
|
|
74
|
-
|
|
75
|
-
`)),f(null),u(n!==!1&&a!==!1?bt.WORKTREE:bt.MAIN_DIRECTORY),C("idle"),E(null)}},[e,n,a,o,m,x,i]),b.useEffect(()=>{q||u(bt.MAIN_DIRECTORY)},[q]);const A=async()=>{if(!p||P.isPending)return;const te=await P.mutateAsync({id:p});f(te),te.worktreeReady&&u(bt.WORKTREE)},O=S!=="idle",D=async()=>{if(!g||!_.trim())return;const te=M?.find(G=>G.provider.id===g);if(!(!te||ts(te))){E(null);try{C("creating-workspace");const G=await j.mutateAsync({workspaceKind:q?l:bt.MAIN_DIRECTORY});C("creating-session");const pe=await ye.post(`/workspaces/${G.id}/sessions`,{providerId:g,prompt:_.trim()});C("starting-session"),await R.mutateAsync(pe.id),await y.invalidateQueries({queryKey:ce.workspaces.list(o)}),C("idle"),r?.(),s()}catch(G){C("idle"),E(G instanceof Error?G.message:c("启动失败,请重试"))}}},L={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},K=(M??[]).map(te=>{const G=te.provider,pe=ts(te),he=!pe,re=G.executionPermission?c("Required permission: {mode}",{mode:c(nu[G.executionPermission])}):void 0;return{value:G.id,label:he?G.name:`${G.name}${c(" (不可用)")}`,description:[re,pe&&c(pe)].filter(Boolean).join(" · "),icon:t.jsx(fi,{agentType:G.agentType,className:"size-4"}),disabled:!he}}),U=M?.find(te=>te.provider.id===g),z=U?ts(U):void 0,W=!!M?.length&&M.every(te=>!!ts(te)),$=!T&&!M?.length,N=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),F=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),V=c(H==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),X=[{value:bt.WORKTREE,label:c("工作树模式"),description:N,disabled:!q},{value:bt.MAIN_DIRECTORY,label:c("本地模式"),description:F}];return t.jsx(gs,{isOpen:e,onClose:O?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{variant:"outline",onClick:s,disabled:O,children:c("取消")}),t.jsx(Ae,{onClick:D,disabled:O||!U||!_.trim()||!!z,children:L[S]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("Agent")}),t.jsx(ds,{value:g,onChange:v,options:K,placeholder:c(T?"加载中...":"选择 Agent"),disabled:O||T}),z?t.jsx("p",{role:"alert",className:"mt-2 break-words text-xs leading-snug text-destructive",children:c(z)}):null,W&&!U?t.jsxs("div",{role:"alert",className:"mt-2 space-y-1 break-words text-xs leading-snug text-destructive",children:[t.jsx("p",{children:c("No available Provider for this session.")}),t.jsx("ul",{className:"space-y-1",children:M.map(te=>t.jsxs("li",{children:[te.provider.name,": ",c(ts(te))]},te.provider.id))})]}):null,$?t.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:c("No available Provider for this session.")}):null]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("模式")}),q?t.jsx(ds,{value:l,onChange:te=>u(te),options:X,disabled:O}):t.jsx(Xd,{side:"bottom",className:"w-full",content:V,children:t.jsxs("div",{tabIndex:0,"aria-label":V,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(ds,{value:l,onChange:te=>u(te),options:X,disabled:!0}),t.jsx("button",{type:"button",onClick:A,disabled:O||P.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:P.isPending?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:_,onChange:te=>w(te.target.value),rows:5,disabled:O,placeholder:c("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function zc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function J0(e,s,r){const o=e?.providerId??r?.providerId??null,p=o?s?.find(n=>n.provider.id===o)?.provider:null,m=p?.name??o??e?.agentType??r?.agentType??null;if(!m)return null;const x=e?.agentType??p?.agentType??r?.agentType??null,i=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:i,agentType:x}}function Wc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:x="top"}){const{t:i}=de(),n=J0(e,s,{providerId:p,agentType:m});return!n&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[n&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${i("Provider")}: ${n.title}`,children:[t.jsx(fi,{agentType:n.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:Md(n.label,o?12:18)})]}),t.jsx(Pn,{usage:r,tooltipSide:x})]})}function ex({isOpen:e,onClose:s,taskId:r}){const{t:o}=de(),[p,m]=b.useState("AUTO"),[x,i]=b.useState(null),[n,a]=b.useState([]),[h,c]=b.useState(null),g=Wa();b.useEffect(()=>{e&&(m("AUTO"),i(null),a([]),c(null))},[e]);const v=g.isPending,_=!!x||n.length>0,w=async()=>{if(!v){if(!x&&n.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...x?{teamTemplateId:x}:{},...n.length>0?{memberPresetIds:n}:{}}),s()}catch(u){if(u instanceof ui&&u.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(u instanceof Error?u.message:o("创建 TeamRun 失败"))}}},l=v||!_;return t.jsxs(gs,{isOpen:e,onClose:v?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{type:"button",variant:"outline",onClick:s,disabled:v,children:o("取消")}),t.jsx(Ae,{type:"button",onClick:w,disabled:l,children:o(v?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(Zd,{mode:p,setMode:m,selectedTemplateId:x,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:a,disabled:v}),h&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:h})]})}function tx({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=de(),p=Qn();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(As,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Ae,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Hc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
|
|
76
|
-
`):"- 未获取到冲突文件列表"}function $c(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function sx(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function rx(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function ix(e,s,r,o,p){const m=Hc(r),x=$c(p);return o===gr.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
|
|
77
|
-
`):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",m,"","### 解决步骤",...sx(e,p)].join(`
|
|
78
|
-
`)}function nx(e){const s=e.conflictOp===gr.REBASE?"Rebase":"Merge",r=Hc(e.conflictedFiles),o=[...$c(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===gr.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":rx(e)].join(`
|
|
79
|
-
`)}function ox(e){if(e.teamRunId)return{type:"team_room",message:nx(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:ix(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Uc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:x,operation:i,worktreePath:n,mergeAborted:a,mergeStrategy:h,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:v,targetWorktreePath:_,sessions:w,currentSessionId:l,teamRunId:u}){const{t:d}=de(),[f,S]=b.useState(""),C=Ln(),k=kn(u??""),E=Yn(),y=!!u,j=l||f,R=y?k.isPending:C.isPending,P=()=>{const H=ox({workspaceId:r,worktreePath:n,operation:i,mergeAborted:a,mergeStrategy:h,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:v,targetWorktreePath:_,sourceBranch:m,targetBranch:x,conflictedFiles:p,conflictOp:o,teamRunId:u,currentSessionId:l,selectedSessionId:f});if(H.type==="team_room"){k.mutate({content:H.message,kind:"chat"},{onSuccess:()=>{ot.success(d("已发送到 Team Room")),s(!1)}});return}H.type==="session"&&C.mutate({id:H.sessionId,message:H.message},{onSuccess:()=>s(!1)})},M=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},T=o==="REBASE"?"Rebase":"Merge",B=!y&&!l&&w.length>0,I=y||!!j;return t.jsx(gs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:T}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ae,{variant:"outline",onClick:M,children:d("在 IDE 中打开")}),t.jsx(Ae,{onClick:P,disabled:!I||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(H=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:H},H))})]}),y&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),B&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:H=>S(H.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:d("选择一个 Session...")}),w.map(H=>t.jsxs("option",{value:H.id,children:[H.agentType," — ",H.status]},H.id))]})]}),!y&&!j&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function ax(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function wa(e,s,r,o){const p=Rc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function qc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:x,canRunGitOperations:i,onOpenChanges:n,onRefreshCommitMessage:a,onConflict:h,className:c}){const{t:g}=de(),v=Wl(),_=zl(),w=Qn(),[l,u]=b.useState(!1),[d,f]=b.useState(null),S=so(e,l),C=(S.data??[]).filter(Ec),k=b.useMemo(()=>ax(p),[p]),E=k.additions+k.deletions,y=k.files>0&&E>0,j=(m?.conflictedFiles.length??0)>0,R=!!(m&&m.operation!=="idle"),P=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),M=(m?.uncommittedCount??0)+(m?.untrackedCount??0),T=(m?.behind??0)>0,B=(m?.ahead??0)>0,I=x||!m&&i,H=!!(i&&e&&m&&T&&!j&&!R&&!P),q=!!(i&&e&&m&&B&&!T&&!j&&!R&&!P);if(b.useEffect(()=>{l&&a?.()},[l,a]),!y)return null;const A=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):M>0?g("{count} 未提交",{count:M}):T?g("落后 {count}",{count:m?.behind??0}):g(B?"可合并":"已是最新"),O=g("{files} 个文件 · {lines} 行",{files:k.files,lines:E}),D=()=>{H&&(f(null),v.mutate(e,{onError:z=>{wa(z,g("更新失败,请稍后重试"),W=>h(W),f)}}))},L=()=>{q&&(f(null),u(!0))},K=(z,W)=>{f(null),_.mutate({id:e,commitMessage:z,stopActiveServices:W},{onSuccess:()=>u(!1),onError:$=>{if(jc($)){f(g("后台服务仍在运行,请确认停止服务后再提交。"));return}wa($,g("提交失败,请稍后重试"),N=>{u(!1),h(N)},f)}})},U=()=>{_.isPending||(u(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:se("space-y-1",c),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:n,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":g("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Qs,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:O}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[k.additions>0&&t.jsxs("span",{className:"text-success",children:["+",k.additions]}),k.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",k.deletions]})]}),j&&t.jsx(As,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:A})]}),t.jsx(Tt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[R&&t.jsx("button",{type:"button",onClick:()=>w.mutate(e),disabled:w.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:w.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:D,disabled:!H||v.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:g(T?"同步更新":"已是最新"),children:[v.isPending?t.jsx(Be,{size:12,className:"animate-spin"}):t.jsx(Ts,{size:12}),t.jsx("span",{children:v.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:L,disabled:!q||_.isPending||I,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:q?g("合并到 {target}",{target:r}):g("提交变更"),children:[_.isPending?t.jsx(Be,{size:12,className:"animate-spin"}):t.jsx(Jr,{size:12}),t.jsx("span",{children:_.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(Nc,{isOpen:l,onClose:U,branchName:s,targetBranch:r,commitMessage:o,isPending:_.isPending,activeServices:C,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:d,onConfirm:K})]})}const Ca=["creating-workspace","creating-session","starting-session"];function Kc({state:e,setupProgress:s,sessionStarted:r=!1,onRetry:o,compact:p=!1}){const{t:m}=de(),[x,i]=b.useState(!1),n=e?.status==="failed",a=s?.status==="failed",h=n||a,c=e?Ca.indexOf(e.status):Ca.length,g=[m("Preparing workspace"),m("Creating session"),m("Starting agent")],v=(e?.setupScript??"").split(`
|
|
80
|
-
`).map(l=>l.trim()).filter(Boolean),_=e||r?g.map((l,u)=>({label:l,status:n?"pending":u<c?"completed":u===c?"active":"pending"})):[];(s||v.length>0)&&_.push({label:s?.status==="running"?m("Running setup ({current}/{total})",{current:s.currentIndex??0,total:s.totalCommands}):s?.status==="completed"?m("Setup complete"):s?.status==="failed"?m("Setup failed"):m("Run setup script"),status:s?.status==="running"?"active":s?.status??"pending",description:s?.currentCommand||v.join(`
|
|
81
|
-
`)});const w=!!s?.output?.trim();return!e&&!s?null:t.jsxs("div",{className:`${p?"my-2 mb-4":"my-3 mb-6"} mx-auto w-full max-w-2xl rounded-xl border ${h?"border-destructive/30 bg-destructive/[0.03]":"border-border/70 bg-background"} px-4 py-3 text-left shadow-sm`,role:h?"alert":"status","aria-live":h?"assertive":"polite",children:[h&&(e?.error||s?.error||n)?t.jsx("p",{className:"mb-2 break-words text-xs text-destructive/80",children:e?.error||s?.error||m("Agent start failed")}):null,t.jsx("div",{className:"space-y-2",children:_.map(({label:l,status:u,description:d})=>{const f=u==="completed",S=u==="active";return t.jsxs("div",{className:`flex items-start gap-2 text-sm ${u==="failed"?"text-destructive":f||S?"text-info":"text-muted-foreground"}`,children:[f?t.jsx(Dd,{className:"h-4 w-4 shrink-0"}):S?t.jsx(Be,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):u==="failed"?t.jsx(za,{className:"h-4 w-4 shrink-0"}):t.jsx(iu,{className:"h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{children:l}),d&&t.jsx("code",{className:"mt-1 block whitespace-pre-wrap break-all rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:d})]})]},l)})}),(w||n)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 border-t border-border/50 pt-2",children:[w?t.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":x,"aria-controls":"task-start-progress-details",children:[x?t.jsx(wt,{className:"h-3.5 w-3.5"}):t.jsx(Tt,{className:"h-3.5 w-3.5"}),m(x?"Hide setup output":"View setup output")]}):t.jsx("span",{}),n&&o?t.jsx(Ae,{size:"sm",variant:"outline",onClick:o,children:m("Retry start")}):null]}),x&&t.jsx("div",{id:"task-start-progress-details",className:"mt-2 rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono",children:s?.output??""})})]})}function lx({agentType:e,workingDir:s}){return jt({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await ye.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Rt.CODEX,staleTime:3e4})}function cx(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Vc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:x}){const[i,n]=b.useState(0),{data:a=[]}=lx({agentType:e,workingDir:s}),c=b.useMemo(()=>e===Rt.CODEX?bo(r):null,[e,r])?.query??null,g=b.useMemo(()=>c===null?[]:Jd(a,c),[c,a]),v=b.useCallback(()=>{const l=p.current;l&&(l.style.height="auto",l.style.height=`${Math.max(m,Math.min(l.scrollHeight,x))}px`)},[x,m,p]);b.useEffect(()=>{n(0)},[e,c]),b.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const _=b.useCallback(l=>{const u=bo(r);if(!u)return;const d=`${r.slice(0,u.replaceStart)}${l.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(v(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,v,o,p]),w=b.useCallback(l=>c===null||g.length===0?!1:l.key==="ArrowDown"?(l.preventDefault(),n(u=>(u+1)%g.length),!0):l.key==="ArrowUp"?(l.preventDefault(),n(u=>(u-1+g.length)%g.length),!0):cx(l)?(l.preventDefault(),_(g[i]??g[0]),!0):!1,[_,g,c,i]);return{allSkills:a,query:c,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:_,handleKeyDown:w}}const en=200,dx=180;function Xc({taskId:e,title:s,readOnly:r=!1,onTitleChange:o,className:p,titleClassName:m,compact:x=!1}){const{t:i}=de(),[n,a]=b.useState(!1),[h,c]=b.useState(s),[g,v]=b.useState(!1),_=b.useRef(null),w=b.useRef(null),l=Ha();b.useEffect(()=>{n||c(s)},[s,n]),b.useEffect(()=>{n&&_.current&&(_.current.focus(),_.current.select())},[n]),b.useEffect(()=>{if(!n)return;const j=R=>{w.current&&!w.current.contains(R.target)&&f()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[n,h]);const u=b.useCallback(()=>{r||(a(!0),c(s))},[r,s]),d=b.useCallback(()=>{a(!1),c(s)},[s]),f=b.useCallback(async()=>{const j=h.trim();if(!j){c(s),a(!1);return}if(j===s){a(!1);return}try{await l.mutateAsync({id:e,title:j}),o?.(j),a(!1)}catch(R){console.error("Failed to update task title:",R),c(s)}},[h,s,e,l,o]),S=b.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),f()):j.key==="Escape"&&(j.preventDefault(),d())},[f,d]),C=b.useCallback(j=>{const R=j.target.value;R.length<=en&&c(R)},[]),k=h.length,E=k>=dx,y=k>=en;return n?t.jsxs("div",{ref:w,className:se("flex flex-col gap-2",p),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:_,type:"text",value:h,onChange:C,onKeyDown:S,disabled:l.isPending,className:se("flex-1 min-w-0 px-2 py-1 text-lg font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",x&&"text-base py-0.5",m),placeholder:i("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Ae,{size:x?"sm":"default",variant:"ghost",onClick:f,disabled:l.isPending||!h.trim(),className:"h-8 w-8 p-0",children:l.isPending?t.jsx(Be,{size:16,className:"animate-spin"}):t.jsx(Gt,{size:16})}),t.jsx(Ae,{size:x?"sm":"default",variant:"ghost",onClick:d,disabled:l.isPending,className:"h-8 w-8 p-0",children:t.jsx(Yt,{size:16})})]})]}),E&&t.jsxs("div",{className:se("text-xs",y?"text-destructive":"text-muted-foreground"),children:[k," / ",en," ",i("字符")]})]}):t.jsxs("div",{ref:w,className:se("group flex items-center gap-2 min-w-0",p),onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[t.jsx("h2",{onClick:u,className:se("flex-1 min-w-0 text-lg font-semibold text-foreground break-words line-clamp-2",!r&&"cursor-text hover:text-foreground/80 transition-colors",x&&"text-base",m),children:s}),!r&&g&&t.jsx(Ae,{size:"sm",variant:"ghost",onClick:u,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:i("编辑标题"),children:t.jsx(uu,{size:14})})]})}const ux=Sr(),hx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${ux}/attachments/by-path?path=${encodeURIComponent(e)}`:e,zs=520,tn=48,fx=4,mx=420;function px(){const{t:e}=de();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const ka=[{status:_e.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(Ja,{className:"w-3 h-3"})},{status:_e.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(Za,{className:"w-3 h-3"})},{status:_e.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(Qa,{className:"w-3 h-3"})},{status:_e.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(Ga,{className:"w-3 h-3"})},{status:_e.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(Ya,{className:"w-3 h-3"})}];function gx({status:e,onChangeStatus:s}){const{t:r}=de(),[o,p]=b.useState(!1),m=b.useRef(null);b.useEffect(()=>{if(!o)return;const i=n=>{m.current&&!m.current.contains(n.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]);const x=ka.find(i=>i.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(i=>!i),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${x.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[x.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:ka.filter(i=>i.status!==e).map(i=>t.jsxs("button",{onClick:()=>{s?.(i.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[t.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),t.jsx("span",{className:"text-foreground/80",children:r(i.status)})]},i.status))})]})}function vx({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,onTaskPriorityChange:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=de(),[n,a]=b.useState(""),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(!1),[l,u]=b.useState(!1),[d,f]=b.useState(!1),[S,C]=b.useState(!1),[k,E]=b.useState(null),y=b.useRef(null),[j,R]=b.useState(!1),[P,M]=b.useState(null),[T,B]=b.useState(void 0),[I,H]=b.useState(!1),q=b.useRef(null),A=b.useRef(null),O=b.useRef(null),D=b.useRef(null),{scrollRef:L,contentRef:K,isAtBottom:U,scrollToBottom:z,stopScroll:W}=Tn({resize:"smooth",initial:"instant"}),[$,N]=b.useState(!1),[F,V]=b.useState(zs),[X,te]=b.useState(!1),G=b.useRef(0),pe=b.useRef(zs),he=b.useRef(null),re=b.useCallback((Q,oe,Ie)=>{y.current?.openFile(Q,oe,Ie)},[]),{data:ne,isLoading:le}=Xn(e?.id??""),Se=Bc(e?.id),We=Se?.status==="completed"&&m?.status!=="failed"?null:m,Ee=!!(We||Se&&Se.status!=="completed"),{data:He}=$a(e?.id??""),{data:at}=Ua(He?.id??""),Me=kn(He?.id??""),Ne=He??null,Oe=!!Ne,Ue=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,qe=He===null&&Ue,De=!!(e?.id&&He===null),{data:Ge,isLoading:Qe}=qa(e?.id??"",De);b.useEffect(()=>{H(!1),M(null),B(void 0)},[e?.id]);const Te=b.useMemo(()=>Vl(ne,Ne,T),[T,Ne,ne]);b.useEffect(()=>{T&&!ne?.some(Q=>Q.id===T)&&B(void 0)},[T,ne]);const ge=b.useMemo(()=>ne?.find(Q=>Q.id===Te),[Te,ne]),et=ge?.status===Pt.ACTIVE?ge.id:void 0,Ye=Ue&&Xl(ge,Ne);b.useEffect(()=>{if(!I||!ne)return;ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&H(!1)},[ne,I]);const $e=b.useMemo(()=>{if(I||!ne)return null;const Q=gt=>{const Li=gt.createdAt,or=gt.endedAt??gt.startedAt??Li;if(!or)return 0;const Os=Date.parse(or);return Number.isNaN(Os)?0:Os},oe=(gt,Li)=>{const or=gt.filter(Os=>Li.includes(Os.status));return or.length===0?null:or.sort((Os,xd)=>Q(xd)-Q(Os))[0]??null},Ie=ne.filter(gt=>gt.status==="ACTIVE"&&Array.isArray(gt.sessions)).flatMap(gt=>gt.sessions??[]),mt=oe(Ie,[ut.RUNNING])??oe(Ie,[ut.PENDING])??oe(Ie,[ut.COMPLETED,ut.FAILED,ut.CANCELLED]);if(mt)return mt;const pt=ne.filter(gt=>(gt.status==="MERGED"||gt.status==="ABANDONED"||gt.status==="HIBERNATED")&&Array.isArray(gt.sessions)).flatMap(gt=>gt.sessions??[]);return oe(pt,[ut.COMPLETED,ut.FAILED,ut.CANCELLED])},[ne,I]),ft=$e?.id??"",tt=Oe?P??"":ft,J=b.useMemo(()=>{if(!P||!ne)return null;for(const Q of ne){const oe=Q.sessions?.find(Ie=>Ie.id===P);if(oe)return oe}return null},[P,ne]),fe=b.useMemo(()=>{if(!P||!Ne?.invocations)return null;const Q=Ne.invocations.filter(oe=>oe.sessionId===P);return Q.length===0?null:Q.sort((oe,Ie)=>{const mt=Date.parse(oe.updatedAt??oe.createdAt??""),pt=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(pt)?0:pt)-(Number.isNaN(mt)?0:mt)})[0]??null},[P,Ne?.invocations]),we=b.useMemo(()=>!fe?.memberId||!Ne?.members?null:Ne.members.find(Q=>Q.id===fe.memberId)??null,[fe?.memberId,Ne?.members]),Y=P?J:$e??null,ee=Y?.id,ie=b.useMemo(()=>{if(Y?.workspaceId)return Y.workspaceId;if(!(!Y||!ne))return ne.find(Q=>Q.sessions?.some(oe=>oe.id===Y.id))?.id},[Y,ne]),ae=b.useCallback((Q,oe)=>{const mt=(oe&&ne?.some(pt=>pt.id===oe)?oe:void 0)??ie??Te??void 0;mt&&B(mt),y.current?.openPreview(Q,mt)},[ie,Te,ne]),Ce=b.useCallback((Q,oe)=>{ae({kind:"web",url:Q},oe)},[ae]),ke=b.useCallback((Q,oe,Ie)=>{ae({kind:"visualization",sessionId:Q,file:oe},Ie)},[ae]),Pe=b.useCallback(Q=>{Ce(Q,ie)},[ie,Ce]),Je=b.useCallback(Q=>{ee&&ke(ee,Q,ie)},[ee,ie,ke]),{isActive:be,isCancelling:xe}=sl(ee??"",Y?.status),me=!!e?.projectArchivedAt,Fe=!!e?.projectRepoDeletedAt,st=i(Fe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:lt}=Gs(),[Nt,kt]=b.useState(null),xt=$e?ul(lt,Nt??$e.providerId):void 0;b.useEffect(()=>{kt($e?.providerId??null)},[$e?.providerId]);const It=b.useMemo(()=>!$e||!ne?!1:!ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Ie=>Ie.id===$e.id)),[$e,ne]),Et=b.useMemo(()=>{if(!(!ne||I)){if(ge)return fs(ge);for(const Q of ne)if(Q.status==="ACTIVE"&&fs(Q))return fs(Q);return fs(ne[0])}},[I,ge,ne]),Mt=rl({agentType:$e?.agentType,workingDir:Et,input:n,setInput:a,textareaRef:O,minHeight:60,maxHeight:300}),$t=Vc({agentType:$e?.agentType,workingDir:Et,input:n,setInput:a,textareaRef:O,minHeight:60,maxHeight:300}),er=Rs(Q=>Q.setVisibleContext),Ut=!!(Ye&&et&&Et&&!me),{data:yt,isLoading:ji}=Gn(et??"",{enabled:Ut}),{data:Qt}=Ei(Et,{enabled:Ut});b.useEffect(()=>{if(!($||!Ut||!et||!Et))return er({workspaceId:et,workingDir:Et,tab:"changes"}),()=>{er(null)}},[$,et,er,Ut,Et]);const Zt=ge?.sessions??[],rs=Ys(ge),bs=ge?.commitMessage,Ms=b.useMemo(()=>Yl(ge,ne,e?.mainBranch??""),[ge,e?.mainBranch,ne]),rt=b.useMemo(()=>yt?.conflictOp&&yt.conflictedFiles.length>0?{conflictOp:yt.conflictOp,conflictedFiles:yt.conflictedFiles}:k,[yt?.conflictOp,yt?.conflictedFiles,k]),tr=rt?.targetWorkspaceId??et,Ar=rt?.targetWorktreePath??ge?.worktreePath,Tr=rt?.sourceBranch??rs,Mr=rt?.targetBranch??Ms,it=vt(),Ds=b.useCallback(async()=>e?.id?it.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>ye.get(`/tasks/${e.id}/body`)}):null,[it,e?.id]),_s=b.useCallback(()=>e?.id?it.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,it]);b.useEffect(()=>{if(!j)return;const Q=oe=>{A.current&&!A.current.contains(oe.target)&&R(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[j]);const Jt=Ln(),Dr=Yn(),ys=Pd(),Pr=Fl(e?.id??""),sr=Dn(),Ps=Ff(),Ot=b.useMemo(()=>!ne||ne.some(oe=>oe.status==="ACTIVE")?null:ne.find(oe=>oe.status==="HIBERNATED")??null,[ne]),is=b.useRef(null);b.useEffect(()=>{Ot&&is.current!==Ot.id&&(Ps.isPending||(is.current=Ot.id,Ps.mutate(Ot.id,{onSettled:()=>{is.current=null}})))},[Ot,Ps]);const Ni=b.useCallback(async()=>{if(!e?.id)return;const Q=$e?.providerId??lt?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(Q){u(!1),f(!0);try{const Ie=(await Ds())?.prompt??e.title;await ys.mutateAsync(e.id),H(!0);const mt=await Pr.mutateAsync({workspaceKind:Ue?void 0:bt.MAIN_DIRECTORY}),pt=await ye.post(`/workspaces/${mt.id}/sessions`,{providerId:Q,prompt:Ie});await sr.mutateAsync(pt.id),await it.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),H(!1)}finally{f(!1)}}},[e?.id,e?.title,Ue,$e?.providerId,lt,Ds,ys,Pr,sr,it]),Ls=b.useCallback(async()=>{e?.id&&(await Ds(),c(!0))},[Ds,e?.id]),Lr=b.useCallback(()=>{ge?.id&&Dr.mutate({workspaceId:ge.id})},[Dr,ge?.id]),rr=b.useCallback(()=>{!e?.id||!s||(s(e.id),w(!1))},[e?.id,s]),ir=b.useCallback(Q=>{M(Q),requestAnimationFrame(()=>{z()})},[z]),Ri=b.useCallback(()=>{M(null)},[]),Is=b.useCallback(Q=>{E(Q??null),C(!0)},[]),Ir=b.useCallback(Q=>Me.mutateAsync(Q),[Me]),ns=b.useCallback(()=>{it.invalidateQueries({queryKey:Ld.all})},[it]),{isConnected:Or,isLoadingSnapshot:nr,isOutputActive:Br,lastExitAt:Fr,logs:Ss,entries:Ai,attach:qt}=cl({sessionId:tt,sessionStatus:Y?.status,sessionStartedAt:Y?.startedAt??Y?.createdAt,sessionEndedAt:Y?.endedAt??(be?null:Y?.updatedAt),onExit:b.useCallback(()=>{it.invalidateQueries({queryKey:["workspaces"]})},[it])});b.useEffect(()=>{if(!e?.id)return;const Q=cs.connect();Q.emit(Ws.SUBSCRIBE,{topic:"task",id:e.id});const oe=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:["tasks"]}),ns())},Ie=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ns())},mt=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ns())};return Q.on(dt.TASK_UPDATED,oe),Q.on(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.on(dt.WORKSPACE_HIBERNATED,mt),()=>{Q.off(dt.TASK_UPDATED,oe),Q.off(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.off(dt.WORKSPACE_HIBERNATED,mt),Q.emit(Ws.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,it,ns]),b.useEffect(()=>{if(!tt)return;const Q=cs.connect(),oe=Ie=>{Ie.sessionId===tt&&(it.invalidateQueries({queryKey:["workspaces"]}),ns())};return Q.on(dt.SESSION_COMPLETED,oe),()=>{Q.off(dt.SESSION_COMPLETED,oe)}},[tt,it,ns]);const{todos:Z}=dl(Ai),{files:ve,addFiles:Re,removeFile:ze,clear:St,buildMarkdownLinks:Bt,hasFiles:Le,isUploading:Ft}=En(),os=b.useMemo(()=>zc(Y),[Y?.tokenUsage]),ws=il(Ss,os);b.useEffect(()=>{tt&&Or&&qt()},[tt,Or,qt]);const co=b.useRef(e?.id);b.useEffect(()=>{if(co.current!==e?.id&&L.current){const Q=L.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}co.current=e?.id},[e?.id,L]);const as=nl(),Ti=b.useRef(!1),uo=b.useCallback(async()=>{if(!n.trim()&&!Le||!tt||Ti.current||as.isPending||xe||Ft||xt)return;Ti.current=!0;const Q=Bt(),oe=[n.trim(),Q].filter(Boolean).join(`
|
|
82
|
-
|
|
83
|
-
`);a(""),St(),O.current&&(O.current.style.height="60px"),Jt.mutate({id:tt,message:oe,providerId:Nt??void 0},{onSuccess:()=>{qt()},onError:()=>{a(Ie=>Ie||oe)},onSettled:()=>{Ti.current=!1}})},[n,tt,Jt,qt,Le,Ft,Bt,St,Nt,xt,as.isPending,xe]),cd=b.useCallback(()=>{!tt||as.isPending||as.mutate(tt)},[tt,as]),dd=b.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&Re(Array.from(oe)),Q.target.value=""},[Re]),ud=b.useCallback(Q=>{const oe=Q.clipboardData.items,Ie=[];for(const mt of oe)if(mt.kind==="file"){const pt=mt.getAsFile();pt&&Ie.push(pt)}Ie.length>0&&(Q.preventDefault(),Re(Ie))},[Re]),[ho,Mi]=b.useState(!1),hd=b.useCallback(Q=>{Q.preventDefault(),Mi(!0)},[]),fd=b.useCallback(Q=>{Q.preventDefault(),Mi(!1)},[]),md=b.useCallback(Q=>{Q.preventDefault(),Mi(!1);const oe=Q.dataTransfer.files;oe.length>0&&Re(Array.from(oe))},[Re]),es=b.useCallback(Q=>{const oe=he.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=oe?Math.max(zs,oe-tn-fx-mx):zs;return Math.max(zs,Math.min(Math.round(Q),Ie))},[]),Di=b.useCallback(Q=>{const oe=Q.clientX-G.current;V(es(pe.current-oe))},[es]),Pi=b.useCallback(()=>{te(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);b.useEffect(()=>{if(X)return document.addEventListener("mousemove",Di),document.addEventListener("mouseup",Pi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Di),document.removeEventListener("mouseup",Pi),document.body.style.cursor="",document.body.style.userSelect=""}},[Pi,Di,X]);const pd=b.useCallback(Q=>{Q.preventDefault(),G.current=Q.clientX,pe.current=F,te(!0)},[F]);b.useEffect(()=>{!$||X||V(Q=>es(Q))},[es,$,X]),b.useEffect(()=>{if(!$)return;const Q=()=>{V(oe=>es(oe))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[es,$]);const gd=b.useCallback(()=>{V(Q=>es(Q)),N(!0),requestAnimationFrame(()=>{y.current?.setTab("review")})},[es]),vd=b.useCallback(Q=>{a(Q.target.value);const oe=Q.target;oe.style.height="auto";const Ie=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]),fo=Ut&&et?t.jsx(qc,{workspaceId:et,branchName:rs,targetBranch:Ms,commitMessage:bs,changes:Qt,gitStatus:yt,isGitStatusLoading:ji,canRunGitOperations:Ye,onOpenChanges:gd,onRefreshCommitMessage:_s,onConflict:Is,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx(Xc,{taskId:e.id,title:e.title,readOnly:me})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(gx,{status:e.status,onChangeStatus:!me&&o?Q=>o(e.id,Q):void 0}),t.jsx(ol,{value:e.priority,onChange:!me&&p?Q=>p(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Lr,disabled:!Et||me,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:i("Open in IDE"),children:t.jsx(mi,{size:16})}),(s||qe)&&!me&&t.jsxs("div",{className:"relative",ref:A,children:[t.jsx("button",{onClick:()=>R(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:i("More actions"),children:t.jsx(pl,{size:16})}),j&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[qe&&t.jsxs("button",{onClick:()=>{v(!0),R(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(us,{size:15}),t.jsx("span",{children:i("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{u(!0),R(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Id,{size:15}),t.jsx("span",{children:i("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{w(!0),R(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(On,{size:15}),t.jsx("span",{children:i("删除任务")})]})]})]})]})]})]})]}),Ye&&et&&yt&&t.jsx(tx,{workspaceId:et,gitStatus:yt,onResolve:()=>Is()}),t.jsxs("div",{ref:he,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Oe&&Ne?P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:i("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:P})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Wc,{session:Y,providers:lt,usage:ws,providerIdFallback:we?.providerId,agentTypeFallback:Y?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ae,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:Ri,children:[t.jsx(Ks,{size:13}),t.jsx("span",{children:i("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:K,className:"w-full max-w-4xl mx-auto",children:nr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading logs...")})]}):Ss.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:i(be?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Qr,{children:t.jsx(Yr,{logs:Ss,downloadSessionId:ee,isOutputActive:Br,lastExitAt:Fr,onUserToggleDetails:W,workingDir:Et,scrollElementRef:L,onOpenWorkspaceFile:re,onOpenPreviewUrl:Pe,onOpenVisualization:Je})})})}),!U&&t.jsxs("button",{onClick:()=>z(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(vr,{size:14}),t.jsx("span",{children:i("回到底部")})]})]}),Z.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Zr,{todos:Z})})})]}):t.jsx(Kl,{teamRun:Ne,messages:at??Ne.messages??[],readOnly:me,readOnlyMessage:st,onSendMessage:Ir,onViewInvocationSession:ir,changeSummaryBar:fo,centered:!0,workingDir:Et,onOpenWorkspaceFile:re,onOpenPreviewUrl:Ce,onOpenVisualization:ke}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:L,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:K,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Qe||Ge?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Qe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:i("Loading...")}):Ge?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(Nn,{urlTransform:hx,components:Xa,children:Ge.body})}):null}),!me&&t.jsx(Kc,{state:We,setupProgress:Se,sessionStarted:!!$e?.startedAt,onRetry:ft&&m?.status==="failed"?Ls:void 0},e.id),le?(!Ee||me)&&t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading...")})]}):ft?nr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading logs...")})]}):Ss.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:i(be?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Qr,{children:t.jsx(Yr,{logs:Ss,downloadSessionId:ee,isOutputActive:Br,lastExitAt:Fr,onUserToggleDetails:W,workingDir:Et,scrollElementRef:L,onOpenWorkspaceFile:re,onOpenPreviewUrl:Pe,onOpenVisualization:Je})}):!Ee||m?.status==="failed"||Se?.status==="failed"||me?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(!Ee||me)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(ks,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:i(me?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:me?st:i("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")})]}),!me&&(!m||m.status==="failed")&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Ae,{onClick:Ls,disabled:!!(m&&m.status!=="failed"),children:[t.jsx(ks,{size:16,className:"mr-1.5"}),m?.status==="failed"?i("重试启动 Agent"):i("启动 Agent")]}),qe&&t.jsxs(Ae,{variant:"outline",onClick:()=>v(!0),children:[t.jsx(us,{size:16,className:"mr-1.5"}),i("创建 TeamRun")]})]})]}):null]})}),!U&&t.jsxs("button",{onClick:()=>z(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(vr,{size:14}),t.jsx("span",{children:i("回到底部")})]})]}),Z.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(Zr,{todos:Z})})}),me?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:st})})}):It?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:i("代码已合并,以上为历史沟通记录")}),t.jsxs(Ae,{size:"sm",onClick:Ls,children:[t.jsx(ks,{size:14,className:"mr-1.5"}),i("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:hd,onDragLeave:fd,onDrop:md,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[fo,tt?t.jsx(al,{sessionId:tt}):null,t.jsxs("div",{ref:q,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${ho?"border-info bg-info/5":"border-border"}`,children:[t.jsx(jn,{files:ve,onRemove:ze}),t.jsx("textarea",{ref:O,value:n,onChange:vd,onPaste:ud,onKeyDown:Q=>{$t.handleKeyDown(Q)||Mt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),uo())},rows:1,placeholder:i(ho?"Drop files here...":ft&&!be?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:D,type:"file",multiple:!0,className:"hidden",onChange:dd}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>D.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:i("Upload file"),children:t.jsx(In,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[$e&<&&t.jsx(ll,{providers:lt,currentProviderId:Nt,agentType:$e.agentType,runtimeType:$e.runtimeType,onSelect:kt}),t.jsx(Pn,{usage:ws}),be&&!n.trim()&&!Le?t.jsx("button",{onClick:cd,disabled:as.isPending||xe,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(qs,{size:14})}):t.jsx("button",{onClick:uo,disabled:!n.trim()&&!Le||Ft||Jt.isPending||as.isPending||xe||!!xt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||Le)&&!Ft&&!Jt.isPending&&!as.isPending&&!xe&&!xt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Mn,{size:18})})]})]})]})]}),t.jsx(Gr,{open:Mt.query!==null,anchorRef:q,commands:Mt.filteredCommands,selectedIndex:Mt.selectedIndex,query:Mt.query??"",hasCatalog:Mt.allCommands.length>0,onSelect:Mt.applyCommand}),t.jsx(Gr,{open:$t.query!==null,anchorRef:q,commands:$t.filteredSkills,selectedIndex:$t.selectedIndex,query:$t.query??"",hasCatalog:$t.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:$t.applySkill})]})]})}),$&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:pd,role:"separator","aria-orientation":"vertical","aria-label":i("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:$?tn+F:tn},children:t.jsx(Oc,{sessionId:ft||void 0,workspaceId:Te,workingDir:Et,projectId:e.projectId,readOnly:me,repoDeleted:Fe,teamRun:Ne,teamStatus:Ne?t.jsx(Zl,{teamRun:Ne,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:B,onViewInvocationSession:ir}):void 0,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:B,variant:"rail",expanded:$,onExpandedChange:Q=>{Q&&V(oe=>es(oe)),N(Q)},minContentWidth:zs,tabRef:y,gitAvailable:Ue,gitProps:Ye&&et?{branchName:rs,targetBranch:Ms,commitMessage:bs,canRunGitOperations:!0,onRefreshCommitMessage:_s,onConflict:Is,onResolveConflicts:()=>Is()}:void 0})})]}),!me&&t.jsx(Fc,{isOpen:h,onClose:()=>c(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ge?.title??e.title,taskDescription:Ge?.body??"",taskPrompt:Ge?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>x?.(e.id)}),qe&&!me&&t.jsx(ex,{isOpen:g,onClose:()=>v(!1),taskId:e.id}),Ye&&tr&&rt&&t.jsx(Uc,{open:S,onOpenChange:Q=>{C(Q),Q||E(null)},workspaceId:tr,conflictOp:rt.conflictOp,conflictedFiles:rt.conflictedFiles,sourceBranch:Tr,targetBranch:Mr,operation:yt?.operation,worktreePath:Ar,mergeAborted:rt.mergeAborted,mergeStrategy:rt.mergeStrategy,sourceWorkspaceId:rt.sourceWorkspaceId,targetWorkspaceId:rt.targetWorkspaceId,sourceWorktreePath:rt.sourceWorktreePath,targetWorktreePath:rt.targetWorktreePath,sessions:Zt,currentSessionId:Oe?void 0:ft,teamRunId:Ne?.id}),t.jsx(Rn,{isOpen:l,onClose:()=>u(!1),onConfirm:Ni,title:i("重新开始任务"),description:t.jsx("p",{children:i("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:i("确认重试"),variant:"default",isLoading:d}),t.jsx(Zn,{isOpen:_,onClose:()=>w(!1),onConfirm:rr,taskId:e.id,taskTitle:e.title,workspaces:ne,isLoading:r})]}):t.jsx(px,{})}function lo(e){switch(e){case Vt.TODO:return _e.Pending;case Vt.IN_PROGRESS:return _e.Running;case Vt.IN_REVIEW:return _e.Review;case Vt.DONE:return _e.Done;case Vt.CANCELLED:return _e.Cancelled}}function xx(e){switch(e){case _e.Pending:return Vt.TODO;case _e.Running:return Vt.IN_PROGRESS;case _e.Review:return Vt.IN_REVIEW;case _e.Done:return Vt.DONE;case _e.Cancelled:return Vt.CANCELLED}}function bx(e){switch(e){case Rt.CLAUDE_CODE:return"Claude Code";case Rt.GEMINI_CLI:return"Gemini CLI";case Rt.CURSOR_AGENT:return"Cursor Agent";case Rt.CODEX:return"Codex";case Rt.QWEN_CODE:return"Qwen Code";case Rt.KIRO_CLI:return"Kiro CLI";case Rt.OPENCODE:return"OpenCode";case Rt.PI_CODING_AGENT:return"Pi Coding Agent";case Rt.GROK_BUILD:return"Grok Build";case Rt.MINION_CODE:return"Minion Code";case Rt.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const ci=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function Yc(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function _x(e){return{id:e.id,name:e.name,color:e.color||ci[Yc(e.name,ci.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function yx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===bt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:lo(e.status),priority:e.priority,agent:e.latestAgentType?bx(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function Sx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===bt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||ci[Yc(s.name,ci.length)],title:e.title,status:lo(e.status),priority:e.priority,branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const Ea={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function wx(e){const s=e.split("/");return s[s.length-1]||e}function Cx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function kx({workingDir:e,filePath:s,type:r}){const{t:o}=de(),{data:p,isLoading:m,isError:x}=kc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
84
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((a,h)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,g),children:a},h)})})}function Ex({entry:e,type:s,workingDir:r}){const[o,p]=b.useState(!1),m=Ea[e.status]||Ea.M,x=Cx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:wx(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Tt,{size:14})})]}),o&&t.jsx(kx,{workingDir:r,filePath:e.path,type:s})]})}function ja({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=de(),[x,i]=b.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:x?t.jsx(wt,{size:14}):t.jsx(Tt,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),x&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(n=>t.jsx(Ex,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function jx({workingDir:e}){const{t:s}=de(),{data:r,isLoading:o,isError:p}=Ei(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],x=r?.committed||[];return m.length+x.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Qs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(ja,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(ja,{title:"Committed",entries:x,type:"committed",workingDir:e,defaultOpen:!1})]})}const sn=50,Na={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function Nx(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?_t("{count}s ago",{count:r}):r<3600?_t("{count}m ago",{count:Math.floor(r/60)}):r<86400?_t("{count}h ago",{count:Math.floor(r/3600)}):r<604800?_t("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Rx(e){const s=e.split("/");return s[s.length-1]||e}function Ax(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Tx({workingDir:e,hash:s,filePath:r}){const{t:o}=de(),{data:p,isLoading:m,isError:x}=ao(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
|
|
85
|
-
`);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((a,h)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:se("px-3 whitespace-pre",c,g),children:a},h)})})}function Mx({entry:e,workingDir:s,hash:r}){const[o,p]=b.useState(!1),m=Na[e.status]||Na.M,x=Ax(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Rx(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(wt,{size:14}):t.jsx(Tt,{size:14})})]}),o&&t.jsx(Tx,{workingDir:s,hash:r,filePath:e.path})]})}function Dx({commit:e,workingDir:s}){const{t:r}=de(),[o,p]=b.useState(!1),{data:m,isLoading:x}=oo(s,o?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:se("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:Nx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(wt,{size:14}):t.jsx(Tt,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),x?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>t.jsx(Mx,{entry:n,workingDir:s,hash:e.hash},n.path))})]})]})}function Px({workingDir:e}){const{t:s}=de(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:x,isFetchingNextPage:i}=Fn({queryKey:ce.git.log(e||""),queryFn:({pageParam:a=0})=>ye.get("/git/log",{params:{workingDir:e||"",limit:String(sn),skip:String(a)}}),initialPageParam:0,getNextPageParam:(a,h)=>a.commits.length<sn?void 0:h.length*sn,enabled:!!e}),n=r?.pages.flatMap(a=>a.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):n.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Xs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(a=>t.jsx(Dx,{commit:a,workingDir:e},a.hash))}),x&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const Lx=Sr(),Ix=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Lx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Ox({status:e}){const s={[_e.Running]:"bg-blue-500",[_e.Review]:"bg-amber-500",[_e.Pending]:"bg-neutral-400",[_e.Done]:"bg-emerald-500",[_e.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const Bx=[{key:"chat",label:"Chat",icon:hi},{key:"changes",label:"Changes",icon:Qs},{key:"history",label:"History",icon:Xs},{key:"workspace",label:"Workspace",icon:pi}],Fx=[{key:"chat",label:"Team room",icon:hi},{key:"team-status",label:"Team Status",icon:js},{key:"changes",label:"Changes",icon:Qs},{key:"workspace",label:"Workspace",icon:pi}];function zx({task:e,onBack:s,onDeleteTask:r,onTaskPriorityChange:o,isDeleting:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=de(),n=Rs(Z=>Z.setVisibleContext),[a,h]=b.useState("chat"),[c,g]=b.useState(""),[v,_]=b.useState(!1),[w,l]=b.useState(!1),[u,d]=b.useState(!1),[f,S]=b.useState(null),[C,k]=b.useState(void 0),E=b.useRef(0),[y,j]=b.useState(),R=b.useRef(null),P=b.useRef(null),M=b.useRef(null),T=b.useRef(null),{scrollRef:B,contentRef:I,isAtBottom:H,scrollToBottom:q,stopScroll:A}=Tn({resize:"smooth",initial:"instant"}),O=vt();b.useEffect(()=>{if(!u)return;const Z=ve=>{P.current&&!P.current.contains(ve.target)&&d(!1)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[u]);const{data:D,isLoading:L}=Xn(e.id),K=Bc(e.id),U=K?.status==="completed"&&m?.status!=="failed"?null:m,z=!!(U||K&&K.status!=="completed"),{data:W}=$a(e.id),{data:$}=Ua(W?.id??""),N=kn(W?.id??""),F=W??null,V=e.isGitRepo!==!1&&e.worktreeReady!==!1,X=b.useMemo(()=>(F?Fx:Bx).filter(Z=>V||Z.key!=="changes"&&Z.key!=="history"),[V,F]),te=W===null,{data:G,isLoading:pe}=qa(e.id,te),he=!!e.projectArchivedAt,re=!!e.projectRepoDeletedAt,ne=i(re?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");b.useEffect(()=>{k(void 0),S(null),j(void 0)},[e.id]),b.useEffect(()=>{F&&a==="history"&&h("chat"),!F&&a==="team-status"&&h("chat"),X.some(Z=>Z.key===a)||h("chat")},[a,X,F]);const le=b.useMemo(()=>Vl(D,F,C),[C,F,D]);b.useEffect(()=>{C&&!D?.some(Z=>Z.id===C)&&k(void 0)},[C,D]);const Se=b.useMemo(()=>D?.find(Z=>Z.id===le),[le,D]),We=b.useMemo(()=>{if(D){if(Se)return fs(Se);for(const Z of D)if(Z.status==="ACTIVE"&&fs(Z))return fs(Z);return fs(D[0])}},[Se,D]),Ee=Se?.status===Pt.ACTIVE?Se.id:void 0,He=V&&Xl(Se,F),at=Se?.branchName??"",Me=Se?.commitMessage,Ne=b.useMemo(()=>Yl(Se,D,e?.mainBranch??""),[Se,e?.mainBranch,D]),Oe=!!(He&&Ee&&We&&!he),{data:Ue,isLoading:qe}=Gn(Ee??"",{enabled:Oe}),{data:De}=Ei(We,{enabled:Oe}),Ge=De?.committed?.length,[Qe,Te]=b.useState(!1),[ge,et]=b.useState(null);b.useEffect(()=>{const Z=V&&(a==="changes"||a==="chat"&&Oe)?"changes":V&&a==="history"?"history":null;if(!Ee||!We||!Z){n(null);return}return n({workspaceId:Ee,workingDir:We,tab:Z}),()=>{n(null)}},[a,V,Ee,n,Oe,We]);const Ye=b.useMemo(()=>Ue?.conflictOp&&Ue.conflictedFiles.length>0?{conflictOp:Ue.conflictOp,conflictedFiles:Ue.conflictedFiles}:ge,[Ue?.conflictOp,Ue?.conflictedFiles,ge]),$e=Ye?.targetWorkspaceId??Ee,ft=Ye?.targetWorktreePath??Se?.worktreePath,tt=Ye?.sourceBranch??at,J=Ye?.targetBranch??Ne,fe=Se?.sessions??[],we=b.useCallback(Z=>{et(Z??null),Te(!0)},[]),Y=b.useCallback(()=>e?.id?O.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,O]),ee=b.useCallback(async()=>O.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>ye.get(`/tasks/${e.id}/body`)}),[O,e.id]),ie=b.useMemo(()=>{if(!D)return null;const Z=D.filter(Le=>Le.status==="ACTIVE"&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]),ve=Le=>{const Ft=Le.createdAt,os=Le.endedAt??Le.startedAt??Ft;if(!os)return 0;const ws=Date.parse(os);return Number.isNaN(ws)?0:ws},Re=Le=>{const Ft=Z.filter(os=>Le.includes(os.status));return Ft.length===0?null:Ft.sort((os,ws)=>ve(ws)-ve(os))[0]??null},ze=Re([ut.RUNNING])??Re([ut.PENDING])??Re([ut.COMPLETED,ut.FAILED,ut.CANCELLED]);if(ze)return ze;const Bt=D.filter(Le=>(Le.status==="ABANDONED"||Le.status==="MERGED"||Le.status==="HIBERNATED")&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]).filter(Le=>[ut.COMPLETED,ut.FAILED,ut.CANCELLED].includes(Le.status));return Bt.length===0?null:Bt.sort((Le,Ft)=>ve(Ft)-ve(Le))[0]??null},[D]),ae=ie?.id??"",Ce=F?f??"":ae,ke=b.useMemo(()=>{if(!f||!D)return null;for(const Z of D){const ve=Z.sessions?.find(Re=>Re.id===f);if(ve)return ve}return null},[f,D]),Pe=b.useMemo(()=>{if(!f||!F?.invocations)return null;const Z=F.invocations.filter(ve=>ve.sessionId===f);return Z.length===0?null:Z.sort((ve,Re)=>{const ze=Date.parse(ve.updatedAt??ve.createdAt??""),St=Date.parse(Re.updatedAt??Re.createdAt??"");return(Number.isNaN(St)?0:St)-(Number.isNaN(ze)?0:ze)})[0]??null},[f,F?.invocations]),Je=b.useMemo(()=>!Pe?.memberId||!F?.members?null:F.members.find(Z=>Z.id===Pe.memberId)??null,[Pe?.memberId,F?.members]),be=f?ke:ie??null,xe=be?.id,me=b.useMemo(()=>{if(be?.workspaceId)return be.workspaceId;if(!(!be||!D))return D.find(Z=>Z.sessions?.some(ve=>ve.id===be.id))?.id},[be,D]),Fe=b.useCallback((Z,ve)=>{const ze=(ve&&D?.some(St=>St.id===ve)?ve:void 0)??me??le??void 0;ze&&k(ze),E.current+=1,j({id:E.current,source:Z,workspaceId:ze}),h("workspace")},[me,le,D]),st=b.useCallback((Z,ve)=>{Fe({kind:"web",url:Z},ve)},[Fe]),lt=b.useCallback((Z,ve,Re)=>{Fe({kind:"visualization",sessionId:Z,file:ve},Re)},[Fe]),Nt=b.useCallback(Z=>{st(Z,me)},[me,st]),kt=b.useCallback(Z=>{xe&<(xe,Z,me)},[xe,me,lt]),{isActive:xt,isCancelling:It}=sl(xe??"",be?.status),Et=b.useMemo(()=>!ie||!D?!1:!D.some(ve=>ve.status==="ACTIVE"&&ve.sessions?.some(Re=>Re.id===ie.id)),[ie,D]),{data:Mt}=Gs(),[$t,er]=b.useState(null),Ut=$t?.sessionId===ae?$t.providerId:ie?.providerId??null,yt=ie?ul(Mt,Ut):void 0,ji=b.useCallback(Z=>{er({sessionId:ae,providerId:Z})},[ae]),Qt=rl({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:M,minHeight:40,maxHeight:140}),Zt=Vc({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:M,minHeight:40,maxHeight:140}),rs=We&&Se?Se.id:void 0,bs=Ln(),Ms=Yn(),rt=nl(),{isConnected:tr,isLoadingSnapshot:Ar,isOutputActive:Tr,lastExitAt:Mr,logs:it,entries:Ds,attach:_s}=cl({sessionId:Ce,sessionStatus:be?.status,sessionStartedAt:be?.startedAt??be?.createdAt,sessionEndedAt:be?.endedAt??(xt?null:be?.updatedAt),onExit:b.useCallback(()=>{O.invalidateQueries({queryKey:["workspaces"]})},[O])}),{todos:Jt}=dl(Ds),{files:Dr,addFiles:ys,removeFile:Pr,clear:sr,buildMarkdownLinks:Ps,hasFiles:Ot,isUploading:is}=En(),Ni=b.useMemo(()=>zc(be),[be?.tokenUsage]),Ls=il(it,Ni);b.useEffect(()=>{Ce&&tr&&_s()},[Ce,tr,_s]);const Lr=b.useRef(null);b.useEffect(()=>{if(Lr.current!==e.id&&B.current){const Z=B.current;requestAnimationFrame(()=>{Z.scrollTop=Z.scrollHeight})}Lr.current=e.id},[e.id,B]);const rr=b.useRef(!1),ir=b.useCallback(async()=>{if(!c.trim()&&!Ot||!ae||rr.current||rt.isPending||It||is||yt)return;rr.current=!0;const Z=Ps(),ve=[c.trim(),Z].filter(Boolean).join(`
|
|
86
|
-
|
|
87
|
-
`);g(""),sr(),M.current&&(M.current.style.height="40px"),bs.mutate({id:ae,message:ve,providerId:Ut??void 0},{onSuccess:()=>_s(),onError:()=>g(Re=>Re||ve),onSettled:()=>{rr.current=!1}})},[c,ae,bs,_s,Ot,is,Ps,sr,Ut,yt,rt.isPending,It]),Ri=b.useCallback(()=>{!ae||rt.isPending||rt.mutate(ae)},[ae,rt]),Is=b.useCallback(Z=>N.mutateAsync(Z),[N]),Ir=b.useCallback(Z=>{S(Z),h("chat"),requestAnimationFrame(()=>{q()})},[q]),ns=b.useCallback(()=>{S(null)},[]),Or=b.useCallback(()=>{h("changes")},[]),nr=Oe&&Ee?t.jsx(qc,{workspaceId:Ee,branchName:at,targetBranch:Ne,commitMessage:Me,changes:De,gitStatus:Ue,isGitStatusLoading:qe,canRunGitOperations:He,onOpenChanges:Or,onRefreshCommitMessage:Y,onConflict:we,className:"mb-2"}):null,Br=b.useCallback(Z=>{const ve=Z.target.files;ve&&ve.length>0&&ys(Array.from(ve)),Z.target.value=""},[ys]),Fr=b.useCallback(Z=>{const ve=Z.clipboardData.items,Re=[];for(const ze of ve)if(ze.kind==="file"){const St=ze.getAsFile();St&&Re.push(St)}Re.length>0&&(Z.preventDefault(),ys(Re))},[ys]),Ss=b.useCallback(Z=>{g(Z.target.value);const ve=Z.target;ve.style.height="auto",ve.style.height=`${Math.max(40,Math.min(ve.scrollHeight,140))}px`},[]),Ai=b.useCallback(()=>{rs&&Ms.mutate({workspaceId:rs})},[Ms,rs]),qt=b.useRef(null);return b.useEffect(()=>{const Z=window.visualViewport;if(!Z)return;let ve=!1;const Re=()=>{qt.current&&(qt.current.style.height=`${Z.height}px`,qt.current.style.top=`${Z.offsetTop}px`)},ze=()=>Re(),St=()=>{ve||Re()},Bt=()=>{ve=!0},Le=()=>{ve=!1,requestAnimationFrame(Re)};return Z.addEventListener("resize",ze),Z.addEventListener("scroll",St),document.addEventListener("touchstart",Bt,{passive:!0}),document.addEventListener("touchend",Le,{passive:!0}),document.addEventListener("touchcancel",Le,{passive:!0}),()=>{Z.removeEventListener("resize",ze),Z.removeEventListener("scroll",St),document.removeEventListener("touchstart",Bt),document.removeEventListener("touchend",Le),document.removeEventListener("touchcancel",Le)}},[]),b.useEffect(()=>{const Z=qt.current;if(!Z)return;const ve=Re=>{let ze=Re.target;for(;ze&&ze!==Z;){if(ze.tagName==="TEXTAREA"){if(ze.scrollHeight>ze.clientHeight)return;ze=ze.parentElement;continue}const Bt=window.getComputedStyle(ze).overflowY;if((Bt==="auto"||Bt==="scroll")&&ze.scrollHeight>ze.clientHeight)return;ze=ze.parentElement}Re.preventDefault()};return Z.addEventListener("touchmove",ve,{passive:!1}),()=>Z.removeEventListener("touchmove",ve)},[]),t.jsxs("div",{ref:qt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Ks,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(Xc,{taskId:e.id,title:e.title,readOnly:he,titleClassName:"text-[13px] font-bold text-neutral-900 truncate leading-tight",compact:!0}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(Ox,{status:e.status}),t.jsx(ol,{value:e.priority,compact:!0,onChange:!he&&o?Z=>o(e.id,Z):void 0}),t.jsx("button",{onClick:Ai,disabled:!rs||he,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(mi,{size:16})}),r&&!he&&t.jsxs("div",{className:"relative",ref:P,children:[t.jsx("button",{onClick:()=>d(Z=>!Z),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(pl,{size:16})}),u&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{l(!0),d(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(On,{size:15}),t.jsx("span",{children:i("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:X.map(({key:Z,label:ve,icon:Re})=>t.jsxs("button",{onClick:()=>h(Z),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${a===Z?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Re,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:i(ve)})]},Z))})]}),a==="chat"&&(F?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:f?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:i("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Wc,{session:be,providers:Mt,usage:Ls,compact:!0,providerIdFallback:Je?.providerId,agentTypeFallback:be?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ae,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:ns,children:[t.jsx(Ks,{size:12}),t.jsx("span",{children:i("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:B,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:I,children:Ar?t.jsx(rn,{label:i("Loading logs...")}):it.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:i(xt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Qr,{children:t.jsx(Yr,{logs:it,downloadSessionId:xe,isOutputActive:Tr,lastExitAt:Mr,onUserToggleDetails:A,scrollElementRef:B,onOpenPreviewUrl:Nt,onOpenVisualization:kt})})})}),!H&&t.jsxs("button",{onClick:()=>q(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(vr,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Jt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Zr,{todos:Jt,compact:!0})})]}):t.jsx(Kl,{teamRun:F,messages:$??F.messages??[],readOnly:he,readOnlyMessage:ne,onSendMessage:Is,onViewInvocationSession:Ir,changeSummaryBar:nr,compactComposer:!0,workingDir:We,onOpenPreviewUrl:st,onOpenVisualization:lt})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:B,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:I,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:pe?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:i("Loading...")}):G?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(Nn,{urlTransform:Ix,components:Xa,children:G.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!he&&t.jsx(Kc,{state:U,setupProgress:K,sessionStarted:!!ie?.startedAt,onRetry:ae&&m?.status==="failed"?async()=>{await ee(),_(!0)}:void 0,compact:!0},e.id),L?(!z||he)&&t.jsx(rn,{label:"Loading..."}):ae?Ar?t.jsx(rn,{label:"Loading logs..."}):it.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:xt?"Waiting for agent output...":"No logs recorded."}):t.jsx(Qr,{children:t.jsx(Yr,{logs:it,downloadSessionId:xe,isOutputActive:Tr,lastExitAt:Mr,onUserToggleDetails:A,scrollElementRef:B,onOpenPreviewUrl:Nt,onOpenVisualization:kt})}):!z||m?.status==="failed"||K?.status==="failed"||he?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(!z||he)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(ks,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:i("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:he?ne:i("选择一个 Agent 来执行此任务")})]}),!he&&(!m||m.status==="failed")&&t.jsxs(Ae,{onClick:async()=>{await ee(),_(!0)},disabled:!!(m&&m.status!=="failed"),children:[t.jsx(ks,{size:16,className:"mr-1.5"}),m?.status==="failed"?i("重试启动 Agent"):i("启动 Agent")]})]}):null]})}),!H&&t.jsxs("button",{onClick:()=>q(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(vr,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Jt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(Zr,{todos:Jt,compact:!0})}),he?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ne})}):Et?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:i("代码已合并,以上为历史沟通记录")}),t.jsxs(Ae,{size:"sm",onClick:async()=>{await ee(),_(!0)},children:[t.jsx(ks,{size:14,className:"mr-1.5"}),i("启动新 Agent")]})]})}):ae&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[nr,t.jsx(al,{sessionId:Ce||ae,compact:!0}),t.jsxs("div",{ref:R,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(jn,{files:Dr,onRemove:Pr}),t.jsx("textarea",{ref:M,value:c,onChange:Ss,onPaste:Fr,onKeyDown:Z=>{Zt.handleKeyDown(Z)||Qt.handleKeyDown(Z)||Z.key==="Enter"&&!Z.shiftKey&&!Z.repeat&&!Z.nativeEvent.isComposing&&Z.nativeEvent.keyCode!==229&&(Z.preventDefault(),ir())},rows:1,placeholder:xt?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:Br}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(In,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ie&&Mt&&t.jsx(ll,{providers:Mt,currentProviderId:Ut,agentType:ie.agentType,runtimeType:ie.runtimeType,onSelect:ji}),t.jsx(Pn,{usage:Ls}),xt&&!c.trim()&&!Ot?t.jsx("button",{onClick:Ri,disabled:rt.isPending||It,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(qs,{size:12})}):t.jsx("button",{onClick:ir,disabled:!c.trim()&&!Ot||is||bs.isPending||rt.isPending||It||!!yt,className:`p-1.5 rounded-lg transition-colors ${(c.trim()||Ot)&&!is&&!bs.isPending&&!rt.isPending&&!It&&!yt?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Mn,{size:15})})]})]})]}),t.jsx(Gr,{open:Qt.query!==null,anchorRef:R,commands:Qt.filteredCommands,selectedIndex:Qt.selectedIndex,query:Qt.query??"",hasCatalog:Qt.allCommands.length>0,compact:!0,onSelect:Qt.applyCommand}),t.jsx(Gr,{open:Zt.query!==null,anchorRef:R,commands:Zt.filteredSkills,selectedIndex:Zt.selectedIndex,query:Zt.query??"",hasCatalog:Zt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Zt.applySkill})]})]})),a==="team-status"&&F&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(Zl,{teamRun:F,workspaces:D,selectedWorkspaceId:le,onSelectWorkspace:k,onViewInvocationSession:Ir})}),a==="changes"&&V&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[D&&D.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Ic,{workspaces:D,teamRun:F,selectedWorkspaceId:le,onSelectWorkspace:k,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),He&&Ee&&t.jsx("div",{className:"shrink-0",children:t.jsx(Ac,{workspaceId:Ee,branchName:at,targetBranch:Ne,commitMessage:Me,committedFileCount:Ge,onRefreshCommitMessage:Y,onConflict:we,onResolveConflicts:()=>we()})}),t.jsx(jx,{workingDir:We})]}),a==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(Px,{workingDir:We})}),a==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Oc,{sessionId:ae||void 0,workspaceId:le,workingDir:We,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:V,readOnly:he,repoDeleted:re,previewRequest:y,onPreviewRequestHandled:Z=>{j(ve=>ve?.id===Z?void 0:ve)}})}),!he&&t.jsx(Fc,{isOpen:v,onClose:()=>_(!1),taskId:e.id,projectId:e.projectId,taskTitle:G?.title??e.title,taskDescription:G?.body??"",taskPrompt:G?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>x?.(e.id)}),t.jsx(Zn,{isOpen:w,onClose:()=>l(!1),onConfirm:()=>{r?.(e.id),l(!1)},taskId:e.id,taskTitle:e.title,workspaces:D,isLoading:p}),Qe&&Ye&&$e&&t.jsx(Uc,{open:Qe,onOpenChange:Z=>{Te(Z),Z||et(null)},workspaceId:$e,conflictOp:Ye.conflictOp,conflictedFiles:Ye.conflictedFiles,sourceBranch:tt,targetBranch:J,operation:Ue?.operation,worktreePath:ft,mergeAborted:Ye.mergeAborted,mergeStrategy:Ye.mergeStrategy,sourceWorkspaceId:Ye.sourceWorkspaceId,targetWorkspaceId:Ye.targetWorkspaceId,sourceWorktreePath:Ye.sourceWorktreePath,targetWorktreePath:Ye.targetWorktreePath,sessions:fe,currentSessionId:F?void 0:ae,teamRunId:F?.id})]})}function rn({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var Wx=Object.defineProperty,di=Object.getOwnPropertySymbols,Gc=Object.prototype.hasOwnProperty,Qc=Object.prototype.propertyIsEnumerable,Ra=(e,s,r)=>s in e?Wx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Sn=(e,s)=>{for(var r in s||(s={}))Gc.call(s,r)&&Ra(e,r,s[r]);if(di)for(var r of di(s))Qc.call(s,r)&&Ra(e,r,s[r]);return e},wn=(e,s)=>{var r={};for(var o in e)Gc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&di)for(var o of di(e))s.indexOf(o)<0&&Qc.call(e,o)&&(r[o]=e[o]);return r};var Ns;(e=>{const s=class je{constructor(n,a,h,c){if(this.version=n,this.errorCorrectionLevel=a,this.modules=[],this.isFunction=[],n<je.MIN_VERSION||n>je.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let g=[];for(let _=0;_<this.size;_++)g.push(!1);for(let _=0;_<this.size;_++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(h);if(this.drawCodewords(v),c==-1){let _=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const l=this.getPenaltyScore();l<_&&(c=w,_=l),this.applyMask(w)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(n,a){const h=e.QrSegment.makeSegments(n);return je.encodeSegments(h,a)}static encodeBinary(n,a){const h=e.QrSegment.makeBytes(n);return je.encodeSegments([h],a)}static encodeSegments(n,a,h=1,c=40,g=-1,v=!0){if(!(je.MIN_VERSION<=h&&h<=c&&c<=je.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let _,w;for(_=h;;_++){const f=je.getNumDataCodewords(_,a)*8,S=x.getTotalBits(n,_);if(S<=f){w=S;break}if(_>=c)throw new RangeError("Data too long")}for(const f of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])v&&w<=je.getNumDataCodewords(_,f)*8&&(a=f);let l=[];for(const f of n){r(f.mode.modeBits,4,l),r(f.numChars,f.mode.numCharCountBits(_),l);for(const S of f.getData())l.push(S)}p(l.length==w);const u=je.getNumDataCodewords(_,a)*8;p(l.length<=u),r(0,Math.min(4,u-l.length),l),r(0,(8-l.length%8)%8,l),p(l.length%8==0);for(let f=236;l.length<u;f^=253)r(f,8,l);let d=[];for(;d.length*8<l.length;)d.push(0);return l.forEach((f,S)=>d[S>>>3]|=f<<7-(S&7)),new je(_,a,d,g)}getModule(n,a){return 0<=n&&n<this.size&&0<=a&&a<this.size&&this.modules[a][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let h=0;h<this.size;h++)this.setFunctionModule(6,h,h%2==0),this.setFunctionModule(h,6,h%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),a=n.length;for(let h=0;h<a;h++)for(let c=0;c<a;c++)h==0&&c==0||h==0&&c==a-1||h==a-1&&c==0||this.drawAlignmentPattern(n[h],n[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const a=this.errorCorrectionLevel.formatBits<<3|n;let h=a;for(let g=0;g<10;g++)h=h<<1^(h>>>9)*1335;const c=(a<<10|h)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let h=0;h<12;h++)n=n<<1^(n>>>11)*7973;const a=this.version<<12|n;p(a>>>18==0);for(let h=0;h<18;h++){const c=o(a,h),g=this.size-11+h%3,v=Math.floor(h/3);this.setFunctionModule(g,v,c),this.setFunctionModule(v,g,c)}}drawFinderPattern(n,a){for(let h=-4;h<=4;h++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(h)),v=n+c,_=a+h;0<=v&&v<this.size&&0<=_&&_<this.size&&this.setFunctionModule(v,_,g!=2&&g!=4)}}drawAlignmentPattern(n,a){for(let h=-2;h<=2;h++)for(let c=-2;c<=2;c++)this.setFunctionModule(n+c,a+h,Math.max(Math.abs(c),Math.abs(h))!=1)}setFunctionModule(n,a,h){this.modules[a][n]=h,this.isFunction[a][n]=!0}addEccAndInterleave(n){const a=this.version,h=this.errorCorrectionLevel;if(n.length!=je.getNumDataCodewords(a,h))throw new RangeError("Invalid argument");const c=je.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][a],g=je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][a],v=Math.floor(je.getNumRawDataModules(a)/8),_=c-v%c,w=Math.floor(v/c);let l=[];const u=je.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=n.slice(S,S+w-g+(f<_?0:1));S+=C.length;const k=je.reedSolomonComputeRemainder(C,u);f<_&&C.push(0),l.push(C.concat(k))}let d=[];for(let f=0;f<l[0].length;f++)l.forEach((S,C)=>{(f!=w-g||C>=_)&&d.push(S[f])});return p(d.length==v),d}drawCodewords(n){if(n.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let a=0;for(let h=this.size-1;h>=1;h-=2){h==6&&(h=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const v=h-g,w=(h+1&2)==0?this.size-1-c:c;!this.isFunction[w][v]&&a<n.length*8&&(this.modules[w][v]=o(n[a>>>3],7-(a&7)),a++)}}p(a==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let a=0;a<this.size;a++)for(let h=0;h<this.size;h++){let c;switch(n){case 0:c=(h+a)%2==0;break;case 1:c=a%2==0;break;case 2:c=h%3==0;break;case 3:c=(h+a)%3==0;break;case 4:c=(Math.floor(h/3)+Math.floor(a/2))%2==0;break;case 5:c=h*a%2+h*a%3==0;break;case 6:c=(h*a%2+h*a%3)%2==0;break;case 7:c=((h+a)%2+h*a%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[a][h]&&c&&(this.modules[a][h]=!this.modules[a][h])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let v=!1,_=0,w=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[g][l]==v?(_++,_==5?n+=je.PENALTY_N1:_>5&&n++):(this.finderPenaltyAddHistory(_,w),v||(n+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[g][l],_=1);n+=this.finderPenaltyTerminateAndCount(v,_,w)*je.PENALTY_N3}for(let g=0;g<this.size;g++){let v=!1,_=0,w=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[l][g]==v?(_++,_==5?n+=je.PENALTY_N1:_>5&&n++):(this.finderPenaltyAddHistory(_,w),v||(n+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[l][g],_=1);n+=this.finderPenaltyTerminateAndCount(v,_,w)*je.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let v=0;v<this.size-1;v++){const _=this.modules[g][v];_==this.modules[g][v+1]&&_==this.modules[g+1][v]&&_==this.modules[g+1][v+1]&&(n+=je.PENALTY_N2)}let a=0;for(const g of this.modules)a=g.reduce((v,_)=>v+(_?1:0),a);const h=this.size*this.size,c=Math.ceil(Math.abs(a*20-h*10)/h)-1;return p(0<=c&&c<=9),n+=c*je.PENALTY_N4,p(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,a=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let h=[6];for(let c=this.size-7;h.length<n;c-=a)h.splice(1,0,c);return h}}static getNumRawDataModules(n){if(n<je.MIN_VERSION||n>je.MAX_VERSION)throw new RangeError("Version number out of range");let a=(16*n+128)*n+64;if(n>=2){const h=Math.floor(n/7)+2;a-=(25*h-10)*h-55,n>=7&&(a-=36)}return p(208<=a&&a<=29648),a}static getNumDataCodewords(n,a){return Math.floor(je.getNumRawDataModules(n)/8)-je.ECC_CODEWORDS_PER_BLOCK[a.ordinal][n]*je.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let a=[];for(let c=0;c<n-1;c++)a.push(0);a.push(1);let h=1;for(let c=0;c<n;c++){for(let g=0;g<a.length;g++)a[g]=je.reedSolomonMultiply(a[g],h),g+1<a.length&&(a[g]^=a[g+1]);h=je.reedSolomonMultiply(h,2)}return a}static reedSolomonComputeRemainder(n,a){let h=a.map(c=>0);for(const c of n){const g=c^h.shift();h.push(0),a.forEach((v,_)=>h[_]^=je.reedSolomonMultiply(v,g))}return h}static reedSolomonMultiply(n,a){if(n>>>8||a>>>8)throw new RangeError("Byte out of range");let h=0;for(let c=7;c>=0;c--)h=h<<1^(h>>>7)*285,h^=(a>>>c&1)*n;return p(h>>>8==0),h}finderPenaltyCountPatterns(n){const a=n[1];p(a<=this.size*3);const h=a>0&&n[2]==a&&n[3]==a*3&&n[4]==a&&n[5]==a;return(h&&n[0]>=a*4&&n[6]>=a?1:0)+(h&&n[6]>=a*4&&n[0]>=a?1:0)}finderPenaltyTerminateAndCount(n,a,h){return n&&(this.finderPenaltyAddHistory(a,h),a=0),a+=this.size,this.finderPenaltyAddHistory(a,h),this.finderPenaltyCountPatterns(h)}finderPenaltyAddHistory(n,a){a[0]==0&&(n+=this.size),a.pop(),a.unshift(n)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(i,n,a){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let h=n-1;h>=0;h--)a.push(i>>>h&1)}function o(i,n){return(i>>>n&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class nt{constructor(n,a,h){if(this.mode=n,this.numChars=a,this.bitData=h,a<0)throw new RangeError("Invalid argument");this.bitData=h.slice()}static makeBytes(n){let a=[];for(const h of n)r(h,8,a);return new nt(nt.Mode.BYTE,n.length,a)}static makeNumeric(n){if(!nt.isNumeric(n))throw new RangeError("String contains non-numeric characters");let a=[];for(let h=0;h<n.length;){const c=Math.min(n.length-h,3);r(parseInt(n.substring(h,h+c),10),c*3+1,a),h+=c}return new nt(nt.Mode.NUMERIC,n.length,a)}static makeAlphanumeric(n){if(!nt.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let a=[],h;for(h=0;h+2<=n.length;h+=2){let c=nt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h))*45;c+=nt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h+1)),r(c,11,a)}return h<n.length&&r(nt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h)),6,a),new nt(nt.Mode.ALPHANUMERIC,n.length,a)}static makeSegments(n){return n==""?[]:nt.isNumeric(n)?[nt.makeNumeric(n)]:nt.isAlphanumeric(n)?[nt.makeAlphanumeric(n)]:[nt.makeBytes(nt.toUtf8ByteArray(n))]}static makeEci(n){let a=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,a);else if(n<16384)r(2,2,a),r(n,14,a);else if(n<1e6)r(6,3,a),r(n,21,a);else throw new RangeError("ECI assignment value out of range");return new nt(nt.Mode.ECI,0,a)}static isNumeric(n){return nt.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return nt.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,a){let h=0;for(const c of n){const g=c.mode.numCharCountBits(a);if(c.numChars>=1<<g)return 1/0;h+=4+g+c.bitData.length}return h}static toUtf8ByteArray(n){n=encodeURI(n);let a=[];for(let h=0;h<n.length;h++)n.charAt(h)!="%"?a.push(n.charCodeAt(h)):(a.push(parseInt(n.substring(h+1,h+3),16)),h+=2);return a}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let x=m;e.QrSegment=m})(Ns||(Ns={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(Ns||(Ns={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(Ns||(Ns={}));var $s=Ns;var Hx={L:$s.QrCode.Ecc.LOW,M:$s.QrCode.Ecc.MEDIUM,Q:$s.QrCode.Ecc.QUARTILE,H:$s.QrCode.Ecc.HIGH},Zc=128,Jc="L",ed="#FFFFFF",td="#000000",sd=!1,rd=1,$x=4,Ux=0,qx=.1;function id(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(x,i){if(!x&&m!==null){r.push(`M${m+s} ${p+s}h${i-m}v1H${m+s}z`),m=null;return}if(i===o.length-1){if(!x)return;m===null?r.push(`M${i+s},${p+s} h1v1H${i+s}z`):r.push(`M${m+s},${p+s} h${i+1-m}v1H${m+s}z`);return}x&&m===null&&(m=i)})}),r.join("")}function nd(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function Kx(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*qx),x=p/s,i=(o.width||m)*x,n=(o.height||m)*x,a=o.x==null?e.length/2-i/2:o.x*x,h=o.y==null?e.length/2-n/2:o.y*x,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let _=Math.floor(a),w=Math.floor(h),l=Math.ceil(i+a-_),u=Math.ceil(n+h-w);g={x:_,y:w,w:l,h:u}}const v=o.crossOrigin;return{x:a,y:h,h:n,w:i,excavation:g,opacity:c,crossOrigin:v}}function Vx(e,s){return s!=null?Math.max(Math.floor(s),0):e?$x:Ux}function od({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:x,boostLevel:i}){let n=ue.useMemo(()=>{const _=(Array.isArray(e)?e:[e]).reduce((w,l)=>(w.push(...$s.QrSegment.makeSegments(l)),w),[]);return $s.QrCode.encodeSegments(_,Hx[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:a,margin:h,numCells:c,calculatedImageSettings:g}=ue.useMemo(()=>{let v=n.getModules();const _=Vx(o,p),w=v.length+_*2,l=Kx(v,x,_,m);return{cells:v,margin:_,numCells:w,calculatedImageSettings:l}},[n,x,m,o,p]);return{qrcode:n,margin:h,cells:a,numCells:c,calculatedImageSettings:g}}var Xx=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),Yx=ue.forwardRef(function(s,r){const o=s,{value:p,size:m=Zc,level:x=Jc,bgColor:i=ed,fgColor:n=td,includeMargin:a=sd,minVersion:h=rd,boostLevel:c,marginSize:g,imageSettings:v}=o,w=wn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:l}=w,u=wn(w,["style"]),d=v?.src,f=ue.useRef(null),S=ue.useRef(null),C=ue.useCallback(B=>{f.current=B,typeof r=="function"?r(B):r&&(r.current=B)},[r]),[k,E]=ue.useState(!1),{margin:y,cells:j,numCells:R,calculatedImageSettings:P}=od({value:p,level:x,minVersion:h,boostLevel:c,includeMargin:a,marginSize:g,imageSettings:v,size:m});ue.useEffect(()=>{if(f.current!=null){const B=f.current,I=B.getContext("2d");if(!I)return;let H=j;const q=S.current,A=P!=null&&q!==null&&q.complete&&q.naturalHeight!==0&&q.naturalWidth!==0;A&&P.excavation!=null&&(H=nd(j,P.excavation));const O=window.devicePixelRatio||1;B.height=B.width=m*O;const D=m/R*O;I.scale(D,D),I.fillStyle=i,I.fillRect(0,0,R,R),I.fillStyle=n,Xx?I.fill(new Path2D(id(H,y))):j.forEach(function(L,K){L.forEach(function(U,z){U&&I.fillRect(z+y,K+y,1,1)})}),P&&(I.globalAlpha=P.opacity),A&&I.drawImage(q,P.x+y,P.y+y,P.w,P.h)}}),ue.useEffect(()=>{E(!1)},[d]);const M=Sn({height:m,width:m},l);let T=null;return d!=null&&(T=ue.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:S,crossOrigin:P?.crossOrigin})),ue.createElement(ue.Fragment,null,ue.createElement("canvas",Sn({style:M,height:m,width:m,ref:C,role:"img"},u)),T)});Yx.displayName="QRCodeCanvas";var ad=ue.forwardRef(function(s,r){const o=s,{value:p,size:m=Zc,level:x=Jc,bgColor:i=ed,fgColor:n=td,includeMargin:a=sd,minVersion:h=rd,boostLevel:c,title:g,marginSize:v,imageSettings:_}=o,w=wn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:l,cells:u,numCells:d,calculatedImageSettings:f}=od({value:p,level:x,minVersion:h,boostLevel:c,includeMargin:a,marginSize:v,imageSettings:_,size:m});let S=u,C=null;_!=null&&f!=null&&(f.excavation!=null&&(S=nd(u,f.excavation)),C=ue.createElement("image",{href:_.src,height:f.h,width:f.w,x:f.x+l,y:f.y+l,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=id(S,l);return ue.createElement("svg",Sn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&ue.createElement("title",null,g),ue.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ue.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),C)});ad.displayName="QRCodeSVG";function ld(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function Gx(){return jt({queryKey:ce.tunnel.status,queryFn:()=>ye.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function Qx(){const e=vt();return Ht({mutationFn:()=>ye.post("/tunnel/start",{port:ld()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Zx(){const e=vt();return Ht({mutationFn:()=>ye.post("/tunnel/regenerate",{port:ld()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function Jx(){const e=vt();return Ht({mutationFn:()=>ye.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function eb(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function tb(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function sb(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function Aa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function cr(e){const s=e?.trim();return s||null}function rb(e){if(!e)return"";const s=[cr(e.lastLocalError),cr(e.lastRemoteError),cr(e.lastError)].filter(p=>p!==null),r=cr(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!cr(e.lastError));return r&&o&&s.push(r),s.join(`
|
|
88
|
-
`)}function Ta(){const{t:e}=de(),{data:s}=Gx(),r=Qx(),o=Jx(),p=Zx(),[m,x]=b.useState(!1),[i,n]=b.useState(null),a=b.useRef(null),[h,c]=b.useState({top:0,right:0}),[g,v]=b.useState(!1),[_,w]=b.useState(!1),l=s?.status!==void 0&&s.status!=="stopped",u=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,S=s?.token,C=eb(s),k=tb(s),E=rb(s);b.useEffect(()=>{if(m&&a.current){const B=a.current.getBoundingClientRect();c({top:B.bottom+8,right:window.innerWidth-B.right})}},[m]);const y=b.useCallback(()=>{x(!0)},[l]),j=b.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>x(!0)})},[r]),R=b.useCallback(()=>{f&&(navigator.clipboard.writeText(f),n("url"),setTimeout(()=>n(null),2e3))},[f]),P=b.useCallback(()=>{S&&(navigator.clipboard.writeText(S),n("token"),setTimeout(()=>n(null),2e3))},[S]),M=b.useCallback(()=>{o.mutate(),x(!1),v(!1),w(!1)},[o]),T=b.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{w(!1),x(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:a,onClick:y,disabled:u,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:u?t.jsx(Be,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(As,{size:16}):t.jsx(Co,{size:16})}),l&&!u&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!l&&Cs.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:h.top,right:h.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(Co,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Yt,{size:14})})]}),t.jsxs("button",{onClick:j,disabled:u,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[u&&t.jsx(Be,{size:13,className:"animate-spin"}),e(u?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&l&&Cs.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:h.top,right:h.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(sb(s))})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Yt,{size:14})})]}),S&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(eu,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(ad,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:B=>B.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:i==="url"?t.jsx(Gt,{size:14,className:"text-emerald-500"}):t.jsx(So,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Aa(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Aa(s?.lastHealthyAt)})]})]}),E&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:E}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),S&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>v(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:S}),t.jsx("button",{onClick:P,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:i==="token"?t.jsx(Gt,{size:14,className:"text-emerald-500"}):t.jsx(So,{size:14})})]})]}),_&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:T,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!_&&t.jsxs("button",{onClick:()=>w(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(Ts,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:M,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function nn({isOpen:e,onClose:s}){const{t:r}=de(),o=cu(),[p,m]=b.useState(""),[x,i]=b.useState(""),[n,a]=b.useState(null),[h,c]=b.useState(!1),[g,v]=b.useState(!1),_=p.trim(),w=x.trim(),l=h||o.isPending,u=b.useMemo(()=>!!(_&&w&&!l),[_,w,l]),d=b.useCallback(()=>{m(""),i(""),a(null),v(!1)},[]),f=b.useCallback(()=>{l||(d(),s())},[l,s,d]);b.useEffect(()=>{e||d()},[e,d]);const S=b.useCallback(async y=>{try{await o.mutateAsync({name:_,repoPath:w,initEmptyRepo:y}),d(),s()}catch(j){const R=j instanceof Error?j.message:r("Failed to create project");a(R),ot.error(R)}},[o,s,d,r,_,w]),C=b.useCallback(async()=>{if(!(!_||!w||l)){a(null),c(!0);try{const y=await ye.get("/filesystem/validate",{params:{path:w}});if(!y.valid){a(y.error??r("Selected path is not a valid directory"));return}if(y.isGitRepo){await S(!1);return}if(y.reason==="no_git"&&y.isEmpty){v(!0);return}if(y.reason==="no_git"){await S(!1);return}await S(!1)}catch(y){a(y instanceof Error?y.message:r("Could not check project path"))}finally{c(!1)}}},[S,l,r,_,w]),k=b.useCallback(()=>{v(!1),S(!1)},[S]),E=b.useCallback(()=>{v(!1),S(!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx(gs,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!u,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${u?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:h?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:y=>m(y.target.value),placeholder:r("e.g., Agent Tower"),disabled:l,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(ru,{value:x,onChange:i,validationMode:"directory"})]}),n&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),t.jsx(gs,{isOpen:g,onClose:()=>{o.isPending||v(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:E,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function Ma(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function ib(e){return e.map((s,r)=>({project:s,index:r,activityTime:Ma(s.lastActivityAt??s.createdAt),createdTime:Ma(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const p=r.createdTime-s.createdTime;return p!==0?p:s.index-r.index}).map(({project:s})=>s)}function Da({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=de(),[x,i]=b.useState(!1),n=e.filter(h=>!h.archivedAt),a=s?e.find(h=>h.id===s)??null:null;return t.jsxs("div",{className:se("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>i(h=>!h),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[a?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${a.color.replace("text-","bg-")}`}):t.jsx(Vs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:a?a.name:m("All Projects")}),t.jsx(wt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${x?"rotate-180":""}`})]}),x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>i(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Vs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(Gt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:n.map(h=>{const c=s===h.id;return t.jsxs("button",{onClick:()=>{r(h.id),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${h.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:h.name}),c?t.jsx(Gt,{size:14,className:"text-foreground shrink-0"}):null]},h.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{i(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(us,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}function Pa(){return t.jsx("div",{className:"px-4 pt-6 space-y-5 animate-pulse","aria-hidden":!0,children:Array.from({length:6}).map((e,s)=>t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("div",{className:"w-4 h-4 rounded-full bg-muted shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1 space-y-2",children:[t.jsx("div",{className:"h-3 rounded bg-muted",style:{width:`${70-s%3*12}%`}}),t.jsx("div",{className:"h-2.5 rounded bg-muted/70",style:{width:`${45+s%2*18}%`}})]})]},s))})}const nb=260,ob=600,La=400,ab=100,lb=1e3;function cb(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,priority:e.priority,...s?{preferredWorkspace:{...s.workspaceKind===bt.MAIN_DIRECTORY?{workspaceKind:bt.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(p=>p.status==="RUNNING"||p.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function db(){const{t:e,locale:s}=de(),[r,o]=b.useState(null),[p,m]=b.useState(null),[x,i]=b.useState(La),[n,a]=b.useState(!1),[h,c]=b.useState("idle"),[g,v]=b.useState({}),_=b.useRef(!1),w=b.useRef(0),l=b.useRef(La),u=b.useRef(null),d=vt(),{data:f,isLoading:S}=Gs(),{data:C,isLoading:k}=du({limit:ab}),E=b.useMemo(()=>C?.data??[],[C?.data]),y=p&&E.some(J=>J.id===p)?p:null,{data:j,isLoading:R}=Od({...y?{projectId:y}:{},limit:lb}),P=b.useMemo(()=>j?.data??[],[j?.data]),[M,T]=b.useState([]),B=b.useMemo(()=>{if(M.length===0)return P;const J=new Set(P.map(fe=>fe.id));return[...M.filter(fe=>!J.has(fe.id)),...P]},[P,M]),[I,H]=b.useState(null),q=b.useMemo(()=>r&&B.some(J=>J.id===r)?r:I&&r===I?I:null,[r,B,I]);b.useEffect(()=>{I&&B.some(J=>J.id===I)&&H(null)},[I,B]),b.useEffect(()=>{if(M.length===0)return;const J=new Set(P.map(fe=>fe.id));M.some(fe=>J.has(fe.id))&&T(fe=>fe.filter(we=>!J.has(we.id)))},[P,M]);const A=b.useMemo(()=>ib(E),[E]),O=b.useMemo(()=>A.map(_x),[A]),D=b.useMemo(()=>A.filter(J=>!J.archivedAt),[A]),L=b.useMemo(()=>{if(!f)return[];const J=localStorage.getItem("providerUsageCount"),fe=J?JSON.parse(J):{};return[...f].sort((we,Y)=>{const ee=we.availability.type!=="NOT_FOUND",ie=Y.availability.type!=="NOT_FOUND";if(ee!==ie)return ee?-1:1;const ae=fe[we.provider.id]??0;return(fe[Y.provider.id]??0)-ae})},[f]),K=b.useMemo(()=>B.map(J=>yx(J,E.find(fe=>fe.id===J.projectId))),[E,B]),U=b.useMemo(()=>{if(!q)return null;const J=B.find(we=>we.id===q);if(!J)return null;const fe=E.find(we=>we.id===J.projectId);if(!fe){const we=J.preferredWorkspace?J.preferredWorkspace.workspaceKind===bt.MAIN_DIRECTORY?"Project directory":J.preferredWorkspace.branchName:"—";return{id:J.id,projectId:J.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:J.title,status:lo(J.status),priority:J.priority,branch:we,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return Sx(J,fe)},[q,B,E]),z=Wa(),W=Bd(),$=Fd(),N=Ha(),F=Dn(),V=b.useCallback(J=>{const fe=cb(J);T(we=>we.some(Y=>Y.id===J.id)?we.map(Y=>Y.id===J.id?fe:Y):[fe,...we]),d.setQueryData(ce.tasks.detail(J.id),J),H(J.id),o(J.id)},[d]),X=b.useCallback((J,fe,we)=>{const Y=J.id,ee=[J.title,J.description].filter(Boolean).join(`
|
|
89
|
-
|
|
90
|
-
`),ie=we===bt.WORKTREE?D.find(ae=>ae.id===J.projectId)?.setupScript??null:null;v(ae=>({...ae,[Y]:{status:"creating-workspace",setupScript:ie}})),(async()=>{try{const ae=await ye.post(`/tasks/${Y}/workspaces`,{workspaceKind:we});v(ke=>({...ke,[Y]:{status:"creating-session",setupScript:ie}}));const Ce=await ye.post(`/workspaces/${ae.id}/sessions`,{providerId:fe,prompt:ee});v(ke=>({...ke,[Y]:{status:"starting-session",setupScript:ie}})),await F.mutateAsync(Ce.id),await d.invalidateQueries({queryKey:ce.workspaces.list(Y)}),await d.invalidateQueries({queryKey:ce.workspaces.setupProgress(Y)}),await d.invalidateQueries({queryKey:ce.tasks.all}),v(ke=>{const{[Y]:Pe,...Je}=ke;return Je})}catch(ae){const Ce=ae instanceof Error?ae.message:e("启动 Agent 失败");v(ke=>({...ke,[Y]:{status:"failed",error:Ce,setupScript:ie}})),ot.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ce.workspaces.list(Y)}),d.invalidateQueries({queryKey:ce.tasks.all})}})()},[D,d,F,e]),te=b.useCallback(J=>{v(fe=>{const{[J]:we,...Y}=fe;return Y}),d.invalidateQueries({queryKey:ce.workspaces.list(J)}),d.invalidateQueries({queryKey:ce.tasks.all})},[d]),G=b.useCallback(J=>{W.mutate(J,{onSuccess:()=>{q===J&&o(null),v(fe=>{const{[J]:we,...Y}=fe;return Y}),T(fe=>fe.filter(we=>we.id!==J)),d.invalidateQueries({queryKey:ce.tasks.all})},onError:()=>{ot.error(e("删除任务失败"))}})},[W,q,d,e]),pe=b.useCallback((J,fe)=>{$.mutate({id:J,status:xx(fe)},{onError:()=>{ot.error(e("状态变更失败,该操作不被允许"))}})},[$,e]),he=b.useCallback((J,fe)=>{N.mutate({id:J,priority:fe},{onError:()=>{ot.error(e("优先级变更失败"))}})},[N,e]),re=b.useCallback(J=>{J.preventDefault(),_.current=!0,w.current=J.clientX,l.current=x,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[x]);b.useEffect(()=>{const J=we=>{if(!_.current)return;const Y=we.clientX-w.current,ee=Math.max(nb,Math.min(ob,l.current+Y));i(ee)},fe=()=>{_.current&&(_.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",J),document.addEventListener("mouseup",fe),()=>{document.removeEventListener("mousemove",J),document.removeEventListener("mouseup",fe)}},[]);const ne=b.useCallback(()=>{a(!0)},[]),le=b.useCallback(()=>{if(D.length===0){ot.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[D,e]),Se=b.useCallback(()=>{a(!1)},[]),We=b.useCallback(async J=>{const{title:fe,description:we,projectId:Y,providerId:ee,mode:ie,workspaceMode:ae,teamRunMode:Ce,teamTemplateId:ke,memberPresetIds:Pe,attachmentLinks:Je,priority:be}=J,xe=[we,Je].filter(Boolean).join(`
|
|
91
|
-
|
|
92
|
-
`);let me=null;try{if(c("creating-task"),me=await ye.post(`/projects/${Y}/tasks`,{title:fe,description:xe||void 0,priority:be}),localStorage.setItem("lastSelectedProjectId",Y),ie==="SOLO"&&ee){localStorage.setItem("lastSelectedProviderId",ee);const st=localStorage.getItem("providerUsageCount"),lt=st?JSON.parse(st):{};lt[ee]=(lt[ee]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(lt))}ie==="TEAM"?(c("creating-teamrun"),await z.mutateAsync({taskId:me.id,mode:Ce,...ke?{teamTemplateId:ke}:{},...Pe.length>0?{memberPresetIds:Pe}:{}})):ee&&X(me,ee,ae),y&&Y!==y&&m(null),V(me),c("idle"),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all})}catch(Fe){if(c("idle"),me&&ie==="TEAM"){try{await W.mutateAsync(me.id)}catch{}throw ot.error(e("TeamRun 创建失败,请检查团队配置后重试")),Fe}else if(me)y&&Y!==y&&m(null),V(me),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all});else throw ot.error(Fe instanceof Error?Fe.message:e("Failed to create task")),Fe}},[D,z,X,W,d,e,y,V]),Ee=k||R,He=b.useMemo(()=>D.map(J=>({id:J.id,name:J.name,color:O.find(fe=>fe.id===J.id)?.color,repoPath:J.repoPath,isGitRepo:J.isGitRepo,worktreeReady:J.worktreeReady,reason:J.reason})),[D,O]),at=b.useMemo(()=>L.map(J=>{const fe=ts(J);return{id:J.provider.id,name:J.provider.name,agentType:J.provider.agentType,available:!fe,permissionMode:J.provider.executionPermission,reason:fe}}),[L]),Me=b.useMemo(()=>{if(y&&D.find(fe=>fe.id===y))return y;const J=localStorage.getItem("lastSelectedProjectId");return J&&D.find(fe=>fe.id===J)?J:D[0]?.id??""},[D,y]),[Ne,Oe]=b.useState(Me);b.useEffect(()=>{Oe(Me)},[Me]);const Ue=b.useMemo(()=>D.find(J=>J.id===Ne)?.name??D.find(J=>J.id===Me)?.name??e("Project"),[D,Ne,Me,e]),qe=s==="zh-CN"?`你需要在 ${Ue} 中做点什么?`:`What do you need to do in ${Ue}?`,De=b.useMemo(()=>{const J=localStorage.getItem("lastSelectedProviderId");return J&&L.find(we=>we.provider.id===J&&!ts(we))?J:L.find(we=>!ts(we))?.provider.id??""},[L]),Ge=Ol(),[Qe,Te]=b.useState(!1),{usesIntegratedTitlebar:ge,desktopPlatform:et,hasMacTrafficLights:Ye}=Ia(),$e=ge&&et==="win32",ft=b.useCallback(()=>{if(D.length===0){ot.error(e("没有可用项目,请先创建或恢复项目"));return}Te(!0)},[D,e]),tt=b.useCallback(async J=>{await We(J),Te(!1)},[We]);return Ge?Qe?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Te(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:qe}),t.jsx(_o,{projects:He,providers:at,isProvidersLoading:S,onSubmit:tt,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Oe,createStep:h})]})]}):q&&U?t.jsxs(t.Fragment,{children:[t.jsx(zx,{task:U,onBack:()=>o(null),onDeleteTask:U.projectArchivedAt?void 0:G,onTaskPriorityChange:U.projectArchivedAt?void 0:he,isDeleting:W.isPending,autoStartState:g[U.id]??null,onAutoStartRecovered:te}),t.jsx(nn,{isOpen:n,onClose:Se})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(yo,{}),t.jsx(Da,{projects:O,filterProjectId:y,setFilterProjectId:m,onCreateProject:ne})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Ta,{}),t.jsx("button",{onClick:()=>go.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(po,{size:16})})]})]}),Ee&&K.length===0?t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Pa,{})}):t.jsx(Oo,{tasks:K,projects:O,selectedTaskId:null,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:"100%",onCreateTask:ft,onCreateProject:ne,onTaskStatusChange:pe,onTaskPriorityChange:he})]}),t.jsx(nn,{isOpen:n,onClose:Se})]}):t.jsxs("div",{ref:u,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:se("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",ge&&"app-region-drag",$e&&"pr-[150px]"),children:[t.jsxs("div",{className:se("flex items-center gap-2 min-w-0",Ye&&"pl-[72px]"),children:[t.jsx(yo,{}),t.jsx(Da,{projects:O,filterProjectId:y,setFilterProjectId:m,onCreateProject:ne,className:ge?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:se("flex items-center gap-1",ge&&"app-region-no-drag"),children:[t.jsx("div",{className:ge?"app-region-no-drag":void 0,children:t.jsx(Ta,{})}),t.jsx("button",{onClick:()=>go.getState().openSettings(),className:se("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",ge&&"app-region-no-drag"),children:t.jsx(po,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[Ee&&K.length===0?t.jsx("div",{className:"h-full overflow-hidden flex-shrink-0",style:{width:x},children:t.jsx(Pa,{})}):t.jsx(Oo,{tasks:K,projects:O,selectedTaskId:q,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:x,onCreateTask:le,onCreateProject:ne,isCreateActive:!q,onTaskStatusChange:pe,onDeleteTask:G,onTaskPriorityChange:he}),t.jsx("div",{onMouseDown:re,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:q&&U?t.jsx(vx,{task:U,onDeleteTask:U.projectArchivedAt?void 0:G,isDeleting:W.isPending,onTaskStatusChange:U.projectArchivedAt?void 0:pe,onTaskPriorityChange:U.projectArchivedAt?void 0:he,autoStartState:g[U.id]??null,onAutoStartRecovered:te}):q&&!U?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:qe}),t.jsx(_o,{projects:He,providers:at,isProvidersLoading:S,onSubmit:We,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Oe,createStep:h})]})})})]}),t.jsx(nn,{isOpen:n,onClose:Se})]})}const Bb=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:db},Symbol.toStringTag,{value:"Module"}));export{Bb as P,nc as l};
|